New Year!

I know its been a while since new years eve. But, whooa, its been a long time not writing on my (own) blog too! The last post I wrote was on August of 2012 when I checked. Yeah, I’d been busy with my school tasks and some school organizations duty. On another side, I was having some side project for my friend and learning WordPress plugin development, and still working on it.

Oh, almost forgot, its new year right? Welcome to 2013! Hope it would be a good year for me, and good to for ya’ll. :)

Last Saturday was a really nice day. When i checked my email in the morning, I saw a mail from Caroline Moore (sixhours), and unbelievably, Minimalizine was live at WordPress.com. I’d have been got an email from her few weeks ago, she told me that Minimalizine would be remarked to be live at WordPress.com directory. I was so glad and happy to know that :)

You can read the announcement of it from WordPress.com’s blog and/or start a new blog there with Minimalizine.

By now, i’m working for updating Minimalizine on WordPress.org directory and hope it’ll available soon. One more theme will cooming after. :)

Gravatar Library for Panada Framework

For last few weeks, I’ve been learning Panada Framework, simple PHP framework made by Indonesian, Iskandar Soesman. It works simlple, as simple as Codeigniter and I thought its simpler :D

I’m still a new player in PHP world, but i really wanted to contribute to this projects. So, I decided to write, editing exactly, a Gravatar library for Panada.

Simple to Use

  1. Put Gravatar.php in your app/Libraries folder.
  2. Initialize the library: $this->gravatar = new Libraries\Gravatar;
  3. Get the image: $this->gravatar->get('email@email.com');

Fork at Github

Installing Node.js on Ubuntu

I was reading at David Walsh’s writing about CSS compressor and minification using clean-css based on Node.js. Then  try installing Node.js on my netbook. I found from official Joyent Node.js wiki page:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

Yeah, it works now :D

Let Contributor Edit Their Published Posts on WordPress

Yesterday, I asked by a friend to publish his post at Blogazinist. I published it then, and realized that the post was not the final yet. He wanted to edit it, so I  pending that post again. And had been doing those activity for many times.

By default, we set registered user on Blogazinist as a contributor. After reading a while at WordPress Codex about User Roles and Capabilities, I knew that contributor can edit their posts, but not after it’s published. Then I scrolling down edit_published_posts capability. Then I thought to add that capability to contributor role.

We all knew, WordPress gives easy way to modify its core functions by hooking to that function. So, to achieve that, I hooked to admin_init function. Also using get_role function to get contributor role and add a new capability on it.

function contributor_edit_published() {
	$contributor = get_role('contributor');
	$contributor->add_cap('edit_published_posts');
}
add_action('admin_init', 'contributor_edit_published');

By now, Blogazinist’s contributor could edit their published posts. :)

Reference

Soundcloud oEmbed Support in WordPress

Soundcloud oEmbed Support in WordPress
It’s come from another post format I made in my tumblog theme. I’ve add a custom meta box in post editor to easily deal with the post format. Firstly, there’s a text input for audio URL and a textarea for SoundCloud embed code. I thought that’s not an effective way to solve this problem. I want just a text input for both audio URL or SoundCloud URL.

I looking for another way more effective and found built-in WordPress function, wp_oembed_get(). But I realized that the built-in library in WordPress doesn’t support SoundCloud oEmbed yet. Here the function wp_oembed_add_provider() works.

// Register oEmbed support for Soundcloud
wp_oembed_add_provider( 'http://soundcloud.com/*', 'http://soundcloud.com/oembed' );

The first argument, http://soundcloud.com/* is the URL structure that this (SoundCloud) oEmbed provider supports. The second, http://soundcloud.com/oembed is the base URL of the oEmbed provider. Actually there’s third argument, regex, but we doesn’t need it this time.

Here is the example of post custom meta data:

// Get the URL from custom field
$audio = get_post_meta($post->ID, 'daoon_audio', true);

// Echo the embedded sound
if ($audio)
    echo wp_oembed_get($audio);

And lastly, we just paste the SoundCloud track URL to the meta box and it automatically embedded. One thing I didn’t find the way is how we add a parameter to the embedded URL without entering it directly in the box. There’s an array argument after the URL at wp_oembed_get(), but I tried and it doesn’t work. Anyone knows, please leave at comment, thanks.

Useful Links

  1. WordPress Embeds
  2. Function Reference: wp oembed get()
  3. Function Reference: wp oembed add provider()
  4. Function Reference: wp_embed_register_handler(), registering non-oEmbed support

Styling Chat Transcript for Custom Post Format

I’ve been busy making a new WordPress tumblog theme. This theme comes with 8 different post format. I thought to make a different layout of chat format was such a great idea. I search how to deal this problem and got some results, but there’s only one which solving my problem, with some modification of the code.

function daoon_chat_post($content) {
    global $post;
    if (has_post_format('chat')) {
        remove_filter ('the_content',  'wpautop');
        $chatoutput = "<ul class=\"chat\">\n";
        $split = preg_split("/(\r?\n)+|(<br\s*\/?>\s*)+/", $content);
        foreach($split as $haystack) {
            if (strpos($haystack, ":")) {
                $string = explode(":", trim($haystack), 2);
                $who = strip_tags(trim($string[0]));
                $what = strip_tags(trim($string[1]));
                $row_class = empty($row_class)? " class=\"chat-highlight\"" : "";
                $chatoutput = $chatoutput . "<li><strong>$who</strong><p>$what</p></li>\n";
            } else {
                $chatoutput = $chatoutput . $haystack . "\n";
            }
        }
 
        // print our new formated chat post
        $content = $chatoutput . "</ul>\n";
        return $content;
     } else {
         return $content;
     }
 }
 add_filter('the_content', 'daoon_chat_post', 9);

Line 3, if (has_post_format('chat')), check whether the post has chat post format or not, then filter the content for re-layouting. The output then has a <li> element for each person and message inside an <ul> element.

Reference

  1. Tumblr Style Chat Posts for WordPress

Hello World! Welcome

Hey, welcome! I’m Rizqy Hidayat, 16 from Indonesia. I’m not a web designer nor developer yet, but I love to. I made this blog as a showcase for what I’ve done and some documentation about web design, WordPress, code snippets, and others.

Today, I’m still registered as a student at a High School in Magelang, Jawa Tengah, Indonesia. I’m not a good student by the way. I spent my time working with my oldish AOA150. Design, coding, blogazining, WordPress theming, and other web stuffs. I’m a coffee addict and that’s why I often got sleep after night.

I love everything to be simple as it should be. Simple is good and no need to complicate. I’m a Mrazer and I love listening his songs while typing codes or designing something.

That might be enough for this first post. Enjoy!