diff --git a/includes/admin/post-types/class-sp-admin-meta-boxes.php b/includes/admin/post-types/class-sp-admin-meta-boxes.php index dfccdb89..8189b3d5 100644 --- a/includes/admin/post-types/class-sp-admin-meta-boxes.php +++ b/includes/admin/post-types/class-sp-admin-meta-boxes.php @@ -173,6 +173,7 @@ class SP_Admin_Meta_Boxes { add_meta_box( 'sp_editordiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_List_Editor::output', 'sp_list', 'normal', 'low' ); // Staff + add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Staff_Shortcode::output', 'sp_staff', 'side', 'default' ); add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Staff_Details::output', 'sp_staff', 'side', 'default' ); add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Staff_Editor::output', 'sp_staff', 'normal', 'low' ); } diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-shortcode.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-shortcode.php new file mode 100644 index 00000000..95c7a7dc --- /dev/null +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-shortcode.php @@ -0,0 +1,29 @@ + +

+ +

+

+ __CLASS__ . '::player_statistics', 'player_list' => __CLASS__ . '::player_list', 'player_gallery' => __CLASS__ . '::player_gallery', + 'staff' => __CLASS__ . '::staff', ); foreach ( $shortcodes as $shortcode => $function ) { diff --git a/includes/shortcodes/class-sp-shortcode-staff.php b/includes/shortcodes/class-sp-shortcode-staff.php new file mode 100644 index 00000000..33db0a99 --- /dev/null +++ b/includes/shortcodes/class-sp-shortcode-staff.php @@ -0,0 +1,25 @@ + 'widget_staff widget_sp_staff', 'description' => __( 'Display a single staff member.', 'sportspress' ) ); + parent::__construct('sp_staff', __( 'Staff', 'sportspress' ) . ' (' . __( 'SportsPress', 'sportspress' ) . ')', $widget_ops); + } + + function widget( $args, $instance ) { + extract($args); + $title = apply_filters('widget_title', empty($instance['title']) ? null : $instance['title'], $instance, $this->id_base); + $id = empty($instance['id']) ? null : $instance['id']; + echo $before_widget; + if ( $title ) + echo $before_title . $title . $after_title; + + // Action to hook into + do_action( 'sportspress_before_widget_template', $args, $instance, 'staff' ); + + sp_get_template( 'staff-photo.php', array( 'id' => $id ) ); + sp_get_template( 'staff-details.php', array( 'id' => $id ) ); + + // Action to hook into + do_action( 'sportspress_after_widget_template', $args, $instance, 'staff' ); + + echo $after_widget; + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['id'] = intval($new_instance['id']); + + // Filter to hook into + $instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'staff' ); + + return $instance; + } + + function form( $instance ) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '' ) ); + $title = strip_tags($instance['title']); + $id = intval($instance['id']); + + // Action to hook into + do_action( 'sportspress_before_widget_template_form', $this, $instance, 'staff' ); + ?> +

+

+ +

+ 'sp_staff', + 'name' => $this->get_field_name('id'), + 'id' => $this->get_field_id('id'), + 'selected' => $id, + 'values' => 'ID', + 'class' => 'widefat', + ); + if ( ! sp_dropdown_pages( $args ) ): + sp_post_adder( 'sp_staff', __( 'Add New', 'sportspress' ) ); + endif; + ?> +

+ +