Advertisement

This is about Me?

Do not read this

Thanks To

Related sites

Community

Syndication

You can grab our news as an Atom feed.


WP Dropdown Posts Plugins

[1-Mar-2010]

Sometime you want to display Wordpress Posts list in a dropdown style just like Wordpress Page does. Unfortunately this feature is not available in Wordpress. But dont’ worry guys, I have created a plugin for this purpose. WP Dropdown Posts will shows posts list in dropdown and if you click on an item, you will be redirected to that post. Read the rest of this entry »


Wordpress Iteration in Your Own PHP Application

[27-Feb-2010]

Wordpress has its own way to loop the posts, that is different than what other CMS does. I think it’s great because of flexibility and usability reason. It would seem easy later, when you want to manipulate the result before it is displayed to the browser.
So you want to implement the Wordpress-style loop in your own PHP application? You have to say yes. :D

The following PHP code contains some basic functions to make your own Wordpress Loop.

Code

Wordpress-style Loop

<?php
$posts 
mysql_query('YOUR SQL QUERY HERE');
$post null;
$post_count 0;
$post_index 0;

function 
have_post() {
    global 
$posts$post_count$post_index;

    if (
$posts && ($post_index < = $post_count)){
        
$post_count count($posts);
        return 
true;
    }
    else {
        
$post_count 0;
        return 
false;
    }
}

function 
the_post() {
    global 
$posts$post$post_count$post_index;

    
// make sure all the posts haven't already been looped through
    
if ($post_index $post_count) {
        return 
false;
    }

    
// retrieve the post data for the current index
    
$post $posts[$post_index+1];

    
// increment the index for the next time this method is called
    
$post_index++;
    return 
$post;

}

function 
the_title() {
    global 
$post;
    return 
$post->Title;
}

function 
the_content() {
    global 
$post;
    return 
$post->Content;
}

//and the output... tada....

if(have_post()) : while(have_post()) : the_post();
echo 
"
<h2>"
.the_title()."</h2>

"
;
echo 
the_content();
endwhile; endif;

<
p>?>

The advantage of using this iteration is:
1. Easy to implement with templating system.
2. Easy to filter output through PHP function, no need edit the template file.
3. Every output element is a function rather than a variable. It accepts parameter, you can do more things.
4. Want to display next post or previous post? that’s no a pain.

Disadvantage:
Of course, that code confusing me at the first time :D

Information


Thanks to Matt Huggins post at Stackoverflow and xrvel post at kaskus


WP Editarea Wordpress Plugin

[11-Feb-2010]

Wordpress used to embed Codepress syntax highlighting at Version 2.8 and immediately disabled it at Version 2.8.1 due to browser incompatibilities. However I found another free Javascript code editor called Editarea which has more features than Codepress . Now you can simply integrate Editarea functionality to your Wordpress by using WP Editarea Plugins.

WP Editarea
Contributors: takien
Requires at least: 2.9
Tested up to: 2.9.1
Stable tag: 0.1

Description

WP Editarea turns your Oldschool textarea code editor in Wordpress Dashboard (plugin/theme editor) into a fancy realtime highlighted code editor using Editarea.

Plugin Feature

* Automatically detect syntax language
* Live preview in plugin option page
* Better than codepress (for me)
* Easy integration, no file to edit
* Easy to use configuration page

Editarea Feature
* Multi language interface
* Bracket matching highlight
* Support many syntax
* Line numbers
* Search/replace with regex
* More at Editarea homepage.

Browser Compatibility
* IE 6 & 7 & 8, Firefox 1.5 & 2 & 3, Safari 3.x & 4, Opera 9, 9.5, 9.6 and Chrome 1 & 2[2]

Installation

The installation process.

1. Upload `wp-editarea` folder to the `/wp-content/plugins/` directory. Make sure directory structures are not changed. Or Directly upload from your Plugin management page.
2. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Go to Settings menu and set options you need.

Screenshots

1. Setting page and live preview.

wordpress editarea, wordpress syntax highlight

WP Editarea setting page.


2. Your new theme editor :D
 editarea, wordpress code editor, wordpress syntax highlight

Wordpress Editarea


Wordpress 3.0 with Twenty Ten Default Theme

[9-Feb-2010]
Wordpress 3.0, twenty ten, wordpress screnshoot

Twenty Ten 0.7 comes with Wordpress 3.0

I just download and install alpha version of WordPress Version 3.0. At a glance, there are no major changes that I can see. After installation process that run as simple as usual, I walk through menus in the Dashboard and found a new sub-menu named “Network” under the Tools menu. As I have heard before that in version 3.0 Wordpress would be integrated with Wordpress MU with Multi-Site feature. It’s mean that you can multiply your site easily without Installing Wordpress MU.

Navigate other menus, there is nothing striking until my mouse clicked on the “Appearance”. There seems to be a new stuff. The new default theme entitled “Twenty Ten 0.7 by the WordPress team“, cool.  There’s a new atmosphere in my Wordpress instead of seeing Kubrick theme for several years.

My curiosity led to Theme Editor that may also have some changes there. A little difference with previous version in the lists of the theme file name. The file title and file name are separated into two lines. Look quite neater.

At the bottom of file lists, there is a new stylesheet file named “editor-style.css“. I hope my guess’ right, it is the css style file to be used in editor page when I write or edit a post. I think it will be useful for those who create a new post from the dashboard, but not for me who prefer to write using Windows Live Writer.

That’s my story when testing Wordpress 3.0 alpha — development version (3.0-alpha)– which may a lot of changes will be added  until the final version released.

Incoming search terms:


Word Replacer Wordpress Plugin

[1-Feb-2010]

Word Replacer is a Wordpress plugin will enable you to replace a specific word in your content then replace it with replacement given. Contents that can be replaced are posts, pages, or comments. It’s identical with the Word Censors in SMF Forum Software.

Readme:

=== Word Replacer ===
Contributors: takien
Donate link: Donate
Tags: replacer, post, comment, page, replace, censor, bbcode, filter
Requires at least: 2.9
Tested up to: 2.9.1
Stable tag: 0.1

Replace word in post, page, or comment.

== Description ==

Word Replacer is a Wordpress plugins to replace any desired text/word with your choice. You can filter which content to be replaced, eg. only in page, comment, or post. With very userfriendly administration page you can manage list of word eaasily. It’s also can be used to censor any bad/vulgar words in your comment your your guest posting. It’s simple but useful.

Feature:

* Userfriendly administration page.
* Define yourself what word to replace in where. (e.g. a word shoud be replaced in comment but not in post etc)
* Uses it’s own database table, if you wish you can directly update/add/delete/import through your MySQL admin.

== Installation ==

The installation process.

1. Upload zipped plugin file to the `/wp-content/plugins/` directory. Or Directly upload from your Plugin management page.
2. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Go to Settings menu and you will see Word Replacer sub menu. Yeah, there are your playground.

== Frequently Asked Questions ==

== Support RegeX ==

No, at this time.

== Screenshots ==

Word replacer

Administration page where you can add/remove your word.


Administration page where you can add/remove your word.

== Changelog ==

= 0.1 =
* First release

The code:

Word Replacer Source Code

<?php
/*
Plugin Name: Word Replacer
Plugin URI: http://wordpress.org/#
Description: Replace word in post, page, or comment
Author: Takien
Version: 0.1
Author URI: http://takien.com/
*/

/*  Copyright 2010 takien.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    For a copy of the GNU General Public License, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

global $wpdb;
global 
$word_replacer;

$word_replacer = Array(
                
'name'             => 'Word Replacer',
                
'version'         => '0.1',
                
'table_name'    => $wpdb->prefix "word_replacer",
                
'base_name'        => 'wordreplacer'
);

function 
_specialchar($string) {
    return 
htmlspecialchars(stripcslashes($string));
}

if(isset(
$_POST['submit'])) {

    
$id                $_POST['id'];
    
$original         $_POST['original'];
    
$replacement     $_POST['replacer'];
    
$in_posts         $_POST['in_posts'];
    
$in_comments    $_POST['in_comments'];
    
$in_pages        $_POST['in_pages'];

$numfield count($original);

    for (
$i 1$i < = $numfield$i++) {
    if(!empty(
$original[$i]) && empty($id[$i])) {
    
$wpdb->query$wpdb->prepare"
        INSERT INTO "
.$word_replacer['table_name']."
        (original, replacement, in_posts, in_comments, in_pages)
        VALUES (%s, %s, %s, %s, %s)"
,
        array(
$wpdb->escape($original[$i]), $wpdb->escape($replacement[$i]),$wpdb->escape($in_posts[$i]),$wpdb->escape($in_comments[$i]),$wpdb->escape($in_pages[$i]))));
        
$message =  '
<div id="message" class="updated fade">

<strong>Word Inserted.</strong>
</div>

'
;
    }
    elseif(empty(
$original[$i]) && !empty($id[$i])) {
        
$wpdb->query("
        DELETE FROM "
.$word_replacer['table_name']." WHERE id = '".$id[$i]."'");
        
$message =  '
<div id="message" class="updated fade">

<strong>Word Deleted.</strong>
</div>

'
;
    }
    elseif(!empty(
$original[$i]) && !empty($id[$i])) {
        
$wpdb->update($word_replacer['table_name'],
        array(
'original'     => $wpdb->escape($original[$i]),
        
'replacement'         => $wpdb->escape($replacement[$i]),
        
'in_posts'            => $wpdb->escape($in_posts[$i]),
        
'in_comments'        => $wpdb->escape($in_comments[$i]),
        
'in_pages'            => $wpdb->escape($in_pages[$i])
        ),
        array( 
'id' => $id[$i] ), array( '%s''%s''%s''%s''%s'), array( '%d' ) );
        
$message =  '
<div id="message" class="updated fade">

<strong>Word Updated.</strong>
</div>

'
;
    }
    }
}

function 
word_replacer_install () {
    global 
$wpdb;
    global 
$word_replacer;

   if(
$wpdb->get_var('show tables like "'.$word_replacer['table_name'].'"') != $word_replacer['table_name']) {

      
$sql "CREATE TABLE " $word_replacer['table_name'] . " (
      id mediumint(9) NOT NULL AUTO_INCREMENT,
      original VARCHAR(200) NOT NULL,
      replacement VARCHAR(200) NOT NULL,
      in_posts VARCHAR(5) NOT NULL,
      in_comments VARCHAR(5) NOT NULL,
      in_pages VARCHAR(5) NOT NULL,
      UNIQUE KEY id (id)
    );"
;

      require_once(
ABSPATH 'wp-admin/includes/upgrade.php');
      
dbDelta($sql);

      
$badword         "badword";
      
$properword     "goodword";

      
$insert "INSERT INTO " $word_replacer['table_name'] .
            
" (original, replacement, in_posts, in_comments, in_pages) " .
            
"VALUES ('" $wpdb->escape($badword) . "','" $wpdb->escape($properword) . "','yes','yes','yes')";

      
$results $wpdb->query$insert );

      
add_option("word_replacer_ver"$word_replacer['version']);
   }
}

register_activation_hook(__FILE__,'word_replacer_install');

function 
word_replacer_db() {
    global 
$wpdb;
    global 
$word_replacer;
    return 
$wpdb->get_results("SELECT * FROM ".$word_replacer['table_name']." ORDER BY id"ARRAY_A);
}

// for content 

function word_replacer_postpage($content) {
$i 1;
foreach(
word_replacer_db() as $wrdb) {
$i++;
    
$original[$i]         = stripslashes($wrdb['original']);
    
$replacement[$i]     = stripslashes($wrdb['replacement']);
    
$in_posts[$i]         = stripslashes($wrdb['in_posts']);
    
$in_comments[$i]     = stripslashes($wrdb['in_comments']);
    
$in_pages[$i]         = stripslashes($wrdb['in_pages']);

    if(
is_page() && ($in_pages[$i] == 'yes')) {
        
$content str_replace($original[$i],$replacement[$i],$content);
    }
    elseif(!
is_page() && ($in_posts[$i] == 'yes')) {
        
$content str_replace($original[$i],$replacement[$i],$content);
    }

}
return 
$content;
}

// for comment
function word_replacer_comment($content) {
$i 1;
foreach(
word_replacer_db() as $wrdb) {
$i++;
    
$original[$i]         = stripslashes($wrdb['original']);
    
$replacement[$i]     = stripslashes($wrdb['replacement']);
    
$in_posts[$i]         = stripslashes($wrdb['in_posts']);
    
$in_comments[$i]     = stripslashes($wrdb['in_comments']);
    
$in_pages[$i]         = stripslashes($wrdb['in_pages']);

    if(
$in_comments[$i]    == 'yes') {
    
$content str_replace($original[$i],$replacement[$i],$content);
    }
    }
return 
$content;
}

add_filter('comment_text','word_replacer_comment');
add_filter('the_content','word_replacer_postpage');
add_action('admin_menu''word_replacer_add_page');

function 
word_replacer_add_page() {
    global 
$word_replacer;
    
add_options_page($word_replacer ['name'], $word_replacer ['name'], 'administrator''wordreplacer''word_replacer_page');
}

function 
word_replacer_page() {
    global 
$wpdb$word_replacer$message;

    echo 
'
<div class="wrap">
<h2>'
.$word_replacer ['name'].'</h2>

'
;
    echo 
$message;
?>

<script language="Javascript" type="text/javascript">
<!--
function addField(area,field,limit) {
    if(!document.getElementById) return;
    var field_area = document.getElementById(area);
    var all_inputs = field_area.getElementsByTagName("input");
    var last_item = all_inputs.length - 1;
    var last = all_inputs[last_item].id;
    var count = Number(last.split("_")[1]) + 1;

    if(count > limit && limit > 0) return;

    field_area.innerHTML += "
<tr>
<td>
<input type='hidden' name='id[]' value='' />
<input style='width:100%' name='original[]' type='text' /></td>
<td> => </td>
<td>
<input style='width:100%' name='replacer[]' type='text' /></td>
<td>
<input value='yes' name='in_posts[]' type='checkbox' /></td>
<td>
<input value='yes' name='in_comments[]' type='checkbox' /></td>
<td>
<input value='yes' name='in_pages[]' type='checkbox' /></td>
</tr>

";

}
//-->
</script>

<?php
$action_url 
$_SERVER[PHP_SELF] . '?page=' $word_replacer['base_name'];

?>

Put the word to be replaced on the left, and what to change it to on the right.
<form method="post" action="<?php echo $action_url;?>">
<table class="widefat fixed" width="650" align="center" id="word-replacer-list" width="100%">
<thead>
<?php wp_nonce_field('update-options'); ?>
<tr>
<th>Original</th>
<th width="20"> </th>
<th>Replacement</th>
<th width="80">Posts</th>
<th width="80">Comments</th>
<th width="80">Pages</th>
</tr>
</thead>

<?php
$i 
= -1;

foreach(
word_replacer_db() as $wrdb) { $i++ ?>
<?php $alternate 
= (empty($alternate) ? 'class="alternate"' '');?>
<tr <?php echo $alternate;?>>
<td>
<input type="hidden" name="id[]" value="<?php echo $wrdb['id']; ?/>" />
<input style="
width:100%" type="text" name="original[<?php echo $i;?/>]" id="original_<?php echo $i;?>" value="<?php echo _specialchar($wrdb['original']) ?>" /></td>
<td> => </td>
<td>
<input style="width:100%" type="text" name="replacer[<?php echo $i;?/>]" value="<?php echo _specialchar($wrdb['replacement']) ?>" /></td>
<td>
<input value="yes" name="in_posts[<?php echo $i;?/>]" <?php echo (($wrdb['in_posts'] == 'yes') ? 'checked="checked"' : ''); ?> type="checkbox" /></td>
<td>
<input value="
yes" name="in_comments[<?php echo $i;?/>]" <?php echo (($wrdb['in_comments'] == 'yes') ? 'checked="checked"' : ''); ?> type="checkbox" /></td>
<td>
<input value="
yes" name="in_pages[<?php echo $i;?/>]" <?php echo (($wrdb['in_pages'] == 'yes') ? 'checked="checked"' : ''); ?> type="checkbox" /></td>
</tr>

<?php } ?>
</table>
<input type="
button" value="Add More Fields" style="cursor:pointer" onclick="addField('word-replacer-list','original_',0);" />
<input type="
hidden" name="action" value="update" />
<input name="
submit" class="button-primary" type="submit" value="<?php _e('Add/Update Words') ?/>" />
</form>

Instruction:


1. To <b>Add New Word</b> click Add More Fields  add your word, replacement and filter, then hit Add/Update Words.
2. To <b>Update</b> a word, just replace/retype in it's place an hit Add/Update Words.
3. To <b>Delete</b> a word, leave blank/clear word in "
original" field and hit Add/Update Words.
</div>

<?php
}
?>

<p>?>


Feature Wishlist

Here are  some feature wish lists for Word Replacer Plugin based on user comments:

  • Replace the title
  • Replace Case-insensitive

Uploaded to Wordpress.org

This Word Replacer Plugin just approved and uploaded to Wordpress Plugins Directory
Please see it in action, here.. http://wordpress.org/extend/plugins/word-replacer/ :D

Note: This post was posted by WP Sub Post Plugin


Wordpress Plugin WP Sub Post

[28-Jan-2010]

WP Sub Post is a wordpress plugin that allow you to make your wordpress post has a parent or child post.

Notes:

  • Child post is a real post that has a parent.
  • Child post only displayed on it’s parent post page or when parent page is displayed.
  • Child post can not be viewed individually.
  • Child post has all possibility like a normal post, such as attachment, custom fields etc.

Features:

  • Add/edit parent post directly from your post area.
  • No need to edit theme file.

Limitations:

  • No setting page
  • I don’t know about it’s compatibility.

Bugs:

  • Not compatible with my syntax highlight plugin :D

Screenshot

Plugin page:

WP sub post

New/Edit post page:

Wp sub post

View Single Post:

Wp sub post

RSS:

Wp sub post


Code:

Here is the code of this plugins…  Hahaha.. little bit messy

WP Sub Post

WP Sub Post

<?php</p>
/*
Plugin Name: WP Sub Post
Plugin URI: http://wordpress.org/#
Description: You can make a post is a child of another post.
Author: Takien
Version: 0.1 Alpha
Author URI: http://takien.com
*/

////////////////////////////

class Walker_PostDropdown extends Walker {

    var 
$tree_type 'post';

    var 
$db_fields = array ('parent' => 'post_parent''id' => 'ID');

    function 
start_el(&$output$page$depth$args) {
        
$pad str_repeat(' '$depth 3);

        
$output .= "\tID\"";
        if ( 
$page->ID == $args['selected'] )
            
$output .= ' selected="selected"';
        
$output .= '>';
        
$title esc_html($page->post_title);
        
$output .= "$pad$title";
        
$output .= "\n";
    }
}
/////////////
function &wp_get_posts($args '') {
    global 
$wpdb;

    
$defaults = array(
        
'child_of' => 0'sort_order' => 'ASC',
        
'sort_column' => 'post_title''hierarchical' => 1,
        
'exclude' => '''include' => '',
        
'meta_key' => '''meta_value' => '',
        
'authors' => '''parent' => -1'exclude_tree' => '',
        
'number' => '''offset' => 0
    
);

    
$r wp_parse_args$args$defaults );
    
extract$rEXTR_SKIP );
    
$number = (int) $number;
    
$offset = (int) $offset;

    
$cache = array();
    
$key md5serializecompact(array_keys($defaults)) ) );
    if ( 
$cache wp_cache_get'wp_get_posts''posts' ) ) {
        if ( 
is_array($cache) && isset( $cache$key ] ) ) {
            
$pages apply_filters('wp_get_posts'$cache$key ], $r );
            return 
$pages;
        }
    }

    if ( !
is_array($cache) )
        
$cache = array();

    
$inclusions '';
    if ( !empty(
$include) ) {
        
$child_of 0//ignore child_of, parent, exclude, meta_key, and meta_value params if using include
        
$parent = -1;
        
$exclude '';
        
$meta_key '';
        
$meta_value '';
        
$hierarchical false;
        
$incpages preg_split('/[\s,]+/',$include);
        if ( 
count($incpages) ) {
            foreach ( 
$incpages as $incpage ) {
                if (empty(
$inclusions))
                    
$inclusions $wpdb->prepare(' AND ( ID = %d '$incpage);
                else
                    
$inclusions .= $wpdb->prepare(' OR ID = %d '$incpage);
            }
        }
    }
    if (!empty(
$inclusions))
        
$inclusions .= ')';

    
$exclusions '';
    if ( !empty(
$exclude) ) {
        
$expages preg_split('/[\s,]+/',$exclude);
        if ( 
count($expages) ) {
            foreach ( 
$expages as $expage ) {
                if (empty(
$exclusions))
                    
$exclusions $wpdb->prepare(' AND ( ID <> %d '$expage);
                else
                    
$exclusions .= $wpdb->prepare(' AND ID <> %d '$expage);
            }
        }
    }
    if (!empty(
$exclusions))
        
$exclusions .= ')';

    
$author_query '';
    if (!empty(
$authors)) {
        
$post_authors preg_split('/[\s,]+/',$authors);

        if ( 
count($post_authors) ) {
            foreach ( 
$post_authors as $post_author ) {
                
//Do we have an author id or an author login?
                
if ( == intval($post_author) ) {
                    
$post_author get_userdatabylogin($post_author);
                    if ( empty(
$post_author) )
                        continue;
                    if ( empty(
$post_author->ID) )
                        continue;
                    
$post_author $post_author->ID;
                }

                if ( 
'' == $author_query )
                    
$author_query $wpdb->prepare(' post_author = %d '$post_author);
                else
                    
$author_query .= $wpdb->prepare(' OR post_author = %d '$post_author);
            }
            if ( 
'' != $author_query )
                
$author_query " AND ($author_query)";
        }
    }

    
$join '';
    
$where "$exclusions $inclusions ";
    if ( ! empty( 
$meta_key ) || ! empty( $meta_value ) ) {
        
$join " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";

        
// meta_key and meta_value might be slashed
        
$meta_key stripslashes($meta_key);
        
$meta_value stripslashes($meta_value);
        if ( ! empty( 
$meta_key ) )
            
$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s"$meta_key);
        if ( ! empty( 
$meta_value ) )
            
$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s"$meta_value);

    }

    if ( 
$parent >= )
        
$where .= $wpdb->prepare(' AND post_parent = %d '$parent);

    
$query "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'post' AND post_status = 'publish') $where ";
    
$query .= $author_query;
    
$query .= " ORDER BY " $sort_column " " $sort_order ;

    if ( !empty(
$number) )
        
$query .= ' LIMIT ' $offset ',' $number;

    
$pages $wpdb->get_results($query);

    if ( empty(
$pages) ) {
        
$pages apply_filters('wp_get_posts', array(), $r);
        return 
$pages;
    }

    
// Sanitize before caching so it'll only get done once
    
$num_pages count($pages);
    for (
$i 0$i $num_pages$i++) {
        
$pages[$i] = sanitize_post($pages[$i], 'raw');
    }

    
// Update cache.
    
update_page_cache($pages);

    if ( 
$child_of || $hierarchical )
        
$pages = & get_page_children($child_of$pages);

    if ( !empty(
$exclude_tree) ) {
        
$exclude = (int) $exclude_tree;
        
$children get_page_children($exclude$pages);
        
$excludes = array();
        foreach ( 
$children as $child )
            
$excludes[] = $child->ID;
        
$excludes[] = $exclude;
        
$num_pages count($pages);
        for ( 
$i 0$i $num_pages$i++ ) {
            if ( 
in_array($pages[$i]->ID$excludes) )
                unset(
$pages[$i]);
        }
    }

    
$cache$key ] = $pages;
    
wp_cache_set'wp_get_posts'$cache'posts' );

    
$pages apply_filters('wp_get_posts'$pages$r);

    return 
$pages;
}
//////////////

function walk_post_dropdown_tree() {
    
$args func_get_args();
    if ( empty(
$args[2]['walker']) ) // the user's options are the third parameter
        
$walker = new Walker_PostDropdown;
    else
        
$walker $args[2]['walker'];

    return 
call_user_func_array(array(&$walker'walk'), $args);
}

function 
wp_dropdown_posts($args '') {
    
$defaults = array(
        
'depth' => 0'child_of' => 0,
        
'selected' => 0'echo' => 1,
        
'name' => 'page_id''show_option_none' => '''show_option_no_change' => '',
        
'option_none_value' => ''
    
);

    
$r wp_parse_args$args$defaults );
    
extract$rEXTR_SKIP );

    
$pages wp_get_posts($r);
    
$output '';
    
$name esc_attr($name);

    if ( ! empty(
$pages) ) {
        
$output "
<select id=""$name\"" 
name="\"$name\""><option value="\"-1\"">$show_option_no_change</option><option value="\""">$show_option_none</option>

\n"
;
    }

    
$output apply_filters('wp_dropdown_pages'$output);

    if ( 
$echo )
        echo 
$output;

    return 
$output;
}
/////////////////////////////

/* Use the admin_menu action to define the custom boxes */
add_action('admin_menu''myplugin_add_custom_box');

/* Use the save_post action to do something with the data entered */
add_action('save_post''myplugin_save_postdata');

/* Adds a custom section to the "advanced" Post and Page edit screens */
function myplugin_add_custom_box() {

  if( 
function_exists'add_meta_box' )) {
    
add_meta_box'myplugin_sectionid'__'WP Sub Posts''myplugin_textdomain' ), 'myplugin_inner_custom_box''post''side','high' );
    
//add_meta_box( $id,                  $title,                                      $callback,                  $page, $context, $priority );
    
add_meta_box'myplugin_sectionid'__'WP Sub Posts''myplugin_textdomain' ), 'myplugin_inner_custom_box''page''advanced' );
   } else {
    
add_action('dbx_post_advanced''myplugin_old_custom_box' );
    
add_action('dbx_page_advanced''myplugin_old_custom_box' );
  }
}

function 
myplugin_inner_custom_box() {
echo 
'
<style type="text/css">
select#parent_id, select#parent_id option {
    width:250px;
}
</style>

'
;

echo 
'
<input id="myplugin_noncename" name="myplugin_noncename" type="hidden" value="' 
.
    
wp_create_nonceplugin_basename(__FILE__) ) . '" />';  ?>
<h5><?php _e('Parent'?></h5>

<label for="post_parent">Please select the parent of this post</label>

<?php 

$currentid 
$_GET['post'];
wp_dropdown_posts(array('exclude_tree'             => $currentid,
                            
'selected'             => $post->post_parent,
                            
'name'                 => 'parent_id',
                            
'show_option_none'     => __('Main Post (no parent)'),
                            
'sort_column'        => 'menu_order, post_title'));
 }

/* Prints the edit form for pre-WordPress 2.5 post/page */
function myplugin_old_custom_box() {

  echo 
'
<div class="dbx-b-ox-wrapper">' 
"\n";
  echo 
'
<fieldset id="myplugin_fieldsetid" class="dbx-box">' 
"\n";
  echo 
'
<div class="dbx-h-andle-wrapper">
<h3 class="dbx-handle">' 
.
        
__'WP Sub Posts''myplugin_textdomain' ) . "</h3>
</div>

"
;   

  echo 
'
<div class="dbx-c-ontent-wrapper">
<div class="dbx-content">'
;

  
// output editing form

  
myplugin_inner_custom_box();

  
// end wrapper

  
echo "</div>
</div>
</fieldset>
</div>

\n"
;
}

/* When the post is saved, saves our custom data */
function myplugin_save_postdata$post_id ) {

  
// verify this came from the our screen and with proper authorization,
  // because save_post can be triggered at other times

  
if ( !wp_verify_nonce$_POST['myplugin_noncename'], plugin_basename(__FILE__) )) {
    return 
$post_id;
  }

  
// verify if this is an auto save routine. If it is our form has not been submitted, so we dont want
  // to do anything
  
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
    return 
$post_id;

  
// Check permissions
  
if ( 'page' == $_POST['post_type'] ) {
    if ( !
current_user_can'edit_page'$post_id ) )
      return 
$post_id;
  } else {
    if ( !
current_user_can'edit_post'$post_id ) )
      return 
$post_id;
  }

  
// OK, we're authenticated: we need to find and save the data

  
$mydata $_POST['parent_id'];

   return 
$mydata;
}

add_filter('posts_where','where_no_parent');
add_filter ('the_content','subpost_template'1);

function 
subpost_template($content) {

    if(
is_singular) {
    
remove_filter('posts_where','where_no_parent');
    }
    echo 
$content;

    
$idnya get_the_ID();
    
$child = new WP_Query("post_type=post&post_parent=".$idnya."");

    while(
$child->have_posts()) : $child->the_post();
    echo 
'
<blockquote>

'
;
    echo 
'
<h3>'
;
    
the_title();

    echo 
'</h3>

'
;
    
$childid =  get_the_ID();
    
the_content();

    
edit_post_link('Edit','','',$childid);
    echo 
'</blockquote>

'
;

    endwhile;
    
wp_reset_query();
}

function 
where_no_parent($where) {
    global 
$wpdb;
     
$where .= " AND post_parent  = 0";
     return 
$where;
}
?>

?>
Revision by polvocdo

subpost_template()

subpost_template()

<?php


    
if(is_singular()) {
        
remove_filter('posts_where','where_no_parent');
    }

    
$parentID get_the_ID();
       
$childposts get_posts(array(
                                
'post_type' => 'post',
                                
'numberposts' => -1,
                                
'post_status' => 'publish',
                                
'post_parent' => $parentID
                                
));
      
$subcontent "";
    foreach(
$childposts as $childpost){
        
$subcontent .= "
<blockquote>

"
;
        
$subcontent .= "
<h3>"
.$childpost->post_title."</h3>

"
;
        
$subcontent .= $childpost->post_content;
        
$subcontent .= '

<a rel="nofollow" href="'
.get_edit_post_link($childpost->ID).'">Edit</a>

'
;
        
$subcontent .= "</blockquote>

"
;
    }

    
$content .= $subcontent;

    return 
$content;
}

<
p>?>

WP Dropdown Post

wp_dropdown_posts()

<?php</p>
$currentid $_GET['post'];
wp_dropdown_posts(array('exclude_tree'             => $currentid,
                            
'selected'             => $post->post_parent,
                            
'name'                 => 'parent_id',
                            
'show_option_none'     => __('Main Post (no parent)'),
                            
'sort_column'        => 'menu_order, post_title'));

<
p>?>
Download

You can download alpha version of this plugin here http://cektkp.com/wpsubpost
If it not working please Click here

Warning

This plugin is Alpha version, use it for testing purpose only. Any problem caused by this plugin is not my responsibility.

Demo:

See below:

Code Update WP Sub Post

There are some changes to the WP Sub Post:

  • Fixed/Added, now child post can be viewed as a single post, with link to the Parent Post instead of displaying blank post with ‘Post not found’ title.
  • Added, CSS class and id to the blockquote of the child post. It would be useful to make a link like http://example.com/parentpost.html#childpostXXX. while XXX is your child post ID.

Two functions that are changed subpost_template() and where_no_parent()

WP Sub Post

<?php
function subpost_template($content) {
global 
$post;

$parentID get_the_ID();
       
$childposts get_posts(array(
                                
'post_type' => 'post',
                                
'numberposts' => -1,
                                
'post_status' => 'publish',
                                
'post_parent' => $parentID
                                
));
      
$subcontent "";
    foreach(
$childposts as $childpost){
        
$subcontent .= "
<blockquote class=\"sub_post\" id=\"subpost_"
.$childpost->ID."\">";
        
$subcontent .= "
<h3>"
.$childpost->post_title."</h3>

"
;
        
$subcontent .= $childpost->post_content;
        
$subcontent .= '
<p class="postmetadata"><small>This sub post was added on: '
.date('l, dS F, Y',strtotime($childpost->post_date)).' <a href="'.get_edit_post_link($childpost->ID).'" rel="nofollow">Edit</a></small>

'
;
        
$subcontent .= "</blockquote>

"
;
    }

        if(
$post->post_parent !== 0) {

        
$parent_info '
<blockquote>This post is a child post of <strong>'
.get_the_title($post->post_parent).'</strong>. To view the parent post, please <a href="'.get_permalink($post->post_parent).'">click here.</a></blockquote>

'
;
        
$content $parent_info.$content;
        }

    
$content .= $subcontent;
    return 
$content;
}

function 
where_no_parent($where) {
    global 
$wpdb;
    if(!
is_single()) {
     
$where .= " AND post_parent  = 0";
    }
    else {
    
$where .= " AND post_type = 'post'";
    }
    return 
$where;
}

<
p>?>

Finally you can see the demo here

Yesterday, I was failed to add a demo directly in this site because of incompatibility with smart tags (all smart tags are not working when WP Sub Post is activated).

The problem comes from my old stupid function subpost_template():D

Thanks and sorry to polvocdo :) , actually your revision is the answer.
Ha ha I’m forget to replace mine with your revision  :hammer: ….


This is a child post

This is an individual post (http://takien.com/536/this-is-a-child-post.php) that attached to the another post ( http://takien.com/550/wordpress-plugin-wp-sub-post.php)

image on the child post

Child post could be useful when you want to add an additional information to the main post,  news analysis, or update. Instead of editing the main post, you can now simply Add New post and mark it as child post.

Child post also has it’s own functionality, can handle attachment, displaying image. etc.

But you can’t see this post in the post editing page (wp-admin/edit.php) because of filter  in the plugin to prevent child post to be displayed individually in the main page, post listing, feed, etc.  Hahaha.. don’t worry, I will fix it soon.


All In One SEO Pack, A Smart and Stupid Plugin

[15-Jul-2009]

What a smart plugin that can optimize basic SEO of our Wordpress blog while no many another plugin can do that out there. This plugin also has good statistics with 2,380,049 times downloaded.

But, I say it’s stupid, because that small plugin never complete from development, lol. The plugin author always doing small changes on this plugin and releases update everyday.

I don’t even want to know what he changed. The most important thing is it always displaying annoying announcement on wordpress dashboard everytime I upgrade. Yes, its important because we have to manually re-enable that plugin after upgrade, otherwise it won’t work. wakakakkakakaka…


Wordpress Spry Menu Plugins

[1-Jul-2009]

Hi, this is my first plugin I write. WP Spry Menu that automatically creating Spry Drop Down Menu for wordpress category include configuration page with configurable “Home” link. This plugin using Spry (Copyright (c) 2006. Adobe Systems Incorporated) javascript library from www.adobe.com. The Spry library is FREE and redistributable with some condition (see license on the js file).

Feature:
* Displaying Wordpress Category in dropdown css menu.
* No template arguments are needed to configure menu behavior, all settings are place on the Admin.
* Live preview as soon as you change the settings. No need to refresh your homepage to see changes.
* Configurable direction, your menu should appears horizontal, vertical drop left, or vertical drop right.
* Changeable Home text link, you can leave it blank for no home link.
* Depth setting, how many child you want to display.
* Exclue setting, you can select which category should not appears on the menu.
* Order setting, order by name or ID.
* Hide/Hide emtpy category. By default Wordpress won’t display an empty category, now you can configure.
* Child of setting, only display menu from selected parent category.

How to install?

The installation is very easy.

1. Upload `wp-spry-menu` folder to the `/wp-content/plugins/` directory. Make sure wp-spry-menu contains all included files.
2. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Place `< ?php if ( function_exists('wp_spry_menu') ) wp_spry_menu();?>` in your templates
4. Configure from WP Spry Menu options in your Wordpress Admin.

Note: Since Wordpress 2.7.1 you can easy upload zipped plugin from admin.

Frequently Asked Questions

Is it support to display page menu?
Currently not, may be in the next release.

Can I edit my own css from the settings page?
I’m sorry you can’t, wait for the next release :)

Screenshots

1. Setting page and Vertical Drop Right preview.
screenshot-1

2. Setting page and Vertical Drop Left preview.
screenshot-2

3. Setting page and Horizontal preview.
screenshot-3

Changelog

July 01, 2009 version 1.0.1
* Add Child of as dropdown select.
* Live preview from plugin setting page.
* Code improvement

June, 2009 version 1.0.0

* Add admin settings
* No need to add template argument, all go to setting area.
* Add Vertical Drop Left and Vertical Drop Right

January, 2009 version 0.0.1

* Only display Horizontal style
* First release

Download

Download from Wordpress.org

Question and feedback are welcome :)

Post updated: August 13, 2009

Next Release’s Features:
1. Added menu for page
2. Added ability to select theme for menu
3. Added ability to change the category title (“View all posts filed under …”)
4. User friendly help, using tooltips.
5. Cleaner output.
6. Fixed some IE problems :)

Still in my head:
1. Add menu for blogroll.
2. Add ability to edit CSS directly.
3. Add ability to create custom menu.

Incoming search terms:


Mencari dan Mengganti String dalam Database MySQL dengan phpMyAdmin

[20-Jun-2009]

Kadangkala kita perlu mengganti suatu teks langsung dari database mySQL menggunakan phpMyAdmin. Hal ini tentu mudah saja dilakukan jika teks yang akan diganti jumlahnya cuma sedikit.

Nah, bagaimana cara merubah teks yang berjumlah banyak dalam database tersebut dengan cepat tanpa mengekspor database?

Hal itu bisa dilakukan menggunakan perintah SQL, caranya bukalah phpMyAdmin, kemudian buka tab SQL dan ketikkan perintah berikut:

UPDATE namatabel SET namakolom = replace(namakolom,"teksyangdicari","tekspengganti");

Contoh berikut akan mengganti semua teks google.com dalam posting wordpress menjadi yahoo.com.

UPDATE wp_posts SET post_content = replace(post_content,"google.com","yahoo.com");

Update: (22 Juni 2009)
Malu aku, posting ini dibaca oleh sang master juga ternyata.

Tapi gak apa-apa, itu menandakan masih punya kemaluan.
Si master tadi ngasih solusi yang lebih cepat lebih baik (bukan kampanye, red).

Kata dia cukup pakai ini aja:

"UPDATE wp_posts SET `post_content` = 'google.com' WHERE `post_content` = 'yahoo.com'" ;

Standard MySQL tuh, katanya menambahkan.

Weleh-weleh, yo wis lah, makasih oom, ntar tak hadiahin chika versi manohara deh sekalian tak gendong kemana-mana.

NB: google.com dan yahoo.com diatas hanyalah sebagai contoh saja, bukan bermaksud mempromosikan kedua situs tersebut apalagi menyemarakkan nama baik.


Gagal Upgrade Wordpress 2.7.1? Ini Solusinya

[15-Feb-2009]

Setelah dulunya sempat bersenang-senang dengan sebuah plugin wordpress yang mantab abis, Upgrade Wordpress Automatically, ternyata hal itu tidak terjadi lagi sekarang. Why? Ketika login ke dashboard situs ini, ada notifikasi bahwa telah tersedia versi wordpress yang terbaru dan dianjurkan untuk melakukan upgrade. Setelah…


News Archive