Skip to content

Commit

Permalink
Show admin notices when the Style is set
Browse files Browse the repository at this point in the history
Fixes #208
  • Loading branch information
ajaydsouza committed Dec 22, 2024
1 parent 38e7b11 commit bd875ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions includes/admin/settings/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1435,6 +1439,24 @@ public static function after_setting_output( $output, $args ) {
$output .= '<a class="crp_button crp_button_gold" target="_blank" href="https://webberzone.com/plugins/contextual-related-posts/pro/" title="' . esc_attr__( 'Upgrade to Pro', 'contextual-related-posts' ) . '">' . esc_html__( 'Upgrade to Pro', 'contextual-related-posts' ) . '</a>';
}

// 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 .= '<p class="description" style="color:#9B0800;">' . 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' ) . '</p>';
}
}

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 .= '<p class="description" style="color:#9B0800;">' . 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' ) . '</p>';
}
if ( in_array( $crp_settings['crp_styles'], array( 'rounded_thumbs', 'thumbs_grid' ), true ) ) {
$output .= '<p class="description" style="color:#9B0800;">' . 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' ) . '</p>';
}
}

return $output;
}
}
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit bd875ac

Please sign in to comment.