From bd875acd2fce7ab493c09eb3305d8f060c4ebf95 Mon Sep 17 00:00:00 2001 From: Ajay D'Souza Date: Sun, 22 Dec 2024 15:28:58 +0000 Subject: [PATCH] Show admin notices when the Style is set Fixes #208 --- includes/admin/settings/class-settings.php | 22 ++++++++++++++++++++++ readme.txt | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/includes/admin/settings/class-settings.php b/includes/admin/settings/class-settings.php index f55f979..a70cc6e 100644 --- a/includes/admin/settings/class-settings.php +++ b/includes/admin/settings/class-settings.php @@ -1243,10 +1243,14 @@ public function change_settings_on_save( $settings ) { if ( 'inline' !== $settings['post_thumb_op'] && 'thumbs_only' !== $settings['post_thumb_op'] ) { $settings['post_thumb_op'] = 'inline'; } + + add_settings_error( $this->prefix . '-notices', '', 'Note: Display of the author, excerpt and date has been disabled as the Thumbnail style is set to Rounded Thumbnails or Rounded Thumbnails with Grid. You can change the style in the Styles tab.', 'updated' ); } // Overwrite settings if text_only thumbnail style is selected. if ( 'text_only' === $settings['crp_styles'] ) { $settings['post_thumb_op'] = 'text_only'; + + add_settings_error( $this->prefix . '-notices', '', 'Note: Thumbnail location set to Text Only as the Thumbnail style is set to Text Only. You can change the style in the Styles tab.', 'updated' ); } // Force thumb_width and thumb_height if either are zero. @@ -1435,6 +1439,24 @@ public static function after_setting_output( $output, $args ) { $output .= '' . esc_html__( 'Upgrade to Pro', 'contextual-related-posts' ) . ''; } + // If $args['id'] is show_excerpt, show_author, show_date and global $crp_settings['crp_styles'] is rounded_thumbs or thumbs_grid then display a notice saying these can't be changed and the style can be changed in the Styles tab. + if ( in_array( $args['id'], array( 'show_excerpt', 'show_author', 'show_date' ), true ) ) { + global $crp_settings; + if ( in_array( $crp_settings['crp_styles'], array( 'rounded_thumbs', 'thumbs_grid' ), true ) ) { + $output .= '

' . esc_html__( 'Note: This setting cannot be changed as the Thumbnail style is set to Rounded Thumbnails or Rounded Thumbnails with Grid. You can change the style in the Styles tab.', 'contextual-related-posts' ) . '

'; + } + } + + if ( in_array( $args['id'], array( 'post_thumb_op' ), true ) ) { + global $crp_settings; + if ( in_array( $crp_settings['crp_styles'], array( 'text_only' ), true ) ) { + $output .= '

' . esc_html__( 'Note: This setting cannot be changed as the Thumbnail style is set to Text Only. You can change the style in the Styles tab.', 'contextual-related-posts' ) . '

'; + } + if ( in_array( $crp_settings['crp_styles'], array( 'rounded_thumbs', 'thumbs_grid' ), true ) ) { + $output .= '

' . esc_html__( 'Note: This setting cannot be changed as the Thumbnail style is set to Rounded Thumbnails or Rounded Thumbnails with Grid. You can change the style in the Styles tab.', 'contextual-related-posts' ) . '

'; + } + } + return $output; } } diff --git a/readme.txt b/readme.txt index 48981cc..4d11989 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,4 @@ -=== Contextual Related Posts Pro === +=== Contextual Related Posts === Tags: related posts, related, contextual related posts, similar posts, seo Contributors: webberzone, ajay Donate link: https://wzn.io/donate-crp @@ -164,6 +164,7 @@ If you enable thumbnails, the plugin will try to find the correct thumbnail in t * Auto-insertion of default and global settings attributes, with an option to disable this in the **List tuning** tab. * Modifications: + * Show admin notices when the Style is set to "Rounded Thumbnails", "Rounded Thumbnails with Grid", or "Text Only" in the Settings page. A notice will appear below the affected settings, indicating that these options cannot be modified. * Updated Freemius SDK to 2.10.1 * Bug fixes: