Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-revie.../includes/widgets
File: class-wp-review-tab-widget.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Tab widget
[2] Fix | Delete
*
[3] Fix | Delete
* @package WP_Review
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Class WP_Review_Tab_Widget
[8] Fix | Delete
*/
[9] Fix | Delete
class WP_Review_Tab_Widget extends WP_Widget {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Class constructor.
[13] Fix | Delete
*/
[14] Fix | Delete
public function __construct() {
[15] Fix | Delete
// ajax functions.
[16] Fix | Delete
add_action( 'wp_ajax_wp_review_tab_widget_content', array( $this, 'ajax_wp_review_tab_widget_content' ) );
[17] Fix | Delete
add_action( 'wp_ajax_nopriv_wp_review_tab_widget_content', array( $this, 'ajax_wp_review_tab_widget_content' ) );
[18] Fix | Delete
[19] Fix | Delete
// css.
[20] Fix | Delete
add_action( 'wp_enqueue_scripts', array( $this, 'wp_review_tab_register_scripts' ) );
[21] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'wp_review_tab_admin_scripts' ) );
[22] Fix | Delete
add_action( 'customize_controls_enqueue_scripts', array( $this, 'wp_review_tab_admin_scripts' ) );
[23] Fix | Delete
[24] Fix | Delete
$widget_ops = array(
[25] Fix | Delete
'classname' => 'widget_wp_review_tab',
[26] Fix | Delete
'description' => __( 'Display Reviews in tabbed format.', 'wp-review' ),
[27] Fix | Delete
);
[28] Fix | Delete
$control_ops = array(
[29] Fix | Delete
'width' => 200,
[30] Fix | Delete
'height' => 350,
[31] Fix | Delete
);
[32] Fix | Delete
parent::__construct( 'wp_review_tab_widget', __( 'WP Review Widget', 'wp-review' ), $widget_ops, $control_ops );
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Enqueues admin scripts.
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $hook Admin page hook.
[39] Fix | Delete
*/
[40] Fix | Delete
public function wp_review_tab_admin_scripts( $hook ) {
[41] Fix | Delete
if ( 'widgets.php' !== $hook ) {
[42] Fix | Delete
return;
[43] Fix | Delete
}
[44] Fix | Delete
wp_register_script( 'wp_review_tab_widget_admin', WP_REVIEW_URI . 'admin/assets/js/wp-review-tab-widget-admin.js', array( 'jquery' ), '3.0.0', true );
[45] Fix | Delete
wp_enqueue_script( 'wp_review_tab_widget_admin' );
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Registers scripts.
[50] Fix | Delete
*/
[51] Fix | Delete
public function wp_review_tab_register_scripts() {
[52] Fix | Delete
// JS.
[53] Fix | Delete
wp_register_script( 'wp_review_tab_widget', WP_REVIEW_ASSETS . 'js/wp-review-tab-widget.js', array( 'jquery' ), '3.0.0', true );
[54] Fix | Delete
wp_localize_script(
[55] Fix | Delete
'wp_review_tab_widget',
[56] Fix | Delete
'wp_review_tab',
[57] Fix | Delete
array(
[58] Fix | Delete
'ajax_url' => admin_url( 'admin-ajax.php' ),
[59] Fix | Delete
)
[60] Fix | Delete
);
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Shows widget form.
[65] Fix | Delete
*
[66] Fix | Delete
* @param array $instance Widget instance.
[67] Fix | Delete
*/
[68] Fix | Delete
public function form( $instance ) {
[69] Fix | Delete
$instance = wp_parse_args(
[70] Fix | Delete
(array) $instance,
[71] Fix | Delete
array(
[72] Fix | Delete
'tabs' => array(
[73] Fix | Delete
'toprated' => 1,
[74] Fix | Delete
'recent' => 1,
[75] Fix | Delete
'mostvoted' => 0,
[76] Fix | Delete
'custom' => 0,
[77] Fix | Delete
),
[78] Fix | Delete
'tab_order' => array(
[79] Fix | Delete
'toprated' => 1,
[80] Fix | Delete
'recent' => 2,
[81] Fix | Delete
'mostvoted' => 3,
[82] Fix | Delete
'custom' => 4,
[83] Fix | Delete
),
[84] Fix | Delete
'tab_titles' => array(
[85] Fix | Delete
'toprated' => __( 'Top Rated', 'wp-review' ),
[86] Fix | Delete
'recent' => __( 'Recent', 'wp-review' ),
[87] Fix | Delete
'mostvoted' => __( 'Most Voted', 'wp-review' ),
[88] Fix | Delete
'custom' => __( 'Editor\'s choice', 'wp-review' ),
[89] Fix | Delete
),
[90] Fix | Delete
'allow_pagination' => 1,
[91] Fix | Delete
'review_type' => '',
[92] Fix | Delete
'post_num' => '5',
[93] Fix | Delete
'comment_num' => '5',
[94] Fix | Delete
'thumb_size' => 'small',
[95] Fix | Delete
'show_date' => 1,
[96] Fix | Delete
'top_rated_posts' => 'visitors',
[97] Fix | Delete
'restrict_recent_reviews' => 0,
[98] Fix | Delete
'custom_reviews' => '',
[99] Fix | Delete
'title_length' => apply_filters( 'wpt_title_length_default', '15' ),
[100] Fix | Delete
)
[101] Fix | Delete
);
[102] Fix | Delete
[103] Fix | Delete
// Fix notice when switch to new version.
[104] Fix | Delete
if ( ! isset( $instance['tabs']['recent_ratings'] ) ) {
[105] Fix | Delete
$instance['tabs']['recent_ratings'] = 0;
[106] Fix | Delete
}
[107] Fix | Delete
if ( ! isset( $instance['tab_order']['recent_ratings'] ) ) {
[108] Fix | Delete
$instance['tab_order']['recent_ratings'] = 4;
[109] Fix | Delete
}
[110] Fix | Delete
if ( ! isset( $instance['tab_titles']['recent_ratings'] ) ) {
[111] Fix | Delete
$instance['tab_titles']['recent_ratings'] = __( 'Comments', 'wp-review' );
[112] Fix | Delete
}
[113] Fix | Delete
extract( $instance ); // phpcs:ignore
[114] Fix | Delete
?>
[115] Fix | Delete
<div class="wp_review_tab_options_form">
[116] Fix | Delete
<h4><?php esc_html_e( 'Select Tabs', 'wp-review' ); ?></h4>
[117] Fix | Delete
[118] Fix | Delete
<div class="wp_review_tab_select_tabs">
[119] Fix | Delete
<label class="alignleft" style="display: block; width: 50%; margin-bottom: 7px;" for="<?php echo $this->get_field_id( 'tabs' ); ?>_toprated">
[120] Fix | Delete
<input type="checkbox" class="checkbox wp_review_tab_enable_toprated" id="<?php echo $this->get_field_id( 'tabs' ); ?>_toprated" name="<?php echo $this->get_field_name( 'tabs' ); ?>[toprated]" value="1" <?php if ( isset( $tabs['toprated'] ) ) checked( 1, $tabs['toprated'], true ); // phpcs:ignore ?> />
[121] Fix | Delete
<?php esc_html_e( 'Top Rated', 'wp-review' ); ?>
[122] Fix | Delete
</label>
[123] Fix | Delete
<label class="alignleft" style="display: block; width: 50%; margin-bottom: 7px;" for="<?php echo $this->get_field_id( 'tabs' ); ?>_recent">
[124] Fix | Delete
<input type="checkbox" class="checkbox wp_review_tab_enable_recent" id="<?php echo $this->get_field_id( 'tabs' ); ?>_recent" name="<?php echo $this->get_field_name( 'tabs' ); ?>[recent]" value="1" <?php if ( isset( $tabs['recent'] ) ) checked( 1, $tabs['recent'], true ); // phpcs:ignore ?> />
[125] Fix | Delete
<?php esc_html_e( 'Recent Reviews', 'wp-review' ); ?>
[126] Fix | Delete
</label>
[127] Fix | Delete
<label class="alignleft" style="display: block; width: 50%; margin-bottom: 7px;" for="<?php echo $this->get_field_id( 'tabs' ); ?>_mostvoted">
[128] Fix | Delete
<input type="checkbox" class="checkbox wp_review_tab_enable_mostvoted" id="<?php echo $this->get_field_id( 'tabs' ); ?>_mostvoted" name="<?php echo $this->get_field_name( 'tabs' ); ?>[mostvoted]" value="1" <?php if ( isset( $tabs['mostvoted'] ) ) checked( 1, $tabs['mostvoted'], true ); // phpcs:ignore ?> />
[129] Fix | Delete
<?php esc_html_e( 'Most Voted', 'wp-review' ); ?>
[130] Fix | Delete
</label>
[131] Fix | Delete
<label class="alignleft" style="display: block; width: 50%; margin-bottom: 7px;" for="<?php echo $this->get_field_id( 'tabs' ); ?>_custom">
[132] Fix | Delete
<input type="checkbox" class="checkbox wp_review_tab_enable_custom" id="<?php echo $this->get_field_id( 'tabs' ); ?>_custom" name="<?php echo $this->get_field_name( 'tabs' ); ?>[custom]" value="1" <?php if ( isset( $tabs['custom'] ) ) { checked( 1, $tabs['custom'], true ); } // phpcs:ignore ?> />
[133] Fix | Delete
<?php esc_html_e( 'Custom', 'wp-review' ); ?>
[134] Fix | Delete
</label>
[135] Fix | Delete
</div>
[136] Fix | Delete
<div class="clear"></div>
[137] Fix | Delete
[138] Fix | Delete
<div class="wp_review_tab_advanced_options">
[139] Fix | Delete
<?php $hide = ! isset( $tabs['recent_ratings'] ) ? 'wpr-hide' : ''; ?>
[140] Fix | Delete
<p class="wp_review_restrict_recent_review" <?php echo esc_attr( $hide ); ?>>
[141] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'restrict_recent_reviews' ) ); ?>">
[142] Fix | Delete
<span class="wp-review-disabled inline-block">
[143] Fix | Delete
<input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'restrict_recent_reviews' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'restrict_recent_reviews' ) ); ?>" value="1" disabled />
[144] Fix | Delete
<?php esc_html_e( 'Restrict recent reviews to current post', 'wp-review' ); ?>
[145] Fix | Delete
</span>
[146] Fix | Delete
</label>
[147] Fix | Delete
</p>
[148] Fix | Delete
[149] Fix | Delete
<p class="wp-review-disabled wp_review_tab_top_rated_filter">
[150] Fix | Delete
<label for="<?php echo $this->get_field_id( 'top_rated_posts' ); ?>"><?php _e( 'Top Rated Posts By:', 'wp-review' ); ?></label>
[151] Fix | Delete
<?php wp_review_print_pro_text(); ?>
[152] Fix | Delete
[153] Fix | Delete
<span class="inline-block has-bg">
[154] Fix | Delete
<select id="<?php echo $this->get_field_id( 'top_rated_posts' ); ?>" name="<?php echo $this->get_field_name( 'top_rated_posts' ); ?>" style="margin-left: 12px;" disabled>
[155] Fix | Delete
<option value="visitors"><?php _e( 'Visitors', 'wp-review' ); ?></option>
[156] Fix | Delete
<option value="comments"><?php _e( 'Comments', 'wp-review' ); ?></option>
[157] Fix | Delete
</select>
[158] Fix | Delete
</span>
[159] Fix | Delete
</p>
[160] Fix | Delete
[161] Fix | Delete
<p class="wp_review_tab_review_type">
[162] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'review_type' ) ); ?>"><?php esc_html_e( 'Review type:', 'wp-review' ); ?></label>
[163] Fix | Delete
<select name="<?php echo esc_attr( $this->get_field_name( 'review_type' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'review_type' ) ); ?>">
[164] Fix | Delete
<?php
[165] Fix | Delete
$review_types = wp_review_get_rating_types();
[166] Fix | Delete
foreach ( $review_types as $name => $type ) {
[167] Fix | Delete
$disabled = ! in_array( $name, array( 'star', 'point', 'percentage' ), true );
[168] Fix | Delete
printf(
[169] Fix | Delete
'<option value="%1$s" class="%2$s" %3$s>%4$s</option>',
[170] Fix | Delete
esc_attr( $name ),
[171] Fix | Delete
$disabled ? 'disabled' : '',
[172] Fix | Delete
selected( $name, $review_type, false ),
[173] Fix | Delete
esc_html( $type['label'] )
[174] Fix | Delete
);
[175] Fix | Delete
}
[176] Fix | Delete
?>
[177] Fix | Delete
</select>
[178] Fix | Delete
</p>
[179] Fix | Delete
[180] Fix | Delete
<p>
[181] Fix | Delete
<label for="<?php echo $this->get_field_id( 'allow_pagination' ); ?>">
[182] Fix | Delete
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'allow_pagination' ); ?>" name="<?php echo $this->get_field_name( 'allow_pagination' ); ?>" value="1" <?php if ( isset( $allow_pagination ) ) { checked( 1, $allow_pagination, true ); } // phpcs:ignore ?> />
[183] Fix | Delete
<?php _e( 'Allow pagination', 'wp-review' ); ?>
[184] Fix | Delete
</label>
[185] Fix | Delete
</p>
[186] Fix | Delete
[187] Fix | Delete
<p>
[188] Fix | Delete
<label for="<?php echo $this->get_field_id( 'post_num' ); ?>"><?php _e( 'Number of reviews to show:', 'wp-review' ); ?>
[189] Fix | Delete
<br />
[190] Fix | Delete
<input id="<?php echo $this->get_field_id( 'post_num' ); ?>" name="<?php echo $this->get_field_name( 'post_num' ); ?>" type="number" min="1" step="1" value="<?php echo $post_num; ?>" />
[191] Fix | Delete
</label>
[192] Fix | Delete
</p>
[193] Fix | Delete
[194] Fix | Delete
<p>
[195] Fix | Delete
<label for="<?php echo $this->get_field_id( 'title_length' ); ?>"><?php _e( 'Title length (words):', 'mts_wpt' ); ?>
[196] Fix | Delete
<br />
[197] Fix | Delete
<!-- dummy input so that WP doesn't pick up title_length as title -->
[198] Fix | Delete
<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="" style="display: none;" />
[199] Fix | Delete
<input id="<?php echo $this->get_field_id( 'title_length' ); ?>" name="<?php echo $this->get_field_name( 'title_length' ); ?>" type="number" min="1" step="1" value="<?php echo $title_length; ?>" />
[200] Fix | Delete
</label>
[201] Fix | Delete
</p>
[202] Fix | Delete
[203] Fix | Delete
<p class="wp_review_tab_thumbnail_size">
[204] Fix | Delete
<label for="<?php echo $this->get_field_id( 'thumb_size' ); ?>"><?php _e( 'Thumbnail size:', 'wp-review' ); ?></label>
[205] Fix | Delete
<select id="<?php echo $this->get_field_id( 'thumb_size' ); ?>" name="<?php echo $this->get_field_name( 'thumb_size' ); ?>" style="margin-left: 12px;">
[206] Fix | Delete
<option value="small" <?php selected( $thumb_size, 'small', true ); ?>><?php _e( 'Small', 'wp-review' ); ?></option>
[207] Fix | Delete
<option value="large" <?php selected( $thumb_size, 'large', true ); ?>><?php _e( 'Large', 'wp-review' ); ?></option>
[208] Fix | Delete
</select>
[209] Fix | Delete
</p>
[210] Fix | Delete
[211] Fix | Delete
<p>
[212] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>"><?php esc_html_e( 'Extra information', 'wp-review' ); ?></label>
[213] Fix | Delete
<select name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" class="widefat">
[214] Fix | Delete
<option value=""><?php esc_html_e( 'None', 'wp-review' ); ?></option>
[215] Fix | Delete
<option value="1" <?php selected( $instance['show_date'], 1 ); ?>><?php esc_html_e( 'Post date', 'wp-review' ); ?></option>
[216] Fix | Delete
<option value="2" class="disabled"><?php esc_html_e( 'Number of reviews', 'wp-review' ); ?></option>
[217] Fix | Delete
</select>
[218] Fix | Delete
</p>
[219] Fix | Delete
[220] Fix | Delete
<p class="wp_review_tab_custom_reviews"<?php echo empty( $tabs['custom'] ) ? ' style="display: none;"' : ''; ?>>
[221] Fix | Delete
<label for="<?php echo $this->get_field_id( 'custom_reviews' ); ?>"><?php _e( 'Reviews on Custom tab:', 'wp-review' ); ?>
[222] Fix | Delete
<br />
[223] Fix | Delete
<input id="<?php echo $this->get_field_id( 'custom_reviews' ); ?>" name="<?php echo $this->get_field_name( 'custom_reviews' ); ?>" type="text" value="<?php echo $custom_reviews; ?>" />
[224] Fix | Delete
<br />
[225] Fix | Delete
<span style="color: #999;">Add IDs, separated by commas, eg. <em>145, 168, 229</em></span>
[226] Fix | Delete
</label>
[227] Fix | Delete
</p>
[228] Fix | Delete
[229] Fix | Delete
<div class="clear"></div>
[230] Fix | Delete
[231] Fix | Delete
<h4><a href="#" class="wp_review_tab_titles_header"><?php _e( 'Tab Titles', 'wp-review' ); ?></a> | <a href="#" class="wp_review_tab_order_header"><?php _e( 'Tab Order', 'wp-review' ); ?></a></h4>
[232] Fix | Delete
[233] Fix | Delete
<div class="wp_review_tab_order" style="display: none;">
[234] Fix | Delete
[235] Fix | Delete
<label class="alignleft wp_review_tab_toprated_order" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_toprated" style="width: 50%;<?php echo empty( $tabs['toprated'] ) ? ' display: none;' : ''; ?>">
[236] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_order' ); ?>_toprated" name="<?php echo $this->get_field_name( 'tab_order' ); ?>[toprated]" type="number" min="1" step="1" value="<?php echo $tab_order['toprated']; ?>" style="width: 48px;" />
[237] Fix | Delete
<?php _e( 'Top Rated', 'wp-review' ); ?>
[238] Fix | Delete
</label>
[239] Fix | Delete
<label class="alignleft wp_review_tab_recent_order" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_recent" style="width: 50%;<?php echo empty( $tabs['recent'] ) ? ' display: none;' : ''; ?>">
[240] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_order' ); ?>_recent" name="<?php echo $this->get_field_name( 'tab_order' ); ?>[recent]" type="number" min="1" step="1" value="<?php echo $tab_order['recent']; ?>" style="width: 48px;" />
[241] Fix | Delete
<?php _e( 'Recent', 'wp-review' ); ?>
[242] Fix | Delete
</label>
[243] Fix | Delete
<label class="alignleft wp_review_tab_mostvoted_order" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_mostvoted" style="width: 50%;<?php echo empty( $tabs['mostvoted'] ) ? ' display: none;' : ''; ?>">
[244] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_order' ); ?>_mostvoted" name="<?php echo $this->get_field_name( 'tab_order' ); ?>[mostvoted]" type="number" min="1" step="1" value="<?php echo $tab_order['mostvoted']; ?>" style="width: 48px;" />
[245] Fix | Delete
<?php _e( 'Most Voted', 'wp-review' ); ?>
[246] Fix | Delete
</label>
[247] Fix | Delete
<label class="alignleft wp_review_tab_recent_ratings_order" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_recent_ratings" style="width: 50%;<?php echo empty( $tabs['recent_ratings'] ) ? ' display: none;' : ''; ?>">
[248] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_order' ); ?>_mostvoted" name="<?php echo $this->get_field_name( 'tab_order' ); ?>[recent_ratings]" type="number" min="1" step="1" value="<?php echo $tab_order['recent_ratings']; ?>" style="width: 48px;" />
[249] Fix | Delete
<?php _e( 'Recent Ratings', 'wp-review' ); ?>
[250] Fix | Delete
</label>
[251] Fix | Delete
<label class="alignleft wp_review_tab_custom_order" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_custom" style="width: 50%;<?php echo empty( $tabs['custom'] ) ? ' display: none;' : ''; ?>">
[252] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_order' ); ?>_custom" name="<?php echo $this->get_field_name( 'tab_order' ); ?>[custom]" type="number" min="1" step="1" value="<?php echo $tab_order['custom']; ?>" style="width: 48px;" />
[253] Fix | Delete
<?php _e( 'Custom', 'wp-review' ); ?>
[254] Fix | Delete
</label>
[255] Fix | Delete
</div>
[256] Fix | Delete
<div class="clear" style="margin-bottom: 15px;"></div>
[257] Fix | Delete
[258] Fix | Delete
<div class="wp_review_tab_titles" style="display: none;">
[259] Fix | Delete
[260] Fix | Delete
<label class="alignleft wp_review_tab_toprated_title" for="<?php echo $this->get_field_id( 'tab_titles' ); ?>_toprated" style="width: 50%;<?php echo empty( $tabs['toprated'] ) ? ' display: none;' : ''; ?>">
[261] Fix | Delete
<?php _e( 'Top Rated', 'wp-review' ); ?>
[262] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_titles' ); ?>_toprated" name="<?php echo $this->get_field_name( 'tab_titles' ); ?>[toprated]" type="text" value="<?php echo esc_attr( $tab_titles['toprated'] ); ?>" style="width: 98%;" />
[263] Fix | Delete
</label>
[264] Fix | Delete
<label class="alignleft wp_review_tab_recent_title" for="<?php echo $this->get_field_id( 'tab_titles' ); ?>_recent" style="width: 50%;<?php echo empty( $tabs['recent'] ) ? ' display: none;' : ''; ?>">
[265] Fix | Delete
<?php _e( 'Recent', 'wp-review' ); ?>
[266] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_titles' ); ?>_recent" name="<?php echo $this->get_field_name( 'tab_titles' ); ?>[recent]" type="text" value="<?php echo esc_attr( $tab_titles['recent'] ); ?>" style="width: 98%;" />
[267] Fix | Delete
</label>
[268] Fix | Delete
<label class="alignleft wp_review_tab_mostvoted_title" for="<?php echo $this->get_field_id( 'tab_titles' ); ?>_mostvoted" style="width: 50%;<?php echo empty( $tabs['mostvoted'] ) ? ' display: none;' : ''; ?>">
[269] Fix | Delete
<?php _e( 'Most Voted', 'wp-review' ); ?>
[270] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_titles' ); ?>_mostvoted" name="<?php echo $this->get_field_name( 'tab_titles' ); ?>[mostvoted]" type="text" value="<?php echo esc_attr( $tab_titles['mostvoted'] ); ?>" style="width: 98%;" />
[271] Fix | Delete
</label>
[272] Fix | Delete
<label class="alignleft wp_review_tab_recent_ratings_title" for="<?php echo $this->get_field_id( 'tab_titles' ); ?>_recent_ratings" style="width: 50%;<?php echo empty( $tabs['recent_ratings'] ) ? ' display: none;' : ''; ?>">
[273] Fix | Delete
<?php _e( 'Recent Ratings', 'wp-review' ); ?>
[274] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_titles' ); ?>_recent_ratings" name="<?php echo $this->get_field_name( 'tab_titles' ); ?>[recent_ratings]" type="text" value="<?php echo esc_attr( $tab_titles['recent_ratings'] ); ?>" style="width: 98%;" />
[275] Fix | Delete
</label>
[276] Fix | Delete
<label class="alignleft wp_review_tab_custom_title" for="<?php echo $this->get_field_id( 'tab_titles' ); ?>_custom" style="width: 50%;<?php echo empty( $tabs['custom'] ) ? ' display: none;' : ''; ?>">
[277] Fix | Delete
<?php _e( 'Custom', 'wp-review' ); ?>
[278] Fix | Delete
<input id="<?php echo $this->get_field_id( 'tab_titles' ); ?>_custom" name="<?php echo $this->get_field_name( 'tab_titles' ); ?>[custom]" type="text" value="<?php echo esc_attr( $tab_titles['custom'] ); ?>" style="width: 98%;" />
[279] Fix | Delete
</label>
[280] Fix | Delete
</div>
[281] Fix | Delete
<div class="clear" style="margin-bottom: 15px;"></div>
[282] Fix | Delete
[283] Fix | Delete
</div><!-- .wp_review_tab_advanced_options -->
[284] Fix | Delete
</div><!-- .wp_review_tab_options_form -->
[285] Fix | Delete
<?php
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
/**
[289] Fix | Delete
* Updates widget values.
[290] Fix | Delete
*
[291] Fix | Delete
* @param array $new_instance New instance.
[292] Fix | Delete
* @param array $old_instance Old instance.
[293] Fix | Delete
* @return array
[294] Fix | Delete
*/
[295] Fix | Delete
public function update( $new_instance, $old_instance ) {
[296] Fix | Delete
$instance = $old_instance;
[297] Fix | Delete
$instance['tabs'] = $new_instance['tabs'];
[298] Fix | Delete
$instance['tab_order'] = $new_instance['tab_order'];
[299] Fix | Delete
$instance['tab_titles'] = $new_instance['tab_titles'];
[300] Fix | Delete
$instance['review_type'] = isset( $new_instance['review_type'] ) ? $new_instance['review_type'] : '';
[301] Fix | Delete
$instance['allow_pagination'] = $new_instance['allow_pagination'];
[302] Fix | Delete
$instance['post_num'] = $new_instance['post_num'];
[303] Fix | Delete
$instance['title_length'] = $new_instance['title_length'];
[304] Fix | Delete
$instance['thumb_size'] = $new_instance['thumb_size'];
[305] Fix | Delete
$instance['show_date'] = isset( $new_instance['show_date'] ) ? intval( $new_instance['show_date'] ) : 1;
[306] Fix | Delete
$instance['custom_reviews'] = $new_instance['custom_reviews'];
[307] Fix | Delete
$instance['restrict_recent_reviews'] = $new_instance['restrict_recent_reviews'];
[308] Fix | Delete
$instance['top_rated_posts'] = $new_instance['top_rated_posts'];
[309] Fix | Delete
return $instance;
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
/**
[313] Fix | Delete
* Shows widget template.
[314] Fix | Delete
*
[315] Fix | Delete
* @param array $args Widget args.
[316] Fix | Delete
* @param array $instance Widget instance.
[317] Fix | Delete
*/
[318] Fix | Delete
public function widget( $args, $instance ) {
[319] Fix | Delete
global $post;
[320] Fix | Delete
extract( $args, EXTR_SKIP ); // phpcs:ignore
[321] Fix | Delete
extract( $instance, EXTR_SKIP ); // phpcs:ignore
[322] Fix | Delete
wp_enqueue_script( 'wp_review_tab_widget' );
[323] Fix | Delete
wp_enqueue_script( 'wp_review-js' );
[324] Fix | Delete
wp_enqueue_style( 'wp_review-style' );
[325] Fix | Delete
wp_enqueue_style( 'wp_review_tab_widget' );
[326] Fix | Delete
[327] Fix | Delete
if ( empty( $tabs ) ) {
[328] Fix | Delete
$tabs = array(
[329] Fix | Delete
'recent' => 1,
[330] Fix | Delete
'toprated' => 1,
[331] Fix | Delete
);
[332] Fix | Delete
}
[333] Fix | Delete
$tabs_count = count( $tabs );
[334] Fix | Delete
if ( $tabs_count <= 1 ) {
[335] Fix | Delete
$tabs_count = 1;
[336] Fix | Delete
} elseif ( $tabs_count > 5 ) {
[337] Fix | Delete
$tabs_count = 5;
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
$tab_titles = wp_parse_args(
[341] Fix | Delete
$tab_titles,
[342] Fix | Delete
array(
[343] Fix | Delete
'toprated' => __( 'Top Rated', 'wp-review' ),
[344] Fix | Delete
'recent' => __( 'Recent', 'wp-review' ),
[345] Fix | Delete
'mostvoted' => __( 'Most Voted', 'wp-review' ),
[346] Fix | Delete
'custom' => __( 'Editor\'s choice', 'wp-review' ),
[347] Fix | Delete
)
[348] Fix | Delete
);
[349] Fix | Delete
[350] Fix | Delete
$available_tabs = array(
[351] Fix | Delete
'toprated' => $tab_titles['toprated'],
[352] Fix | Delete
'recent' => $tab_titles['recent'],
[353] Fix | Delete
'mostvoted' => $tab_titles['mostvoted'],
[354] Fix | Delete
'custom' => $tab_titles['custom'],
[355] Fix | Delete
);
[356] Fix | Delete
[357] Fix | Delete
if ( isset( $tab_order['recent_ratings'] ) ) {
[358] Fix | Delete
unset( $tab_order['recent_ratings'] );
[359] Fix | Delete
}
[360] Fix | Delete
if ( isset( $available_tabs['recent_ratings'] ) ) {
[361] Fix | Delete
unset( $available_tabs['recent_ratings'] );
[362] Fix | Delete
}
[363] Fix | Delete
array_multisort( $tab_order, $available_tabs );
[364] Fix | Delete
?>
[365] Fix | Delete
<?php echo wp_kses_post( $before_widget ); ?>
[366] Fix | Delete
<div class="wp_review_tab_widget_content" id="<?php echo esc_attr( $widget_id ); ?>_content">
[367] Fix | Delete
<ul class="wp-review-tabs has-<?php echo intval( $tabs_count ); ?>-tabs">
[368] Fix | Delete
<?php foreach ( $available_tabs as $tab => $label ) : ?>
[369] Fix | Delete
<?php if ( ! empty( $tabs[ $tab ] ) ) : ?>
[370] Fix | Delete
<li class="tab_title"><a href="#" id="<?php echo esc_attr( $tab ); ?>-tab"><?php echo esc_html( $label ); ?></a></li>
[371] Fix | Delete
<?php endif; ?>
[372] Fix | Delete
<?php endforeach; ?>
[373] Fix | Delete
</ul> <!--end .tabs-->
[374] Fix | Delete
<div class="clear"></div>
[375] Fix | Delete
<div class="inside">
[376] Fix | Delete
<?php if ( ! empty( $tabs['toprated'] ) ) : ?>
[377] Fix | Delete
<div id="toprated-tab-content" class="tab-content">
[378] Fix | Delete
</div> <!--end #toprated-tab-content-->
[379] Fix | Delete
<?php endif; ?>
[380] Fix | Delete
<?php if ( ! empty( $tabs['recent'] ) ) : ?>
[381] Fix | Delete
<div id="recent-tab-content" class="tab-content">
[382] Fix | Delete
</div> <!--end #recent-tab-content-->
[383] Fix | Delete
<?php endif; ?>
[384] Fix | Delete
<?php if ( ! empty( $tabs['mostvoted'] ) ) : ?>
[385] Fix | Delete
<div id="mostvoted-tab-content" class="tab-content">
[386] Fix | Delete
<ul></ul>
[387] Fix | Delete
</div> <!--end #mostvoted-tab-content-->
[388] Fix | Delete
<?php endif; ?>
[389] Fix | Delete
<?php if ( ! empty( $tabs['recent_ratings'] ) ) : ?>
[390] Fix | Delete
<div id="recent_ratings-tab-content" class="tab-content">
[391] Fix | Delete
<ul></ul>
[392] Fix | Delete
</div> <!--end #recent_ratings-tab-content-->
[393] Fix | Delete
<?php endif; ?>
[394] Fix | Delete
<?php if ( ! empty( $tabs['custom'] ) ) : ?>
[395] Fix | Delete
<div id="custom-tab-content" class="tab-content">
[396] Fix | Delete
<ul></ul>
[397] Fix | Delete
</div> <!--end #custom-tab-content-->
[398] Fix | Delete
<?php endif; ?>
[399] Fix | Delete
<div class="clear"></div>
[400] Fix | Delete
</div> <!--end .inside -->
[401] Fix | Delete
<div class="clear"></div>
[402] Fix | Delete
</div><!--end #tabber -->
[403] Fix | Delete
<?php
[404] Fix | Delete
// inline script
[405] Fix | Delete
// to support multiple instances per page with different settings.
[406] Fix | Delete
unset( $instance['tabs'], $instance['tab_order'], $instance['tab_titles'] ); // unset unneeded.
[407] Fix | Delete
$instance['current_post_id'] = ! empty( $post->ID ) ? $post->ID : 0;
[408] Fix | Delete
[409] Fix | Delete
if ( isset( $_GET['clear'] ) ) {
[410] Fix | Delete
$instance['clear_cache'] = true;
[411] Fix | Delete
}
[412] Fix | Delete
?>
[413] Fix | Delete
<script type="text/javascript">
[414] Fix | Delete
jQuery(function( $) {
[415] Fix | Delete
$( '#<?php echo esc_attr( $widget_id ); ?>_content' ).data( 'args', <?php echo wp_json_encode( $instance ); ?>);
[416] Fix | Delete
});
[417] Fix | Delete
</script>
[418] Fix | Delete
<?php
[419] Fix | Delete
echo wp_kses_post( $after_widget );
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
/**
[423] Fix | Delete
* AJAX gets tab content.
[424] Fix | Delete
*/
[425] Fix | Delete
public function ajax_wp_review_tab_widget_content() {
[426] Fix | Delete
$tab = $_POST['tab'];
[427] Fix | Delete
$args = $_POST['args'];
[428] Fix | Delete
$page = intval( $_POST['page'] );
[429] Fix | Delete
if ( $page < 1 ) {
[430] Fix | Delete
$page = 1;
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
$GLOBALS['in_widget'] = 1;
[434] Fix | Delete
[435] Fix | Delete
$thumb_size = $args['thumb_size'];
[436] Fix | Delete
if ( 'small' != $thumb_size && 'large' != $thumb_size ) {
[437] Fix | Delete
$thumb_size = 'small'; // default.
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
$title_length = ! empty( $args['title_length'] ) ? $args['title_length'] : apply_filters( 'wpt_title_length_default', '15' );
[441] Fix | Delete
[442] Fix | Delete
$show_date = intval( $args['show_date'] );
[443] Fix | Delete
$allow_pagination = ! empty( $args['allow_pagination'] );
[444] Fix | Delete
[445] Fix | Delete
$post_num = ( empty( $args['post_num'] ) || $args['post_num'] > 20 || $args['post_num'] < 1 ) ? 5 : intval( $args['post_num'] );
[446] Fix | Delete
$review_type = ! empty( $args['review_type'] ) ? (array) $args['review_type'] : array();
[447] Fix | Delete
[448] Fix | Delete
// Normal tabs.
[449] Fix | Delete
$query_args = array(
[450] Fix | Delete
'post_type' => 'any',
[451] Fix | Delete
'post_num' => $post_num,
[452] Fix | Delete
'page' => $page,
[453] Fix | Delete
'review_type' => $review_type,
[454] Fix | Delete
'clear_cache' => ! empty( $args['clear_cache'] ),
[455] Fix | Delete
);
[456] Fix | Delete
[457] Fix | Delete
if ( 'custom' === $tab ) {
[458] Fix | Delete
$custom_reviews = array();
[459] Fix | Delete
if ( ! empty( $args['custom_reviews'] ) ) {
[460] Fix | Delete
$custom_reviews = explode( ',', $args['custom_reviews'] );
[461] Fix | Delete
$custom_reviews = array_map( 'trim', $custom_reviews );
[462] Fix | Delete
$custom_reviews = array_map( 'intval', $custom_reviews );
[463] Fix | Delete
}
[464] Fix | Delete
$query_args['ids'] = $custom_reviews;
[465] Fix | Delete
} elseif ( 'toprated' === $tab ) {
[466] Fix | Delete
$toprated_key = 'wp_review_total';
[467] Fix | Delete
[468] Fix | Delete
if ( ! empty( $args['top_rated_posts'] ) && 'comments' === $args['top_rated_posts'] ) {
[469] Fix | Delete
$toprated_key = 'wp_review_comments_rating_value';
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
$query_args['toprated_key'] = $toprated_key;
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
$query = wp_review_get_reviews_query( $tab, $query_args );
[476] Fix | Delete
?>
[477] Fix | Delete
<ul class="review_thumb_<?php echo $thumb_size; ?>">
[478] Fix | Delete
<?php
[479] Fix | Delete
$last_page = $query->max_num_pages;
[480] Fix | Delete
while ( $query->have_posts() ) :
[481] Fix | Delete
$query->the_post();
[482] Fix | Delete
$classes = array( 'wp_review_tab_thumbnail' );
[483] Fix | Delete
$classes[] = 'wp_review_tab_thumb_' . $thumb_size;
[484] Fix | Delete
if ( ! has_post_thumbnail() ) {
[485] Fix | Delete
$classes[] = 'wp-review-no-thumb';
[486] Fix | Delete
}
[487] Fix | Delete
$classes = implode( ' ', $classes );
[488] Fix | Delete
?>
[489] Fix | Delete
<li>
[490] Fix | Delete
<a title="<?php the_title(); ?>" rel="nofollow" href="<?php the_permalink(); ?>">
[491] Fix | Delete
<div class="<?php echo esc_attr( $classes ); ?>">
[492] Fix | Delete
<?php if ( has_post_thumbnail() ) : ?>
[493] Fix | Delete
<?php the_post_thumbnail( 'wp_review_' . $thumb_size, array( 'title' => '' ) ); ?>
[494] Fix | Delete
<?php else : ?>
[495] Fix | Delete
<img src="<?php echo esc_url( WP_REVIEW_ASSETS . 'images/' . $thumb_size . 'thumb.png' ); ?>" alt="<?php the_title(); ?>" class="wp-post-image" />
[496] Fix | Delete
<?php endif; ?>
[497] Fix | Delete
</div>
[498] Fix | Delete
</a>
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function