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('appliance_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"','appliance'), 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('appliance_hide_posts_menu',false)) array_push($menus_to_hide,__('Posts')); if(get_option('appliance_hide_pages_menu',false)) array_push($menus_to_hide,__('Pages')); if(get_option('appliance_hide_comments_menu',false)) array_push($menus_to_hide,__('Comments')); if(get_option('appliance_hide_media_menu',false)) array_push($menus_to_hide,__('Media')); if(get_option('appliance_hide_links_menu',false)) array_push($menus_to_hide,__('Links')); if(get_option('appliance_hide_profile_menu',false)) array_push($menus_to_hide,__('Profile')); if(get_option('appliance_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('appliance_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('appliance_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', 'appliance_barebones_menu'); function appliance_barebones_menu() { add_theme_page('Theme options', 'Theme options', 'manage_options', 'appliance', 'appliance_theme_options'); } function appliance_theme_options() { //Display the theme options include('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('appliance_hide_attachment_caption',false)==true){ $form_fields['post_excerpt']['value'] = ''; $form_fields['post_excerpt']['input'] = 'hidden'; } if(get_option('appliance_hide_attachment_description',false)==true){ $form_fields['post_content']['value'] = ''; $form_fields['post_content']['input'] = 'hidden'; } if(get_option('appliance_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('appliance_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('appliance',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); } ?>