__( 'Primary Menu', 'belajar' ),
'select-menu' => __( 'Select Menu', 'belajar' ),
) );
/*
* This theme supports custom background color and image, and here
* we also set up the default background color.
*/
add_theme_support( 'custom-background', array(
'default-color' => 'e6e6e6',
) );
/**
* Add support for the Aside and Gallery Post Formats
*/
add_theme_support( 'post-formats', array( 'aside', 'image', 'gallery' ) );
}
endif; // belajar_setup
/**
* Tell WordPress to run belajar_setup() when the 'after_setup_theme' hook is run.
*/
add_action( 'after_setup_theme', 'belajar_setup' );
/**
* Tell WordPress to run belajar_setup() when the 'after_setup_theme' hook is run.
*/
add_action( 'after_setup_theme', 'belajar_setup' );
/**
* Adds support for a custom header image.
*//**
'444',
'default-image' => get_template_directory_uri() . '/images/logo.png',
// Set height and width, with a maximum value for the width.
'height' => 180,
'width' => 300,
'max-width' => 2000,
// Support flexible height and width.
'flex-height' => true,
'flex-width' => true,
// Random image rotation off by default.
'random-default' => false,
// Callbacks for styling the header and the admin preview.
'wp-head-callback' => 'belajar_header_style',
'admin-head-callback' => 'belajar_admin_header_style',
'admin-preview-callback' => 'belajar_admin_header_image',
);
add_theme_support( 'custom-header', $args );
}
add_action( 'after_setup_theme', 'belajar_custom_header_setup' );
/**
* Styles the header text displayed on the blog.
*
* get_header_textcolor() options: 444 is default, hide text (returns 'blank'), or any hex value.
*/
function belajar_header_style() {
$text_color = get_header_textcolor();
// If no custom options for text are set, let's bail
if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
return;
// If we get this far, we have custom styles.
?>
Header admin panel.
*/
function belajar_admin_header_style() {
?>
Header admin panel.
*/
function belajar_admin_header_image() {
?>
Posted on by %7$s', 'belajar' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'belajar' ), get_the_author() ) ),
esc_html( get_the_author() )
);
}
endif;
/**
* Adds custom classes to the array of body classes.
*
* @since belajar 1.2
*/
function belajar_body_classes( $classes ) {
// Adds a class of single-author to blogs with only 1 published author
if ( ! is_multi_author() ) {
$classes[] = 'single-author';
}
return $classes;
}
add_filter( 'body_class', 'belajar_body_classes' );
/**
* Returns true if a blog has more than 1 category
*
* @since belajar 1.2
*/
function belajar_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) {
// Create an array of all the categories that are attached to posts
$all_the_cool_cats = get_categories( array(
'hide_empty' => 1,
) );
// Count the number of categories that are attached to the posts
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'all_the_cool_cats', $all_the_cool_cats );
}
if ( '1' != $all_the_cool_cats ) {
// This blog has more than 1 category so belajar_categorized_blog should return true
return true;
} else {
// This blog has only 1 category so belajar_categorized_blog should return false
return false;
}
}
/**
* Flush out the transients used in belajar_categorized_blog
*
* @since belajar 1.2
*/
function belajar_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'all_the_cool_cats' );
}
add_action( 'edit_category', 'belajar_category_transient_flusher' );
add_action( 'save_post', 'belajar_category_transient_flusher' );
/**
* Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
*/
function belajar_enhanced_image_navigation( $url ) {
global $post, $wp_rewrite;
$id = (int) $post->ID;
$object = get_post( $id );
if ( wp_attachment_is_image( $post->ID ) && ( $wp_rewrite->using_permalinks() && ( $object->post_parent > 0 ) && ( $object->post_parent != $id ) ) )
$url = $url . '#main';
return $url;
}
add_filter( 'attachment_link', 'belajar_enhanced_image_navigation' );
/**
* Related post
*
* @since belajar 1.2
*/
function my_related_posts() {
$tags = the_tags('');
$args = array(
'posts_per_page' => 4,
'post__in' => $tags,
);
$the_query = new WP_Query( $args );
?>