"; endif; } //Check see if the beautifuldecay_setup exists if ( !function_exists('beautifuldecay_setup') ): //Any theme customisations contained in this function function beautifuldecay_setup() { //Define default header image define( 'HEADER_IMAGE', '%s/img/header.png' ); //Define the width and height of our header image define('HEADER_TEXTCOLOR', ''); define('NO_HEADER_TEXT', true ); define( 'HEADER_IMAGE_WIDTH', apply_filters( 'beautifuldecay_header_image_width', 1000 ) ); define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'beautifuldecay_header_image_height', 250 ) ); //Don't forget this, it adds the functionality to the admin menu add_custom_image_header( '', 'beautifuldecay_admin_header_style' ); //Set some custom header images, add as many as you like //%s is a placeholder for your theme directory $customHeaders = array ( //Image 1 'blue' => array ( 'url' => '%s/headers/001.jpg', 'thumbnail_url' => '%s/headers/thumbnails/001_thumb.jpg', 'description' => __( 'Blue', 'beautifuldecay' ) ), //Image 2 'barbed' => array ( 'url' => '%s/headers/002.jpg', 'thumbnail_url' => '%s/headers/thumbnails/002_thumb.jpg', 'description' => __( 'Barbed', 'beautifuldecay' ) ), //Image 3 'leaves' => array ( 'url' => '%s/headers/003.jpg', 'thumbnail_url' => '%s/headers/thumbnails/003_thumb.jpg', 'description' => __( 'Leaves', 'beautifuldecay' ) ), //Image 4 'sky' => array ( 'url' => '%s/headers/004.jpg', 'thumbnail_url' => '%s/headers/thumbnails/004_thumb.jpg', 'description' => __( 'Sky', 'beautifuldecay' ) ), ); //Register the images with WordPress register_default_headers($customHeaders); } endif; if ( ! function_exists( 'beautifuldecay_admin_header_style' ) ) : //Function fired and inline styles added to the admin panel //Customise as required function beautifuldecay_admin_header_style() { ?> 'Sidebar Menu', 'before_widget' => '
', // Removes
  • 'after_widget' => '
  • ', // Removes 'before_title' => '

    ', 'after_title' => '

    ', )); function beautifuldecay_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '' : ?>
  • id="li-comment-">
    says:', 'beautifuldecay' ), sprintf( '%s', get_comment_author_link() ) ); ?>
    comment_approved == '0' ) : ?>
    $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  • ID,'description',true) != ''){ $description = get_post_meta($post->ID,'description',true); } elseif(is_single() && get_the_excerpt()!==''){ $description = get_the_excerpt(); } } echo $description; } //Use the "x days ago" date format if( get_option('beautifuldecay_use_human_readable_dates',false) ){ function time_ago_date($date){ return sprintf( _x("Posted %s ago",'The %s parameter is a date like "5 days" or "3 minutes"','beautifuldecay'), human_time_diff(get_the_time('U'), current_time('timestamp')) ); } add_filter('the_date','time_ago_date'); } //Remove inline CSS placed by WordPress function my_remove_recent_comments_style() { add_filter( 'show_recent_comments_widget_style', '__return_false' ); } add_action( 'widgets_init', 'my_remove_recent_comments_style' ); //Add a label next to the media upload button, to make it easy to understand function custom_admin_js() { echo ' '; } add_action('admin_footer', 'custom_admin_js'); //Remove h1 tags and automatically show the kitchen sink function change_mce_options( $init ) { $init['theme_advanced_blockformats'] = 'p,code,h2,h3,h4,h5,h6'; $init['theme_advanced_disable'] = 'forecolor'; $init['wordpress_adv_hidden'] = false; return $init; } add_filter('tiny_mce_before_init', 'change_mce_options'); //ADMIN //Hide specific admin menus from non-admin users (if activated) if(!current_user_can('administrator')){ //Only hide menus for non-admins function remove_menus () { global $menu; //The WordPress admin menu. Contains a multi-dimensional array $menus_to_hide = array(); //The array of menus to hide, really. if(get_option('beautifuldecay_hide_posts_menu',false)) array_push($menus_to_hide,__('Posts')); if(get_option('beautifuldecay_hide_pages_menu',false)) array_push($menus_to_hide,__('Pages')); if(get_option('beautifuldecay_hide_comments_menu',false)) array_push($menus_to_hide,__('Comments')); if(get_option('beautifuldecay_hide_media_menu',false)) array_push($menus_to_hide,__('Media')); if(get_option('beautifuldecay_hide_links_menu',false)) array_push($menus_to_hide,__('Links')); if(get_option('beautifuldecay_hide_profile_menu',false)) array_push($menus_to_hide,__('Profile')); if(get_option('beautifuldecay_hide_tools_menu',false)) array_push($menus_to_hide,__('Tools')); end ($menu); while (prev($menu)){ $value = explode(' ',$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:"" , $menus_to_hide)){unset($menu[key($menu)]);} } } add_action('admin_menu', 'remove_menus'); } //Disable the admin bar for logged in users if(get_option('beautifuldecay_hide_admin_bar',false)==true){ add_filter( 'show_admin_bar', '__return_false' ); } //Hide the admin bar logo for logged in users function annointed_admin_bar_remove() { global $wp_admin_bar; /* Remove their stuff */ $wp_admin_bar->remove_menu('wp-logo'); } if(get_option('beautifuldecay_hide_admin_bar_logo',false)==true){ add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0); } //Add the plugin options page add_action('admin_menu', 'beautifuldecay_barebones_menu'); function beautifuldecay_barebones_menu() { add_theme_page('Theme options', 'manage_options', 'beautifuldecay', 'beautifuldecay_theme_options'); } require_once ( get_stylesheet_directory() . '/theme-options.php' ); //Hide the description and URL fields for attachments, as well as "Insert into post" function hide_attachment_fields($form_fields, $post) { if(!current_user_can('administrator')){ if(get_option('beautifuldecay_hide_attachment_caption',false)==true){ $form_fields['post_excerpt']['value'] = ''; $form_fields['post_excerpt']['input'] = 'hidden'; } if(get_option('beautifuldecay_hide_attachment_description',false)==true){ $form_fields['post_content']['value'] = ''; $form_fields['post_content']['input'] = 'hidden'; } if(get_option('beautifuldecay_hide_attachment_link',false)==true){ $form_fields['url']['value'] = ''; $form_fields['url']['input'] = 'hidden'; } } return $form_fields; } add_filter("attachment_fields_to_edit", "hide_attachment_fields", null, 2); //Hide file upload tabs function remove_media_library_tab($tabs) { if (!current_user_can('administrator') && get_option('beautifuldecay_hide_attachment_library',false)==true && isset($_REQUEST['post_id'])) { unset($tabs['library']); } return $tabs; } add_filter('media_upload_tabs', 'remove_media_library_tab'); //LOCALIZATION //Enable localization load_theme_textdomain('beautifuldecay',get_template_directory() . '/languages'); //UTILITY //URL validator function is_valid_url($URL) { $v = "/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i"; return (bool)preg_match($v, $URL); } ?>