Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/review-schema/app/Controllers/Admin/AdminSettings.php
+++ b/review-schema/app/Controllers/Admin/AdminSettings.php
@@ -66,6 +66,20 @@
[ $this, 'get_help_page' ],
30
);
+ add_submenu_page(
+ 'review-schema',
+ esc_html__( 'Our Plugins', 'the-post-grid' ),
+ esc_html__( 'Our Plugins', 'the-post-grid' ),
+ 'manage_options',
+ 'rtrs-our-plugins',
+ [ $this, 'our_plugins' ]
+ );
+ }
+ /**
+ * get Help
+ */
+ public function our_plugins() {
+ require_once RTRS_PATH . 'views/pages/our-plugins.php';
}
/**
@@ -153,12 +167,12 @@
'schema' => esc_html__( 'Schema', 'review-schema' ),
'woocommerce' => esc_html__( 'WooCommerce', 'review-schema' ),
'media' => esc_html__( 'Media', 'review-schema' ),
- 'misc' => esc_html__( 'Misc', 'review-schema' ),
+ 'misc' => esc_html__( 'Misc', 'review-schema' ),
// 'support' => esc_html__('Support', 'review-schema'),
];
// Hook to register custom tabs
$this->tabs = apply_filters( 'rtrs_register_settings_tabs', $this->tabs );
-
+
// Find the active tab.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$this->option = $this->active_tab = ! empty( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->tabs ) ? trim( $_GET['tab'] ) : 'review';
--- a/review-schema/app/Controllers/Admin/Meta/AddMetaBox.php
+++ b/review-schema/app/Controllers/Admin/Meta/AddMetaBox.php
@@ -6,26 +6,56 @@
class AddMetaBox {
public function __construct() {
- //actions
- add_action('admin_head', [$this, 'add_meta_boxes']);
- add_action('save_post', [$this, 'save_meta_data'], 10, 2);
- add_action('pre_post_update', [$this, 'before_update_post']);
- add_action('before_delete_post', [$this, 'before_delete_post'], 10, 2);
+ // actions
+ add_action( 'admin_notices', [ $this, 'render_notices' ] );
+ add_action( 'admin_head', [ $this, 'add_meta_boxes' ] );
+ add_action( 'save_post', [ $this, 'save_meta_data' ], 10, 2 );
+ add_action( 'pre_post_update', [ $this, 'before_update_post' ] );
+ add_action( 'before_delete_post', [ $this, 'before_delete_post' ], 10, 2 );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
- if (Functions::is_edit_page() || (isset($_GET['page']) && $_GET['page'] == 'rtrs-settings')) {
- add_action('admin_footer', [$this, 'pro_alert_html']);
+ if ( Functions::is_edit_page() || ( isset( $_GET['page'] ) && $_GET['page'] == 'rtrs-settings' ) ) {
+ add_action( 'admin_footer', [ $this, 'pro_alert_html' ] );
}
- //rtrs post type
- add_filter('manage_edit-rtrs_columns', [$this, 'rtrs_columns_title_arrange']);
- add_action('manage_rtrs_posts_custom_column', [$this, 'rtrs_columns_data_arrange'], 10, 2);
+ // rtrs post type.
+ add_filter( 'manage_edit-rtrs_columns', [ $this, 'rtrs_columns_title_arrange' ] );
+ add_action( 'manage_rtrs_posts_custom_column', [ $this, 'rtrs_columns_data_arrange' ], 10, 2 );
- //rtrs affiliate post type
- add_action('edit_form_after_title', [$this, 'rtrs_sc_after_title']);
- add_filter('manage_edit-rtrs_affiliate_columns', [$this, 'rtrs_affiliate_columns_title_arrange']);
- add_action('manage_rtrs_affiliate_posts_custom_column', [$this, 'rtrs_affiliate_columns_data_arrange'], 10, 2);
+ // rtrs affiliate post type.
+ add_action( 'edit_form_after_title', [ $this, 'rtrs_sc_after_title' ] );
+ add_filter( 'manage_edit-rtrs_affiliate_columns', [ $this, 'rtrs_affiliate_columns_title_arrange' ] );
+ add_action( 'manage_rtrs_affiliate_posts_custom_column', [ $this, 'rtrs_affiliate_columns_data_arrange' ], 10, 2 );
- add_filter('preprocess_comment', [$this, 'modify_comment_type']);
+ add_filter( 'preprocess_comment', [ $this, 'modify_comment_type' ] );
+ }
+ /**
+ * Add admin error notice.
+ *
+ * @param string $message Error message.
+ */
+ private function add_admin_error( $message ) {
+ set_transient( 'rtrs_admin_notice', $message, 30 ); // expire in 30 seconds.
+ }
+ /**
+ * Redirect back to the previous page safely.
+ *
+ * @return void
+ */
+ private function redirect_back() {
+ $redirect = wp_get_referer() ? wp_get_referer() : admin_url();
+ wp_safe_redirect( $redirect );
+ exit;
+ }
+
+ /**
+ * @return void
+ */
+ public function render_notices() {
+ $message = get_transient( 'rtrs_admin_notice' );
+ if ( $message ) {
+ echo '<div class="notice notice-error is-dismissible"><p>' . esc_html( $message ) . '</p></div>';
+ delete_transient( 'rtrs_admin_notice' );
+ }
}
/**
@@ -36,45 +66,45 @@
*
* @since 1.0
*/
- public function modify_comment_type($commentdata) {
- $post_type = get_post_type($commentdata['comment_post_ID']);
- if (Functions::isEnableByPostType($post_type)) {
+ public function modify_comment_type( $commentdata ) {
+ $post_type = get_post_type( $commentdata['comment_post_ID'] );
+ if ( Functions::isEnableByPostType( $post_type ) ) {
$commentdata['comment_type'] = 'review';
}
return $commentdata;
}
- public function rtrs_columns_title_arrange($columns) {
+ public function rtrs_columns_title_arrange( $columns ) {
$shortcode = [
- 'post_type' => esc_html__('Post Type', 'review-schema'),
- 'support' => esc_html__('Support', 'review-schema'),
+ 'post_type' => esc_html__( 'Post Type', 'review-schema' ),
+ 'support' => esc_html__( 'Support', 'review-schema' ),
];
- return array_slice($columns, 0, 2, true) + $shortcode + array_slice($columns, 1, null, true);
+ return array_slice( $columns, 0, 2, true ) + $shortcode + array_slice( $columns, 1, null, true );
}
- public function rtrs_columns_data_arrange($column) {
- switch ($column) {
+ public function rtrs_columns_data_arrange( $column ) {
+ switch ( $column ) {
case 'post_type':
- if ($post_type = get_post_meta(get_the_ID(), 'rtrs_post_type', true)) {
- echo ucfirst(esc_html($post_type));
+ if ( $post_type = get_post_meta( get_the_ID(), 'rtrs_post_type', true ) ) {
+ echo ucfirst( esc_html( $post_type ) );
}
break;
case 'support':
- $support = get_post_meta(get_the_ID(), 'rtrs_support', true);
- switch ($support) {
+ $support = get_post_meta( get_the_ID(), 'rtrs_support', true );
+ switch ( $support ) {
case 'review-schema':
- esc_html_e('Review with Schema JSON-LD', 'review-schema');
+ esc_html_e( 'Review with Schema JSON-LD', 'review-schema' );
break;
case 'review':
- esc_html_e('Only Review', 'review-schema');
+ esc_html_e( 'Only Review', 'review-schema' );
break;
case 'schema':
- esc_html_e('Only Schema JSON-LD', 'review-schema');
+ esc_html_e( 'Only Schema JSON-LD', 'review-schema' );
break;
}
break;
@@ -84,16 +114,16 @@
}
}
- public function rtrs_affiliate_columns_title_arrange($columns) {
+ public function rtrs_affiliate_columns_title_arrange( $columns ) {
$shortcode = [
- 'shortcode' => esc_html__('Shortcode', 'review-schema'),
+ 'shortcode' => esc_html__( 'Shortcode', 'review-schema' ),
];
- return array_slice($columns, 0, 2, true) + $shortcode + array_slice($columns, 1, null, true);
+ return array_slice( $columns, 0, 2, true ) + $shortcode + array_slice( $columns, 1, null, true );
}
- public function rtrs_affiliate_columns_data_arrange($column) {
- switch ($column) {
+ public function rtrs_affiliate_columns_data_arrange( $column ) {
+ switch ( $column ) {
case 'shortcode':
echo '<input type="text" onfocus="this.select();" readonly="readonly" value="[rtrs-affiliate id="' . get_the_ID() . '" title="' . get_the_title() . '"]" class="large-text code rt-code-sc">';
break;
@@ -106,8 +136,8 @@
public function add_meta_boxes() {
add_meta_box(
'rtrs_meta',
- esc_html__('Review Schema Generator', 'review-schema'),
- [$this, 'rtrs_meta_settings'],
+ esc_html__( 'Review Schema Generator', 'review-schema' ),
+ [ $this, 'rtrs_meta_settings' ],
rtrs()->getPostType(),
'normal',
'high'
@@ -115,8 +145,8 @@
add_meta_box(
'rt_plugin_sc_pro_information',
- esc_html__('Documentation', 'review-schema'),
- [$this, 'rt_plugin_sc_pro_information'],
+ esc_html__( 'Documentation', 'review-schema' ),
+ [ $this, 'rt_plugin_sc_pro_information' ],
rtrs()->getPostType(),
'side',
'low'
@@ -124,22 +154,22 @@
add_meta_box(
'rtrs_meta',
- esc_html__('Affiliate Shortcode Generator', 'review-schema'),
- [$this, 'rtrs_affiliate_settings'],
+ esc_html__( 'Affiliate Shortcode Generator', 'review-schema' ),
+ [ $this, 'rtrs_affiliate_settings' ],
'rtrs_affiliate',
'normal',
'high'
);
- if (Functions::is_edit_page()) {
+ if ( Functions::is_edit_page() ) {
global $post;
$post_type = $post->post_type;
- if (Functions::isEnableByPostTypeReview($post_type)) {
+ if ( Functions::isEnableByPostTypeReview( $post_type ) ) {
add_meta_box(
'rtrs_meta',
- esc_html__('Review & Schema Settings', 'review-schema'),
- [$this, 'rtrs_single_meta_settings'],
- [$post_type],
+ esc_html__( 'Review & Schema Settings', 'review-schema' ),
+ [ $this, 'rtrs_single_meta_settings' ],
+ [ $post_type ],
'normal',
'low'
);
@@ -147,7 +177,7 @@
}
}
- public function rt_plugin_sc_pro_information($post) {
+ public function rt_plugin_sc_pro_information( $post ) {
$html = '';
$html .= sprintf(
@@ -159,17 +189,17 @@
<a href="https://www.radiustheme.com/docs/review-schema/review-schema/" target="_blank" class="rt-admin-btn">%1$s</a>
</div>
</div>',
- esc_html__('Documentation', 'review-schema'),
- esc_html__('Get started by spending some time with the documentation we included step by step process with screenshots with video.', 'review-schema')
+ esc_html__( 'Documentation', 'review-schema' ),
+ esc_html__( 'Get started by spending some time with the documentation we included step by step process with screenshots with video.', 'review-schema' )
);
$html .= '<div class="rt-document-box">
<div class="rt-box-icon"><i class="dashicons dashicons-sos"></i></div>
<div class="rt-box-content">
- <h3 class="rt-box-title">' . esc_html__('Need Help?', 'review-schema') . '</h3>
- <p>' . esc_html__('Stuck with something? Please create a', 'review-schema') . '
- <a href="https://www.radiustheme.com/contact/">' . esc_html__('ticket here', 'review-schema') . '</a> ' . esc_html__('or post on ', 'review-schema') . '<a href="https://www.facebook.com/groups/234799147426640/">facebook group</a>. ' . esc_html__('For emergency case join our', 'review-schema') . ' <a href="https://www.radiustheme.com/">' . esc_html__('live chat', 'review-schema') . '</a>.</p>
- <a href="https://www.radiustheme.com/contact/" target="_blank" class="rt-admin-btn">' . esc_html__('Get Support', 'review-schema') . '</a>
+ <h3 class="rt-box-title">' . esc_html__( 'Need Help?', 'review-schema' ) . '</h3>
+ <p>' . esc_html__( 'Stuck with something? Please create a', 'review-schema' ) . '
+ <a href="https://www.radiustheme.com/contact/">' . esc_html__( 'ticket here', 'review-schema' ) . '</a> ' . esc_html__( 'or post on ', 'review-schema' ) . '<a href="https://www.facebook.com/groups/234799147426640/">facebook group</a>. ' . esc_html__( 'For emergency case join our', 'review-schema' ) . ' <a href="https://www.radiustheme.com/">' . esc_html__( 'live chat', 'review-schema' ) . '</a>.</p>
+ <a href="https://www.radiustheme.com/contact/" target="_blank" class="rt-admin-btn">' . esc_html__( 'Get Support', 'review-schema' ) . '</a>
</div>
</div>';
@@ -178,7 +208,7 @@
<div class="rt-box-content">
<h3 class="rt-box-title">Happy Our Work?</h3>
<p>Thank you for choosing Review Schema. If you have found our plugin useful and makes you smile, please consider giving us a 5-star rating on WordPress.org. It will help us to grow.</p>
- <a target="_blank" href="https://wordpress.org/support/plugin/review-schema/reviews/?filter=5#new-post" class="rt-admin-btn">Yes, You Deserve It</a>
+ <a target="_blank" href="https://wordpress.org/support/plugin/review-schema/reviews/" class="rt-admin-btn">Yes, You Deserve It</a>
</div>
</div>';
@@ -187,13 +217,13 @@
public function pro_alert_html() {
$html = '';
- if (! function_exists('rtrsp')) {
+ if ( ! function_exists( 'rtrsp' ) ) {
$html .= '<div class="rt-document-box rt-alert rtrs-pro-alert">
<div class="rt-box-icon"><i class="dashicons dashicons-lock"></i></div>
<div class="rt-box-content">
- <h3 class="rt-box-title">' . esc_html__('Pro field alert!', 'review-schema') . '</h3>
- <p><span></span>' . esc_html__('Sorry! this is a pro field. To use this field, you need to use pro plugin.', 'review-schema') . '</p>
- <a href="https://www.radiustheme.com/downloads/wordpress-review-structure-data-schema-plugin/?utm_source=WordPress&utm_medium=reviewschema&utm_campaign=pro_click" target="_blank" class="rt-admin-btn">' . esc_html__('Upgrade to pro', 'review-schema') . '</a>
+ <h3 class="rt-box-title">' . esc_html__( 'Pro field alert!', 'review-schema' ) . '</h3>
+ <p><span></span>' . esc_html__( 'Sorry! this is a pro field. To use this field, you need to use pro plugin.', 'review-schema' ) . '</p>
+ <a href="https://www.radiustheme.com/downloads/wordpress-review-structure-data-schema-plugin/?utm_source=WordPress&utm_medium=reviewschema&utm_campaign=pro_click" target="_blank" class="rt-admin-btn">' . esc_html__( 'Upgrade to pro', 'review-schema' ) . '</a>
<a href="#" target="_blank" class="rt-alert-close rtrs-pro-alert-close">x</a>
</div>
</div>';
@@ -202,8 +232,8 @@
$html .= '<div class="rt-document-box rt-alert rtrs-post-type">
<div class="rt-box-icon"><i class="dashicons dashicons-lock"></i></div>
<div class="rt-box-content">
- <h3 class="rt-box-title">' . esc_html__('Already exist alert!', 'review-schema') . '</h3>
- <p>' . esc_html__('Sorry! this post type already exist, you need to choose new one.', 'review-schema') . '</p>
+ <h3 class="rt-box-title">' . esc_html__( 'Already exist alert!', 'review-schema' ) . '</h3>
+ <p>' . esc_html__( 'Sorry! this post type already exist, you need to choose new one.', 'review-schema' ) . '</p>
<a href="#" target="_blank" class="rt-alert-close rtrs-post-type-close">x</a>
</div>
</div>';
@@ -211,243 +241,244 @@
echo $html;
}
- public function rtrs_sc_after_title($post) {
- if (rtrs()->getPostTypeAffiliate() !== $post->post_type) {
+ public function rtrs_sc_after_title( $post ) {
+ if ( rtrs()->getPostTypeAffiliate() !== $post->post_type ) {
return;
}
- $html = null;
+ $html = null;
$html .= '<div class="postbox rt-after-title" style="margin-bottom: 0;"><div class="inside">';
- $html .= '<p><input type="text" onfocus="this.select();" readonly="readonly" value="[rtrs-affiliate id="' . esc_attr($post->ID) . '" title="' . esc_attr($post->post_title) . '"]" class="large-text code rt-code-sc">
- <input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo do_shortcode( '[rtrs-affiliate id="' . esc_attr($post->ID) . '" title="' . esc_attr($post->post_title) . '"]' ); ?>" class="large-text code rt-code-sc">
+ $html .= '<p><input type="text" onfocus="this.select();" readonly="readonly" value="[rtrs-affiliate id="' . esc_attr( $post->ID ) . '" title="' . esc_attr( $post->post_title ) . '"]" class="large-text code rt-code-sc">
+ <input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo do_shortcode( '[rtrs-affiliate id="' . esc_attr( $post->ID ) . '" title="' . esc_attr( $post->post_title ) . '"]' ); ?>" class="large-text code rt-code-sc">
</p>';
$html .= '</div></div>';
echo $html;
}
public function postType() {
- return apply_filters('rtrs_post_type', Functions::getPostTypes());
+ return apply_filters( 'rtrs_post_type', Functions::getPostTypes() );
}
- public function rtrs_meta_settings($post) {
+ public function rtrs_meta_settings( $post ) {
$post = [
'post' => $post,
];
- wp_nonce_field(rtrs()->getNonceId(), rtrs()->getNonceId());
+ wp_nonce_field( rtrs()->getNonceId(), rtrs()->getNonceId() );
- //auto select tab
- $tab = get_post_meta(get_the_ID(), '_rtrs_sc_tab', true);
- if (! $tab) {
+ // auto select tab
+ $tab = get_post_meta( get_the_ID(), '_rtrs_sc_tab', true );
+ if ( ! $tab ) {
$tab = 'review';
}
- $review_tab = ($tab == 'review') ? 'active' : '';
- $schema_tab = ($tab == 'schema') ? 'active' : '';
- $setting_tab = ($tab == 'setting') ? 'active' : '';
- $style_tab = ($tab == 'style') ? 'active' : '';
- $preview_tab = ($tab == 'preview') ? 'active' : '';
+ $review_tab = ( $tab == 'review' ) ? 'active' : '';
+ $schema_tab = ( $tab == 'schema' ) ? 'active' : '';
+ $setting_tab = ( $tab == 'setting' ) ? 'active' : '';
+ $style_tab = ( $tab == 'style' ) ? 'active' : '';
+ $preview_tab = ( $tab == 'preview' ) ? 'active' : '';
$html = null;
$html .= '<div id="rt-conditional-wrap" class="rtrs-tab-content" style="display: block;">';
- $html .= rtrs()->render('metas.sc.conditional', $post, true);
+ $html .= rtrs()->render( 'metas.sc.conditional', $post, true );
$html .= '</div>';
- //meta tab
+ // meta tab
$html .= '<div id="sc-tabs" class="rtrs-tab-container">';
$html .= '<ul class="rtrs-tab-nav rt-back">
- <li class="review-tab ' . esc_attr($review_tab) . '"><a href="#sc-review"><i class="dashicons dashicons-star-filled"></i>' . esc_html__('Review', 'review-schema') . '</a></li>
- <li class="' . esc_attr($setting_tab) . '"><a href="#sc-settings"><i class="dashicons dashicons-admin-tools"></i>' . esc_html__('Settings', 'review-schema') . '</a></li>
- <li class="schema-tab ' . esc_attr($schema_tab) . '"><a href="#sc-schema"><i class="dashicons dashicons-editor-table"></i>' . esc_html__('Schema', 'review-schema') . '</a></li>
- <li class="' . esc_attr($style_tab) . '"><a href="#sc-style"><i class="dashicons dashicons-admin-customizer"></i>' . esc_html__('Style', 'review-schema') . '</a></li></ul>';
-
- $review_tab = ($tab == 'review') ? 'display: block' : '';
- $schema_tab = ($tab == 'schema') ? 'display: block' : '';
- $setting_tab = ($tab == 'setting') ? 'display: block' : '';
- $style_tab = ($tab == 'style') ? 'display: block' : '';
- $preview_tab = ($tab == 'preview') ? 'display: block' : '';
+ <li class="review-tab ' . esc_attr( $review_tab ) . '"><a href="#sc-review"><i class="dashicons dashicons-star-filled"></i>' . esc_html__( 'Review', 'review-schema' ) . '</a></li>
+ <li class="' . esc_attr( $setting_tab ) . '"><a href="#sc-settings"><i class="dashicons dashicons-admin-tools"></i>' . esc_html__( 'Settings', 'review-schema' ) . '</a></li>
+ <li class="schema-tab ' . esc_attr( $schema_tab ) . '"><a href="#sc-schema"><i class="dashicons dashicons-editor-table"></i>' . esc_html__( 'Schema', 'review-schema' ) . '</a></li>
+ <li class="' . esc_attr( $style_tab ) . '"><a href="#sc-style"><i class="dashicons dashicons-admin-customizer"></i>' . esc_html__( 'Style', 'review-schema' ) . '</a></li></ul>';
+
+ $review_tab = ( $tab == 'review' ) ? 'display: block' : '';
+ $schema_tab = ( $tab == 'schema' ) ? 'display: block' : '';
+ $setting_tab = ( $tab == 'setting' ) ? 'display: block' : '';
+ $style_tab = ( $tab == 'style' ) ? 'display: block' : '';
+ $preview_tab = ( $tab == 'preview' ) ? 'display: block' : '';
- $html .= '<input type="hidden" id="_rtrs_sc_tab" name="_rtrs_sc_tab" value="' . esc_attr($tab) . '" />';
+ $html .= '<input type="hidden" id="_rtrs_sc_tab" name="_rtrs_sc_tab" value="' . esc_attr( $tab ) . '" />';
- $html .= '<div id="sc-review" class="rtrs-tab-content" style="' . esc_attr($review_tab) . '">';
- $html .= rtrs()->render('metas.sc.review', $post, true);
+ $html .= '<div id="sc-review" class="rtrs-tab-content" style="' . esc_attr( $review_tab ) . '">';
+ $html .= rtrs()->render( 'metas.sc.review', $post, true );
$html .= '</div>';
- $html .= '<div id="sc-schema" class="rtrs-tab-content" style="' . esc_attr($schema_tab) . '">';
- $html .= rtrs()->render('metas.sc.schema', $post, true);
+ $html .= '<div id="sc-schema" class="rtrs-tab-content" style="' . esc_attr( $schema_tab ) . '">';
+ $html .= rtrs()->render( 'metas.sc.schema', $post, true );
$html .= '</div>';
- $html .= '<div id="sc-settings" class="rtrs-tab-content" style="' . esc_attr($setting_tab) . '">';
- $html .= rtrs()->render('metas.sc.settings', $post, true);
+ $html .= '<div id="sc-settings" class="rtrs-tab-content" style="' . esc_attr( $setting_tab ) . '">';
+ $html .= rtrs()->render( 'metas.sc.settings', $post, true );
$html .= '</div>';
- $html .= '<div id="sc-style" class="rtrs-tab-content" style="' . esc_attr($style_tab) . '">';
- $html .= rtrs()->render('metas.sc.style', $post, true);
+ $html .= '<div id="sc-style" class="rtrs-tab-content" style="' . esc_attr( $style_tab ) . '">';
+ $html .= rtrs()->render( 'metas.sc.style', $post, true );
$html .= '</div>';
echo $html;
- echo '</div>'; //wrap div
+ echo '</div>'; // wrap div
}
- public function rtrs_affiliate_settings($post) {
+ public function rtrs_affiliate_settings( $post ) {
$post = [
'post' => $post,
];
- wp_nonce_field(rtrs()->getNonceId(), rtrs()->getNonceId());
+ wp_nonce_field( rtrs()->getNonceId(), rtrs()->getNonceId() );
- //auto select tab
- $tab = get_post_meta(get_the_ID(), '_rtrs_sc_tab', true);
- if (! $tab) {
+ // auto select tab
+ $tab = get_post_meta( get_the_ID(), '_rtrs_sc_tab', true );
+ if ( ! $tab ) {
$tab = 'affiliate';
}
- $affiliate_tab = ($tab == 'affiliate') ? 'active' : '';
- $schema_tab = ($tab == 'schema') ? 'active' : '';
- $style_tab = ($tab == 'style') ? 'active' : '';
- $preview_tab = ($tab == 'preview') ? 'active' : '';
+ $affiliate_tab = ( $tab == 'affiliate' ) ? 'active' : '';
+ $schema_tab = ( $tab == 'schema' ) ? 'active' : '';
+ $style_tab = ( $tab == 'style' ) ? 'active' : '';
+ $preview_tab = ( $tab == 'preview' ) ? 'active' : '';
$html = null;
$html .= '<div id="sc-tabs" class="rtrs-tab-container">';
$html .= '<ul class="rtrs-tab-nav">
- <li class="' . esc_attr($affiliate_tab) . '"><a href="#sc-affiliate"><i class="dashicons dashicons-megaphone"></i>' . esc_html__('Affiliate', 'review-schema') . '</a></li>
- <li class="' . esc_attr($schema_tab) . '"><a href="#sc-schema"><i class="dashicons dashicons-editor-table"></i>' . esc_html__('Schema', 'review-schema') . '</a></li>
- <li class="' . esc_attr($style_tab) . '"><a href="#sc-style"><i class="dashicons dashicons-admin-customizer"></i>' . esc_html__('Style', 'review-schema') . '</a></li></ul>';
-
- $affiliate_tab = ($tab == 'affiliate') ? 'display: block' : '';
- $schema_tab = ($tab == 'schema') ? 'display: block' : '';
- $style_tab = ($tab == 'style') ? 'display: block' : '';
- $preview_tab = ($tab == 'preview') ? 'display: block' : '';
+ <li class="' . esc_attr( $affiliate_tab ) . '"><a href="#sc-affiliate"><i class="dashicons dashicons-megaphone"></i>' . esc_html__( 'Affiliate', 'review-schema' ) . '</a></li>
+ <li class="' . esc_attr( $schema_tab ) . '"><a href="#sc-schema"><i class="dashicons dashicons-editor-table"></i>' . esc_html__( 'Schema', 'review-schema' ) . '</a></li>
+ <li class="' . esc_attr( $style_tab ) . '"><a href="#sc-style"><i class="dashicons dashicons-admin-customizer"></i>' . esc_html__( 'Style', 'review-schema' ) . '</a></li></ul>';
+
+ $affiliate_tab = ( $tab == 'affiliate' ) ? 'display: block' : '';
+ $schema_tab = ( $tab == 'schema' ) ? 'display: block' : '';
+ $style_tab = ( $tab == 'style' ) ? 'display: block' : '';
+ $preview_tab = ( $tab == 'preview' ) ? 'display: block' : '';
- $html .= '<input type="hidden" id="_rtrs_sc_tab" name="_rtrs_sc_tab" value="' . esc_attr($tab) . '" />';
+ $html .= '<input type="hidden" id="_rtrs_sc_tab" name="_rtrs_sc_tab" value="' . esc_attr( $tab ) . '" />';
- $html .= '<div id="sc-affiliate" class="rtrs-tab-content" style="' . esc_attr($affiliate_tab) . '">';
- $html .= rtrs()->render('metas.affiliate.affiliate', $post, true);
+ $html .= '<div id="sc-affiliate" class="rtrs-tab-content" style="' . esc_attr( $affiliate_tab ) . '">';
+ $html .= rtrs()->render( 'metas.affiliate.affiliate', $post, true );
$html .= '</div>';
- $html .= '<div id="sc-schema" class="rtrs-tab-content" style="' . esc_attr($schema_tab) . '">';
- $html .= rtrs()->render('metas.affiliate.schema', $post, true);
+ $html .= '<div id="sc-schema" class="rtrs-tab-content" style="' . esc_attr( $schema_tab ) . '">';
+ $html .= rtrs()->render( 'metas.affiliate.schema', $post, true );
$html .= '</div>';
- $html .= '<div id="sc-style" class="rtrs-tab-content" style="' . esc_attr($style_tab) . '">';
- $html .= rtrs()->render('metas.affiliate.style', $post, true);
+ $html .= '<div id="sc-style" class="rtrs-tab-content" style="' . esc_attr( $style_tab ) . '">';
+ $html .= rtrs()->render( 'metas.affiliate.style', $post, true );
$html .= '</div>';
echo $html;
- echo '</div>'; //wrap div
+ echo '</div>'; // wrap div
}
- public function rtrs_single_meta_settings($post) {
+ public function rtrs_single_meta_settings( $post ) {
$post = [
'post' => $post,
];
- wp_nonce_field(rtrs()->getNonceId(), rtrs()->getNonceId());
+ wp_nonce_field( rtrs()->getNonceId(), rtrs()->getNonceId() );
$post_type = $post['post']->post_type;
- //auto select tab
- $tab = get_post_meta(get_the_ID(), '_rtrs_sc_tab', true);
+ // auto select tab
+ $tab = get_post_meta( get_the_ID(), '_rtrs_sc_tab', true );
- if (! $tab) {
- $tab = (Functions::isEnableByPostType($post_type)) ? 'review' : 'schema';
+ if ( ! $tab ) {
+ $tab = ( Functions::isEnableByPostType( $post_type ) ) ? 'review' : 'schema';
} else {
- if (Functions::isEnableByPostTypeSchema($post_type) && $tab == 'review') {
+ if ( Functions::isEnableByPostTypeSchema( $post_type ) && $tab == 'review' ) {
$tab = 'schema';
}
}
- $review_tab = ($tab == 'review') ? 'active' : '';
- $schema_tab = ($tab == 'schema') ? 'active' : '';
- $preview_tab = ($tab == 'preview') ? 'active' : '';
+ $review_tab = ( $tab == 'review' ) ? 'active' : '';
+ $schema_tab = ( $tab == 'schema' ) ? 'active' : '';
+ $preview_tab = ( $tab == 'preview' ) ? 'active' : '';
- $html = null;
+ $html = null;
$html .= '<div id="sc-tabs" class="rtrs-tab-container">';
$html .= '<ul class="rtrs-tab-nav">';
- if (Functions::isEnableByPostType($post_type)) {
- $html .= '<li class="' . esc_attr($review_tab) . '"><a href="#sc-review"><i class="dashicons dashicons-star-filled"></i>' . esc_html__('Review', 'review-schema') . '</a></li>';
+ if ( Functions::isEnableByPostType( $post_type ) ) {
+ $html .= '<li class="' . esc_attr( $review_tab ) . '"><a href="#sc-review"><i class="dashicons dashicons-star-filled"></i>' . esc_html__( 'Review', 'review-schema' ) . '</a></li>';
}
- if (Functions::isEnableByPostTypeSchema($post_type)) {
- $html .= '<li class="' . esc_attr($schema_tab) . '"><a href="#sc-schema"><i class="dashicons dashicons-editor-table"></i>' . esc_html__('Schema', 'review-schema') . '</a></li>';
+ if ( Functions::isEnableByPostTypeSchema( $post_type ) ) {
+ $html .= '<li class="' . esc_attr( $schema_tab ) . '"><a href="#sc-schema"><i class="dashicons dashicons-editor-table"></i>' . esc_html__( 'Schema', 'review-schema' ) . '</a></li>';
}
$html .= '</ul>';
- $review_tab = ($tab == 'review') ? 'display: block' : '';
- $schema_tab = ($tab == 'schema') ? 'display: block' : '';
- $preview_tab = ($tab == 'preview') ? 'display: block' : '';
-
- $html .= '<input type="hidden" id="_rtrs_sc_tab" name="_rtrs_sc_tab" value="' . esc_attr($tab) . '" />';
- if (Functions::isEnableByPostType($post_type)) {
- $html .= '<div id="sc-review" class="rtrs-tab-content" style="' . esc_attr($review_tab) . '">';
- $html .= rtrs()->render('metas.single.review', $post, true);
+ $review_tab = ( $tab == 'review' ) ? 'display: block' : '';
+ $schema_tab = ( $tab == 'schema' ) ? 'display: block' : '';
+ $preview_tab = ( $tab == 'preview' ) ? 'display: block' : '';
+
+ $html .= '<input type="hidden" id="_rtrs_sc_tab" name="_rtrs_sc_tab" value="' . esc_attr( $tab ) . '" />';
+ if ( Functions::isEnableByPostType( $post_type ) ) {
+ $html .= '<div id="sc-review" class="rtrs-tab-content" style="' . esc_attr( $review_tab ) . '">';
+ $html .= rtrs()->render( 'metas.single.review', $post, true );
+ $html .= rtrs()->render( 'metas.single.review-graph', $post, true );
$html .= '</div>';
}
- if (Functions::isEnableByPostTypeSchema($post_type)) {
- $html .= '<div id="sc-schema" class="rtrs-tab-content" style="' . esc_attr($schema_tab) . '">';
- $html .= rtrs()->render('metas.single.schema', $post, true);
+ if ( Functions::isEnableByPostTypeSchema( $post_type ) ) {
+ $html .= '<div id="sc-schema" class="rtrs-tab-content" style="' . esc_attr( $schema_tab ) . '">';
+ $html .= rtrs()->render( 'metas.single.schema', $post, true );
$html .= '</div>';
}
- $html .= '<div id="sc-preview" class="rtrs-tab-content" style="' . esc_attr($preview_tab) . '">';
+ $html .= '<div id="sc-preview" class="rtrs-tab-content" style="' . esc_attr( $preview_tab ) . '">';
$html .= '</div>';
- $html .= '</div>'; //wrap div
+ $html .= '</div>'; // wrap div
echo $html;
}
- public function sanitize_field($type, $value) {
+ public function sanitize_field( $type, $value ) {
$fValue = '';
- switch ($type) {
- case 'textarea':
- $fValue = isset($value) ? sanitize_textarea_field( $value ) : null;
- break;
- case 'text':
+ switch ( $type ) {
+ case 'textarea':
+ $fValue = isset( $value ) ? sanitize_textarea_field( $value ) : null;
+ break;
+ case 'text':
case 'select':
case 'tab':
case 'radio-image':
- $fValue = isset($value) ? sanitize_text_field($value) : null;
+ $fValue = isset( $value ) ? sanitize_text_field( $value ) : null;
break;
case 'url':
- $fValue = isset($value) ? esc_url_raw($value) : null;
+ $fValue = isset( $value ) ? esc_url_raw( $value ) : null;
break;
case 'number':
case 'switch':
case 'checkbox':
case 'image':
- $fValue = isset($value) ? absint($value) : null;
+ $fValue = isset( $value ) ? absint( $value ) : null;
break;
case 'float':
- $fValue = isset($value) ? floatval($value) : null;
+ $fValue = isset( $value ) ? floatval( $value ) : null;
break;
case 'gallery':
- $fValue = isset($value) && is_array($value) ? array_map('absint', $value) : null;
+ $fValue = isset( $value ) && is_array( $value ) ? array_map( 'absint', $value ) : null;
break;
case 'repeater':
- $fValue = isset($value) && is_array($value) ? array_map('sanitize_text_field', array_filter($value)) : null;
+ $fValue = isset( $value ) && is_array( $value ) ? array_map( 'sanitize_text_field', array_filter( $value ) ) : null;
break;
case 'color':
- $fValue = isset($value) ? sanitize_hex_color($value) : null;
+ $fValue = isset( $value ) ? sanitize_hex_color( $value ) : null;
break;
case 'style':
- $fValue = isset($value) ? array_map('sanitize_text_field', $value) : null;
+ $fValue = isset( $value ) ? array_map( 'sanitize_text_field', $value ) : null;
break;
default:
- $fValue = isset($value) ? sanitize_text_field($value) : null;
+ $fValue = isset( $value ) ? sanitize_text_field( $value ) : null;
break;
}
return $fValue;
}
- public function searchArray($value, $key, $array) {
- foreach ($array as $k => $val) {
- if ( !empty( $val[$key] ) && $val[$key] == $value) {
+ public function searchArray( $value, $key, $array ) {
+ foreach ( $array as $k => $val ) {
+ if ( ! empty( $val[ $key ] ) && $val[ $key ] == $value ) {
return $k;
}
}
@@ -455,47 +486,47 @@
return null;
}
- public function save_meta_data($post_id, $post) {
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
+ public function save_meta_data( $post_id, $post ) {
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
}
- if (! wp_verify_nonce( Functions::get_nonce() , rtrs()->getNonceId())) {
+ if ( ! wp_verify_nonce( Functions::get_nonce(), rtrs()->getNonceId() ) ) {
return $post_id;
}
$meta_options = null;
- if (rtrs()->getPostType() == $post->post_type) {
+ if ( rtrs()->getPostType() == $post->post_type ) {
$meta_options = new MetaOptions();
$meta_options = $meta_options->allMetaFields();
- } elseif ('rtrs_affiliate' == $post->post_type) {
+ } elseif ( 'rtrs_affiliate' == $post->post_type ) {
$meta_options = new AffiliateOptions();
$meta_options = $meta_options->allMetaFields();
} else {
- $meta_options = new SingleMetaOptions();
- $meta_options = $meta_options->allMetaFields();
+ $meta_options = new SingleMetaOptions();
+ $meta_options = $meta_options->allMetaFields();
$selected_schema = [];
- // $selected_schema = [
- // $meta_options[0],
- // $meta_options[1],
- // $meta_options[2],
- // $meta_options[3],
- // ];
+ // $selected_schema = [
+ // $meta_options[0],
+ // $meta_options[1],
+ // $meta_options[2],
+ // $meta_options[3],
+ // ];
foreach ( $meta_options as $value ) {
- if( in_array( ( $value['type'] ?? '' ) , [ 'group', 'info' ], true ) ){
+ if ( in_array( ( $value['type'] ?? '' ), [ 'group', 'info' ], true ) ) {
continue;
}
$selected_schema[] = $value;
}
// phpcs:ignore WordPress.Security.NonceVerification.Missing
- if (isset($_POST['_rtrs_rich_snippet_cat']) && is_array($_POST['_rtrs_rich_snippet_cat'])) {
+ if ( isset( $_POST['_rtrs_rich_snippet_cat'] ) && is_array( $_POST['_rtrs_rich_snippet_cat'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Missing
- foreach ($_POST['_rtrs_rich_snippet_cat'] as $value) {
- $index = $this->searchArray('rtrs_' . $value . '_schema', 'name', $meta_options);
- if ($index != null) {
- $selected_schema[] = $meta_options[$index];
+ foreach ( $_POST['_rtrs_rich_snippet_cat'] as $value ) {
+ $index = $this->searchArray( 'rtrs_' . $value . '_schema', 'name', $meta_options );
+ if ( $index != null ) {
+ $selected_schema[] = $meta_options[ $index ];
}
}
}
@@ -503,89 +534,89 @@
$meta_options = $selected_schema;
}
- foreach ($meta_options as $field) {
- if ($field['type'] == 'heading' || $field['type'] == 'auto-fill') {
+ foreach ( $meta_options as $field ) {
+ if ( $field['type'] == 'heading' || $field['type'] == 'auto-fill' ) {
continue;
}
- if ($field['type'] == 'group') {
- //escape pro field
- if ($field['name'] != 'rating_criteria') {
- if (isset($field['is_pro']) && ! function_exists('rtrsp')) {
+ if ( $field['type'] == 'group' ) {
+ // escape pro field
+ if ( $field['name'] != 'rating_criteria' ) {
+ if ( isset( $field['is_pro'] ) && ! function_exists( 'rtrsp' ) ) {
continue;
}
}
- //save group field
+ // save group field
$groupValue = [];
- //remove heading type from groups field
- foreach ($field['fields'] as $key => $single_meta) {
- if ($single_meta['type'] == 'heading' || $single_meta['type'] == 'auto-fill') {
- unset($field['fields'][$key]);
+ // remove heading type from groups field
+ foreach ( $field['fields'] as $key => $single_meta ) {
+ if ( $single_meta['type'] == 'heading' || $single_meta['type'] == 'auto-fill' ) {
+ unset( $field['fields'][ $key ] );
}
}
- //after remove heading type sort again
- $field['fields'] = array_values($field['fields']);
+ // after remove heading type sort again
+ $field['fields'] = array_values( $field['fields'] );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
- if( isset( $_REQUEST[$field['name']] ) ){
+ if ( isset( $_REQUEST[ $field['name'] ] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
- foreach ($_REQUEST[$field['name']] as $key => $group_fields) {
- $i = 0;
- foreach ($group_fields as $group_key => $group_field) {
- // if 1st nested group
- if ($field['fields'][$i]['type'] == 'group') {
- foreach ($group_field as $group_two_key => $group_two_field) {
- foreach ($group_two_field as $group_three_key => $group_three_field) {
- $nested_index = array_search($group_three_key, array_column($field['fields'][$i]['fields'], 'name'));
- //if 2nd nested group
- if ($field['fields'][$i]['fields'][$nested_index]['type'] == 'group') {
- foreach ($group_three_field as $group_four_key => $group_four_field) {
- foreach ($group_four_field as $group_five_key => $group_five_field) {
- $second_nested_index = array_search($group_five_key, array_column($field['fields'][$i]['fields'][$nested_index]['fields'], 'name'));
- $groupValue[$key][$group_key][$group_two_key][$group_three_key][$group_four_key][$group_five_key] = $this->sanitize_field($field['fields'][$i]['fields'][$nested_index]['fields'][$second_nested_index]['type'], $group_five_field);
+ foreach ( $_REQUEST[ $field['name'] ] as $key => $group_fields ) {
+ $i = 0;
+ foreach ( $group_fields as $group_key => $group_field ) {
+ // if 1st nested group
+ if ( $field['fields'][ $i ]['type'] == 'group' ) {
+ foreach ( $group_field as $group_two_key => $group_two_field ) {
+ foreach ( $group_two_field as $group_three_key => $group_three_field ) {
+ $nested_index = array_search( $group_three_key, array_column( $field['fields'][ $i ]['fields'], 'name' ) );
+ // if 2nd nested group
+ if ( $field['fields'][ $i ]['fields'][ $nested_index ]['type'] == 'group' ) {
+ foreach ( $group_three_field as $group_four_key => $group_four_field ) {
+ foreach ( $group_four_field as $group_five_key => $group_five_field ) {
+ $second_nested_index = array_search( $group_five_key, array_column( $field['fields'][ $i ]['fields'][ $nested_index ]['fields'], 'name' ) );
+ $groupValue[ $key ][ $group_key ][ $group_two_key ][ $group_three_key ][ $group_four_key ][ $group_five_key ] = $this->sanitize_field( $field['fields'][ $i ]['fields'][ $nested_index ]['fields'][ $second_nested_index ]['type'], $group_five_field );
+ }
}
+ } else {
+ $groupValue[ $key ][ $group_key ][ $group_two_key ][ $group_three_key ] = $this->sanitize_field( $field['fields'][ $i ]['fields'][ $nested_index ]['type'], $group_three_field );
}
- } else {
- $groupValue[$key][$group_key][$group_two_key][$group_three_key] = $this->sanitize_field($field['fields'][$i]['fields'][$nested_index]['type'], $group_three_field);
}
}
+ } else {
+ $groupValue[ $key ][ $group_key ] = $this->sanitize_field( $field['fields'][ $i ]['type'], $group_field );
}
- } else {
- $groupValue[$key][$group_key] = $this->sanitize_field($field['fields'][$i]['type'], $group_field);
+ $i++;
}
- $i++;
}
}
- }
- update_post_meta($post_id, $field['name'], $groupValue);
+ update_post_meta( $post_id, $field['name'], $groupValue );
} else {
- if (isset($field['multiple'])) {
- if ($field['multiple']) {
- delete_post_meta($post_id, $field['name']);
+ if ( isset( $field['multiple'] ) ) {
+ if ( $field['multiple'] ) {
+ delete_post_meta( $post_id, $field['name'] );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $mValueA = isset($_REQUEST[$field['name']]) ? array_map('sanitize_text_field', $_REQUEST[$field['name']]) : [];
- if (is_array($mValueA) && ! empty($mValueA)) {
- foreach ($mValueA as $item) {
- add_post_meta($post_id, $field['name'], trim($item));
+ $mValueA = isset( $_REQUEST[ $field['name'] ] ) ? array_map( 'sanitize_text_field', $_REQUEST[ $field['name'] ] ) : [];
+ if ( is_array( $mValueA ) && ! empty( $mValueA ) ) {
+ foreach ( $mValueA as $item ) {
+ add_post_meta( $post_id, $field['name'], trim( $item ) );
}
}
}
} else {
- //escape pro field
- if (isset($field['is_pro']) && ! function_exists('rtrsp')) {
+ // escape pro field
+ if ( isset( $field['is_pro'] ) && ! function_exists( 'rtrsp' ) ) {
continue;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
- if (isset($_REQUEST[$field['name']])) {
+ if ( isset( $_REQUEST[ $field['name'] ] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $fValue = $this->sanitize_field($field['type'], $_REQUEST[$field['name']]);
- update_post_meta($post_id, $field['name'], $fValue);
- } elseif ($field['type'] == 'switch' || $field['type'] == 'checkbox') {
- update_post_meta($post_id, $field['name'], null);
+ $fValue = $this->sanitize_field( $field['type'], $_REQUEST[ $field['name'] ] );
+ update_post_meta( $post_id, $field['name'], $fValue );
+ } elseif ( $field['type'] == 'switch' || $field['type'] == 'checkbox' ) {
+ update_post_meta( $post_id, $field['name'], null );
}
}
}
@@ -593,14 +624,14 @@
// Save current tab.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $sc_tab = isset($_REQUEST['_rtrs_sc_tab']) ? sanitize_text_field($_REQUEST['_rtrs_sc_tab']) : '';
- update_post_meta($post_id, '_rtrs_sc_tab', $sc_tab);
+ $sc_tab = isset( $_REQUEST['_rtrs_sc_tab'] ) ? sanitize_text_field( $_REQUEST['_rtrs_sc_tab'] ) : '';
+ update_post_meta( $post_id, '_rtrs_sc_tab', $sc_tab );
// generate shortcode
- if (rtrs()->getPostType() == $post->post_type) {
- Functions::generatorShortCodeCss($post_id, 'review');
- } elseif ('rtrs_affiliate' == $post->post_type) {
- Functions::generatorShortCodeCss($post_id, 'affiliate');
+ if ( rtrs()->getPostType() == $post->post_type ) {
+ Functions::generatorShortCodeCss( $post_id, 'review' );
+ } elseif ( 'rtrs_affiliate' == $post->post_type ) {
+ Functions::generatorShortCodeCss( $post_id, 'affiliate' );
}
} // end function
@@ -608,28 +639,19 @@
* Check if post type already exists before save.
*
* @param int $post_id
- *
* @return void
*/
- public function before_update_post($post_id) {
- $allowed_html = [
- 'a' => [
- 'href' => [],
- 'title' => [],
- ],
- 'b' => [],
- 'p' => [],
- ];
- // phpcs:ignore WordPress.Security.NonceVerification.Missing
- if (isset($_POST['rtrs_post_type']) && ! $_POST['rtrs_post_type']) {
- wp_die(wp_kses(__('<b>ERROR:</b> Please choose a post type', 'review-schema'), $allowed_html) . "<p><a href='javascript:history.back()'>" . esc_html__('« Back', 'review-schema') . '</a></p>');
- } else {
- // phpcs:ignore WordPress.Security.NonceVerification.Missing
- $post_type = isset($_POST['rtrs_post_type']) ? sanitize_text_field($_POST['rtrs_post_type']) : '';
- $scPostIds = get_posts([
+ public function before_update_post( $post_id ) {
+ if ( rtrs()->getPostType() !== get_post_type( $post_id ) ) {
+ return;
+ }
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $post_type = isset( $_POST['rtrs_post_type'] ) ? sanitize_text_field( $_POST['rtrs_post_type'] ) : '';
+ $scPostIds = get_posts(
+ [
'post_type' => rtrs()->getPostType(),
'posts_per_page' => -1,
- 'post_status' => ['publish', 'draft'],
+ 'post_status' => [ 'publish', 'draft' ],
'fields' => 'ids',
'meta_query' => [
[
@@ -638,13 +660,18 @@
'compare' => '=',
],
],
- ]);
-
- $current_post_type = get_post_meta($post_id, 'rtrs_post_type', true);
-
- if (($current_post_type != $post_type) && ! empty($scPostIds)) {
- wp_die(wp_kses(__('<b>ERROR:</b> Sorry! this post type already exist, you need to choose new one.', 'review-schema'), $allowed_html) . "<p><a href='javascript:history.back()'>" . esc_html__('« Back', 'review-schema') . '</a></p>');
- }
+ ]
+ );
+ $current_post_type = get_post_meta( $post_id, 'rtrs_post_type', true );
+ if ( ! post_type_exists( $post_type ) ) {
+ $this->add_admin_error( __( 'Please choose a valid post type.', 'review-schema' ) );
+ $this->redirect_back();
+ return;
+ }
+ if ( ( $current_post_type !== $post_type ) && ! empty( $scPostIds ) ) {
+ $this->add_admin_error( __( 'This post type already exists. Please choose a new one.', 'review-schema' ) );
+ $this->redirect_back();
+ return;
}
}
@@ -654,11 +681,11 @@
*
* @return void
*/
- public function before_delete_post($post_id, $post) {
- if (rtrs()->getPostType() == $post->post_type) {
- Functions::removeGeneratorShortCodeCss($post_id, 'review');
- } elseif ('rtrs_affiliate' == $post->post_type) {
- Functions::removeGeneratorShortCodeCss($post_id, 'affiliate');
+ public function before_delete_post( $post_id, $post ) {
+ if ( rtrs()->getPostType() == $post->post_type ) {
+ Functions::removeGeneratorShortCodeCss( $post_id, 'review' );
+ } elseif ( 'rtrs_affiliate' == $post->post_type ) {
+ Functions::removeGeneratorShortCodeCss( $post_id, 'affiliate' );
}
}
}
--- a/review-schema/app/Controllers/Admin/Meta/MetaOptions.php
+++ b/review-schema/app/Controllers/Admin/Meta/MetaOptions.php
@@ -11,7 +11,7 @@
* @return array
*/
public function allMetaFields() {
- $fields = array();
+ $fields = [];
$fieldsA = array_merge(
$this->sectionConditionalFields(),
$this->sectionReviewFields(),
@@ -32,7 +32,7 @@
* @return array
*/
public static function metaValue( $sc_id ) {
- $sc_meta = array();
+ $sc_meta = [];
// layout tab
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$sc_meta['rtrs_post_type'] = isset( $_REQUEST['rtrs_post_type'] ) ? sanitize_text_field( $_REQUEST['rtrs_post_type'] ) : get_post_meta( $sc_id, 'rtrs_post_type', true );
@@ -41,7 +41,7 @@
}
public function filterOptions() {
- $business_info_field = array(
+ $business_info_field = [
'top_rated' => esc_html__( 'Top Rated', 'review-schema' ),
'low_rated' => esc_html__( 'Lowest Rating', 'review-schema' ),
'latest_first' => esc_html__( 'Latest First', 'review-schema' ),
@@ -49,26 +49,26 @@
// TODO: do it later
// 'recommended' => esc_html__('Recommended', 'review-schema'),
// 'highlighted' => esc_html__('Highlighted', 'review-schema'),
- );
+ ];
return apply_filters( 'rtrs_business_info_field', $business_info_field );
}
public function reviewFields() {
- $review_field = array(
+ $review_field = [
'img' => esc_html__( 'Author Image', 'review-schema' ),
'name' => esc_html__( 'Author Name', 'review-schema' ),
'rating_star' => esc_html__( 'Rating Star', 'review-schema' ),
'time' => esc_html__( 'Time', 'review-schema' ),
'review' => esc_html__( 'Review', 'review-schema' ),
- );
+ ];
return apply_filters( 'rtrs_review_field', $review_field );
}
public function sectionConditionalFields() {
- $section_conditional = array(
- array(
+ $section_conditional = [
+ [
'type' => 'select2',
'name' => 'rtrs_post_type',
'label' => esc_html__( 'Select post type', 'review-schema' ),
@@ -76,8 +76,8 @@
'required' => true,
'id' => 'rtrs-post-type',
'options' => $this->postType(),
- ),
- array(
+ ],
+ [
'type' => 'select2',
'name' => 'rtrs_page_id',
'holderClass' => 'rtrs-hidden',
@@ -86,46 +86,46 @@
'id' => 'rtrs-page-id',
'multiple' => true,
'options' => $this->allPages(),
- ),
- array(
+ ],
+ [
'type' => 'radio',
'name' => 'rtrs_support',
'label' => esc_html__( 'Support', 'review-schema' ),
'id' => 'rtrs-support',
'default' => 'review-schema',
'alignment' => 'vertical',
- 'options' => array(
+ 'options' => [
'review-schema' => esc_html__( 'Review with Schema JSON-LD', 'review-schema' ),
'review' => esc_html__( 'Only Review', 'review-schema' ),
'schema' => esc_html__( 'Only Schema JSON-LD', 'review-schema' ),
- ),
- ),
- );
+ ],
+ ],
+ ];
return apply_filters( 'rtrs_section_conditional_fields', $section_conditional );
}
public function sectionReviewFields() {
- $section_layout = array(
- array(
+ $section_layout = [
+ [
'type' => 'radio-image',
'name' => 'criteria',
'label' => esc_html__( 'Criteria?', 'review-schema' ),
'doc' => esc_html__( 'If you want you can enable or disable single or criteria based rating from here', 'review-schema' ),
'id' => 'rtrs-criteria',
'default' => 'single',
- 'options' => array(
- array(
+ 'options' => [
+ [
'value' => 'single',
'img' => RTRS_URL . '/assets/imgs/single-criteria.jpg',
- ),
- array(
+ ],
+ [
'value' => 'multi',
'img' => RTRS_URL . '/assets/imgs/multi-criteria.jpg',
- ),
- ),
- ),
- array(
+ ],
+ ],
+ ],
+ [
'type' => 'repeater',
'name' => 'multi_criteria',
'label' => esc_html__( 'Multi criteria', 'review-schema' ),
@@ -133,91 +133,91 @@
'alignment' => 'vertical',
'default' => $this->multiCriteria(),
'options' => $this->multiCriteria(),
- ),
- array(
+ ],
+ [
'type' => 'radio-image',
'name' => 'summary_layout',
'label' => esc_html__( 'Review summary layout', 'review-schema' ),
'default' => 'one',
'id' => 'rtrs-summary_layout',
- 'options' => array(
- array(
+ 'options' => [
+ [
'value' => 'one',
'img' => RTRS_URL . '/assets/imgs/summary-one.jpg',
- ),
- array(
+ ],
+ [
'value' => 'two',
'img' => RTRS_URL . '/assets/imgs/summary-two.jpg',
- ),
- array(
+ ],
+ [
'value' => 'three',
'img' => RTRS_URL . '/assets/imgs/summary-three.jpg',
'is_pro' => true,
- ),
- array(
+ ],
+ [
'value' => 'four',
'img' => RTRS_URL . '/assets/imgs/summary-four.jpg',
'is_pro' => true,
- ),
- ),
- ),
- array(
+ ],
+ ],
+ ],
+ [
'type' => 'radio-image',
'name' => 'review_layout',
'label' => esc_html__( 'Review layout', 'review-schema' ),
'default' => 'one',
'id' => 'rtrs-review_layout',
- 'options' => array(
- array(
+ 'options' => [
+ [
'value' => 'one',
'img' => RTRS_URL . '/assets/imgs/review-one.jpg',
- ),
- array(
+ ],
+ [
'value' => 'two',
'img' => RTRS_URL . '/assets/imgs/review-two.jpg',
- ),
- array(
+ ],
+ [
'value' => 'three',
'img' => RTRS_URL . '/assets/imgs/review-three.jpg',
'is_pro' => true,
- ),
- array(
+ ],
+ [
'value' => 'four',
'img' => RTRS_URL . '/assets/imgs/review-two.jpg',
'is_pro' => true,
- ),
- ),
- ),
- array(
+ ],
+ ],
+ ],
+ [
'type' => 'select2',
'name' => 'pagination_type',
'label' => esc_html__( 'Pagination type', 'review-schema' ),
'id' => 'rtrs-pagination_type',
'default' => 'normal',
'options' => $this->pagination_type(),
- ),
- );
+ ],
+ ];
return apply_filters( 'rtrs_section_layout_fields', $section_layout );
}
public function sectionSchemaFields() {
- $section_schema = array(
- array(
+ $section_schema = [
+ [
'name' => 'page_schema',
'type' => 'heading',
'holderClass' => 'rtrs-page-schema',
'label' => esc_html__( 'Google rich snippet?', 'review-schema' ),
'desc' => __( "Google auto rich snippet not support in page, you need to set it manually from single page. <a target='_blank' href='https://www.radiustheme.com/docs/review-schema/generate-review-schema/schema/'> Help Documentation</a>", 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'rich_snippet',
'id' => 'rtrs-auto_rich_snippet',
'label' => esc_html__( 'Structured data (rich snippet)?', 'review-schema' ),
'desc' => esc_html__( 'Auto generate Structured data schema (rich snippet). If you want, you can add custom structured data from single post/page', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'select2',
'name' => 'rich_snippet_cat',
'label' => esc_html__( 'Structured data type', 'review-schema' ),
@@ -225,67 +225,102 @@
'default' => '',
'id' => 'rtrs-rich_snippet_cat_back',
'options' => Functions::rich_snippet_auto_cats(),
- ),
- );
+ ],
+ ];
return apply_filters( 'rtrs_section_schema_fields', $section_schema );
}
public function sectionSettingFields() {
- $settings_fields = array(
- array(
+ $settings_fields = [
+ /*
+ [
+ 'type' => 'switch',
+ 'name' => 'review-summary-hide',
+ 'id' => 'rtrs-summary-hide',
+ 'label' => esc_html__( 'Hide Review Summary?', 'review-schema' ),
+ 'option' => esc_html__( 'Hide', 'review-schema' ),
+ 'desc' => sprintf(
+ esc_html__( 'When enabled, the review summary will be hidden, but you can still display it using the %s shortcode.', 'review-schema' ),
+ '<strong>[rtrs-review-summary]</strong>'
+ ),
+ ],
+ [
+ 'type' => 'switch',
+ 'name' => 'review-list-hide',
+ 'id' => 'rtrs-list-hide',
+ 'label' => esc_html__( 'Hide Review List?', 'review-schema' ),
+ 'option' => esc_html__( 'Disable', 'review-schema' ),
+ 'desc' => sprintf(
+ esc_html__( 'When enabled, the review list will be hidden, but you can still display it using the %s shortcode.', 'review-schema' ),
+ '<strong>[rtrs-review-list]</strong>'
+ ),
+ ],
+ [
+ 'type' => 'switch',
+ 'name' => 'review-form-hide',
+ 'id' => 'rtrs-form-hide',
+ 'label' => esc_html__( 'Hide Review Form?', 'review-schema' ),
+ 'option' => esc_html__( 'Disable', 'review-schema' ),
+ 'desc' => sprintf(
+ esc_html__( 'When enabled, the review form will be hidden, but you can still display it using the %s shortcode.', 'review-schema' ),
+ '<strong>[rtrs-review-form]</strong>'
+ ),
+ ],
+ */
+ [
'type' => 'switch',
'name' => 'title',
'id' => 'rtrs-title',
'label' => esc_html__( 'Review title disable?', 'review-schema' ),
'option' => esc_html__( 'Disable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'human-time-diff',
'id' => 'rtrs-human-time-diff',
'label' => esc_html__( 'Disable human readable time format ?', 'review-schema' ),
'option' => esc_html__( 'Disable', 'review-schema' ),
'desc' => esc_html__( 'By default review time is human readable format such as "1 hour ago", "5 mins ago", "2 days ago " Or ', 'review-schema' ) . ' <a href=' . admin_url( 'options-general.php' ) . '>' . esc_html__( 'Go to General Settings for change date formate', 'review-schema' ) . '</a>',
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'website',
'id' => 'rtrs-website',
'label' => esc_html__( 'Review website url disable?', 'review-schema' ),
'option' => esc_html__( 'Disable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'image_review',
'id' => 'rtrs-image-review',
'label' => esc_html__( 'Allow image review?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'video_review',
'is_pro' => true,
'id' => 'rtrs-video-review',
'label' => esc_html__( 'Allow video review?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'pros_cons',
'id' => 'rtrs-pros_cons',
'label' => esc_html__( 'Allow pros cons?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'name' => 'pros_cons_limit',
'type' => 'number',
'default' => 3,
'is_pro' => true,
'label' => esc_html__( 'Pros cons limit', 'review-schema' ),
'desc' => esc_html__( 'How many field field you want to allow', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'recommendation',
'is_pro' => true,
@@ -293,8 +328,8 @@
'class' => 'rtrs-hidden',
'label' => esc_html__( 'Allow recommendation?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'highlight_review',
'is_pro' => true,
@@ -302,8 +337,8 @@
'class' => 'rtrs-hidden',
'label' => esc_html__( 'Highlight review?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'sticky_review',
'is_pro' => true,
@@ -311,40 +346,40 @@
'class' => 'rtrs-hidden',
'label' => esc_html__( 'Sticky review?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'social_share',
'is_pro' => true,
'id' => 'rtrs-social-share',
'label' => esc_html__( 'Social share?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'like',
'is_pro' => true,
'id' => 'rtrs-like',
'label' => esc_html__( 'Allow review like?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'dislike',
'is_pro' => true,
'id' => 'rtrs-dislike',
'label' => esc_html__( 'Allow review dislike?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'type' => 'switch',
'name' => 'anonymous_review',
'is_pro' => true,
'id' => 'rtrs-anonymous_review',
'label' => esc_html__( 'Allow anonymous review?', 'review-schema' ),
'option' => esc_html__( 'Enable', 'review-schema' ),
- ),
- array(
+ ],
+ [
'