Friday, July 15, 2011

Belajar Membuat Theme WordPress [P8]

Seperti yang sudah ane janjiin dulu di pagenya B|H di facebook bahwa ane akan bahas tentang functions.php di wordpress, nah pertemuan sekarang ane akan sedikit mengulas tentang functions.php, pada dasarnya functions.php adalah file yang berisi perintah tambahan untuk blog kita. dan disini kita bisa melakukan segala hal untuk blog kita. bisa dibilang ini adalah nyawa ketiga blog kita setelah hosting dan theme….

So lets begin
Completely remove the version number from pages and feeds
// remove version info from head and feeds
function complete_version_removal() {
return ”;
}
add_filter(‘the_generator’, ‘complete_version_removal’);
Customize the admin footer message
// customize admin footer text
function custom_admin_footer() {
echo ‘Website Design by Monzilla Media’;
}
add_filter(‘admin_footer_text’, ‘custom_admin_footer’);
Enable delete and spam links for comments
// spam & delete links for all versions of wordpress
function delete_comment_link($id) {
if (current_user_can(‘edit_post’)) {
echo ‘| del ‘;
echo ‘| spam’;
}
}
dan tambah kan ini di cooments loop nya
Disable all WordPress feeds
// disable all feeds
function fb_disable_feed() {
wp_die(__(‘

Feed not available, please visit our Home Page!

‘));
}
add_action(‘do_feed’, ‘fb_disable_feed’, 1);
add_action(‘do_feed_rdf’, ‘fb_disable_feed’, 1);
add_action(‘do_feed_rss’, ‘fb_disable_feed’, 1);
add_action(‘do_feed_rss2′, ‘fb_disable_feed’, 1);
add_action(‘do_feed_atom’, ‘fb_disable_feed’, 1);
Add feed links to header
// add feed links to header
if (function_exists(‘automatic_feed_links’)) {
automatic_feed_links();
} else {
return;
}
Enable threaded comments
// enable threaded comments
function enable_threaded_comments(){
if (!is_admin()) {
if (is_singular() AND comments_open() AND (get_option(‘thread_comments’) == 1))
wp_enqueue_script(‘comment-reply’);
}
}
add_action(‘get_header’, ‘enable_threaded_comments’);
Remove unwanted crap from the head section
// remove junk from head
remove_action(‘wp_head’, ‘rsd_link’);
remove_action(‘wp_head’, ‘wp_generator’);
remove_action(‘wp_head’, ‘feed_links’, 2);
remove_action(‘wp_head’, ‘index_rel_link’);
remove_action(‘wp_head’, ‘wlwmanifest_link’);
remove_action(‘wp_head’, ‘feed_links_extra’, 3);
remove_action(‘wp_head’, ‘start_post_rel_link’, 10, 0);
remove_action(‘wp_head’, ‘parent_post_rel_link’, 10, 0);
remove_action(‘wp_head’, ‘adjacent_posts_rel_link’, 10, 0);
Add a different favicon for your blog’s Admin area
// add a favicon for your admin
function admin_favicon() {
echo ”;
}
add_action(‘admin_head’, ‘admin_favicon’);
Custom Admin Login logo
// custom admin login logo
function custom_login_logo() {
echo ‘
h1 a { background-image: url(‘.get_bloginfo(‘template_directory’).’/images/custom-login-logo.png) !important; }
‘;
}
add_action(‘login_head’, ‘custom_login_logo’);
Disable unused widget areas
// disable all widget areas
function disable_all_widgets($sidebars_widgets) {
//if (is_home())
$sidebars_widgets = array(false);
return $sidebars_widgets;
}
add_filter(‘sidebars_widgets’, ‘disable_all_widgets’);
Kill the WordPress update nag
// kill the admin nag
if (!current_user_can(‘edit_users’)) {
add_action(‘init’, create_function(‘$a’, “remove_action(‘init’, ‘wp_version_check’);”), 2);
add_filter(‘pre_option_update_core’, create_function(‘$a’, “return null;”));
}
Sekarang tinggal di masukan kepada file functions.php dan walah,, jadilah tema yang selama ini jadi tutorial kita.. untuk demo nya menyusul ya, cz belum ane susun…
Keep stay at binushacker.net and forum.binushacker.net

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews