*/ class TICA_Team_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/tica-team-admin.css', $this->version, 'all' ); } /** * Register the JavaScript for the admin area. * @param $hook * * @since 1.0.0 */ public function enqueue_scripts( $hook ) { global $post; // add scripts to add/edit form if ( TICA_Team::POST_TYPE == $post->post_type && in_array( $hook, [ 'post-new.php', 'post.php' ] ) ) { wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/tica-team-edit.js', ['jquery'], $this->version, false ); } } public function register_team_cpt() { // register team post type $labels = array( 'name' => _x( 'Team', 'Post Type General Name', 'e' ), 'singular_name' => _x( 'Team Member', 'Post Type Singular Name', 'tica-team' ), 'menu_name' => __( 'TICA Team', 'tica-team' ), 'name_admin_bar' => __( 'Team', 'tica-team' ), 'archives' => __( 'Team', 'tica-team' ), 'attributes' => __( 'Team Attributes', 'tica-team' ), 'parent_item_colon' => __( 'Parent Item:', 'tica-team' ), 'all_items' => __( 'All Team Members', 'tica-team' ), 'add_new_item' => __( 'Add New Team Member', 'tica-team' ), 'add_new' => __( 'Add New', 'tica-team' ), 'new_item' => __( 'New Team Member', 'tica-team' ), 'edit_item' => __( 'Edit Team Member', 'tica-team' ), 'update_item' => __( 'Update Team Member', 'tica-team' ), 'view_item' => __( 'View Team Member', 'tica-team' ), 'view_items' => __( 'View Team', 'tica-team' ), 'search_items' => __( 'Search Team', 'tica-team' ), 'not_found' => __( 'Not found', 'tica-team' ), 'not_found_in_trash' => __( 'Not found in Trash', 'tica-team' ), 'featured_image' => __( 'Featured Image', 'tica-team' ), 'set_featured_image' => __( 'Set featured image', 'tica-team' ), 'remove_featured_image' => __( 'Remove featured image', 'tica-team' ), 'use_featured_image' => __( 'Use as featured image', 'tica-team' ), 'insert_into_item' => __( /** @lang text */ 'Insert into team member', 'tica-team' ), 'uploaded_to_this_item' => __( 'Uploaded to this team item', 'tica-team' ), 'items_list' => __( 'Team list', 'tica-team' ), 'items_list_navigation' => __( 'Team list navigation', 'tica-team' ), 'filter_items_list' => __( 'Filter Team list', 'tica-team' ), ); $args = array( 'label' => __( 'Team', 'tica-team' ), 'description' => __( 'Team Description', 'tica-team' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'page-attributes', 'thumbnail' ), 'hierarchical' => false, 'public' => false, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 30, 'menu_icon' => plugin_dir_url( __FILE__ ) . 'img/icon.png', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => true, 'capability_type' => 'post', 'rewrite' => [] ); register_post_type( TICA_Team::POST_TYPE, $args ); } public function edit_form_after_title( $post ) { if ( TICA_Team::POST_TYPE == $post->post_type ) { $name = TICA_Team::POST_TYPE . '_position'; $position = get_post_meta( $post->ID, $name, true ); echo <<
POS; } } public function add_meta_boxes() { remove_meta_box( 'pageparentdiv', TICA_Team::POST_TYPE, 'side' ); add_meta_box( TICA_Team::POST_TYPE . '_attribs', 'Team Member Attributes', [ $this, 'attributes_matabox' ], TICA_Team::POST_TYPE, 'side' ); } public function attributes_matabox( $post ) { $prev_intern_name = TICA_Team::POST_TYPE . '_previous_intern'; $prev_intern = ( 'y' == get_post_meta( $post->ID, TICA_Team::POST_TYPE . '_previous_intern', true ) ); ?>

$first_val, TICA_Team::DEFAULT_ORDERBY => 'Order' ] + $columns; } else { $columns = [ TICA_Team::DEFAULT_ORDERBY => 'Order' ] + $columns; } return $columns; } public function sortable_columns( $columns ) { $columns[TICA_Team::DEFAULT_ORDERBY] = [ TICA_Team::DEFAULT_ORDERBY, ( 'DESC' == strtoupper( TICA_Team::DEFAULT_ORDER ) ) ]; return $columns; } public function posts_custom_column( $column, $post_id ) { global $post; esc_html_e( $post->{$column} ); } public function default_order() { if ( TICA_Team::POST_TYPE == @$_REQUEST['post_type'] && empty( $_REQUEST['orderby'] ) ) { $url = get_admin_url( null, '/edit.php?' ); $url .= http_build_query( [ 'post_type' => TICA_Team::POST_TYPE, 'orderby' => TICA_Team::DEFAULT_ORDERBY, 'order' => TICA_Team::DEFAULT_ORDER, ] ); wp_redirect( $url ); } } public function print_admin_styles() { if ( ! is_admin() ) { return; } global $pagenow; $column = TICA_Team::DEFAULT_ORDERBY; if ( $pagenow == 'edit.php' && isset( $_GET['post_type'] ) && $_GET['post_type'] == TICA_Team::POST_TYPE ) { echo << STYLE; } } }