_x('Custom Fonts', 'plural'), 'singular_name' => _x('Custom Font', 'singular'), 'menu_name' => _x('Custom Fonts', 'admin menu'), 'name_admin_bar' => _x('Custom Fonts', 'admin bar'), 'add_new' => _x('Add New', 'Add'), 'add_new_item' => __('Add New'), 'new_item' => __('New Font'), 'edit_item' => __('Edit Font'), 'view_item' => __('View Font'), 'all_items' => __('All Fonts'), 'search_items' => __('Search Fonts'), 'not_found' => __('No Pagelayer custom fonts found'), ); $args = array( 'supports' => $supports, 'labels' => $labels, 'public' => false, 'show_in_menu' => false, 'publicly_queryable' => true, 'show_ui' => true, 'exclude_from_search' => true, 'show_in_nav_menus' => false, 'has_archive' => false, 'rewrite' => false, ); // Register custom post type register_post_type(PAGELAYER_FONT_POST_TYPE, $args); remove_post_type_support( PAGELAYER_FONT_POST_TYPE, 'editor'); } // Removing extra columns add_filter( 'manage_'.PAGELAYER_FONT_POST_TYPE.'_posts_columns', 'pagelayer_add_custom_columns' ); function pagelayer_add_custom_columns($columns){ unset( $columns['author'] ); unset( $columns['date'] ); $columns['pl-preview'] = __('Preview'); return $columns; } // Adding preview column data add_action( 'manage_'.PAGELAYER_FONT_POST_TYPE.'_posts_custom_column' , 'pagelayer_add_custom_columns_data', 10, 2 ); function pagelayer_add_custom_columns_data( $column, $post_id ){ if($column == __('pl-preview')){ $font_link = get_post_meta( $post_id, 'pagelayer_font_link', true ); echo ''; echo 'Preview of the CUSTOM font'; } } // Removing row actions add_filter( 'post_row_actions', 'pagelayer_remove_row_actions', 10, 1 ); function pagelayer_remove_row_actions( $actions ){ if( get_post_type() === PAGELAYER_FONT_POST_TYPE ){ foreach($actions as $action => $html){ if($action == 'edit' || $action == 'trash' || $action == 'clone' || $action == 'untrash' || $action == 'delete'){ continue; }else{ unset($actions[$action]); } } } return $actions; } // Removing Screen options add_filter('screen_options_show_screen', 'pagelayer_remove_screen_options', 1, 1); function pagelayer_remove_screen_options($show_screen) { if(get_post_type() == PAGELAYER_FONT_POST_TYPE) { return false; } return $show_screen; } // Removing all other metaboxes. add_action('admin_init', function() {pagelayer_remove_all_metaboxes(PAGELAYER_FONT_POST_TYPE);}); function pagelayer_remove_all_metaboxes($type) { add_filter("get_user_option_meta-box-order_{$type}", function() use($type) { global $wp_meta_boxes; $publishbox = $wp_meta_boxes[$type]['side']['core']['submitdiv']; $fontsBox = $wp_meta_boxes[$type]['normal']['default']['pl-fonts-link-box']; $wp_meta_boxes[$type] = array( 'side' => array( 'core' => array( 'submitdiv' => $publishbox ) ), 'normal' => array( 'default' => array( 'pl-fonts-link-box' => $fontsBox ) ) ); return array(); }, PHP_INT_MAX); } // Hiding extra options of publish metabox add_action( 'admin_head', 'pagelayer_hide_publish_options' ); function pagelayer_hide_publish_options() { if(get_post_type() == PAGELAYER_FONT_POST_TYPE){ echo ''; } } // Adding source metabox add_action('add_meta_boxes', 'pagelayer_add_meta_box'); function pagelayer_add_meta_box(){ add_meta_box( 'pl-fonts-link-box', _x('Source', 'font source'), 'pagelayer_font_link_metabox', PAGELAYER_FONT_POST_TYPE, 'normal', 'default', null); } function pagelayer_font_link_metabox($object){ wp_enqueue_media(); wp_nonce_field('pagelayer-font-post', 'pagelayer'); $link = get_post_meta($object->ID, 'pagelayer_font_link', true); ?>
: |
|
---|