Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- }
- /**
- * Initialize staff member custom post type and taxonomies.
- *
- * @since 1.17
- */
- public function staff_member_init() {
- global $wp_version;
- // Get user options for post type labels.
- if ( ! get_option( '_staff_listing_custom_slug' ) ) {
- $slug = get_option( '_staff_listing_default_slug' );
- } else {
- $slug = get_option( '_staff_listing_custom_slug' );
- }
- if ( ! get_option( '_staff_listing_custom_name_singular' ) ) {
- $singular_name = get_option( '_staff_listing_default_name_singular' );
- } else {
- $singular_name = get_option( '_staff_listing_custom_name_singular' );
- }
- if ( ! get_option( '_staff_listing_custom_name_plural' ) ) {
- $name = get_option( '_staff_listing_default_name_plural' );
- } else {
- $name = get_option( '_staff_listing_custom_name_plural' );
- }
- // TODO Instead of using "Staff" all through here...try to use the custom slug set in options.
- // Set up post type options.
- $labels = array(
- 'name' => $name,
- 'singular_name' => $singular_name,
- 'add_new' => _x( 'Add New', 'staff member', $this->plugin_name ),
- 'add_new_item' => __( 'Add New Staff Member', $this->plugin_name ),
- 'edit_item' => __( 'Edit Staff Member', $this->plugin_name ),
- 'new_item' => __( 'New Staff Member', $this->plugin_name ),
- 'view_item' => __( 'View Staff Member', $this->plugin_name ),
- 'search_items' => __( 'Search Staff Members', $this->plugin_name ),
- 'exclude_from_search' => true,
- 'not_found' => __( 'No staff members found', $this->plugin_name ),
- 'not_found_in_trash' => __( 'No staff members found in Trash', $this->plugin_name ),
- 'parent_item_colon' => '',
- 'all_items' => __( 'All Staff Members', $this->plugin_name ),
- 'menu_name' => __( 'Staff Members', $this->plugin_name ),
- 'featured_image' => __( 'Staff Photo', $this->plugin_name ),
- 'set_featured_image' => __( 'Set Staff Photo', $this->plugin_name ),
- 'remove_featured_image' => __( 'Remove Staff Photo', $this->plugin_name ),
- 'use_featured_image' => __( 'Use Staff Photo', $this->plugin_name ),
- );
- /**
- * sslp_enable_staff_member_archive
- *
- * Return false on this filter and flush your permalinks to disable the staff-members archive page.
- *
- * @since 2.2.0
- *
- * @param $enabled bool Whether or not the archive page is enabled. Default is true.
- */
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'page',
- 'has_archive' => apply_filters( 'sslp_enable_staff_member_archive', true ),
- 'hierarchical' => false,
- 'menu_position' => 100,
- 'rewrite' => array(
- 'slug' => $slug,
- 'with_front' => false,
- ),
- 'supports' => array( 'title', 'thumbnail', 'excerpt' ),
- 'menu_icon' => 'dashicons-groups',
- );
- /**
- * Removing this version check - only 4.7% of WordPress installs are now at or below version 3.8.
- */
- // if ( version_compare( $wp_version, '3.8', '>=' ) ) {
- // $args['menu_icon'] = 'dashicons-groups';
- // }
- // Register post type.
- register_post_type( 'staff-member', $args );
- $group_labels = array(
- 'name' => _x( 'Groups', 'taxonomy general name', $this->plugin_name ),
- 'singular_name' => _x( 'Group', 'taxonomy singular name', $this->plugin_name ),
- 'search_items' => __( 'Search Groups', $this->plugin_name ),
- 'all_items' => __( 'All Groups', $this->plugin_name ),
- 'parent_item' => __( 'Parent Group', $this->plugin_name ),
- 'parent_item_colon' => __( 'Parent Group:', $this->plugin_name ),
- 'edit_item' => __( 'Edit Group', $this->plugin_name ),
- 'update_item' => __( 'Update Group', $this->plugin_name ),
- 'add_new_item' => __( 'Add New Group', $this->plugin_name ),
- 'new_item_name' => __( 'New Group Name', $this->plugin_name ),
- );
- register_taxonomy(
- 'staff-member-group', array( 'staff-member' ), array(
- 'hierarchical' => true,
- 'labels' => $group_labels, /* NOTICE: Here is where the $labels variable is used */
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'group' ),
- )
- );
- }
- /**
- * Maybe flush rewrite rules
- *
- * @since 2.0
- */
- public function maybe_flush_rewrite_rules() {
- if ( get_option( '_staff_listing_flush_rewrite_rules_flag' ) ) {
- // Flush the rewrite rules.
- flush_rewrite_rules();
- // Remove our flag.
- delete_option( '_staff_listing_flush_rewrite_rules_flag' );
- }
- }
- /**
- * Register plugin shortcode(s)
- *
- * @since 1.17
- */
- public function staff_member_register_shortcodes() {
- add_shortcode( 'simple-staff-list', array( $this, 'staff_member_simple_staff_list_shortcode_callback' ) );
- }
- /**
- * Callback for [simple-staff-list]
- *
- * @since 1.17
- * @param array $atts Array of attributes passed in with the shortcode.
- */
- public function staff_member_simple_staff_list_shortcode_callback( $atts = array() ) {
- global $sslp_sc_output;
- $this->simple_staff_list_shortcode_atts = shortcode_atts( $this->simple_staff_list_shortcode_atts_defaults, $atts, 'simple-staff-list' );
- include 'partials/simple-staff-list-shortcode-display.php';
- return $sslp_sc_output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement