SHARE
TWEET

Untitled

a guest Jun 16th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     }
  2.  
  3.     /**
  4.      * Initialize staff member custom post type and taxonomies.
  5.      *
  6.      * @since 1.17
  7.      */
  8.     public function staff_member_init() {
  9.  
  10.         global $wp_version;
  11.  
  12.         // Get user options for post type labels.
  13.         if ( ! get_option( '_staff_listing_custom_slug' ) ) {
  14.             $slug = get_option( '_staff_listing_default_slug' );
  15.         } else {
  16.             $slug = get_option( '_staff_listing_custom_slug' );
  17.         }
  18.         if ( ! get_option( '_staff_listing_custom_name_singular' ) ) {
  19.             $singular_name = get_option( '_staff_listing_default_name_singular' );
  20.         } else {
  21.             $singular_name = get_option( '_staff_listing_custom_name_singular' );
  22.         }
  23.         if ( ! get_option( '_staff_listing_custom_name_plural' ) ) {
  24.             $name = get_option( '_staff_listing_default_name_plural' );
  25.         } else {
  26.             $name = get_option( '_staff_listing_custom_name_plural' );
  27.         }
  28.  
  29.         // TODO Instead of using "Staff" all through here...try to use the custom slug set in options.
  30.         // Set up post type options.
  31.         $labels = array(
  32.             'name'                  => $name,
  33.             'singular_name'         => $singular_name,
  34.             'add_new'               => _x( 'Add New', 'staff member', $this->plugin_name ),
  35.             'add_new_item'          => __( 'Add New Staff Member', $this->plugin_name ),
  36.             'edit_item'             => __( 'Edit Staff Member', $this->plugin_name ),
  37.             'new_item'              => __( 'New Staff Member', $this->plugin_name ),
  38.             'view_item'             => __( 'View Staff Member', $this->plugin_name ),
  39.             'search_items'          => __( 'Search Staff Members', $this->plugin_name ),
  40.             'exclude_from_search'   => true,
  41.             'not_found'             => __( 'No staff members found', $this->plugin_name ),
  42.             'not_found_in_trash'    => __( 'No staff members found in Trash', $this->plugin_name ),
  43.             'parent_item_colon'     => '',
  44.             'all_items'             => __( 'All Staff Members', $this->plugin_name ),
  45.             'menu_name'             => __( 'Staff Members', $this->plugin_name ),
  46.             'featured_image'        => __( 'Staff Photo', $this->plugin_name ),
  47.             'set_featured_image'    => __( 'Set Staff Photo', $this->plugin_name ),
  48.             'remove_featured_image' => __( 'Remove Staff Photo', $this->plugin_name ),
  49.             'use_featured_image'    => __( 'Use Staff Photo', $this->plugin_name ),
  50.         );
  51.  
  52.         /**
  53.          * sslp_enable_staff_member_archive
  54.          *
  55.          * Return false on this filter and flush your permalinks to disable the staff-members archive page.
  56.          *
  57.          * @since 2.2.0
  58.          *
  59.          * @param $enabled bool Whether or not the archive page is enabled. Default is true.
  60.          */
  61.         $args = array(
  62.             'labels'             => $labels,
  63.             'public'             => true,
  64.             'publicly_queryable' => true,
  65.             'show_ui'            => true,
  66.             'show_in_menu'       => true,
  67.             'query_var'          => true,
  68.             'rewrite'            => true,
  69.             'capability_type'    => 'page',
  70.             'has_archive'        => apply_filters( 'sslp_enable_staff_member_archive', true ),
  71.             'hierarchical'       => false,
  72.             'menu_position'      => 100,
  73.             'rewrite'            => array(
  74.                 'slug'       => $slug,
  75.                 'with_front' => false,
  76.             ),
  77.             'supports'           => array( 'title', 'thumbnail', 'excerpt' ),
  78.             'menu_icon'          => 'dashicons-groups',
  79.         );
  80.  
  81.         /**
  82.          * Removing this version check - only 4.7% of WordPress installs are now at or below version 3.8.
  83.          */
  84.         // if ( version_compare( $wp_version, '3.8', '>=' ) ) {
  85.         //  $args['menu_icon'] = 'dashicons-groups';
  86.         // }
  87.  
  88.         // Register post type.
  89.         register_post_type( 'staff-member', $args );
  90.  
  91.         $group_labels = array(
  92.             'name'              => _x( 'Groups', 'taxonomy general name', $this->plugin_name ),
  93.             'singular_name'     => _x( 'Group', 'taxonomy singular name', $this->plugin_name ),
  94.             'search_items'      => __( 'Search Groups', $this->plugin_name ),
  95.             'all_items'         => __( 'All Groups', $this->plugin_name ),
  96.             'parent_item'       => __( 'Parent Group', $this->plugin_name ),
  97.             'parent_item_colon' => __( 'Parent Group:', $this->plugin_name ),
  98.             'edit_item'         => __( 'Edit Group', $this->plugin_name ),
  99.             'update_item'       => __( 'Update Group', $this->plugin_name ),
  100.             'add_new_item'      => __( 'Add New Group', $this->plugin_name ),
  101.             'new_item_name'     => __( 'New Group Name', $this->plugin_name ),
  102.         );
  103.         register_taxonomy(
  104.             'staff-member-group', array( 'staff-member' ), array(
  105.                 'hierarchical' => true,
  106.                 'labels'       => $group_labels, /* NOTICE: Here is where the $labels variable is used */
  107.                 'show_ui'      => true,
  108.                 'query_var'    => true,
  109.                 'rewrite'      => array( 'slug' => 'group' ),
  110.             )
  111.         );
  112.  
  113.     }
  114.  
  115.     /**
  116.      * Maybe flush rewrite rules
  117.      *
  118.      * @since 2.0
  119.      */
  120.     public function maybe_flush_rewrite_rules() {
  121.  
  122.         if ( get_option( '_staff_listing_flush_rewrite_rules_flag' ) ) {
  123.  
  124.             // Flush the rewrite rules.
  125.             flush_rewrite_rules();
  126.  
  127.             // Remove our flag.
  128.             delete_option( '_staff_listing_flush_rewrite_rules_flag' );
  129.  
  130.         }
  131.  
  132.     }
  133.  
  134.  
  135.     /**
  136.      * Register plugin shortcode(s)
  137.      *
  138.      * @since 1.17
  139.      */
  140.     public function staff_member_register_shortcodes() {
  141.  
  142.         add_shortcode( 'simple-staff-list', array( $this, 'staff_member_simple_staff_list_shortcode_callback' ) );
  143.  
  144.     }
  145.  
  146.     /**
  147.      * Callback for [simple-staff-list]
  148.      *
  149.      * @since 1.17
  150.      * @param array $atts Array of attributes passed in with the shortcode.
  151.      */
  152.     public function staff_member_simple_staff_list_shortcode_callback( $atts = array() ) {
  153.  
  154.         global $sslp_sc_output;
  155.  
  156.         $this->simple_staff_list_shortcode_atts = shortcode_atts( $this->simple_staff_list_shortcode_atts_defaults, $atts, 'simple-staff-list' );
  157.         include 'partials/simple-staff-list-shortcode-display.php';
  158.         return $sslp_sc_output;
  159.  
  160.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top