Add table heading option to widgets
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
|
||||
function __construct() {
|
||||
$widget_ops = array('classname' => 'widget_player_gallery widget_sp_player_gallery', 'description' => __( 'Display a gallery of players.', 'sportspress' ) );
|
||||
$widget_ops = array('classname' => 'widget_sportspress widget_player_gallery widget_sp_player_gallery', 'description' => __( 'Display a gallery of players.', 'sportspress' ) );
|
||||
parent::__construct('sportspress-player-gallery', __( 'Player Gallery', 'sportspress' ), $widget_ops);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
$id = empty($instance['id']) ? 0 : $instance['id'];
|
||||
if ( $id <= 0 ) return;
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
$caption = empty($instance['caption']) ? null : $instance['caption'];
|
||||
$number = empty($instance['number']) ? null : $instance['number'];
|
||||
$columns = empty($instance['columns']) ? null : $instance['columns'];
|
||||
$orderby = empty($instance['orderby']) ? 'default' : $instance['orderby'];
|
||||
@@ -27,7 +28,7 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template', $args, $instance, 'player-gallery' );
|
||||
|
||||
sp_get_template( 'player-gallery.php', array( 'id' => $id, 'number' => $number, 'columns' => $columns, 'orderby' => $orderby , 'order' => $order, 'grouping' => 0, 'show_all_players_link' => $show_all_players_link, 'show_names_on_hover' => $show_names_on_hover ) );
|
||||
sp_get_template( 'player-gallery.php', array( 'id' => $id, 'title' => $caption, 'number' => $number, 'columns' => $columns, 'orderby' => $orderby , 'order' => $order, 'grouping' => 0, 'show_all_players_link' => $show_all_players_link, 'show_names_on_hover' => $show_names_on_hover ) );
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'player-gallery' );
|
||||
@@ -40,6 +41,7 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['id'] = intval($new_instance['id']);
|
||||
$instance['caption'] = strip_tags($new_instance['caption']);
|
||||
$instance['number'] = intval($new_instance['number']);
|
||||
$instance['columns'] = intval($new_instance['columns']);
|
||||
$instance['orderby'] = strip_tags($new_instance['orderby']);
|
||||
@@ -54,9 +56,10 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'columns' => 2, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true, 'show_names_on_hover' => false ) );
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'caption' => '', 'number' => 5, 'columns' => 2, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true, 'show_names_on_hover' => false ) );
|
||||
$title = strip_tags($instance['title']);
|
||||
$id = intval($instance['id']);
|
||||
$caption = strip_tags($instance['caption']);
|
||||
$number = intval($instance['number']);
|
||||
$columns = intval($instance['columns']);
|
||||
$orderby = strip_tags($instance['orderby']);
|
||||
@@ -70,6 +73,9 @@ class SP_Widget_Player_Gallery extends WP_Widget {
|
||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?></label>
|
||||
<?php
|
||||
$args = array(
|
||||
|
||||
Reference in New Issue
Block a user