Contextual Related Posts - Version 2.5.0

Version Description

  • Features:

    • New option to disable related posts on mobile devices
    • New option to disable related posts on AMP pages
  • Enhancements:

    • New filters crp_thumb_alt and crp_thumb_title to edit the post thumbnail alt and title tags. Use this to remove/replace the tags
    • New function and filter crp_permalink
    • Saving a post will delete its cache
  • Bug fixes:

    • Fixed CSS validation errors
    • Removed conversion of table schema from/to InnoDB. If you are using a version of mySQL above v5.6, you can alter the table engine to use InnoDB with a FULLTEXT index
    • Prevent errors from non-existent post id (virtual post). Contributed by @jnorell
Download this release

Release Info

Developer Ajay
Plugin Icon 128x128 Contextual Related Posts
Version 2.5.0
Comparing to
See all releases

Code changes from version 2.4.1 to 2.5.0

README.md CHANGED
@@ -1,21 +1,20 @@
 
 
1
  [![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/contextual-related-posts.svg?style=flat-square)](https://wordpress.org/plugins/contextual-related-posts/)
2
  [![License](https://img.shields.io/badge/license-GPL_v2%2B-orange.svg?style=flat-square)](http://opensource.org/licenses/GPL-2.0)
3
  [![WordPress Tested](https://img.shields.io/wordpress/v/contextual-related-posts.svg?style=flat-square)](https://wordpress.org/plugins/contextual-related-posts/)
4
  [![Build Status](https://travis-ci.org/WebberZone/contextual-related-posts.svg?branch=master)](https://travis-ci.org/WebberZone/contextual-related-posts)
5
  [![Code Climate](https://codeclimate.com/github/WebberZone/contextual-related-posts/badges/gpa.svg)](https://codeclimate.com/github/WebberZone/contextual-related-posts)
6
 
7
- # Contextual Related Posts
8
-
9
- __Requires:__ 4.1
10
 
11
- __Tested up to:__ 4.8
12
 
13
  __License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html)
14
 
15
  __Plugin page:__ [Contextual Related Posts home page](https://webberzone.com/plugins/contextual-related-posts/) | [WordPress.org listing](https://wordpress.org/plugins/contextual-related-posts/)
16
 
17
-
18
- Display related posts on your WordPress blog and feed. Supports thumbnails, shortcodes, widgets and custom post types!
19
 
20
  ## Description
21
 
@@ -30,27 +29,33 @@ And the default inbuilt styles allow you to switch between gorgeous thumbnail-ri
30
  ### Key features
31
 
32
  * **Automatic**: CRP will start displaying related posts on your site and feed automatically after the content when you activate the plugin. No need to edit template files
33
- * **Manual install**: Want more control over placement? Check the [FAQ](http://wordpress.org/extend/plugins/contextual-related-posts/faq/) on which functions are available for manual install.
 
34
  * **Widgets**: Add related posts to widgetized area of your theme. Lots of options available
35
  * **Shortcode**: Use `[crp]` to display the posts anywhere you want in the post content
36
  * **The algorithm**: Find related posts by title and/or content of the current post
37
- * **Caching**: Related posts output is automatically cached as visitors browse through your site
38
  * **Exclusions**: Exclude posts from categories from being displayed in the list. Or you can exclude posts or pages by ID
39
  * **Custom post types**: The related posts list lets you include posts, pages, attachments or any other custom post type!
40
  * **Thumbnail support**:
41
- * Support for WordPress post thumbnails. CRP will create a custom image size (`crp_thumbnail`) with the dimensions specified in the Settings page
42
- * Auto-extract the first image in your post to be displayed as a thumbnail
43
- * Manually enter the URL of the thumbnail via [WordPress meta fields](http://codex.wordpress.org/Custom_Fields). Specify this using the meta box in your Edit screens.
44
- * Optionally, use timthumb to resize images or use your own filter function to resize post images
45
  * **Styles**: The output is wrapped in CSS classes which allows you to easily style the list. You can enter your custom CSS styles from within WordPress Admin area or use the style included.
46
  * **Customisable output**:
47
- * Display excerpts in post. You can select the length of the excerpt in words
48
- * Customise which HTML tags to use for displaying the output in case you don't prefer the default `list` format
49
  * **Extendable code**: CRP has tonnes of filters and actions that allow any developer to easily add features, edit outputs, etc.
50
 
51
- ### Extensions
 
 
 
 
52
 
53
- * [CRP Taxonomy Extender](https://webberzone.com/plugins/crp-taxonomy/)
 
 
54
 
55
  ### Donations
56
 
@@ -58,42 +63,32 @@ I spend a significant amount of my free time maintaining, updating and more impo
58
  If you have been using this plugin and find this useful, do consider making a donation. This helps me pay for my hosting and domains.
59
 
60
  ### Translations
61
- Contextual Related Posts is now on Transifex with several translations made available by the [WP Translations](http://wp-translations.org). If you're a translator, do consider joining the WP Translations team and contribute towards this and a huge number of WordPress plugins.
62
-
63
- Visit [Contextual Related Posts on Transifex](https://www.transifex.com/projects/p/contextual-related-posts/).
64
 
 
65
 
66
  ## Screenshots
67
- ![General Options](https://raw.github.com/WebberZone/contextual-related-posts/master/wporg-assets/screenshot-1.png)
68
-
69
- _Contextual Related Posts - General Options_
70
 
71
- More screenshots are available on the [WordPress plugin page](http://wordpress.org/plugins/contextual-related-posts/screenshots/)
 
72
 
 
73
 
74
  ## Installation
75
 
76
  ### WordPress install (the easy way)
77
 
78
  1. Navigate to Plugins within your WordPress Admin Area
79
-
80
  2. Click "Add new" and in the search box enter "Contextual Related Posts"
81
-
82
  3. Find the plugin in the list (usually the first result) and click "Install Now"
83
 
84
  ### Manual install
85
 
86
  1. Download the plugin
87
-
88
  2. Extract the contents of contextual-related-posts.zip to wp-content/plugins/ folder. You should get a folder called contextual-related-posts.
89
-
90
  3. Activate the Plugin in WP-Admin under the Plugins screen
91
 
92
-
93
-
94
  ## Frequently Asked Questions
95
 
96
- Check out the [FAQ on the plugin page](http://wordpress.org/plugins/contextual-related-posts/faq/).
97
-
98
- If your question isn't listed there, please create a new post at the [WordPress.org support forum](http://wordpress.org/support/plugin/contextual-related-posts). It is the fastest way to get support as I monitor the forums regularly. I also provide [premium *paid* support via email](https://webberzone.com/support/).
99
 
 
1
+ # Contextual Related Posts
2
+
3
  [![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/contextual-related-posts.svg?style=flat-square)](https://wordpress.org/plugins/contextual-related-posts/)
4
  [![License](https://img.shields.io/badge/license-GPL_v2%2B-orange.svg?style=flat-square)](http://opensource.org/licenses/GPL-2.0)
5
  [![WordPress Tested](https://img.shields.io/wordpress/v/contextual-related-posts.svg?style=flat-square)](https://wordpress.org/plugins/contextual-related-posts/)
6
  [![Build Status](https://travis-ci.org/WebberZone/contextual-related-posts.svg?branch=master)](https://travis-ci.org/WebberZone/contextual-related-posts)
7
  [![Code Climate](https://codeclimate.com/github/WebberZone/contextual-related-posts/badges/gpa.svg)](https://codeclimate.com/github/WebberZone/contextual-related-posts)
8
 
9
+ __Requires:__ 4.2
 
 
10
 
11
+ __Tested up to:__ 5.0
12
 
13
  __License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html)
14
 
15
  __Plugin page:__ [Contextual Related Posts home page](https://webberzone.com/plugins/contextual-related-posts/) | [WordPress.org listing](https://wordpress.org/plugins/contextual-related-posts/)
16
 
17
+ Add related posts to your WordPress site with inbuilt caching. Supports thumbnails, shortcodes, widgets and custom post types!
 
18
 
19
  ## Description
20
 
29
  ### Key features
30
 
31
  * **Automatic**: CRP will start displaying related posts on your site and feed automatically after the content when you activate the plugin. No need to edit template files
32
+ * **Manual install**: Want more control over placement? Check the [FAQ](https://wordpress.org/extend/plugins/contextual-related-posts/faq/) on which functions are available for manual install.
33
+ * **Caching**: Related posts output is automatically cached as visitors browse through your site
34
  * **Widgets**: Add related posts to widgetized area of your theme. Lots of options available
35
  * **Shortcode**: Use `[crp]` to display the posts anywhere you want in the post content
36
  * **The algorithm**: Find related posts by title and/or content of the current post
 
37
  * **Exclusions**: Exclude posts from categories from being displayed in the list. Or you can exclude posts or pages by ID
38
  * **Custom post types**: The related posts list lets you include posts, pages, attachments or any other custom post type!
39
  * **Thumbnail support**:
40
+ * Support for WordPress post thumbnails. CRP will create a custom image size (`crp_thumbnail`) with the dimensions specified in the Settings page
41
+ * Auto-extract the first image in your post to be displayed as a thumbnail
42
+ * Manually enter the URL of the thumbnail via [WordPress meta fields](http://codex.wordpress.org/Custom_Fields). Specify this using the meta box in your Edit screens.
43
+ * Optionally, use timthumb to resize images or use your own filter function to resize post images
44
  * **Styles**: The output is wrapped in CSS classes which allows you to easily style the list. You can enter your custom CSS styles from within WordPress Admin area or use the style included.
45
  * **Customisable output**:
46
+ * Display excerpts in post. You can select the length of the excerpt in words
47
+ * Customise which HTML tags to use for displaying the output in case you don't prefer the default `list` format
48
  * **Extendable code**: CRP has tonnes of filters and actions that allow any developer to easily add features, edit outputs, etc.
49
 
50
+ ### Extensions/Addons
51
+
52
+ * [Related Posts by Categories and Tags](https://webberzone.com/downloads/crp-taxonomy/)
53
+
54
+ ### GDPR
55
 
56
+ Contextual Related Posts is GDPR compliant as it doesn't collect any personal data about your visitors when installed out of the box. All posts are processed on your site and not sent to any external service.
57
+
58
+ YOU ARE RESPONSIBLE FOR ENSURING THAT ALL GDPR REQUIREMENTS ARE MET ON YOUR WEBSITE.
59
 
60
  ### Donations
61
 
63
  If you have been using this plugin and find this useful, do consider making a donation. This helps me pay for my hosting and domains.
64
 
65
  ### Translations
 
 
 
66
 
67
+ Contextual Related Posts is available for [translation directly on WordPress.org](https://translate.wordpress.org/projects/wp-plugins/contextual-related-posts). Check out the official [Translator Handbook](https://make.wordpress.org/polyglots/handbook/rosetta/theme-plugin-directories/) to contribute.
68
 
69
  ## Screenshots
 
 
 
70
 
71
+ ![General Options](https://raw.github.com/WebberZone/contextual-related-posts/master/wporg-assets/screenshot-1.png)
72
+ *Contextual Related Posts - General Options*
73
 
74
+ More screenshots are available on the [WordPress plugin page](https://wordpress.org/plugins/contextual-related-posts/screenshots/)
75
 
76
  ## Installation
77
 
78
  ### WordPress install (the easy way)
79
 
80
  1. Navigate to Plugins within your WordPress Admin Area
 
81
  2. Click "Add new" and in the search box enter "Contextual Related Posts"
 
82
  3. Find the plugin in the list (usually the first result) and click "Install Now"
83
 
84
  ### Manual install
85
 
86
  1. Download the plugin
 
87
  2. Extract the contents of contextual-related-posts.zip to wp-content/plugins/ folder. You should get a folder called contextual-related-posts.
 
88
  3. Activate the Plugin in WP-Admin under the Plugins screen
89
 
 
 
90
  ## Frequently Asked Questions
91
 
92
+ Check out the [FAQ on the plugin page](https://wordpress.org/plugins/contextual-related-posts/faq/).
 
 
93
 
94
+ If your question isn't listed there, please create a new post at the [WordPress.org support forum](https://wordpress.org/support/plugin/contextual-related-posts). It is the fastest way to get support as I monitor the forums regularly. I also provide [premium *paid* support via email](https://webberzone.com/support/).
admin/admin.php CHANGED
@@ -5,10 +5,10 @@
5
  * This page is accessible via Settings > Contextual Related Posts
6
  *
7
  * @package Contextual_Related_Posts
8
- * @author Ajay D'Souza <me@ajaydsouza.com>
9
  * @license GPL-2.0+
10
  * @link https://webberzone.com
11
- * @copyright 2009-2017 Ajay D'Souza
12
  */
13
 
14
  /**** If this file is called directly, abort. ****/
@@ -20,7 +20,7 @@ if ( ! defined( 'WPINC' ) ) {
20
  /**
21
  * Function generates the plugin settings page.
22
  *
23
- * @since 1.0.1
24
  */
25
  function crp_options() {
26
 
@@ -28,15 +28,17 @@ function crp_options() {
28
 
29
  $crp_settings = crp_read_options();
30
 
31
- $wp_post_types = get_post_types( array(
32
- 'public' => true,
33
- ) );
 
 
34
 
35
  // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
36
  if ( ! empty( $crp_settings['post_types'] ) && false === strpos( $crp_settings['post_types'], '=' ) ) {
37
  $post_types = explode( ',', $crp_settings['post_types'] );
38
  } else {
39
- parse_str( $crp_settings['post_types'], $post_types ); // Save post types in $post_types variable.
40
  }
41
 
42
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
@@ -45,7 +47,7 @@ function crp_options() {
45
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
46
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
47
  } else {
48
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
49
  }
50
 
51
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
@@ -63,52 +65,54 @@ function crp_options() {
63
 
64
  if ( ( isset( $_POST['crp_save'] ) ) && ( check_admin_referer( 'crp-plugin-settings' ) ) ) { // Input var okay.
65
 
66
- /**** General options ***/
67
- $crp_settings['cache'] = isset( $_POST['cache'] ) ? true : false;
68
- $crp_settings['limit'] = absint( $_POST['limit'] );
69
- $crp_settings['daily_range'] = absint( $_POST['daily_range'] );
70
- $crp_settings['random_order'] = isset( $_POST['random_order'] ) ? true : false;
71
- $crp_settings['match_content'] = isset( $_POST['match_content'] ) ? true : false;
72
  $crp_settings['match_content_words'] = min( CRP_MAX_WORDS, absint( $_POST['match_content_words'] ) );
73
- $crp_settings['same_post_type'] = isset( $_POST['same_post_type'] ) ? true : false;
74
 
75
- $crp_settings['add_to_content'] = ( isset( $_POST['add_to_content'] ) ? true : false );
76
- $crp_settings['add_to_page'] = ( isset( $_POST['add_to_page'] ) ? true : false );
77
- $crp_settings['add_to_feed'] = ( isset( $_POST['add_to_feed'] ) ? true : false );
78
- $crp_settings['add_to_home'] = ( isset( $_POST['add_to_home'] ) ? true : false );
79
  $crp_settings['add_to_category_archives'] = ( isset( $_POST['add_to_category_archives'] ) ? true : false );
80
- $crp_settings['add_to_tag_archives'] = ( isset( $_POST['add_to_tag_archives'] ) ? true : false );
81
- $crp_settings['add_to_archives'] = ( isset( $_POST['add_to_archives'] ) ? true : false );
82
 
83
  $crp_settings['content_filter_priority'] = absint( $_POST['content_filter_priority'] );
84
- $crp_settings['insert_after_paragraph'] = ( -1 === $_POST['insert_after_paragraph'] || '' === $_POST['insert_after_paragraph'] ) ? -1 : intval( $_POST['insert_after_paragraph'] );
85
- $crp_settings['show_metabox'] = ( isset( $_POST['show_metabox'] ) ? true : false );
86
- $crp_settings['show_metabox_admins'] = ( isset( $_POST['show_metabox_admins'] ) ? true : false );
87
- $crp_settings['show_credit'] = ( isset( $_POST['show_credit'] ) ? true : false );
88
-
89
- /**** Output options ****/
90
- $crp_settings['title'] = wp_kses_post( wp_unslash( $_POST['title'] ) );
91
- $crp_settings['blank_output'] = 'blank' === $_POST['blank_output'] ? true : false;
 
 
92
  $crp_settings['blank_output_text'] = wp_kses_post( wp_unslash( $_POST['blank_output_text'] ) );
93
 
94
- $crp_settings['show_excerpt'] = ( isset( $_POST['show_excerpt'] ) ? true : false );
95
- $crp_settings['show_date'] = ( isset( $_POST['show_date'] ) ? true : false );
96
- $crp_settings['show_author'] = ( isset( $_POST['show_author'] ) ? true : false );
97
  $crp_settings['excerpt_length'] = absint( $_POST['excerpt_length'] );
98
- $crp_settings['title_length'] = absint( $_POST['title_length'] );
99
 
100
  $crp_settings['link_new_window'] = ( isset( $_POST['link_new_window'] ) ? true : false );
101
- $crp_settings['link_nofollow'] = ( isset( $_POST['link_nofollow'] ) ? true : false );
102
 
103
- $crp_settings['before_list'] = wp_kses_post( wp_unslash( $_POST['before_list'] ) );
104
- $crp_settings['after_list'] = wp_kses_post( wp_unslash( $_POST['after_list'] ) );
105
  $crp_settings['before_list_item'] = wp_kses_post( wp_unslash( $_POST['before_list_item'] ) );
106
- $crp_settings['after_list_item'] = wp_kses_post( wp_unslash( $_POST['after_list_item'] ) );
107
 
108
  $crp_settings['exclude_on_post_ids'] = empty( $_POST['exclude_on_post_ids'] ) ? '' : implode( ',', array_map( 'absint', explode( ',', sanitize_text_field( wp_unslash( $_POST['exclude_on_post_ids'] ) ) ) ) );
109
- $crp_settings['exclude_post_ids'] = empty( $_POST['exclude_post_ids'] ) ? '' : implode( ',', array_map( 'absint', explode( ',', sanitize_text_field( wp_unslash( $_POST['exclude_post_ids'] ) ) ) ) );
110
 
111
- /**** Thumbnail options ****/
112
  $crp_settings['post_thumb_op'] = sanitize_text_field( wp_unslash( $_POST['post_thumb_op'] ) );
113
 
114
  $crp_settings['thumb_size'] = sanitize_text_field( wp_unslash( $_POST['thumb_size'] ) );
@@ -117,47 +121,47 @@ function crp_options() {
117
  $crp_thumb_size = crp_get_all_image_sizes( $crp_settings['thumb_size'] );
118
 
119
  $crp_settings['thumb_height'] = absint( $crp_thumb_size['height'] );
120
- $crp_settings['thumb_width'] = absint( $crp_thumb_size['width'] );
121
- $crp_settings['thumb_crop'] = $crp_thumb_size['crop'];
122
  } else {
123
  $crp_settings['thumb_height'] = absint( $_POST['thumb_height'] );
124
- $crp_settings['thumb_width'] = absint( $_POST['thumb_width'] );
125
- $crp_settings['thumb_crop'] = ( isset( $_POST['thumb_crop'] ) ? true : false );
126
  }
127
 
128
  $crp_settings['thumb_html'] = sanitize_text_field( wp_unslash( $_POST['thumb_html'] ) );
129
 
130
- $crp_settings['thumb_meta'] = empty( $_POST['thumb_meta'] ) ? 'post-image' : sanitize_text_field( wp_unslash( $_POST['thumb_meta'] ) );
131
- $crp_settings['scan_images'] = ( isset( $_POST['scan_images'] ) ? true : false );
132
- $crp_settings['thumb_default'] = ( ( '' === esc_url_raw( $_POST['thumb_default'] ) ) || ( '/default.png' === esc_url_raw( $_POST['thumb_default'] ) ) ) ? CRP_PLUGIN_URL . '/default.png' : esc_url_raw( $_POST['thumb_default'] );
133
  $crp_settings['thumb_default_show'] = ( isset( $_POST['thumb_default_show'] ) ? true : false );
134
 
135
- /**** Feed options ****/
136
- $crp_settings['limit_feed'] = absint( $_POST['limit_feed'] );
137
  $crp_settings['post_thumb_op_feed'] = sanitize_text_field( wp_unslash( $_POST['post_thumb_op_feed'] ) );
138
- $crp_settings['thumb_height_feed'] = absint( $_POST['thumb_height_feed'] );
139
- $crp_settings['thumb_width_feed'] = absint( $_POST['thumb_width_feed'] );
140
- $crp_settings['show_excerpt_feed'] = ( isset( $_POST['show_excerpt_feed'] ) ? true : false );
141
 
142
- /**** Styles ****/
143
  $crp_settings['custom_CSS'] = wp_kses_post( wp_unslash( $_POST['custom_CSS'] ) );
144
 
145
  $crp_settings['crp_styles'] = sanitize_text_field( wp_unslash( $_POST['crp_styles'] ) );
146
 
147
  if ( 'rounded_thumbs' === $crp_settings['crp_styles'] ) {
148
  $crp_settings['include_default_style'] = true;
149
- $crp_settings['post_thumb_op'] = 'inline';
150
- $crp_settings['show_excerpt'] = false;
151
- $crp_settings['show_author'] = false;
152
- $crp_settings['show_date'] = false;
153
  } elseif ( 'text_only' === $crp_settings['crp_styles'] ) {
154
  $crp_settings['include_default_style'] = false;
155
- $crp_settings['post_thumb_op'] = 'text_only';
156
  } else {
157
  $crp_settings['include_default_style'] = false;
158
  }
159
 
160
- /**** Exclude categories ****/
161
  $exclude_categories_slugs = array_map( 'trim', explode( ',', sanitize_text_field( wp_unslash( $_POST['exclude_cat_slugs'] ) ) ) );
162
 
163
  foreach ( $exclude_categories_slugs as $exclude_categories_slug ) {
@@ -169,38 +173,40 @@ function crp_options() {
169
  }
170
  if ( isset( $category_obj->term_taxonomy_id ) ) {
171
  $exclude_categories[] = $category_obj->term_taxonomy_id;
172
- $exclude_cat_slugs[] = $category_obj->name;
173
  }
174
  }
175
  $crp_settings['exclude_categories'] = isset( $exclude_categories ) ? join( ',', $exclude_categories ) : '';
176
- $crp_settings['exclude_cat_slugs'] = isset( $exclude_cat_slugs ) ? join( ',', $exclude_cat_slugs ) : '';
177
 
178
- /**** Post types to include ****/
179
- $wp_post_types = get_post_types( array(
180
- 'public' => true,
181
- ) );
182
- $post_types_arr = ( isset( $_POST['post_types'] ) && is_array( $_POST['post_types'] ) ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['post_types'] ) ) : array(
 
 
183
  'post' => 'post',
184
  );
185
- $post_types = array_intersect( $wp_post_types, $post_types_arr );
186
  $crp_settings['post_types'] = implode( ',', $post_types );
187
 
188
- /**** Post types to exclude display on ****/
189
- $post_types_excl_arr = ( isset( $_POST['exclude_on_post_types'] ) && is_array( $_POST['exclude_on_post_types'] ) ) ? $_POST['exclude_on_post_types'] : array();
190
- $exclude_on_post_types = array_intersect( $wp_post_types, $post_types_excl_arr );
191
  $crp_settings['exclude_on_post_types'] = implode( ',', $exclude_on_post_types );
192
 
193
  /**
194
  * Filters $crp_settings before it is saved into the database
195
  *
196
- * @since 2.0.0
197
  *
198
- * @param array $crp_settings CRP settings
199
- * @param array $_POST POST array that consists of the saved settings
200
  */
201
  $crp_settings = apply_filters( 'crp_save_options', $crp_settings, $_POST );
202
 
203
- /**** Update CRP options into the database ****/
204
  update_option( 'ald_crp_settings', $crp_settings );
205
  $crp_settings = crp_read_options();
206
 
@@ -208,14 +214,14 @@ function crp_options() {
208
  if ( ! empty( $crp_settings['post_types'] ) && false === strpos( $crp_settings['post_types'], '=' ) ) {
209
  $post_types = explode( ',', $crp_settings['post_types'] );
210
  } else {
211
- parse_str( $crp_settings['post_types'], $post_types ); // Save post types in $post_types variable.
212
  }
213
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
214
 
215
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
216
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
217
  } else {
218
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
219
  }
220
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
221
 
@@ -248,21 +254,23 @@ function crp_options() {
248
 
249
  $crp_settings = crp_read_options();
250
 
251
- $wp_post_types = get_post_types( array(
252
- 'public' => true,
253
- ) );
 
 
254
  // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
255
  if ( ! empty( $crp_settings['post_types'] ) && false === strpos( $crp_settings['post_types'], '=' ) ) {
256
  $post_types = explode( ',', $crp_settings['post_types'] );
257
  } else {
258
- parse_str( $crp_settings['post_types'], $post_types ); // Save post types in $post_types variable.
259
  }
260
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
261
 
262
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
263
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
264
  } else {
265
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
266
  }
267
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
268
 
@@ -279,8 +287,8 @@ function crp_options() {
279
  echo $str; // WPCS: XSS ok.
280
  }
281
 
282
- /**** Include the views page ****/
283
- include_once( 'main-view.php' );
284
  }
285
 
286
 
@@ -317,7 +325,7 @@ function crp_adminhead() {
317
 
318
  add_thickbox();
319
 
320
- ?>
321
  <style type="text/css">
322
  .postbox .handlediv:before {
323
  right:12px;
@@ -374,6 +382,6 @@ function crp_adminhead() {
374
 
375
  //]]>
376
  </script>
377
- <?php
378
  }
379
 
5
  * This page is accessible via Settings > Contextual Related Posts
6
  *
7
  * @package Contextual_Related_Posts
8
+ * @author Ajay D'Souza
9
  * @license GPL-2.0+
10
  * @link https://webberzone.com
11
+ * @copyright 2009-2018 Ajay D'Souza
12
  */
13
 
14
  /**** If this file is called directly, abort. ****/
20
  /**
21
  * Function generates the plugin settings page.
22
  *
23
+ * @since 1.0.1
24
  */
25
  function crp_options() {
26
 
28
 
29
  $crp_settings = crp_read_options();
30
 
31
+ $wp_post_types = get_post_types(
32
+ array(
33
+ 'public' => true,
34
+ )
35
+ );
36
 
37
  // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
38
  if ( ! empty( $crp_settings['post_types'] ) && false === strpos( $crp_settings['post_types'], '=' ) ) {
39
  $post_types = explode( ',', $crp_settings['post_types'] );
40
  } else {
41
+ parse_str( $crp_settings['post_types'], $post_types ); // Save post types in $post_types variable.
42
  }
43
 
44
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
47
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
48
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
49
  } else {
50
+ parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
51
  }
52
 
53
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
65
 
66
  if ( ( isset( $_POST['crp_save'] ) ) && ( check_admin_referer( 'crp-plugin-settings' ) ) ) { // Input var okay.
67
 
68
+ /**** General options */
69
+ $crp_settings['cache'] = isset( $_POST['cache'] ) ? true : false;
70
+ $crp_settings['limit'] = absint( $_POST['limit'] );
71
+ $crp_settings['daily_range'] = absint( $_POST['daily_range'] );
72
+ $crp_settings['random_order'] = isset( $_POST['random_order'] ) ? true : false;
73
+ $crp_settings['match_content'] = isset( $_POST['match_content'] ) ? true : false;
74
  $crp_settings['match_content_words'] = min( CRP_MAX_WORDS, absint( $_POST['match_content_words'] ) );
75
+ $crp_settings['same_post_type'] = isset( $_POST['same_post_type'] ) ? true : false;
76
 
77
+ $crp_settings['add_to_content'] = ( isset( $_POST['add_to_content'] ) ? true : false );
78
+ $crp_settings['add_to_page'] = ( isset( $_POST['add_to_page'] ) ? true : false );
79
+ $crp_settings['add_to_feed'] = ( isset( $_POST['add_to_feed'] ) ? true : false );
80
+ $crp_settings['add_to_home'] = ( isset( $_POST['add_to_home'] ) ? true : false );
81
  $crp_settings['add_to_category_archives'] = ( isset( $_POST['add_to_category_archives'] ) ? true : false );
82
+ $crp_settings['add_to_tag_archives'] = ( isset( $_POST['add_to_tag_archives'] ) ? true : false );
83
+ $crp_settings['add_to_archives'] = ( isset( $_POST['add_to_archives'] ) ? true : false );
84
 
85
  $crp_settings['content_filter_priority'] = absint( $_POST['content_filter_priority'] );
86
+ $crp_settings['insert_after_paragraph'] = ( -1 === $_POST['insert_after_paragraph'] || '' === $_POST['insert_after_paragraph'] ) ? -1 : intval( $_POST['insert_after_paragraph'] );
87
+ $crp_settings['disable_on_mobile'] = ( isset( $_POST['disable_on_mobile'] ) ? true : false );
88
+ $crp_settings['disable_on_amp'] = ( isset( $_POST['disable_on_amp'] ) ? true : false );
89
+ $crp_settings['show_metabox'] = ( isset( $_POST['show_metabox'] ) ? true : false );
90
+ $crp_settings['show_metabox_admins'] = ( isset( $_POST['show_metabox_admins'] ) ? true : false );
91
+ $crp_settings['show_credit'] = ( isset( $_POST['show_credit'] ) ? true : false );
92
+
93
+ /**** Output options */
94
+ $crp_settings['title'] = wp_kses_post( wp_unslash( $_POST['title'] ) );
95
+ $crp_settings['blank_output'] = 'blank' === $_POST['blank_output'] ? true : false;
96
  $crp_settings['blank_output_text'] = wp_kses_post( wp_unslash( $_POST['blank_output_text'] ) );
97
 
98
+ $crp_settings['show_excerpt'] = ( isset( $_POST['show_excerpt'] ) ? true : false );
99
+ $crp_settings['show_date'] = ( isset( $_POST['show_date'] ) ? true : false );
100
+ $crp_settings['show_author'] = ( isset( $_POST['show_author'] ) ? true : false );
101
  $crp_settings['excerpt_length'] = absint( $_POST['excerpt_length'] );
102
+ $crp_settings['title_length'] = absint( $_POST['title_length'] );
103
 
104
  $crp_settings['link_new_window'] = ( isset( $_POST['link_new_window'] ) ? true : false );
105
+ $crp_settings['link_nofollow'] = ( isset( $_POST['link_nofollow'] ) ? true : false );
106
 
107
+ $crp_settings['before_list'] = wp_kses_post( wp_unslash( $_POST['before_list'] ) );
108
+ $crp_settings['after_list'] = wp_kses_post( wp_unslash( $_POST['after_list'] ) );
109
  $crp_settings['before_list_item'] = wp_kses_post( wp_unslash( $_POST['before_list_item'] ) );
110
+ $crp_settings['after_list_item'] = wp_kses_post( wp_unslash( $_POST['after_list_item'] ) );
111
 
112
  $crp_settings['exclude_on_post_ids'] = empty( $_POST['exclude_on_post_ids'] ) ? '' : implode( ',', array_map( 'absint', explode( ',', sanitize_text_field( wp_unslash( $_POST['exclude_on_post_ids'] ) ) ) ) );
113
+ $crp_settings['exclude_post_ids'] = empty( $_POST['exclude_post_ids'] ) ? '' : implode( ',', array_map( 'absint', explode( ',', sanitize_text_field( wp_unslash( $_POST['exclude_post_ids'] ) ) ) ) );
114
 
115
+ /**** Thumbnail options */
116
  $crp_settings['post_thumb_op'] = sanitize_text_field( wp_unslash( $_POST['post_thumb_op'] ) );
117
 
118
  $crp_settings['thumb_size'] = sanitize_text_field( wp_unslash( $_POST['thumb_size'] ) );
121
  $crp_thumb_size = crp_get_all_image_sizes( $crp_settings['thumb_size'] );
122
 
123
  $crp_settings['thumb_height'] = absint( $crp_thumb_size['height'] );
124
+ $crp_settings['thumb_width'] = absint( $crp_thumb_size['width'] );
125
+ $crp_settings['thumb_crop'] = $crp_thumb_size['crop'];
126
  } else {
127
  $crp_settings['thumb_height'] = absint( $_POST['thumb_height'] );
128
+ $crp_settings['thumb_width'] = absint( $_POST['thumb_width'] );
129
+ $crp_settings['thumb_crop'] = ( isset( $_POST['thumb_crop'] ) ? true : false );
130
  }
131
 
132
  $crp_settings['thumb_html'] = sanitize_text_field( wp_unslash( $_POST['thumb_html'] ) );
133
 
134
+ $crp_settings['thumb_meta'] = empty( $_POST['thumb_meta'] ) ? 'post-image' : sanitize_text_field( wp_unslash( $_POST['thumb_meta'] ) );
135
+ $crp_settings['scan_images'] = ( isset( $_POST['scan_images'] ) ? true : false );
136
+ $crp_settings['thumb_default'] = ( ( '' === esc_url_raw( $_POST['thumb_default'] ) ) || ( '/default.png' === esc_url_raw( $_POST['thumb_default'] ) ) ) ? CRP_PLUGIN_URL . '/default.png' : esc_url_raw( $_POST['thumb_default'] );
137
  $crp_settings['thumb_default_show'] = ( isset( $_POST['thumb_default_show'] ) ? true : false );
138
 
139
+ /**** Feed options */
140
+ $crp_settings['limit_feed'] = absint( $_POST['limit_feed'] );
141
  $crp_settings['post_thumb_op_feed'] = sanitize_text_field( wp_unslash( $_POST['post_thumb_op_feed'] ) );
142
+ $crp_settings['thumb_height_feed'] = absint( $_POST['thumb_height_feed'] );
143
+ $crp_settings['thumb_width_feed'] = absint( $_POST['thumb_width_feed'] );
144
+ $crp_settings['show_excerpt_feed'] = ( isset( $_POST['show_excerpt_feed'] ) ? true : false );
145
 
146
+ /**** Styles */
147
  $crp_settings['custom_CSS'] = wp_kses_post( wp_unslash( $_POST['custom_CSS'] ) );
148
 
149
  $crp_settings['crp_styles'] = sanitize_text_field( wp_unslash( $_POST['crp_styles'] ) );
150
 
151
  if ( 'rounded_thumbs' === $crp_settings['crp_styles'] ) {
152
  $crp_settings['include_default_style'] = true;
153
+ $crp_settings['post_thumb_op'] = 'inline';
154
+ $crp_settings['show_excerpt'] = false;
155
+ $crp_settings['show_author'] = false;
156
+ $crp_settings['show_date'] = false;
157
  } elseif ( 'text_only' === $crp_settings['crp_styles'] ) {
158
  $crp_settings['include_default_style'] = false;
159
+ $crp_settings['post_thumb_op'] = 'text_only';
160
  } else {
161
  $crp_settings['include_default_style'] = false;
162
  }
163
 
164
+ /**** Exclude categories */
165
  $exclude_categories_slugs = array_map( 'trim', explode( ',', sanitize_text_field( wp_unslash( $_POST['exclude_cat_slugs'] ) ) ) );
166
 
167
  foreach ( $exclude_categories_slugs as $exclude_categories_slug ) {
173
  }
174
  if ( isset( $category_obj->term_taxonomy_id ) ) {
175
  $exclude_categories[] = $category_obj->term_taxonomy_id;
176
+ $exclude_cat_slugs[] = $category_obj->name;
177
  }
178
  }
179
  $crp_settings['exclude_categories'] = isset( $exclude_categories ) ? join( ',', $exclude_categories ) : '';
180
+ $crp_settings['exclude_cat_slugs'] = isset( $exclude_cat_slugs ) ? join( ',', $exclude_cat_slugs ) : '';
181
 
182
+ /**** Post types to include */
183
+ $wp_post_types = get_post_types(
184
+ array(
185
+ 'public' => true,
186
+ )
187
+ );
188
+ $post_types_arr = ( isset( $_POST['post_types'] ) && is_array( $_POST['post_types'] ) ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['post_types'] ) ) : array(
189
  'post' => 'post',
190
  );
191
+ $post_types = array_intersect( $wp_post_types, $post_types_arr );
192
  $crp_settings['post_types'] = implode( ',', $post_types );
193
 
194
+ /**** Post types to exclude display on */
195
+ $post_types_excl_arr = ( isset( $_POST['exclude_on_post_types'] ) && is_array( $_POST['exclude_on_post_types'] ) ) ? $_POST['exclude_on_post_types'] : array();
196
+ $exclude_on_post_types = array_intersect( $wp_post_types, $post_types_excl_arr );
197
  $crp_settings['exclude_on_post_types'] = implode( ',', $exclude_on_post_types );
198
 
199
  /**
200
  * Filters $crp_settings before it is saved into the database
201
  *
202
+ * @since 2.0.0
203
  *
204
+ * @param array $crp_settings CRP settings
205
+ * @param array $_POST POST array that consists of the saved settings
206
  */
207
  $crp_settings = apply_filters( 'crp_save_options', $crp_settings, $_POST );
208
 
209
+ /**** Update CRP options into the database */
210
  update_option( 'ald_crp_settings', $crp_settings );
211
  $crp_settings = crp_read_options();
212
 
214
  if ( ! empty( $crp_settings['post_types'] ) && false === strpos( $crp_settings['post_types'], '=' ) ) {
215
  $post_types = explode( ',', $crp_settings['post_types'] );
216
  } else {
217
+ parse_str( $crp_settings['post_types'], $post_types ); // Save post types in $post_types variable.
218
  }
219
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
220
 
221
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
222
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
223
  } else {
224
+ parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
225
  }
226
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
227
 
254
 
255
  $crp_settings = crp_read_options();
256
 
257
+ $wp_post_types = get_post_types(
258
+ array(
259
+ 'public' => true,
260
+ )
261
+ );
262
  // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
263
  if ( ! empty( $crp_settings['post_types'] ) && false === strpos( $crp_settings['post_types'], '=' ) ) {
264
  $post_types = explode( ',', $crp_settings['post_types'] );
265
  } else {
266
+ parse_str( $crp_settings['post_types'], $post_types ); // Save post types in $post_types variable.
267
  }
268
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
269
 
270
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
271
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
272
  } else {
273
+ parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
274
  }
275
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
276
 
287
  echo $str; // WPCS: XSS ok.
288
  }
289
 
290
+ /**** Include the views page */
291
+ include_once 'main-view.php';
292
  }
293
 
294
 
325
 
326
  add_thickbox();
327
 
328
+ ?>
329
  <style type="text/css">
330
  .postbox .handlediv:before {
331
  right:12px;
382
 
383
  //]]>
384
  </script>
385
+ <?php
386
  }
387
 
admin/cache.php CHANGED
@@ -3,30 +3,35 @@
3
  * Contextual Related Posts Cache interface.
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  /**
13
  * Function to clear the CRP Cache with Ajax.
14
  *
15
- * @since 1.8.10
16
  */
17
  function crp_ajax_clearcache() {
18
 
19
  global $wpdb;
20
 
21
  $meta_keys = crp_cache_get_keys();
22
- $error = false;
23
 
24
  foreach ( $meta_keys as $meta_key ) {
25
 
26
- $count = $wpdb->query( $wpdb->prepare( "
 
 
27
  DELETE FROM {$wpdb->postmeta}
28
  WHERE meta_key = %s
29
- ", $meta_key ) );
 
 
 
30
 
31
  if ( false === $count ) {
32
  $error = true;
@@ -35,19 +40,111 @@ function crp_ajax_clearcache() {
35
  }
36
  }
37
 
38
- /**** Did an error occur? ****/
39
  if ( $error ) {
40
- exit( wp_json_encode( array(
41
- 'success' => 0,
42
- 'message' => __( 'An error occurred clearing the cache. Please contact your site administrator.\n\nError message:\n', 'contextual-related-posts' ) . $wpdb->print_error(),
43
- ) ) );
44
- } else { // No error, return the number of.
45
- exit( wp_json_encode( array(
46
- 'success' => 1,
47
- 'message' => ( array_sum( $counter ) ) . __( ' cached row(s) cleared', 'contextual-related-posts' ),
48
- ) ) );
 
 
 
 
 
 
 
 
49
  }
50
  }
51
  add_action( 'wp_ajax_crp_clear_cache', 'crp_ajax_clearcache' );
52
 
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  * Contextual Related Posts Cache interface.
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  /**
13
  * Function to clear the CRP Cache with Ajax.
14
  *
15
+ * @since 1.8.10
16
  */
17
  function crp_ajax_clearcache() {
18
 
19
  global $wpdb;
20
 
21
  $meta_keys = crp_cache_get_keys();
22
+ $error = false;
23
 
24
  foreach ( $meta_keys as $meta_key ) {
25
 
26
+ $count = $wpdb->query(
27
+ $wpdb->prepare(
28
+ "
29
  DELETE FROM {$wpdb->postmeta}
30
  WHERE meta_key = %s
31
+ ",
32
+ $meta_key
33
+ )
34
+ );
35
 
36
  if ( false === $count ) {
37
  $error = true;
40
  }
41
  }
42
 
43
+ /**** Did an error occur? */
44
  if ( $error ) {
45
+ exit(
46
+ wp_json_encode(
47
+ array(
48
+ 'success' => 0,
49
+ 'message' => __( 'An error occurred clearing the cache. Please contact your site administrator.\n\nError message:\n', 'contextual-related-posts' ) . $wpdb->print_error(),
50
+ )
51
+ )
52
+ );
53
+ } else { // No error, return the number of.
54
+ exit(
55
+ wp_json_encode(
56
+ array(
57
+ 'success' => 1,
58
+ 'message' => ( array_sum( $counter ) ) . __( ' cached row(s) cleared', 'contextual-related-posts' ),
59
+ )
60
+ )
61
+ );
62
  }
63
  }
64
  add_action( 'wp_ajax_crp_clear_cache', 'crp_ajax_clearcache' );
65
 
66
 
67
+ /**
68
+ * Delete the CRP cache.
69
+ *
70
+ * @since 2.2.0
71
+ *
72
+ * @param array $meta_keys Array of meta keys that hold the cache.
73
+ */
74
+ function crp_cache_delete( $meta_keys = array() ) {
75
+
76
+ $default_meta_keys = crp_cache_get_keys();
77
+
78
+ if ( ! empty( $meta_keys ) ) {
79
+ $meta_keys = array_intersect( $default_meta_keys, (array) $meta_keys );
80
+ } else {
81
+ $meta_keys = $default_meta_keys;
82
+ }
83
+
84
+ foreach ( $meta_keys as $meta_key ) {
85
+ delete_post_meta_by_key( $meta_key );
86
+ }
87
+ }
88
+
89
+
90
+ /**
91
+ * Get the default meta keys used for the cache
92
+ *
93
+ * @since 2.2.0
94
+ */
95
+ function crp_cache_get_keys() {
96
+
97
+ $meta_keys = array(
98
+ 'crp_related_posts',
99
+ 'crp_related_posts_widget',
100
+ 'crp_related_posts_feed',
101
+ 'crp_related_posts_widget_feed',
102
+ 'crp_related_posts_manual',
103
+ );
104
+
105
+ /**
106
+ * Filters the array containing the various cache keys.
107
+ *
108
+ * @since 1.9
109
+ *
110
+ * @param array $default_meta_keys Array of meta keys
111
+ */
112
+ return apply_filters( 'crp_cache_keys', $meta_keys );
113
+ }
114
+
115
+
116
+ /**
117
+ * Function to clear cache on post save.
118
+ *
119
+ * @since 2.5.0
120
+ *
121
+ * @param mixed $post_id Post ID.
122
+ */
123
+ function crp_delete_cache_post_save( $post_id ) {
124
+ global $crp_settings;
125
+
126
+ // Bail if we're doing an auto save.
127
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
128
+ return;
129
+ }
130
+
131
+ // If our nonce isn't there, or we can't verify it, bail.
132
+ if ( ! isset( $_POST['crp_meta_box_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['crp_meta_box_nonce'] ), 'crp_meta_box' ) ) { // Input var okay.
133
+ return;
134
+ }
135
+
136
+ // If our current user can't edit this post, bail.
137
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
138
+ return;
139
+ }
140
+
141
+ // Clear cache of current post.
142
+ $default_meta_keys = crp_cache_get_keys();
143
+ foreach ( $default_meta_keys as $meta_key ) {
144
+ delete_post_meta( $post_id, $meta_key );
145
+ }
146
+
147
+ }
148
+ add_action( 'save_post', 'crp_delete_cache_post_save' );
149
+ add_action( 'edit_attachment', 'crp_delete_cache_post_save' );
150
+
admin/loader.php CHANGED
@@ -3,25 +3,28 @@
3
  * Contextual Related Posts Admin Loader.
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  /**
13
  * Add link to WordPress plugin action links.
14
  *
15
- * @version 1.8.10
16
  *
17
  * @param array $links Links array.
18
  * @return array Links array with our settings link added
19
  */
20
  function crp_plugin_actions_links( $links ) {
21
 
22
- return array_merge( array(
23
- 'settings' => '<a href="' . admin_url( 'options-general.php?page=crp_options' ) . '">' . esc_html__( 'Settings', 'contextual-related-posts' ) . '</a>',
24
- ), $links );
 
 
 
25
 
26
  }
27
  add_filter( 'plugin_action_links_' . plugin_basename( CRP_PLUGIN_FILE ), 'crp_plugin_actions_links' );
3
  * Contextual Related Posts Admin Loader.
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  /**
13
  * Add link to WordPress plugin action links.
14
  *
15
+ * @version 1.8.10
16
  *
17
  * @param array $links Links array.
18
  * @return array Links array with our settings link added
19
  */
20
  function crp_plugin_actions_links( $links ) {
21
 
22
+ return array_merge(
23
+ array(
24
+ 'settings' => '<a href="' . admin_url( 'options-general.php?page=crp_options' ) . '">' . esc_html__( 'Settings', 'contextual-related-posts' ) . '</a>',
25
+ ),
26
+ $links
27
+ );
28
 
29
  }
30
  add_filter( 'plugin_action_links_' . plugin_basename( CRP_PLUGIN_FILE ), 'crp_plugin_actions_links' );
admin/main-view.php CHANGED
@@ -3,10 +3,10 @@
3
  * Represents the view for the administration dashboard.
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -29,12 +29,12 @@ if ( ! defined( 'WPINC' ) ) {
29
  do_action( 'crp_admin_nav_bar_before' )
30
  ?>
31
 
32
- <li><a href="#genopdiv"><?php esc_html_e( 'General options', 'contextual-related-posts' ); ?></a> | </li>
33
- <li><a href="#tuneopdiv"><?php esc_html_e( 'List tuning options', 'contextual-related-posts' ); ?></a> | </li>
34
- <li><a href="#outputopdiv"><?php esc_html_e( 'Output options', 'contextual-related-posts' ); ?></a> | </li>
35
- <li><a href="#thumbopdiv"><?php esc_html_e( 'Thumbnail options', 'contextual-related-posts' ); ?></a> | </li>
36
- <li><a href="#customcssdiv"><?php esc_html_e( 'Styles', 'contextual-related-posts' ); ?></a> | </li>
37
- <li><a href="#feedopdiv"><?php esc_html_e( 'Feed options', 'contextual-related-posts' ); ?></a></li>
38
 
39
  <?php
40
  /**
@@ -51,9 +51,9 @@ if ( ! defined( 'WPINC' ) ) {
51
  <div id="post-body-content">
52
  <form method="post" id="crp_options" name="crp_options" onsubmit="return checkForm()">
53
 
54
- <div id="genopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
55
- <h3 class='hndle'><span><?php esc_html_e( 'General options', 'contextual-related-posts' ); ?></span></h3>
56
- <div class="inside">
57
 
58
  <table class="form-table">
59
 
@@ -63,7 +63,7 @@ if ( ! defined( 'WPINC' ) ) {
63
  *
64
  * @since 2.0.0
65
  *
66
- * @param array $crp_settings Contextual Related Posts settings array
67
  */
68
  do_action( 'crp_admin_general_options_before', $crp_settings );
69
  ?>
@@ -72,7 +72,7 @@ if ( ! defined( 'WPINC' ) ) {
72
  <td><input type="checkbox" name="cache" id="cache" <?php checked( true, $crp_settings['cache'] ); ?> />
73
  <p class="description"><?php esc_html_e( 'Enabling this option will cache the related posts output when the post is visited the first time. The cache is cleaned when you save this page.', 'contextual-related-posts' ); ?></p>
74
  <p class="description"><?php esc_html_e( 'The CRP cache works independently and in addition to any of your caching plugins like WP Super Cache or W3 Total Cache. It is recommended that you enable this on your blog.', 'contextual-related-posts' ); ?></p>
75
- <p><input type="button" value="<?php esc_html_e( 'Clear cache', 'contextual-related-posts' ) ?>" onclick="return clearCache();" class="button-secondary" /></p>
76
  </td>
77
  </tr>
78
 
@@ -104,6 +104,20 @@ if ( ! defined( 'WPINC' ) ) {
104
  </td>
105
  </tr>
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  <tr><th scope="row"><label for="show_metabox"><?php esc_html_e( 'Show metabox:', 'contextual-related-posts' ); ?></label></th>
108
  <td>
109
  <input type="checkbox" name="show_metabox" id="show_metabox" <?php checked( true, $crp_settings['show_metabox'] ); ?> />
@@ -131,7 +145,7 @@ if ( ! defined( 'WPINC' ) ) {
131
  *
132
  * @since 2.0.0
133
  *
134
- * @param array $crp_settings Contextual Related Posts settings array
135
  */
136
  do_action( 'crp_admin_general_options_after', $crp_settings );
137
  ?>
@@ -142,12 +156,12 @@ if ( ! defined( 'WPINC' ) ) {
142
  <input type="submit" name="crp_save" id="crp_genop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
143
  </p>
144
 
145
- </div> <!-- // inside -->
146
- </div> <!-- // genopdiv -->
147
 
148
- <div id="tuneopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
149
- <h3 class='hndle'><span><?php esc_html_e( 'List tuning options', 'contextual-related-posts' ); ?></span></h3>
150
- <div class="inside">
151
 
152
  <table class="form-table">
153
 
@@ -157,7 +171,7 @@ if ( ! defined( 'WPINC' ) ) {
157
  *
158
  * @since 2.1.0
159
  *
160
- * @param array $crp_settings Contextual Related Posts settings array
161
  */
162
  do_action( 'crp_admin_tuning_options_before', $crp_settings );
163
  ?>
@@ -241,7 +255,7 @@ if ( ! defined( 'WPINC' ) ) {
241
  *
242
  * @since 2.1.0
243
  *
244
- * @param array $crp_settings Contextual Related Posts settings array
245
  */
246
  do_action( 'crp_admin_tuning_options_after', $crp_settings );
247
  ?>
@@ -252,12 +266,12 @@ if ( ! defined( 'WPINC' ) ) {
252
  <input type="submit" name="crp_save" id="crp_tuneop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
253
  </p>
254
 
255
- </div> <!-- // inside -->
256
- </div> <!-- // tuneopdiv -->
257
 
258
- <div id="outputopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
259
- <h3 class='hndle'><span><?php esc_html_e( 'Output options', 'contextual-related-posts' ); ?></span></h3>
260
- <div class="inside">
261
 
262
  <table class="form-table">
263
 
@@ -267,7 +281,7 @@ if ( ! defined( 'WPINC' ) ) {
267
  *
268
  * @since 2.0.0
269
  *
270
- * @param array $crp_settings Contextual Related Posts settings array
271
  */
272
  do_action( 'crp_admin_output_options_before', $crp_settings );
273
  ?>
@@ -297,7 +311,7 @@ if ( ! defined( 'WPINC' ) ) {
297
  <tr><th scope="row"><label for="show_excerpt"><?php esc_html_e( 'Show post excerpt in list?', 'contextual-related-posts' ); ?></label></th>
298
  <td>
299
  <input type="checkbox" name="show_excerpt" id="show_excerpt" <?php checked( true, $crp_settings['show_excerpt'] ); ?> />
300
- <p class="description"><?php printf( esc_html__( "Displays the excerpt of the post. If you do not provide an explicit excerpt to a post (in the post editor's optional excerpt field), it will display an automatic excerpt which refers to the first %d words of the post's content", 'contextual-related-posts' ), esc_html_e( $crp_settings['excerpt_length'] ) ); ?></p>
301
 
302
  <?php if ( 'rounded_thumbs' === $crp_settings['crp_styles'] ) { ?>
303
  <p style="color: #F00"><?php esc_html_e( 'Rounded Thumbnails style selected under the Custom Styles. Excerpt display is disabled.', 'contextual-related-posts' ); ?></p>
@@ -358,7 +372,7 @@ if ( ! defined( 'WPINC' ) ) {
358
  *
359
  * @since 2.0.0
360
  *
361
- * @param array $crp_settings Contextual Related Posts settings array
362
  */
363
  do_action( 'crp_admin_output_options_after', $crp_settings );
364
  ?>
@@ -373,7 +387,7 @@ if ( ! defined( 'WPINC' ) ) {
373
  *
374
  * @since 2.0.0
375
  *
376
- * @param array $crp_settings Contextual Related Posts settings array
377
  */
378
  do_action( 'crp_admin_exclusion_options_before', $crp_settings );
379
  ?>
@@ -404,7 +418,7 @@ if ( ! defined( 'WPINC' ) ) {
404
  *
405
  * @since 2.0.0
406
  *
407
- * @param array $crp_settings Contextual Related Posts settings array
408
  */
409
  do_action( 'crp_admin_exclusion_options_after', $crp_settings );
410
  ?>
@@ -419,7 +433,7 @@ if ( ! defined( 'WPINC' ) ) {
419
  *
420
  * @since 2.0.0
421
  *
422
- * @param array $crp_settings Contextual Related Posts settings array
423
  */
424
  do_action( 'crp_admin_customize_options_before', $crp_settings );
425
  ?>
@@ -445,7 +459,7 @@ if ( ! defined( 'WPINC' ) ) {
445
  *
446
  * @since 2.0.0
447
  *
448
- * @param array $crp_settings Contextual Related Posts settings array
449
  */
450
  do_action( 'crp_admin_customize_options_after', $crp_settings );
451
  ?>
@@ -456,12 +470,12 @@ if ( ! defined( 'WPINC' ) ) {
456
  <input type="submit" name="crp_save" id="crp_outputop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
457
  </p>
458
 
459
- </div> <!-- // inside -->
460
- </div> <!-- // outputopdiv -->
461
 
462
- <div id="thumbopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
463
- <h3 class='hndle'><span><?php esc_html_e( 'Thumbnail options', 'contextual-related-posts' ); ?></span></h3>
464
- <div class="inside">
465
 
466
  <table class="form-table">
467
 
@@ -471,7 +485,7 @@ if ( ! defined( 'WPINC' ) ) {
471
  *
472
  * @since 2.0.0
473
  *
474
- * @param array $crp_settings Contextual Related Posts settings array
475
  */
476
  do_action( 'crp_admin_thumb_options_before', $crp_settings );
477
  ?>
@@ -479,22 +493,22 @@ if ( ! defined( 'WPINC' ) ) {
479
  <tr><th scope="row"><label for="post_thumb_op"><?php esc_html_e( 'Location of post thumbnail:', 'contextual-related-posts' ); ?></label></th>
480
  <td>
481
  <label>
482
- <input type="radio" name="post_thumb_op" value="inline" id="post_thumb_op_0" <?php checked( 'inline', $crp_settings['post_thumb_op'], true ); ?> />
483
  <?php esc_html_e( 'Display thumbnails inline with posts, before title', 'contextual-related-posts' ); ?>
484
  </label>
485
  <br />
486
  <label>
487
- <input type="radio" name="post_thumb_op" value="after" id="post_thumb_op_1" <?php checked( 'after', $crp_settings['post_thumb_op'], true ); ?> />
488
  <?php esc_html_e( 'Display thumbnails inline with posts, after title', 'contextual-related-posts' ); ?>
489
  </label>
490
  <br />
491
  <label>
492
- <input type="radio" name="post_thumb_op" value="thumbs_only" id="post_thumb_op_2" <?php checked( 'thumbs_only', $crp_settings['post_thumb_op'], true ); ?> />
493
  <?php esc_html_e( 'Display only thumbnails, no text', 'contextual-related-posts' ); ?>
494
  </label>
495
  <br />
496
  <label>
497
- <input type="radio" name="post_thumb_op" value="text_only" id="post_thumb_op_3" <?php checked( 'text_only', $crp_settings['post_thumb_op'], true ); ?> />
498
  <?php esc_html_e( 'Do not display thumbnails, only text.', 'contextual-related-posts' ); ?>
499
  </label>
500
 
@@ -513,15 +527,15 @@ if ( ! defined( 'WPINC' ) ) {
513
  }
514
 
515
  foreach ( $crp_get_all_image_sizes as $size ) :
516
- ?>
517
  <label>
518
- <input type="radio" name="thumb_size" value="<?php esc_attr_e( $size['name'] ) ?>" id="<?php esc_attr_e( $size['name'] ) ?>" <?php checked( $crp_settings['thumb_size'], $size['name'] ); ?> />
519
  <?php esc_html_e( $size['name'] ); ?> ( <?php esc_html_e( $size['width'] ); ?>x<?php esc_html_e( $size['height'] ); ?>
520
  <?php
521
  if ( $size['crop'] ) {
522
  echo 'cropped';
523
  }
524
- ?>
525
  )
526
  </label>
527
  <br />
@@ -535,11 +549,13 @@ if ( ! defined( 'WPINC' ) ) {
535
  <?php esc_html_e( 'If you choose an existing size, then the width, height and crop mode settings in the three options below will be automatically updated to reflect the correct dimensions of the setting.', 'contextual-related-posts' ); ?><br />
536
  <?php esc_html_e( 'If you have chosen Custom size above, then enter the width, height and crop settings below. For best results, use a cropped image with the same width and height. The default setting is 150x150 cropped image.', 'contextual-related-posts' ); ?><br /><br />
537
  <?php esc_html_e( "Any changes to the thumbnail settings doesn't automatically resize existing images.", 'contextual-related-posts' ); ?>
538
- <?php printf(
 
539
  esc_html__( 'I recommend using %1$s or %2$s to regenerate all image sizes.', 'contextual-related-posts' ),
540
  '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=otf-regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550' ) ) . '" class="thickbox">OTF Regenerate Thumbnails</a>',
541
  '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550' ) ) . '" class="thickbox">Regenerate Thumbnails</a>'
542
- ); ?>
 
543
  </p>
544
  </td>
545
  </tr>
@@ -563,14 +579,18 @@ if ( ! defined( 'WPINC' ) ) {
563
  <td>
564
  <label>
565
  <input type="radio" name="thumb_html" value="css" id="thumb_html_0" <?php checked( 'css', $crp_settings['thumb_html'], true ); ?> />
566
- <?php esc_html_e( 'Style attributes. e.g.', 'contextual-related-posts' );
567
- echo ' <code>style="max-width:' . esc_attr( $crp_settings['thumb_width'] ) . 'px;max-height:' . esc_attr( $crp_settings['thumb_height'] ) . 'px;"</code>'; ?>
 
 
568
  </label>
569
  <br />
570
  <label>
571
  <input type="radio" name="thumb_html" value="html" id="thumb_html_1" <?php checked( 'html', $crp_settings['thumb_html'], true ); ?> />
572
- <?php esc_html_e( 'HTML width and height attributes. e.g.', 'contextual-related-posts' );
573
- echo ' <code>width="' . esc_attr( $crp_settings['thumb_width'] ) . '" height="' . esc_attr( $crp_settings['thumb_height'] ) . '"</code>' ?>
 
 
574
  </label>
575
  <br />
576
  <label>
@@ -597,11 +617,11 @@ if ( ! defined( 'WPINC' ) ) {
597
  </tr>
598
  <tr><th scope="row"><label for="thumb_default"><?php esc_html_e( 'Default thumbnail:', 'contextual-related-posts' ); ?></label></th>
599
  <td><input type="textbox" name="thumb_default" id="thumb_default" value="<?php echo esc_attr( $crp_settings['thumb_default'] ); ?>" style="width:100%">
600
- <?php
601
- if ( ! empty( $crp_settings['thumb_default'] ) ) {
602
- printf( '<img src="%1$s" style="max-width:200px" />', esc_url( $crp_settings['thumb_default'] ) );
603
- }
604
- ?>
605
  <p class="description"><?php esc_html_e( "The plugin will first check if the post contains a thumbnail. If it doesn't then it will check the meta field. If this is not available, then it will show the default image as specified above.", 'contextual-related-posts' ); ?></p>
606
  </td>
607
  </tr>
@@ -612,7 +632,7 @@ if ( ! defined( 'WPINC' ) ) {
612
  *
613
  * @since 2.0.0
614
  *
615
- * @param array $crp_settings Contextual Related Posts settings array
616
  */
617
  do_action( 'crp_admin_thumb_options_after', $crp_settings );
618
  ?>
@@ -623,12 +643,12 @@ if ( ! defined( 'WPINC' ) ) {
623
  <input type="submit" name="crp_save" id="crp_thumbop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
624
  </p>
625
 
626
- </div> <!-- // inside -->
627
- </div> <!-- // outputopdiv -->
628
 
629
- <div id="customcssdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
630
- <h3 class='hndle'><span><?php esc_html_e( 'Styles', 'contextual-related-posts' ); ?></span></h3>
631
- <div class="inside">
632
 
633
  <table class="form-table">
634
 
@@ -638,7 +658,7 @@ if ( ! defined( 'WPINC' ) ) {
638
  *
639
  * @since 2.0.0
640
  *
641
- * @param array $crp_settings Contextual Related Posts settings array
642
  */
643
  do_action( 'crp_admin_custom_styles_before', $crp_settings );
644
  ?>
@@ -652,14 +672,23 @@ if ( ! defined( 'WPINC' ) ) {
652
  <br />
653
 
654
  <label>
655
- <input type="radio" name="crp_styles" value="rounded_thumbs" id="crp_styles_0" <?php if ( $crp_settings['include_default_style'] && ( 'rounded_thumbs' === $crp_settings['crp_styles'] ) ) { echo 'checked="checked"'; } ?> /> <?php esc_html_e( 'Rounded Thumbnails', 'contextual-related-posts' ); ?>
 
 
 
 
 
656
  </label>
657
  <p class="description"><img src="<?php echo esc_url( plugins_url( 'admin/images/crp-rounded-thumbs.png', CRP_PLUGIN_FILE ) ); ?>" /></p>
658
  <p class="description"><?php esc_html_e( 'Enabling this option will turn on the thumbnails and set their width and height to 150px. It will also turn off the display of the author, excerpt and date if already enabled. Disabling this option will not revert any settings.', 'contextual-related-posts' ); ?></p>
659
- <p class="description"><?php printf(
 
 
660
  esc_html__( 'You can view the default style at %s', 'contextual-related-posts' ),
661
  '<a href="' . esc_url( 'https://github.com/WebberZone/contextual-related-posts/blob/master/css/default-style.css' ) . '" target="_blank">' . esc_url( 'https://github.com/WebberZone/contextual-related-posts/blob/master/css/default-style.css' ) . '</a>'
662
- ); ?></p>
 
 
663
  <br />
664
 
665
  <label>
@@ -673,7 +702,7 @@ if ( ! defined( 'WPINC' ) ) {
673
  *
674
  * @since 2.2.0
675
  *
676
- * @param array $crp_settings Contextual Related Posts settings array
677
  */
678
  do_action( 'crp_admin_crp_styles', $crp_settings );
679
  ?>
@@ -695,7 +724,7 @@ if ( ! defined( 'WPINC' ) ) {
695
  *
696
  * @since 2.0.0
697
  *
698
- * @param array $crp_settings Contextual Related Posts settings array
699
  */
700
  do_action( 'crp_admin_custom_styles_after', $crp_settings );
701
  ?>
@@ -706,12 +735,12 @@ if ( ! defined( 'WPINC' ) ) {
706
  <input type="submit" name="crp_save" id="crp_customcss_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
707
  </p>
708
 
709
- </div> <!-- // inside -->
710
- </div> <!-- // customcssdiv -->
711
 
712
- <div id="feedopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
713
- <h3 class='hndle'><span><?php esc_html_e( 'Feed options', 'contextual-related-posts' ); ?></span></h3>
714
- <div class="inside">
715
 
716
  <table class="form-table">
717
 
@@ -721,7 +750,7 @@ if ( ! defined( 'WPINC' ) ) {
721
  *
722
  * @since 2.0.0
723
  *
724
- * @param array $crp_settings Contextual Related Posts settings array
725
  */
726
  do_action( 'crp_admin_feed_options_before', $crp_settings );
727
  ?>
@@ -767,7 +796,7 @@ if ( ! defined( 'WPINC' ) ) {
767
  *
768
  * @since 2.0.0
769
  *
770
- * @param array $crp_settings Contextual Related Posts settings array
771
  */
772
  do_action( 'crp_admin_feed_options_after', $crp_settings );
773
  ?>
@@ -778,8 +807,8 @@ if ( ! defined( 'WPINC' ) ) {
778
  <input type="submit" name="crp_save" id="crp_feedop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
779
  </p>
780
 
781
- </div> <!-- // inside -->
782
- </div> <!-- // feedopdiv -->
783
 
784
  <?php
785
  /**
@@ -814,13 +843,13 @@ if ( ! defined( 'WPINC' ) ) {
814
  </p>
815
  </div>
816
 
817
- <?php wp_nonce_field( 'crp-plugin-settings' ) ?>
818
  </form>
819
  </div><!-- /post-body-content -->
820
  <div id="postbox-container-1" class="postbox-container">
821
  <div id="side-sortables" class="meta-box-sortables ui-sortable">
822
 
823
- <?php include_once( 'sidebar-view.php' ); ?>
824
 
825
  </div><!-- /side-sortables -->
826
  </div><!-- /postbox-container-1 -->
3
  * Represents the view for the administration dashboard.
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
29
  do_action( 'crp_admin_nav_bar_before' )
30
  ?>
31
 
32
+ <li><a href="#genopdiv"><?php esc_html_e( 'General options', 'contextual-related-posts' ); ?></a> | </li>
33
+ <li><a href="#tuneopdiv"><?php esc_html_e( 'List tuning options', 'contextual-related-posts' ); ?></a> | </li>
34
+ <li><a href="#outputopdiv"><?php esc_html_e( 'Output options', 'contextual-related-posts' ); ?></a> | </li>
35
+ <li><a href="#thumbopdiv"><?php esc_html_e( 'Thumbnail options', 'contextual-related-posts' ); ?></a> | </li>
36
+ <li><a href="#customcssdiv"><?php esc_html_e( 'Styles', 'contextual-related-posts' ); ?></a> | </li>
37
+ <li><a href="#feedopdiv"><?php esc_html_e( 'Feed options', 'contextual-related-posts' ); ?></a></li>
38
 
39
  <?php
40
  /**
51
  <div id="post-body-content">
52
  <form method="post" id="crp_options" name="crp_options" onsubmit="return checkForm()">
53
 
54
+ <div id="genopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
55
+ <h3 class='hndle'><span><?php esc_html_e( 'General options', 'contextual-related-posts' ); ?></span></h3>
56
+ <div class="inside">
57
 
58
  <table class="form-table">
59
 
63
  *
64
  * @since 2.0.0
65
  *
66
+ * @param array $crp_settings Contextual Related Posts settings array
67
  */
68
  do_action( 'crp_admin_general_options_before', $crp_settings );
69
  ?>
72
  <td><input type="checkbox" name="cache" id="cache" <?php checked( true, $crp_settings['cache'] ); ?> />
73
  <p class="description"><?php esc_html_e( 'Enabling this option will cache the related posts output when the post is visited the first time. The cache is cleaned when you save this page.', 'contextual-related-posts' ); ?></p>
74
  <p class="description"><?php esc_html_e( 'The CRP cache works independently and in addition to any of your caching plugins like WP Super Cache or W3 Total Cache. It is recommended that you enable this on your blog.', 'contextual-related-posts' ); ?></p>
75
+ <p><input type="button" value="<?php esc_html_e( 'Clear cache', 'contextual-related-posts' ); ?>" onclick="return clearCache();" class="button-secondary" /></p>
76
  </td>
77
  </tr>
78
 
104
  </td>
105
  </tr>
106
 
107
+ <tr><th scope="row"><label for="disable_on_mobile"><?php esc_html_e( 'Disable on mobile devices:', 'contextual-related-posts' ); ?></label></th>
108
+ <td>
109
+ <input type="checkbox" name="disable_on_mobile" id="disable_on_mobile" <?php checked( true, $crp_settings['disable_on_mobile'] ); ?> />
110
+ <p class="description"><?php esc_html_e( 'Disable display of related posts on mobile devices', 'contextual-related-posts' ); ?></p>
111
+ </td>
112
+ </tr>
113
+
114
+ <tr><th scope="row"><label for="disable_on_amp"><?php esc_html_e( 'Disable on AMP pages:', 'contextual-related-posts' ); ?></label></th>
115
+ <td>
116
+ <input type="checkbox" name="disable_on_amp" id="disable_on_amp" <?php checked( true, $crp_settings['disable_on_amp'] ); ?> />
117
+ <p class="description"><?php esc_html_e( 'Disable display of related posts on AMP pages', 'contextual-related-posts' ); ?></p>
118
+ </td>
119
+ </tr>
120
+
121
  <tr><th scope="row"><label for="show_metabox"><?php esc_html_e( 'Show metabox:', 'contextual-related-posts' ); ?></label></th>
122
  <td>
123
  <input type="checkbox" name="show_metabox" id="show_metabox" <?php checked( true, $crp_settings['show_metabox'] ); ?> />
145
  *
146
  * @since 2.0.0
147
  *
148
+ * @param array $crp_settings Contextual Related Posts settings array
149
  */
150
  do_action( 'crp_admin_general_options_after', $crp_settings );
151
  ?>
156
  <input type="submit" name="crp_save" id="crp_genop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
157
  </p>
158
 
159
+ </div> <!-- // inside -->
160
+ </div> <!-- // genopdiv -->
161
 
162
+ <div id="tuneopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
163
+ <h3 class='hndle'><span><?php esc_html_e( 'List tuning options', 'contextual-related-posts' ); ?></span></h3>
164
+ <div class="inside">
165
 
166
  <table class="form-table">
167
 
171
  *
172
  * @since 2.1.0
173
  *
174
+ * @param array $crp_settings Contextual Related Posts settings array
175
  */
176
  do_action( 'crp_admin_tuning_options_before', $crp_settings );
177
  ?>
255
  *
256
  * @since 2.1.0
257
  *
258
+ * @param array $crp_settings Contextual Related Posts settings array
259
  */
260
  do_action( 'crp_admin_tuning_options_after', $crp_settings );
261
  ?>
266
  <input type="submit" name="crp_save" id="crp_tuneop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
267
  </p>
268
 
269
+ </div> <!-- // inside -->
270
+ </div> <!-- // tuneopdiv -->
271
 
272
+ <div id="outputopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
273
+ <h3 class='hndle'><span><?php esc_html_e( 'Output options', 'contextual-related-posts' ); ?></span></h3>
274
+ <div class="inside">
275
 
276
  <table class="form-table">
277
 
281
  *
282
  * @since 2.0.0
283
  *
284
+ * @param array $crp_settings Contextual Related Posts settings array
285
  */
286
  do_action( 'crp_admin_output_options_before', $crp_settings );
287
  ?>
311
  <tr><th scope="row"><label for="show_excerpt"><?php esc_html_e( 'Show post excerpt in list?', 'contextual-related-posts' ); ?></label></th>
312
  <td>
313
  <input type="checkbox" name="show_excerpt" id="show_excerpt" <?php checked( true, $crp_settings['show_excerpt'] ); ?> />
314
+ <p class="description"><?php printf( esc_html__( "Displays the excerpt of the post. If you do not provide an explicit excerpt to a post (in the post editor's optional excerpt field), it will display an automatic excerpt which refers to the first %d words of the post's content", 'contextual-related-posts' ), $crp_settings['excerpt_length'] ); ?></p>
315
 
316
  <?php if ( 'rounded_thumbs' === $crp_settings['crp_styles'] ) { ?>
317
  <p style="color: #F00"><?php esc_html_e( 'Rounded Thumbnails style selected under the Custom Styles. Excerpt display is disabled.', 'contextual-related-posts' ); ?></p>
372
  *
373
  * @since 2.0.0
374
  *
375
+ * @param array $crp_settings Contextual Related Posts settings array
376
  */
377
  do_action( 'crp_admin_output_options_after', $crp_settings );
378
  ?>
387
  *
388
  * @since 2.0.0
389
  *
390
+ * @param array $crp_settings Contextual Related Posts settings array
391
  */
392
  do_action( 'crp_admin_exclusion_options_before', $crp_settings );
393
  ?>
418
  *
419
  * @since 2.0.0
420
  *
421
+ * @param array $crp_settings Contextual Related Posts settings array
422
  */
423
  do_action( 'crp_admin_exclusion_options_after', $crp_settings );
424
  ?>
433
  *
434
  * @since 2.0.0
435
  *
436
+ * @param array $crp_settings Contextual Related Posts settings array
437
  */
438
  do_action( 'crp_admin_customize_options_before', $crp_settings );
439
  ?>
459
  *
460
  * @since 2.0.0
461
  *
462
+ * @param array $crp_settings Contextual Related Posts settings array
463
  */
464
  do_action( 'crp_admin_customize_options_after', $crp_settings );
465
  ?>
470
  <input type="submit" name="crp_save" id="crp_outputop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
471
  </p>
472
 
473
+ </div> <!-- // inside -->
474
+ </div> <!-- // outputopdiv -->
475
 
476
+ <div id="thumbopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
477
+ <h3 class='hndle'><span><?php esc_html_e( 'Thumbnail options', 'contextual-related-posts' ); ?></span></h3>
478
+ <div class="inside">
479
 
480
  <table class="form-table">
481
 
485
  *
486
  * @since 2.0.0
487
  *
488
+ * @param array $crp_settings Contextual Related Posts settings array
489
  */
490
  do_action( 'crp_admin_thumb_options_before', $crp_settings );
491
  ?>
493
  <tr><th scope="row"><label for="post_thumb_op"><?php esc_html_e( 'Location of post thumbnail:', 'contextual-related-posts' ); ?></label></th>
494
  <td>
495
  <label>
496
+ <input type="radio" name="post_thumb_op" value="inline" id="post_thumb_op_0" <?php checked( 'inline', $crp_settings['post_thumb_op'], true ); ?> />
497
  <?php esc_html_e( 'Display thumbnails inline with posts, before title', 'contextual-related-posts' ); ?>
498
  </label>
499
  <br />
500
  <label>
501
+ <input type="radio" name="post_thumb_op" value="after" id="post_thumb_op_1" <?php checked( 'after', $crp_settings['post_thumb_op'], true ); ?> />
502
  <?php esc_html_e( 'Display thumbnails inline with posts, after title', 'contextual-related-posts' ); ?>
503
  </label>
504
  <br />
505
  <label>
506
+ <input type="radio" name="post_thumb_op" value="thumbs_only" id="post_thumb_op_2" <?php checked( 'thumbs_only', $crp_settings['post_thumb_op'], true ); ?> />
507
  <?php esc_html_e( 'Display only thumbnails, no text', 'contextual-related-posts' ); ?>
508
  </label>
509
  <br />
510
  <label>
511
+ <input type="radio" name="post_thumb_op" value="text_only" id="post_thumb_op_3" <?php checked( 'text_only', $crp_settings['post_thumb_op'], true ); ?> />
512
  <?php esc_html_e( 'Do not display thumbnails, only text.', 'contextual-related-posts' ); ?>
513
  </label>
514
 
527
  }
528
 
529
  foreach ( $crp_get_all_image_sizes as $size ) :
530
+ ?>
531
  <label>
532
+ <input type="radio" name="thumb_size" value="<?php esc_attr_e( $size['name'] ); ?>" id="<?php esc_attr_e( $size['name'] ); ?>" <?php checked( $crp_settings['thumb_size'], $size['name'] ); ?> />
533
  <?php esc_html_e( $size['name'] ); ?> ( <?php esc_html_e( $size['width'] ); ?>x<?php esc_html_e( $size['height'] ); ?>
534
  <?php
535
  if ( $size['crop'] ) {
536
  echo 'cropped';
537
  }
538
+ ?>
539
  )
540
  </label>
541
  <br />
549
  <?php esc_html_e( 'If you choose an existing size, then the width, height and crop mode settings in the three options below will be automatically updated to reflect the correct dimensions of the setting.', 'contextual-related-posts' ); ?><br />
550
  <?php esc_html_e( 'If you have chosen Custom size above, then enter the width, height and crop settings below. For best results, use a cropped image with the same width and height. The default setting is 150x150 cropped image.', 'contextual-related-posts' ); ?><br /><br />
551
  <?php esc_html_e( "Any changes to the thumbnail settings doesn't automatically resize existing images.", 'contextual-related-posts' ); ?>
552
+ <?php
553
+ printf(
554
  esc_html__( 'I recommend using %1$s or %2$s to regenerate all image sizes.', 'contextual-related-posts' ),
555
  '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=otf-regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550' ) ) . '" class="thickbox">OTF Regenerate Thumbnails</a>',
556
  '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550' ) ) . '" class="thickbox">Regenerate Thumbnails</a>'
557
+ );
558
+ ?>
559
  </p>
560
  </td>
561
  </tr>
579
  <td>
580
  <label>
581
  <input type="radio" name="thumb_html" value="css" id="thumb_html_0" <?php checked( 'css', $crp_settings['thumb_html'], true ); ?> />
582
+ <?php
583
+ esc_html_e( 'Style attributes. e.g.', 'contextual-related-posts' );
584
+ echo ' <code>style="max-width:' . esc_attr( $crp_settings['thumb_width'] ) . 'px;max-height:' . esc_attr( $crp_settings['thumb_height'] ) . 'px;"</code>';
585
+ ?>
586
  </label>
587
  <br />
588
  <label>
589
  <input type="radio" name="thumb_html" value="html" id="thumb_html_1" <?php checked( 'html', $crp_settings['thumb_html'], true ); ?> />
590
+ <?php
591
+ esc_html_e( 'HTML width and height attributes. e.g.', 'contextual-related-posts' );
592
+ echo ' <code>width="' . esc_attr( $crp_settings['thumb_width'] ) . '" height="' . esc_attr( $crp_settings['thumb_height'] ) . '"</code>'
593
+ ?>
594
  </label>
595
  <br />
596
  <label>
617
  </tr>
618
  <tr><th scope="row"><label for="thumb_default"><?php esc_html_e( 'Default thumbnail:', 'contextual-related-posts' ); ?></label></th>
619
  <td><input type="textbox" name="thumb_default" id="thumb_default" value="<?php echo esc_attr( $crp_settings['thumb_default'] ); ?>" style="width:100%">
620
+ <?php
621
+ if ( ! empty( $crp_settings['thumb_default'] ) ) {
622
+ printf( '<img src="%1$s" style="max-width:200px" />', esc_url( $crp_settings['thumb_default'] ) );
623
+ }
624
+ ?>
625
  <p class="description"><?php esc_html_e( "The plugin will first check if the post contains a thumbnail. If it doesn't then it will check the meta field. If this is not available, then it will show the default image as specified above.", 'contextual-related-posts' ); ?></p>
626
  </td>
627
  </tr>
632
  *
633
  * @since 2.0.0
634
  *
635
+ * @param array $crp_settings Contextual Related Posts settings array
636
  */
637
  do_action( 'crp_admin_thumb_options_after', $crp_settings );
638
  ?>
643
  <input type="submit" name="crp_save" id="crp_thumbop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
644
  </p>
645
 
646
+ </div> <!-- // inside -->
647
+ </div> <!-- // outputopdiv -->
648
 
649
+ <div id="customcssdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
650
+ <h3 class='hndle'><span><?php esc_html_e( 'Styles', 'contextual-related-posts' ); ?></span></h3>
651
+ <div class="inside">
652
 
653
  <table class="form-table">
654
 
658
  *
659
  * @since 2.0.0
660
  *
661
+ * @param array $crp_settings Contextual Related Posts settings array
662
  */
663
  do_action( 'crp_admin_custom_styles_before', $crp_settings );
664
  ?>
672
  <br />
673
 
674
  <label>
675
+ <input type="radio" name="crp_styles" value="rounded_thumbs" id="crp_styles_0"
676
+ <?php
677
+ if ( $crp_settings['include_default_style'] && ( 'rounded_thumbs' === $crp_settings['crp_styles'] ) ) {
678
+ echo 'checked="checked"'; }
679
+ ?>
680
+ /> <?php esc_html_e( 'Rounded Thumbnails', 'contextual-related-posts' ); ?>
681
  </label>
682
  <p class="description"><img src="<?php echo esc_url( plugins_url( 'admin/images/crp-rounded-thumbs.png', CRP_PLUGIN_FILE ) ); ?>" /></p>
683
  <p class="description"><?php esc_html_e( 'Enabling this option will turn on the thumbnails and set their width and height to 150px. It will also turn off the display of the author, excerpt and date if already enabled. Disabling this option will not revert any settings.', 'contextual-related-posts' ); ?></p>
684
+ <p class="description">
685
+ <?php
686
+ printf(
687
  esc_html__( 'You can view the default style at %s', 'contextual-related-posts' ),
688
  '<a href="' . esc_url( 'https://github.com/WebberZone/contextual-related-posts/blob/master/css/default-style.css' ) . '" target="_blank">' . esc_url( 'https://github.com/WebberZone/contextual-related-posts/blob/master/css/default-style.css' ) . '</a>'
689
+ );
690
+ ?>
691
+ </p>
692
  <br />
693
 
694
  <label>
702
  *
703
  * @since 2.2.0
704
  *
705
+ * @param array $crp_settings Contextual Related Posts settings array
706
  */
707
  do_action( 'crp_admin_crp_styles', $crp_settings );
708
  ?>
724
  *
725
  * @since 2.0.0
726
  *
727
+ * @param array $crp_settings Contextual Related Posts settings array
728
  */
729
  do_action( 'crp_admin_custom_styles_after', $crp_settings );
730
  ?>
735
  <input type="submit" name="crp_save" id="crp_customcss_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
736
  </p>
737
 
738
+ </div> <!-- // inside -->
739
+ </div> <!-- // customcssdiv -->
740
 
741
+ <div id="feedopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'contextual-related-posts' ); ?>"><br /></div>
742
+ <h3 class='hndle'><span><?php esc_html_e( 'Feed options', 'contextual-related-posts' ); ?></span></h3>
743
+ <div class="inside">
744
 
745
  <table class="form-table">
746
 
750
  *
751
  * @since 2.0.0
752
  *
753
+ * @param array $crp_settings Contextual Related Posts settings array
754
  */
755
  do_action( 'crp_admin_feed_options_before', $crp_settings );
756
  ?>
796
  *
797
  * @since 2.0.0
798
  *
799
+ * @param array $crp_settings Contextual Related Posts settings array
800
  */
801
  do_action( 'crp_admin_feed_options_after', $crp_settings );
802
  ?>
807
  <input type="submit" name="crp_save" id="crp_feedop_save" value="<?php esc_attr_e( 'Save Options', 'contextual-related-posts' ); ?>" class="button button-primary" />
808
  </p>
809
 
810
+ </div> <!-- // inside -->
811
+ </div> <!-- // feedopdiv -->
812
 
813
  <?php
814
  /**
843
  </p>
844
  </div>
845
 
846
+ <?php wp_nonce_field( 'crp-plugin-settings' ); ?>
847
  </form>
848
  </div><!-- /post-body-content -->
849
  <div id="postbox-container-1" class="postbox-container">
850
  <div id="side-sortables" class="meta-box-sortables ui-sortable">
851
 
852
+ <?php require_once 'sidebar-view.php'; ?>
853
 
854
  </div><!-- /side-sortables -->
855
  </div><!-- /postbox-container-1 -->
admin/metabox.php CHANGED
@@ -3,10 +3,10 @@
3
  * Contextual Related Posts Metabox interface.
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  /**** If this file is called directly, abort. ****/
@@ -17,7 +17,7 @@ if ( ! defined( 'WPINC' ) ) {
17
  /**
18
  * Function to add meta box in Write screens of Post, Page and Custom Post Types.
19
  *
20
- * @since 1.9.1
21
  *
22
  * @param text $post_type Post Type.
23
  * @param object $post Post object.
@@ -26,20 +26,22 @@ function crp_add_meta_box( $post_type, $post ) {
26
  global $crp_settings;
27
 
28
  // If metaboxes are disabled, then exit.
29
- if ( ! $crp_settings['show_metabox'] ) { return; }
 
30
 
31
  // If current user isn't an admin and we're restricting metaboxes to admins only, then exit.
32
- if ( ! current_user_can( 'manage_options' ) && $crp_settings['show_metabox_admins'] ) { return; }
 
33
 
34
- $args = array(
35
- 'public' => true,
36
  );
37
  $post_types = get_post_types( $args );
38
 
39
  /**
40
  * Filter post types on which the meta box is displayed
41
  *
42
- * @since 2.2.0
43
  *
44
  * @param array $post_types Array of post types.
45
  * @param array $post_types Post object.
@@ -58,23 +60,23 @@ function crp_add_meta_box( $post_type, $post ) {
58
  );
59
  }
60
  }
61
- add_action( 'add_meta_boxes', 'crp_add_meta_box' , 10, 2 );
62
 
63
 
64
  /**
65
  * Function to call the meta box.
66
  *
67
- * @since 1.9.1
68
  */
69
  function crp_call_meta_box() {
70
  global $post, $crp_settings;
71
 
72
- /**** Add an nonce field so we can check for it later. ****/
73
  wp_nonce_field( 'crp_meta_box', 'crp_meta_box_nonce' );
74
 
75
  // Get the thumbnail settings. The name of the meta key is defined in thumb_meta parameter of the CRP Settings array.
76
  $crp_thumb_meta = get_post_meta( $post->ID, $crp_settings['thumb_meta'], true );
77
- $value = ( $crp_thumb_meta ) ? $crp_thumb_meta : '';
78
 
79
  // Get related posts specific meta.
80
  $crp_post_meta = get_post_meta( $post->ID, 'crp_post_meta', true );
@@ -98,9 +100,9 @@ function crp_call_meta_box() {
98
  } else {
99
  $manual_related = '';
100
  }
101
- $manual_related_array = explode( ',' , $manual_related );
102
 
103
- ?>
104
  <p>
105
  <label for="crp_disable_here"><strong><?php esc_html_e( 'Disable Related Posts display:', 'contextual-related-posts' ); ?></strong></label>
106
  <input type="checkbox" id="crp_disable_here" name="crp_disable_here" <?php checked( 1, $disable_here, true ); ?> />
@@ -117,7 +119,7 @@ function crp_call_meta_box() {
117
 
118
  <p>
119
  <label for="manual_related"><strong><?php esc_html_e( 'Manual related posts:', 'contextual-related-posts' ); ?></strong></label>
120
- <input type="text" id="manual_related" name="manual_related" value="<?php echo esc_attr( $manual_related ) ?>" style="width:100%" />
121
  <em><?php esc_html_e( 'Comma separated list of post, page or custom post type IDs. e.g. 188,320,500. These will be given preference over the related posts generated by the plugin.', 'contextual-related-posts' ); ?></em>
122
  <em><?php esc_html_e( 'Once you enter the list above and save this page, the plugin will display the titles of the posts below for your reference. Only IDs corresponding to published posts or custom post types will be retained.', 'contextual-related-posts' ); ?></em>
123
  </p>
@@ -147,7 +149,7 @@ function crp_call_meta_box() {
147
 
148
  <p>
149
  <label for="crp_thumb_meta"><strong><?php esc_html_e( 'Location of thumbnail', 'contextual-related-posts' ); ?>:</strong></label>
150
- <input type="text" id="crp_thumb_meta" name="crp_thumb_meta" value="<?php echo esc_attr( $value ) ?>" style="width:100%" />
151
  <em><?php esc_html_e( "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This image will be used for the post. It will be resized to the thumbnail size set under Settings &raquo; Related Posts &raquo; Output Options", 'contextual-related-posts' ); ?></em>
152
  <em><?php esc_html_e( 'The URL above is saved in the meta field:', 'contextual-related-posts' ); ?></em> <strong><?php esc_html_e( $crp_settings['thumb_meta'] ); ?></strong>
153
  </p>
@@ -168,9 +170,9 @@ function crp_call_meta_box() {
168
  /**
169
  * Action triggered when displaying Contextual Related Posts meta box
170
  *
171
- * @since 2.2
172
  *
173
- * @param object $post Post object
174
  */
175
  do_action( 'crp_call_meta_box', $post );
176
  }
@@ -179,7 +181,7 @@ function crp_call_meta_box() {
179
  /**
180
  * Function to save the meta box.
181
  *
182
- * @since 1.9.1
183
  *
184
  * @param mixed $post_id Post ID.
185
  */
@@ -243,28 +245,34 @@ function crp_save_meta_box( $post_id ) {
243
  /**
244
  * Filter the CRP Post meta variable which contains post-specific settings
245
  *
246
- * @since 2.2.0
247
  *
248
- * @param array $crp_post_meta CRP post-specific settings
249
- * @param int $post_id Post ID
250
  */
251
  $crp_post_meta = apply_filters( 'crp_post_meta', $crp_post_meta, $post_id );
252
 
253
  $crp_post_meta_filtered = array_filter( $crp_post_meta );
254
 
255
- /**** Now we can start saving ****/
256
- if ( empty( $crp_post_meta_filtered ) ) { // Checks if all the array items are 0 or empty
257
- delete_post_meta( $post_id, 'crp_post_meta' ); // Delete the post meta if no options are set
258
  } else {
259
  update_post_meta( $post_id, 'crp_post_meta', $crp_post_meta_filtered );
260
  }
261
 
 
 
 
 
 
 
262
  /**
263
  * Action triggered when saving Contextual Related Posts meta box settings
264
  *
265
- * @since 2.2
266
  *
267
- * @param int $post_id Post ID
268
  */
269
  do_action( 'crp_save_meta_box', $post_id );
270
  }
3
  * Contextual Related Posts Metabox interface.
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  /**** If this file is called directly, abort. ****/
17
  /**
18
  * Function to add meta box in Write screens of Post, Page and Custom Post Types.
19
  *
20
+ * @since 1.9.1
21
  *
22
  * @param text $post_type Post Type.
23
  * @param object $post Post object.
26
  global $crp_settings;
27
 
28
  // If metaboxes are disabled, then exit.
29
+ if ( ! $crp_settings['show_metabox'] ) {
30
+ return; }
31
 
32
  // If current user isn't an admin and we're restricting metaboxes to admins only, then exit.
33
+ if ( ! current_user_can( 'manage_options' ) && $crp_settings['show_metabox_admins'] ) {
34
+ return; }
35
 
36
+ $args = array(
37
+ 'public' => true,
38
  );
39
  $post_types = get_post_types( $args );
40
 
41
  /**
42
  * Filter post types on which the meta box is displayed
43
  *
44
+ * @since 2.2.0
45
  *
46
  * @param array $post_types Array of post types.
47
  * @param array $post_types Post object.
60
  );
61
  }
62
  }
63
+ add_action( 'add_meta_boxes', 'crp_add_meta_box', 10, 2 );
64
 
65
 
66
  /**
67
  * Function to call the meta box.
68
  *
69
+ * @since 1.9.1
70
  */
71
  function crp_call_meta_box() {
72
  global $post, $crp_settings;
73
 
74
+ /**** Add an nonce field so we can check for it later. */
75
  wp_nonce_field( 'crp_meta_box', 'crp_meta_box_nonce' );
76
 
77
  // Get the thumbnail settings. The name of the meta key is defined in thumb_meta parameter of the CRP Settings array.
78
  $crp_thumb_meta = get_post_meta( $post->ID, $crp_settings['thumb_meta'], true );
79
+ $value = ( $crp_thumb_meta ) ? $crp_thumb_meta : '';
80
 
81
  // Get related posts specific meta.
82
  $crp_post_meta = get_post_meta( $post->ID, 'crp_post_meta', true );
100
  } else {
101
  $manual_related = '';
102
  }
103
+ $manual_related_array = explode( ',', $manual_related );
104
 
105
+ ?>
106
  <p>
107
  <label for="crp_disable_here"><strong><?php esc_html_e( 'Disable Related Posts display:', 'contextual-related-posts' ); ?></strong></label>
108
  <input type="checkbox" id="crp_disable_here" name="crp_disable_here" <?php checked( 1, $disable_here, true ); ?> />
119
 
120
  <p>
121
  <label for="manual_related"><strong><?php esc_html_e( 'Manual related posts:', 'contextual-related-posts' ); ?></strong></label>
122
+ <input type="text" id="manual_related" name="manual_related" value="<?php echo esc_attr( $manual_related ); ?>" style="width:100%" />
123
  <em><?php esc_html_e( 'Comma separated list of post, page or custom post type IDs. e.g. 188,320,500. These will be given preference over the related posts generated by the plugin.', 'contextual-related-posts' ); ?></em>
124
  <em><?php esc_html_e( 'Once you enter the list above and save this page, the plugin will display the titles of the posts below for your reference. Only IDs corresponding to published posts or custom post types will be retained.', 'contextual-related-posts' ); ?></em>
125
  </p>
149
 
150
  <p>
151
  <label for="crp_thumb_meta"><strong><?php esc_html_e( 'Location of thumbnail', 'contextual-related-posts' ); ?>:</strong></label>
152
+ <input type="text" id="crp_thumb_meta" name="crp_thumb_meta" value="<?php echo esc_attr( $value ); ?>" style="width:100%" />
153
  <em><?php esc_html_e( "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This image will be used for the post. It will be resized to the thumbnail size set under Settings &raquo; Related Posts &raquo; Output Options", 'contextual-related-posts' ); ?></em>
154
  <em><?php esc_html_e( 'The URL above is saved in the meta field:', 'contextual-related-posts' ); ?></em> <strong><?php esc_html_e( $crp_settings['thumb_meta'] ); ?></strong>
155
  </p>
170
  /**
171
  * Action triggered when displaying Contextual Related Posts meta box
172
  *
173
+ * @since 2.2
174
  *
175
+ * @param object $post Post object
176
  */
177
  do_action( 'crp_call_meta_box', $post );
178
  }
181
  /**
182
  * Function to save the meta box.
183
  *
184
+ * @since 1.9.1
185
  *
186
  * @param mixed $post_id Post ID.
187
  */
245
  /**
246
  * Filter the CRP Post meta variable which contains post-specific settings
247
  *
248
+ * @since 2.2.0
249
  *
250
+ * @param array $crp_post_meta CRP post-specific settings
251
+ * @param int $post_id Post ID
252
  */
253
  $crp_post_meta = apply_filters( 'crp_post_meta', $crp_post_meta, $post_id );
254
 
255
  $crp_post_meta_filtered = array_filter( $crp_post_meta );
256
 
257
+ /**** Now we can start saving */
258
+ if ( empty( $crp_post_meta_filtered ) ) { // Checks if all the array items are 0 or empty
259
+ delete_post_meta( $post_id, 'crp_post_meta' ); // Delete the post meta if no options are set
260
  } else {
261
  update_post_meta( $post_id, 'crp_post_meta', $crp_post_meta_filtered );
262
  }
263
 
264
+ // Clear cache of current post.
265
+ $default_meta_keys = crp_cache_get_keys();
266
+ foreach ( $default_meta_keys as $meta_key ) {
267
+ delete_post_meta( $post_id, $meta_key );
268
+ }
269
+
270
  /**
271
  * Action triggered when saving Contextual Related Posts meta box settings
272
  *
273
+ * @since 2.2
274
  *
275
+ * @param int $post_id Post ID
276
  */
277
  do_action( 'crp_save_meta_box', $post_id );
278
  }
admin/sidebar-view.php CHANGED
@@ -3,10 +3,10 @@
3
  * Represents the sidebar view for the administration dashboard.
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
3
  * Represents the sidebar view for the administration dashboard.
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
contextual-related-posts.php CHANGED
@@ -6,22 +6,22 @@
6
  * allows you to display a list of related posts on your website and in your feed.
7
  *
8
  * @package Contextual_Related_Posts
9
- * @author Ajay D'Souza <me@ajaydsouza.com>
10
  * @license GPL-2.0+
11
  * @link https://webberzone.com
12
- * @copyright 2009-2017 Ajay D'Souza
13
  *
14
  * @wordpress-plugin
15
- * Plugin Name: Contextual Related Posts
16
- * Plugin URI: https://webberzone.com/plugins/contextual-related-posts/
17
- * Description: Display a set of related posts on your website or in your feed. Increase reader retention and reduce bounce rates
18
- * Version: 2.4.1
19
- * Author: WebberZone
20
- * Author URI: https://webberzone.com
21
- * License: GPL-2.0+
22
- * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
23
- * Text Domain: contextual-related-posts
24
- * Domain Path: /languages
25
  * GitHub Plugin URI: https://github.com/WebberZone/contextual-related-posts/
26
  */
27
 
@@ -80,7 +80,7 @@ if ( ! defined( 'CRP_MAX_WORDS' ) ) {
80
  /**
81
  * Global variable holding the current settings for Contextual Related Posts
82
  *
83
- * @since 1.8.10
84
  *
85
  * @var array
86
  */
@@ -101,95 +101,97 @@ function crp_default_options() {
101
 
102
  $blank_output_text = __( 'No related posts found', 'contextual-related-posts' );
103
 
104
- $thumb_default = plugins_url( 'default.png' , __FILE__ );
105
 
106
  $crp_settings = array(
107
  // General options.
108
- 'cache' => false, // Cache output for faster page load.
109
 
110
- 'add_to_content' => true, // Add related posts to content (only on single posts).
111
- 'add_to_page' => true, // Add related posts to content (only on single pages).
112
- 'add_to_feed' => false, // Add related posts to feed (full).
113
- 'add_to_home' => false, // Add related posts to home page.
114
- 'add_to_category_archives' => false, // Add related posts to category archives.
115
- 'add_to_tag_archives' => false, // Add related posts to tag archives.
116
- 'add_to_archives' => false, // Add related posts to other archives.
117
 
118
- 'content_filter_priority' => 10, // Content priority.
119
- 'insert_after_paragraph' => -1, // Insert after paragraph number.
120
- 'show_metabox' => true, // Show metabox to admins.
121
- 'show_metabox_admins' => false, // Limit to admins as well.
 
 
122
 
123
- 'show_credit' => false, // Link to this plugin's page?
124
 
125
  // List tuning options.
126
- 'limit' => '6', // How many posts to display?
127
- 'daily_range' => '1095', // How old posts should be displayed?
128
- 'random_order' => false, // Randomise posts.
129
 
130
- 'match_content' => true, // Match against post content as well as title.
131
- 'match_content_words' => '0', // How many characters of content should be matched? 0 for all chars.
132
 
133
- 'post_types' => 'post,page', // WordPress custom post types.
134
- 'same_post_type' => false, // Limit to the same post type.
135
 
136
- 'exclude_categories' => '', // Exclude these categories.
137
- 'exclude_cat_slugs' => '', // Exclude these categories (slugs).
138
- 'exclude_post_ids' => '', // Comma separated list of page / post IDs that are to be excluded in the results.
139
 
140
  // Output options.
141
- 'title' => $title, // Add before the content.
142
- 'blank_output' => true, // Blank output?
143
- 'blank_output_text' => $blank_output_text, // Blank output text.
144
 
145
- 'show_excerpt' => false, // Show post excerpt in list item.
146
- 'show_date' => false, // Show date in list item.
147
- 'show_author' => false, // Show author in list item.
148
- 'excerpt_length' => '10', // Length of characters.
149
- 'title_length' => '60', // Limit length of post title.
150
 
151
- 'link_new_window' => false, // Open link in new window.
152
- 'link_nofollow' => false, // Includes rel nofollow to links.
153
 
154
- 'before_list' => '<ul>', // Before the entire list.
155
- 'after_list' => '</ul>', // After the entire list.
156
- 'before_list_item' => '<li>', // Before each list item.
157
- 'after_list_item' => '</li>', // After each list item.
158
 
159
- 'exclude_on_post_ids' => '', // Comma separate list of page/post IDs to not display related posts on.
160
- 'exclude_on_post_types' => '', // WordPress custom post types.
161
 
162
  // Thumbnail options.
163
- 'post_thumb_op' => 'inline', // Default option to display text and no thumbnails in posts.
164
- 'thumb_size' => 'thumbnail', // Default thumbnail size
165
- 'thumb_height' => '150', // Height of thumbnails.
166
- 'thumb_width' => '150', // Width of thumbnails.
167
- 'thumb_crop' => true, // Crop mode. default is hard crop.
168
- 'thumb_html' => 'html', // Use HTML or CSS for width and height of the thumbnail?
169
- 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
170
- 'scan_images' => true, // Scan post for images.
171
- 'thumb_default' => $thumb_default, // Default thumbnail image.
172
- 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
173
 
174
  // Feed options.
175
- 'limit_feed' => '5', // How many posts to display in feeds.
176
- 'post_thumb_op_feed' => 'text_only', // Default option to display text and no thumbnails in Feeds.
177
- 'thumb_height_feed' => '50', // Height of thumbnails in feed.
178
- 'thumb_width_feed' => '50', // Width of thumbnails in feed.
179
- 'show_excerpt_feed' => false, // Show description in list item in feed.
180
 
181
  // Custom styles.
182
- 'custom_CSS' => '', // Custom CSS to style the output.
183
- 'include_default_style' => true, // Include default style - Will be DEPRECATED in the next version.
184
- 'crp_styles' => 'rounded_thumbs', // Defaault style is rounded thubnails.
185
  );
186
 
187
  /**
188
  * Filters the default options array.
189
  *
190
- * @since 1.9.1
191
  *
192
- * @param array $crp_settings Default options.
193
  */
194
  return apply_filters( 'crp_default_options', $crp_settings );
195
  }
@@ -223,9 +225,9 @@ function crp_read_options() {
223
  /**
224
  * Filters the options array.
225
  *
226
- * @since 1.9.1
227
  *
228
- * @param array $crp_settings Options read from the database
229
  */
230
  return apply_filters( 'crp_read_options', $crp_settings );
231
  }
@@ -237,19 +239,19 @@ function crp_read_options() {
237
  *----------------------------------------------------------------------------
238
  */
239
 
240
- require_once( CRP_PLUGIN_DIR . 'includes/plugin-activator.php' );
241
- require_once( CRP_PLUGIN_DIR . 'includes/i10n.php' );
242
- require_once( CRP_PLUGIN_DIR . 'includes/output-generator.php' );
243
- require_once( CRP_PLUGIN_DIR . 'includes/media.php' );
244
- require_once( CRP_PLUGIN_DIR . 'includes/tools.php' );
245
- require_once( CRP_PLUGIN_DIR . 'includes/header.php' );
246
- require_once( CRP_PLUGIN_DIR . 'includes/content.php' );
247
- require_once( CRP_PLUGIN_DIR . 'includes/main-query.php' );
248
- require_once( CRP_PLUGIN_DIR . 'includes/modules/manual-posts.php' );
249
- require_once( CRP_PLUGIN_DIR . 'includes/modules/shortcode.php' );
250
- require_once( CRP_PLUGIN_DIR . 'includes/modules/taxonomies.php' );
251
- require_once( CRP_PLUGIN_DIR . 'includes/modules/exclusions.php' );
252
- require_once( CRP_PLUGIN_DIR . 'includes/modules/class-crp-widget.php' );
253
 
254
 
255
  /*
@@ -260,10 +262,10 @@ require_once( CRP_PLUGIN_DIR . 'includes/modules/class-crp-widget.php' );
260
 
261
  if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
262
 
263
- require_once( CRP_PLUGIN_DIR . 'admin/admin.php' );
264
- require_once( CRP_PLUGIN_DIR . 'admin/loader.php' );
265
- require_once( CRP_PLUGIN_DIR . 'admin/metabox.php' );
266
- require_once( CRP_PLUGIN_DIR . 'admin/cache.php' );
267
 
268
  } // End if().
269
 
@@ -274,5 +276,5 @@ if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
274
  *----------------------------------------------------------------------------
275
  */
276
 
277
- require_once( CRP_PLUGIN_DIR . 'includes/deprecated.php' );
278
 
6
  * allows you to display a list of related posts on your website and in your feed.
7
  *
8
  * @package Contextual_Related_Posts
9
+ * @author Ajay D'Souza
10
  * @license GPL-2.0+
11
  * @link https://webberzone.com
12
+ * @copyright 2009-2018 Ajay D'Souza
13
  *
14
  * @wordpress-plugin
15
+ * Plugin Name: Contextual Related Posts
16
+ * Plugin URI: https://webberzone.com/plugins/contextual-related-posts/
17
+ * Description: Display a set of related posts on your website or in your feed. Increase reader retention and reduce bounce rates
18
+ * Version: 2.5.0
19
+ * Author: WebberZone
20
+ * Author URI: https://webberzone.com
21
+ * License: GPL-2.0+
22
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
23
+ * Text Domain: contextual-related-posts
24
+ * Domain Path: /languages
25
  * GitHub Plugin URI: https://github.com/WebberZone/contextual-related-posts/
26
  */
27
 
80
  /**
81
  * Global variable holding the current settings for Contextual Related Posts
82
  *
83
+ * @since 1.8.10
84
  *
85
  * @var array
86
  */
101
 
102
  $blank_output_text = __( 'No related posts found', 'contextual-related-posts' );
103
 
104
+ $thumb_default = plugins_url( 'default.png', __FILE__ );
105
 
106
  $crp_settings = array(
107
  // General options.
108
+ 'cache' => false, // Cache output for faster page load.
109
 
110
+ 'add_to_content' => true, // Add related posts to content (only on single posts).
111
+ 'add_to_page' => true, // Add related posts to content (only on single pages).
112
+ 'add_to_feed' => false, // Add related posts to feed (full).
113
+ 'add_to_home' => false, // Add related posts to home page.
114
+ 'add_to_category_archives' => false, // Add related posts to category archives.
115
+ 'add_to_tag_archives' => false, // Add related posts to tag archives.
116
+ 'add_to_archives' => false, // Add related posts to other archives.
117
 
118
+ 'content_filter_priority' => 10, // Content priority.
119
+ 'insert_after_paragraph' => -1, // Insert after paragraph number.
120
+ 'disable_on_mobile' => false, // Disable on mobile.
121
+ 'disable_on_amp' => false, // Disable on AMP.
122
+ 'show_metabox' => true, // Show metabox to admins.
123
+ 'show_metabox_admins' => false, // Limit to admins as well.
124
 
125
+ 'show_credit' => false, // Link to this plugin's page?
126
 
127
  // List tuning options.
128
+ 'limit' => '6', // How many posts to display?
129
+ 'daily_range' => '1095', // How old posts should be displayed?
130
+ 'random_order' => false, // Randomise posts.
131
 
132
+ 'match_content' => true, // Match against post content as well as title.
133
+ 'match_content_words' => '0', // How many characters of content should be matched? 0 for all chars.
134
 
135
+ 'post_types' => 'post,page', // WordPress custom post types.
136
+ 'same_post_type' => false, // Limit to the same post type.
137
 
138
+ 'exclude_categories' => '', // Exclude these categories.
139
+ 'exclude_cat_slugs' => '', // Exclude these categories (slugs).
140
+ 'exclude_post_ids' => '', // Comma separated list of page / post IDs that are to be excluded in the results.
141
 
142
  // Output options.
143
+ 'title' => $title, // Add before the content.
144
+ 'blank_output' => true, // Blank output?
145
+ 'blank_output_text' => $blank_output_text, // Blank output text.
146
 
147
+ 'show_excerpt' => false, // Show post excerpt in list item.
148
+ 'show_date' => false, // Show date in list item.
149
+ 'show_author' => false, // Show author in list item.
150
+ 'excerpt_length' => '10', // Length of characters.
151
+ 'title_length' => '60', // Limit length of post title.
152
 
153
+ 'link_new_window' => false, // Open link in new window.
154
+ 'link_nofollow' => false, // Includes rel nofollow to links.
155
 
156
+ 'before_list' => '<ul>', // Before the entire list.
157
+ 'after_list' => '</ul>', // After the entire list.
158
+ 'before_list_item' => '<li>', // Before each list item.
159
+ 'after_list_item' => '</li>', // After each list item.
160
 
161
+ 'exclude_on_post_ids' => '', // Comma separate list of page/post IDs to not display related posts on.
162
+ 'exclude_on_post_types' => '', // WordPress custom post types.
163
 
164
  // Thumbnail options.
165
+ 'post_thumb_op' => 'inline', // Default option to display text and no thumbnails in posts.
166
+ 'thumb_size' => 'thumbnail', // Default thumbnail size.
167
+ 'thumb_height' => '150', // Height of thumbnails.
168
+ 'thumb_width' => '150', // Width of thumbnails.
169
+ 'thumb_crop' => true, // Crop mode. default is hard crop.
170
+ 'thumb_html' => 'html', // Use HTML or CSS for width and height of the thumbnail?
171
+ 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
172
+ 'scan_images' => true, // Scan post for images.
173
+ 'thumb_default' => $thumb_default, // Default thumbnail image.
174
+ 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
175
 
176
  // Feed options.
177
+ 'limit_feed' => '5', // How many posts to display in feeds.
178
+ 'post_thumb_op_feed' => 'text_only', // Default option to display text and no thumbnails in Feeds.
179
+ 'thumb_height_feed' => '50', // Height of thumbnails in feed.
180
+ 'thumb_width_feed' => '50', // Width of thumbnails in feed.
181
+ 'show_excerpt_feed' => false, // Show description in list item in feed.
182
 
183
  // Custom styles.
184
+ 'custom_CSS' => '', // Custom CSS to style the output.
185
+ 'include_default_style' => true, // Include default style - Will be DEPRECATED in the next version.
186
+ 'crp_styles' => 'rounded_thumbs', // Defaault style is rounded thubnails.
187
  );
188
 
189
  /**
190
  * Filters the default options array.
191
  *
192
+ * @since 1.9.1
193
  *
194
+ * @param array $crp_settings Default options.
195
  */
196
  return apply_filters( 'crp_default_options', $crp_settings );
197
  }
225
  /**
226
  * Filters the options array.
227
  *
228
+ * @since 1.9.1
229
  *
230
+ * @param array $crp_settings Options read from the database
231
  */
232
  return apply_filters( 'crp_read_options', $crp_settings );
233
  }
239
  *----------------------------------------------------------------------------
240
  */
241
 
242
+ require_once CRP_PLUGIN_DIR . 'includes/plugin-activator.php';
243
+ require_once CRP_PLUGIN_DIR . 'includes/i10n.php';
244
+ require_once CRP_PLUGIN_DIR . 'includes/output-generator.php';
245
+ require_once CRP_PLUGIN_DIR . 'includes/media.php';
246
+ require_once CRP_PLUGIN_DIR . 'includes/tools.php';
247
+ require_once CRP_PLUGIN_DIR . 'includes/header.php';
248
+ require_once CRP_PLUGIN_DIR . 'includes/content.php';
249
+ require_once CRP_PLUGIN_DIR . 'includes/main-query.php';
250
+ require_once CRP_PLUGIN_DIR . 'includes/modules/manual-posts.php';
251
+ require_once CRP_PLUGIN_DIR . 'includes/modules/shortcode.php';
252
+ require_once CRP_PLUGIN_DIR . 'includes/modules/taxonomies.php';
253
+ require_once CRP_PLUGIN_DIR . 'includes/modules/exclusions.php';
254
+ require_once CRP_PLUGIN_DIR . 'includes/modules/class-crp-widget.php';
255
 
256
 
257
  /*
262
 
263
  if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
264
 
265
+ require_once CRP_PLUGIN_DIR . 'admin/admin.php';
266
+ require_once CRP_PLUGIN_DIR . 'admin/loader.php';
267
+ require_once CRP_PLUGIN_DIR . 'admin/metabox.php';
268
+ require_once CRP_PLUGIN_DIR . 'admin/cache.php';
269
 
270
  } // End if().
271
 
276
  *----------------------------------------------------------------------------
277
  */
278
 
279
+ require_once CRP_PLUGIN_DIR . 'includes/deprecated.php';
280
 
css/default-style.css CHANGED
@@ -43,16 +43,14 @@
43
  padding: 3px;
44
  color: #fff;
45
  font-size: .9em;
46
- text-shadow: 1000 .1em .1em .2em;
47
- background: rgb(0.5, 0.5, 0.5);
48
- background: rgba(0, 0, 0, 0.5);
49
  -webkit-border-radius: 7px;
50
  -moz-border-radius: 7px;
51
  border-radius: 7px;
52
  }
53
  .crp_related li:hover .crp_title {
54
- background: rgb(0.2, 0.2, 0.2);
55
- background: rgba(0, 0, 0, 0.8);
56
  }
57
  .crp_related li {
58
  vertical-align: bottom;
@@ -62,6 +60,7 @@
62
  -webkit-border-radius: 7px;
63
  -moz-border-radius: 7px;
64
  border-radius: 7px;
 
65
  }
66
  .crp_clear {
67
  clear: both;
43
  padding: 3px;
44
  color: #fff;
45
  font-size: .9em;
46
+ text-shadow: .1em .1em .2em #000;
47
+ background-color: rgba(0, 0, 0, 0.5);
 
48
  -webkit-border-radius: 7px;
49
  -moz-border-radius: 7px;
50
  border-radius: 7px;
51
  }
52
  .crp_related li:hover .crp_title {
53
+ background-color: rgba(0, 0, 0, 0.8);
 
54
  }
55
  .crp_related li {
56
  vertical-align: bottom;
60
  -webkit-border-radius: 7px;
61
  -moz-border-radius: 7px;
62
  border-radius: 7px;
63
+ list-style-type: none;
64
  }
65
  .crp_clear {
66
  clear: both;
includes/content.php CHANGED
@@ -3,10 +3,10 @@
3
  * Functions related to the content
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -46,10 +46,20 @@ function crp_content_filter( $content ) {
46
  return $content;
47
  }
48
 
 
 
 
 
 
 
 
 
 
 
49
  // If this post ID is in the DO NOT DISPLAY list.
50
  $exclude_on_post_ids = explode( ',', $crp_settings['exclude_on_post_ids'] );
51
  if ( in_array( $post->ID, $exclude_on_post_ids ) ) {
52
- return $content; // Exit without adding related posts.
53
  }
54
 
55
  // If this post type is in the DO NOT DISPLAY list.
@@ -57,11 +67,11 @@ function crp_content_filter( $content ) {
57
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
58
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
59
  } else {
60
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
61
  }
62
 
63
  if ( in_array( $post->post_type, $exclude_on_post_types, true ) ) {
64
- return $content; // Exit without adding related posts.
65
  }
66
  // If the DO NOT DISPLAY meta field is set.
67
  $crp_post_meta = get_post_meta( $post->ID, 'crp_post_meta', true );
@@ -100,7 +110,7 @@ function crp_content_filter( $content ) {
100
  * @since 2.3.0
101
  *
102
  * @param string $content Post content.
103
- * @param string $crp_code CRP generated code.
104
  * @return string After the filter has been processed
105
  */
106
  function crp_generate_content( $content, $crp_code ) {
@@ -122,12 +132,12 @@ function crp_generate_content( $content, $crp_code ) {
122
  * @since 2.3.0
123
  *
124
  * @param string $content Post content.
125
- * @param string $crp_code CRP generated code.
126
  * @param string $paragraph_id Paragraph number to insert after.
127
  * @return string After the filter has been processed
128
  */
129
  function crp_insert_after_paragraph( $content, $crp_code, $paragraph_id ) {
130
- $closing_p = '</p>';
131
  $paragraphs = explode( $closing_p, $content );
132
 
133
  if ( count( $paragraphs ) >= $paragraph_id ) {
@@ -153,18 +163,18 @@ function crp_insert_after_paragraph( $content, $crp_code, $paragraph_id ) {
153
  *
154
  * @since 1.8.4
155
  *
156
- * @param string $content Post content.
157
- * @return string Formatted content
158
  */
159
  function crp_rss_filter( $content ) {
160
  global $crp_settings;
161
 
162
- $limit_feed = $crp_settings['limit_feed'];
163
- $show_excerpt_feed = $crp_settings['show_excerpt_feed'];
164
  $post_thumb_op_feed = $crp_settings['post_thumb_op_feed'];
165
 
166
  if ( $crp_settings['add_to_feed'] ) {
167
- $output = $content;
168
  $output .= get_crp( 'is_widget=0&limit=' . $limit_feed . '&show_excerpt=' . $show_excerpt_feed . '&post_thumb_op=' . $post_thumb_op_feed );
169
  return $output;
170
  } else {
3
  * Functions related to the content
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
46
  return $content;
47
  }
48
 
49
+ // Return if this is a mobile device and disable on mobile option is enabled.
50
+ if ( wp_is_mobile() && $crp_settings['disable_on_mobile'] ) {
51
+ return $content;
52
+ }
53
+
54
+ // Return if this is an amp page and disable on amp option is enabled.
55
+ if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() && $crp_settings['disable_on_amp'] ) {
56
+ return $content;
57
+ }
58
+
59
  // If this post ID is in the DO NOT DISPLAY list.
60
  $exclude_on_post_ids = explode( ',', $crp_settings['exclude_on_post_ids'] );
61
  if ( in_array( $post->ID, $exclude_on_post_ids ) ) {
62
+ return $content; // Exit without adding related posts.
63
  }
64
 
65
  // If this post type is in the DO NOT DISPLAY list.
67
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
68
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
69
  } else {
70
+ parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
71
  }
72
 
73
  if ( in_array( $post->post_type, $exclude_on_post_types, true ) ) {
74
+ return $content; // Exit without adding related posts.
75
  }
76
  // If the DO NOT DISPLAY meta field is set.
77
  $crp_post_meta = get_post_meta( $post->ID, 'crp_post_meta', true );
110
  * @since 2.3.0
111
  *
112
  * @param string $content Post content.
113
+ * @param string $crp_code CRP generated code.
114
  * @return string After the filter has been processed
115
  */
116
  function crp_generate_content( $content, $crp_code ) {
132
  * @since 2.3.0
133
  *
134
  * @param string $content Post content.
135
+ * @param string $crp_code CRP generated code.
136
  * @param string $paragraph_id Paragraph number to insert after.
137
  * @return string After the filter has been processed
138
  */
139
  function crp_insert_after_paragraph( $content, $crp_code, $paragraph_id ) {
140
+ $closing_p = '</p>';
141
  $paragraphs = explode( $closing_p, $content );
142
 
143
  if ( count( $paragraphs ) >= $paragraph_id ) {
163
  *
164
  * @since 1.8.4
165
  *
166
+ * @param string $content Post content.
167
+ * @return string Formatted content
168
  */
169
  function crp_rss_filter( $content ) {
170
  global $crp_settings;
171
 
172
+ $limit_feed = $crp_settings['limit_feed'];
173
+ $show_excerpt_feed = $crp_settings['show_excerpt_feed'];
174
  $post_thumb_op_feed = $crp_settings['post_thumb_op_feed'];
175
 
176
  if ( $crp_settings['add_to_feed'] ) {
177
+ $output = $content;
178
  $output .= get_crp( 'is_widget=0&limit=' . $limit_feed . '&show_excerpt=' . $show_excerpt_feed . '&post_thumb_op=' . $post_thumb_op_feed );
179
  return $output;
180
  } else {
includes/deprecated.php CHANGED
@@ -10,7 +10,7 @@
10
  /**
11
  * Holds the URL for CRP
12
  *
13
- * @since 1.2
14
  * @deprecated 2.3.0
15
  *
16
  * @var string
@@ -23,7 +23,7 @@ $crp_url = plugins_url() . '/' . plugin_basename( dirname( __FILE__ ) );
23
  * @since 1.8.6
24
  *
25
  * @deprecated v2.0.0
26
- * @see get_crp_posts_id
27
  *
28
  * @param int $postid (default: FALSE) The post ID for which you want the posts for.
29
  * @param int $limit (default: FALSE) Maximum posts to retreive.
@@ -34,18 +34,20 @@ function get_crp_posts( $postid = false, $limit = false, $strict_limit = true )
34
 
35
  _deprecated_function( __FUNCTION__, '2.0.0', 'get_crp_posts_id()' );
36
 
37
- $results = get_crp_posts_id( array(
38
- 'postid' => $postid,
39
- 'limit' => $limit,
40
- 'strict_limit' => $strict_limit,
41
- ) );
 
 
42
 
43
  /**
44
  * Filter object containing the post IDs.
45
  *
46
- * @since 1.9
47
  *
48
- * @param object $results Object containing the related post IDs
49
  */
50
  return apply_filters( 'get_crp_posts', $results );
51
  }
@@ -55,11 +57,11 @@ function get_crp_posts( $postid = false, $limit = false, $strict_limit = true )
55
  * Main function to generate the related posts output
56
  *
57
  * @since 1.0.1
58
- * @deprecated 2.2.0
59
- * @see get_crp
60
  *
61
- * @param array $args Parameters in a query string format.
62
- * @return string HTML formatted list of related posts
63
  */
64
  function ald_crp( $args = array() ) {
65
 
@@ -70,10 +72,10 @@ function ald_crp( $args = array() ) {
70
  /**
71
  * Filter the output
72
  *
73
- * @since 1.9.1
74
  *
75
- * @param string $output Formatted list of related posts
76
- * @param array $args Complete set of arguments
77
  */
78
  return apply_filters( 'ald_crp', $output, $args );
79
  }
@@ -83,8 +85,8 @@ function ald_crp( $args = array() ) {
83
  * Filter for 'the_content' to add the related posts.
84
  *
85
  * @since 1.0.1
86
- * @deprecated 2.2.0
87
- * @see crp_content_filter
88
  *
89
  * @param string $content Post content.
90
  * @return string After the filter has been processed
@@ -101,11 +103,11 @@ function ald_crp_content( $content ) {
101
  * Filter to add related posts to feeds.
102
  *
103
  * @since 1.8.4
104
- * @deprecated 2.2.0
105
- * @see crp_rss_filter
106
  *
107
- * @param string $content Post content.
108
- * @return string Formatted content
109
  */
110
  function ald_crp_rss( $content ) {
111
 
@@ -119,8 +121,8 @@ function ald_crp_rss( $content ) {
119
  * Manual install of the related posts.
120
  *
121
  * @since 1.0.1
122
- * @deprecated 2.2.0
123
- * @see echo_crp
124
  *
125
  * @param string $args Array of arguments.
126
  */
@@ -137,9 +139,9 @@ function echo_ald_crp( $args = array() ) {
137
  * @since 1.8.4
138
  * @deprecated 2.4.0
139
  *
140
- * @param string $content Content to be used to make an excerpt.
141
- * @param int $no_of_char Maximum length of excerpt in characters.
142
- * @return string Formatted content.
143
  */
144
  function crp_max_formatted_content( $content, $no_of_char = -1 ) {
145
 
@@ -150,11 +152,11 @@ function crp_max_formatted_content( $content, $no_of_char = -1 ) {
150
  /**
151
  * Filters formatted content after cropping.
152
  *
153
- * @since 1.9
154
  *
155
- * @param string $content Formatted content
156
- * @param int $no_of_char Maximum length of excerpt in characters
157
  */
158
- return apply_filters( 'crp_max_formatted_content' , $content, $no_of_char );
159
  }
160
 
10
  /**
11
  * Holds the URL for CRP
12
  *
13
+ * @since 1.2
14
  * @deprecated 2.3.0
15
  *
16
  * @var string
23
  * @since 1.8.6
24
  *
25
  * @deprecated v2.0.0
26
+ * @see get_crp_posts_id
27
  *
28
  * @param int $postid (default: FALSE) The post ID for which you want the posts for.
29
  * @param int $limit (default: FALSE) Maximum posts to retreive.
34
 
35
  _deprecated_function( __FUNCTION__, '2.0.0', 'get_crp_posts_id()' );
36
 
37
+ $results = get_crp_posts_id(
38
+ array(
39
+ 'postid' => $postid,
40
+ 'limit' => $limit,
41
+ 'strict_limit' => $strict_limit,
42
+ )
43
+ );
44
 
45
  /**
46
  * Filter object containing the post IDs.
47
  *
48
+ * @since 1.9
49
  *
50
+ * @param object $results Object containing the related post IDs
51
  */
52
  return apply_filters( 'get_crp_posts', $results );
53
  }
57
  * Main function to generate the related posts output
58
  *
59
  * @since 1.0.1
60
+ * @deprecated 2.2.0
61
+ * @see get_crp
62
  *
63
+ * @param array $args Parameters in a query string format.
64
+ * @return string HTML formatted list of related posts
65
  */
66
  function ald_crp( $args = array() ) {
67
 
72
  /**
73
  * Filter the output
74
  *
75
+ * @since 1.9.1
76
  *
77
+ * @param string $output Formatted list of related posts
78
+ * @param array $args Complete set of arguments
79
  */
80
  return apply_filters( 'ald_crp', $output, $args );
81
  }
85
  * Filter for 'the_content' to add the related posts.
86
  *
87
  * @since 1.0.1
88
+ * @deprecated 2.2.0
89
+ * @see crp_content_filter
90
  *
91
  * @param string $content Post content.
92
  * @return string After the filter has been processed
103
  * Filter to add related posts to feeds.
104
  *
105
  * @since 1.8.4
106
+ * @deprecated 2.2.0
107
+ * @see crp_rss_filter
108
  *
109
+ * @param string $content Post content.
110
+ * @return string Formatted content
111
  */
112
  function ald_crp_rss( $content ) {
113
 
121
  * Manual install of the related posts.
122
  *
123
  * @since 1.0.1
124
+ * @deprecated 2.2.0
125
+ * @see echo_crp
126
  *
127
  * @param string $args Array of arguments.
128
  */
139
  * @since 1.8.4
140
  * @deprecated 2.4.0
141
  *
142
+ * @param string $content Content to be used to make an excerpt.
143
+ * @param int $no_of_char Maximum length of excerpt in characters.
144
+ * @return string Formatted content.
145
  */
146
  function crp_max_formatted_content( $content, $no_of_char = -1 ) {
147
 
152
  /**
153
  * Filters formatted content after cropping.
154
  *
155
+ * @since 1.9
156
  *
157
+ * @param string $content Formatted content
158
+ * @param int $no_of_char Maximum length of excerpt in characters
159
  */
160
+ return apply_filters( 'crp_max_formatted_content', $content, $no_of_char );
161
  }
162
 
includes/header.php CHANGED
@@ -3,10 +3,10 @@
3
  * Functions related to the header
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -28,7 +28,7 @@ function crp_header() {
28
  if ( '' != $custom_css ) {
29
  if ( ( is_single() ) ) {
30
  echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
31
- } elseif ( (is_page()) ) {
32
  echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
33
  } elseif ( ( is_home() ) && ( $crp_settings['add_to_home'] ) ) {
34
  echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
3
  * Functions related to the header
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
28
  if ( '' != $custom_css ) {
29
  if ( ( is_single() ) ) {
30
  echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
31
+ } elseif ( ( is_page() ) ) {
32
  echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
33
  } elseif ( ( is_home() ) && ( $crp_settings['add_to_home'] ) ) {
34
  echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
includes/i10n.php CHANGED
@@ -8,7 +8,7 @@
8
  /**
9
  * Initialises text domain for l10n.
10
  *
11
- * @since 2.2.0
12
  */
13
  function crp_lang_init() {
14
  load_plugin_textdomain( 'contextual-related-posts', false, dirname( plugin_basename( CRP_PLUGIN_FILE ) ) . '/languages/' );
@@ -19,7 +19,7 @@ add_action( 'plugins_loaded', 'crp_lang_init' );
19
  /**
20
  * Returns the object identifier for the current language (WPML).
21
  *
22
- * @since 2.1.0
23
  *
24
  * @param int|string $post_id Post ID.
25
  */
@@ -30,10 +30,10 @@ function crp_object_id_cur_lang( $post_id ) {
30
  /**
31
  * Filter to modify if the original language ID is returned.
32
  *
33
- * @since 2.2.3
34
  *
35
- * @param bool $return_original_if_missing
36
- * @param int $post_id Post ID
37
  */
38
  $return_original_if_missing = apply_filters( 'crp_wpml_return_original', $return_original_if_missing, $post_id );
39
 
@@ -48,9 +48,9 @@ function crp_object_id_cur_lang( $post_id ) {
48
  /**
49
  * Filters object ID for current language (WPML).
50
  *
51
- * @since 2.1.0
52
  *
53
- * @param int $post_id Post ID
54
  */
55
  return apply_filters( 'crp_object_id_cur_lang', $post_id );
56
  }
8
  /**
9
  * Initialises text domain for l10n.
10
  *
11
+ * @since 2.2.0
12
  */
13
  function crp_lang_init() {
14
  load_plugin_textdomain( 'contextual-related-posts', false, dirname( plugin_basename( CRP_PLUGIN_FILE ) ) . '/languages/' );
19
  /**
20
  * Returns the object identifier for the current language (WPML).
21
  *
22
+ * @since 2.1.0
23
  *
24
  * @param int|string $post_id Post ID.
25
  */
30
  /**
31
  * Filter to modify if the original language ID is returned.
32
  *
33
+ * @since 2.2.3
34
  *
35
+ * @param bool $return_original_if_missing
36
+ * @param int $post_id Post ID
37
  */
38
  $return_original_if_missing = apply_filters( 'crp_wpml_return_original', $return_original_if_missing, $post_id );
39
 
48
  /**
49
  * Filters object ID for current language (WPML).
50
  *
51
+ * @since 2.1.0
52
  *
53
+ * @param int $post_id Post ID
54
  */
55
  return apply_filters( 'crp_object_id_cur_lang', $post_id );
56
  }
includes/main-query.php CHANGED
@@ -3,10 +3,10 @@
3
  * Functions related to the header
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -27,16 +27,16 @@ function get_crp( $args = array() ) {
27
 
28
  // If set, save $exclude_categories.
29
  if ( isset( $args['exclude_categories'] ) && '' != $args['exclude_categories'] ) {
30
- $exclude_categories = explode( ',', $args['exclude_categories'] );
31
  $args['strict_limit'] = false;
32
  }
33
  $defaults = array(
34
- 'is_widget' => false,
35
  'is_shortcode' => false,
36
- 'is_manual' => false,
37
- 'echo' => true,
38
- 'heading' => true,
39
- 'offset' => 0,
40
  );
41
  $defaults = array_merge( $defaults, $crp_settings );
42
 
@@ -67,20 +67,25 @@ function get_crp( $args = array() ) {
67
  }
68
 
69
  // Retrieve the list of posts.
70
- $results = get_crp_posts_id( array_merge( $args, array(
71
- 'postid' => $post->ID,
72
- 'strict_limit' => isset( $args['strict_limit'] ) ? $args['strict_limit'] : true,
73
- ) ) );
 
 
 
 
 
74
 
75
  /**
76
  * Filter to create a custom HTML output
77
  *
78
  * @since 2.2.3
79
  *
80
- * @param mixed Default return value
81
- * @param array $results Array of IDs of related posts
82
- * @param array $args Array of settings
83
- * @return string Custom HTML formatted list of related posts
84
  */
85
  $custom_template = apply_filters( 'crp_custom_template', null, $results, $args );
86
  if ( ! empty( $custom_template ) ) {
@@ -90,7 +95,7 @@ function get_crp( $args = array() ) {
90
  return $custom_template;
91
  }
92
 
93
- $widget_class = $args['is_widget'] ? 'crp_related_widget' : 'crp_related ';
94
  $shortcode_class = $args['is_shortcode'] ? 'crp_related_shortcode ' : '';
95
 
96
  $post_classes = $widget_class . $shortcode_class;
@@ -98,9 +103,9 @@ function get_crp( $args = array() ) {
98
  /**
99
  * Filter the classes added to the div wrapper of the Contextual Related Posts.
100
  *
101
- * @since 2.2.3
102
  *
103
- * @param string $post_classes Post classes string.
104
  */
105
  $post_classes = apply_filters( 'crp_post_class', $post_classes );
106
 
@@ -132,27 +137,28 @@ function get_crp( $args = array() ) {
132
  /**
133
  * Filter the post ID for each result. Allows a custom function to hook in and change the ID if needed.
134
  *
135
- * @since 1.9
136
  *
137
- * @param int $resultid ID of the post
138
  */
139
  $resultid = apply_filters( 'crp_post_id', $resultid );
140
 
141
- $result = get_post( $resultid ); // Let's get the Post using the ID.
142
 
143
  // Process the category exclusion if passed in the shortcode.
144
  if ( isset( $exclude_categories ) ) {
145
 
146
- $categorys = get_the_category( $result->ID ); // Fetch categories of the plugin.
147
 
148
- $p_in_c = false; // Variable to check if post exists in a particular category
149
- foreach ( $categorys as $cat ) { // Loop to check if post exists in excluded category.
150
  $p_in_c = ( in_array( $cat->cat_ID, $exclude_categories, true ) ) ? true : false;
151
  if ( $p_in_c ) {
152
- break; // Skip loop execution and go to the next step.
153
  }
154
  }
155
- if ( $p_in_c ) { continue; // Skip loop execution and go to the next step.
 
156
  }
157
  }
158
 
@@ -177,9 +183,9 @@ function get_crp( $args = array() ) {
177
  $output .= crp_after_list_item( $args, $result );
178
 
179
  if ( absint( $args['limit'] ) === $loop_counter ) {
180
- break; // End loop when related posts limit is reached.
181
  }
182
- } // End foreach().
183
 
184
  if ( $args['show_credit'] ) {
185
 
@@ -199,19 +205,19 @@ function get_crp( $args = array() ) {
199
  /**
200
  * Filter the clearfix div tag. This is included after the closing tag to clear any miscellaneous floating elements;
201
  *
202
- * @since 2.0.0
203
  *
204
- * @param string $clearfix Contains: <div style="clear:both"></div>
205
  */
206
  $output .= apply_filters( 'crp_clearfix', $clearfix );
207
 
208
  } else {
209
  $output .= ( $args['blank_output'] ) ? ' ' : '<p>' . $args['blank_output_text'] . '</p>';
210
- }// End if().
211
 
212
  // Check if the opening list tag is missing in the output, it means all of our results were eliminated cause of the category filter.
213
  if ( false === ( strpos( $output, $args['before_list_item'] ) ) ) {
214
- $output = '<div id="crp_related">';
215
  $output .= ( $args['blank_output'] ) ? ' ' : '<p>' . $args['blank_output_text'] . '</p>';
216
  }
217
 
@@ -225,10 +231,10 @@ function get_crp( $args = array() ) {
225
  /**
226
  * Filter the output
227
  *
228
- * @since 1.9.1
229
  *
230
- * @param string $output Formatted list of related posts
231
- * @param array $args Complete set of arguments
232
  */
233
  return apply_filters( 'get_crp', $output, $args );
234
  }
@@ -246,19 +252,19 @@ function get_crp_posts_id( $args = array() ) {
246
  global $wpdb, $post, $crp_settings;
247
 
248
  // Initialise some variables.
249
- $fields = '';
250
- $where = '';
251
- $join = '';
252
- $groupby = '';
253
- $orderby = '';
254
- $having = '';
255
- $limits = '';
256
  $match_fields = '';
257
 
258
  $defaults = array(
259
- 'postid' => false, // Get related posts for a specific post ID.
260
- 'strict_limit' => true, // If this is set to false, then it will fetch 5x posts.
261
- 'offset' => 0, // Offset the related posts returned by this number.
262
  );
263
  $defaults = array_merge( $defaults, $crp_settings );
264
 
@@ -269,7 +275,7 @@ function get_crp_posts_id( $args = array() ) {
269
  $crp_thumb_size = crp_get_all_image_sizes( $args['thumb_size'] );
270
 
271
  if ( isset( $crp_thumb_size['width'] ) ) {
272
- $thumb_width = $crp_thumb_size['width'];
273
  $thumb_height = $crp_thumb_size['height'];
274
  }
275
 
@@ -283,21 +289,27 @@ function get_crp_posts_id( $args = array() ) {
283
 
284
  $source_post = ( empty( $args['postid'] ) ) ? $post : get_post( $args['postid'] );
285
 
286
- $limit = ( $args['strict_limit'] ) ? $args['limit'] : ( $args['limit'] * 3 );
 
 
 
 
287
  $offset = isset( $args['offset'] ) ? $args['offset'] : 0;
288
 
289
  // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
290
  if ( ! empty( $args['post_types'] ) && false === strpos( $args['post_types'], '=' ) ) {
291
  $post_types = explode( ',', $args['post_types'] );
292
  } else {
293
- parse_str( $args['post_types'], $post_types ); // Save post types in $post_types variable.
294
  }
295
 
296
  // If post_types is empty or if we want all the post types.
297
  if ( empty( $post_types ) || 'all' === $args['post_types'] ) {
298
- $post_types = get_post_types( array(
299
- 'public' => true,
300
- ) );
 
 
301
  }
302
 
303
  // If we only want posts from the same post type.
@@ -326,42 +338,42 @@ function get_crp_posts_id( $args = array() ) {
326
  );
327
 
328
  if ( $args['match_content'] ) {
329
- $match_fields[] = 'post_content';
330
  $match_fields_content[] = crp_excerpt( $source_post->ID, $args['match_content_words'], false );
331
  }
332
 
333
  /**
334
  * Filter the fields that are to be matched.
335
  *
336
- * @since 2.2.0
337
  *
338
- * @param array $match_fields Array of fields to be matched
339
- * @param int $source_post->ID Post ID
340
  */
341
  $match_fields = apply_filters( 'crp_posts_match_fields', $match_fields, $source_post->ID );
342
 
343
  /**
344
  * Filter the content of the fields that are to be matched.
345
  *
346
- * @since 2.2.0
347
  *
348
- * @param array $match_fields_content Array of content of fields to be matched
349
- * @param int $source_post->ID Post ID
350
  */
351
  $match_fields_content = apply_filters( 'crp_posts_match_fields_content', $match_fields_content, $source_post->ID );
352
 
353
  // Convert our arrays into their corresponding strings after they have been filtered.
354
  $match_fields = implode( ',', $match_fields );
355
- $stuff = implode( ' ', $match_fields_content );
356
 
357
  // Make sure the post is not from the future.
358
  $time_difference = get_option( 'gmt_offset' );
359
- $now = gmdate( 'Y-m-d H:i:s', ( time() + ( $time_difference * 3600 ) ) );
360
 
361
  // Limit the related posts by time.
362
  $current_time = current_time( 'timestamp', 0 );
363
- $from_date = $current_time - ( $args['daily_range'] * DAY_IN_SECONDS );
364
- $from_date = gmdate( 'Y-m-d H:i:s' , $from_date );
365
 
366
  // Create the SQL query to fetch the related posts from the database.
367
  if ( is_int( $source_post->ID ) ) {
@@ -370,51 +382,51 @@ function get_crp_posts_id( $args = array() ) {
370
  $fields = " $wpdb->posts.ID ";
371
 
372
  // Create the base MATCH clause.
373
- $match = $wpdb->prepare( ' AND MATCH (' . $match_fields . ") AGAINST ('%s') ", $stuff );
374
 
375
  /**
376
  * Filter the MATCH clause of the query.
377
  *
378
- * @since 2.1.0
379
  *
380
- * @param string $match The MATCH section of the WHERE clause of the query
381
- * @param string $stuff String to match fulltext with
382
- * @param int $source_post->ID Post ID
383
  */
384
  $match = apply_filters( 'crp_posts_match', $match, $stuff, $source_post->ID );
385
 
386
  // Create the maximum date limit. Show posts before today.
387
- $now_clause = $wpdb->prepare( " AND $wpdb->posts.post_date < '%s' ", $now );
388
 
389
  /**
390
  * Filter the Maximum date clause of the query.
391
  *
392
- * @since 2.1.0
393
  *
394
  * @param string $now_clause The Maximum date of the WHERE clause of the query.
395
- * @param int $source_post->ID Post ID
396
  */
397
  $now_clause = apply_filters( 'crp_posts_now_date', $now_clause, $source_post->ID );
398
 
399
  // Create the minimum date limit. Show posts after the date specified.
400
- $from_clause = ( 0 == $args['daily_range'] ) ? '' : $wpdb->prepare( " AND $wpdb->posts.post_date >= '%s' ", $from_date );
401
 
402
  /**
403
  * Filter the Maximum date clause of the query.
404
  *
405
- * @since 2.1.0
406
  *
407
  * @param string $from_clause The Minimum date of the WHERE clause of the query.
408
- * @param int $source_post->ID Post ID
409
  */
410
  $from_clause = apply_filters( 'crp_posts_from_date', $from_clause, $source_post->ID );
411
 
412
  // Create the base WHERE clause.
413
- $where = $match;
414
  $where .= $now_clause;
415
  $where .= $from_clause;
416
- $where .= " AND $wpdb->posts.post_status = 'publish' "; // Only show published posts
417
- $where .= $wpdb->prepare( " AND {$wpdb->posts}.ID != %d ", $source_post->ID ); // Show posts after the date specified.
418
 
419
  // Convert exclude post IDs string to array so it can be filtered.
420
  $exclude_post_ids = explode( ',', $args['exclude_post_ids'] );
@@ -435,7 +447,7 @@ function get_crp_posts_id( $args = array() ) {
435
  $where .= " AND $wpdb->posts.ID NOT IN ({$exclude_post_ids}) ";
436
  }
437
 
438
- $where .= " AND $wpdb->posts.post_type IN ('" . join( "', '", $post_types ) . "') "; // Array of post types.
439
 
440
  // Create the base LIMITS clause.
441
  $limits .= $wpdb->prepare( ' LIMIT %d, %d ', $offset, $limit );
@@ -443,70 +455,70 @@ function get_crp_posts_id( $args = array() ) {
443
  /**
444
  * Filter the SELECT clause of the query.
445
  *
446
- * @since 2.0.0
447
  *
448
  * @param string $fields The SELECT clause of the query.
449
- * @param int $source_post->ID Post ID
450
  */
451
  $fields = apply_filters( 'crp_posts_fields', $fields, $source_post->ID );
452
 
453
  /**
454
  * Filter the JOIN clause of the query.
455
  *
456
- * @since 2.0.0
457
  *
458
  * @param string $join The JOIN clause of the query.
459
- * @param int $source_post->ID Post ID
460
  */
461
  $join = apply_filters( 'crp_posts_join', $join, $source_post->ID );
462
 
463
  /**
464
  * Filter the WHERE clause of the query.
465
  *
466
- * @since 2.0.0
467
  *
468
  * @param string $where The WHERE clause of the query.
469
- * @param int $source_post->ID Post ID
470
  */
471
  $where = apply_filters( 'crp_posts_where', $where, $source_post->ID );
472
 
473
  /**
474
  * Filter the GROUP BY clause of the query.
475
  *
476
- * @since 2.0.0
477
  *
478
  * @param string $groupby The GROUP BY clause of the query.
479
- * @param int $source_post->ID Post ID
480
  */
481
  $groupby = apply_filters( 'crp_posts_groupby', $groupby, $source_post->ID );
482
 
483
  /**
484
  * Filter the HAVING clause of the query.
485
  *
486
- * @since 2.2.0
487
  *
488
  * @param string $having The HAVING clause of the query.
489
- * @param int $source_post->ID Post ID
490
  */
491
  $having = apply_filters( 'crp_posts_having', $having, $source_post->ID );
492
 
493
  /**
494
  * Filter the ORDER BY clause of the query.
495
  *
496
- * @since 2.0.0
497
  *
498
  * @param string $orderby The ORDER BY clause of the query.
499
- * @param int $source_post->ID Post ID
500
  */
501
  $orderby = apply_filters( 'crp_posts_orderby', $orderby, $source_post->ID );
502
 
503
  /**
504
  * Filter the LIMIT clause of the query.
505
  *
506
- * @since 2.0.0
507
  *
508
  * @param string $limits The LIMIT clause of the query.
509
- * @param int $source_post->ID Post ID
510
  */
511
  $limits = apply_filters( 'crp_posts_limits', $limits, $source_post->ID );
512
 
@@ -524,7 +536,7 @@ function get_crp_posts_id( $args = array() ) {
524
 
525
  $sql = "SELECT DISTINCT $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $having $orderby $limits";
526
 
527
- $results = $wpdb->get_results( $sql );
528
 
529
  if ( $args['random_order'] ) {
530
  $results_array = (array) $results;
@@ -533,14 +545,14 @@ function get_crp_posts_id( $args = array() ) {
533
  }
534
  } else {
535
  $results = false;
536
- }// End if().
537
 
538
  /**
539
  * Filter object containing the post IDs.
540
  *
541
- * @since 1.9
542
  *
543
- * @param object $results Object containing the related post IDs
544
  */
545
  return apply_filters( 'get_crp_posts_id', $results );
546
  }
3
  * Functions related to the header
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
27
 
28
  // If set, save $exclude_categories.
29
  if ( isset( $args['exclude_categories'] ) && '' != $args['exclude_categories'] ) {
30
+ $exclude_categories = explode( ',', $args['exclude_categories'] );
31
  $args['strict_limit'] = false;
32
  }
33
  $defaults = array(
34
+ 'is_widget' => false,
35
  'is_shortcode' => false,
36
+ 'is_manual' => false,
37
+ 'echo' => true,
38
+ 'heading' => true,
39
+ 'offset' => 0,
40
  );
41
  $defaults = array_merge( $defaults, $crp_settings );
42
 
67
  }
68
 
69
  // Retrieve the list of posts.
70
+ $results = get_crp_posts_id(
71
+ array_merge(
72
+ $args,
73
+ array(
74
+ 'postid' => $post->ID,
75
+ 'strict_limit' => isset( $args['strict_limit'] ) ? $args['strict_limit'] : true,
76
+ )
77
+ )
78
+ );
79
 
80
  /**
81
  * Filter to create a custom HTML output
82
  *
83
  * @since 2.2.3
84
  *
85
+ * @param mixed Default return value
86
+ * @param array $results Array of IDs of related posts
87
+ * @param array $args Array of settings
88
+ * @return string Custom HTML formatted list of related posts
89
  */
90
  $custom_template = apply_filters( 'crp_custom_template', null, $results, $args );
91
  if ( ! empty( $custom_template ) ) {
95
  return $custom_template;
96
  }
97
 
98
+ $widget_class = $args['is_widget'] ? 'crp_related_widget' : 'crp_related ';
99
  $shortcode_class = $args['is_shortcode'] ? 'crp_related_shortcode ' : '';
100
 
101
  $post_classes = $widget_class . $shortcode_class;
103
  /**
104
  * Filter the classes added to the div wrapper of the Contextual Related Posts.
105
  *
106
+ * @since 2.2.3
107
  *
108
+ * @param string $post_classes Post classes string.
109
  */
110
  $post_classes = apply_filters( 'crp_post_class', $post_classes );
111
 
137
  /**
138
  * Filter the post ID for each result. Allows a custom function to hook in and change the ID if needed.
139
  *
140
+ * @since 1.9
141
  *
142
+ * @param int $resultid ID of the post
143
  */
144
  $resultid = apply_filters( 'crp_post_id', $resultid );
145
 
146
+ $result = get_post( $resultid ); // Let's get the Post using the ID.
147
 
148
  // Process the category exclusion if passed in the shortcode.
149
  if ( isset( $exclude_categories ) ) {
150
 
151
+ $categorys = get_the_category( $result->ID ); // Fetch categories of the plugin.
152
 
153
+ $p_in_c = false; // Variable to check if post exists in a particular category.
154
+ foreach ( $categorys as $cat ) { // Loop to check if post exists in excluded category.
155
  $p_in_c = ( in_array( $cat->cat_ID, $exclude_categories, true ) ) ? true : false;
156
  if ( $p_in_c ) {
157
+ break; // Skip loop execution and go to the next step.
158
  }
159
  }
160
+ if ( $p_in_c ) {
161
+ continue; // Skip loop execution and go to the next step.
162
  }
163
  }
164
 
183
  $output .= crp_after_list_item( $args, $result );
184
 
185
  if ( absint( $args['limit'] ) === $loop_counter ) {
186
+ break; // End loop when related posts limit is reached.
187
  }
188
+ } // End foreach.
189
 
190
  if ( $args['show_credit'] ) {
191
 
205
  /**
206
  * Filter the clearfix div tag. This is included after the closing tag to clear any miscellaneous floating elements;
207
  *
208
+ * @since 2.0.0
209
  *
210
+ * @param string $clearfix Contains: <div style="clear:both"></div>
211
  */
212
  $output .= apply_filters( 'crp_clearfix', $clearfix );
213
 
214
  } else {
215
  $output .= ( $args['blank_output'] ) ? ' ' : '<p>' . $args['blank_output_text'] . '</p>';
216
+ }// End if.
217
 
218
  // Check if the opening list tag is missing in the output, it means all of our results were eliminated cause of the category filter.
219
  if ( false === ( strpos( $output, $args['before_list_item'] ) ) ) {
220
+ $output = '<div id="crp_related">';
221
  $output .= ( $args['blank_output'] ) ? ' ' : '<p>' . $args['blank_output_text'] . '</p>';
222
  }
223
 
231
  /**
232
  * Filter the output
233
  *
234
+ * @since 1.9.1
235
  *
236
+ * @param string $output Formatted list of related posts
237
+ * @param array $args Complete set of arguments
238
  */
239
  return apply_filters( 'get_crp', $output, $args );
240
  }
252
  global $wpdb, $post, $crp_settings;
253
 
254
  // Initialise some variables.
255
+ $fields = '';
256
+ $where = '';
257
+ $join = '';
258
+ $groupby = '';
259
+ $orderby = '';
260
+ $having = '';
261
+ $limits = '';
262
  $match_fields = '';
263
 
264
  $defaults = array(
265
+ 'postid' => false, // Get related posts for a specific post ID.
266
+ 'strict_limit' => true, // If this is set to false, then it will fetch 5x posts.
267
+ 'offset' => 0, // Offset the related posts returned by this number.
268
  );
269
  $defaults = array_merge( $defaults, $crp_settings );
270
 
275
  $crp_thumb_size = crp_get_all_image_sizes( $args['thumb_size'] );
276
 
277
  if ( isset( $crp_thumb_size['width'] ) ) {
278
+ $thumb_width = $crp_thumb_size['width'];
279
  $thumb_height = $crp_thumb_size['height'];
280
  }
281
 
289
 
290
  $source_post = ( empty( $args['postid'] ) ) ? $post : get_post( $args['postid'] );
291
 
292
+ if ( ! $source_post ) {
293
+ $source_post = $post;
294
+ }
295
+
296
+ $limit = ( $args['strict_limit'] ) ? $args['limit'] : ( $args['limit'] * 3 );
297
  $offset = isset( $args['offset'] ) ? $args['offset'] : 0;
298
 
299
  // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
300
  if ( ! empty( $args['post_types'] ) && false === strpos( $args['post_types'], '=' ) ) {
301
  $post_types = explode( ',', $args['post_types'] );
302
  } else {
303
+ parse_str( $args['post_types'], $post_types ); // Save post types in $post_types variable.
304
  }
305
 
306
  // If post_types is empty or if we want all the post types.
307
  if ( empty( $post_types ) || 'all' === $args['post_types'] ) {
308
+ $post_types = get_post_types(
309
+ array(
310
+ 'public' => true,
311
+ )
312
+ );
313
  }
314
 
315
  // If we only want posts from the same post type.
338
  );
339
 
340
  if ( $args['match_content'] ) {
341
+ $match_fields[] = 'post_content';
342
  $match_fields_content[] = crp_excerpt( $source_post->ID, $args['match_content_words'], false );
343
  }
344
 
345
  /**
346
  * Filter the fields that are to be matched.
347
  *
348
+ * @since 2.2.0
349
  *
350
+ * @param array $match_fields Array of fields to be matched
351
+ * @param int $source_post->ID Post ID
352
  */
353
  $match_fields = apply_filters( 'crp_posts_match_fields', $match_fields, $source_post->ID );
354
 
355
  /**
356
  * Filter the content of the fields that are to be matched.
357
  *
358
+ * @since 2.2.0
359
  *
360
+ * @param array $match_fields_content Array of content of fields to be matched
361
+ * @param int $source_post->ID Post ID
362
  */
363
  $match_fields_content = apply_filters( 'crp_posts_match_fields_content', $match_fields_content, $source_post->ID );
364
 
365
  // Convert our arrays into their corresponding strings after they have been filtered.
366
  $match_fields = implode( ',', $match_fields );
367
+ $stuff = implode( ' ', $match_fields_content );
368
 
369
  // Make sure the post is not from the future.
370
  $time_difference = get_option( 'gmt_offset' );
371
+ $now = gmdate( 'Y-m-d H:i:s', ( time() + ( $time_difference * 3600 ) ) );
372
 
373
  // Limit the related posts by time.
374
  $current_time = current_time( 'timestamp', 0 );
375
+ $from_date = $current_time - ( absint( $args['daily_range'] ) * DAY_IN_SECONDS );
376
+ $from_date = gmdate( 'Y-m-d H:i:s', $from_date );
377
 
378
  // Create the SQL query to fetch the related posts from the database.
379
  if ( is_int( $source_post->ID ) ) {
382
  $fields = " $wpdb->posts.ID ";
383
 
384
  // Create the base MATCH clause.
385
+ $match = $wpdb->prepare( ' AND MATCH (' . $match_fields . ') AGAINST (%s) ', $stuff ); // WPCS: unprepared SQL ok.
386
 
387
  /**
388
  * Filter the MATCH clause of the query.
389
  *
390
+ * @since 2.1.0
391
  *
392
+ * @param string $match The MATCH section of the WHERE clause of the query
393
+ * @param string $stuff String to match fulltext with
394
+ * @param int $source_post->ID Post ID
395
  */
396
  $match = apply_filters( 'crp_posts_match', $match, $stuff, $source_post->ID );
397
 
398
  // Create the maximum date limit. Show posts before today.
399
+ $now_clause = $wpdb->prepare( " AND $wpdb->posts.post_date < %s ", $now );
400
 
401
  /**
402
  * Filter the Maximum date clause of the query.
403
  *
404
+ * @since 2.1.0
405
  *
406
  * @param string $now_clause The Maximum date of the WHERE clause of the query.
407
+ * @param int $source_post->ID Post ID
408
  */
409
  $now_clause = apply_filters( 'crp_posts_now_date', $now_clause, $source_post->ID );
410
 
411
  // Create the minimum date limit. Show posts after the date specified.
412
+ $from_clause = ( 0 === absint( $args['daily_range'] ) ) ? '' : $wpdb->prepare( " AND $wpdb->posts.post_date >= %s ", $from_date );
413
 
414
  /**
415
  * Filter the Maximum date clause of the query.
416
  *
417
+ * @since 2.1.0
418
  *
419
  * @param string $from_clause The Minimum date of the WHERE clause of the query.
420
+ * @param int $source_post->ID Post ID
421
  */
422
  $from_clause = apply_filters( 'crp_posts_from_date', $from_clause, $source_post->ID );
423
 
424
  // Create the base WHERE clause.
425
+ $where = $match;
426
  $where .= $now_clause;
427
  $where .= $from_clause;
428
+ $where .= " AND $wpdb->posts.post_status = 'publish' "; // Only show published posts.
429
+ $where .= $wpdb->prepare( " AND {$wpdb->posts}.ID != %d ", $source_post->ID ); // Show posts after the date specified.
430
 
431
  // Convert exclude post IDs string to array so it can be filtered.
432
  $exclude_post_ids = explode( ',', $args['exclude_post_ids'] );
447
  $where .= " AND $wpdb->posts.ID NOT IN ({$exclude_post_ids}) ";
448
  }
449
 
450
+ $where .= " AND $wpdb->posts.post_type IN ('" . join( "', '", $post_types ) . "') "; // Array of post types.
451
 
452
  // Create the base LIMITS clause.
453
  $limits .= $wpdb->prepare( ' LIMIT %d, %d ', $offset, $limit );
455
  /**
456
  * Filter the SELECT clause of the query.
457
  *
458
+ * @since 2.0.0
459
  *
460
  * @param string $fields The SELECT clause of the query.
461
+ * @param int $source_post->ID Post ID
462
  */
463
  $fields = apply_filters( 'crp_posts_fields', $fields, $source_post->ID );
464
 
465
  /**
466
  * Filter the JOIN clause of the query.
467
  *
468
+ * @since 2.0.0
469
  *
470
  * @param string $join The JOIN clause of the query.
471
+ * @param int $source_post->ID Post ID
472
  */
473
  $join = apply_filters( 'crp_posts_join', $join, $source_post->ID );
474
 
475
  /**
476
  * Filter the WHERE clause of the query.
477
  *
478
+ * @since 2.0.0
479
  *
480
  * @param string $where The WHERE clause of the query.
481
+ * @param int $source_post->ID Post ID
482
  */
483
  $where = apply_filters( 'crp_posts_where', $where, $source_post->ID );
484
 
485
  /**
486
  * Filter the GROUP BY clause of the query.
487
  *
488
+ * @since 2.0.0
489
  *
490
  * @param string $groupby The GROUP BY clause of the query.
491
+ * @param int $source_post->ID Post ID
492
  */
493
  $groupby = apply_filters( 'crp_posts_groupby', $groupby, $source_post->ID );
494
 
495
  /**
496
  * Filter the HAVING clause of the query.
497
  *
498
+ * @since 2.2.0
499
  *
500
  * @param string $having The HAVING clause of the query.
501
+ * @param int $source_post->ID Post ID
502
  */
503
  $having = apply_filters( 'crp_posts_having', $having, $source_post->ID );
504
 
505
  /**
506
  * Filter the ORDER BY clause of the query.
507
  *
508
+ * @since 2.0.0
509
  *
510
  * @param string $orderby The ORDER BY clause of the query.
511
+ * @param int $source_post->ID Post ID
512
  */
513
  $orderby = apply_filters( 'crp_posts_orderby', $orderby, $source_post->ID );
514
 
515
  /**
516
  * Filter the LIMIT clause of the query.
517
  *
518
+ * @since 2.0.0
519
  *
520
  * @param string $limits The LIMIT clause of the query.
521
+ * @param int $source_post->ID Post ID
522
  */
523
  $limits = apply_filters( 'crp_posts_limits', $limits, $source_post->ID );
524
 
536
 
537
  $sql = "SELECT DISTINCT $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $having $orderby $limits";
538
 
539
+ $results = $wpdb->get_results( $sql ); // WPCS: unprepared SQL ok.
540
 
541
  if ( $args['random_order'] ) {
542
  $results_array = (array) $results;
545
  }
546
  } else {
547
  $results = false;
548
+ }// End if.
549
 
550
  /**
551
  * Filter object containing the post IDs.
552
  *
553
+ * @since 1.9
554
  *
555
+ * @param object $results Object containing the related post IDs
556
  */
557
  return apply_filters( 'get_crp_posts_id', $results );
558
  }
includes/media.php CHANGED
@@ -3,10 +3,10 @@
3
  * Image handling functions
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  /**
@@ -23,9 +23,9 @@ function crp_add_image_sizes() {
23
 
24
  // Add image sizes if 'crp_thumbnail' is selected or the selected thumbnail size is no longer valid.
25
  if ( 'crp_thumbnail' === $crp_settings['thumb_size'] ) {
26
- $width = empty( $crp_settings['thumb_width'] ) ? 150 : $crp_settings['thumb_width'];
27
  $height = empty( $crp_settings['thumb_height'] ) ? 150 : $crp_settings['thumb_height'];
28
- $crop = isset( $crp_settings['thumb_crop'] ) ? $crp_settings['thumb_crop'] : false;
29
 
30
  add_image_size( 'crp_thumbnail', $width, $height, $crop );
31
  }
@@ -46,15 +46,15 @@ function crp_get_the_post_thumbnail( $args = array() ) {
46
  global $crp_settings;
47
 
48
  $defaults = array(
49
- 'postid' => '',
50
- 'thumb_height' => '150', // Max height of thumbnails.
51
- 'thumb_width' => '150', // Max width of thumbnails.
52
- 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
53
- 'thumb_html' => 'html', // HTML / CSS for width and height attributes.
54
- 'thumb_default' => '', // Default thumbnail image.
55
- 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
56
- 'scan_images' => false, // Scan post for images.
57
- 'class' => 'crp_thumb', // Class of the thumbnail.
58
  );
59
 
60
  // Parse incomming $args into an array and merge it with $defaults.
@@ -73,26 +73,26 @@ function crp_get_the_post_thumbnail( $args = array() ) {
73
  _deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'filter argument has been deprecated', 'contextual-related-posts' ) );
74
  }
75
 
76
- $result = get_post( $args['postid'] );
77
  $post_title = get_the_title( $args['postid'] );
78
 
79
  /**
80
  * Filters the title and alt message for thumbnails.
81
  *
82
- * @since 2.2.2
83
  *
84
- * @param string $post_title Post tile used as thumbnail alt and title
85
- * @param object $result Post Object
86
  */
87
  $post_title = apply_filters( 'crp_thumb_title', $post_title, $result );
88
 
89
- $output = '';
90
  $postimage = '';
91
 
92
  // Let's start fetching the thumbnail. First place to look is in the post meta defined in the Settings page.
93
  if ( ! $postimage ) {
94
  $postimage = get_post_meta( $result->ID, $args['thumb_meta'], true );
95
- $pick = 'meta';
96
  }
97
 
98
  // If there is no thumbnail found, check the post thumbnail.
@@ -112,10 +112,10 @@ function crp_get_the_post_thumbnail( $args = array() ) {
112
  *
113
  * A filter function can be tapped into this to execute shortcodes, modify content, etc.
114
  *
115
- * @since 2.2.2
116
  *
117
- * @param string $result->post_content Post content
118
- * @param object $result Post Object
119
  */
120
  $post_content = apply_filters( 'crp_thumb_post_content', $result->post_content, $result );
121
 
@@ -139,19 +139,19 @@ function crp_get_the_post_thumbnail( $args = array() ) {
139
  // If there is no thumbnail found, fetch the first child image.
140
  if ( ! $postimage ) {
141
  $postimage = crp_get_first_image( $result->ID );
142
- $pick = 'firstchild';
143
  }
144
 
145
  // If no other thumbnail set, try to get the custom video thumbnail set by the Video Thumbnails plugin.
146
  if ( ! $postimage ) {
147
  $postimage = get_post_meta( $result->ID, '_video_thumbnail', true );
148
- $pick = 'video';
149
  }
150
 
151
  // If no thumb found and settings permit, use default thumb.
152
  if ( ! $postimage && $args['thumb_default_show'] ) {
153
  $postimage = $args['thumb_default'];
154
- $pick = 'default';
155
  }
156
 
157
  // Hopefully, we've found a thumbnail by now. If so, run it through the custom filter, check for SSL and create the image tag.
@@ -163,31 +163,31 @@ function crp_get_the_post_thumbnail( $args = array() ) {
163
  * Use this filter to modify the thumbnail URL that is automatically created
164
  * Before v2.1 this was used for cropping the post image using timthumb
165
  *
166
- * @since 2.1.0
167
  *
168
- * @param string $postimage URL of the thumbnail image
169
- * @param int $thumb_width Thumbnail width
170
- * @param int $thumb_height Thumbnail height
171
- * @param object $result Post Object
172
  */
173
  $postimage = apply_filters( 'crp_thumb_url', $postimage, $args['thumb_width'], $args['thumb_height'], $result );
174
 
175
  /* Backward compatibility */
176
- $thumb_timthumb = false;
177
  $thumb_timthumb_q = 75;
178
 
179
  /**
180
  * Filters the thumbnail image URL.
181
  *
182
- * @since 1.8.10
183
- * @deprecated 2.1 Use crp_thumb_url instead.
184
  *
185
- * @param string $postimage URL of the thumbnail image
186
- * @param int $thumb_width Thumbnail width
187
- * @param int $thumb_height Thumbnail height
188
- * @param boolean $thumb_timthumb Enable timthumb?
189
- * @param int $thumb_timthumb_q Quality of timthumb thumbnail.
190
- * @param object $result Post Object
191
  */
192
  $postimage = apply_filters( 'crp_postimage', $postimage, $args['thumb_width'], $args['thumb_height'], $thumb_timthumb, $thumb_timthumb_q, $result );
193
 
@@ -196,9 +196,9 @@ function crp_get_the_post_thumbnail( $args = array() ) {
196
  }
197
 
198
  if ( 'css' === $args['thumb_html'] ) {
199
- $thumb_html = 'style="max-width:' . $args['thumb_width'] . 'px;max-height:' . $args['thumb_height'] . 'px;"';
200
  } elseif ( 'html' === $args['thumb_html'] ) {
201
- $thumb_html = 'width="' . $args['thumb_width'] . '" height="' . $args['thumb_height'] . '"';
202
  } else {
203
  $thumb_html = '';
204
  }
@@ -206,33 +206,59 @@ function crp_get_the_post_thumbnail( $args = array() ) {
206
  /**
207
  * Filters the thumbnail HTML and allows a filter function to add any more HTML if needed.
208
  *
209
- * @since 2.2.0
210
  *
211
- * @param string $thumb_html Thumbnail HTML
 
212
  */
213
- $thumb_html = apply_filters( 'crp_thumb_html', $thumb_html );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
  $class = $args['class'] . ' crp_' . $pick;
216
 
217
  /**
218
  * Filters the thumbnail classes and allows a filter function to add any more classes if needed.
219
  *
220
- * @since 2.2.2
221
  *
222
- * @param string $thumb_html Thumbnail HTML
 
223
  */
224
- $class = apply_filters( 'crp_thumb_class', $class );
225
 
226
- $output .= '<img src="' . $postimage . '" alt="' . $post_title . '" title="' . $post_title . '" ' . $thumb_html . ' class="' . $class . '" />';
227
- }// End if().
228
 
229
  /**
230
  * Filters post thumbnail created for CRP.
231
  *
232
- * @since 1.9
233
  *
234
- * @param array $output Formatted output
235
- * @param array $args Argument list
236
  */
237
  return apply_filters( 'crp_get_the_post_thumbnail', $output, $args );
238
  }
@@ -243,34 +269,34 @@ function crp_get_the_post_thumbnail( $args = array() ) {
243
  *
244
  * @since 1.8.9
245
  *
246
- * @param mixed $post_id Post ID.
247
  * @return string
248
  */
249
  function crp_get_first_image( $post_id ) {
250
  global $crp_settings;
251
 
252
  $args = array(
253
- 'numberposts' => 1,
254
- 'order' => 'ASC',
255
  'post_mime_type' => 'image',
256
- 'post_parent' => $post_id,
257
- 'post_status' => null,
258
- 'post_type' => 'attachment',
259
  );
260
 
261
  $attachments = get_children( $args );
262
 
263
  if ( $attachments ) {
264
  foreach ( $attachments as $attachment ) {
265
- $image_attributes = wp_get_attachment_image_src( $attachment->ID, $crp_settings['thumb_size'] ) ? wp_get_attachment_image_src( $attachment->ID, $crp_settings['thumb_size'] ) : wp_get_attachment_image_src( $attachment->ID, 'full' );
266
 
267
  /**
268
  * Filters first child image from the post.
269
  *
270
- * @since 2.0.0
271
  *
272
- * @param array $image_attributes[0] URL of the image
273
- * @param int $post_id Post ID
274
  */
275
  return apply_filters( 'crp_get_first_image', $image_attributes[0], $post_id );
276
  }
@@ -285,8 +311,8 @@ function crp_get_first_image( $post_id ) {
285
  *
286
  * @since 2.1
287
  *
288
- * @param string $attachment_url Attachment URL.
289
- * @return int Attachment ID
290
  */
291
  function crp_get_attachment_id_from_url( $attachment_url = '' ) {
292
 
@@ -311,17 +337,17 @@ function crp_get_attachment_id_from_url( $attachment_url = '' ) {
311
  $attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );
312
 
313
  // Finally, run a custom database query to get the attachment ID from the modified attachment URL.
314
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url ) );
315
 
316
  }
317
 
318
  /**
319
  * Filters attachment ID generated from URL.
320
  *
321
- * @since 2.1.0
322
  *
323
- * @param int $attachment_id Attachment ID
324
- * @param string $attachment_url Attachment URL
325
  */
326
  return apply_filters( 'crp_get_attachment_id_from_url', $attachment_id, $attachment_url );
327
  }
@@ -330,9 +356,9 @@ function crp_get_attachment_id_from_url( $attachment_url = '' ) {
330
  /**
331
  * Get all image sizes.
332
  *
333
- * @since 2.0.0
334
- * @param string $size Get specific image size.
335
- * @return array Image size names along with width, height and crop setting
336
  */
337
  function crp_get_all_image_sizes( $size = '' ) {
338
  global $_wp_additional_image_sizes;
@@ -343,10 +369,10 @@ function crp_get_all_image_sizes( $size = '' ) {
343
  foreach ( $intermediate_image_sizes as $_size ) {
344
  if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ), true ) ) {
345
 
346
- $sizes[ $_size ]['name'] = $_size;
347
- $sizes[ $_size ]['width'] = absint( get_option( $_size . '_size_w' ) );
348
  $sizes[ $_size ]['height'] = absint( get_option( $_size . '_size_h' ) );
349
- $sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
350
 
351
  if ( ( 0 === $sizes[ $_size ]['width'] ) && ( 0 === $sizes[ $_size ]['height'] ) ) {
352
  unset( $sizes[ $_size ] );
@@ -354,10 +380,10 @@ function crp_get_all_image_sizes( $size = '' ) {
354
  } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
355
 
356
  $sizes[ $_size ] = array(
357
- 'name' => $_size,
358
- 'width' => $_wp_additional_image_sizes[ $_size ]['width'],
359
  'height' => $_wp_additional_image_sizes[ $_size ]['height'],
360
- 'crop' => (bool) $_wp_additional_image_sizes[ $_size ]['crop'],
361
  );
362
  }
363
  }
@@ -374,9 +400,9 @@ function crp_get_all_image_sizes( $size = '' ) {
374
  /**
375
  * Filters array of image sizes.
376
  *
377
- * @since 2.0
378
  *
379
- * @param array $sizes Image sizes
380
  */
381
  return apply_filters( 'crp_get_all_image_sizes', $sizes );
382
  }
3
  * Image handling functions
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  /**
23
 
24
  // Add image sizes if 'crp_thumbnail' is selected or the selected thumbnail size is no longer valid.
25
  if ( 'crp_thumbnail' === $crp_settings['thumb_size'] ) {
26
+ $width = empty( $crp_settings['thumb_width'] ) ? 150 : $crp_settings['thumb_width'];
27
  $height = empty( $crp_settings['thumb_height'] ) ? 150 : $crp_settings['thumb_height'];
28
+ $crop = isset( $crp_settings['thumb_crop'] ) ? $crp_settings['thumb_crop'] : false;
29
 
30
  add_image_size( 'crp_thumbnail', $width, $height, $crop );
31
  }
46
  global $crp_settings;
47
 
48
  $defaults = array(
49
+ 'postid' => '',
50
+ 'thumb_height' => '150', // Max height of thumbnails.
51
+ 'thumb_width' => '150', // Max width of thumbnails.
52
+ 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
53
+ 'thumb_html' => 'html', // HTML / CSS for width and height attributes.
54
+ 'thumb_default' => '', // Default thumbnail image.
55
+ 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
56
+ 'scan_images' => false, // Scan post for images.
57
+ 'class' => 'crp_thumb', // Class of the thumbnail.
58
  );
59
 
60
  // Parse incomming $args into an array and merge it with $defaults.
73
  _deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'filter argument has been deprecated', 'contextual-related-posts' ) );
74
  }
75
 
76
+ $result = get_post( $args['postid'] );
77
  $post_title = get_the_title( $args['postid'] );
78
 
79
  /**
80
  * Filters the title and alt message for thumbnails.
81
  *
82
+ * @since 2.2.2
83
  *
84
+ * @param string $post_title Post tile used as thumbnail alt and title
85
+ * @param object $result Post Object
86
  */
87
  $post_title = apply_filters( 'crp_thumb_title', $post_title, $result );
88
 
89
+ $output = '';
90
  $postimage = '';
91
 
92
  // Let's start fetching the thumbnail. First place to look is in the post meta defined in the Settings page.
93
  if ( ! $postimage ) {
94
  $postimage = get_post_meta( $result->ID, $args['thumb_meta'], true );
95
+ $pick = 'meta';
96
  }
97
 
98
  // If there is no thumbnail found, check the post thumbnail.
112
  *
113
  * A filter function can be tapped into this to execute shortcodes, modify content, etc.
114
  *
115
+ * @since 2.2.2
116
  *
117
+ * @param string $result->post_content Post content
118
+ * @param object $result Post Object
119
  */
120
  $post_content = apply_filters( 'crp_thumb_post_content', $result->post_content, $result );
121
 
139
  // If there is no thumbnail found, fetch the first child image.
140
  if ( ! $postimage ) {
141
  $postimage = crp_get_first_image( $result->ID );
142
+ $pick = 'firstchild';
143
  }
144
 
145
  // If no other thumbnail set, try to get the custom video thumbnail set by the Video Thumbnails plugin.
146
  if ( ! $postimage ) {
147
  $postimage = get_post_meta( $result->ID, '_video_thumbnail', true );
148
+ $pick = 'video';
149
  }
150
 
151
  // If no thumb found and settings permit, use default thumb.
152
  if ( ! $postimage && $args['thumb_default_show'] ) {
153
  $postimage = $args['thumb_default'];
154
+ $pick = 'default';
155
  }
156
 
157
  // Hopefully, we've found a thumbnail by now. If so, run it through the custom filter, check for SSL and create the image tag.
163
  * Use this filter to modify the thumbnail URL that is automatically created
164
  * Before v2.1 this was used for cropping the post image using timthumb
165
  *
166
+ * @since 2.1.0
167
  *
168
+ * @param string $postimage URL of the thumbnail image
169
+ * @param int $thumb_width Thumbnail width
170
+ * @param int $thumb_height Thumbnail height
171
+ * @param object $result Post Object
172
  */
173
  $postimage = apply_filters( 'crp_thumb_url', $postimage, $args['thumb_width'], $args['thumb_height'], $result );
174
 
175
  /* Backward compatibility */
176
+ $thumb_timthumb = false;
177
  $thumb_timthumb_q = 75;
178
 
179
  /**
180
  * Filters the thumbnail image URL.
181
  *
182
+ * @since 1.8.10
183
+ * @deprecated 2.1 Use crp_thumb_url instead.
184
  *
185
+ * @param string $postimage URL of the thumbnail image
186
+ * @param int $thumb_width Thumbnail width
187
+ * @param int $thumb_height Thumbnail height
188
+ * @param boolean $thumb_timthumb Enable timthumb?
189
+ * @param int $thumb_timthumb_q Quality of timthumb thumbnail.
190
+ * @param object $result Post Object
191
  */
192
  $postimage = apply_filters( 'crp_postimage', $postimage, $args['thumb_width'], $args['thumb_height'], $thumb_timthumb, $thumb_timthumb_q, $result );
193
 
196
  }
197
 
198
  if ( 'css' === $args['thumb_html'] ) {
199
+ $thumb_html = ' style="max-width:' . $args['thumb_width'] . 'px;max-height:' . $args['thumb_height'] . 'px;"';
200
  } elseif ( 'html' === $args['thumb_html'] ) {
201
+ $thumb_html = ' width="' . $args['thumb_width'] . '" height="' . $args['thumb_height'] . '"';
202
  } else {
203
  $thumb_html = '';
204
  }
206
  /**
207
  * Filters the thumbnail HTML and allows a filter function to add any more HTML if needed.
208
  *
209
+ * @since 2.2.0
210
  *
211
+ * @param string $thumb_html Thumbnail HTML
212
+ * @param array $args Argument array
213
  */
214
+ $thumb_html = apply_filters( 'crp_thumb_html', $thumb_html, $args );
215
+
216
+ $img_alt = ' alt="' . $post_title . '"';
217
+
218
+ /**
219
+ * Filters the thumbnail alt tag.
220
+ *
221
+ * @since 2.5.0
222
+ *
223
+ * @param string $img_alt Thumbnail alt tag
224
+ * @param array $args Argument array
225
+ */
226
+ $img_alt = apply_filters( 'crp_thumb_alt', $img_alt, $args );
227
+
228
+ $img_title = ' title="' . $post_title . '"';
229
+
230
+ /**
231
+ * Filters the thumbnail title tag.
232
+ *
233
+ * @since 2.5.0
234
+ *
235
+ * @param string $img_title Thumbnail title tag
236
+ * @param array $args Argument array
237
+ */
238
+ $img_title = apply_filters( 'crp_thumb_title', $img_title, $args );
239
 
240
  $class = $args['class'] . ' crp_' . $pick;
241
 
242
  /**
243
  * Filters the thumbnail classes and allows a filter function to add any more classes if needed.
244
  *
245
+ * @since 2.2.2
246
  *
247
+ * @param string $thumb_html Thumbnail HTML
248
+ * @param array $args Argument array
249
  */
250
+ $class = apply_filters( 'crp_thumb_class', $class, $args );
251
 
252
+ $output .= '<img src="' . $postimage . '"' . $img_alt . $img_title . $thumb_html . ' class="' . $class . '" />';
253
+ }
254
 
255
  /**
256
  * Filters post thumbnail created for CRP.
257
  *
258
+ * @since 1.9
259
  *
260
+ * @param array $output Formatted output
261
+ * @param array $args Argument array
262
  */
263
  return apply_filters( 'crp_get_the_post_thumbnail', $output, $args );
264
  }
269
  *
270
  * @since 1.8.9
271
  *
272
+ * @param mixed $post_id Post ID.
273
  * @return string
274
  */
275
  function crp_get_first_image( $post_id ) {
276
  global $crp_settings;
277
 
278
  $args = array(
279
+ 'numberposts' => 1,
280
+ 'order' => 'ASC',
281
  'post_mime_type' => 'image',
282
+ 'post_parent' => $post_id,
283
+ 'post_status' => null,
284
+ 'post_type' => 'attachment',
285
  );
286
 
287
  $attachments = get_children( $args );
288
 
289
  if ( $attachments ) {
290
  foreach ( $attachments as $attachment ) {
291
+ $image_attributes = wp_get_attachment_image_src( $attachment->ID, $crp_settings['thumb_size'] ) ? wp_get_attachment_image_src( $attachment->ID, $crp_settings['thumb_size'] ) : wp_get_attachment_image_src( $attachment->ID, 'full' );
292
 
293
  /**
294
  * Filters first child image from the post.
295
  *
296
+ * @since 2.0.0
297
  *
298
+ * @param array $image_attributes[0] URL of the image
299
+ * @param int $post_id Post ID
300
  */
301
  return apply_filters( 'crp_get_first_image', $image_attributes[0], $post_id );
302
  }
311
  *
312
  * @since 2.1
313
  *
314
+ * @param string $attachment_url Attachment URL.
315
+ * @return int Attachment ID
316
  */
317
  function crp_get_attachment_id_from_url( $attachment_url = '' ) {
318
 
337
  $attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );
338
 
339
  // Finally, run a custom database query to get the attachment ID from the modified attachment URL.
340
+ $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = %s AND wposts.post_type = 'attachment'", $attachment_url ) );
341
 
342
  }
343
 
344
  /**
345
  * Filters attachment ID generated from URL.
346
  *
347
+ * @since 2.1.0
348
  *
349
+ * @param int $attachment_id Attachment ID
350
+ * @param string $attachment_url Attachment URL
351
  */
352
  return apply_filters( 'crp_get_attachment_id_from_url', $attachment_id, $attachment_url );
353
  }
356
  /**
357
  * Get all image sizes.
358
  *
359
+ * @since 2.0.0
360
+ * @param string $size Get specific image size.
361
+ * @return array Image size names along with width, height and crop setting
362
  */
363
  function crp_get_all_image_sizes( $size = '' ) {
364
  global $_wp_additional_image_sizes;
369
  foreach ( $intermediate_image_sizes as $_size ) {
370
  if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ), true ) ) {
371
 
372
+ $sizes[ $_size ]['name'] = $_size;
373
+ $sizes[ $_size ]['width'] = absint( get_option( $_size . '_size_w' ) );
374
  $sizes[ $_size ]['height'] = absint( get_option( $_size . '_size_h' ) );
375
+ $sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
376
 
377
  if ( ( 0 === $sizes[ $_size ]['width'] ) && ( 0 === $sizes[ $_size ]['height'] ) ) {
378
  unset( $sizes[ $_size ] );
380
  } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
381
 
382
  $sizes[ $_size ] = array(
383
+ 'name' => $_size,
384
+ 'width' => $_wp_additional_image_sizes[ $_size ]['width'],
385
  'height' => $_wp_additional_image_sizes[ $_size ]['height'],
386
+ 'crop' => (bool) $_wp_additional_image_sizes[ $_size ]['crop'],
387
  );
388
  }
389
  }
400
  /**
401
  * Filters array of image sizes.
402
  *
403
+ * @since 2.0
404
  *
405
+ * @param array $sizes Image sizes
406
  */
407
  return apply_filters( 'crp_get_all_image_sizes', $sizes );
408
  }
includes/modules/class-crp-widget.php CHANGED
@@ -3,10 +3,10 @@
3
  * Widget class.
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -15,7 +15,7 @@ if ( ! defined( 'WPINC' ) ) {
15
  }
16
 
17
  /**
18
- * Create a Wordpress Widget for CRP.
19
  *
20
  * @since 1.9
21
  *
@@ -31,7 +31,7 @@ class CRP_Widget extends WP_Widget {
31
  'widget_crp',
32
  __( 'Related Posts [CRP]', 'contextual-related-posts' ),
33
  array(
34
- 'description' => __( 'Display Related Posts', 'contextual-related-posts' ),
35
  'customize_selective_refresh' => true,
36
  )
37
  );
@@ -40,20 +40,20 @@ class CRP_Widget extends WP_Widget {
40
  /**
41
  * Back-end widget form.
42
  *
43
- * @see WP_Widget::form()
44
  *
45
- * @param array $instance Previously saved values from database.
46
  */
47
  public function form( $instance ) {
48
- $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
49
- $limit = isset( $instance['limit'] ) ? esc_attr( $instance['limit'] ) : '';
50
- $offset = isset( $instance['offset'] ) ? esc_attr( $instance['offset'] ) : '';
51
- $show_excerpt = isset( $instance['show_excerpt'] ) ? esc_attr( $instance['show_excerpt'] ) : '';
52
- $show_author = isset( $instance['show_author'] ) ? esc_attr( $instance['show_author'] ) : '';
53
- $show_date = isset( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
54
  $post_thumb_op = isset( $instance['post_thumb_op'] ) ? esc_attr( $instance['post_thumb_op'] ) : '';
55
- $thumb_height = isset( $instance['thumb_height'] ) ? esc_attr( $instance['thumb_height'] ) : '';
56
- $thumb_width = isset( $instance['thumb_width'] ) ? esc_attr( $instance['thumb_width'] ) : '';
57
 
58
  // Parse the Post types.
59
  $post_types = array();
@@ -62,12 +62,14 @@ class CRP_Widget extends WP_Widget {
62
  if ( ! empty( $instance['post_types'] ) && false === strpos( $instance['post_types'], '=' ) ) {
63
  $post_types = explode( ',', $instance['post_types'] );
64
  } else {
65
- parse_str( $instance['post_types'], $post_types ); // Save post types in $post_types variable.
66
  }
67
 
68
- $wp_post_types = get_post_types( array(
69
- 'public' => true,
70
- ) );
 
 
71
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
72
 
73
  ?>
@@ -88,26 +90,41 @@ class CRP_Widget extends WP_Widget {
88
  </p>
89
  <p>
90
  <label for="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>">
91
- <input id="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_excerpt' ) ); ?>" type="checkbox" <?php if ( $show_excerpt ) { echo 'checked="checked"'; } ?> /> <?php esc_html_e( ' Show excerpt?', 'contextual-related-posts' ); ?>
 
 
 
 
 
92
  </label>
93
  </p>
94
  <p>
95
  <label for="<?php echo esc_attr( $this->get_field_id( 'show_author' ) ); ?>">
96
- <input id="<?php echo esc_attr( $this->get_field_id( 'show_author' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_author' ) ); ?>" type="checkbox" <?php if ( $show_author ) { echo 'checked="checked"'; } ?> /> <?php esc_html_e( ' Show author?', 'contextual-related-posts' ); ?>
 
 
 
 
 
97
  </label>
98
  </p>
99
  <p>
100
  <label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>">
101
- <input id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" type="checkbox" <?php if ( $show_date ) { echo 'checked="checked"'; } ?> /> <?php esc_html_e( ' Show date?', 'contextual-related-posts' ); ?>
 
 
 
 
 
102
  </label>
103
  </p>
104
  <p>
105
  <?php esc_html_e( 'Thumbnail options', 'contextual-related-posts' ); ?>: <br />
106
  <select class="widefat" id="<?php esc_attr_e( $this->get_field_id( 'post_thumb_op' ) ); ?>" name="<?php esc_attr_e( $this->get_field_name( 'post_thumb_op' ) ); ?>">
107
- <option value="inline" <?php selected( 'inline', $post_thumb_op, true ); ?>><?php esc_html_e( 'Thumbnails inline, before title','contextual-related-posts' ); ?></option>
108
- <option value="after" <?php selected( 'after', $post_thumb_op, true ); ?>><?php esc_html_e( 'Thumbnails inline, after title','contextual-related-posts' ); ?></option>
109
- <option value="thumbs_only" <?php selected( 'thumbs_only', $post_thumb_op, true ); ?>><?php esc_html_e( 'Only thumbnails, no text','contextual-related-posts' ); ?></option>
110
- <option value="text_only" <?php selected( 'text_only', $post_thumb_op, true ); ?>><?php esc_html_e( 'No thumbnails, only text.','contextual-related-posts' ); ?></option>
111
  </select>
112
  </p>
113
  <p>
@@ -131,7 +148,7 @@ class CRP_Widget extends WP_Widget {
131
  </label>
132
  <br />
133
 
134
- <?php } ?>
135
  </p>
136
 
137
  <?php
@@ -140,7 +157,7 @@ class CRP_Widget extends WP_Widget {
140
  *
141
  * @since 2.1.0
142
  *
143
- * @param array $instance Widget options array
144
  */
145
  do_action( 'crp_widget_options_after', $instance );
146
  ?>
@@ -153,29 +170,31 @@ class CRP_Widget extends WP_Widget {
153
  *
154
  * @see WP_Widget::update()
155
  *
156
- * @param array $new_instance Values just sent to be saved.
157
- * @param array $old_instance Previously saved values from database.
158
  *
159
- * @return array Updated safe values to be saved.
160
  */
161
  public function update( $new_instance, $old_instance ) {
162
- $instance = $old_instance;
163
- $instance['title'] = strip_tags( $new_instance['title'] );
164
- $instance['limit'] = $new_instance['limit'];
165
- $instance['offset'] = $new_instance['offset'];
166
- $instance['show_excerpt'] = $new_instance['show_excerpt'];
167
- $instance['show_author'] = $new_instance['show_author'];
168
- $instance['show_date'] = $new_instance['show_date'];
169
  $instance['post_thumb_op'] = $new_instance['post_thumb_op'];
170
- $instance['thumb_height'] = $new_instance['thumb_height'];
171
- $instance['thumb_width'] = $new_instance['thumb_width'];
172
 
173
  // Process post types to be selected.
174
- $wp_post_types = get_post_types( array(
175
- 'public' => true,
176
- ) );
177
- $post_types = isset( $new_instance['post_types'] ) ? $new_instance['post_types'] : array();
178
- $post_types = array_intersect( $wp_post_types, $post_types );
 
 
179
  $instance['post_types'] = implode( ',', $post_types );
180
 
181
  delete_post_meta_by_key( 'crp_related_posts_widget' ); // Delete the cache.
@@ -197,8 +216,8 @@ class CRP_Widget extends WP_Widget {
197
  *
198
  * @see WP_Widget::widget()
199
  *
200
- * @param array $args Widget arguments.
201
- * @param array $instance Saved values from database.
202
  */
203
  public function widget( $args, $instance ) {
204
  global $post, $crp_settings;
@@ -216,11 +235,11 @@ class CRP_Widget extends WP_Widget {
216
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
217
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
218
  } else {
219
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
220
  }
221
 
222
  if ( is_object( $post ) && ( in_array( $post->post_type, $exclude_on_post_types, true ) ) ) {
223
- return 0; // Exit without adding related posts.
224
  }
225
 
226
  $exclude_on_post_ids = explode( ',', $crp_settings['exclude_on_post_ids'] );
@@ -236,24 +255,24 @@ class CRP_Widget extends WP_Widget {
236
  $offset = isset( $instance['offset'] ) ? $instance['offset'] : 0;
237
 
238
  $post_thumb_op = isset( $instance['post_thumb_op'] ) ? esc_attr( $instance['post_thumb_op'] ) : 'text_only';
239
- $thumb_height = isset( $instance['thumb_height'] ) ? esc_attr( $instance['thumb_height'] ) : $crp_settings['thumb_height'];
240
- $thumb_width = isset( $instance['thumb_width'] ) ? esc_attr( $instance['thumb_width'] ) : $crp_settings['thumb_width'];
241
- $show_excerpt = isset( $instance['show_excerpt'] ) ? esc_attr( $instance['show_excerpt'] ) : '';
242
- $show_author = isset( $instance['show_author'] ) ? esc_attr( $instance['show_author'] ) : '';
243
- $show_date = isset( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
244
- $post_types = isset( $instance['post_types'] ) && ! empty( $instance['post_types'] ) ? $instance['post_types'] : $crp_settings['post_types'];
245
 
246
  $arguments = array(
247
- 'is_widget' => 1,
248
- 'limit' => $limit,
249
- 'offset' => $offset,
250
- 'show_excerpt' => $show_excerpt,
251
- 'show_author' => $show_author,
252
- 'show_date' => $show_date,
253
  'post_thumb_op' => $post_thumb_op,
254
- 'thumb_height' => $thumb_height,
255
- 'thumb_width' => $thumb_width,
256
- 'post_types' => $post_types,
257
  );
258
 
259
  /**
@@ -265,9 +284,9 @@ class CRP_Widget extends WP_Widget {
265
  * @param array $args Widget arguments.
266
  * @param array $instance Saved values from database.
267
  */
268
- $arguments = apply_filters( 'crp_widget_options' , $arguments, $args, $instance );
269
 
270
- $output = $args['before_widget'];
271
  $output .= $args['before_title'] . $title . $args['after_title'];
272
  $output .= get_crp( $arguments );
273
 
3
  * Widget class.
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
15
  }
16
 
17
  /**
18
+ * Create a WordPress Widget for CRP.
19
  *
20
  * @since 1.9
21
  *
31
  'widget_crp',
32
  __( 'Related Posts [CRP]', 'contextual-related-posts' ),
33
  array(
34
+ 'description' => __( 'Display Related Posts', 'contextual-related-posts' ),
35
  'customize_selective_refresh' => true,
36
  )
37
  );
40
  /**
41
  * Back-end widget form.
42
  *
43
+ * @see WP_Widget::form()
44
  *
45
+ * @param array $instance Previously saved values from database.
46
  */
47
  public function form( $instance ) {
48
+ $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
49
+ $limit = isset( $instance['limit'] ) ? esc_attr( $instance['limit'] ) : '';
50
+ $offset = isset( $instance['offset'] ) ? esc_attr( $instance['offset'] ) : '';
51
+ $show_excerpt = isset( $instance['show_excerpt'] ) ? esc_attr( $instance['show_excerpt'] ) : '';
52
+ $show_author = isset( $instance['show_author'] ) ? esc_attr( $instance['show_author'] ) : '';
53
+ $show_date = isset( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
54
  $post_thumb_op = isset( $instance['post_thumb_op'] ) ? esc_attr( $instance['post_thumb_op'] ) : '';
55
+ $thumb_height = isset( $instance['thumb_height'] ) ? esc_attr( $instance['thumb_height'] ) : '';
56
+ $thumb_width = isset( $instance['thumb_width'] ) ? esc_attr( $instance['thumb_width'] ) : '';
57
 
58
  // Parse the Post types.
59
  $post_types = array();
62
  if ( ! empty( $instance['post_types'] ) && false === strpos( $instance['post_types'], '=' ) ) {
63
  $post_types = explode( ',', $instance['post_types'] );
64
  } else {
65
+ parse_str( $instance['post_types'], $post_types ); // Save post types in $post_types variable.
66
  }
67
 
68
+ $wp_post_types = get_post_types(
69
+ array(
70
+ 'public' => true,
71
+ )
72
+ );
73
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
74
 
75
  ?>
90
  </p>
91
  <p>
92
  <label for="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>">
93
+ <input id="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_excerpt' ) ); ?>" type="checkbox"
94
+ <?php
95
+ if ( $show_excerpt ) {
96
+ echo 'checked="checked"'; }
97
+ ?>
98
+ /> <?php esc_html_e( ' Show excerpt?', 'contextual-related-posts' ); ?>
99
  </label>
100
  </p>
101
  <p>
102
  <label for="<?php echo esc_attr( $this->get_field_id( 'show_author' ) ); ?>">
103
+ <input id="<?php echo esc_attr( $this->get_field_id( 'show_author' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_author' ) ); ?>" type="checkbox"
104
+ <?php
105
+ if ( $show_author ) {
106
+ echo 'checked="checked"'; }
107
+ ?>
108
+ /> <?php esc_html_e( ' Show author?', 'contextual-related-posts' ); ?>
109
  </label>
110
  </p>
111
  <p>
112
  <label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>">
113
+ <input id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" type="checkbox"
114
+ <?php
115
+ if ( $show_date ) {
116
+ echo 'checked="checked"'; }
117
+ ?>
118
+ /> <?php esc_html_e( ' Show date?', 'contextual-related-posts' ); ?>
119
  </label>
120
  </p>
121
  <p>
122
  <?php esc_html_e( 'Thumbnail options', 'contextual-related-posts' ); ?>: <br />
123
  <select class="widefat" id="<?php esc_attr_e( $this->get_field_id( 'post_thumb_op' ) ); ?>" name="<?php esc_attr_e( $this->get_field_name( 'post_thumb_op' ) ); ?>">
124
+ <option value="inline" <?php selected( 'inline', $post_thumb_op, true ); ?>><?php esc_html_e( 'Thumbnails inline, before title', 'contextual-related-posts' ); ?></option>
125
+ <option value="after" <?php selected( 'after', $post_thumb_op, true ); ?>><?php esc_html_e( 'Thumbnails inline, after title', 'contextual-related-posts' ); ?></option>
126
+ <option value="thumbs_only" <?php selected( 'thumbs_only', $post_thumb_op, true ); ?>><?php esc_html_e( 'Only thumbnails, no text', 'contextual-related-posts' ); ?></option>
127
+ <option value="text_only" <?php selected( 'text_only', $post_thumb_op, true ); ?>><?php esc_html_e( 'No thumbnails, only text.', 'contextual-related-posts' ); ?></option>
128
  </select>
129
  </p>
130
  <p>
148
  </label>
149
  <br />
150
 
151
+ <?php } ?>
152
  </p>
153
 
154
  <?php
157
  *
158
  * @since 2.1.0
159
  *
160
+ * @param array $instance Widget options array
161
  */
162
  do_action( 'crp_widget_options_after', $instance );
163
  ?>
170
  *
171
  * @see WP_Widget::update()
172
  *
173
+ * @param array $new_instance Values just sent to be saved.
174
+ * @param array $old_instance Previously saved values from database.
175
  *
176
+ * @return array Updated safe values to be saved.
177
  */
178
  public function update( $new_instance, $old_instance ) {
179
+ $instance = $old_instance;
180
+ $instance['title'] = strip_tags( $new_instance['title'] );
181
+ $instance['limit'] = $new_instance['limit'];
182
+ $instance['offset'] = $new_instance['offset'];
183
+ $instance['show_excerpt'] = $new_instance['show_excerpt'];
184
+ $instance['show_author'] = $new_instance['show_author'];
185
+ $instance['show_date'] = $new_instance['show_date'];
186
  $instance['post_thumb_op'] = $new_instance['post_thumb_op'];
187
+ $instance['thumb_height'] = $new_instance['thumb_height'];
188
+ $instance['thumb_width'] = $new_instance['thumb_width'];
189
 
190
  // Process post types to be selected.
191
+ $wp_post_types = get_post_types(
192
+ array(
193
+ 'public' => true,
194
+ )
195
+ );
196
+ $post_types = isset( $new_instance['post_types'] ) ? $new_instance['post_types'] : array();
197
+ $post_types = array_intersect( $wp_post_types, $post_types );
198
  $instance['post_types'] = implode( ',', $post_types );
199
 
200
  delete_post_meta_by_key( 'crp_related_posts_widget' ); // Delete the cache.
216
  *
217
  * @see WP_Widget::widget()
218
  *
219
+ * @param array $args Widget arguments.
220
+ * @param array $instance Saved values from database.
221
  */
222
  public function widget( $args, $instance ) {
223
  global $post, $crp_settings;
235
  if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
236
  $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
237
  } else {
238
+ parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
239
  }
240
 
241
  if ( is_object( $post ) && ( in_array( $post->post_type, $exclude_on_post_types, true ) ) ) {
242
+ return 0; // Exit without adding related posts.
243
  }
244
 
245
  $exclude_on_post_ids = explode( ',', $crp_settings['exclude_on_post_ids'] );
255
  $offset = isset( $instance['offset'] ) ? $instance['offset'] : 0;
256
 
257
  $post_thumb_op = isset( $instance['post_thumb_op'] ) ? esc_attr( $instance['post_thumb_op'] ) : 'text_only';
258
+ $thumb_height = isset( $instance['thumb_height'] ) ? esc_attr( $instance['thumb_height'] ) : $crp_settings['thumb_height'];
259
+ $thumb_width = isset( $instance['thumb_width'] ) ? esc_attr( $instance['thumb_width'] ) : $crp_settings['thumb_width'];
260
+ $show_excerpt = isset( $instance['show_excerpt'] ) ? esc_attr( $instance['show_excerpt'] ) : '';
261
+ $show_author = isset( $instance['show_author'] ) ? esc_attr( $instance['show_author'] ) : '';
262
+ $show_date = isset( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
263
+ $post_types = isset( $instance['post_types'] ) && ! empty( $instance['post_types'] ) ? $instance['post_types'] : $crp_settings['post_types'];
264
 
265
  $arguments = array(
266
+ 'is_widget' => 1,
267
+ 'limit' => $limit,
268
+ 'offset' => $offset,
269
+ 'show_excerpt' => $show_excerpt,
270
+ 'show_author' => $show_author,
271
+ 'show_date' => $show_date,
272
  'post_thumb_op' => $post_thumb_op,
273
+ 'thumb_height' => $thumb_height,
274
+ 'thumb_width' => $thumb_width,
275
+ 'post_types' => $post_types,
276
  );
277
 
278
  /**
284
  * @param array $args Widget arguments.
285
  * @param array $instance Saved values from database.
286
  */
287
+ $arguments = apply_filters( 'crp_widget_options', $arguments, $args, $instance );
288
 
289
+ $output = $args['before_widget'];
290
  $output .= $args['before_title'] . $title . $args['after_title'];
291
  $output .= get_crp( $arguments );
292
 
includes/modules/exclusions.php CHANGED
@@ -8,10 +8,10 @@
8
  /**
9
  * Function to filter exclude post IDs.
10
  *
11
- * @since 2.3.0
12
  *
13
- * @param array $exclude_post_ids Original excluded post IDs.
14
- * @return array Updated excluded post ID
15
  */
16
  function crp_exclude_post_ids( $exclude_post_ids ) {
17
  global $wpdb;
8
  /**
9
  * Function to filter exclude post IDs.
10
  *
11
+ * @since 2.3.0
12
  *
13
+ * @param array $exclude_post_ids Original excluded post IDs.
14
+ * @return array Updated excluded post ID
15
  */
16
  function crp_exclude_post_ids( $exclude_post_ids ) {
17
  global $wpdb;
includes/modules/manual-posts.php CHANGED
@@ -3,11 +3,11 @@
3
  * Manual posts module
4
  *
5
  * @package Contextual_Related_Posts
6
- * @subpackage Manual_Posts
7
- * @author Ajay D'Souza <me@ajaydsouza.com>
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
- * @copyright 2009-2017 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
@@ -18,10 +18,10 @@ if ( ! defined( 'WPINC' ) ) {
18
  /**
19
  * Checks if a list of manual posts exists and adds them before the other posts.
20
  *
21
- * @since 2.2.0
22
  *
23
- * @param object $results Original object array with post results.
24
- * @return object Updated object array with post results
25
  */
26
  function crp_manual_posts( $results ) {
27
  global $post, $wpdb;
3
  * Manual posts module
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @subpackage Manual_Posts
7
+ * @author Ajay D'Souza
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
+ * @copyright 2009-2018 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
18
  /**
19
  * Checks if a list of manual posts exists and adds them before the other posts.
20
  *
21
+ * @since 2.2.0
22
  *
23
+ * @param object $results Original object array with post results.
24
+ * @return object Updated object array with post results
25
  */
26
  function crp_manual_posts( $results ) {
27
  global $post, $wpdb;
includes/modules/shortcode.php CHANGED
@@ -3,11 +3,11 @@
3
  * Shortcode module
4
  *
5
  * @package Contextual_Related_Posts
6
- * @subpackage Shortcode
7
- * @author Ajay D'Souza <me@ajaydsouza.com>
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
- * @copyright 2009-2017 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
@@ -18,23 +18,27 @@ if ( ! defined( 'WPINC' ) ) {
18
  /**
19
  * Creates a shortcode [crp limit="5" heading="1" cache="1"].
20
  *
21
- * @since 1.8.6
22
  *
23
- * @param array $atts Shortcode attributes.
24
- * @param string $content Post content.
25
- * @return Related Posts
26
  */
27
  function crp_shortcode( $atts, $content = null ) {
28
  global $crp_settings;
29
 
30
- $atts = shortcode_atts( array_merge(
31
- $crp_settings,
32
- array(
33
- 'heading' => 1,
34
- 'is_shortcode' => 1,
35
- 'offset' => 0,
36
- )
37
- ), $atts, 'crp' );
 
 
 
 
38
 
39
  return get_crp( $atts );
40
  }
3
  * Shortcode module
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @subpackage Shortcode
7
+ * @author Ajay D'Souza
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
+ * @copyright 2009-2018 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
18
  /**
19
  * Creates a shortcode [crp limit="5" heading="1" cache="1"].
20
  *
21
+ * @since 1.8.6
22
  *
23
+ * @param array $atts Shortcode attributes.
24
+ * @param string $content Post content.
25
+ * @return Related Posts
26
  */
27
  function crp_shortcode( $atts, $content = null ) {
28
  global $crp_settings;
29
 
30
+ $atts = shortcode_atts(
31
+ array_merge(
32
+ $crp_settings,
33
+ array(
34
+ 'heading' => 1,
35
+ 'is_shortcode' => 1,
36
+ 'offset' => 0,
37
+ )
38
+ ),
39
+ $atts,
40
+ 'crp'
41
+ );
42
 
43
  return get_crp( $atts );
44
  }
includes/modules/taxonomies.php CHANGED
@@ -3,11 +3,11 @@
3
  * Taxonomies control module
4
  *
5
  * @package Contextual_Related_Posts
6
- * @subpackage Manual_Posts
7
- * @author Ajay D'Souza <me@ajaydsouza.com>
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
- * @copyright 2009-2017 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
@@ -20,15 +20,15 @@ if ( ! defined( 'WPINC' ) ) {
20
  *
21
  * @since 1.0.0
22
  *
23
- * @param mixed $join JOIN clause.
24
- * @return string Filtered CRP JOIN clause
25
  */
26
  function crp_exclude_categories_join( $join ) {
27
  global $wpdb, $crp_settings;
28
 
29
  if ( ! empty( $crp_settings['exclude_categories'] ) ) {
30
 
31
- $sql = $join;
32
  $sql .= " INNER JOIN $wpdb->term_relationships AS excat_tr ON ($wpdb->posts.ID = excat_tr.object_id) ";
33
  $sql .= " INNER JOIN $wpdb->term_taxonomy AS excat_tt ON (excat_tr.term_taxonomy_id = excat_tt.term_taxonomy_id) ";
34
 
@@ -44,8 +44,8 @@ add_filter( 'crp_posts_join', 'crp_exclude_categories_join' );
44
  *
45
  * @since 1.0.0
46
  *
47
- * @param mixed $where WHERE clause.
48
- * @return string Filtered CRP WHERE clause
49
  */
50
  function crp_exclude_categories_where( $where ) {
51
  global $wpdb, $crp_settings;
3
  * Taxonomies control module
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @subpackage Manual_Posts
7
+ * @author Ajay D'Souza
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
+ * @copyright 2009-2018 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
20
  *
21
  * @since 1.0.0
22
  *
23
+ * @param mixed $join JOIN clause.
24
+ * @return string Filtered CRP JOIN clause
25
  */
26
  function crp_exclude_categories_join( $join ) {
27
  global $wpdb, $crp_settings;
28
 
29
  if ( ! empty( $crp_settings['exclude_categories'] ) ) {
30
 
31
+ $sql = $join;
32
  $sql .= " INNER JOIN $wpdb->term_relationships AS excat_tr ON ($wpdb->posts.ID = excat_tr.object_id) ";
33
  $sql .= " INNER JOIN $wpdb->term_taxonomy AS excat_tt ON (excat_tr.term_taxonomy_id = excat_tt.term_taxonomy_id) ";
34
 
44
  *
45
  * @since 1.0.0
46
  *
47
+ * @param mixed $where WHERE clause.
48
+ * @return string Filtered CRP WHERE clause
49
  */
50
  function crp_exclude_categories_where( $where ) {
51
  global $wpdb, $crp_settings;
includes/output-generator.php CHANGED
@@ -3,10 +3,10 @@
3
  * Generates the output
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -17,28 +17,28 @@ if ( ! defined( 'WPINC' ) ) {
17
  /**
18
  * Returns the link attributes.
19
  *
20
- * @since 2.2.0
21
  *
22
- * @param array $args Array of arguments.
23
- * @return string Space separated list of link attributes.
24
  */
25
  function crp_link_attributes( $args ) {
26
 
27
- $rel_attribute = ( $args['link_nofollow'] ) ? ' rel="nofollow" ' : ' ';
28
  $target_attribute = ( $args['link_new_window'] ) ? ' target="_blank" ' : ' ';
29
 
30
  $link_attributes = array(
31
- 'rel_attribute' => $rel_attribute,
32
  'target_attribute' => $target_attribute,
33
  );
34
 
35
  /**
36
  * Filter the title of the Related Posts list
37
  *
38
- * @since 2.2.0
39
  *
40
- * @param array $link_attributes Array of link attributes
41
- * @param array $args Array of arguments
42
  */
43
  $link_attributes = apply_filters( 'crp_link_attributes', $link_attributes, $args );
44
 
@@ -53,10 +53,10 @@ function crp_link_attributes( $args ) {
53
  /**
54
  * Returns the heading of the related posts.
55
  *
56
- * @since 2.2.0
57
  *
58
- * @param array $args Array of arguments.
59
- * @return string Space separated list of link attributes
60
  */
61
  function crp_heading_title( $args ) {
62
  global $post;
@@ -64,16 +64,16 @@ function crp_heading_title( $args ) {
64
  $title = '';
65
 
66
  if ( $args['heading'] && ! $args['is_widget'] ) {
67
- $title = str_replace( '%postname%', $post->post_title, $args['title'] ); // Replace %postname% with the title of the current post.
68
  }
69
 
70
  /**
71
  * Filter the title of the Related Posts list
72
  *
73
- * @since 1.9
74
  *
75
- * @param string $title Title/heading of the Related Posts list
76
- * @param array $args Array of arguments
77
  */
78
  return apply_filters( 'crp_heading_title', $title, $args );
79
  }
@@ -82,10 +82,10 @@ function crp_heading_title( $args ) {
82
  /**
83
  * Returns the opening tag of the related posts list.
84
  *
85
- * @since 2.2.0
86
  *
87
- * @param array $args Array of arguments.
88
- * @return string Space separated list of link attributes
89
  */
90
  function crp_before_list( $args ) {
91
 
@@ -94,10 +94,10 @@ function crp_before_list( $args ) {
94
  /**
95
  * Filter the opening tag of the related posts list
96
  *
97
- * @since 1.9
98
  *
99
- * @param string $before_list Opening tag set in the Settings Page
100
- * @param array $args Array of arguments
101
  */
102
  return apply_filters( 'crp_before_list', $before_list, $args );
103
 
@@ -107,10 +107,10 @@ function crp_before_list( $args ) {
107
  /**
108
  * Returns the closing tag of the related posts list.
109
  *
110
- * @since 2.2.0
111
  *
112
- * @param array $args Array of arguments.
113
- * @return string Space separated list of link attributes
114
  */
115
  function crp_after_list( $args ) {
116
 
@@ -119,10 +119,10 @@ function crp_after_list( $args ) {
119
  /**
120
  * Filter the closing tag of the related posts list
121
  *
122
- * @since 1.9
123
  *
124
- * @param string $after_list Closing tag set in the Settings Page
125
- * @param array $args Array of arguments
126
  */
127
  return apply_filters( 'crp_after_list', $after_list, $args );
128
 
@@ -132,11 +132,11 @@ function crp_after_list( $args ) {
132
  /**
133
  * Returns the opening tag of each list item.
134
  *
135
- * @since 2.2.0
136
  *
137
- * @param array $args Array of arguments.
138
- * @param object $result Object of the current post result.
139
- * @return string Space separated list of link attributes
140
  */
141
  function crp_before_list_item( $args, $result ) {
142
 
@@ -145,11 +145,11 @@ function crp_before_list_item( $args, $result ) {
145
  /**
146
  * Filter the opening tag of each list item.
147
  *
148
- * @since 1.9
149
  *
150
- * @param string $before_list_item Tag before each list item. Can be defined in the Settings page.
151
- * @param object $result Object of the current post result
152
- * @param array $args Array of arguments
153
  */
154
  return apply_filters( 'crp_before_list_item', $before_list_item, $result, $args );
155
 
@@ -159,11 +159,11 @@ function crp_before_list_item( $args, $result ) {
159
  /**
160
  * Returns the closing tag of each list item.
161
  *
162
- * @since 2.2.0
163
  *
164
- * @param array $args Array of arguments.
165
- * @param object $result Object of the current post result.
166
- * @return string Space separated list of link attributes
167
  */
168
  function crp_after_list_item( $args, $result ) {
169
 
@@ -172,11 +172,11 @@ function crp_after_list_item( $args, $result ) {
172
  /**
173
  * Filter the closing tag of each list item.
174
  *
175
- * @since 1.9
176
  *
177
- * @param string $after_list_item Tag after each list item. Can be defined in the Settings page.
178
- * @param object $result Object of the current post result
179
- * @param array $args Array of arguments
180
  */
181
  return apply_filters( 'crp_after_list_item', $after_list_item, $result, $args );
182
 
@@ -186,24 +186,24 @@ function crp_after_list_item( $args, $result ) {
186
  /**
187
  * Returns the title of each list item.
188
  *
189
- * @since 2.2.0
190
  *
191
- * @param array $args Array of arguments.
192
- * @param object $result Object of the current post result.
193
- * @return string Space separated list of link attributes
194
  */
195
  function crp_title( $args, $result ) {
196
 
197
- $title = crp_trim_char( get_the_title( $result->ID ), $args['title_length'] ); // Get the post title and crop it if needed.
198
 
199
  /**
200
  * Filter the title of each list item.
201
  *
202
- * @since 1.9
203
  *
204
- * @param string $title Title of the post.
205
- * @param object $result Object of the current post result
206
- * @param array $args Array of arguments
207
  */
208
  return apply_filters( 'crp_title', $title, $result, $args );
209
 
@@ -213,11 +213,11 @@ function crp_title( $args, $result ) {
213
  /**
214
  * Returns the author of each list item.
215
  *
216
- * @since 2.2.0
217
  *
218
- * @param array $args Array of arguments.
219
- * @param object $result Object of the current post result.
220
- * @return string Space separated list of link attributes
221
  */
222
  function crp_author( $args, $result ) {
223
 
@@ -228,10 +228,10 @@ function crp_author( $args, $result ) {
228
  /**
229
  * Filter the author name.
230
  *
231
- * @since 1.9.1
232
  *
233
- * @param string $author_name Proper name of the post author.
234
- * @param object $author_info WP_User object of the post author
235
  */
236
  $author_name = apply_filters( 'crp_author_name', $author_name, $author_info );
237
 
@@ -244,51 +244,81 @@ function crp_author( $args, $result ) {
244
  /**
245
  * Filter the text with the author details.
246
  *
247
- * @since 2.0.0
248
  *
249
- * @param string $crp_author Formatted string with author details and link
250
- * @param object $author_info WP_User object of the post author
251
- * @param object $result Object of the current post result
252
- * @param array $args Array of arguments
253
  */
254
  return apply_filters( 'crp_author', $crp_author, $author_info, $result, $args );
255
 
256
  }
257
 
258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  /**
260
  * Returns the formatted list item with link and and thumbnail for each list item.
261
  *
262
- * @since 2.2.0
263
  *
264
- * @param array $args Array of arguments.
265
- * @param object $result Object of the current post result.
266
- * @return string Space separated list of link attributes
267
  */
268
  function crp_list_link( $args, $result ) {
269
 
270
- $output = '';
271
- $title = crp_title( $args, $result );
 
272
  $link_attributes = crp_link_attributes( $args );
273
 
274
- $output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . '>';
275
 
276
  if ( 'after' === $args['post_thumb_op'] ) {
277
  $output .= '<span class="crp_title">' . $title . '</span>'; // Add title when required by settings.
278
  }
279
 
280
  if ( 'inline' === $args['post_thumb_op'] || 'after' === $args['post_thumb_op'] || 'thumbs_only' === $args['post_thumb_op'] ) {
281
- $output .= crp_get_the_post_thumbnail( array(
282
- 'postid' => $result->ID,
283
- 'thumb_height' => $args['thumb_height'],
284
- 'thumb_width' => $args['thumb_width'],
285
- 'thumb_meta' => $args['thumb_meta'],
286
- 'thumb_html' => $args['thumb_html'],
287
- 'thumb_default' => $args['thumb_default'],
288
- 'thumb_default_show' => $args['thumb_default_show'],
289
- 'scan_images' => $args['scan_images'],
290
- 'class' => 'crp_thumb',
291
- ) );
 
 
292
  }
293
 
294
  if ( 'inline' === $args['post_thumb_op'] || 'text_only' === $args['post_thumb_op'] ) {
@@ -300,11 +330,11 @@ function crp_list_link( $args, $result ) {
300
  /**
301
  * Filter Formatted list item with link and and thumbnail.
302
  *
303
- * @since 2.2.0
304
  *
305
- * @param string $output Formatted list item with link and and thumbnail
306
- * @param object $result Object of the current post result
307
- * @param array $args Array of arguments
308
  */
309
  return apply_filters( 'crp_list_link', $output, $result, $args );
310
 
3
  * Generates the output
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
17
  /**
18
  * Returns the link attributes.
19
  *
20
+ * @since 2.2.0
21
  *
22
+ * @param array $args Array of arguments.
23
+ * @return string Space separated list of link attributes.
24
  */
25
  function crp_link_attributes( $args ) {
26
 
27
+ $rel_attribute = ( $args['link_nofollow'] ) ? ' rel="nofollow" ' : ' ';
28
  $target_attribute = ( $args['link_new_window'] ) ? ' target="_blank" ' : ' ';
29
 
30
  $link_attributes = array(
31
+ 'rel_attribute' => $rel_attribute,
32
  'target_attribute' => $target_attribute,
33
  );
34
 
35
  /**
36
  * Filter the title of the Related Posts list
37
  *
38
+ * @since 2.2.0
39
  *
40
+ * @param array $link_attributes Array of link attributes
41
+ * @param array $args Array of arguments
42
  */
43
  $link_attributes = apply_filters( 'crp_link_attributes', $link_attributes, $args );
44
 
53
  /**
54
  * Returns the heading of the related posts.
55
  *
56
+ * @since 2.2.0
57
  *
58
+ * @param array $args Array of arguments.
59
+ * @return string Space separated list of link attributes
60
  */
61
  function crp_heading_title( $args ) {
62
  global $post;
64
  $title = '';
65
 
66
  if ( $args['heading'] && ! $args['is_widget'] ) {
67
+ $title = str_replace( '%postname%', $post->post_title, $args['title'] ); // Replace %postname% with the title of the current post.
68
  }
69
 
70
  /**
71
  * Filter the title of the Related Posts list
72
  *
73
+ * @since 1.9
74
  *
75
+ * @param string $title Title/heading of the Related Posts list
76
+ * @param array $args Array of arguments
77
  */
78
  return apply_filters( 'crp_heading_title', $title, $args );
79
  }
82
  /**
83
  * Returns the opening tag of the related posts list.
84
  *
85
+ * @since 2.2.0
86
  *
87
+ * @param array $args Array of arguments.
88
+ * @return string Space separated list of link attributes
89
  */
90
  function crp_before_list( $args ) {
91
 
94
  /**
95
  * Filter the opening tag of the related posts list
96
  *
97
+ * @since 1.9
98
  *
99
+ * @param string $before_list Opening tag set in the Settings Page
100
+ * @param array $args Array of arguments
101
  */
102
  return apply_filters( 'crp_before_list', $before_list, $args );
103
 
107
  /**
108
  * Returns the closing tag of the related posts list.
109
  *
110
+ * @since 2.2.0
111
  *
112
+ * @param array $args Array of arguments.
113
+ * @return string Space separated list of link attributes
114
  */
115
  function crp_after_list( $args ) {
116
 
119
  /**
120
  * Filter the closing tag of the related posts list
121
  *
122
+ * @since 1.9
123
  *
124
+ * @param string $after_list Closing tag set in the Settings Page
125
+ * @param array $args Array of arguments
126
  */
127
  return apply_filters( 'crp_after_list', $after_list, $args );
128
 
132
  /**
133
  * Returns the opening tag of each list item.
134
  *
135
+ * @since 2.2.0
136
  *
137
+ * @param array $args Array of arguments.
138
+ * @param object $result Object of the current post result.
139
+ * @return string Space separated list of link attributes
140
  */
141
  function crp_before_list_item( $args, $result ) {
142
 
145
  /**
146
  * Filter the opening tag of each list item.
147
  *
148
+ * @since 1.9
149
  *
150
+ * @param string $before_list_item Tag before each list item. Can be defined in the Settings page.
151
+ * @param object $result Object of the current post result
152
+ * @param array $args Array of arguments
153
  */
154
  return apply_filters( 'crp_before_list_item', $before_list_item, $result, $args );
155
 
159
  /**
160
  * Returns the closing tag of each list item.
161
  *
162
+ * @since 2.2.0
163
  *
164
+ * @param array $args Array of arguments.
165
+ * @param object $result Object of the current post result.
166
+ * @return string Space separated list of link attributes
167
  */
168
  function crp_after_list_item( $args, $result ) {
169
 
172
  /**
173
  * Filter the closing tag of each list item.
174
  *
175
+ * @since 1.9
176
  *
177
+ * @param string $after_list_item Tag after each list item. Can be defined in the Settings page.
178
+ * @param object $result Object of the current post result
179
+ * @param array $args Array of arguments
180
  */
181
  return apply_filters( 'crp_after_list_item', $after_list_item, $result, $args );
182
 
186
  /**
187
  * Returns the title of each list item.
188
  *
189
+ * @since 2.2.0
190
  *
191
+ * @param array $args Array of arguments.
192
+ * @param object $result Object of the current post result.
193
+ * @return string Space separated list of link attributes
194
  */
195
  function crp_title( $args, $result ) {
196
 
197
+ $title = crp_trim_char( get_the_title( $result->ID ), $args['title_length'] ); // Get the post title and crop it if needed.
198
 
199
  /**
200
  * Filter the title of each list item.
201
  *
202
+ * @since 1.9
203
  *
204
+ * @param string $title Title of the post.
205
+ * @param object $result Object of the current post result
206
+ * @param array $args Array of arguments
207
  */
208
  return apply_filters( 'crp_title', $title, $result, $args );
209
 
213
  /**
214
  * Returns the author of each list item.
215
  *
216
+ * @since 2.2.0
217
  *
218
+ * @param array $args Array of arguments.
219
+ * @param object $result Object of the current post result.
220
+ * @return string Space separated list of link attributes
221
  */
222
  function crp_author( $args, $result ) {
223
 
228
  /**
229
  * Filter the author name.
230
  *
231
+ * @since 1.9.1
232
  *
233
+ * @param string $author_name Proper name of the post author.
234
+ * @param object $author_info WP_User object of the post author
235
  */
236
  $author_name = apply_filters( 'crp_author_name', $author_name, $author_info );
237
 
244
  /**
245
  * Filter the text with the author details.
246
  *
247
+ * @since 2.0.0
248
  *
249
+ * @param string $crp_author Formatted string with author details and link
250
+ * @param object $author_info WP_User object of the post author
251
+ * @param object $result Object of the current post result
252
+ * @param array $args Array of arguments
253
  */
254
  return apply_filters( 'crp_author', $crp_author, $author_info, $result, $args );
255
 
256
  }
257
 
258
 
259
+ /**
260
+ * Returns the permalink of each list item.
261
+ *
262
+ * @since 2.5.0
263
+ *
264
+ * @param array $args Array of arguments.
265
+ * @param object $result Object of the current post result.
266
+ * @return string Space separated list of link attributes
267
+ */
268
+ function crp_permalink( $args, $result ) {
269
+
270
+ $link = get_permalink( $result->ID );
271
+
272
+ /**
273
+ * Filter the title of each list item.
274
+ *
275
+ * @since 2.5.0
276
+ *
277
+ * @param string $title Permalink of the post.
278
+ * @param object $result Object of the current post result
279
+ * @param array $args Array of arguments
280
+ */
281
+ return apply_filters( 'crp_permalink', $link, $result, $args );
282
+
283
+ }
284
+
285
+
286
  /**
287
  * Returns the formatted list item with link and and thumbnail for each list item.
288
  *
289
+ * @since 2.2.0
290
  *
291
+ * @param array $args Array of arguments.
292
+ * @param object $result Object of the current post result.
293
+ * @return string Space separated list of link attributes
294
  */
295
  function crp_list_link( $args, $result ) {
296
 
297
+ $output = '';
298
+ $title = crp_title( $args, $result );
299
+ $link = crp_permalink( $args, $result );
300
  $link_attributes = crp_link_attributes( $args );
301
 
302
+ $output .= '<a href="' . $link . '" ' . $link_attributes . '>';
303
 
304
  if ( 'after' === $args['post_thumb_op'] ) {
305
  $output .= '<span class="crp_title">' . $title . '</span>'; // Add title when required by settings.
306
  }
307
 
308
  if ( 'inline' === $args['post_thumb_op'] || 'after' === $args['post_thumb_op'] || 'thumbs_only' === $args['post_thumb_op'] ) {
309
+ $output .= crp_get_the_post_thumbnail(
310
+ array(
311
+ 'postid' => $result->ID,
312
+ 'thumb_height' => $args['thumb_height'],
313
+ 'thumb_width' => $args['thumb_width'],
314
+ 'thumb_meta' => $args['thumb_meta'],
315
+ 'thumb_html' => $args['thumb_html'],
316
+ 'thumb_default' => $args['thumb_default'],
317
+ 'thumb_default_show' => $args['thumb_default_show'],
318
+ 'scan_images' => $args['scan_images'],
319
+ 'class' => 'crp_thumb',
320
+ )
321
+ );
322
  }
323
 
324
  if ( 'inline' === $args['post_thumb_op'] || 'text_only' === $args['post_thumb_op'] ) {
330
  /**
331
  * Filter Formatted list item with link and and thumbnail.
332
  *
333
+ * @since 2.2.0
334
  *
335
+ * @param string $output Formatted list item with link and and thumbnail
336
+ * @param object $result Object of the current post result
337
+ * @param array $args Array of arguments
338
  */
339
  return apply_filters( 'crp_list_link', $output, $result, $args );
340
 
includes/plugin-activator.php CHANGED
@@ -3,10 +3,10 @@
3
  * Fired during plugin activation
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  /**
@@ -25,10 +25,12 @@ function crp_activate( $network_wide ) {
25
  if ( is_multisite() && $network_wide ) {
26
 
27
  // Get all blogs in the network and activate plugin on each one.
28
- $blog_ids = $wpdb->get_col( "
 
29
  SELECT blog_id FROM $wpdb->blogs
30
  WHERE archived = '0' AND spam = '0' AND deleted = '0'
31
- " );
 
32
  foreach ( $blog_ids as $blog_id ) {
33
  switch_to_blog( $blog_id );
34
  crp_single_activate();
3
  * Fired during plugin activation
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  /**
25
  if ( is_multisite() && $network_wide ) {
26
 
27
  // Get all blogs in the network and activate plugin on each one.
28
+ $blog_ids = $wpdb->get_col(
29
+ "
30
  SELECT blog_id FROM $wpdb->blogs
31
  WHERE archived = '0' AND spam = '0' AND deleted = '0'
32
+ "
33
+ );
34
  foreach ( $blog_ids as $blog_id ) {
35
  switch_to_blog( $blog_id );
36
  crp_single_activate();
includes/tools.php CHANGED
@@ -3,10 +3,10 @@
3
  * Tool functions
4
  *
5
  * @package Contextual_Related_Posts
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2017 Ajay D'Souza
10
  */
11
 
12
  /**
@@ -22,24 +22,27 @@
22
  function crp_excerpt( $id, $excerpt_length = 0, $use_excerpt = true ) {
23
  $content = '';
24
 
25
- if ( $use_excerpt ) {
26
- $content = get_post( $id )->post_excerpt;
27
- }
28
- if ( empty( $content ) ) {
29
- $content = get_post( $id )->post_content;
 
 
 
30
  }
31
 
32
- $output = strip_tags( strip_shortcodes( $content ) );
33
 
34
  /**
35
  * Filters excerpt generated by CRP before it is trimmed.
36
  *
37
  * @since 2.3.0
38
  *
39
- * @param array $output Formatted excerpt
40
- * @param int $id Post ID
41
- * @param int $excerpt_length Length of the excerpt
42
- * @param boolean $use_excerpt Use the excerpt?
43
  */
44
  $output = apply_filters( 'crp_excerpt_pre_trim', $output, $id, $excerpt_length, $use_excerpt );
45
 
@@ -54,12 +57,12 @@ function crp_excerpt( $id, $excerpt_length = 0, $use_excerpt = true ) {
54
  /**
55
  * Filters excerpt generated by CRP.
56
  *
57
- * @since 1.9
58
  *
59
- * @param array $output Formatted excerpt
60
- * @param int $id Post ID
61
- * @param int $excerpt_length Length of the excerpt
62
- * @param boolean $use_excerpt Use the excerpt?
63
  */
64
  return apply_filters( 'crp_excerpt', $output, $id, $excerpt_length, $use_excerpt );
65
  }
@@ -107,76 +110,16 @@ function crp_trim_char( $string, $count = 60, $more = '&hellip;', $break_words =
107
  return apply_filters( 'crp_trim_char', $string, $count, $more, $break_words );
108
  }
109
 
110
- /**
111
- * Delete the CRP cache.
112
- *
113
- * @param array $meta_keys Array of meta keys that hold the cache.
114
- */
115
- function crp_cache_delete( $meta_keys = array() ) {
116
-
117
- $default_meta_keys = crp_cache_get_keys();
118
-
119
- if ( ! empty( $meta_keys ) ) {
120
- $meta_keys = array_intersect( $default_meta_keys, (array) $meta_keys );
121
- } else {
122
- $meta_keys = $default_meta_keys;
123
- }
124
-
125
- foreach ( $meta_keys as $meta_key ) {
126
- delete_post_meta_by_key( $meta_key );
127
- }
128
- }
129
-
130
- /**
131
- * Get the default meta keys used for the cache
132
- */
133
- function crp_cache_get_keys() {
134
-
135
- $meta_keys = array(
136
- 'crp_related_posts',
137
- 'crp_related_posts_widget',
138
- 'crp_related_posts_feed',
139
- 'crp_related_posts_widget_feed',
140
- 'crp_related_posts_manual',
141
- );
142
-
143
- /**
144
- * Filters the array containing the various cache keys.
145
- *
146
- * @since 1.9
147
- *
148
- * @param array $default_meta_keys Array of meta keys
149
- */
150
- return apply_filters( 'crp_cache_keys', $meta_keys );
151
- }
152
-
153
  /**
154
  * Create the FULLTEXT index.
155
  *
156
- * @since 2.2.1
157
  */
158
  function crp_create_index() {
159
  global $wpdb;
160
 
161
  $wpdb->hide_errors();
162
 
163
- // If we're running mySQL v5.6, convert the WPDB posts table to InnoDB, since InnoDB supports FULLTEXT from v5.6 onwards.
164
- if ( version_compare( 5.6, $wpdb->db_version(), '<=' ) ) {
165
- $table_engine = 'InnoDB';
166
- } else {
167
- $table_engine = 'MyISAM';
168
- }
169
-
170
- $current_engine = $wpdb->get_row( "
171
- SELECT engine FROM INFORMATION_SCHEMA.TABLES
172
- WHERE table_schema=DATABASE()
173
- AND table_name = '{$wpdb->posts}'
174
- " );
175
-
176
- if ( $current_engine->engine !== $table_engine ) {
177
- $wpdb->query( "ALTER TABLE {$wpdb->posts} ENGINE = {$table_engine};" ); // WPCS: unprepared SQL OK.
178
- }
179
-
180
  if ( ! $wpdb->get_results( "SHOW INDEX FROM {$wpdb->posts} where Key_name = 'crp_related'" ) ) {
181
  $wpdb->query( "ALTER TABLE {$wpdb->posts} ADD FULLTEXT crp_related (post_title, post_content);" );
182
  }
@@ -195,7 +138,7 @@ function crp_create_index() {
195
  /**
196
  * Delete the FULLTEXT index.
197
  *
198
- * @since 2.2.1
199
  */
200
  function crp_delete_index() {
201
  global $wpdb;
@@ -217,3 +160,21 @@ function crp_delete_index() {
217
  }
218
 
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  * Tool functions
4
  *
5
  * @package Contextual_Related_Posts
6
+ * @author Ajay D'Souza
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
+ * @copyright 2009-2018 Ajay D'Souza
10
  */
11
 
12
  /**
22
  function crp_excerpt( $id, $excerpt_length = 0, $use_excerpt = true ) {
23
  $content = '';
24
 
25
+ $post = get_post( $id );
26
+ if ( $post ) {
27
+ if ( $use_excerpt ) {
28
+ $content = $post->post_excerpt;
29
+ }
30
+ if ( empty( $content ) ) {
31
+ $content = $post->post_content;
32
+ }
33
  }
34
 
35
+ $output = wp_strip_all_tags( strip_shortcodes( $content ) );
36
 
37
  /**
38
  * Filters excerpt generated by CRP before it is trimmed.
39
  *
40
  * @since 2.3.0
41
  *
42
+ * @param array $output Formatted excerpt
43
+ * @param int $id Post ID
44
+ * @param int $excerpt_length Length of the excerpt
45
+ * @param boolean $use_excerpt Use the excerpt?
46
  */
47
  $output = apply_filters( 'crp_excerpt_pre_trim', $output, $id, $excerpt_length, $use_excerpt );
48
 
57
  /**
58
  * Filters excerpt generated by CRP.
59
  *
60
+ * @since 1.9
61
  *
62
+ * @param array $output Formatted excerpt
63
+ * @param int $id Post ID
64
+ * @param int $excerpt_length Length of the excerpt
65
+ * @param boolean $use_excerpt Use the excerpt?
66
  */
67
  return apply_filters( 'crp_excerpt', $output, $id, $excerpt_length, $use_excerpt );
68
  }
110
  return apply_filters( 'crp_trim_char', $string, $count, $more, $break_words );
111
  }
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  /**
114
  * Create the FULLTEXT index.
115
  *
116
+ * @since 2.2.1
117
  */
118
  function crp_create_index() {
119
  global $wpdb;
120
 
121
  $wpdb->hide_errors();
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  if ( ! $wpdb->get_results( "SHOW INDEX FROM {$wpdb->posts} where Key_name = 'crp_related'" ) ) {
124
  $wpdb->query( "ALTER TABLE {$wpdb->posts} ADD FULLTEXT crp_related (post_title, post_content);" );
125
  }
138
  /**
139
  * Delete the FULLTEXT index.
140
  *
141
+ * @since 2.2.1
142
  */
143
  function crp_delete_index() {
144
  global $wpdb;
160
  }
161
 
162
 
163
+ /**
164
+ * Get the table schema for the posts table.
165
+ *
166
+ * @since 2.5.0
167
+ */
168
+ function crp_posts_table_engine() {
169
+ global $wpdb;
170
+
171
+ $engine = $wpdb->get_row(
172
+ "
173
+ SELECT engine FROM INFORMATION_SCHEMA.TABLES
174
+ WHERE table_schema=DATABASE()
175
+ AND table_name = '{$wpdb->posts}'
176
+ "
177
+ );
178
+
179
+ return $engine;
180
+ }
languages/contextual-related-posts-en_US.mo CHANGED
Binary file
languages/contextual-related-posts-en_US.po CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Contextual Related Posts\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2017-06-04 00:37+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
8
  "Language-Team: WebberZone <plugins@webberzone.com>\n"
@@ -13,65 +13,65 @@ msgstr ""
13
  "X-Poedit-KeywordsList: __;_e;_c;__ngettext;esc_html__;esc_attr__;esc_html_e;"
14
  "esc_attr_e\n"
15
  "X-Poedit-Basepath: ..\n"
16
- "X-Generator: Poedit 2.0.1\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
 
21
- #: admin/admin.php:226
22
  msgid "Options saved successfully. If enabled, the cache has been cleared."
23
  msgstr ""
24
 
25
- #: admin/admin.php:229
26
  msgid ""
27
  "Rounded Thumbnails style selected. Author, Excerpt and Date will not be "
28
  "displayed."
29
  msgstr ""
30
 
31
- #: admin/admin.php:232
32
  msgid "Text Only style selected. Thumbnails will not be displayed."
33
  msgstr ""
34
 
35
- #: admin/admin.php:236
36
  #, php-format
37
  msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %2$d."
38
  msgstr ""
39
 
40
- #: admin/admin.php:269
41
  msgid "Options set to Default."
42
  msgstr ""
43
 
44
- #: admin/admin.php:278
45
  msgid "Index recreated"
46
  msgstr ""
47
 
48
- #: admin/admin.php:295
49
  msgid "Related Posts"
50
  msgstr ""
51
 
52
- #: admin/cache.php:42
53
  msgid ""
54
  "An error occurred clearing the cache. Please contact your site administrator."
55
  "\\n\\nError message:\\n"
56
  msgstr ""
57
 
58
- #: admin/cache.php:47
59
  msgid " cached row(s) cleared"
60
  msgstr ""
61
 
62
- #: admin/loader.php:23
63
  msgid "Settings"
64
  msgstr ""
65
 
66
- #: admin/loader.php:44 admin/sidebar-view.php:48
67
  msgid "Support"
68
  msgstr ""
69
 
70
- #: admin/loader.php:45
71
  msgid "Donate"
72
  msgstr ""
73
 
74
- #: admin/loader.php:46
75
  msgid "Contribute"
76
  msgstr ""
77
 
@@ -79,29 +79,29 @@ msgstr ""
79
  msgid "General options"
80
  msgstr ""
81
 
82
- #: admin/main-view.php:33 admin/main-view.php:149
83
  msgid "List tuning options"
84
  msgstr ""
85
 
86
- #: admin/main-view.php:34 admin/main-view.php:259
87
  msgid "Output options"
88
  msgstr ""
89
 
90
- #: admin/main-view.php:35 admin/main-view.php:463
91
- #: includes/modules/class-crp-widget.php:105
92
  msgid "Thumbnail options"
93
  msgstr ""
94
 
95
- #: admin/main-view.php:36 admin/main-view.php:630
96
  msgid "Styles"
97
  msgstr ""
98
 
99
- #: admin/main-view.php:37 admin/main-view.php:713
100
  msgid "Feed options"
101
  msgstr ""
102
 
103
- #: admin/main-view.php:54 admin/main-view.php:148 admin/main-view.php:258
104
- #: admin/main-view.php:462 admin/main-view.php:629 admin/main-view.php:712
105
  #: admin/sidebar-view.php:19 admin/sidebar-view.php:40
106
  #: admin/sidebar-view.php:58
107
  msgid "Click to toggle"
@@ -196,85 +196,101 @@ msgid ""
196
  msgstr ""
197
 
198
  #: admin/main-view.php:107
199
- msgid "Show metabox:"
200
  msgstr ""
201
 
202
  #: admin/main-view.php:110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  msgid ""
204
  "This will add the Contextual Related Posts metabox on Edit Posts or Add New "
205
  "Posts screens. Also applies to Pages and Custom Post Types."
206
  msgstr ""
207
 
208
- #: admin/main-view.php:114
209
  msgid "Limit metabox to Admins only:"
210
  msgstr ""
211
 
212
- #: admin/main-view.php:117
213
  msgid ""
214
  "If this is selected, the metabox will be hidden from anyone who is not an "
215
  "Admin. Otherwise, by default, Contributors and above will be able to see the "
216
  "metabox. This applies only if the above option is selected."
217
  msgstr ""
218
 
219
- #: admin/main-view.php:121
220
  msgid "Tell the world you're using Contextual Related Posts:"
221
  msgstr ""
222
 
223
- #: admin/main-view.php:123
224
  msgid "Optional"
225
  msgstr ""
226
 
227
- #: admin/main-view.php:124
228
  msgid ""
229
  "Adds a nofollow link to Contextual Related Posts homepage as the last time "
230
  "in the list."
231
  msgstr ""
232
 
233
- #: admin/main-view.php:142 admin/main-view.php:252 admin/main-view.php:456
234
- #: admin/main-view.php:623 admin/main-view.php:706 admin/main-view.php:778
235
- #: admin/main-view.php:794
236
  msgid "Save Options"
237
  msgstr ""
238
 
239
- #: admin/main-view.php:165 admin/main-view.php:731
240
  msgid "Number of related posts to display: "
241
  msgstr ""
242
 
243
- #: admin/main-view.php:168
244
  msgid ""
245
  "Maximum number of posts that will be displayed. The actual number may be "
246
  "smaller if less related posts are found."
247
  msgstr ""
248
 
249
- #: admin/main-view.php:172
250
  msgid "Related posts should be newer than:"
251
  msgstr ""
252
 
253
- #: admin/main-view.php:174
254
  msgid "days"
255
  msgstr ""
256
 
257
- #: admin/main-view.php:175
258
  msgid ""
259
  "This sets the cutoff period for which posts will be displayed. e.g. setting "
260
  "it to 365 will show related posts from the last year only. Set to 0 to "
261
  "disable limiting posts by date."
262
  msgstr ""
263
 
264
- #: admin/main-view.php:179
265
  msgid "Randomize posts"
266
  msgstr ""
267
 
268
- #: admin/main-view.php:181
269
  msgid ""
270
  "This shuffles the top related posts. Does not work if the cache is enabled."
271
  msgstr ""
272
 
273
- #: admin/main-view.php:185
274
  msgid "Find related posts based on content as well as title:"
275
  msgstr ""
276
 
277
- #: admin/main-view.php:187
278
  msgid ""
279
  "If unchecked, only posts titles are used. I recommend using a caching plugin "
280
  "or enabling \"Cache output\" above if you enable this. Each site is "
@@ -282,99 +298,99 @@ msgid ""
282
  "quality related posts."
283
  msgstr ""
284
 
285
- #: admin/main-view.php:191
286
  msgid "Limit content to be compared:"
287
  msgstr ""
288
 
289
- #: admin/main-view.php:193
290
  msgid ""
291
  "This sets the maximum words of the content that will be matched. Set to 0 "
292
  "for no limit. Max value: 2,000. Only applies if you activate the above "
293
  "option."
294
  msgstr ""
295
 
296
- #: admin/main-view.php:197
297
  msgid "Post types to include in results:"
298
  msgstr ""
299
 
300
- #: admin/main-view.php:204
301
  msgid ""
302
  "These post types will be displayed in the list. Includes custom post types."
303
  msgstr ""
304
 
305
- #: admin/main-view.php:208
306
  msgid "Limit to same post type"
307
  msgstr ""
308
 
309
- #: admin/main-view.php:210
310
  msgid ""
311
  "If checked, the related posts will only be selected from the same post type "
312
  "of the current post."
313
  msgstr ""
314
 
315
- #: admin/main-view.php:214
316
  msgid "List of post or page IDs to exclude from the results:"
317
  msgstr ""
318
 
319
- #: admin/main-view.php:216 admin/main-view.php:387
320
  msgid ""
321
  "Comma separated list of post, page or custom post type IDs. e.g. 188,320,500"
322
  msgstr ""
323
 
324
- #: admin/main-view.php:220
325
  msgid "Categories to exclude from the results: "
326
  msgstr ""
327
 
328
- #: admin/main-view.php:223
329
  msgid ""
330
  "Comma separated list of category slugs. The field above has an autocomplete "
331
  "so simply start typing in the beginning of your category name and it will "
332
  "prompt you with options."
333
  msgstr ""
334
 
335
- #: admin/main-view.php:226
336
  msgid "Excluded category IDs are:"
337
  msgstr ""
338
 
339
- #: admin/main-view.php:227
340
  msgid " "
341
  msgstr ""
342
 
343
- #: admin/main-view.php:232
344
  #, php-format
345
  msgid ""
346
  "These might differ from the IDs visible in the Categories page which use the "
347
  "%1$s. CRP uses the %2$s which is unique to this taxonomy."
348
  msgstr ""
349
 
350
- #: admin/main-view.php:275
351
  msgid "Title of related posts:"
352
  msgstr ""
353
 
354
- #: admin/main-view.php:278
355
  #, php-format
356
  msgid ""
357
  "This is the main heading of the related posts. You can also display the "
358
  "current post title by using %1$s"
359
  msgstr ""
360
 
361
- #: admin/main-view.php:282
362
  msgid "When there are no posts, what should be shown?"
363
  msgstr ""
364
 
365
- #: admin/main-view.php:286
366
  msgid "Blank Output"
367
  msgstr ""
368
 
369
- #: admin/main-view.php:291
370
  msgid "Display:"
371
  msgstr ""
372
 
373
- #: admin/main-view.php:297 admin/main-view.php:734
374
  msgid "Show post excerpt in list?"
375
  msgstr ""
376
 
377
- #: admin/main-view.php:300
378
  #, php-format
379
  msgid ""
380
  "Displays the excerpt of the post. If you do not provide an explicit excerpt "
@@ -382,122 +398,122 @@ msgid ""
382
  "automatic excerpt which refers to the first %d words of the post's content"
383
  msgstr ""
384
 
385
- #: admin/main-view.php:303
386
  msgid ""
387
  "Rounded Thumbnails style selected under the Custom Styles. Excerpt display "
388
  "is disabled."
389
  msgstr ""
390
 
391
- #: admin/main-view.php:308
392
  msgid "Length of excerpt (in words):"
393
  msgstr ""
394
 
395
- #: admin/main-view.php:314
396
  msgid "Show post author in list?"
397
  msgstr ""
398
 
399
- #: admin/main-view.php:317
400
  msgid "Displays the author name prefixed with \"by\". e.g. by John Doe"
401
  msgstr ""
402
 
403
- #: admin/main-view.php:320
404
  msgid ""
405
  "Rounded Thumbnails style selected under the Custom Styles. Author display is "
406
  "disabled."
407
  msgstr ""
408
 
409
- #: admin/main-view.php:325
410
  msgid "Show post date in list?"
411
  msgstr ""
412
 
413
- #: admin/main-view.php:328
414
  msgid ""
415
  "Displays the date of the post. Uses the same date format set in General "
416
  "Options"
417
  msgstr ""
418
 
419
- #: admin/main-view.php:331
420
  msgid ""
421
  "Rounded Thumbnails style selected under the Custom Styles. Date display is "
422
  "disabled."
423
  msgstr ""
424
 
425
- #: admin/main-view.php:336
426
  msgid "Limit post title length (in characters)"
427
  msgstr ""
428
 
429
- #: admin/main-view.php:339
430
  msgid ""
431
  "Any title longer than the number of characters set above will be cut and "
432
  "appended with an ellipsis (&hellip;)"
433
  msgstr ""
434
 
435
- #: admin/main-view.php:343
436
  msgid "Open links in new window"
437
  msgstr ""
438
 
439
- #: admin/main-view.php:349
440
  msgid "Add nofollow attribute to links in the list"
441
  msgstr ""
442
 
443
- #: admin/main-view.php:382
444
  msgid "Exclusion settings:"
445
  msgstr ""
446
 
447
- #: admin/main-view.php:384
448
  msgid "Exclude display of related posts on these posts / pages"
449
  msgstr ""
450
 
451
- #: admin/main-view.php:390
452
  msgid "Exclude display of related posts on these post types."
453
  msgstr ""
454
 
455
- #: admin/main-view.php:397
456
  msgid ""
457
  "The related posts will not display on any of the above selected post types"
458
  msgstr ""
459
 
460
- #: admin/main-view.php:427
461
  msgid "Customize the output:"
462
  msgstr ""
463
 
464
- #: admin/main-view.php:429
465
  msgid "HTML to display before the list of posts: "
466
  msgstr ""
467
 
468
- #: admin/main-view.php:432
469
  msgid "HTML to display before each list item: "
470
  msgstr ""
471
 
472
- #: admin/main-view.php:435
473
  msgid "HTML to display after each list item: "
474
  msgstr ""
475
 
476
- #: admin/main-view.php:438
477
  msgid "HTML to display after the list of posts: "
478
  msgstr ""
479
 
480
- #: admin/main-view.php:479 admin/main-view.php:737
481
  msgid "Location of post thumbnail:"
482
  msgstr ""
483
 
484
- #: admin/main-view.php:483 admin/main-view.php:741
485
  msgid "Display thumbnails inline with posts, before title"
486
  msgstr ""
487
 
488
- #: admin/main-view.php:488 admin/main-view.php:745
489
  msgid "Display thumbnails inline with posts, after title"
490
  msgstr ""
491
 
492
- #: admin/main-view.php:493 admin/main-view.php:749
493
  msgid "Display only thumbnails, no text"
494
  msgstr ""
495
 
496
- #: admin/main-view.php:498 admin/main-view.php:753
497
  msgid "Do not display thumbnails, only text."
498
  msgstr ""
499
 
500
- #: admin/main-view.php:502
501
  #, php-format
502
  msgid ""
503
  "This setting cannot be changed because an inbuilt style has been selected "
@@ -505,140 +521,140 @@ msgid ""
505
  "select %1$s under the Styles section."
506
  msgstr ""
507
 
508
- #: admin/main-view.php:502 admin/main-view.php:649
509
  msgid "No styles"
510
  msgstr ""
511
 
512
- #: admin/main-view.php:506
513
  msgid "Thumbnail size:"
514
  msgstr ""
515
 
516
- #: admin/main-view.php:531
517
  msgid "Custom size"
518
  msgstr ""
519
 
520
- #: admin/main-view.php:534
521
  msgid "You can choose from existing image sizes above or create a custom size."
522
  msgstr ""
523
 
524
- #: admin/main-view.php:535
525
  msgid ""
526
  "If you choose an existing size, then the width, height and crop mode "
527
  "settings in the three options below will be automatically updated to reflect "
528
  "the correct dimensions of the setting."
529
  msgstr ""
530
 
531
- #: admin/main-view.php:536
532
  msgid ""
533
  "If you have chosen Custom size above, then enter the width, height and crop "
534
  "settings below. For best results, use a cropped image with the same width "
535
  "and height. The default setting is 150x150 cropped image."
536
  msgstr ""
537
 
538
- #: admin/main-view.php:537
539
  msgid ""
540
  "Any changes to the thumbnail settings doesn't automatically resize existing "
541
  "images."
542
  msgstr ""
543
 
544
- #: admin/main-view.php:539
545
  #, php-format
546
  msgid "I recommend using %1$s or %2$s to regenerate all image sizes."
547
  msgstr ""
548
 
549
- #: admin/main-view.php:546
550
  msgid "Width of the thumbnail:"
551
  msgstr ""
552
 
553
- #: admin/main-view.php:549
554
  msgid "Height of the thumbnail: "
555
  msgstr ""
556
 
557
- #: admin/main-view.php:554
558
  msgid "Crop mode:"
559
  msgstr ""
560
 
561
- #: admin/main-view.php:558
562
  msgid ""
563
  "By default, thumbnails will be hard cropped. Uncheck this box to "
564
  "proportionately/soft crop the thumbnails."
565
  msgstr ""
566
 
567
- #: admin/main-view.php:562
568
  msgid "Image size attributes:"
569
  msgstr ""
570
 
571
- #: admin/main-view.php:566
572
  msgid "Style attributes. e.g."
573
  msgstr ""
574
 
575
- #: admin/main-view.php:572
576
  msgid "HTML width and height attributes. e.g."
577
  msgstr ""
578
 
579
- #: admin/main-view.php:578
580
  msgid "No HTML or Style attributes"
581
  msgstr ""
582
 
583
- #: admin/main-view.php:583
584
  msgid "Post thumbnail meta field name:"
585
  msgstr ""
586
 
587
- #: admin/main-view.php:585
588
  #, php-format
589
  msgid ""
590
  "The value of this field should contain a direct link to the image. This is "
591
  "set in the meta box in the %1$s screen."
592
  msgstr ""
593
 
594
- #: admin/main-view.php:585
595
  msgid "Add New Post"
596
  msgstr ""
597
 
598
- #: admin/main-view.php:588
599
  msgid "Extract the first image from the post?"
600
  msgstr ""
601
 
602
- #: admin/main-view.php:590
603
  msgid ""
604
  "This will only happen if there is no post thumbnail set and no image URL is "
605
  "specified in the meta field."
606
  msgstr ""
607
 
608
- #: admin/main-view.php:593
609
  msgid "Use default thumbnail?"
610
  msgstr ""
611
 
612
- #: admin/main-view.php:595
613
  msgid ""
614
  "If checked, when no thumbnail is found, show a default one from the URL "
615
  "below. If not checked and no thumbnail is found, no image will be shown."
616
  msgstr ""
617
 
618
- #: admin/main-view.php:598
619
  msgid "Default thumbnail:"
620
  msgstr ""
621
 
622
- #: admin/main-view.php:605
623
  msgid ""
624
  "The plugin will first check if the post contains a thumbnail. If it doesn't "
625
  "then it will check the meta field. If this is not available, then it will "
626
  "show the default image as specified above."
627
  msgstr ""
628
 
629
- #: admin/main-view.php:646
630
  msgid "Style of the related posts:"
631
  msgstr ""
632
 
633
- #: admin/main-view.php:651
634
  msgid "Select this option if you plan to add your own styles"
635
  msgstr ""
636
 
637
- #: admin/main-view.php:655
638
  msgid "Rounded Thumbnails"
639
  msgstr ""
640
 
641
- #: admin/main-view.php:658
642
  msgid ""
643
  "Enabling this option will turn on the thumbnails and set their width and "
644
  "height to 150px. It will also turn off the display of the author, excerpt "
@@ -646,139 +662,139 @@ msgid ""
646
  "settings."
647
  msgstr ""
648
 
649
- #: admin/main-view.php:660
650
  #, php-format
651
  msgid "You can view the default style at %s"
652
  msgstr ""
653
 
654
- #: admin/main-view.php:666
655
  msgid "Text only"
656
  msgstr ""
657
 
658
- #: admin/main-view.php:668
659
  msgid ""
660
  "Enabling this option will disable thumbnails and no longer include the "
661
  "default style sheet included in the plugin."
662
  msgstr ""
663
 
664
- #: admin/main-view.php:683
665
  msgid "Custom CSS to add to header:"
666
  msgstr ""
667
 
668
- #: admin/main-view.php:688
669
  #, php-format
670
  msgid ""
671
  "Do not include %1$s tags. Check out the %2$s for available CSS classes to "
672
  "style."
673
  msgstr ""
674
 
675
- #: admin/main-view.php:729
676
  msgid ""
677
  "Below options override the related posts settings for your blog feed. These "
678
  "only apply if you have selected to add related posts to Feeds in the General "
679
  "Options tab."
680
  msgstr ""
681
 
682
- #: admin/main-view.php:757
683
  msgid "Maximum width of the thumbnail: "
684
  msgstr ""
685
 
686
- #: admin/main-view.php:760
687
  msgid "Maximum height of the thumbnail: "
688
  msgstr ""
689
 
690
- #: admin/main-view.php:795
691
  msgid "Default Options"
692
  msgstr ""
693
 
694
- #: admin/main-view.php:795
695
  msgid "Do you want to set options to Default?"
696
  msgstr ""
697
 
698
- #: admin/main-view.php:796
699
  msgid "Recreate Index"
700
  msgstr ""
701
 
702
- #: admin/main-view.php:796
703
  msgid "Are you sure you want to recreate the index?"
704
  msgstr ""
705
 
706
- #: admin/main-view.php:801
707
  #, php-format
708
  msgid ""
709
  "One or more FULLTEXT indices are missing. Please hit the %1$s at the bottom "
710
  "of the page to fix this."
711
  msgstr ""
712
 
713
- #: admin/main-view.php:801
714
  msgid "Recreate Index button"
715
  msgstr ""
716
 
717
- #: admin/main-view.php:806
718
  msgid ""
719
  "If the Recreate Index button fails, please run the following queries in "
720
  "phpMyAdmin or Adminer"
721
  msgstr ""
722
 
723
- #: admin/metabox.php:105
724
  msgid "Disable Related Posts display:"
725
  msgstr ""
726
 
727
- #: admin/metabox.php:108
728
  msgid ""
729
  "If this is checked, then Contextual Related Posts will not automatically "
730
  "insert the related posts at the end of post content."
731
  msgstr ""
732
 
733
- #: admin/metabox.php:112
734
  msgid "Exclude this post from the related posts list:"
735
  msgstr ""
736
 
737
- #: admin/metabox.php:115
738
  msgid ""
739
  "If this is checked, then this post will be excluded from the popular posts "
740
  "list."
741
  msgstr ""
742
 
743
- #: admin/metabox.php:119 admin/metabox.php:127
744
  msgid "Manual related posts:"
745
  msgstr ""
746
 
747
- #: admin/metabox.php:121
748
  msgid ""
749
  "Comma separated list of post, page or custom post type IDs. e.g. "
750
  "188,320,500. These will be given preference over the related posts generated "
751
  "by the plugin."
752
  msgstr ""
753
 
754
- #: admin/metabox.php:122
755
  msgid ""
756
  "Once you enter the list above and save this page, the plugin will display "
757
  "the titles of the posts below for your reference. Only IDs corresponding to "
758
  "published posts or custom post types will be retained."
759
  msgstr ""
760
 
761
- #: admin/metabox.php:138
762
  #, php-format
763
  msgid "This post type is: %s"
764
  msgstr ""
765
 
766
- #: admin/metabox.php:149
767
  msgid "Location of thumbnail"
768
  msgstr ""
769
 
770
- #: admin/metabox.php:151
771
  msgid ""
772
  "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This "
773
  "image will be used for the post. It will be resized to the thumbnail size "
774
  "set under Settings &raquo; Related Posts &raquo; Output Options"
775
  msgstr ""
776
 
777
- #: admin/metabox.php:152
778
  msgid "The URL above is saved in the meta field:"
779
  msgstr ""
780
 
781
- #: admin/metabox.php:157
782
  msgid ""
783
  "You have Top 10 WordPress Plugin installed. If you are trying to modify the "
784
  "thumbnail, then you'll need to make the same change in the Top 10 meta box "
@@ -845,7 +861,7 @@ msgstr ""
845
  msgid "No related posts found"
846
  msgstr ""
847
 
848
- #: includes/main-query.php:189
849
  #, php-format
850
  msgid "Powered by <a href=\"%s\" rel=\"nofollow\">Contextual Related Posts</a>"
851
  msgstr ""
@@ -870,55 +886,55 @@ msgstr ""
870
  msgid "Display Related Posts"
871
  msgstr ""
872
 
873
- #: includes/modules/class-crp-widget.php:76
874
  msgid "Title"
875
  msgstr ""
876
 
877
- #: includes/modules/class-crp-widget.php:81
878
  msgid "No. of posts"
879
  msgstr ""
880
 
881
- #: includes/modules/class-crp-widget.php:86
882
  msgid "Offset"
883
  msgstr ""
884
 
885
- #: includes/modules/class-crp-widget.php:91
886
  msgid " Show excerpt?"
887
  msgstr ""
888
 
889
- #: includes/modules/class-crp-widget.php:96
890
  msgid " Show author?"
891
  msgstr ""
892
 
893
- #: includes/modules/class-crp-widget.php:101
894
  msgid " Show date?"
895
  msgstr ""
896
 
897
- #: includes/modules/class-crp-widget.php:107
898
  msgid "Thumbnails inline, before title"
899
  msgstr ""
900
 
901
- #: includes/modules/class-crp-widget.php:108
902
  msgid "Thumbnails inline, after title"
903
  msgstr ""
904
 
905
- #: includes/modules/class-crp-widget.php:109
906
  msgid "Only thumbnails, no text"
907
  msgstr ""
908
 
909
- #: includes/modules/class-crp-widget.php:110
910
  msgid "No thumbnails, only text."
911
  msgstr ""
912
 
913
- #: includes/modules/class-crp-widget.php:115
914
  msgid "Thumbnail height"
915
  msgstr ""
916
 
917
- #: includes/modules/class-crp-widget.php:120
918
  msgid "Thumbnail width"
919
  msgstr ""
920
 
921
- #: includes/modules/class-crp-widget.php:124
922
  msgid "Post types to include"
923
  msgstr ""
924
 
2
  msgstr ""
3
  "Project-Id-Version: Contextual Related Posts\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2018-11-18 13:36+0000\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
8
  "Language-Team: WebberZone <plugins@webberzone.com>\n"
13
  "X-Poedit-KeywordsList: __;_e;_c;__ngettext;esc_html__;esc_attr__;esc_html_e;"
14
  "esc_attr_e\n"
15
  "X-Poedit-Basepath: ..\n"
16
+ "X-Generator: Poedit 2.2\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
 
21
+ #: admin/admin.php:232
22
  msgid "Options saved successfully. If enabled, the cache has been cleared."
23
  msgstr ""
24
 
25
+ #: admin/admin.php:235
26
  msgid ""
27
  "Rounded Thumbnails style selected. Author, Excerpt and Date will not be "
28
  "displayed."
29
  msgstr ""
30
 
31
+ #: admin/admin.php:238
32
  msgid "Text Only style selected. Thumbnails will not be displayed."
33
  msgstr ""
34
 
35
+ #: admin/admin.php:242
36
  #, php-format
37
  msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %2$d."
38
  msgstr ""
39
 
40
+ #: admin/admin.php:277
41
  msgid "Options set to Default."
42
  msgstr ""
43
 
44
+ #: admin/admin.php:286
45
  msgid "Index recreated"
46
  msgstr ""
47
 
48
+ #: admin/admin.php:303
49
  msgid "Related Posts"
50
  msgstr ""
51
 
52
+ #: admin/cache.php:49
53
  msgid ""
54
  "An error occurred clearing the cache. Please contact your site administrator."
55
  "\\n\\nError message:\\n"
56
  msgstr ""
57
 
58
+ #: admin/cache.php:58
59
  msgid " cached row(s) cleared"
60
  msgstr ""
61
 
62
+ #: admin/loader.php:24
63
  msgid "Settings"
64
  msgstr ""
65
 
66
+ #: admin/loader.php:47 admin/sidebar-view.php:48
67
  msgid "Support"
68
  msgstr ""
69
 
70
+ #: admin/loader.php:48
71
  msgid "Donate"
72
  msgstr ""
73
 
74
+ #: admin/loader.php:49
75
  msgid "Contribute"
76
  msgstr ""
77
 
79
  msgid "General options"
80
  msgstr ""
81
 
82
+ #: admin/main-view.php:33 admin/main-view.php:163
83
  msgid "List tuning options"
84
  msgstr ""
85
 
86
+ #: admin/main-view.php:34 admin/main-view.php:273
87
  msgid "Output options"
88
  msgstr ""
89
 
90
+ #: admin/main-view.php:35 admin/main-view.php:477
91
+ #: includes/modules/class-crp-widget.php:122
92
  msgid "Thumbnail options"
93
  msgstr ""
94
 
95
+ #: admin/main-view.php:36 admin/main-view.php:650
96
  msgid "Styles"
97
  msgstr ""
98
 
99
+ #: admin/main-view.php:37 admin/main-view.php:742
100
  msgid "Feed options"
101
  msgstr ""
102
 
103
+ #: admin/main-view.php:54 admin/main-view.php:162 admin/main-view.php:272
104
+ #: admin/main-view.php:476 admin/main-view.php:649 admin/main-view.php:741
105
  #: admin/sidebar-view.php:19 admin/sidebar-view.php:40
106
  #: admin/sidebar-view.php:58
107
  msgid "Click to toggle"
196
  msgstr ""
197
 
198
  #: admin/main-view.php:107
199
+ msgid "Disable on mobile devices:"
200
  msgstr ""
201
 
202
  #: admin/main-view.php:110
203
+ msgid "Disable display of related posts on mobile devices"
204
+ msgstr ""
205
+
206
+ #: admin/main-view.php:114
207
+ msgid "Disable on AMP pages:"
208
+ msgstr ""
209
+
210
+ #: admin/main-view.php:117
211
+ msgid "Disable display of related posts on AMP pages"
212
+ msgstr ""
213
+
214
+ #: admin/main-view.php:121
215
+ msgid "Show metabox:"
216
+ msgstr ""
217
+
218
+ #: admin/main-view.php:124
219
  msgid ""
220
  "This will add the Contextual Related Posts metabox on Edit Posts or Add New "
221
  "Posts screens. Also applies to Pages and Custom Post Types."
222
  msgstr ""
223
 
224
+ #: admin/main-view.php:128
225
  msgid "Limit metabox to Admins only:"
226
  msgstr ""
227
 
228
+ #: admin/main-view.php:131
229
  msgid ""
230
  "If this is selected, the metabox will be hidden from anyone who is not an "
231
  "Admin. Otherwise, by default, Contributors and above will be able to see the "
232
  "metabox. This applies only if the above option is selected."
233
  msgstr ""
234
 
235
+ #: admin/main-view.php:135
236
  msgid "Tell the world you're using Contextual Related Posts:"
237
  msgstr ""
238
 
239
+ #: admin/main-view.php:137
240
  msgid "Optional"
241
  msgstr ""
242
 
243
+ #: admin/main-view.php:138
244
  msgid ""
245
  "Adds a nofollow link to Contextual Related Posts homepage as the last time "
246
  "in the list."
247
  msgstr ""
248
 
249
+ #: admin/main-view.php:156 admin/main-view.php:266 admin/main-view.php:470
250
+ #: admin/main-view.php:643 admin/main-view.php:735 admin/main-view.php:807
251
+ #: admin/main-view.php:823
252
  msgid "Save Options"
253
  msgstr ""
254
 
255
+ #: admin/main-view.php:179 admin/main-view.php:760
256
  msgid "Number of related posts to display: "
257
  msgstr ""
258
 
259
+ #: admin/main-view.php:182
260
  msgid ""
261
  "Maximum number of posts that will be displayed. The actual number may be "
262
  "smaller if less related posts are found."
263
  msgstr ""
264
 
265
+ #: admin/main-view.php:186
266
  msgid "Related posts should be newer than:"
267
  msgstr ""
268
 
269
+ #: admin/main-view.php:188
270
  msgid "days"
271
  msgstr ""
272
 
273
+ #: admin/main-view.php:189
274
  msgid ""
275
  "This sets the cutoff period for which posts will be displayed. e.g. setting "
276
  "it to 365 will show related posts from the last year only. Set to 0 to "
277
  "disable limiting posts by date."
278
  msgstr ""
279
 
280
+ #: admin/main-view.php:193
281
  msgid "Randomize posts"
282
  msgstr ""
283
 
284
+ #: admin/main-view.php:195
285
  msgid ""
286
  "This shuffles the top related posts. Does not work if the cache is enabled."
287
  msgstr ""
288
 
289
+ #: admin/main-view.php:199
290
  msgid "Find related posts based on content as well as title:"
291
  msgstr ""
292
 
293
+ #: admin/main-view.php:201
294
  msgid ""
295
  "If unchecked, only posts titles are used. I recommend using a caching plugin "
296
  "or enabling \"Cache output\" above if you enable this. Each site is "
298
  "quality related posts."
299
  msgstr ""
300
 
301
+ #: admin/main-view.php:205
302
  msgid "Limit content to be compared:"
303
  msgstr ""
304
 
305
+ #: admin/main-view.php:207
306
  msgid ""
307
  "This sets the maximum words of the content that will be matched. Set to 0 "
308
  "for no limit. Max value: 2,000. Only applies if you activate the above "
309
  "option."
310
  msgstr ""
311
 
312
+ #: admin/main-view.php:211
313
  msgid "Post types to include in results:"
314
  msgstr ""
315
 
316
+ #: admin/main-view.php:218
317
  msgid ""
318
  "These post types will be displayed in the list. Includes custom post types."
319
  msgstr ""
320
 
321
+ #: admin/main-view.php:222
322
  msgid "Limit to same post type"
323
  msgstr ""
324
 
325
+ #: admin/main-view.php:224
326
  msgid ""
327
  "If checked, the related posts will only be selected from the same post type "
328
  "of the current post."
329
  msgstr ""
330
 
331
+ #: admin/main-view.php:228
332
  msgid "List of post or page IDs to exclude from the results:"
333
  msgstr ""
334
 
335
+ #: admin/main-view.php:230 admin/main-view.php:401
336
  msgid ""
337
  "Comma separated list of post, page or custom post type IDs. e.g. 188,320,500"
338
  msgstr ""
339
 
340
+ #: admin/main-view.php:234
341
  msgid "Categories to exclude from the results: "
342
  msgstr ""
343
 
344
+ #: admin/main-view.php:237
345
  msgid ""
346
  "Comma separated list of category slugs. The field above has an autocomplete "
347
  "so simply start typing in the beginning of your category name and it will "
348
  "prompt you with options."
349
  msgstr ""
350
 
351
+ #: admin/main-view.php:240
352
  msgid "Excluded category IDs are:"
353
  msgstr ""
354
 
355
+ #: admin/main-view.php:241
356
  msgid " "
357
  msgstr ""
358
 
359
+ #: admin/main-view.php:246
360
  #, php-format
361
  msgid ""
362
  "These might differ from the IDs visible in the Categories page which use the "
363
  "%1$s. CRP uses the %2$s which is unique to this taxonomy."
364
  msgstr ""
365
 
366
+ #: admin/main-view.php:289
367
  msgid "Title of related posts:"
368
  msgstr ""
369
 
370
+ #: admin/main-view.php:292
371
  #, php-format
372
  msgid ""
373
  "This is the main heading of the related posts. You can also display the "
374
  "current post title by using %1$s"
375
  msgstr ""
376
 
377
+ #: admin/main-view.php:296
378
  msgid "When there are no posts, what should be shown?"
379
  msgstr ""
380
 
381
+ #: admin/main-view.php:300
382
  msgid "Blank Output"
383
  msgstr ""
384
 
385
+ #: admin/main-view.php:305
386
  msgid "Display:"
387
  msgstr ""
388
 
389
+ #: admin/main-view.php:311 admin/main-view.php:763
390
  msgid "Show post excerpt in list?"
391
  msgstr ""
392
 
393
+ #: admin/main-view.php:314
394
  #, php-format
395
  msgid ""
396
  "Displays the excerpt of the post. If you do not provide an explicit excerpt "
398
  "automatic excerpt which refers to the first %d words of the post's content"
399
  msgstr ""
400
 
401
+ #: admin/main-view.php:317
402
  msgid ""
403
  "Rounded Thumbnails style selected under the Custom Styles. Excerpt display "
404
  "is disabled."
405
  msgstr ""
406
 
407
+ #: admin/main-view.php:322
408
  msgid "Length of excerpt (in words):"
409
  msgstr ""
410
 
411
+ #: admin/main-view.php:328
412
  msgid "Show post author in list?"
413
  msgstr ""
414
 
415
+ #: admin/main-view.php:331
416
  msgid "Displays the author name prefixed with \"by\". e.g. by John Doe"
417
  msgstr ""
418
 
419
+ #: admin/main-view.php:334
420
  msgid ""
421
  "Rounded Thumbnails style selected under the Custom Styles. Author display is "
422
  "disabled."
423
  msgstr ""
424
 
425
+ #: admin/main-view.php:339
426
  msgid "Show post date in list?"
427
  msgstr ""
428
 
429
+ #: admin/main-view.php:342
430
  msgid ""
431
  "Displays the date of the post. Uses the same date format set in General "
432
  "Options"
433
  msgstr ""
434
 
435
+ #: admin/main-view.php:345
436
  msgid ""
437
  "Rounded Thumbnails style selected under the Custom Styles. Date display is "
438
  "disabled."
439
  msgstr ""
440
 
441
+ #: admin/main-view.php:350
442
  msgid "Limit post title length (in characters)"
443
  msgstr ""
444
 
445
+ #: admin/main-view.php:353
446
  msgid ""
447
  "Any title longer than the number of characters set above will be cut and "
448
  "appended with an ellipsis (&hellip;)"
449
  msgstr ""
450
 
451
+ #: admin/main-view.php:357
452
  msgid "Open links in new window"
453
  msgstr ""
454
 
455
+ #: admin/main-view.php:363
456
  msgid "Add nofollow attribute to links in the list"
457
  msgstr ""
458
 
459
+ #: admin/main-view.php:396
460
  msgid "Exclusion settings:"
461
  msgstr ""
462
 
463
+ #: admin/main-view.php:398
464
  msgid "Exclude display of related posts on these posts / pages"
465
  msgstr ""
466
 
467
+ #: admin/main-view.php:404
468
  msgid "Exclude display of related posts on these post types."
469
  msgstr ""
470
 
471
+ #: admin/main-view.php:411
472
  msgid ""
473
  "The related posts will not display on any of the above selected post types"
474
  msgstr ""
475
 
476
+ #: admin/main-view.php:441
477
  msgid "Customize the output:"
478
  msgstr ""
479
 
480
+ #: admin/main-view.php:443
481
  msgid "HTML to display before the list of posts: "
482
  msgstr ""
483
 
484
+ #: admin/main-view.php:446
485
  msgid "HTML to display before each list item: "
486
  msgstr ""
487
 
488
+ #: admin/main-view.php:449
489
  msgid "HTML to display after each list item: "
490
  msgstr ""
491
 
492
+ #: admin/main-view.php:452
493
  msgid "HTML to display after the list of posts: "
494
  msgstr ""
495
 
496
+ #: admin/main-view.php:493 admin/main-view.php:766
497
  msgid "Location of post thumbnail:"
498
  msgstr ""
499
 
500
+ #: admin/main-view.php:497 admin/main-view.php:770
501
  msgid "Display thumbnails inline with posts, before title"
502
  msgstr ""
503
 
504
+ #: admin/main-view.php:502 admin/main-view.php:774
505
  msgid "Display thumbnails inline with posts, after title"
506
  msgstr ""
507
 
508
+ #: admin/main-view.php:507 admin/main-view.php:778
509
  msgid "Display only thumbnails, no text"
510
  msgstr ""
511
 
512
+ #: admin/main-view.php:512 admin/main-view.php:782
513
  msgid "Do not display thumbnails, only text."
514
  msgstr ""
515
 
516
+ #: admin/main-view.php:516
517
  #, php-format
518
  msgid ""
519
  "This setting cannot be changed because an inbuilt style has been selected "
521
  "select %1$s under the Styles section."
522
  msgstr ""
523
 
524
+ #: admin/main-view.php:516 admin/main-view.php:669
525
  msgid "No styles"
526
  msgstr ""
527
 
528
+ #: admin/main-view.php:520
529
  msgid "Thumbnail size:"
530
  msgstr ""
531
 
532
+ #: admin/main-view.php:545
533
  msgid "Custom size"
534
  msgstr ""
535
 
536
+ #: admin/main-view.php:548
537
  msgid "You can choose from existing image sizes above or create a custom size."
538
  msgstr ""
539
 
540
+ #: admin/main-view.php:549
541
  msgid ""
542
  "If you choose an existing size, then the width, height and crop mode "
543
  "settings in the three options below will be automatically updated to reflect "
544
  "the correct dimensions of the setting."
545
  msgstr ""
546
 
547
+ #: admin/main-view.php:550
548
  msgid ""
549
  "If you have chosen Custom size above, then enter the width, height and crop "
550
  "settings below. For best results, use a cropped image with the same width "
551
  "and height. The default setting is 150x150 cropped image."
552
  msgstr ""
553
 
554
+ #: admin/main-view.php:551
555
  msgid ""
556
  "Any changes to the thumbnail settings doesn't automatically resize existing "
557
  "images."
558
  msgstr ""
559
 
560
+ #: admin/main-view.php:554
561
  #, php-format
562
  msgid "I recommend using %1$s or %2$s to regenerate all image sizes."
563
  msgstr ""
564
 
565
+ #: admin/main-view.php:562
566
  msgid "Width of the thumbnail:"
567
  msgstr ""
568
 
569
+ #: admin/main-view.php:565
570
  msgid "Height of the thumbnail: "
571
  msgstr ""
572
 
573
+ #: admin/main-view.php:570
574
  msgid "Crop mode:"
575
  msgstr ""
576
 
577
+ #: admin/main-view.php:574
578
  msgid ""
579
  "By default, thumbnails will be hard cropped. Uncheck this box to "
580
  "proportionately/soft crop the thumbnails."
581
  msgstr ""
582
 
583
+ #: admin/main-view.php:578
584
  msgid "Image size attributes:"
585
  msgstr ""
586
 
587
+ #: admin/main-view.php:583
588
  msgid "Style attributes. e.g."
589
  msgstr ""
590
 
591
+ #: admin/main-view.php:591
592
  msgid "HTML width and height attributes. e.g."
593
  msgstr ""
594
 
595
+ #: admin/main-view.php:598
596
  msgid "No HTML or Style attributes"
597
  msgstr ""
598
 
599
+ #: admin/main-view.php:603
600
  msgid "Post thumbnail meta field name:"
601
  msgstr ""
602
 
603
+ #: admin/main-view.php:605
604
  #, php-format
605
  msgid ""
606
  "The value of this field should contain a direct link to the image. This is "
607
  "set in the meta box in the %1$s screen."
608
  msgstr ""
609
 
610
+ #: admin/main-view.php:605
611
  msgid "Add New Post"
612
  msgstr ""
613
 
614
+ #: admin/main-view.php:608
615
  msgid "Extract the first image from the post?"
616
  msgstr ""
617
 
618
+ #: admin/main-view.php:610
619
  msgid ""
620
  "This will only happen if there is no post thumbnail set and no image URL is "
621
  "specified in the meta field."
622
  msgstr ""
623
 
624
+ #: admin/main-view.php:613
625
  msgid "Use default thumbnail?"
626
  msgstr ""
627
 
628
+ #: admin/main-view.php:615
629
  msgid ""
630
  "If checked, when no thumbnail is found, show a default one from the URL "
631
  "below. If not checked and no thumbnail is found, no image will be shown."
632
  msgstr ""
633
 
634
+ #: admin/main-view.php:618
635
  msgid "Default thumbnail:"
636
  msgstr ""
637
 
638
+ #: admin/main-view.php:625
639
  msgid ""
640
  "The plugin will first check if the post contains a thumbnail. If it doesn't "
641
  "then it will check the meta field. If this is not available, then it will "
642
  "show the default image as specified above."
643
  msgstr ""
644
 
645
+ #: admin/main-view.php:666
646
  msgid "Style of the related posts:"
647
  msgstr ""
648
 
649
+ #: admin/main-view.php:671
650
  msgid "Select this option if you plan to add your own styles"
651
  msgstr ""
652
 
653
+ #: admin/main-view.php:680
654
  msgid "Rounded Thumbnails"
655
  msgstr ""
656
 
657
+ #: admin/main-view.php:683
658
  msgid ""
659
  "Enabling this option will turn on the thumbnails and set their width and "
660
  "height to 150px. It will also turn off the display of the author, excerpt "
662
  "settings."
663
  msgstr ""
664
 
665
+ #: admin/main-view.php:687
666
  #, php-format
667
  msgid "You can view the default style at %s"
668
  msgstr ""
669
 
670
+ #: admin/main-view.php:695
671
  msgid "Text only"
672
  msgstr ""
673
 
674
+ #: admin/main-view.php:697
675
  msgid ""
676
  "Enabling this option will disable thumbnails and no longer include the "
677
  "default style sheet included in the plugin."
678
  msgstr ""
679
 
680
+ #: admin/main-view.php:712
681
  msgid "Custom CSS to add to header:"
682
  msgstr ""
683
 
684
+ #: admin/main-view.php:717
685
  #, php-format
686
  msgid ""
687
  "Do not include %1$s tags. Check out the %2$s for available CSS classes to "
688
  "style."
689
  msgstr ""
690
 
691
+ #: admin/main-view.php:758
692
  msgid ""
693
  "Below options override the related posts settings for your blog feed. These "
694
  "only apply if you have selected to add related posts to Feeds in the General "
695
  "Options tab."
696
  msgstr ""
697
 
698
+ #: admin/main-view.php:786
699
  msgid "Maximum width of the thumbnail: "
700
  msgstr ""
701
 
702
+ #: admin/main-view.php:789
703
  msgid "Maximum height of the thumbnail: "
704
  msgstr ""
705
 
706
+ #: admin/main-view.php:824
707
  msgid "Default Options"
708
  msgstr ""
709
 
710
+ #: admin/main-view.php:824
711
  msgid "Do you want to set options to Default?"
712
  msgstr ""
713
 
714
+ #: admin/main-view.php:825
715
  msgid "Recreate Index"
716
  msgstr ""
717
 
718
+ #: admin/main-view.php:825
719
  msgid "Are you sure you want to recreate the index?"
720
  msgstr ""
721
 
722
+ #: admin/main-view.php:830
723
  #, php-format
724
  msgid ""
725
  "One or more FULLTEXT indices are missing. Please hit the %1$s at the bottom "
726
  "of the page to fix this."
727
  msgstr ""
728
 
729
+ #: admin/main-view.php:830
730
  msgid "Recreate Index button"
731
  msgstr ""
732
 
733
+ #: admin/main-view.php:835
734
  msgid ""
735
  "If the Recreate Index button fails, please run the following queries in "
736
  "phpMyAdmin or Adminer"
737
  msgstr ""
738
 
739
+ #: admin/metabox.php:107
740
  msgid "Disable Related Posts display:"
741
  msgstr ""
742
 
743
+ #: admin/metabox.php:110
744
  msgid ""
745
  "If this is checked, then Contextual Related Posts will not automatically "
746
  "insert the related posts at the end of post content."
747
  msgstr ""
748
 
749
+ #: admin/metabox.php:114
750
  msgid "Exclude this post from the related posts list:"
751
  msgstr ""
752
 
753
+ #: admin/metabox.php:117
754
  msgid ""
755
  "If this is checked, then this post will be excluded from the popular posts "
756
  "list."
757
  msgstr ""
758
 
759
+ #: admin/metabox.php:121 admin/metabox.php:129
760
  msgid "Manual related posts:"
761
  msgstr ""
762
 
763
+ #: admin/metabox.php:123
764
  msgid ""
765
  "Comma separated list of post, page or custom post type IDs. e.g. "
766
  "188,320,500. These will be given preference over the related posts generated "
767
  "by the plugin."
768
  msgstr ""
769
 
770
+ #: admin/metabox.php:124
771
  msgid ""
772
  "Once you enter the list above and save this page, the plugin will display "
773
  "the titles of the posts below for your reference. Only IDs corresponding to "
774
  "published posts or custom post types will be retained."
775
  msgstr ""
776
 
777
+ #: admin/metabox.php:140
778
  #, php-format
779
  msgid "This post type is: %s"
780
  msgstr ""
781
 
782
+ #: admin/metabox.php:151
783
  msgid "Location of thumbnail"
784
  msgstr ""
785
 
786
+ #: admin/metabox.php:153
787
  msgid ""
788
  "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This "
789
  "image will be used for the post. It will be resized to the thumbnail size "
790
  "set under Settings &raquo; Related Posts &raquo; Output Options"
791
  msgstr ""
792
 
793
+ #: admin/metabox.php:154
794
  msgid "The URL above is saved in the meta field:"
795
  msgstr ""
796
 
797
+ #: admin/metabox.php:159
798
  msgid ""
799
  "You have Top 10 WordPress Plugin installed. If you are trying to modify the "
800
  "thumbnail, then you'll need to make the same change in the Top 10 meta box "
861
  msgid "No related posts found"
862
  msgstr ""
863
 
864
+ #: includes/main-query.php:195
865
  #, php-format
866
  msgid "Powered by <a href=\"%s\" rel=\"nofollow\">Contextual Related Posts</a>"
867
  msgstr ""
886
  msgid "Display Related Posts"
887
  msgstr ""
888
 
889
+ #: includes/modules/class-crp-widget.php:78
890
  msgid "Title"
891
  msgstr ""
892
 
893
+ #: includes/modules/class-crp-widget.php:83
894
  msgid "No. of posts"
895
  msgstr ""
896
 
897
+ #: includes/modules/class-crp-widget.php:88
898
  msgid "Offset"
899
  msgstr ""
900
 
901
+ #: includes/modules/class-crp-widget.php:98
902
  msgid " Show excerpt?"
903
  msgstr ""
904
 
905
+ #: includes/modules/class-crp-widget.php:108
906
  msgid " Show author?"
907
  msgstr ""
908
 
909
+ #: includes/modules/class-crp-widget.php:118
910
  msgid " Show date?"
911
  msgstr ""
912
 
913
+ #: includes/modules/class-crp-widget.php:124
914
  msgid "Thumbnails inline, before title"
915
  msgstr ""
916
 
917
+ #: includes/modules/class-crp-widget.php:125
918
  msgid "Thumbnails inline, after title"
919
  msgstr ""
920
 
921
+ #: includes/modules/class-crp-widget.php:126
922
  msgid "Only thumbnails, no text"
923
  msgstr ""
924
 
925
+ #: includes/modules/class-crp-widget.php:127
926
  msgid "No thumbnails, only text."
927
  msgstr ""
928
 
929
+ #: includes/modules/class-crp-widget.php:132
930
  msgid "Thumbnail height"
931
  msgstr ""
932
 
933
+ #: includes/modules/class-crp-widget.php:137
934
  msgid "Thumbnail width"
935
  msgstr ""
936
 
937
+ #: includes/modules/class-crp-widget.php:141
938
  msgid "Post types to include"
939
  msgstr ""
940
 
languages/contextual-related-posts-en_US.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Project-Id-Version: Contextual Related Posts\n"
5
  "Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2017-06-04 00:37+0100\n"
7
  "PO-Revision-Date: \n"
8
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
9
  "Language-Team: plugins@webberzone.com\n"
@@ -14,64 +14,64 @@ msgstr ""
14
  "X-Poedit-KeywordsList: __;_e;_c;__ngettext;esc_html__;esc_html_e;esc_attr__;"
15
  "esc_attr_e\n"
16
  "X-Poedit-Basepath: ..\n"
17
- "X-Generator: Poedit 2.0.1\n"
18
  "X-Poedit-SourceCharset: UTF-8\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
 
21
- #: admin/admin.php:226
22
  msgid "Options saved successfully. If enabled, the cache has been cleared."
23
  msgstr ""
24
 
25
- #: admin/admin.php:229
26
  msgid ""
27
  "Rounded Thumbnails style selected. Author, Excerpt and Date will not be "
28
  "displayed."
29
  msgstr ""
30
 
31
- #: admin/admin.php:232
32
  msgid "Text Only style selected. Thumbnails will not be displayed."
33
  msgstr ""
34
 
35
- #: admin/admin.php:236
36
  #, php-format
37
  msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %2$d."
38
  msgstr ""
39
 
40
- #: admin/admin.php:269
41
  msgid "Options set to Default."
42
  msgstr ""
43
 
44
- #: admin/admin.php:278
45
  msgid "Index recreated"
46
  msgstr ""
47
 
48
- #: admin/admin.php:295
49
  msgid "Related Posts"
50
  msgstr ""
51
 
52
- #: admin/cache.php:42
53
  msgid ""
54
  "An error occurred clearing the cache. Please contact your site administrator."
55
  "\\n\\nError message:\\n"
56
  msgstr ""
57
 
58
- #: admin/cache.php:47
59
  msgid " cached row(s) cleared"
60
  msgstr ""
61
 
62
- #: admin/loader.php:23
63
  msgid "Settings"
64
  msgstr ""
65
 
66
- #: admin/loader.php:44 admin/sidebar-view.php:48
67
  msgid "Support"
68
  msgstr ""
69
 
70
- #: admin/loader.php:45
71
  msgid "Donate"
72
  msgstr ""
73
 
74
- #: admin/loader.php:46
75
  msgid "Contribute"
76
  msgstr ""
77
 
@@ -79,29 +79,29 @@ msgstr ""
79
  msgid "General options"
80
  msgstr ""
81
 
82
- #: admin/main-view.php:33 admin/main-view.php:149
83
  msgid "List tuning options"
84
  msgstr ""
85
 
86
- #: admin/main-view.php:34 admin/main-view.php:259
87
  msgid "Output options"
88
  msgstr ""
89
 
90
- #: admin/main-view.php:35 admin/main-view.php:463
91
- #: includes/modules/class-crp-widget.php:105
92
  msgid "Thumbnail options"
93
  msgstr ""
94
 
95
- #: admin/main-view.php:36 admin/main-view.php:630
96
  msgid "Styles"
97
  msgstr ""
98
 
99
- #: admin/main-view.php:37 admin/main-view.php:713
100
  msgid "Feed options"
101
  msgstr ""
102
 
103
- #: admin/main-view.php:54 admin/main-view.php:148 admin/main-view.php:258
104
- #: admin/main-view.php:462 admin/main-view.php:629 admin/main-view.php:712
105
  #: admin/sidebar-view.php:19 admin/sidebar-view.php:40
106
  #: admin/sidebar-view.php:58
107
  msgid "Click to toggle"
@@ -196,85 +196,101 @@ msgid ""
196
  msgstr ""
197
 
198
  #: admin/main-view.php:107
199
- msgid "Show metabox:"
200
  msgstr ""
201
 
202
  #: admin/main-view.php:110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  msgid ""
204
  "This will add the Contextual Related Posts metabox on Edit Posts or Add New "
205
  "Posts screens. Also applies to Pages and Custom Post Types."
206
  msgstr ""
207
 
208
- #: admin/main-view.php:114
209
  msgid "Limit metabox to Admins only:"
210
  msgstr ""
211
 
212
- #: admin/main-view.php:117
213
  msgid ""
214
  "If this is selected, the metabox will be hidden from anyone who is not an "
215
  "Admin. Otherwise, by default, Contributors and above will be able to see the "
216
  "metabox. This applies only if the above option is selected."
217
  msgstr ""
218
 
219
- #: admin/main-view.php:121
220
  msgid "Tell the world you're using Contextual Related Posts:"
221
  msgstr ""
222
 
223
- #: admin/main-view.php:123
224
  msgid "Optional"
225
  msgstr ""
226
 
227
- #: admin/main-view.php:124
228
  msgid ""
229
  "Adds a nofollow link to Contextual Related Posts homepage as the last time "
230
  "in the list."
231
  msgstr ""
232
 
233
- #: admin/main-view.php:142 admin/main-view.php:252 admin/main-view.php:456
234
- #: admin/main-view.php:623 admin/main-view.php:706 admin/main-view.php:778
235
- #: admin/main-view.php:794
236
  msgid "Save Options"
237
  msgstr ""
238
 
239
- #: admin/main-view.php:165 admin/main-view.php:731
240
  msgid "Number of related posts to display: "
241
  msgstr ""
242
 
243
- #: admin/main-view.php:168
244
  msgid ""
245
  "Maximum number of posts that will be displayed. The actual number may be "
246
  "smaller if less related posts are found."
247
  msgstr ""
248
 
249
- #: admin/main-view.php:172
250
  msgid "Related posts should be newer than:"
251
  msgstr ""
252
 
253
- #: admin/main-view.php:174
254
  msgid "days"
255
  msgstr ""
256
 
257
- #: admin/main-view.php:175
258
  msgid ""
259
  "This sets the cutoff period for which posts will be displayed. e.g. setting "
260
  "it to 365 will show related posts from the last year only. Set to 0 to "
261
  "disable limiting posts by date."
262
  msgstr ""
263
 
264
- #: admin/main-view.php:179
265
  msgid "Randomize posts"
266
  msgstr ""
267
 
268
- #: admin/main-view.php:181
269
  msgid ""
270
  "This shuffles the top related posts. Does not work if the cache is enabled."
271
  msgstr ""
272
 
273
- #: admin/main-view.php:185
274
  msgid "Find related posts based on content as well as title:"
275
  msgstr ""
276
 
277
- #: admin/main-view.php:187
278
  msgid ""
279
  "If unchecked, only posts titles are used. I recommend using a caching plugin "
280
  "or enabling \"Cache output\" above if you enable this. Each site is "
@@ -282,99 +298,99 @@ msgid ""
282
  "quality related posts."
283
  msgstr ""
284
 
285
- #: admin/main-view.php:191
286
  msgid "Limit content to be compared:"
287
  msgstr ""
288
 
289
- #: admin/main-view.php:193
290
  msgid ""
291
  "This sets the maximum words of the content that will be matched. Set to 0 "
292
  "for no limit. Max value: 2,000. Only applies if you activate the above "
293
  "option."
294
  msgstr ""
295
 
296
- #: admin/main-view.php:197
297
  msgid "Post types to include in results:"
298
  msgstr ""
299
 
300
- #: admin/main-view.php:204
301
  msgid ""
302
  "These post types will be displayed in the list. Includes custom post types."
303
  msgstr ""
304
 
305
- #: admin/main-view.php:208
306
  msgid "Limit to same post type"
307
  msgstr ""
308
 
309
- #: admin/main-view.php:210
310
  msgid ""
311
  "If checked, the related posts will only be selected from the same post type "
312
  "of the current post."
313
  msgstr ""
314
 
315
- #: admin/main-view.php:214
316
  msgid "List of post or page IDs to exclude from the results:"
317
  msgstr ""
318
 
319
- #: admin/main-view.php:216 admin/main-view.php:387
320
  msgid ""
321
  "Comma separated list of post, page or custom post type IDs. e.g. 188,320,500"
322
  msgstr ""
323
 
324
- #: admin/main-view.php:220
325
  msgid "Categories to exclude from the results: "
326
  msgstr ""
327
 
328
- #: admin/main-view.php:223
329
  msgid ""
330
  "Comma separated list of category slugs. The field above has an autocomplete "
331
  "so simply start typing in the beginning of your category name and it will "
332
  "prompt you with options."
333
  msgstr ""
334
 
335
- #: admin/main-view.php:226
336
  msgid "Excluded category IDs are:"
337
  msgstr ""
338
 
339
- #: admin/main-view.php:227
340
  msgid " "
341
  msgstr ""
342
 
343
- #: admin/main-view.php:232
344
  #, php-format
345
  msgid ""
346
  "These might differ from the IDs visible in the Categories page which use the "
347
  "%1$s. CRP uses the %2$s which is unique to this taxonomy."
348
  msgstr ""
349
 
350
- #: admin/main-view.php:275
351
  msgid "Title of related posts:"
352
  msgstr ""
353
 
354
- #: admin/main-view.php:278
355
  #, php-format
356
  msgid ""
357
  "This is the main heading of the related posts. You can also display the "
358
  "current post title by using %1$s"
359
  msgstr ""
360
 
361
- #: admin/main-view.php:282
362
  msgid "When there are no posts, what should be shown?"
363
  msgstr ""
364
 
365
- #: admin/main-view.php:286
366
  msgid "Blank Output"
367
  msgstr ""
368
 
369
- #: admin/main-view.php:291
370
  msgid "Display:"
371
  msgstr ""
372
 
373
- #: admin/main-view.php:297 admin/main-view.php:734
374
  msgid "Show post excerpt in list?"
375
  msgstr ""
376
 
377
- #: admin/main-view.php:300
378
  #, php-format
379
  msgid ""
380
  "Displays the excerpt of the post. If you do not provide an explicit excerpt "
@@ -382,122 +398,122 @@ msgid ""
382
  "automatic excerpt which refers to the first %d words of the post's content"
383
  msgstr ""
384
 
385
- #: admin/main-view.php:303
386
  msgid ""
387
  "Rounded Thumbnails style selected under the Custom Styles. Excerpt display "
388
  "is disabled."
389
  msgstr ""
390
 
391
- #: admin/main-view.php:308
392
  msgid "Length of excerpt (in words):"
393
  msgstr ""
394
 
395
- #: admin/main-view.php:314
396
  msgid "Show post author in list?"
397
  msgstr ""
398
 
399
- #: admin/main-view.php:317
400
  msgid "Displays the author name prefixed with \"by\". e.g. by John Doe"
401
  msgstr ""
402
 
403
- #: admin/main-view.php:320
404
  msgid ""
405
  "Rounded Thumbnails style selected under the Custom Styles. Author display is "
406
  "disabled."
407
  msgstr ""
408
 
409
- #: admin/main-view.php:325
410
  msgid "Show post date in list?"
411
  msgstr ""
412
 
413
- #: admin/main-view.php:328
414
  msgid ""
415
  "Displays the date of the post. Uses the same date format set in General "
416
  "Options"
417
  msgstr ""
418
 
419
- #: admin/main-view.php:331
420
  msgid ""
421
  "Rounded Thumbnails style selected under the Custom Styles. Date display is "
422
  "disabled."
423
  msgstr ""
424
 
425
- #: admin/main-view.php:336
426
  msgid "Limit post title length (in characters)"
427
  msgstr ""
428
 
429
- #: admin/main-view.php:339
430
  msgid ""
431
  "Any title longer than the number of characters set above will be cut and "
432
  "appended with an ellipsis (&hellip;)"
433
  msgstr ""
434
 
435
- #: admin/main-view.php:343
436
  msgid "Open links in new window"
437
  msgstr ""
438
 
439
- #: admin/main-view.php:349
440
  msgid "Add nofollow attribute to links in the list"
441
  msgstr ""
442
 
443
- #: admin/main-view.php:382
444
  msgid "Exclusion settings:"
445
  msgstr ""
446
 
447
- #: admin/main-view.php:384
448
  msgid "Exclude display of related posts on these posts / pages"
449
  msgstr ""
450
 
451
- #: admin/main-view.php:390
452
  msgid "Exclude display of related posts on these post types."
453
  msgstr ""
454
 
455
- #: admin/main-view.php:397
456
  msgid ""
457
  "The related posts will not display on any of the above selected post types"
458
  msgstr ""
459
 
460
- #: admin/main-view.php:427
461
  msgid "Customize the output:"
462
  msgstr ""
463
 
464
- #: admin/main-view.php:429
465
  msgid "HTML to display before the list of posts: "
466
  msgstr ""
467
 
468
- #: admin/main-view.php:432
469
  msgid "HTML to display before each list item: "
470
  msgstr ""
471
 
472
- #: admin/main-view.php:435
473
  msgid "HTML to display after each list item: "
474
  msgstr ""
475
 
476
- #: admin/main-view.php:438
477
  msgid "HTML to display after the list of posts: "
478
  msgstr ""
479
 
480
- #: admin/main-view.php:479 admin/main-view.php:737
481
  msgid "Location of post thumbnail:"
482
  msgstr ""
483
 
484
- #: admin/main-view.php:483 admin/main-view.php:741
485
  msgid "Display thumbnails inline with posts, before title"
486
  msgstr ""
487
 
488
- #: admin/main-view.php:488 admin/main-view.php:745
489
  msgid "Display thumbnails inline with posts, after title"
490
  msgstr ""
491
 
492
- #: admin/main-view.php:493 admin/main-view.php:749
493
  msgid "Display only thumbnails, no text"
494
  msgstr ""
495
 
496
- #: admin/main-view.php:498 admin/main-view.php:753
497
  msgid "Do not display thumbnails, only text."
498
  msgstr ""
499
 
500
- #: admin/main-view.php:502
501
  #, php-format
502
  msgid ""
503
  "This setting cannot be changed because an inbuilt style has been selected "
@@ -505,140 +521,140 @@ msgid ""
505
  "select %1$s under the Styles section."
506
  msgstr ""
507
 
508
- #: admin/main-view.php:502 admin/main-view.php:649
509
  msgid "No styles"
510
  msgstr ""
511
 
512
- #: admin/main-view.php:506
513
  msgid "Thumbnail size:"
514
  msgstr ""
515
 
516
- #: admin/main-view.php:531
517
  msgid "Custom size"
518
  msgstr ""
519
 
520
- #: admin/main-view.php:534
521
  msgid "You can choose from existing image sizes above or create a custom size."
522
  msgstr ""
523
 
524
- #: admin/main-view.php:535
525
  msgid ""
526
  "If you choose an existing size, then the width, height and crop mode "
527
  "settings in the three options below will be automatically updated to reflect "
528
  "the correct dimensions of the setting."
529
  msgstr ""
530
 
531
- #: admin/main-view.php:536
532
  msgid ""
533
  "If you have chosen Custom size above, then enter the width, height and crop "
534
  "settings below. For best results, use a cropped image with the same width "
535
  "and height. The default setting is 150x150 cropped image."
536
  msgstr ""
537
 
538
- #: admin/main-view.php:537
539
  msgid ""
540
  "Any changes to the thumbnail settings doesn't automatically resize existing "
541
  "images."
542
  msgstr ""
543
 
544
- #: admin/main-view.php:539
545
  #, php-format
546
  msgid "I recommend using %1$s or %2$s to regenerate all image sizes."
547
  msgstr ""
548
 
549
- #: admin/main-view.php:546
550
  msgid "Width of the thumbnail:"
551
  msgstr ""
552
 
553
- #: admin/main-view.php:549
554
  msgid "Height of the thumbnail: "
555
  msgstr ""
556
 
557
- #: admin/main-view.php:554
558
  msgid "Crop mode:"
559
  msgstr ""
560
 
561
- #: admin/main-view.php:558
562
  msgid ""
563
  "By default, thumbnails will be hard cropped. Uncheck this box to "
564
  "proportionately/soft crop the thumbnails."
565
  msgstr ""
566
 
567
- #: admin/main-view.php:562
568
  msgid "Image size attributes:"
569
  msgstr ""
570
 
571
- #: admin/main-view.php:566
572
  msgid "Style attributes. e.g."
573
  msgstr ""
574
 
575
- #: admin/main-view.php:572
576
  msgid "HTML width and height attributes. e.g."
577
  msgstr ""
578
 
579
- #: admin/main-view.php:578
580
  msgid "No HTML or Style attributes"
581
  msgstr ""
582
 
583
- #: admin/main-view.php:583
584
  msgid "Post thumbnail meta field name:"
585
  msgstr ""
586
 
587
- #: admin/main-view.php:585
588
  #, php-format
589
  msgid ""
590
  "The value of this field should contain a direct link to the image. This is "
591
  "set in the meta box in the %1$s screen."
592
  msgstr ""
593
 
594
- #: admin/main-view.php:585
595
  msgid "Add New Post"
596
  msgstr ""
597
 
598
- #: admin/main-view.php:588
599
  msgid "Extract the first image from the post?"
600
  msgstr ""
601
 
602
- #: admin/main-view.php:590
603
  msgid ""
604
  "This will only happen if there is no post thumbnail set and no image URL is "
605
  "specified in the meta field."
606
  msgstr ""
607
 
608
- #: admin/main-view.php:593
609
  msgid "Use default thumbnail?"
610
  msgstr ""
611
 
612
- #: admin/main-view.php:595
613
  msgid ""
614
  "If checked, when no thumbnail is found, show a default one from the URL "
615
  "below. If not checked and no thumbnail is found, no image will be shown."
616
  msgstr ""
617
 
618
- #: admin/main-view.php:598
619
  msgid "Default thumbnail:"
620
  msgstr ""
621
 
622
- #: admin/main-view.php:605
623
  msgid ""
624
  "The plugin will first check if the post contains a thumbnail. If it doesn't "
625
  "then it will check the meta field. If this is not available, then it will "
626
  "show the default image as specified above."
627
  msgstr ""
628
 
629
- #: admin/main-view.php:646
630
  msgid "Style of the related posts:"
631
  msgstr ""
632
 
633
- #: admin/main-view.php:651
634
  msgid "Select this option if you plan to add your own styles"
635
  msgstr ""
636
 
637
- #: admin/main-view.php:655
638
  msgid "Rounded Thumbnails"
639
  msgstr ""
640
 
641
- #: admin/main-view.php:658
642
  msgid ""
643
  "Enabling this option will turn on the thumbnails and set their width and "
644
  "height to 150px. It will also turn off the display of the author, excerpt "
@@ -646,139 +662,139 @@ msgid ""
646
  "settings."
647
  msgstr ""
648
 
649
- #: admin/main-view.php:660
650
  #, php-format
651
  msgid "You can view the default style at %s"
652
  msgstr ""
653
 
654
- #: admin/main-view.php:666
655
  msgid "Text only"
656
  msgstr ""
657
 
658
- #: admin/main-view.php:668
659
  msgid ""
660
  "Enabling this option will disable thumbnails and no longer include the "
661
  "default style sheet included in the plugin."
662
  msgstr ""
663
 
664
- #: admin/main-view.php:683
665
  msgid "Custom CSS to add to header:"
666
  msgstr ""
667
 
668
- #: admin/main-view.php:688
669
  #, php-format
670
  msgid ""
671
  "Do not include %1$s tags. Check out the %2$s for available CSS classes to "
672
  "style."
673
  msgstr ""
674
 
675
- #: admin/main-view.php:729
676
  msgid ""
677
  "Below options override the related posts settings for your blog feed. These "
678
  "only apply if you have selected to add related posts to Feeds in the General "
679
  "Options tab."
680
  msgstr ""
681
 
682
- #: admin/main-view.php:757
683
  msgid "Maximum width of the thumbnail: "
684
  msgstr ""
685
 
686
- #: admin/main-view.php:760
687
  msgid "Maximum height of the thumbnail: "
688
  msgstr ""
689
 
690
- #: admin/main-view.php:795
691
  msgid "Default Options"
692
  msgstr ""
693
 
694
- #: admin/main-view.php:795
695
  msgid "Do you want to set options to Default?"
696
  msgstr ""
697
 
698
- #: admin/main-view.php:796
699
  msgid "Recreate Index"
700
  msgstr ""
701
 
702
- #: admin/main-view.php:796
703
  msgid "Are you sure you want to recreate the index?"
704
  msgstr ""
705
 
706
- #: admin/main-view.php:801
707
  #, php-format
708
  msgid ""
709
  "One or more FULLTEXT indices are missing. Please hit the %1$s at the bottom "
710
  "of the page to fix this."
711
  msgstr ""
712
 
713
- #: admin/main-view.php:801
714
  msgid "Recreate Index button"
715
  msgstr ""
716
 
717
- #: admin/main-view.php:806
718
  msgid ""
719
  "If the Recreate Index button fails, please run the following queries in "
720
  "phpMyAdmin or Adminer"
721
  msgstr ""
722
 
723
- #: admin/metabox.php:105
724
  msgid "Disable Related Posts display:"
725
  msgstr ""
726
 
727
- #: admin/metabox.php:108
728
  msgid ""
729
  "If this is checked, then Contextual Related Posts will not automatically "
730
  "insert the related posts at the end of post content."
731
  msgstr ""
732
 
733
- #: admin/metabox.php:112
734
  msgid "Exclude this post from the related posts list:"
735
  msgstr ""
736
 
737
- #: admin/metabox.php:115
738
  msgid ""
739
  "If this is checked, then this post will be excluded from the popular posts "
740
  "list."
741
  msgstr ""
742
 
743
- #: admin/metabox.php:119 admin/metabox.php:127
744
  msgid "Manual related posts:"
745
  msgstr ""
746
 
747
- #: admin/metabox.php:121
748
  msgid ""
749
  "Comma separated list of post, page or custom post type IDs. e.g. "
750
  "188,320,500. These will be given preference over the related posts generated "
751
  "by the plugin."
752
  msgstr ""
753
 
754
- #: admin/metabox.php:122
755
  msgid ""
756
  "Once you enter the list above and save this page, the plugin will display "
757
  "the titles of the posts below for your reference. Only IDs corresponding to "
758
  "published posts or custom post types will be retained."
759
  msgstr ""
760
 
761
- #: admin/metabox.php:138
762
  #, php-format
763
  msgid "This post type is: %s"
764
  msgstr ""
765
 
766
- #: admin/metabox.php:149
767
  msgid "Location of thumbnail"
768
  msgstr ""
769
 
770
- #: admin/metabox.php:151
771
  msgid ""
772
  "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This "
773
  "image will be used for the post. It will be resized to the thumbnail size "
774
  "set under Settings &raquo; Related Posts &raquo; Output Options"
775
  msgstr ""
776
 
777
- #: admin/metabox.php:152
778
  msgid "The URL above is saved in the meta field:"
779
  msgstr ""
780
 
781
- #: admin/metabox.php:157
782
  msgid ""
783
  "You have Top 10 WordPress Plugin installed. If you are trying to modify the "
784
  "thumbnail, then you'll need to make the same change in the Top 10 meta box "
@@ -845,7 +861,7 @@ msgstr ""
845
  msgid "No related posts found"
846
  msgstr ""
847
 
848
- #: includes/main-query.php:189
849
  #, php-format
850
  msgid "Powered by <a href=\"%s\" rel=\"nofollow\">Contextual Related Posts</a>"
851
  msgstr ""
@@ -870,55 +886,55 @@ msgstr ""
870
  msgid "Display Related Posts"
871
  msgstr ""
872
 
873
- #: includes/modules/class-crp-widget.php:76
874
  msgid "Title"
875
  msgstr ""
876
 
877
- #: includes/modules/class-crp-widget.php:81
878
  msgid "No. of posts"
879
  msgstr ""
880
 
881
- #: includes/modules/class-crp-widget.php:86
882
  msgid "Offset"
883
  msgstr ""
884
 
885
- #: includes/modules/class-crp-widget.php:91
886
  msgid " Show excerpt?"
887
  msgstr ""
888
 
889
- #: includes/modules/class-crp-widget.php:96
890
  msgid " Show author?"
891
  msgstr ""
892
 
893
- #: includes/modules/class-crp-widget.php:101
894
  msgid " Show date?"
895
  msgstr ""
896
 
897
- #: includes/modules/class-crp-widget.php:107
898
  msgid "Thumbnails inline, before title"
899
  msgstr ""
900
 
901
- #: includes/modules/class-crp-widget.php:108
902
  msgid "Thumbnails inline, after title"
903
  msgstr ""
904
 
905
- #: includes/modules/class-crp-widget.php:109
906
  msgid "Only thumbnails, no text"
907
  msgstr ""
908
 
909
- #: includes/modules/class-crp-widget.php:110
910
  msgid "No thumbnails, only text."
911
  msgstr ""
912
 
913
- #: includes/modules/class-crp-widget.php:115
914
  msgid "Thumbnail height"
915
  msgstr ""
916
 
917
- #: includes/modules/class-crp-widget.php:120
918
  msgid "Thumbnail width"
919
  msgstr ""
920
 
921
- #: includes/modules/class-crp-widget.php:124
922
  msgid "Post types to include"
923
  msgstr ""
924
 
3
  msgstr ""
4
  "Project-Id-Version: Contextual Related Posts\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2018-11-18 13:36+0000\n"
7
  "PO-Revision-Date: \n"
8
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
9
  "Language-Team: plugins@webberzone.com\n"
14
  "X-Poedit-KeywordsList: __;_e;_c;__ngettext;esc_html__;esc_html_e;esc_attr__;"
15
  "esc_attr_e\n"
16
  "X-Poedit-Basepath: ..\n"
17
+ "X-Generator: Poedit 2.2\n"
18
  "X-Poedit-SourceCharset: UTF-8\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
 
21
+ #: admin/admin.php:232
22
  msgid "Options saved successfully. If enabled, the cache has been cleared."
23
  msgstr ""
24
 
25
+ #: admin/admin.php:235
26
  msgid ""
27
  "Rounded Thumbnails style selected. Author, Excerpt and Date will not be "
28
  "displayed."
29
  msgstr ""
30
 
31
+ #: admin/admin.php:238
32
  msgid "Text Only style selected. Thumbnails will not be displayed."
33
  msgstr ""
34
 
35
+ #: admin/admin.php:242
36
  #, php-format
37
  msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %2$d."
38
  msgstr ""
39
 
40
+ #: admin/admin.php:277
41
  msgid "Options set to Default."
42
  msgstr ""
43
 
44
+ #: admin/admin.php:286
45
  msgid "Index recreated"
46
  msgstr ""
47
 
48
+ #: admin/admin.php:303
49
  msgid "Related Posts"
50
  msgstr ""
51
 
52
+ #: admin/cache.php:49
53
  msgid ""
54
  "An error occurred clearing the cache. Please contact your site administrator."
55
  "\\n\\nError message:\\n"
56
  msgstr ""
57
 
58
+ #: admin/cache.php:58
59
  msgid " cached row(s) cleared"
60
  msgstr ""
61
 
62
+ #: admin/loader.php:24
63
  msgid "Settings"
64
  msgstr ""
65
 
66
+ #: admin/loader.php:47 admin/sidebar-view.php:48
67
  msgid "Support"
68
  msgstr ""
69
 
70
+ #: admin/loader.php:48
71
  msgid "Donate"
72
  msgstr ""
73
 
74
+ #: admin/loader.php:49
75
  msgid "Contribute"
76
  msgstr ""
77
 
79
  msgid "General options"
80
  msgstr ""
81
 
82
+ #: admin/main-view.php:33 admin/main-view.php:163
83
  msgid "List tuning options"
84
  msgstr ""
85
 
86
+ #: admin/main-view.php:34 admin/main-view.php:273
87
  msgid "Output options"
88
  msgstr ""
89
 
90
+ #: admin/main-view.php:35 admin/main-view.php:477
91
+ #: includes/modules/class-crp-widget.php:122
92
  msgid "Thumbnail options"
93
  msgstr ""
94
 
95
+ #: admin/main-view.php:36 admin/main-view.php:650
96
  msgid "Styles"
97
  msgstr ""
98
 
99
+ #: admin/main-view.php:37 admin/main-view.php:742
100
  msgid "Feed options"
101
  msgstr ""
102
 
103
+ #: admin/main-view.php:54 admin/main-view.php:162 admin/main-view.php:272
104
+ #: admin/main-view.php:476 admin/main-view.php:649 admin/main-view.php:741
105
  #: admin/sidebar-view.php:19 admin/sidebar-view.php:40
106
  #: admin/sidebar-view.php:58
107
  msgid "Click to toggle"
196
  msgstr ""
197
 
198
  #: admin/main-view.php:107
199
+ msgid "Disable on mobile devices:"
200
  msgstr ""
201
 
202
  #: admin/main-view.php:110
203
+ msgid "Disable display of related posts on mobile devices"
204
+ msgstr ""
205
+
206
+ #: admin/main-view.php:114
207
+ msgid "Disable on AMP pages:"
208
+ msgstr ""
209
+
210
+ #: admin/main-view.php:117
211
+ msgid "Disable display of related posts on AMP pages"
212
+ msgstr ""
213
+
214
+ #: admin/main-view.php:121
215
+ msgid "Show metabox:"
216
+ msgstr ""
217
+
218
+ #: admin/main-view.php:124
219
  msgid ""
220
  "This will add the Contextual Related Posts metabox on Edit Posts or Add New "
221
  "Posts screens. Also applies to Pages and Custom Post Types."
222
  msgstr ""
223
 
224
+ #: admin/main-view.php:128
225
  msgid "Limit metabox to Admins only:"
226
  msgstr ""
227
 
228
+ #: admin/main-view.php:131
229
  msgid ""
230
  "If this is selected, the metabox will be hidden from anyone who is not an "
231
  "Admin. Otherwise, by default, Contributors and above will be able to see the "
232
  "metabox. This applies only if the above option is selected."
233
  msgstr ""
234
 
235
+ #: admin/main-view.php:135
236
  msgid "Tell the world you're using Contextual Related Posts:"
237
  msgstr ""
238
 
239
+ #: admin/main-view.php:137
240
  msgid "Optional"
241
  msgstr ""
242
 
243
+ #: admin/main-view.php:138
244
  msgid ""
245
  "Adds a nofollow link to Contextual Related Posts homepage as the last time "
246
  "in the list."
247
  msgstr ""
248
 
249
+ #: admin/main-view.php:156 admin/main-view.php:266 admin/main-view.php:470
250
+ #: admin/main-view.php:643 admin/main-view.php:735 admin/main-view.php:807
251
+ #: admin/main-view.php:823
252
  msgid "Save Options"
253
  msgstr ""
254
 
255
+ #: admin/main-view.php:179 admin/main-view.php:760
256
  msgid "Number of related posts to display: "
257
  msgstr ""
258
 
259
+ #: admin/main-view.php:182
260
  msgid ""
261
  "Maximum number of posts that will be displayed. The actual number may be "
262
  "smaller if less related posts are found."
263
  msgstr ""
264
 
265
+ #: admin/main-view.php:186
266
  msgid "Related posts should be newer than:"
267
  msgstr ""
268
 
269
+ #: admin/main-view.php:188
270
  msgid "days"
271
  msgstr ""
272
 
273
+ #: admin/main-view.php:189
274
  msgid ""
275
  "This sets the cutoff period for which posts will be displayed. e.g. setting "
276
  "it to 365 will show related posts from the last year only. Set to 0 to "
277
  "disable limiting posts by date."
278
  msgstr ""
279
 
280
+ #: admin/main-view.php:193
281
  msgid "Randomize posts"
282
  msgstr ""
283
 
284
+ #: admin/main-view.php:195
285
  msgid ""
286
  "This shuffles the top related posts. Does not work if the cache is enabled."
287
  msgstr ""
288
 
289
+ #: admin/main-view.php:199
290
  msgid "Find related posts based on content as well as title:"
291
  msgstr ""
292
 
293
+ #: admin/main-view.php:201
294
  msgid ""
295
  "If unchecked, only posts titles are used. I recommend using a caching plugin "
296
  "or enabling \"Cache output\" above if you enable this. Each site is "
298
  "quality related posts."
299
  msgstr ""
300
 
301
+ #: admin/main-view.php:205
302
  msgid "Limit content to be compared:"
303
  msgstr ""
304
 
305
+ #: admin/main-view.php:207
306
  msgid ""
307
  "This sets the maximum words of the content that will be matched. Set to 0 "
308
  "for no limit. Max value: 2,000. Only applies if you activate the above "
309
  "option."
310
  msgstr ""
311
 
312
+ #: admin/main-view.php:211
313
  msgid "Post types to include in results:"
314
  msgstr ""
315
 
316
+ #: admin/main-view.php:218
317
  msgid ""
318
  "These post types will be displayed in the list. Includes custom post types."
319
  msgstr ""
320
 
321
+ #: admin/main-view.php:222
322
  msgid "Limit to same post type"
323
  msgstr ""
324
 
325
+ #: admin/main-view.php:224
326
  msgid ""
327
  "If checked, the related posts will only be selected from the same post type "
328
  "of the current post."
329
  msgstr ""
330
 
331
+ #: admin/main-view.php:228
332
  msgid "List of post or page IDs to exclude from the results:"
333
  msgstr ""
334
 
335
+ #: admin/main-view.php:230 admin/main-view.php:401
336
  msgid ""
337
  "Comma separated list of post, page or custom post type IDs. e.g. 188,320,500"
338
  msgstr ""
339
 
340
+ #: admin/main-view.php:234
341
  msgid "Categories to exclude from the results: "
342
  msgstr ""
343
 
344
+ #: admin/main-view.php:237
345
  msgid ""
346
  "Comma separated list of category slugs. The field above has an autocomplete "
347
  "so simply start typing in the beginning of your category name and it will "
348
  "prompt you with options."
349
  msgstr ""
350
 
351
+ #: admin/main-view.php:240
352
  msgid "Excluded category IDs are:"
353
  msgstr ""
354
 
355
+ #: admin/main-view.php:241
356
  msgid " "
357
  msgstr ""
358
 
359
+ #: admin/main-view.php:246
360
  #, php-format
361
  msgid ""
362
  "These might differ from the IDs visible in the Categories page which use the "
363
  "%1$s. CRP uses the %2$s which is unique to this taxonomy."
364
  msgstr ""
365
 
366
+ #: admin/main-view.php:289
367
  msgid "Title of related posts:"
368
  msgstr ""
369
 
370
+ #: admin/main-view.php:292
371
  #, php-format
372
  msgid ""
373
  "This is the main heading of the related posts. You can also display the "
374
  "current post title by using %1$s"
375
  msgstr ""
376
 
377
+ #: admin/main-view.php:296
378
  msgid "When there are no posts, what should be shown?"
379
  msgstr ""
380
 
381
+ #: admin/main-view.php:300
382
  msgid "Blank Output"
383
  msgstr ""
384
 
385
+ #: admin/main-view.php:305
386
  msgid "Display:"
387
  msgstr ""
388
 
389
+ #: admin/main-view.php:311 admin/main-view.php:763
390
  msgid "Show post excerpt in list?"
391
  msgstr ""
392
 
393
+ #: admin/main-view.php:314
394
  #, php-format
395
  msgid ""
396
  "Displays the excerpt of the post. If you do not provide an explicit excerpt "
398
  "automatic excerpt which refers to the first %d words of the post's content"
399
  msgstr ""
400
 
401
+ #: admin/main-view.php:317
402
  msgid ""
403
  "Rounded Thumbnails style selected under the Custom Styles. Excerpt display "
404
  "is disabled."
405
  msgstr ""
406
 
407
+ #: admin/main-view.php:322
408
  msgid "Length of excerpt (in words):"
409
  msgstr ""
410
 
411
+ #: admin/main-view.php:328
412
  msgid "Show post author in list?"
413
  msgstr ""
414
 
415
+ #: admin/main-view.php:331
416
  msgid "Displays the author name prefixed with \"by\". e.g. by John Doe"
417
  msgstr ""
418
 
419
+ #: admin/main-view.php:334
420
  msgid ""
421
  "Rounded Thumbnails style selected under the Custom Styles. Author display is "
422
  "disabled."
423
  msgstr ""
424
 
425
+ #: admin/main-view.php:339
426
  msgid "Show post date in list?"
427
  msgstr ""
428
 
429
+ #: admin/main-view.php:342
430
  msgid ""
431
  "Displays the date of the post. Uses the same date format set in General "
432
  "Options"
433
  msgstr ""
434
 
435
+ #: admin/main-view.php:345
436
  msgid ""
437
  "Rounded Thumbnails style selected under the Custom Styles. Date display is "
438
  "disabled."
439
  msgstr ""
440
 
441
+ #: admin/main-view.php:350
442
  msgid "Limit post title length (in characters)"
443
  msgstr ""
444
 
445
+ #: admin/main-view.php:353
446
  msgid ""
447
  "Any title longer than the number of characters set above will be cut and "
448
  "appended with an ellipsis (&hellip;)"
449
  msgstr ""
450
 
451
+ #: admin/main-view.php:357
452
  msgid "Open links in new window"
453
  msgstr ""
454
 
455
+ #: admin/main-view.php:363
456
  msgid "Add nofollow attribute to links in the list"
457
  msgstr ""
458
 
459
+ #: admin/main-view.php:396
460
  msgid "Exclusion settings:"
461
  msgstr ""
462
 
463
+ #: admin/main-view.php:398
464
  msgid "Exclude display of related posts on these posts / pages"
465
  msgstr ""
466
 
467
+ #: admin/main-view.php:404
468
  msgid "Exclude display of related posts on these post types."
469
  msgstr ""
470
 
471
+ #: admin/main-view.php:411
472
  msgid ""
473
  "The related posts will not display on any of the above selected post types"
474
  msgstr ""
475
 
476
+ #: admin/main-view.php:441
477
  msgid "Customize the output:"
478
  msgstr ""
479
 
480
+ #: admin/main-view.php:443
481
  msgid "HTML to display before the list of posts: "
482
  msgstr ""
483
 
484
+ #: admin/main-view.php:446
485
  msgid "HTML to display before each list item: "
486
  msgstr ""
487
 
488
+ #: admin/main-view.php:449
489
  msgid "HTML to display after each list item: "
490
  msgstr ""
491
 
492
+ #: admin/main-view.php:452
493
  msgid "HTML to display after the list of posts: "
494
  msgstr ""
495
 
496
+ #: admin/main-view.php:493 admin/main-view.php:766
497
  msgid "Location of post thumbnail:"
498
  msgstr ""
499
 
500
+ #: admin/main-view.php:497 admin/main-view.php:770
501
  msgid "Display thumbnails inline with posts, before title"
502
  msgstr ""
503
 
504
+ #: admin/main-view.php:502 admin/main-view.php:774
505
  msgid "Display thumbnails inline with posts, after title"
506
  msgstr ""
507
 
508
+ #: admin/main-view.php:507 admin/main-view.php:778
509
  msgid "Display only thumbnails, no text"
510
  msgstr ""
511
 
512
+ #: admin/main-view.php:512 admin/main-view.php:782
513
  msgid "Do not display thumbnails, only text."
514
  msgstr ""
515
 
516
+ #: admin/main-view.php:516
517
  #, php-format
518
  msgid ""
519
  "This setting cannot be changed because an inbuilt style has been selected "
521
  "select %1$s under the Styles section."
522
  msgstr ""
523
 
524
+ #: admin/main-view.php:516 admin/main-view.php:669
525
  msgid "No styles"
526
  msgstr ""
527
 
528
+ #: admin/main-view.php:520
529
  msgid "Thumbnail size:"
530
  msgstr ""
531
 
532
+ #: admin/main-view.php:545
533
  msgid "Custom size"
534
  msgstr ""
535
 
536
+ #: admin/main-view.php:548
537
  msgid "You can choose from existing image sizes above or create a custom size."
538
  msgstr ""
539
 
540
+ #: admin/main-view.php:549
541
  msgid ""
542
  "If you choose an existing size, then the width, height and crop mode "
543
  "settings in the three options below will be automatically updated to reflect "
544
  "the correct dimensions of the setting."
545
  msgstr ""
546
 
547
+ #: admin/main-view.php:550
548
  msgid ""
549
  "If you have chosen Custom size above, then enter the width, height and crop "
550
  "settings below. For best results, use a cropped image with the same width "
551
  "and height. The default setting is 150x150 cropped image."
552
  msgstr ""
553
 
554
+ #: admin/main-view.php:551
555
  msgid ""
556
  "Any changes to the thumbnail settings doesn't automatically resize existing "
557
  "images."
558
  msgstr ""
559
 
560
+ #: admin/main-view.php:554
561
  #, php-format
562
  msgid "I recommend using %1$s or %2$s to regenerate all image sizes."
563
  msgstr ""
564
 
565
+ #: admin/main-view.php:562
566
  msgid "Width of the thumbnail:"
567
  msgstr ""
568
 
569
+ #: admin/main-view.php:565
570
  msgid "Height of the thumbnail: "
571
  msgstr ""
572
 
573
+ #: admin/main-view.php:570
574
  msgid "Crop mode:"
575
  msgstr ""
576
 
577
+ #: admin/main-view.php:574
578
  msgid ""
579
  "By default, thumbnails will be hard cropped. Uncheck this box to "
580
  "proportionately/soft crop the thumbnails."
581
  msgstr ""
582
 
583
+ #: admin/main-view.php:578
584
  msgid "Image size attributes:"
585
  msgstr ""
586
 
587
+ #: admin/main-view.php:583
588
  msgid "Style attributes. e.g."
589
  msgstr ""
590
 
591
+ #: admin/main-view.php:591
592
  msgid "HTML width and height attributes. e.g."
593
  msgstr ""
594
 
595
+ #: admin/main-view.php:598
596
  msgid "No HTML or Style attributes"
597
  msgstr ""
598
 
599
+ #: admin/main-view.php:603
600
  msgid "Post thumbnail meta field name:"
601
  msgstr ""
602
 
603
+ #: admin/main-view.php:605
604
  #, php-format
605
  msgid ""
606
  "The value of this field should contain a direct link to the image. This is "
607
  "set in the meta box in the %1$s screen."
608
  msgstr ""
609
 
610
+ #: admin/main-view.php:605
611
  msgid "Add New Post"
612
  msgstr ""
613
 
614
+ #: admin/main-view.php:608
615
  msgid "Extract the first image from the post?"
616
  msgstr ""
617
 
618
+ #: admin/main-view.php:610
619
  msgid ""
620
  "This will only happen if there is no post thumbnail set and no image URL is "
621
  "specified in the meta field."
622
  msgstr ""
623
 
624
+ #: admin/main-view.php:613
625
  msgid "Use default thumbnail?"
626
  msgstr ""
627
 
628
+ #: admin/main-view.php:615
629
  msgid ""
630
  "If checked, when no thumbnail is found, show a default one from the URL "
631
  "below. If not checked and no thumbnail is found, no image will be shown."
632
  msgstr ""
633
 
634
+ #: admin/main-view.php:618
635
  msgid "Default thumbnail:"
636
  msgstr ""
637
 
638
+ #: admin/main-view.php:625
639
  msgid ""
640
  "The plugin will first check if the post contains a thumbnail. If it doesn't "
641
  "then it will check the meta field. If this is not available, then it will "
642
  "show the default image as specified above."
643
  msgstr ""
644
 
645
+ #: admin/main-view.php:666
646
  msgid "Style of the related posts:"
647
  msgstr ""
648
 
649
+ #: admin/main-view.php:671
650
  msgid "Select this option if you plan to add your own styles"
651
  msgstr ""
652
 
653
+ #: admin/main-view.php:680
654
  msgid "Rounded Thumbnails"
655
  msgstr ""
656
 
657
+ #: admin/main-view.php:683
658
  msgid ""
659
  "Enabling this option will turn on the thumbnails and set their width and "
660
  "height to 150px. It will also turn off the display of the author, excerpt "
662
  "settings."
663
  msgstr ""
664
 
665
+ #: admin/main-view.php:687
666
  #, php-format
667
  msgid "You can view the default style at %s"
668
  msgstr ""
669
 
670
+ #: admin/main-view.php:695
671
  msgid "Text only"
672
  msgstr ""
673
 
674
+ #: admin/main-view.php:697
675
  msgid ""
676
  "Enabling this option will disable thumbnails and no longer include the "
677
  "default style sheet included in the plugin."
678
  msgstr ""
679
 
680
+ #: admin/main-view.php:712
681
  msgid "Custom CSS to add to header:"
682
  msgstr ""
683
 
684
+ #: admin/main-view.php:717
685
  #, php-format
686
  msgid ""
687
  "Do not include %1$s tags. Check out the %2$s for available CSS classes to "
688
  "style."
689
  msgstr ""
690
 
691
+ #: admin/main-view.php:758
692
  msgid ""
693
  "Below options override the related posts settings for your blog feed. These "
694
  "only apply if you have selected to add related posts to Feeds in the General "
695
  "Options tab."
696
  msgstr ""
697
 
698
+ #: admin/main-view.php:786
699
  msgid "Maximum width of the thumbnail: "
700
  msgstr ""
701
 
702
+ #: admin/main-view.php:789
703
  msgid "Maximum height of the thumbnail: "
704
  msgstr ""
705
 
706
+ #: admin/main-view.php:824
707
  msgid "Default Options"
708
  msgstr ""
709
 
710
+ #: admin/main-view.php:824
711
  msgid "Do you want to set options to Default?"
712
  msgstr ""
713
 
714
+ #: admin/main-view.php:825
715
  msgid "Recreate Index"
716
  msgstr ""
717
 
718
+ #: admin/main-view.php:825
719
  msgid "Are you sure you want to recreate the index?"
720
  msgstr ""
721
 
722
+ #: admin/main-view.php:830
723
  #, php-format
724
  msgid ""
725
  "One or more FULLTEXT indices are missing. Please hit the %1$s at the bottom "
726
  "of the page to fix this."
727
  msgstr ""
728
 
729
+ #: admin/main-view.php:830
730
  msgid "Recreate Index button"
731
  msgstr ""
732
 
733
+ #: admin/main-view.php:835
734
  msgid ""
735
  "If the Recreate Index button fails, please run the following queries in "
736
  "phpMyAdmin or Adminer"
737
  msgstr ""
738
 
739
+ #: admin/metabox.php:107
740
  msgid "Disable Related Posts display:"
741
  msgstr ""
742
 
743
+ #: admin/metabox.php:110
744
  msgid ""
745
  "If this is checked, then Contextual Related Posts will not automatically "
746
  "insert the related posts at the end of post content."
747
  msgstr ""
748
 
749
+ #: admin/metabox.php:114
750
  msgid "Exclude this post from the related posts list:"
751
  msgstr ""
752
 
753
+ #: admin/metabox.php:117
754
  msgid ""
755
  "If this is checked, then this post will be excluded from the popular posts "
756
  "list."
757
  msgstr ""
758
 
759
+ #: admin/metabox.php:121 admin/metabox.php:129
760
  msgid "Manual related posts:"
761
  msgstr ""
762
 
763
+ #: admin/metabox.php:123
764
  msgid ""
765
  "Comma separated list of post, page or custom post type IDs. e.g. "
766
  "188,320,500. These will be given preference over the related posts generated "
767
  "by the plugin."
768
  msgstr ""
769
 
770
+ #: admin/metabox.php:124
771
  msgid ""
772
  "Once you enter the list above and save this page, the plugin will display "
773
  "the titles of the posts below for your reference. Only IDs corresponding to "
774
  "published posts or custom post types will be retained."
775
  msgstr ""
776
 
777
+ #: admin/metabox.php:140
778
  #, php-format
779
  msgid "This post type is: %s"
780
  msgstr ""
781
 
782
+ #: admin/metabox.php:151
783
  msgid "Location of thumbnail"
784
  msgstr ""
785
 
786
+ #: admin/metabox.php:153
787
  msgid ""
788
  "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This "
789
  "image will be used for the post. It will be resized to the thumbnail size "
790
  "set under Settings &raquo; Related Posts &raquo; Output Options"
791
  msgstr ""
792
 
793
+ #: admin/metabox.php:154
794
  msgid "The URL above is saved in the meta field:"
795
  msgstr ""
796
 
797
+ #: admin/metabox.php:159
798
  msgid ""
799
  "You have Top 10 WordPress Plugin installed. If you are trying to modify the "
800
  "thumbnail, then you'll need to make the same change in the Top 10 meta box "
861
  msgid "No related posts found"
862
  msgstr ""
863
 
864
+ #: includes/main-query.php:195
865
  #, php-format
866
  msgid "Powered by <a href=\"%s\" rel=\"nofollow\">Contextual Related Posts</a>"
867
  msgstr ""
886
  msgid "Display Related Posts"
887
  msgstr ""
888
 
889
+ #: includes/modules/class-crp-widget.php:78
890
  msgid "Title"
891
  msgstr ""
892
 
893
+ #: includes/modules/class-crp-widget.php:83
894
  msgid "No. of posts"
895
  msgstr ""
896
 
897
+ #: includes/modules/class-crp-widget.php:88
898
  msgid "Offset"
899
  msgstr ""
900
 
901
+ #: includes/modules/class-crp-widget.php:98
902
  msgid " Show excerpt?"
903
  msgstr ""
904
 
905
+ #: includes/modules/class-crp-widget.php:108
906
  msgid " Show author?"
907
  msgstr ""
908
 
909
+ #: includes/modules/class-crp-widget.php:118
910
  msgid " Show date?"
911
  msgstr ""
912
 
913
+ #: includes/modules/class-crp-widget.php:124
914
  msgid "Thumbnails inline, before title"
915
  msgstr ""
916
 
917
+ #: includes/modules/class-crp-widget.php:125
918
  msgid "Thumbnails inline, after title"
919
  msgstr ""
920
 
921
+ #: includes/modules/class-crp-widget.php:126
922
  msgid "Only thumbnails, no text"
923
  msgstr ""
924
 
925
+ #: includes/modules/class-crp-widget.php:127
926
  msgid "No thumbnails, only text."
927
  msgstr ""
928
 
929
+ #: includes/modules/class-crp-widget.php:132
930
  msgid "Thumbnail height"
931
  msgstr ""
932
 
933
+ #: includes/modules/class-crp-widget.php:137
934
  msgid "Thumbnail width"
935
  msgstr ""
936
 
937
+ #: includes/modules/class-crp-widget.php:141
938
  msgid "Post types to include"
939
  msgstr ""
940
 
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === Contextual Related Posts ===
2
- Tags: related posts, related, similar posts, posts, post, feed, feeds, rss, widget, thumbnail, shortcodes
3
  Contributors: webberzone, Ajay
4
  Donate link: https://ajaydsouza.com/donate/
5
  Stable tag: trunk
6
- Requires at least: 4.1
7
- Tested up to: 4.8
8
  License: GPLv2 or later
9
 
10
- Display related posts on your WordPress blog and feed. Supports thumbnails, shortcodes, widgets and custom post types!
11
 
12
  == Description ==
13
 
@@ -23,10 +23,10 @@ And the default inbuilt styles allow you to switch between gorgeous thumbnail-ri
23
 
24
  * **Automatic**: CRP will start displaying related posts on your site and feed automatically after the content when you activate the plugin. No need to edit template files
25
  * **Manual install**: Want more control over placement? Check the [FAQ](http://wordpress.org/extend/plugins/contextual-related-posts/faq/) on which functions are available for manual install.
 
26
  * **Widgets**: Add related posts to widgetized area of your theme. Lots of options available
27
  * **Shortcode**: Use `[crp]` to display the posts anywhere you want in the post content
28
  * **The algorithm**: Find related posts by title and/or content of the current post
29
- * **Caching**: Related posts output is automatically cached as visitors browse through your site
30
  * **Exclusions**: Exclude posts from categories from being displayed in the list. Or you can exclude posts or pages by ID
31
  * **Custom post types**: The related posts list lets you include posts, pages, attachments or any other custom post type!
32
  * **Thumbnail support**:
@@ -40,9 +40,14 @@ And the default inbuilt styles allow you to switch between gorgeous thumbnail-ri
40
  * Customise which HTML tags to use for displaying the output in case you don't prefer the default `list` format
41
  * **Extendable code**: CRP has tonnes of filters and actions that allow any developer to easily add features, edit outputs, etc.
42
 
43
- = Extensions =
 
 
 
 
 
44
 
45
- * [CRP Taxonomy Extender](https://webberzone.com/downloads/crp-taxonomy/)
46
 
47
  = Donations =
48
 
@@ -58,10 +63,7 @@ Bug reports are [welcomed on GitHub](https://github.com/WebberZone/contextual-re
58
 
59
  = Translations =
60
 
61
- Contextual Related Posts is now on Transifex with several translations made available by the [WP Translations](http://wp-translations.org). If you're a translator, do consider joining the WP Translations team and contribute towards this and a huge number of WordPress plugins.
62
-
63
- Visit [Contextual Related Posts on Transifex](https://www.transifex.com/projects/p/contextual-related-posts/).
64
-
65
 
66
  == Installation ==
67
 
@@ -181,6 +183,22 @@ In addition to the above, the shortcode takes every option that the plugin suppo
181
 
182
  == Changelog ==
183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  = 2.4.1 =
185
 
186
  * Bug fixes:
@@ -341,7 +359,7 @@ For the changelog of earlier versions, please refer to the separate changelog.tx
341
 
342
  == Upgrade Notice ==
343
 
344
- = 2.4.1 =
345
  * New features. Upgrade highly recommended. Please do verify your settings after the upgrade.
346
  Check the Changelog for more details
347
 
1
  === Contextual Related Posts ===
2
+ Tags: related posts, related, related articles, contextual related posts, similar posts, related posts widget
3
  Contributors: webberzone, Ajay
4
  Donate link: https://ajaydsouza.com/donate/
5
  Stable tag: trunk
6
+ Requires at least: 4.2
7
+ Tested up to: 5.0
8
  License: GPLv2 or later
9
 
10
+ Add related posts to your WordPress site with inbuilt caching. Supports thumbnails, shortcodes, widgets and custom post types!
11
 
12
  == Description ==
13
 
23
 
24
  * **Automatic**: CRP will start displaying related posts on your site and feed automatically after the content when you activate the plugin. No need to edit template files
25
  * **Manual install**: Want more control over placement? Check the [FAQ](http://wordpress.org/extend/plugins/contextual-related-posts/faq/) on which functions are available for manual install.
26
+ * **Caching**: Related posts output is automatically cached as visitors browse through your site
27
  * **Widgets**: Add related posts to widgetized area of your theme. Lots of options available
28
  * **Shortcode**: Use `[crp]` to display the posts anywhere you want in the post content
29
  * **The algorithm**: Find related posts by title and/or content of the current post
 
30
  * **Exclusions**: Exclude posts from categories from being displayed in the list. Or you can exclude posts or pages by ID
31
  * **Custom post types**: The related posts list lets you include posts, pages, attachments or any other custom post type!
32
  * **Thumbnail support**:
40
  * Customise which HTML tags to use for displaying the output in case you don't prefer the default `list` format
41
  * **Extendable code**: CRP has tonnes of filters and actions that allow any developer to easily add features, edit outputs, etc.
42
 
43
+ = Extensions/Addons =
44
+
45
+ * [Related Posts by Categories and Tags](https://webberzone.com/downloads/crp-taxonomy/)
46
+
47
+ = GDPR =
48
+ Contextual Related Posts is GDPR compliant as it doesn't collect any personal data about your visitors when installed out of the box. All posts are processed on your site and not sent to any external service.
49
 
50
+ YOU ARE RESPONSIBLE FOR ENSURING THAT ALL GDPR REQUIREMENTS ARE MET ON YOUR WEBSITE.
51
 
52
  = Donations =
53
 
63
 
64
  = Translations =
65
 
66
+ Contextual Related Posts is available for [translation directly on WordPress.org](https://translate.wordpress.org/projects/wp-plugins/contextual-related-posts). Check out the official [Translator Handbook](https://make.wordpress.org/polyglots/handbook/rosetta/theme-plugin-directories/) to contribute.
 
 
 
67
 
68
  == Installation ==
69
 
183
 
184
  == Changelog ==
185
 
186
+ = 2.5.0 =
187
+
188
+ * Features:
189
+ * New option to disable related posts on mobile devices
190
+ * New option to disable related posts on AMP pages
191
+
192
+ * Enhancements:
193
+ * New filters `crp_thumb_alt` and `crp_thumb_title` to edit the post thumbnail alt and title tags. Use this to remove/replace the tags
194
+ * New function and filter `crp_permalink`
195
+ * Saving a post will delete its cache
196
+
197
+ * Bug fixes:
198
+ * Fixed CSS validation errors
199
+ * Removed conversion of table schema from/to InnoDB. If you are using a version of mySQL above v5.6, you can alter the table engine to use InnoDB with a FULLTEXT index
200
+ * Prevent errors from non-existent post id (virtual post). Contributed by [@jnorell](https://github.com/jnorell)
201
+
202
  = 2.4.1 =
203
 
204
  * Bug fixes:
359
 
360
  == Upgrade Notice ==
361
 
362
+ = 2.5.0 =
363
  * New features. Upgrade highly recommended. Please do verify your settings after the upgrade.
364
  Check the Changelog for more details
365
 
uninstall.php CHANGED
@@ -20,20 +20,24 @@ if ( ! is_multisite() ) {
20
  $wpdb->query( "ALTER TABLE {$wpdb->posts} DROP INDEX crp_related_title" );
21
  $wpdb->query( "ALTER TABLE {$wpdb->posts} DROP INDEX crp_related_content" );
22
 
23
- $wpdb->query( "
 
24
  DELETE FROM {$wpdb->postmeta}
25
  WHERE meta_key LIKE 'crp_related_posts%'
26
- " );
 
27
 
28
  delete_option( $option_name );
29
 
30
  } else {
31
 
32
  // Get all blogs in the network and activate plugin on each one.
33
- $blog_ids = $wpdb->get_col( "
 
34
  SELECT blog_id FROM $wpdb->blogs
35
  WHERE archived = '0' AND spam = '0' AND deleted = '0'
36
- " );
 
37
 
38
  foreach ( $blog_ids as $blog_id ) {
39
  switch_to_blog( $blog_id );
@@ -42,10 +46,12 @@ if ( ! is_multisite() ) {
42
  $wpdb->query( "ALTER TABLE {$wpdb->posts} DROP INDEX crp_related_title" );
43
  $wpdb->query( "ALTER TABLE {$wpdb->posts} DROP INDEX crp_related_content" );
44
 
45
- $wpdb->query( "
 
46
  DELETE FROM {$wpdb->postmeta}
47
  WHERE meta_key LIKE 'crp_related_posts%'
48
- " );
 
49
 
50
  delete_option( $option_name );
51
 
20
  $wpdb->query( "ALTER TABLE {$wpdb->posts} DROP INDEX crp_related_title" );
21
  $wpdb->query( "ALTER TABLE {$wpdb->posts} DROP INDEX crp_related_content" );
22
 
23
+ $wpdb->query(
24
+ "
25
  DELETE FROM {$wpdb->postmeta}
26
  WHERE meta_key LIKE 'crp_related_posts%'
27
+ "
28
+ );
29
 
30
  delete_option( $option_name );
31
 
32
  } else {
33
 
34
  // Get all blogs in the network and activate plugin on each one.
35
+ $blog_ids = $wpdb->get_col(
36
+ "
37
  SELECT blog_id FROM $wpdb->blogs
38
  WHERE archived = '0' AND spam = '0' AND deleted = '0'
39
+ "
40
+ );
41
 
42
  foreach ( $blog_ids as $blog_id ) {
43
  switch_to_blog( $blog_id );
46
  $wpdb->query( "ALTER TABLE {$wpdb->posts} DROP INDEX crp_related_title" );
47
  $wpdb->query( "ALTER TABLE {$wpdb->posts} DROP INDEX crp_related_content" );
48
 
49
+ $wpdb->query(
50
+ "
51
  DELETE FROM {$wpdb->postmeta}
52
  WHERE meta_key LIKE 'crp_related_posts%'
53
+ "
54
+ );
55
 
56
  delete_option( $option_name );
57