Contextual Related Posts - Version 2.4.0

Version Description

  • Features:

    • New option to randomize the related posts
    • New option to limit related posts to the same post type
    • "Automatically add related posts to" option applies to widgets
  • Enhancements:

    • post_types argument now takes a comma-separated list of post types. Default format when resaving options is also comma-separated
  • Bug fixes:

    • Trimming titles should now work with multibyte / non-English characters
  • Deprecated:

    • crp_max_formatted_content has been deprecated. Use crp_trim_char instead
Download this release

Release Info

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

Code changes from version 2.3.1 to 2.4.0

README.md CHANGED
@@ -1,10 +1,14 @@
1
- [![Build Status](https://travis-ci.org/WebberZone/contextual-related-posts.svg)](https://travis-ci.org/WebberZone/contextual-related-posts)
 
 
 
 
2
 
3
  # Contextual Related Posts
4
 
5
  __Requires:__ 4.1
6
 
7
- __Tested up to:__ 4.7
8
 
9
  __License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html)
10
 
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
 
admin/admin.php CHANGED
@@ -8,7 +8,7 @@
8
  * @author Ajay D'Souza <me@ajaydsouza.com>
9
  * @license GPL-2.0+
10
  * @link https://webberzone.com
11
- * @copyright 2009-2015 Ajay D'Souza
12
  */
13
 
14
  /**** If this file is called directly, abort. ****/
@@ -31,10 +31,23 @@ function crp_options() {
31
  $wp_post_types = get_post_types( array(
32
  'public' => true,
33
  ) );
34
- parse_str( $crp_settings['post_types'], $post_types );
 
 
 
 
 
 
 
35
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
36
 
37
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types );
 
 
 
 
 
 
38
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
39
 
40
  // Temporary check if default styles are off and rounded thumbnails are selected - will be eventually deprecated.
@@ -54,8 +67,10 @@ function crp_options() {
54
  $crp_settings['cache'] = isset( $_POST['cache'] ) ? true : false;
55
  $crp_settings['limit'] = absint( $_POST['limit'] );
56
  $crp_settings['daily_range'] = absint( $_POST['daily_range'] );
 
57
  $crp_settings['match_content'] = isset( $_POST['match_content'] ) ? true : false;
58
  $crp_settings['match_content_words'] = min( CRP_MAX_WORDS, absint( $_POST['match_content_words'] ) );
 
59
 
60
  $crp_settings['add_to_content'] = ( isset( $_POST['add_to_content'] ) ? true : false );
61
  $crp_settings['add_to_page'] = ( isset( $_POST['add_to_page'] ) ? true : false );
@@ -164,14 +179,16 @@ function crp_options() {
164
  $wp_post_types = get_post_types( array(
165
  'public' => true,
166
  ) );
167
- $post_types_arr = ( isset( $_POST['post_types'] ) && is_array( $_POST['post_types'] ) ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['post_types'] ) ) : array( 'post' => 'post' );
 
 
168
  $post_types = array_intersect( $wp_post_types, $post_types_arr );
169
- $crp_settings['post_types'] = http_build_query( $post_types, '', '&' );
170
 
171
  /**** Post types to exclude display on ****/
172
  $post_types_excl_arr = ( isset( $_POST['exclude_on_post_types'] ) && is_array( $_POST['exclude_on_post_types'] ) ) ? $_POST['exclude_on_post_types'] : array();
173
  $exclude_on_post_types = array_intersect( $wp_post_types, $post_types_excl_arr );
174
- $crp_settings['exclude_on_post_types'] = http_build_query( $exclude_on_post_types, '', '&' );
175
 
176
  /**
177
  * Filters $crp_settings before it is saved into the database
@@ -187,10 +204,19 @@ function crp_options() {
187
  update_option( 'ald_crp_settings', $crp_settings );
188
  $crp_settings = crp_read_options();
189
 
190
- parse_str( $crp_settings['post_types'], $post_types );
 
 
 
 
 
191
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
192
 
193
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types );
 
 
 
 
194
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
195
 
196
  // Delete the cache.
@@ -206,13 +232,14 @@ function crp_options() {
206
  $str .= '<p>' . __( 'Text Only style selected. Thumbnails will not be displayed.', 'contextual-related-posts' ) . '</p>';
207
  }
208
  if ( 'crp_thumbnail' !== $crp_settings['thumb_size'] ) {
209
- $str .= '<p>' . sprintf( __( 'Pre-built thumbnail size selected. Thumbnail set to %1$d x %1$d.', 'contextual-related-posts' ), $crp_settings['thumb_width'], $crp_settings['thumb_height'] ) . '</p>';
 
210
  }
211
 
212
  $str .= '</div>';
213
 
214
  echo $str; // WPCS: XSS OK.
215
- }
216
 
217
  if ( ( isset( $_POST['crp_default'] ) ) && ( check_admin_referer( 'crp-plugin-settings' ) ) ) {
218
  delete_option( 'ald_crp_settings' );
@@ -224,10 +251,19 @@ function crp_options() {
224
  $wp_post_types = get_post_types( array(
225
  'public' => true,
226
  ) );
227
- parse_str( $crp_settings['post_types'], $post_types );
 
 
 
 
 
228
  $posts_types_inc = array_intersect( $wp_post_types, $post_types );
229
 
230
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types );
 
 
 
 
231
  $posts_types_excl = array_intersect( $wp_post_types, $exclude_on_post_types );
232
 
233
  $str = '<div id="message" class="updated fade"><p>' . __( 'Options set to Default.', 'contextual-related-posts' ) . '</p></div>';
@@ -300,12 +336,12 @@ function crp_adminhead() {
300
  content: '\f140';
301
  }
302
  .wrap h1:before {
303
- content: "\f237";
304
- display: inline-block;
305
- -webkit-font-smoothing: antialiased;
306
- font: normal 29px/1 'dashicons';
307
- vertical-align: middle;
308
- margin-right: 0.3em;
309
  }
310
  </style>
311
 
@@ -318,10 +354,10 @@ function crp_adminhead() {
318
  postboxes.add_postbox_toggles('crp_options');
319
  });
320
 
321
- // Function to add auto suggest.
322
- function setSuggest( id, taxonomy ) {
323
- jQuery('#' + id).suggest("<?php echo admin_url( 'admin-ajax.php?action=ajax-tag-search&tax=' ); ?>" + taxonomy, {multiple:true, multipleSep: ","});
324
- }
325
 
326
  function clearCache() {
327
  jQuery.post(ajaxurl, {action: 'crp_clear_cache'}, function(response, textStatus, jqXHR) {
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. ****/
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 );
43
 
44
+ // If this post type is in the DO NOT DISPLAY list.
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 );
52
 
53
  // Temporary check if default styles are off and rounded thumbnails are selected - will be eventually deprecated.
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 );
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
204
  update_option( 'ald_crp_settings', $crp_settings );
205
  $crp_settings = crp_read_options();
206
 
207
+ // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
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
 
222
  // Delete the cache.
232
  $str .= '<p>' . __( 'Text Only style selected. Thumbnails will not be displayed.', 'contextual-related-posts' ) . '</p>';
233
  }
234
  if ( 'crp_thumbnail' !== $crp_settings['thumb_size'] ) {
235
+ /* translators: Thumbnail width and height */
236
+ $str .= '<p>' . sprintf( __( 'Pre-built thumbnail size selected. Thumbnail set to %1$d x %2$d.', 'contextual-related-posts' ), $crp_settings['thumb_width'], $crp_settings['thumb_height'] ) . '</p>';
237
  }
238
 
239
  $str .= '</div>';
240
 
241
  echo $str; // WPCS: XSS OK.
242
+ }// End if().
243
 
244
  if ( ( isset( $_POST['crp_default'] ) ) && ( check_admin_referer( 'crp-plugin-settings' ) ) ) {
245
  delete_option( 'ald_crp_settings' );
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
 
269
  $str = '<div id="message" class="updated fade"><p>' . __( 'Options set to Default.', 'contextual-related-posts' ) . '</p></div>';
336
  content: '\f140';
337
  }
338
  .wrap h1:before {
339
+ content: "\f237";
340
+ display: inline-block;
341
+ -webkit-font-smoothing: antialiased;
342
+ font: normal 29px/1 'dashicons';
343
+ vertical-align: middle;
344
+ margin-right: 0.3em;
345
  }
346
  </style>
347
 
354
  postboxes.add_postbox_toggles('crp_options');
355
  });
356
 
357
+ // Function to add auto suggest.
358
+ function setSuggest( id, taxonomy ) {
359
+ jQuery('#' + id).suggest("<?php echo admin_url( 'admin-ajax.php?action=ajax-tag-search&tax=' ); ?>" + taxonomy, {multiple:true, multipleSep: ","});
360
+ }
361
 
362
  function clearCache() {
363
  jQuery.post(ajaxurl, {action: 'crp_clear_cache'}, function(response, textStatus, jqXHR) {
admin/cache.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  /**
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
  /**
admin/loader.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  /**
@@ -14,23 +14,23 @@
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' ) . '">' . __( 'Settings', 'contextual-related-posts' ) . '</a>',
24
  ), $links );
25
 
26
  }
27
- add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __DIR__ ) . 'contextual-related-posts.php' ), 'crp_plugin_actions_links' );
28
 
29
 
30
  /**
31
  * Add links to the plugin action row.
32
  *
33
- * @since 1.4
34
  *
35
  * @param array $links Links array.
36
  * @param string $file Plugin file name.
@@ -38,13 +38,15 @@ add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __DIR__ )
38
  */
39
  function crp_plugin_actions( $links, $file ) {
40
 
41
- $plugin = plugin_basename( plugin_dir_path( __DIR__ ) . 'contextual-related-posts.php' );
42
 
43
- /**** Add links ****/
44
- if ( $file === $plugin ) {
45
- $links[] = '<a href="http://wordpress.org/support/plugin/contextual-related-posts">' . __( 'Support', 'contextual-related-posts' ) . '</a>';
46
- $links[] = '<a href="https://ajaydsouza.com/donate/">' . __( 'Donate', 'contextual-related-posts' ) . '</a>';
47
- $links[] = '<a href="https://github.com/WebberZone/contextual-related-posts">' . __( 'Contribute', 'contextual-related-posts' ) . '</a>';
 
 
48
  }
49
  return $links;
50
  }
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
  /**
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' );
28
 
29
 
30
  /**
31
  * Add links to the plugin action row.
32
  *
33
+ * @since 1.4
34
  *
35
  * @param array $links Links array.
36
  * @param string $file Plugin file name.
38
  */
39
  function crp_plugin_actions( $links, $file ) {
40
 
41
+ if ( plugin_basename( CRP_PLUGIN_FILE ) === $file ) {
42
 
43
+ $new_links = array(
44
+ 'support' => '<a href = "http://wordpress.org/support/plugin/contextual-related-posts">' . esc_html__( 'Support', 'contextual-related-posts' ) . '</a>',
45
+ 'donate' => '<a href = "https://ajaydsouza.com/donate/">' . esc_html__( 'Donate', 'contextual-related-posts' ) . '</a>',
46
+ 'contribute' => '<a href = "https://github.com/WebberZone/contextual-related-posts">' . esc_html__( 'Contribute', 'contextual-related-posts' ) . '</a>',
47
+ );
48
+
49
+ $links = array_merge( $links, $new_links );
50
  }
51
  return $links;
52
  }
admin/main-view.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -176,6 +176,12 @@ if ( ! defined( 'WPINC' ) ) {
176
  </td>
177
  </tr>
178
 
 
 
 
 
 
 
179
  <tr><th scope="row"><label for="match_content"><?php esc_html_e( 'Find related posts based on content as well as title:', 'contextual-related-posts' ); ?></label></th>
180
  <td><input type="checkbox" name="match_content" id="match_content" <?php checked( $crp_settings['match_content'] ); ?> />
181
  <p class="description"><?php esc_html_e( 'If unchecked, only posts titles are used. I recommend using a caching plugin or enabling "Cache output" above if you enable this. Each site is different, so toggle this option to see which setting gives you better quality related posts.', 'contextual-related-posts' ); ?></p>
@@ -199,6 +205,12 @@ if ( ! defined( 'WPINC' ) ) {
199
  </td>
200
  </tr>
201
 
 
 
 
 
 
 
202
  <tr><th scope="row"><label for="exclude_post_ids"><?php esc_html_e( 'List of post or page IDs to exclude from the results:', 'contextual-related-posts' ); ?></label></th>
203
  <td><input type="textbox" name="exclude_post_ids" id="exclude_post_ids" value="<?php echo esc_attr( stripslashes( $crp_settings['exclude_post_ids'] ) ); ?>" style="width:250px">
204
  <p class="description"><?php esc_html_e( 'Comma separated list of post, page or custom post type IDs. e.g. 188,320,500', 'contextual-related-posts' ); ?></p>
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.
176
  </td>
177
  </tr>
178
 
179
+ <tr><th scope="row"><label for="random_order"><?php esc_html_e( 'Randomize posts', 'contextual-related-posts' ); ?>:</label></th>
180
+ <td><input type="checkbox" name="random_order" id="random_order" <?php checked( $crp_settings['random_order'] ); ?> />
181
+ <p class="description"><?php esc_html_e( 'This shuffles the top related posts. Does not work if the cache is enabled.', 'contextual-related-posts' ); ?></p>
182
+ </td>
183
+ </tr>
184
+
185
  <tr><th scope="row"><label for="match_content"><?php esc_html_e( 'Find related posts based on content as well as title:', 'contextual-related-posts' ); ?></label></th>
186
  <td><input type="checkbox" name="match_content" id="match_content" <?php checked( $crp_settings['match_content'] ); ?> />
187
  <p class="description"><?php esc_html_e( 'If unchecked, only posts titles are used. I recommend using a caching plugin or enabling "Cache output" above if you enable this. Each site is different, so toggle this option to see which setting gives you better quality related posts.', 'contextual-related-posts' ); ?></p>
205
  </td>
206
  </tr>
207
 
208
+ <tr><th scope="row"><label for="same_post_type"><?php esc_html_e( 'Limit to same post type', 'contextual-related-posts' ); ?>:</label></th>
209
+ <td><input type="checkbox" name="same_post_type" id="same_post_type" <?php checked( $crp_settings['same_post_type'] ); ?> />
210
+ <p class="description"><?php esc_html_e( 'If checked, the related posts will only be selected from the same post type of the current post.', 'contextual-related-posts' ); ?></p>
211
+ </td>
212
+ </tr>
213
+
214
  <tr><th scope="row"><label for="exclude_post_ids"><?php esc_html_e( 'List of post or page IDs to exclude from the results:', 'contextual-related-posts' ); ?></label></th>
215
  <td><input type="textbox" name="exclude_post_ids" id="exclude_post_ids" value="<?php echo esc_attr( stripslashes( $crp_settings['exclude_post_ids'] ) ); ?>" style="width:250px">
216
  <p class="description"><?php esc_html_e( 'Comma separated list of post, page or custom post type IDs. e.g. 188,320,500', 'contextual-related-posts' ); ?></p>
admin/metabox.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  /**** If this file is called directly, abort. ****/
@@ -41,11 +41,12 @@ function crp_add_meta_box( $post_type, $post ) {
41
  *
42
  * @since 2.2.0
43
  *
44
- * @param array $post_types Array of post types
 
45
  */
46
- $post_types = apply_filters( 'crp_meta_box_post_types', $post_types );
47
 
48
- if ( in_array( $post_type, $post_types ) ) {
49
 
50
  add_meta_box(
51
  'crp_metabox',
@@ -133,6 +134,7 @@ function crp_call_meta_box() {
133
  $title = get_the_title( $manual_related_post );
134
  echo '<a href="' . esc_url( get_permalink( $manual_related_post ) ) . '" target="_blank" title="' . esc_attr( $title ) . '" class="wherego_title">' . esc_attr( $title ) . '</a>. ';
135
  printf(
 
136
  esc_html__( 'This post type is: %s', 'contextual-related-posts' ),
137
  '<em>' . esc_html__( get_post_type( $manual_related_post ) ) . '</em>'
138
  );
@@ -187,7 +189,9 @@ function crp_save_meta_box( $post_id ) {
187
  $crp_post_meta = array();
188
 
189
  // Bail if we're doing an auto save.
190
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; }
 
 
191
 
192
  // If our nonce isn't there, or we can't verify it, bail.
193
  if ( ! isset( $_POST['crp_meta_box_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['crp_meta_box_nonce'] ), 'crp_meta_box' ) ) { // Input var okay.
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. ****/
41
  *
42
  * @since 2.2.0
43
  *
44
+ * @param array $post_types Array of post types.
45
+ * @param array $post_types Post object.
46
  */
47
+ $post_types = apply_filters( 'crp_meta_box_post_types', $post_types, $post );
48
 
49
+ if ( in_array( $post_type, $post_types, true ) ) {
50
 
51
  add_meta_box(
52
  'crp_metabox',
134
  $title = get_the_title( $manual_related_post );
135
  echo '<a href="' . esc_url( get_permalink( $manual_related_post ) ) . '" target="_blank" title="' . esc_attr( $title ) . '" class="wherego_title">' . esc_attr( $title ) . '</a>. ';
136
  printf(
137
+ /* translators: Post type name */
138
  esc_html__( 'This post type is: %s', 'contextual-related-posts' ),
139
  '<em>' . esc_html__( get_post_type( $manual_related_post ) ) . '</em>'
140
  );
189
  $crp_post_meta = array();
190
 
191
  // Bail if we're doing an auto save.
192
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
193
+ return;
194
+ }
195
 
196
  // If our nonce isn't there, or we can't verify it, bail.
197
  if ( ! isset( $_POST['crp_meta_box_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['crp_meta_box_nonce'] ), 'crp_meta_box' ) ) { // Input var okay.
admin/sidebar-view.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
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.
contextual-related-posts.php CHANGED
@@ -9,13 +9,13 @@
9
  * @author Ajay D'Souza <me@ajaydsouza.com>
10
  * @license GPL-2.0+
11
  * @link https://webberzone.com
12
- * @copyright 2009-2015 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.3.1
19
  * Author: WebberZone
20
  * Author URI: https://webberzone.com
21
  * License: GPL-2.0+
@@ -88,722 +88,6 @@ global $crp_settings;
88
  $crp_settings = crp_read_options();
89
 
90
 
91
- /**
92
- * Main function to generate the related posts output
93
- *
94
- * @since 1.0.1
95
- *
96
- * @param array $args Parameters in a query string format.
97
- * @return string HTML formatted list of related posts
98
- */
99
- function get_crp( $args = array() ) {
100
- global $post, $crp_settings;
101
-
102
- // If set, save $exclude_categories.
103
- if ( isset( $args['exclude_categories'] ) && '' != $args['exclude_categories'] ) {
104
- $exclude_categories = explode( ',', $args['exclude_categories'] );
105
- $args['strict_limit'] = false;
106
- }
107
- $defaults = array(
108
- 'is_widget' => false,
109
- 'is_shortcode' => false,
110
- 'is_manual' => false,
111
- 'echo' => true,
112
- 'heading' => true,
113
- 'offset' => 0,
114
- );
115
- $defaults = array_merge( $defaults, $crp_settings );
116
-
117
- // Parse incomming $args into an array and merge it with $defaults.
118
- $args = wp_parse_args( $args, $defaults );
119
-
120
- // WPML support.
121
- if ( function_exists( 'wpml_object_id_filter' ) || function_exists( 'icl_object_id' ) ) {
122
- $args['strict_limit'] = false;
123
- }
124
-
125
- // Support caching to speed up retrieval.
126
- if ( ! empty( $args['cache'] ) ) {
127
- $meta_key = 'crp_related_posts';
128
- if ( $args['is_widget'] ) {
129
- $meta_key .= '_widget';
130
- }
131
- if ( $args['is_manual'] ) {
132
- $meta_key .= '_manual';
133
- }
134
- if ( is_feed() ) {
135
- $meta_key .= '_feed';
136
- }
137
- $output = get_post_meta( $post->ID, $meta_key, true );
138
- if ( $output ) {
139
- return $output;
140
- }
141
- }
142
-
143
- // Retrieve the list of posts.
144
- $results = get_crp_posts_id( array_merge( $args, array(
145
- 'postid' => $post->ID,
146
- 'strict_limit' => isset( $args['strict_limit'] ) ? $args['strict_limit'] : true,
147
- ) ) );
148
-
149
- /**
150
- * Filter to create a custom HTML output
151
- *
152
- * @since 2.2.3
153
- *
154
- * @param mixed Default return value
155
- * @param array $results Array of IDs of related posts
156
- * @param array $args Array of settings
157
- * @return string Custom HTML formatted list of related posts
158
- */
159
- $custom_template = apply_filters( 'crp_custom_template', null, $results, $args );
160
- if ( ! empty( $custom_template ) ) {
161
- if ( ! empty( $args['cache'] ) ) {
162
- update_post_meta( $post->ID, $meta_key, $custom_template, '' );
163
- }
164
- return $custom_template;
165
- }
166
-
167
- $widget_class = $args['is_widget'] ? 'crp_related_widget' : 'crp_related ';
168
- $shortcode_class = $args['is_shortcode'] ? 'crp_related_shortcode ' : '';
169
-
170
- $post_classes = $widget_class . $shortcode_class;
171
-
172
- /**
173
- * Filter the classes added to the div wrapper of the Contextual Related Posts.
174
- *
175
- * @since 2.2.3
176
- *
177
- * @param string $post_classes Post classes string.
178
- */
179
- $post_classes = apply_filters( 'crp_post_class', $post_classes );
180
-
181
- $output = '<div class="' . $post_classes . '">';
182
-
183
- if ( $results ) {
184
- $loop_counter = 0;
185
-
186
- $output .= crp_heading_title( $args );
187
-
188
- $output .= crp_before_list( $args );
189
-
190
- // We need this for WPML support.
191
- $processed_results = array();
192
-
193
- foreach ( $results as $result ) {
194
-
195
- /* Support WPML */
196
- $resultid = crp_object_id_cur_lang( $result->ID );
197
-
198
- // If this is NULL or already processed ID or matches current post then skip processing this loop.
199
- if ( ! $resultid || in_array( $resultid, $processed_results ) || intval( $resultid ) === intval( $post->ID ) ) {
200
- continue;
201
- }
202
-
203
- // Push the current ID into the array to ensure we're not repeating it.
204
- array_push( $processed_results, $resultid );
205
-
206
- /**
207
- * Filter the post ID for each result. Allows a custom function to hook in and change the ID if needed.
208
- *
209
- * @since 1.9
210
- *
211
- * @param int $resultid ID of the post
212
- */
213
- $resultid = apply_filters( 'crp_post_id', $resultid );
214
-
215
- $result = get_post( $resultid ); // Let's get the Post using the ID.
216
-
217
- // Process the category exclusion if passed in the shortcode.
218
- if ( isset( $exclude_categories ) ) {
219
-
220
- $categorys = get_the_category( $result->ID ); // Fetch categories of the plugin.
221
-
222
- $p_in_c = false; // Variable to check if post exists in a particular category
223
- foreach ( $categorys as $cat ) { // Loop to check if post exists in excluded category.
224
- $p_in_c = ( in_array( $cat->cat_ID, $exclude_categories ) ) ? true : false;
225
- if ( $p_in_c ) {
226
- break; // Skip loop execution and go to the next step.
227
- }
228
- }
229
- if ( $p_in_c ) { continue; // Skip loop execution and go to the next step.
230
- }
231
- }
232
-
233
- $output .= crp_before_list_item( $args, $result );
234
-
235
- $output .= crp_list_link( $args, $result );
236
-
237
- if ( $args['show_author'] ) {
238
- $output .= crp_author( $args, $result );
239
- }
240
-
241
- if ( $args['show_date'] ) {
242
- $output .= '<span class="crp_date"> ' . mysql2date( get_option( 'date_format', 'd/m/y' ), $result->post_date ) . '</span> ';
243
- }
244
-
245
- if ( $args['show_excerpt'] ) {
246
- $output .= '<span class="crp_excerpt"> ' . crp_excerpt( $result->ID, $args['excerpt_length'] ) . '</span>';
247
- }
248
-
249
- $loop_counter++;
250
-
251
- $output .= crp_after_list_item( $args, $result );
252
-
253
- if ( $loop_counter == $args['limit'] ) {
254
- break; // End loop when related posts limit is reached.
255
- }
256
- } //end of foreach loop
257
-
258
- if ( $args['show_credit'] ) {
259
-
260
- $output .= crp_before_list_item( $args, $result );
261
-
262
- $output .= sprintf( __( 'Powered by <a href="%s" rel="nofollow">Contextual Related Posts</a>', 'contextual-related-posts' ), esc_url( 'https://webberzone.com/plugins/contextual-related-posts/' ) );
263
-
264
- $output .= crp_after_list_item( $args, $result );
265
-
266
- }
267
-
268
- $output .= crp_after_list( $args );
269
-
270
- $clearfix = '<div class="crp_clear"></div>';
271
-
272
- /**
273
- * Filter the clearfix div tag. This is included after the closing tag to clear any miscellaneous floating elements;
274
- *
275
- * @since 2.0.0
276
- *
277
- * @param string $clearfix Contains: <div style="clear:both"></div>
278
- */
279
- $output .= apply_filters( 'crp_clearfix', $clearfix );
280
-
281
- } else {
282
- $output .= ( $args['blank_output'] ) ? ' ' : '<p>' . $args['blank_output_text'] . '</p>';
283
- }
284
-
285
- // Check if the opening list tag is missing in the output, it means all of our results were eliminated cause of the category filter.
286
- if ( false === ( strpos( $output, $args['before_list_item'] ) ) ) {
287
- $output = '<div id="crp_related">';
288
- $output .= ( $args['blank_output'] ) ? ' ' : '<p>' . $args['blank_output_text'] . '</p>';
289
- }
290
-
291
- $output .= '</div>'; // Closing div of 'crp_related'.
292
-
293
- // Support caching to speed up retrieval.
294
- if ( ! empty( $args['cache'] ) ) {
295
- update_post_meta( $post->ID, $meta_key, $output, '' );
296
- }
297
-
298
- /**
299
- * Filter the output
300
- *
301
- * @since 1.9.1
302
- *
303
- * @param string $output Formatted list of related posts
304
- * @param array $args Complete set of arguments
305
- */
306
- return apply_filters( 'get_crp', $output, $args );
307
- }
308
-
309
-
310
- /**
311
- * Fetch related posts IDs.
312
- *
313
- * @since 1.9
314
- *
315
- * @param array $args Arguments array.
316
- * @return object $results
317
- */
318
- function get_crp_posts_id( $args = array() ) {
319
- global $wpdb, $post, $crp_settings;
320
-
321
- // Initialise some variables.
322
- $fields = '';
323
- $where = '';
324
- $join = '';
325
- $groupby = '';
326
- $orderby = '';
327
- $having = '';
328
- $limits = '';
329
- $match_fields = '';
330
-
331
- $defaults = array(
332
- 'postid' => false, // Get related posts for a specific post ID.
333
- 'strict_limit' => true, // If this is set to false, then it will fetch 5x posts.
334
- 'offset' => 0, // Offset the related posts returned by this number.
335
- );
336
- $defaults = array_merge( $defaults, $crp_settings );
337
-
338
- // Parse incoming $args into an array and merge it with $defaults.
339
- $args = wp_parse_args( $args, $defaults );
340
-
341
- // Fix the thumb size in case it is missing.
342
- $crp_thumb_size = crp_get_all_image_sizes( $args['thumb_size'] );
343
-
344
- if ( isset( $crp_thumb_size['width'] ) ) {
345
- $thumb_width = $crp_thumb_size['width'];
346
- $thumb_height = $crp_thumb_size['height'];
347
- }
348
-
349
- if ( empty( $thumb_width ) ) {
350
- $thumb_width = $crp_settings['thumb_width'];
351
- }
352
-
353
- if ( empty( $thumb_height ) ) {
354
- $thumb_height = $crp_settings['thumb_height'];
355
- }
356
-
357
- $source_post = ( empty( $args['postid'] ) ) ? $post : get_post( $args['postid'] );
358
-
359
- $limit = ( $args['strict_limit'] ) ? $args['limit'] : ( $args['limit'] * 3 );
360
- $offset = isset( $args['offset'] ) ? $args['offset'] : 0;
361
-
362
- // Save post types in $post_types variable.
363
- parse_str( $args['post_types'], $post_types );
364
-
365
- /**
366
- * Filter the post_type clause of the query.
367
- *
368
- * @since 2.2.0
369
- *
370
- * @param array $post_types Array of post types to filter by
371
- * @param int $source_post->ID Post ID
372
- */
373
- $post_types = apply_filters( 'crp_posts_post_types', $post_types, $source_post->ID );
374
-
375
- // Are we matching only the title or the post content as well?
376
- $match_fields = array(
377
- 'post_title',
378
- );
379
-
380
- $match_fields_content = array(
381
- $source_post->post_title,
382
- );
383
-
384
- if ( $args['match_content'] ) {
385
-
386
- $match_fields[] = 'post_content';
387
- $match_fields_content[] = crp_excerpt( $source_post->ID, $args['match_content_words'], false );
388
- }
389
-
390
- /**
391
- * Filter the fields that are to be matched.
392
- *
393
- * @since 2.2.0
394
- *
395
- * @param array $match_fields Array of fields to be matched
396
- * @param int $source_post->ID Post ID
397
- */
398
- $match_fields = apply_filters( 'crp_posts_match_fields', $match_fields, $source_post->ID );
399
-
400
- /**
401
- * Filter the content of the fields that are to be matched.
402
- *
403
- * @since 2.2.0
404
- *
405
- * @param array $match_fields_content Array of content of fields to be matched
406
- * @param int $source_post->ID Post ID
407
- */
408
- $match_fields_content = apply_filters( 'crp_posts_match_fields_content', $match_fields_content, $source_post->ID );
409
-
410
- // Convert our arrays into their corresponding strings after they have been filtered.
411
- $match_fields = implode( ',', $match_fields );
412
- $stuff = implode( ' ', $match_fields_content );
413
-
414
- // Make sure the post is not from the future.
415
- $time_difference = get_option( 'gmt_offset' );
416
- $now = gmdate( 'Y-m-d H:i:s', ( time() + ( $time_difference * 3600 ) ) );
417
-
418
- // Limit the related posts by time.
419
- $current_time = current_time( 'timestamp', 0 );
420
- $from_date = $current_time - ( $args['daily_range'] * DAY_IN_SECONDS );
421
- $from_date = gmdate( 'Y-m-d H:i:s' , $from_date );
422
-
423
- // Create the SQL query to fetch the related posts from the database.
424
- if ( is_int( $source_post->ID ) ) {
425
-
426
- // Fields to return.
427
- $fields = " $wpdb->posts.ID ";
428
-
429
- // Create the base MATCH clause.
430
- $match = $wpdb->prepare( ' AND MATCH (' . $match_fields . ") AGAINST ('%s') ", $stuff );
431
-
432
- /**
433
- * Filter the MATCH clause of the query.
434
- *
435
- * @since 2.1.0
436
- *
437
- * @param string $match The MATCH section of the WHERE clause of the query
438
- * @param string $stuff String to match fulltext with
439
- * @param int $source_post->ID Post ID
440
- */
441
- $match = apply_filters( 'crp_posts_match', $match, $stuff, $source_post->ID );
442
-
443
- // Create the maximum date limit. Show posts before today.
444
- $now_clause = $wpdb->prepare( " AND $wpdb->posts.post_date < '%s' ", $now );
445
-
446
- /**
447
- * Filter the Maximum date clause of the query.
448
- *
449
- * @since 2.1.0
450
- *
451
- * @param string $now_clause The Maximum date of the WHERE clause of the query.
452
- * @param int $source_post->ID Post ID
453
- */
454
- $now_clause = apply_filters( 'crp_posts_now_date', $now_clause, $source_post->ID );
455
-
456
- // Create the minimum date limit. Show posts after the date specified.
457
- $from_clause = ( 0 == $args['daily_range'] ) ? '' : $wpdb->prepare( " AND $wpdb->posts.post_date >= '%s' ", $from_date );
458
-
459
- /**
460
- * Filter the Maximum date clause of the query.
461
- *
462
- * @since 2.1.0
463
- *
464
- * @param string $from_clause The Minimum date of the WHERE clause of the query.
465
- * @param int $source_post->ID Post ID
466
- */
467
- $from_clause = apply_filters( 'crp_posts_from_date', $from_clause, $source_post->ID );
468
-
469
- // Create the base WHERE clause.
470
- $where = $match;
471
- $where .= $now_clause;
472
- $where .= $from_clause;
473
- $where .= " AND $wpdb->posts.post_status = 'publish' "; // Only show published posts
474
- $where .= $wpdb->prepare( " AND {$wpdb->posts}.ID != %d ", $source_post->ID ); // Show posts after the date specified.
475
-
476
- // Convert exclude post IDs string to array so it can be filtered
477
- $exclude_post_ids = explode( ',', $args['exclude_post_ids'] );
478
-
479
- /**
480
- * Filter exclude post IDs array.
481
- *
482
- * @since 2.3.0
483
- *
484
- * @param array $exclude_post_ids Array of post IDs.
485
- */
486
- $exclude_post_ids = apply_filters( 'crp_exclude_post_ids', $exclude_post_ids );
487
-
488
- // Convert it back to string
489
- $exclude_post_ids = implode( ',', array_filter( $exclude_post_ids ) );
490
-
491
- if ( '' != $exclude_post_ids ) {
492
- $where .= " AND $wpdb->posts.ID NOT IN ({$exclude_post_ids}) ";
493
- }
494
-
495
- $where .= " AND $wpdb->posts.post_type IN ('" . join( "', '", $post_types ) . "') "; // Array of post types.
496
-
497
- // Create the base LIMITS clause.
498
- $limits .= $wpdb->prepare( ' LIMIT %d, %d ', $offset, $limit );
499
-
500
- /**
501
- * Filter the SELECT clause of the query.
502
- *
503
- * @since 2.0.0
504
- *
505
- * @param string $fields The SELECT clause of the query.
506
- * @param int $source_post->ID Post ID
507
- */
508
- $fields = apply_filters( 'crp_posts_fields', $fields, $source_post->ID );
509
-
510
- /**
511
- * Filter the JOIN clause of the query.
512
- *
513
- * @since 2.0.0
514
- *
515
- * @param string $join The JOIN clause of the query.
516
- * @param int $source_post->ID Post ID
517
- */
518
- $join = apply_filters( 'crp_posts_join', $join, $source_post->ID );
519
-
520
- /**
521
- * Filter the WHERE clause of the query.
522
- *
523
- * @since 2.0.0
524
- *
525
- * @param string $where The WHERE clause of the query.
526
- * @param int $source_post->ID Post ID
527
- */
528
- $where = apply_filters( 'crp_posts_where', $where, $source_post->ID );
529
-
530
- /**
531
- * Filter the GROUP BY clause of the query.
532
- *
533
- * @since 2.0.0
534
- *
535
- * @param string $groupby The GROUP BY clause of the query.
536
- * @param int $source_post->ID Post ID
537
- */
538
- $groupby = apply_filters( 'crp_posts_groupby', $groupby, $source_post->ID );
539
-
540
- /**
541
- * Filter the HAVING clause of the query.
542
- *
543
- * @since 2.2.0
544
- *
545
- * @param string $having The HAVING clause of the query.
546
- * @param int $source_post->ID Post ID
547
- */
548
- $having = apply_filters( 'crp_posts_having', $having, $source_post->ID );
549
-
550
- /**
551
- * Filter the ORDER BY clause of the query.
552
- *
553
- * @since 2.0.0
554
- *
555
- * @param string $orderby The ORDER BY clause of the query.
556
- * @param int $source_post->ID Post ID
557
- */
558
- $orderby = apply_filters( 'crp_posts_orderby', $orderby, $source_post->ID );
559
-
560
- /**
561
- * Filter the LIMIT clause of the query.
562
- *
563
- * @since 2.0.0
564
- *
565
- * @param string $limits The LIMIT clause of the query.
566
- * @param int $source_post->ID Post ID
567
- */
568
- $limits = apply_filters( 'crp_posts_limits', $limits, $source_post->ID );
569
-
570
- if ( ! empty( $groupby ) ) {
571
- $groupby = 'GROUP BY ' . $groupby;
572
- }
573
-
574
- if ( ! empty( $having ) ) {
575
- $having = 'HAVING ' . $having;
576
- }
577
-
578
- if ( ! empty( $orderby ) ) {
579
- $orderby = 'ORDER BY ' . $orderby;
580
- }
581
-
582
- $sql = "SELECT DISTINCT $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $having $orderby $limits";
583
- $results = $wpdb->get_results( $sql );
584
- } else {
585
- $results = false;
586
- }
587
-
588
- /**
589
- * Filter object containing the post IDs.
590
- *
591
- * @since 1.9
592
- *
593
- * @param object $results Object containing the related post IDs
594
- */
595
- return apply_filters( 'get_crp_posts_id', $results );
596
- }
597
-
598
-
599
- /**
600
- * Content function with user defined filter.
601
- *
602
- * @since 1.9
603
- */
604
- function crp_content_prepare_filter() {
605
- global $crp_settings;
606
-
607
- $priority = isset( $crp_settings['content_filter_priority'] ) ? $crp_settings['content_filter_priority'] : 10;
608
-
609
- add_filter( 'the_content', 'crp_content_filter', $priority );
610
- }
611
- add_action( 'template_redirect', 'crp_content_prepare_filter' );
612
-
613
-
614
- /**
615
- * Filter for 'the_content' to add the related posts.
616
- *
617
- * @since 1.0.1
618
- *
619
- * @param string $content Post content.
620
- * @return string After the filter has been processed
621
- */
622
- function crp_content_filter( $content ) {
623
-
624
- global $post, $crp_settings;
625
-
626
- // Return if it's not in the loop or in the main query.
627
- if ( ! in_the_loop() && ! is_main_query() ) {
628
- return $content;
629
- }
630
-
631
- // If this post ID is in the DO NOT DISPLAY list.
632
- $exclude_on_post_ids = explode( ',', $crp_settings['exclude_on_post_ids'] );
633
- if ( in_array( $post->ID, $exclude_on_post_ids ) ) {
634
- return $content; // Exit without adding related posts.
635
- }
636
- // If this post type is in the DO NOT DISPLAY list
637
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
638
- if ( in_array( $post->post_type, $exclude_on_post_types ) ) {
639
- return $content; // Exit without adding related posts.
640
- }
641
- // If the DO NOT DISPLAY meta field is set.
642
- $crp_post_meta = get_post_meta( $post->ID, 'crp_post_meta', true );
643
-
644
- if ( isset( $crp_post_meta['crp_disable_here'] ) ) {
645
- $crp_disable_here = $crp_post_meta['crp_disable_here'];
646
- } else {
647
- $crp_disable_here = 0;
648
- }
649
-
650
- if ( $crp_disable_here ) {
651
- return $content;
652
- }
653
-
654
- // Else add the content.
655
- if ( ( ( is_single() ) && ( $crp_settings['add_to_content'] ) ) ||
656
- ( ( is_page() ) && ( $crp_settings['add_to_page'] ) ) ||
657
- ( ( is_home() ) && ( $crp_settings['add_to_home'] ) ) ||
658
- ( ( is_category() ) && ( $crp_settings['add_to_category_archives'] ) ) ||
659
- ( ( is_tag() ) && ( $crp_settings['add_to_tag_archives'] ) ) ||
660
- ( ( ( is_tax() ) || ( is_author() ) || ( is_date() ) ) && ( $crp_settings['add_to_archives'] ) ) ) {
661
-
662
- $crp_code = get_crp( 'is_widget=0' );
663
-
664
- return crp_generate_content( $content, $crp_code );
665
-
666
- } else {
667
- return $content;
668
- }
669
- }
670
-
671
-
672
- /**
673
- * Helper for inserting crp code into or alongside content
674
- *
675
- * @since 2.3.0
676
- *
677
- * @param string $content Post content.
678
- * @param string $crp_code CRP generated code.
679
- * @return string After the filter has been processed
680
- */
681
- function crp_generate_content( $content, $crp_code ) {
682
- global $crp_settings;
683
-
684
- if ( -1 === (int) $crp_settings['insert_after_paragraph'] || ! is_numeric( $crp_settings['insert_after_paragraph'] ) ) {
685
- return $content . $crp_code;
686
- } elseif ( 0 === (int) $crp_settings['insert_after_paragraph'] ) {
687
- return $crp_code . $content;
688
- } else {
689
- return crp_insert_after_paragraph( $content, $crp_code, $crp_settings['insert_after_paragraph'] );
690
- }
691
-
692
- }
693
-
694
- /**
695
- * Helper for inserting code after a closing paragraph tag
696
- *
697
- * @since 2.3.0
698
- *
699
- * @param string $content Post content.
700
- * @param string $crp_code CRP generated code.
701
- * @param string $paragraph_id Paragraph number to insert after.
702
- * @return string After the filter has been processed
703
- */
704
- function crp_insert_after_paragraph( $content, $crp_code, $paragraph_id ) {
705
- $closing_p = '</p>';
706
- $paragraphs = explode( $closing_p, $content );
707
-
708
- if ( count( $paragraphs ) >= $paragraph_id ) {
709
- foreach ( $paragraphs as $index => $paragraph ) {
710
-
711
- if ( trim( $paragraph ) ) {
712
- $paragraphs[ $index ] .= $closing_p;
713
- }
714
-
715
- if ( (int) $paragraph_id === $index + 1 ) {
716
- $paragraphs[ $index ] .= $crp_code;
717
- }
718
- }
719
-
720
- return implode( '', $paragraphs );
721
- }
722
-
723
- return $content . $crp_code;
724
- }
725
-
726
- /**
727
- * Filter to add related posts to feeds.
728
- *
729
- * @since 1.8.4
730
- *
731
- * @param string $content Post content.
732
- * @return string Formatted content
733
- */
734
- function crp_rss_filter( $content ) {
735
- global $crp_settings;
736
-
737
- $limit_feed = $crp_settings['limit_feed'];
738
- $show_excerpt_feed = $crp_settings['show_excerpt_feed'];
739
- $post_thumb_op_feed = $crp_settings['post_thumb_op_feed'];
740
-
741
- if ( $crp_settings['add_to_feed'] ) {
742
- $output = $content;
743
- $output .= get_crp( 'is_widget=0&limit=' . $limit_feed . '&show_excerpt=' . $show_excerpt_feed . '&post_thumb_op=' . $post_thumb_op_feed );
744
- return $output;
745
- } else {
746
- return $content;
747
- }
748
- }
749
- add_filter( 'the_excerpt_rss', 'crp_rss_filter' );
750
- add_filter( 'the_content_feed', 'crp_rss_filter' );
751
-
752
-
753
- /**
754
- * Echos the related posts. Used for manual install
755
- *
756
- * @since 1.0.1
757
- *
758
- * @param string $args Array of arguments to control the output.
759
- */
760
- function echo_crp( $args = array() ) {
761
-
762
- $defaults = array(
763
- 'is_manual' => true,
764
- );
765
-
766
- // Parse incomming $args into an array and merge it with $defaults.
767
- $args = wp_parse_args( $args, $defaults );
768
-
769
- echo get_crp( $args ); // WPCS: XSS ok.
770
- }
771
-
772
-
773
- /**
774
- * Enqueue styles.
775
- *
776
- * @since 1.9
777
- */
778
- function crp_heading_styles() {
779
- global $crp_settings;
780
-
781
- if ( 'rounded_thumbs' == $crp_settings['crp_styles'] ) {
782
- wp_register_style( 'crp-style-rounded-thumbs', plugins_url( 'css/default-style.css', CRP_PLUGIN_FILE ) );
783
- wp_enqueue_style( 'crp-style-rounded-thumbs' );
784
-
785
- $custom_css = "
786
- .crp_related a {
787
- width: {$crp_settings['thumb_width']}px;
788
- height: {$crp_settings['thumb_height']}px;
789
- text-decoration: none;
790
- }
791
- .crp_related img {
792
- max-width: {$crp_settings['thumb_width']}px;
793
- margin: auto;
794
- }
795
- .crp_related .crp_title {
796
- width: " . ( $crp_settings['thumb_width'] ) . 'px;
797
- }
798
- ';
799
-
800
- wp_add_inline_style( 'crp-style-rounded-thumbs', $custom_css );
801
-
802
- }
803
- }
804
- add_action( 'wp_enqueue_scripts', 'crp_heading_styles' );
805
-
806
-
807
  /**
808
  * Default options.
809
  *
@@ -819,90 +103,85 @@ function crp_default_options() {
819
 
820
  $thumb_default = plugins_url( 'default.png' , __FILE__ );
821
 
822
- // Set default post types to post and page.
823
- $post_types = array(
824
- 'post' => 'post',
825
- 'page' => 'page',
826
- );
827
- $post_types = http_build_query( $post_types, '', '&' );
828
-
829
  $crp_settings = array(
830
  // General options.
831
- 'cache' => false, // Cache output for faster page load.
832
 
833
- 'add_to_content' => true, // Add related posts to content (only on single posts).
834
- 'add_to_page' => true, // Add related posts to content (only on single pages).
835
- 'add_to_feed' => false, // Add related posts to feed (full).
836
- 'add_to_home' => false, // Add related posts to home page.
837
  'add_to_category_archives' => false, // Add related posts to category archives.
838
- 'add_to_tag_archives' => false, // Add related posts to tag archives.
839
- 'add_to_archives' => false, // Add related posts to other archives.
840
 
841
- 'content_filter_priority' => 10, // Content priority.
842
- 'insert_after_paragraph' => -1, // Insert after paragraph number.
843
- 'show_metabox' => true, // Show metabox to admins.
844
- 'show_metabox_admins' => false, // Limit to admins as well.
845
 
846
- 'show_credit' => false, // Link to this plugin's page?
847
 
848
  // List tuning options.
849
- 'limit' => '6', // How many posts to display?
850
- 'daily_range' => '1095', // How old posts should be displayed?
 
851
 
852
- 'match_content' => true, // Match against post content as well as title.
853
- 'match_content_words' => '0', // How many characters of content should be matched? 0 for all chars.
854
 
855
- 'post_types' => $post_types, // WordPress custom post types.
 
856
 
857
- 'exclude_categories' => '', // Exclude these categories.
858
- 'exclude_cat_slugs' => '', // Exclude these categories (slugs).
859
- 'exclude_post_ids' => '', // Comma separated list of page / post IDs that are to be excluded in the results.
860
 
861
  // Output options.
862
- 'title' => $title, // Add before the content.
863
- 'blank_output' => true, // Blank output?
864
- 'blank_output_text' => $blank_output_text, // Blank output text.
865
 
866
- 'show_excerpt' => false, // Show post excerpt in list item.
867
- 'show_date' => false, // Show date in list item.
868
- 'show_author' => false, // Show author in list item.
869
- 'excerpt_length' => '10', // Length of characters.
870
- 'title_length' => '60', // Limit length of post title.
871
 
872
- 'link_new_window' => false, // Open link in new window - Includes target="_blank" to links.
873
- 'link_nofollow' => false, // Includes rel="nofollow" to links.
874
 
875
- 'before_list' => '<ul>', // Before the entire list.
876
- 'after_list' => '</ul>', // After the entire list.
877
- 'before_list_item' => '<li>', // Before each list item.
878
- 'after_list_item' => '</li>', // After each list item.
879
 
880
- 'exclude_on_post_ids' => '', // Comma separate list of page/post IDs to not display related posts on.
881
- 'exclude_on_post_types' => '', // WordPress custom post types.
882
 
883
  // Thumbnail options.
884
- 'post_thumb_op' => 'inline', // Default option to display text and no thumbnails in posts.
885
- 'thumb_size' => 'thumbnail', // Default thumbnail size
886
- 'thumb_height' => '150', // Height of thumbnails.
887
- 'thumb_width' => '150', // Width of thumbnails.
888
- 'thumb_crop' => true, // Crop mode. default is hard crop.
889
- 'thumb_html' => 'html', // Use HTML or CSS for width and height of the thumbnail?
890
- 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
891
- 'scan_images' => true, // Scan post for images.
892
- 'thumb_default' => $thumb_default, // Default thumbnail image.
893
- 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
894
 
895
  // Feed options.
896
- 'limit_feed' => '5', // How many posts to display in feeds.
897
- 'post_thumb_op_feed' => 'text_only', // Default option to display text and no thumbnails in Feeds.
898
- 'thumb_height_feed' => '50', // Height of thumbnails in feed.
899
- 'thumb_width_feed' => '50', // Width of thumbnails in feed.
900
- 'show_excerpt_feed' => false, // Show description in list item in feed.
901
 
902
  // Custom styles.
903
- 'custom_CSS' => '', // Custom CSS to style the output.
904
- 'include_default_style' => true, // Include default style - Will be DEPRECATED in the next version.
905
- 'crp_styles' => 'rounded_thumbs',// Defaault style is rounded thubnails.
906
  );
907
 
908
  /**
@@ -937,7 +216,7 @@ function crp_read_options() {
937
  }
938
  $crp_settings_changed = true;
939
  }
940
- if ( true == $crp_settings_changed ) {
941
  update_option( 'ald_crp_settings', $crp_settings );
942
  }
943
 
@@ -952,115 +231,25 @@ function crp_read_options() {
952
  }
953
 
954
 
955
- /**
956
- * Filter for wp_head to include the custom CSS.
957
- *
958
- * @since 1.8.4
959
- */
960
- function crp_header() {
961
- global $crp_settings;
962
-
963
- $custom_css = stripslashes( $crp_settings['custom_CSS'] );
964
-
965
- // Add CSS to header.
966
- if ( '' != $custom_css ) {
967
- if ( ( is_single() ) ) {
968
- echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
969
- } elseif ( (is_page()) ) {
970
- echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
971
- } elseif ( ( is_home() ) && ( $crp_settings['add_to_home'] ) ) {
972
- echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
973
- } elseif ( ( is_category() ) && ( $crp_settings['add_to_category_archives'] ) ) {
974
- echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
975
- } elseif ( ( is_tag() ) && ( $crp_settings['add_to_tag_archives'] ) ) {
976
- echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
977
- } elseif ( ( ( is_tax() ) || ( is_author() ) || ( is_date() ) ) && ( $crp_settings['add_to_archives'] ) ) {
978
- echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
979
- } elseif ( is_active_widget( false, false, 'CRP_Widget', true ) ) {
980
- echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
981
- }
982
- }
983
- }
984
- add_action( 'wp_head', 'crp_header' );
985
-
986
-
987
- /*
988
- ----------------------------------------------------------------------------*
989
- * Activate the plugin
990
- *----------------------------------------------------------------------------
991
- */
992
-
993
- /**
994
- * The code that runs during plugin activation.
995
- * This action is documented in includes/class-plugin-name-activator.php
996
- *
997
- * @since 2.2.0
998
- *
999
- * @param bool $network_wide Network wide flag.
1000
- */
1001
- function activate_crp( $network_wide ) {
1002
- require_once( CRP_PLUGIN_DIR . 'includes/plugin-activator.php' );
1003
- crp_activate( $network_wide );
1004
- }
1005
- register_activation_hook( CRP_PLUGIN_FILE, 'activate_crp' );
1006
-
1007
-
1008
- /**
1009
- * Fired when a new site is activated with a WPMU environment.
1010
- *
1011
- * @since 2.0.0
1012
- *
1013
- * @param int $blog_id ID of the new blog.
1014
- */
1015
- function crp_activate_new_site( $blog_id ) {
1016
-
1017
- if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
1018
- return;
1019
- }
1020
-
1021
- require_once( CRP_PLUGIN_DIR . 'includes/plugin-activator.php' );
1022
-
1023
- switch_to_blog( $blog_id );
1024
- crp_single_activate();
1025
- restore_current_blog();
1026
-
1027
- }
1028
- add_action( 'wpmu_new_blog', 'crp_activate_new_site' );
1029
-
1030
-
1031
- /*
1032
- ----------------------------------------------------------------------------*
1033
- * WordPress widget
1034
- *----------------------------------------------------------------------------
1035
- */
1036
-
1037
- /**
1038
- * Initialise the widget.
1039
- *
1040
- * @since 1.9.1
1041
- */
1042
- function register_crp_widget() {
1043
- require_once( CRP_PLUGIN_DIR . 'includes/modules/class-crp-widget.php' );
1044
-
1045
- register_widget( 'CRP_Widget' );
1046
- }
1047
- add_action( 'widgets_init', 'register_crp_widget' );
1048
-
1049
-
1050
  /*
1051
  ----------------------------------------------------------------------------*
1052
  * CRP modules & includes
1053
  *----------------------------------------------------------------------------
1054
  */
1055
 
 
1056
  require_once( CRP_PLUGIN_DIR . 'includes/i10n.php' );
1057
  require_once( CRP_PLUGIN_DIR . 'includes/output-generator.php' );
1058
  require_once( CRP_PLUGIN_DIR . 'includes/media.php' );
1059
  require_once( CRP_PLUGIN_DIR . 'includes/tools.php' );
 
 
 
1060
  require_once( CRP_PLUGIN_DIR . 'includes/modules/manual-posts.php' );
1061
  require_once( CRP_PLUGIN_DIR . 'includes/modules/shortcode.php' );
1062
  require_once( CRP_PLUGIN_DIR . 'includes/modules/taxonomies.php' );
1063
  require_once( CRP_PLUGIN_DIR . 'includes/modules/exclusions.php' );
 
1064
 
1065
 
1066
  /*
@@ -1076,7 +265,7 @@ if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
1076
  require_once( CRP_PLUGIN_DIR . 'admin/metabox.php' );
1077
  require_once( CRP_PLUGIN_DIR . 'admin/cache.php' );
1078
 
1079
- } // End admin.inc
1080
 
1081
 
1082
  /*
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.0
19
  * Author: WebberZone
20
  * Author URI: https://webberzone.com
21
  * License: GPL-2.0+
88
  $crp_settings = crp_read_options();
89
 
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  /**
92
  * Default options.
93
  *
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
  /**
216
  }
217
  $crp_settings_changed = true;
218
  }
219
+ if ( true === $crp_settings_changed ) {
220
  update_option( 'ald_crp_settings', $crp_settings );
221
  }
222
 
231
  }
232
 
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  /*
235
  ----------------------------------------------------------------------------*
236
  * CRP modules & includes
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
  /*
265
  require_once( CRP_PLUGIN_DIR . 'admin/metabox.php' );
266
  require_once( CRP_PLUGIN_DIR . 'admin/cache.php' );
267
 
268
+ } // End if().
269
 
270
 
271
  /*
includes/content.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
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.
13
+ if ( ! defined( 'WPINC' ) ) {
14
+ die;
15
+ }
16
+
17
+ /**
18
+ * Content function with user defined filter.
19
+ *
20
+ * @since 1.9
21
+ */
22
+ function crp_content_prepare_filter() {
23
+ global $crp_settings;
24
+
25
+ $priority = isset( $crp_settings['content_filter_priority'] ) ? $crp_settings['content_filter_priority'] : 10;
26
+
27
+ add_filter( 'the_content', 'crp_content_filter', $priority );
28
+ }
29
+ add_action( 'template_redirect', 'crp_content_prepare_filter' );
30
+
31
+
32
+ /**
33
+ * Filter for 'the_content' to add the related posts.
34
+ *
35
+ * @since 1.0.1
36
+ *
37
+ * @param string $content Post content.
38
+ * @return string After the filter has been processed
39
+ */
40
+ function crp_content_filter( $content ) {
41
+
42
+ global $post, $crp_settings;
43
+
44
+ // Return if it's not in the loop or in the main query.
45
+ if ( ! in_the_loop() && ! is_main_query() ) {
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.
56
+ // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
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 );
68
+
69
+ if ( isset( $crp_post_meta['crp_disable_here'] ) ) {
70
+ $crp_disable_here = $crp_post_meta['crp_disable_here'];
71
+ } else {
72
+ $crp_disable_here = 0;
73
+ }
74
+
75
+ if ( $crp_disable_here ) {
76
+ return $content;
77
+ }
78
+
79
+ // Else add the content.
80
+ if ( ( ( is_single() ) && ( $crp_settings['add_to_content'] ) ) ||
81
+ ( ( is_page() ) && ( $crp_settings['add_to_page'] ) ) ||
82
+ ( ( is_home() ) && ( $crp_settings['add_to_home'] ) ) ||
83
+ ( ( is_category() ) && ( $crp_settings['add_to_category_archives'] ) ) ||
84
+ ( ( is_tag() ) && ( $crp_settings['add_to_tag_archives'] ) ) ||
85
+ ( ( ( is_tax() ) || ( is_author() ) || ( is_date() ) ) && ( $crp_settings['add_to_archives'] ) ) ) {
86
+
87
+ $crp_code = get_crp( 'is_widget=0' );
88
+
89
+ return crp_generate_content( $content, $crp_code );
90
+
91
+ } else {
92
+ return $content;
93
+ }
94
+ }
95
+
96
+
97
+ /**
98
+ * Helper for inserting crp code into or alongside content
99
+ *
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 ) {
107
+ global $crp_settings;
108
+
109
+ if ( -1 === (int) $crp_settings['insert_after_paragraph'] || ! is_numeric( $crp_settings['insert_after_paragraph'] ) ) {
110
+ return $content . $crp_code;
111
+ } elseif ( 0 === (int) $crp_settings['insert_after_paragraph'] ) {
112
+ return $crp_code . $content;
113
+ } else {
114
+ return crp_insert_after_paragraph( $content, $crp_code, $crp_settings['insert_after_paragraph'] );
115
+ }
116
+
117
+ }
118
+
119
+ /**
120
+ * Helper for inserting code after a closing paragraph tag
121
+ *
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 ) {
134
+ foreach ( $paragraphs as $index => $paragraph ) {
135
+
136
+ if ( trim( $paragraph ) ) {
137
+ $paragraphs[ $index ] .= $closing_p;
138
+ }
139
+
140
+ if ( (int) $paragraph_id === $index + 1 ) {
141
+ $paragraphs[ $index ] .= $crp_code;
142
+ }
143
+ }
144
+
145
+ return implode( '', $paragraphs );
146
+ }
147
+
148
+ return $content . $crp_code;
149
+ }
150
+
151
+ /**
152
+ * Filter to add related posts to feeds.
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 {
171
+ return $content;
172
+ }
173
+ }
174
+ add_filter( 'the_excerpt_rss', 'crp_rss_filter' );
175
+ add_filter( 'the_content_feed', 'crp_rss_filter' );
176
+
177
+
178
+ /**
179
+ * Echos the related posts. Used for manual install
180
+ *
181
+ * @since 1.0.1
182
+ *
183
+ * @param string $args Array of arguments to control the output.
184
+ */
185
+ function echo_crp( $args = array() ) {
186
+
187
+ $defaults = array(
188
+ 'is_manual' => true,
189
+ );
190
+
191
+ // Parse incomming $args into an array and merge it with $defaults.
192
+ $args = wp_parse_args( $args, $defaults );
193
+
194
+ echo get_crp( $args ); // WPCS: XSS ok.
195
+ }
196
+
197
+
includes/deprecated.php CHANGED
@@ -131,3 +131,30 @@ function echo_ald_crp( $args = array() ) {
131
  echo_crp( $args );
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  echo_crp( $args );
132
  }
133
 
134
+ /**
135
+ * Function to limit content by characters.
136
+ *
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
+
146
+ _deprecated_function( __FUNCTION__, '2.4.0', 'crp_trim_char()' );
147
+
148
+ $content = crp_trim_char( $content, $no_of_char );
149
+
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
+
includes/header.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
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.
13
+ if ( ! defined( 'WPINC' ) ) {
14
+ die;
15
+ }
16
+
17
+ /**
18
+ * Filter for wp_head to include the custom CSS.
19
+ *
20
+ * @since 1.8.4
21
+ */
22
+ function crp_header() {
23
+ global $crp_settings;
24
+
25
+ $custom_css = stripslashes( $crp_settings['custom_CSS'] );
26
+
27
+ // Add CSS to 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.
35
+ } elseif ( ( is_category() ) && ( $crp_settings['add_to_category_archives'] ) ) {
36
+ echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
37
+ } elseif ( ( is_tag() ) && ( $crp_settings['add_to_tag_archives'] ) ) {
38
+ echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
39
+ } elseif ( ( ( is_tax() ) || ( is_author() ) || ( is_date() ) ) && ( $crp_settings['add_to_archives'] ) ) {
40
+ echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
41
+ } elseif ( is_active_widget( false, false, 'CRP_Widget', true ) ) {
42
+ echo '<style type="text/css">' . $custom_css . '</style>'; // WPCS: XSS ok.
43
+ }
44
+ }
45
+ }
46
+ add_action( 'wp_head', 'crp_header' );
47
+
48
+
49
+ /**
50
+ * Enqueue styles.
51
+ *
52
+ * @since 1.9
53
+ */
54
+ function crp_heading_styles() {
55
+ global $crp_settings;
56
+
57
+ if ( 'rounded_thumbs' === $crp_settings['crp_styles'] ) {
58
+ wp_register_style( 'crp-style-rounded-thumbs', plugins_url( 'css/default-style.css', CRP_PLUGIN_FILE ) );
59
+ wp_enqueue_style( 'crp-style-rounded-thumbs' );
60
+
61
+ $custom_css = "
62
+ .crp_related a {
63
+ width: {$crp_settings['thumb_width']}px;
64
+ height: {$crp_settings['thumb_height']}px;
65
+ text-decoration: none;
66
+ }
67
+ .crp_related img {
68
+ max-width: {$crp_settings['thumb_width']}px;
69
+ margin: auto;
70
+ }
71
+ .crp_related .crp_title {
72
+ width: " . ( $crp_settings['thumb_width'] ) . 'px;
73
+ }
74
+ ';
75
+
76
+ wp_add_inline_style( 'crp-style-rounded-thumbs', $custom_css );
77
+
78
+ }
79
+ }
80
+ add_action( 'wp_enqueue_scripts', 'crp_heading_styles' );
81
+
includes/main-query.php ADDED
@@ -0,0 +1,547 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
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.
13
+ if ( ! defined( 'WPINC' ) ) {
14
+ die;
15
+ }
16
+
17
+ /**
18
+ * Main function to generate the related posts output
19
+ *
20
+ * @since 1.0.1
21
+ *
22
+ * @param array $args Parameters in a query string format.
23
+ * @return string HTML formatted list of related posts
24
+ */
25
+ function get_crp( $args = array() ) {
26
+ global $post, $crp_settings;
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
+
43
+ // Parse incomming $args into an array and merge it with $defaults.
44
+ $args = wp_parse_args( $args, $defaults );
45
+
46
+ // WPML support.
47
+ if ( function_exists( 'wpml_object_id_filter' ) || function_exists( 'icl_object_id' ) ) {
48
+ $args['strict_limit'] = false;
49
+ }
50
+
51
+ // Support caching to speed up retrieval.
52
+ if ( ! empty( $args['cache'] ) ) {
53
+ $meta_key = 'crp_related_posts';
54
+ if ( $args['is_widget'] ) {
55
+ $meta_key .= '_widget';
56
+ }
57
+ if ( $args['is_manual'] ) {
58
+ $meta_key .= '_manual';
59
+ }
60
+ if ( is_feed() ) {
61
+ $meta_key .= '_feed';
62
+ }
63
+ $output = get_post_meta( $post->ID, $meta_key, true );
64
+ if ( $output ) {
65
+ return $output;
66
+ }
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 ) ) {
87
+ if ( ! empty( $args['cache'] ) ) {
88
+ update_post_meta( $post->ID, $meta_key, $custom_template, '' );
89
+ }
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;
97
+
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
+
107
+ $output = '<div class="' . $post_classes . '">';
108
+
109
+ if ( $results ) {
110
+ $loop_counter = 0;
111
+
112
+ $output .= crp_heading_title( $args );
113
+
114
+ $output .= crp_before_list( $args );
115
+
116
+ // We need this for WPML support.
117
+ $processed_results = array();
118
+
119
+ foreach ( $results as $result ) {
120
+
121
+ /* Support WPML */
122
+ $resultid = crp_object_id_cur_lang( $result->ID );
123
+
124
+ // If this is NULL or already processed ID or matches current post then skip processing this loop.
125
+ if ( ! $resultid || in_array( $resultid, $processed_results ) || intval( $resultid ) === intval( $post->ID ) ) {
126
+ continue;
127
+ }
128
+
129
+ // Push the current ID into the array to ensure we're not repeating it.
130
+ array_push( $processed_results, $resultid );
131
+
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
+
159
+ $output .= crp_before_list_item( $args, $result );
160
+
161
+ $output .= crp_list_link( $args, $result );
162
+
163
+ if ( $args['show_author'] ) {
164
+ $output .= crp_author( $args, $result );
165
+ }
166
+
167
+ if ( $args['show_date'] ) {
168
+ $output .= '<span class="crp_date"> ' . mysql2date( get_option( 'date_format', 'd/m/y' ), $result->post_date ) . '</span> ';
169
+ }
170
+
171
+ if ( $args['show_excerpt'] ) {
172
+ $output .= '<span class="crp_excerpt"> ' . crp_excerpt( $result->ID, $args['excerpt_length'] ) . '</span>';
173
+ }
174
+
175
+ $loop_counter++;
176
+
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
+
186
+ $output .= crp_before_list_item( $args, $result );
187
+
188
+ /* translators: Link to plugin home page */
189
+ $output .= sprintf( __( 'Powered by <a href="%s" rel="nofollow">Contextual Related Posts</a>', 'contextual-related-posts' ), esc_url( 'https://webberzone.com/plugins/contextual-related-posts/' ) );
190
+
191
+ $output .= crp_after_list_item( $args, $result );
192
+
193
+ }
194
+
195
+ $output .= crp_after_list( $args );
196
+
197
+ $clearfix = '<div class="crp_clear"></div>';
198
+
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
+
218
+ $output .= '</div>'; // Closing div of 'crp_related'.
219
+
220
+ // Support caching to speed up retrieval.
221
+ if ( ! empty( $args['cache'] ) ) {
222
+ update_post_meta( $post->ID, $meta_key, $output, '' );
223
+ }
224
+
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
+ }
235
+
236
+
237
+ /**
238
+ * Fetch related posts IDs.
239
+ *
240
+ * @since 1.9
241
+ *
242
+ * @param array $args Arguments array.
243
+ * @return object $results
244
+ */
245
+ 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
+
265
+ // Parse incoming $args into an array and merge it with $defaults.
266
+ $args = wp_parse_args( $args, $defaults );
267
+
268
+ // Fix the thumb size in case it is missing.
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
+
276
+ if ( empty( $thumb_width ) ) {
277
+ $thumb_width = $crp_settings['thumb_width'];
278
+ }
279
+
280
+ if ( empty( $thumb_height ) ) {
281
+ $thumb_height = $crp_settings['thumb_height'];
282
+ }
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.
304
+ if ( $args['same_post_type'] ) {
305
+ $post_types = (array) $source_post->post_type;
306
+ }
307
+
308
+ /**
309
+ * Filter the post_type clause of the query.
310
+ *
311
+ * @since 2.2.0
312
+ *
313
+ * @param array $post_types Array of post types to filter by.
314
+ * @param int $source_post->ID Post ID.
315
+ * @param array $args Arguments array.
316
+ */
317
+ $post_types = apply_filters( 'crp_posts_post_types', $post_types, $source_post->ID, $args );
318
+
319
+ // Are we matching only the title or the post content as well?
320
+ $match_fields = array(
321
+ 'post_title',
322
+ );
323
+
324
+ $match_fields_content = array(
325
+ $source_post->post_title,
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 ) ) {
368
+
369
+ // Fields to return.
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'] );
421
+
422
+ /**
423
+ * Filter exclude post IDs array.
424
+ *
425
+ * @since 2.3.0
426
+ *
427
+ * @param array $exclude_post_ids Array of post IDs.
428
+ */
429
+ $exclude_post_ids = apply_filters( 'crp_exclude_post_ids', $exclude_post_ids );
430
+
431
+ // Convert it back to string.
432
+ $exclude_post_ids = implode( ',', array_filter( $exclude_post_ids ) );
433
+
434
+ if ( '' != $exclude_post_ids ) {
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 );
442
+
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
+
513
+ if ( ! empty( $groupby ) ) {
514
+ $groupby = 'GROUP BY ' . $groupby;
515
+ }
516
+
517
+ if ( ! empty( $having ) ) {
518
+ $having = 'HAVING ' . $having;
519
+ }
520
+
521
+ if ( ! empty( $orderby ) ) {
522
+ $orderby = 'ORDER BY ' . $orderby;
523
+ }
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;
531
+ shuffle( $results_array );
532
+ $results = (object) $results_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
+ }
547
+
includes/media.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  /**
@@ -17,7 +17,7 @@
17
  function crp_add_image_sizes() {
18
  global $crp_settings;
19
 
20
- if ( ! in_array( $crp_settings['thumb_size'], get_intermediate_image_sizes() ) ) {
21
  $crp_settings['thumb_size'] = 'crp_thumbnail';
22
  }
23
 
@@ -62,15 +62,15 @@ function crp_get_the_post_thumbnail( $args = array() ) {
62
 
63
  // Issue notice for deprecated arguments.
64
  if ( isset( $args['thumb_timthumb'] ) ) {
65
- _deprecated_argument( __FUNCTION__, '2.1', __( 'thumb_timthumb argument has been deprecated', 'contextual-related-posts' ) );
66
  }
67
 
68
  if ( isset( $args['thumb_timthumb_q'] ) ) {
69
- _deprecated_argument( __FUNCTION__, '2.1', __( 'thumb_timthumb_q argument has been deprecated', 'contextual-related-posts' ) );
70
  }
71
 
72
  if ( isset( $args['filter'] ) ) {
73
- _deprecated_argument( __FUNCTION__, '2.1', __( 'filter argument has been deprecated', 'contextual-related-posts' ) );
74
  }
75
 
76
  $result = get_post( $args['postid'] );
@@ -97,7 +97,7 @@ function crp_get_the_post_thumbnail( $args = array() ) {
97
 
98
  // If there is no thumbnail found, check the post thumbnail.
99
  if ( ! $postimage ) {
100
- if ( false != get_post_thumbnail_id( $result->ID ) ) {
101
  $postthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $result->ID ), $crp_settings['thumb_size'] );
102
  $postimage = $postthumb[0];
103
  }
@@ -127,7 +127,7 @@ function crp_get_the_post_thumbnail( $args = array() ) {
127
  if ( $postimage ) {
128
  $postimage_id = crp_get_attachment_id_from_url( $postimage );
129
 
130
- if ( false != wp_get_attachment_image_src( $postimage_id, $crp_settings['thumb_size'] ) ) {
131
  $postthumb = wp_get_attachment_image_src( $postimage_id, $crp_settings['thumb_size'] );
132
  $postimage = $postthumb[0];
133
  }
@@ -192,12 +192,12 @@ function crp_get_the_post_thumbnail( $args = array() ) {
192
  $postimage = apply_filters( 'crp_postimage', $postimage, $args['thumb_width'], $args['thumb_height'], $thumb_timthumb, $thumb_timthumb_q, $result );
193
 
194
  if ( is_ssl() ) {
195
- $postimage = preg_replace( '~http://~', 'https://', $postimage );
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 = '';
@@ -224,7 +224,7 @@ function crp_get_the_post_thumbnail( $args = array() ) {
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
- }
228
 
229
  /**
230
  * Filters post thumbnail created for CRP.
@@ -294,7 +294,7 @@ function crp_get_attachment_id_from_url( $attachment_url = '' ) {
294
  $attachment_id = false;
295
 
296
  // If there is no url, return.
297
- if ( '' == $attachment_url ) {
298
  return;
299
  }
300
 
@@ -341,20 +341,20 @@ function crp_get_all_image_sizes( $size = '' ) {
341
  $intermediate_image_sizes = get_intermediate_image_sizes();
342
 
343
  foreach ( $intermediate_image_sizes as $_size ) {
344
- if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) {
345
 
346
  $sizes[ $_size ]['name'] = $_size;
347
- $sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
348
- $sizes[ $_size ]['height'] = 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 ] );
353
- }
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'],
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
  /**
17
  function crp_add_image_sizes() {
18
  global $crp_settings;
19
 
20
+ if ( ! in_array( $crp_settings['thumb_size'], get_intermediate_image_sizes(), true ) ) {
21
  $crp_settings['thumb_size'] = 'crp_thumbnail';
22
  }
23
 
62
 
63
  // Issue notice for deprecated arguments.
64
  if ( isset( $args['thumb_timthumb'] ) ) {
65
+ _deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'thumb_timthumb argument has been deprecated', 'contextual-related-posts' ) );
66
  }
67
 
68
  if ( isset( $args['thumb_timthumb_q'] ) ) {
69
+ _deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'thumb_timthumb_q argument has been deprecated', 'contextual-related-posts' ) );
70
  }
71
 
72
  if ( isset( $args['filter'] ) ) {
73
+ _deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'filter argument has been deprecated', 'contextual-related-posts' ) );
74
  }
75
 
76
  $result = get_post( $args['postid'] );
97
 
98
  // If there is no thumbnail found, check the post thumbnail.
99
  if ( ! $postimage ) {
100
+ if ( false !== get_post_thumbnail_id( $result->ID ) ) {
101
  $postthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $result->ID ), $crp_settings['thumb_size'] );
102
  $postimage = $postthumb[0];
103
  }
127
  if ( $postimage ) {
128
  $postimage_id = crp_get_attachment_id_from_url( $postimage );
129
 
130
+ if ( false !== wp_get_attachment_image_src( $postimage_id, $crp_settings['thumb_size'] ) ) {
131
  $postthumb = wp_get_attachment_image_src( $postimage_id, $crp_settings['thumb_size'] );
132
  $postimage = $postthumb[0];
133
  }
192
  $postimage = apply_filters( 'crp_postimage', $postimage, $args['thumb_width'], $args['thumb_height'], $thumb_timthumb, $thumb_timthumb_q, $result );
193
 
194
  if ( is_ssl() ) {
195
+ $postimage = preg_replace( '~http://~', 'https://', $postimage );
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 = '';
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.
294
  $attachment_id = false;
295
 
296
  // If there is no url, return.
297
+ if ( '' === $attachment_url ) {
298
  return;
299
  }
300
 
341
  $intermediate_image_sizes = get_intermediate_image_sizes();
342
 
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 ] );
353
+ }
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'],
includes/modules/class-crp-widget.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -28,9 +28,12 @@ class CRP_Widget extends WP_Widget {
28
  */
29
  function __construct() {
30
  parent::__construct(
31
- 'widget_crp', // Base ID
32
- __( 'Related Posts [CRP]', 'contextual-related-posts' ), // Name
33
- array( 'description' => __( 'Display Related Posts', 'contextual-related-posts' ) ) // Args.
 
 
 
34
  );
35
  }
36
 
@@ -54,10 +57,14 @@ class CRP_Widget extends WP_Widget {
54
 
55
  // Parse the Post types.
56
  $post_types = array();
57
- if ( isset( $instance['post_types'] ) ) {
58
- $post_types = $instance['post_types'];
59
- parse_str( $post_types, $post_types ); // Save post types in $post_types variable.
 
 
 
60
  }
 
61
  $wp_post_types = get_post_types( array(
62
  'public' => true,
63
  ) );
@@ -119,7 +126,7 @@ class CRP_Widget extends WP_Widget {
119
  <?php foreach ( $wp_post_types as $wp_post_type ) { ?>
120
 
121
  <label>
122
- <input id="<?php echo esc_attr( $this->get_field_id( 'post_types' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'post_types' ) ); ?>[]" type="checkbox" value="<?php echo esc_attr( $wp_post_type ); ?>" <?php if ( in_array( $wp_post_type, $posts_types_inc ) ) { echo 'checked="checked"'; } ?> />
123
  <?php echo esc_attr( $wp_post_type ); ?>
124
  </label>
125
  <br />
@@ -167,9 +174,9 @@ class CRP_Widget extends WP_Widget {
167
  $wp_post_types = get_post_types( array(
168
  'public' => true,
169
  ) );
170
- $post_types = ( isset( $new_instance['post_types'] ) ) ? $new_instance['post_types'] : array();
171
  $post_types = array_intersect( $wp_post_types, $post_types );
172
- $instance['post_types'] = http_build_query( $post_types, '', '&' );
173
 
174
  delete_post_meta_by_key( 'crp_related_posts_widget' ); // Delete the cache.
175
 
@@ -178,9 +185,11 @@ class CRP_Widget extends WP_Widget {
178
  *
179
  * @since 2.0.0
180
  *
181
- * @param array $instance Widget options array
 
 
182
  */
183
- return apply_filters( 'crp_widget_options_update' , $instance );
184
  } //ending update
185
 
186
  /**
@@ -198,13 +207,29 @@ class CRP_Widget extends WP_Widget {
198
  if ( isset( $post ) ) {
199
  $crp_post_meta = get_post_meta( $post->ID, 'crp_post_meta', true );
200
 
201
- if ( isset( $crp_post_meta['disable_here'] ) && ( 1 == $crp_post_meta['disable_here'] ) ) {
202
  return;
203
  }
204
  }
205
 
206
- parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
207
- if ( is_object( $post ) && ( in_array( $post->post_type, $exclude_on_post_types ) ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  return 0; // Exit without adding related posts.
209
  }
210
 
@@ -246,9 +271,11 @@ class CRP_Widget extends WP_Widget {
246
  *
247
  * @since 2.0.0
248
  *
249
- * @param array $arguments Widget options array
 
 
250
  */
251
- $arguments = apply_filters( 'crp_widget_options' , $arguments );
252
 
253
  $output = $args['before_widget'];
254
  $output .= $args['before_title'] . $title . $args['after_title'];
@@ -257,8 +284,18 @@ class CRP_Widget extends WP_Widget {
257
  $output .= $args['after_widget'];
258
 
259
  echo $output; // WPCS: XSS OK.
260
- }
261
- } //ending function widget
262
  }
263
 
264
 
 
 
 
 
 
 
 
 
 
 
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
  */
29
  function __construct() {
30
  parent::__construct(
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
  );
38
  }
39
 
57
 
58
  // Parse the Post types.
59
  $post_types = array();
60
+
61
+ // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
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
  ) );
126
  <?php foreach ( $wp_post_types as $wp_post_type ) { ?>
127
 
128
  <label>
129
+ <input id="<?php echo esc_attr( $this->get_field_id( 'post_types' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'post_types' ) ); ?>[]" type="checkbox" value="<?php echo esc_attr( $wp_post_type ); ?>" <?php checked( true, in_array( $wp_post_type, $posts_types_inc, true ) ); ?> />
130
  <?php echo esc_attr( $wp_post_type ); ?>
131
  </label>
132
  <br />
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.
182
 
185
  *
186
  * @since 2.0.0
187
  *
188
+ * @param array $instance Widget options array
189
+ * @param array $new_instance Values just sent to be saved.
190
+ * @param array $old_instance Previously saved values from database.
191
  */
192
+ return apply_filters( 'crp_widget_options_update', $instance, $new_instance, $old_instance );
193
  } //ending update
194
 
195
  /**
207
  if ( isset( $post ) ) {
208
  $crp_post_meta = get_post_meta( $post->ID, 'crp_post_meta', true );
209
 
210
+ if ( isset( $crp_post_meta['disable_here'] ) && $crp_post_meta['disable_here'] ) {
211
  return;
212
  }
213
  }
214
 
215
+ // Return if disabled in settings page.
216
+ if ( ( is_single() && ! $crp_settings['add_to_content'] ) ||
217
+ ( is_page() && ! $crp_settings['add_to_page'] ) ||
218
+ ( is_home() && ! $crp_settings['add_to_home'] ) ||
219
+ ( is_category() && ! $crp_settings['add_to_category_archives'] ) ||
220
+ ( is_tag() && ! $crp_settings['add_to_tag_archives'] ) ||
221
+ ( ( is_tax() || is_author() || is_date() ) && ! $crp_settings['add_to_archives'] ) ) {
222
+ return;
223
+ }
224
+
225
+ // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
226
+ if ( ! empty( $crp_settings['exclude_on_post_types'] ) && false === strpos( $crp_settings['exclude_on_post_types'], '=' ) ) {
227
+ $exclude_on_post_types = explode( ',', $crp_settings['exclude_on_post_types'] );
228
+ } else {
229
+ parse_str( $crp_settings['exclude_on_post_types'], $exclude_on_post_types ); // Save post types in $exclude_on_post_types variable.
230
+ }
231
+
232
+ if ( is_object( $post ) && ( in_array( $post->post_type, $exclude_on_post_types, true ) ) ) {
233
  return 0; // Exit without adding related posts.
234
  }
235
 
271
  *
272
  * @since 2.0.0
273
  *
274
+ * @param array $arguments Widget options array.
275
+ * @param array $args Widget arguments.
276
+ * @param array $instance Saved values from database.
277
  */
278
+ $arguments = apply_filters( 'crp_widget_options' , $arguments, $args, $instance );
279
 
280
  $output = $args['before_widget'];
281
  $output .= $args['before_title'] . $title . $args['after_title'];
284
  $output .= $args['after_widget'];
285
 
286
  echo $output; // WPCS: XSS OK.
287
+ }// End if().
288
+ } // Ending function widget.
289
  }
290
 
291
 
292
+ /**
293
+ * Initialise the widget.
294
+ *
295
+ * @since 1.9.1
296
+ */
297
+ function register_crp_widget() {
298
+ register_widget( 'CRP_Widget' );
299
+ }
300
+ add_action( 'widgets_init', 'register_crp_widget' );
301
+
includes/modules/exclusions.php CHANGED
@@ -21,7 +21,7 @@ function crp_exclude_post_ids( $exclude_post_ids ) {
21
  $crp_post_metas = $wpdb->get_results( "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE `meta_key` = 'crp_post_meta'", ARRAY_A );
22
 
23
  foreach ( $crp_post_metas as $crp_post_meta ) {
24
- $meta_value = unserialize( $crp_post_meta['meta_value'] );
25
 
26
  if ( isset( $meta_value['exclude_this_post'] ) && $meta_value['exclude_this_post'] ) {
27
  $exclude_post_ids[] = $crp_post_meta['post_id'];
21
  $crp_post_metas = $wpdb->get_results( "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE `meta_key` = 'crp_post_meta'", ARRAY_A );
22
 
23
  foreach ( $crp_post_metas as $crp_post_meta ) {
24
+ $meta_value = maybe_unserialize( $crp_post_meta['meta_value'] );
25
 
26
  if ( isset( $meta_value['exclude_this_post'] ) && $meta_value['exclude_this_post'] ) {
27
  $exclude_post_ids[] = $crp_post_meta['post_id'];
includes/modules/manual-posts.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author Ajay D'Souza <me@ajaydsouza.com>
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
- * @copyright 2009-2015 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
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.
includes/modules/shortcode.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author Ajay D'Souza <me@ajaydsouza.com>
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
- * @copyright 2009-2015 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
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.
includes/modules/taxonomies.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author Ajay D'Souza <me@ajaydsouza.com>
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
10
- * @copyright 2009-2015 Ajay D'Souza
11
  */
12
 
13
  // If this file is called directly, abort.
@@ -26,16 +26,16 @@ if ( ! defined( 'WPINC' ) ) {
26
  function crp_exclude_categories_join( $join ) {
27
  global $wpdb, $crp_settings;
28
 
29
- if ( '' != $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
 
35
  return $sql;
36
- } else {
37
- return $join;
38
  }
 
 
39
  }
40
  add_filter( 'crp_posts_join', 'crp_exclude_categories_join' );
41
 
@@ -50,23 +50,22 @@ add_filter( 'crp_posts_join', 'crp_exclude_categories_join' );
50
  function crp_exclude_categories_where( $where ) {
51
  global $wpdb, $crp_settings;
52
 
53
- if ( '' == $crp_settings['exclude_categories'] ) {
54
- return $where;
55
- } else {
56
 
57
  $terms = $crp_settings['exclude_categories'];
58
 
59
  $sql = $where;
60
 
61
  $sql .= " AND $wpdb->posts.ID NOT IN (
62
- SELECT object_id
63
- FROM $wpdb->term_relationships
64
- WHERE term_taxonomy_id IN ($terms)
65
- )";
66
 
67
  return $sql;
68
  }
69
 
 
70
  }
71
  add_filter( 'crp_posts_where', 'crp_exclude_categories_where' );
72
 
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.
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
 
35
  return $sql;
 
 
36
  }
37
+
38
+ return $join;
39
  }
40
  add_filter( 'crp_posts_join', 'crp_exclude_categories_join' );
41
 
50
  function crp_exclude_categories_where( $where ) {
51
  global $wpdb, $crp_settings;
52
 
53
+ if ( ! empty( $crp_settings['exclude_categories'] ) ) {
 
 
54
 
55
  $terms = $crp_settings['exclude_categories'];
56
 
57
  $sql = $where;
58
 
59
  $sql .= " AND $wpdb->posts.ID NOT IN (
60
+ SELECT object_id
61
+ FROM $wpdb->term_relationships
62
+ WHERE term_taxonomy_id IN ($terms)
63
+ )";
64
 
65
  return $sql;
66
  }
67
 
68
+ return $where;
69
  }
70
  add_filter( 'crp_posts_where', 'crp_exclude_categories_where' );
71
 
includes/output-generator.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  // If this file is called directly, abort.
@@ -194,7 +194,7 @@ function crp_after_list_item( $args, $result ) {
194
  */
195
  function crp_title( $args, $result ) {
196
 
197
- $title = crp_max_formatted_content( 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.
@@ -274,7 +274,7 @@ function crp_list_link( $args, $result ) {
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'] ) {
@@ -292,7 +292,7 @@ function crp_list_link( $args, $result ) {
292
  }
293
 
294
  if ( 'inline' === $args['post_thumb_op'] || 'text_only' === $args['post_thumb_op'] ) {
295
- $output .= '<span class="crp_title">' . $title . '</span>'; // Add title when required by settings
296
  }
297
 
298
  $output .= '</a>';
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.
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.
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'] ) {
292
  }
293
 
294
  if ( 'inline' === $args['post_thumb_op'] || 'text_only' === $args['post_thumb_op'] ) {
295
+ $output .= '<span class="crp_title">' . $title . '</span>'; // Add title when required by settings.
296
  }
297
 
298
  $output .= '</a>';
includes/plugin-activator.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  /**
@@ -41,6 +41,7 @@ function crp_activate( $network_wide ) {
41
  crp_single_activate();
42
  }
43
  }
 
44
 
45
 
46
  /**
@@ -63,3 +64,24 @@ function crp_single_activate() {
63
  }
64
 
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  /**
41
  crp_single_activate();
42
  }
43
  }
44
+ register_activation_hook( CRP_PLUGIN_FILE, 'crp_activate' );
45
 
46
 
47
  /**
64
  }
65
 
66
 
67
+ /**
68
+ * Fired when a new site is activated with a WPMU environment.
69
+ *
70
+ * @since 2.0.0
71
+ *
72
+ * @param int $blog_id ID of the new blog.
73
+ */
74
+ function crp_activate_new_site( $blog_id ) {
75
+
76
+ if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
77
+ return;
78
+ }
79
+
80
+ switch_to_blog( $blog_id );
81
+ crp_single_activate();
82
+ restore_current_blog();
83
+
84
+ }
85
+ add_action( 'wpmu_new_blog', 'crp_activate_new_site' );
86
+
87
+
includes/tools.php CHANGED
@@ -6,7 +6,7 @@
6
  * @author Ajay D'Souza <me@ajaydsouza.com>
7
  * @license GPL-2.0+
8
  * @link https://webberzone.com
9
- * @copyright 2009-2015 Ajay D'Souza
10
  */
11
 
12
  /**
@@ -66,44 +66,51 @@ function crp_excerpt( $id, $excerpt_length = 0, $use_excerpt = true ) {
66
 
67
 
68
  /**
69
- * Function to limit content by characters.
70
  *
71
- * @since 1.8.4
72
  *
73
- * @param string $content Content to be used to make an excerpt.
74
- * @param int $no_of_char Maximum length of excerpt in characters.
75
- * @return string Formatted content.
 
 
76
  */
77
- function crp_max_formatted_content( $content, $no_of_char = -1 ) {
78
- $content = strip_tags( $content );
79
 
80
- if ( ( $no_of_char > 0 ) && ( strlen( $content ) > $no_of_char ) ) {
81
- $words_array = preg_split( '/[\s]+/', substr( $content, 0, $no_of_char ) );
82
 
83
- // Break back down into a string of words, but drop the last one if it's chopped off.
84
- if ( substr( $content, $no_of_char, 1 ) === ' ' ) {
85
- $content = implode( ' ', $words_array );
86
- } else {
87
- $content = implode( ' ', array_slice( $words_array, 0, -1 ) ) . '&hellip;';
 
 
 
 
88
  }
 
 
89
  }
90
 
91
  /**
92
- * Filters formatted content after cropping.
93
  *
94
- * @since 1.9
95
  *
96
- * @param string $content Formatted content
97
- * @param int $no_of_char Maximum length of excerpt in characters
 
 
98
  */
99
- return apply_filters( 'crp_max_formatted_content' , $content, $no_of_char );
100
  }
101
 
102
-
103
  /**
104
  * Delete the CRP cache.
105
  *
106
- * @param array $meta_keys Array of meta keys that hold the cache.
107
  */
108
  function crp_cache_delete( $meta_keys = array() ) {
109
 
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
  /**
66
 
67
 
68
  /**
69
+ * Truncate a string to a certain length.
70
  *
71
+ * @since 2.4.0
72
  *
73
+ * @param string $string String to truncate.
74
+ * @param int $count Maximum number of characters to take.
75
+ * @param string $more What to append if $string needs to be trimmed.
76
+ * @param bool $break_words Optionally choose to break words.
77
+ * @return string Truncated string.
78
  */
79
+ function crp_trim_char( $string, $count = 60, $more = '&hellip;', $break_words = false ) {
 
80
 
81
+ $string = wp_strip_all_tags( $string, true );
 
82
 
83
+ if ( 0 === $count ) {
84
+ return '';
85
+ }
86
+
87
+ if ( mb_strlen( $string ) > $count && $count > 0 ) {
88
+ $count -= min( $count, mb_strlen( $more ) );
89
+
90
+ if ( ! $break_words ) {
91
+ $string = preg_replace( '/\s+?(\S+)?$/u', '', mb_substr( $string, 0, $count + 1 ) );
92
  }
93
+
94
+ $string = mb_substr( $string, 0, $count ) . $more;
95
  }
96
 
97
  /**
98
+ * Filters truncated string.
99
  *
100
+ * @since 2.4.0
101
  *
102
+ * @param string $string String to truncate.
103
+ * @param int $count Maximum number of characters to take.
104
+ * @param string $more What to append if $string needs to be trimmed.
105
+ * @param bool $break_words Optionally choose to break words.
106
  */
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
 
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: 2016-10-01 17:07+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,39 +13,39 @@ 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 1.8.9\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:200
22
  msgid "Options saved successfully. If enabled, the cache has been cleared."
23
  msgstr ""
24
 
25
- #: admin/admin.php:203
26
  msgid ""
27
  "Rounded Thumbnails style selected. Author, Excerpt and Date will not be "
28
  "displayed."
29
  msgstr ""
30
 
31
- #: admin/admin.php:206
32
  msgid "Text Only style selected. Thumbnails will not be displayed."
33
  msgstr ""
34
 
35
- #: admin/admin.php:209
36
  #, php-format
37
- msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %1$d."
38
  msgstr ""
39
 
40
- #: admin/admin.php:233
41
  msgid "Options set to Default."
42
  msgstr ""
43
 
44
- #: admin/admin.php:242
45
  msgid "Index recreated"
46
  msgstr ""
47
 
48
- #: admin/admin.php:259
49
  msgid "Related Posts"
50
  msgstr ""
51
 
@@ -63,15 +63,15 @@ msgstr ""
63
  msgid "Settings"
64
  msgstr ""
65
 
66
- #: admin/loader.php:45 admin/sidebar-view.php:48
67
  msgid "Support"
68
  msgstr ""
69
 
70
- #: admin/loader.php:46
71
  msgid "Donate"
72
  msgstr ""
73
 
74
- #: admin/loader.php:47
75
  msgid "Contribute"
76
  msgstr ""
77
 
@@ -83,25 +83,25 @@ msgstr ""
83
  msgid "List tuning options"
84
  msgstr ""
85
 
86
- #: admin/main-view.php:34 admin/main-view.php:247
87
  msgid "Output options"
88
  msgstr ""
89
 
90
- #: admin/main-view.php:35 admin/main-view.php:451
91
- #: includes/modules/class-crp-widget.php:98
92
  msgid "Thumbnail options"
93
  msgstr ""
94
 
95
- #: admin/main-view.php:36 admin/main-view.php:618
96
  msgid "Styles"
97
  msgstr ""
98
 
99
- #: admin/main-view.php:37 admin/main-view.php:701
100
  msgid "Feed options"
101
  msgstr ""
102
 
103
- #: admin/main-view.php:54 admin/main-view.php:148 admin/main-view.php:246
104
- #: admin/main-view.php:450 admin/main-view.php:617 admin/main-view.php:700
105
  #: admin/sidebar-view.php:19 admin/sidebar-view.php:40
106
  #: admin/sidebar-view.php:58
107
  msgid "Click to toggle"
@@ -230,13 +230,13 @@ msgid ""
230
  "in the list."
231
  msgstr ""
232
 
233
- #: admin/main-view.php:142 admin/main-view.php:240 admin/main-view.php:444
234
- #: admin/main-view.php:611 admin/main-view.php:694 admin/main-view.php:766
235
- #: admin/main-view.php:782
236
  msgid "Save Options"
237
  msgstr ""
238
 
239
- #: admin/main-view.php:165 admin/main-view.php:719
240
  msgid "Number of related posts to display: "
241
  msgstr ""
242
 
@@ -262,100 +262,119 @@ msgid ""
262
  msgstr ""
263
 
264
  #: admin/main-view.php:179
265
- msgid "Find related posts based on content as well as title:"
266
  msgstr ""
267
 
268
  #: admin/main-view.php:181
269
  msgid ""
 
 
 
 
 
 
 
 
 
270
  "If unchecked, only posts titles are used. I recommend using a caching plugin "
271
  "or enabling \"Cache output\" above if you enable this. Each site is "
272
  "different, so toggle this option to see which setting gives you better "
273
  "quality related posts."
274
  msgstr ""
275
 
276
- #: admin/main-view.php:185
277
  msgid "Limit content to be compared:"
278
  msgstr ""
279
 
280
- #: admin/main-view.php:187
281
  msgid ""
282
  "This sets the maximum words of the content that will be matched. Set to 0 "
283
  "for no limit. Max value: 2,000. Only applies if you activate the above "
284
  "option."
285
  msgstr ""
286
 
287
- #: admin/main-view.php:191
288
  msgid "Post types to include in results:"
289
  msgstr ""
290
 
291
- #: admin/main-view.php:198
292
  msgid ""
293
  "These post types will be displayed in the list. Includes custom post types."
294
  msgstr ""
295
 
296
- #: admin/main-view.php:202
 
 
 
 
 
 
 
 
 
 
297
  msgid "List of post or page IDs to exclude from the results:"
298
  msgstr ""
299
 
300
- #: admin/main-view.php:204 admin/main-view.php:375
301
  msgid ""
302
  "Comma separated list of post, page or custom post type IDs. e.g. 188,320,500"
303
  msgstr ""
304
 
305
- #: admin/main-view.php:208
306
  msgid "Categories to exclude from the results: "
307
  msgstr ""
308
 
309
- #: admin/main-view.php:211
310
  msgid ""
311
  "Comma separated list of category slugs. The field above has an autocomplete "
312
  "so simply start typing in the beginning of your category name and it will "
313
  "prompt you with options."
314
  msgstr ""
315
 
316
- #: admin/main-view.php:214
317
  msgid "Excluded category IDs are:"
318
  msgstr ""
319
 
320
- #: admin/main-view.php:215
321
  msgid " "
322
  msgstr ""
323
 
324
- #: admin/main-view.php:220
325
  #, php-format
326
  msgid ""
327
  "These might differ from the IDs visible in the Categories page which use the "
328
  "%1$s. CRP uses the %2$s which is unique to this taxonomy."
329
  msgstr ""
330
 
331
- #: admin/main-view.php:263
332
  msgid "Title of related posts:"
333
  msgstr ""
334
 
335
- #: admin/main-view.php:266
336
  #, php-format
337
  msgid ""
338
  "This is the main heading of the related posts. You can also display the "
339
  "current post title by using %1$s"
340
  msgstr ""
341
 
342
- #: admin/main-view.php:270
343
  msgid "When there are no posts, what should be shown?"
344
  msgstr ""
345
 
346
- #: admin/main-view.php:274
347
  msgid "Blank Output"
348
  msgstr ""
349
 
350
- #: admin/main-view.php:279
351
  msgid "Display:"
352
  msgstr ""
353
 
354
- #: admin/main-view.php:285 admin/main-view.php:722
355
  msgid "Show post excerpt in list?"
356
  msgstr ""
357
 
358
- #: admin/main-view.php:288
359
  #, php-format
360
  msgid ""
361
  "Displays the excerpt of the post. If you do not provide an explicit excerpt "
@@ -363,122 +382,122 @@ msgid ""
363
  "automatic excerpt which refers to the first %d words of the post's content"
364
  msgstr ""
365
 
366
- #: admin/main-view.php:291
367
  msgid ""
368
  "Rounded Thumbnails style selected under the Custom Styles. Excerpt display "
369
  "is disabled."
370
  msgstr ""
371
 
372
- #: admin/main-view.php:296
373
  msgid "Length of excerpt (in words):"
374
  msgstr ""
375
 
376
- #: admin/main-view.php:302
377
  msgid "Show post author in list?"
378
  msgstr ""
379
 
380
- #: admin/main-view.php:305
381
  msgid "Displays the author name prefixed with \"by\". e.g. by John Doe"
382
  msgstr ""
383
 
384
- #: admin/main-view.php:308
385
  msgid ""
386
  "Rounded Thumbnails style selected under the Custom Styles. Author display is "
387
  "disabled."
388
  msgstr ""
389
 
390
- #: admin/main-view.php:313
391
  msgid "Show post date in list?"
392
  msgstr ""
393
 
394
- #: admin/main-view.php:316
395
  msgid ""
396
  "Displays the date of the post. Uses the same date format set in General "
397
  "Options"
398
  msgstr ""
399
 
400
- #: admin/main-view.php:319
401
  msgid ""
402
  "Rounded Thumbnails style selected under the Custom Styles. Date display is "
403
  "disabled."
404
  msgstr ""
405
 
406
- #: admin/main-view.php:324
407
  msgid "Limit post title length (in characters)"
408
  msgstr ""
409
 
410
- #: admin/main-view.php:327
411
  msgid ""
412
  "Any title longer than the number of characters set above will be cut and "
413
  "appended with an ellipsis (&hellip;)"
414
  msgstr ""
415
 
416
- #: admin/main-view.php:331
417
  msgid "Open links in new window"
418
  msgstr ""
419
 
420
- #: admin/main-view.php:337
421
  msgid "Add nofollow attribute to links in the list"
422
  msgstr ""
423
 
424
- #: admin/main-view.php:370
425
  msgid "Exclusion settings:"
426
  msgstr ""
427
 
428
- #: admin/main-view.php:372
429
  msgid "Exclude display of related posts on these posts / pages"
430
  msgstr ""
431
 
432
- #: admin/main-view.php:378
433
  msgid "Exclude display of related posts on these post types."
434
  msgstr ""
435
 
436
- #: admin/main-view.php:385
437
  msgid ""
438
  "The related posts will not display on any of the above selected post types"
439
  msgstr ""
440
 
441
- #: admin/main-view.php:415
442
  msgid "Customize the output:"
443
  msgstr ""
444
 
445
- #: admin/main-view.php:417
446
  msgid "HTML to display before the list of posts: "
447
  msgstr ""
448
 
449
- #: admin/main-view.php:420
450
  msgid "HTML to display before each list item: "
451
  msgstr ""
452
 
453
- #: admin/main-view.php:423
454
  msgid "HTML to display after each list item: "
455
  msgstr ""
456
 
457
- #: admin/main-view.php:426
458
  msgid "HTML to display after the list of posts: "
459
  msgstr ""
460
 
461
- #: admin/main-view.php:467 admin/main-view.php:725
462
  msgid "Location of post thumbnail:"
463
  msgstr ""
464
 
465
- #: admin/main-view.php:471 admin/main-view.php:729
466
  msgid "Display thumbnails inline with posts, before title"
467
  msgstr ""
468
 
469
- #: admin/main-view.php:476 admin/main-view.php:733
470
  msgid "Display thumbnails inline with posts, after title"
471
  msgstr ""
472
 
473
- #: admin/main-view.php:481 admin/main-view.php:737
474
  msgid "Display only thumbnails, no text"
475
  msgstr ""
476
 
477
- #: admin/main-view.php:486 admin/main-view.php:741
478
  msgid "Do not display thumbnails, only text."
479
  msgstr ""
480
 
481
- #: admin/main-view.php:490
482
  #, php-format
483
  msgid ""
484
  "This setting cannot be changed because an inbuilt style has been selected "
@@ -486,140 +505,140 @@ msgid ""
486
  "select %1$s under the Styles section."
487
  msgstr ""
488
 
489
- #: admin/main-view.php:490 admin/main-view.php:637
490
  msgid "No styles"
491
  msgstr ""
492
 
493
- #: admin/main-view.php:494
494
  msgid "Thumbnail size:"
495
  msgstr ""
496
 
497
- #: admin/main-view.php:519
498
  msgid "Custom size"
499
  msgstr ""
500
 
501
- #: admin/main-view.php:522
502
  msgid "You can choose from existing image sizes above or create a custom size."
503
  msgstr ""
504
 
505
- #: admin/main-view.php:523
506
  msgid ""
507
  "If you choose an existing size, then the width, height and crop mode "
508
  "settings in the three options below will be automatically updated to reflect "
509
  "the correct dimensions of the setting."
510
  msgstr ""
511
 
512
- #: admin/main-view.php:524
513
  msgid ""
514
  "If you have chosen Custom size above, then enter the width, height and crop "
515
  "settings below. For best results, use a cropped image with the same width "
516
  "and height. The default setting is 150x150 cropped image."
517
  msgstr ""
518
 
519
- #: admin/main-view.php:525
520
  msgid ""
521
  "Any changes to the thumbnail settings doesn't automatically resize existing "
522
  "images."
523
  msgstr ""
524
 
525
- #: admin/main-view.php:527
526
  #, php-format
527
  msgid "I recommend using %1$s or %2$s to regenerate all image sizes."
528
  msgstr ""
529
 
530
- #: admin/main-view.php:534
531
  msgid "Width of the thumbnail:"
532
  msgstr ""
533
 
534
- #: admin/main-view.php:537
535
  msgid "Height of the thumbnail: "
536
  msgstr ""
537
 
538
- #: admin/main-view.php:542
539
  msgid "Crop mode:"
540
  msgstr ""
541
 
542
- #: admin/main-view.php:546
543
  msgid ""
544
  "By default, thumbnails will be hard cropped. Uncheck this box to "
545
  "proportionately/soft crop the thumbnails."
546
  msgstr ""
547
 
548
- #: admin/main-view.php:550
549
  msgid "Image size attributes:"
550
  msgstr ""
551
 
552
- #: admin/main-view.php:554
553
  msgid "Style attributes. e.g."
554
  msgstr ""
555
 
556
- #: admin/main-view.php:560
557
  msgid "HTML width and height attributes. e.g."
558
  msgstr ""
559
 
560
- #: admin/main-view.php:566
561
  msgid "No HTML or Style attributes"
562
  msgstr ""
563
 
564
- #: admin/main-view.php:571
565
  msgid "Post thumbnail meta field name:"
566
  msgstr ""
567
 
568
- #: admin/main-view.php:573
569
  #, php-format
570
  msgid ""
571
  "The value of this field should contain a direct link to the image. This is "
572
  "set in the meta box in the %1$s screen."
573
  msgstr ""
574
 
575
- #: admin/main-view.php:573
576
  msgid "Add New Post"
577
  msgstr ""
578
 
579
- #: admin/main-view.php:576
580
  msgid "Extract the first image from the post?"
581
  msgstr ""
582
 
583
- #: admin/main-view.php:578
584
  msgid ""
585
  "This will only happen if there is no post thumbnail set and no image URL is "
586
  "specified in the meta field."
587
  msgstr ""
588
 
589
- #: admin/main-view.php:581
590
  msgid "Use default thumbnail?"
591
  msgstr ""
592
 
593
- #: admin/main-view.php:583
594
  msgid ""
595
  "If checked, when no thumbnail is found, show a default one from the URL "
596
  "below. If not checked and no thumbnail is found, no image will be shown."
597
  msgstr ""
598
 
599
- #: admin/main-view.php:586
600
  msgid "Default thumbnail:"
601
  msgstr ""
602
 
603
- #: admin/main-view.php:593
604
  msgid ""
605
  "The plugin will first check if the post contains a thumbnail. If it doesn't "
606
  "then it will check the meta field. If this is not available, then it will "
607
  "show the default image as specified above."
608
  msgstr ""
609
 
610
- #: admin/main-view.php:634
611
  msgid "Style of the related posts:"
612
  msgstr ""
613
 
614
- #: admin/main-view.php:639
615
  msgid "Select this option if you plan to add your own styles"
616
  msgstr ""
617
 
618
- #: admin/main-view.php:643
619
  msgid "Rounded Thumbnails"
620
  msgstr ""
621
 
622
- #: admin/main-view.php:646
623
  msgid ""
624
  "Enabling this option will turn on the thumbnails and set their width and "
625
  "height to 150px. It will also turn off the display of the author, excerpt "
@@ -627,139 +646,139 @@ msgid ""
627
  "settings."
628
  msgstr ""
629
 
630
- #: admin/main-view.php:648
631
  #, php-format
632
  msgid "You can view the default style at %s"
633
  msgstr ""
634
 
635
- #: admin/main-view.php:654
636
  msgid "Text only"
637
  msgstr ""
638
 
639
- #: admin/main-view.php:656
640
  msgid ""
641
  "Enabling this option will disable thumbnails and no longer include the "
642
  "default style sheet included in the plugin."
643
  msgstr ""
644
 
645
- #: admin/main-view.php:671
646
  msgid "Custom CSS to add to header:"
647
  msgstr ""
648
 
649
- #: admin/main-view.php:676
650
  #, php-format
651
  msgid ""
652
  "Do not include %1$s tags. Check out the %2$s for available CSS classes to "
653
  "style."
654
  msgstr ""
655
 
656
- #: admin/main-view.php:717
657
  msgid ""
658
  "Below options override the related posts settings for your blog feed. These "
659
  "only apply if you have selected to add related posts to Feeds in the General "
660
  "Options tab."
661
  msgstr ""
662
 
663
- #: admin/main-view.php:745
664
  msgid "Maximum width of the thumbnail: "
665
  msgstr ""
666
 
667
- #: admin/main-view.php:748
668
  msgid "Maximum height of the thumbnail: "
669
  msgstr ""
670
 
671
- #: admin/main-view.php:783
672
  msgid "Default Options"
673
  msgstr ""
674
 
675
- #: admin/main-view.php:783
676
  msgid "Do you want to set options to Default?"
677
  msgstr ""
678
 
679
- #: admin/main-view.php:784
680
  msgid "Recreate Index"
681
  msgstr ""
682
 
683
- #: admin/main-view.php:784
684
  msgid "Are you sure you want to recreate the index?"
685
  msgstr ""
686
 
687
- #: admin/main-view.php:789
688
  #, php-format
689
  msgid ""
690
  "One or more FULLTEXT indices are missing. Please hit the %1$s at the bottom "
691
  "of the page to fix this."
692
  msgstr ""
693
 
694
- #: admin/main-view.php:789
695
  msgid "Recreate Index button"
696
  msgstr ""
697
 
698
- #: admin/main-view.php:794
699
  msgid ""
700
  "If the Recreate Index button fails, please run the following queries in "
701
  "phpMyAdmin or Adminer"
702
  msgstr ""
703
 
704
- #: admin/metabox.php:104
705
  msgid "Disable Related Posts display:"
706
  msgstr ""
707
 
708
- #: admin/metabox.php:107
709
  msgid ""
710
  "If this is checked, then Contextual Related Posts will not automatically "
711
  "insert the related posts at the end of post content."
712
  msgstr ""
713
 
714
- #: admin/metabox.php:111
715
  msgid "Exclude this post from the related posts list:"
716
  msgstr ""
717
 
718
- #: admin/metabox.php:114
719
  msgid ""
720
  "If this is checked, then this post will be excluded from the popular posts "
721
  "list."
722
  msgstr ""
723
 
724
- #: admin/metabox.php:118 admin/metabox.php:126
725
  msgid "Manual related posts:"
726
  msgstr ""
727
 
728
- #: admin/metabox.php:120
729
  msgid ""
730
  "Comma separated list of post, page or custom post type IDs. e.g. "
731
  "188,320,500. These will be given preference over the related posts generated "
732
  "by the plugin."
733
  msgstr ""
734
 
735
- #: admin/metabox.php:121
736
  msgid ""
737
  "Once you enter the list above and save this page, the plugin will display "
738
  "the titles of the posts below for your reference. Only IDs corresponding to "
739
  "published posts or custom post types will be retained."
740
  msgstr ""
741
 
742
- #: admin/metabox.php:136
743
  #, php-format
744
  msgid "This post type is: %s"
745
  msgstr ""
746
 
747
- #: admin/metabox.php:147
748
  msgid "Location of thumbnail"
749
  msgstr ""
750
 
751
- #: admin/metabox.php:149
752
  msgid ""
753
  "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This "
754
  "image will be used for the post. It will be resized to the thumbnail size "
755
  "set under Settings &raquo; Related Posts &raquo; Output Options"
756
  msgstr ""
757
 
758
- #: admin/metabox.php:150
759
  msgid "The URL above is saved in the meta field:"
760
  msgstr ""
761
 
762
- #: admin/metabox.php:155
763
  msgid ""
764
  "You have Top 10 WordPress Plugin installed. If you are trying to modify the "
765
  "thumbnail, then you'll need to make the same change in the Top 10 meta box "
@@ -818,19 +837,19 @@ msgstr ""
818
  msgid "Follow us"
819
  msgstr ""
820
 
821
- #: contextual-related-posts.php:262
822
- #, php-format
823
- msgid "Powered by <a href=\"%s\" rel=\"nofollow\">Contextual Related Posts</a>"
824
- msgstr ""
825
-
826
- #: contextual-related-posts.php:816
827
  msgid "<h3>Related Posts:</h3>"
828
  msgstr ""
829
 
830
- #: contextual-related-posts.php:818
831
  msgid "No related posts found"
832
  msgstr ""
833
 
 
 
 
 
 
834
  #: includes/media.php:65
835
  msgid "thumb_timthumb argument has been deprecated"
836
  msgstr ""
@@ -847,59 +866,59 @@ msgstr ""
847
  msgid "Related Posts [CRP]"
848
  msgstr ""
849
 
850
- #: includes/modules/class-crp-widget.php:33
851
  msgid "Display Related Posts"
852
  msgstr ""
853
 
854
- #: includes/modules/class-crp-widget.php:69
855
  msgid "Title"
856
  msgstr ""
857
 
858
- #: includes/modules/class-crp-widget.php:74
859
  msgid "No. of posts"
860
  msgstr ""
861
 
862
- #: includes/modules/class-crp-widget.php:79
863
  msgid "Offset"
864
  msgstr ""
865
 
866
- #: includes/modules/class-crp-widget.php:84
867
  msgid " Show excerpt?"
868
  msgstr ""
869
 
870
- #: includes/modules/class-crp-widget.php:89
871
  msgid " Show author?"
872
  msgstr ""
873
 
874
- #: includes/modules/class-crp-widget.php:94
875
  msgid " Show date?"
876
  msgstr ""
877
 
878
- #: includes/modules/class-crp-widget.php:100
879
  msgid "Thumbnails inline, before title"
880
  msgstr ""
881
 
882
- #: includes/modules/class-crp-widget.php:101
883
  msgid "Thumbnails inline, after title"
884
  msgstr ""
885
 
886
- #: includes/modules/class-crp-widget.php:102
887
  msgid "Only thumbnails, no text"
888
  msgstr ""
889
 
890
- #: includes/modules/class-crp-widget.php:103
891
  msgid "No thumbnails, only text."
892
  msgstr ""
893
 
894
- #: includes/modules/class-crp-widget.php:108
895
  msgid "Thumbnail height"
896
  msgstr ""
897
 
898
- #: includes/modules/class-crp-widget.php:113
899
  msgid "Thumbnail width"
900
  msgstr ""
901
 
902
- #: includes/modules/class-crp-widget.php:117
903
  msgid "Post types to include"
904
  msgstr ""
905
 
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
  "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
 
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
 
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"
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
 
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 "
281
  "different, so toggle this option to see which setting gives you better "
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
  "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
  "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
  "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 "
837
  msgid "Follow us"
838
  msgstr ""
839
 
840
+ #: contextual-related-posts.php:100
 
 
 
 
 
841
  msgid "<h3>Related Posts:</h3>"
842
  msgstr ""
843
 
844
+ #: contextual-related-posts.php:102
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 ""
852
+
853
  #: includes/media.php:65
854
  msgid "thumb_timthumb argument has been deprecated"
855
  msgstr ""
866
  msgid "Related Posts [CRP]"
867
  msgstr ""
868
 
869
+ #: includes/modules/class-crp-widget.php:34
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
 
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: 2016-10-01 17:05+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,38 +14,38 @@ 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 1.8.9\n"
18
  "X-Poedit-SourceCharset: UTF-8\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
 
21
- #: admin/admin.php:200
22
  msgid "Options saved successfully. If enabled, the cache has been cleared."
23
  msgstr ""
24
 
25
- #: admin/admin.php:203
26
  msgid ""
27
  "Rounded Thumbnails style selected. Author, Excerpt and Date will not be "
28
  "displayed."
29
  msgstr ""
30
 
31
- #: admin/admin.php:206
32
  msgid "Text Only style selected. Thumbnails will not be displayed."
33
  msgstr ""
34
 
35
- #: admin/admin.php:209
36
  #, php-format
37
- msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %1$d."
38
  msgstr ""
39
 
40
- #: admin/admin.php:233
41
  msgid "Options set to Default."
42
  msgstr ""
43
 
44
- #: admin/admin.php:242
45
  msgid "Index recreated"
46
  msgstr ""
47
 
48
- #: admin/admin.php:259
49
  msgid "Related Posts"
50
  msgstr ""
51
 
@@ -63,15 +63,15 @@ msgstr ""
63
  msgid "Settings"
64
  msgstr ""
65
 
66
- #: admin/loader.php:45 admin/sidebar-view.php:48
67
  msgid "Support"
68
  msgstr ""
69
 
70
- #: admin/loader.php:46
71
  msgid "Donate"
72
  msgstr ""
73
 
74
- #: admin/loader.php:47
75
  msgid "Contribute"
76
  msgstr ""
77
 
@@ -83,25 +83,25 @@ msgstr ""
83
  msgid "List tuning options"
84
  msgstr ""
85
 
86
- #: admin/main-view.php:34 admin/main-view.php:247
87
  msgid "Output options"
88
  msgstr ""
89
 
90
- #: admin/main-view.php:35 admin/main-view.php:451
91
- #: includes/modules/class-crp-widget.php:98
92
  msgid "Thumbnail options"
93
  msgstr ""
94
 
95
- #: admin/main-view.php:36 admin/main-view.php:618
96
  msgid "Styles"
97
  msgstr ""
98
 
99
- #: admin/main-view.php:37 admin/main-view.php:701
100
  msgid "Feed options"
101
  msgstr ""
102
 
103
- #: admin/main-view.php:54 admin/main-view.php:148 admin/main-view.php:246
104
- #: admin/main-view.php:450 admin/main-view.php:617 admin/main-view.php:700
105
  #: admin/sidebar-view.php:19 admin/sidebar-view.php:40
106
  #: admin/sidebar-view.php:58
107
  msgid "Click to toggle"
@@ -230,13 +230,13 @@ msgid ""
230
  "in the list."
231
  msgstr ""
232
 
233
- #: admin/main-view.php:142 admin/main-view.php:240 admin/main-view.php:444
234
- #: admin/main-view.php:611 admin/main-view.php:694 admin/main-view.php:766
235
- #: admin/main-view.php:782
236
  msgid "Save Options"
237
  msgstr ""
238
 
239
- #: admin/main-view.php:165 admin/main-view.php:719
240
  msgid "Number of related posts to display: "
241
  msgstr ""
242
 
@@ -262,100 +262,119 @@ msgid ""
262
  msgstr ""
263
 
264
  #: admin/main-view.php:179
265
- msgid "Find related posts based on content as well as title:"
266
  msgstr ""
267
 
268
  #: admin/main-view.php:181
269
  msgid ""
 
 
 
 
 
 
 
 
 
270
  "If unchecked, only posts titles are used. I recommend using a caching plugin "
271
  "or enabling \"Cache output\" above if you enable this. Each site is "
272
  "different, so toggle this option to see which setting gives you better "
273
  "quality related posts."
274
  msgstr ""
275
 
276
- #: admin/main-view.php:185
277
  msgid "Limit content to be compared:"
278
  msgstr ""
279
 
280
- #: admin/main-view.php:187
281
  msgid ""
282
  "This sets the maximum words of the content that will be matched. Set to 0 "
283
  "for no limit. Max value: 2,000. Only applies if you activate the above "
284
  "option."
285
  msgstr ""
286
 
287
- #: admin/main-view.php:191
288
  msgid "Post types to include in results:"
289
  msgstr ""
290
 
291
- #: admin/main-view.php:198
292
  msgid ""
293
  "These post types will be displayed in the list. Includes custom post types."
294
  msgstr ""
295
 
296
- #: admin/main-view.php:202
 
 
 
 
 
 
 
 
 
 
297
  msgid "List of post or page IDs to exclude from the results:"
298
  msgstr ""
299
 
300
- #: admin/main-view.php:204 admin/main-view.php:375
301
  msgid ""
302
  "Comma separated list of post, page or custom post type IDs. e.g. 188,320,500"
303
  msgstr ""
304
 
305
- #: admin/main-view.php:208
306
  msgid "Categories to exclude from the results: "
307
  msgstr ""
308
 
309
- #: admin/main-view.php:211
310
  msgid ""
311
  "Comma separated list of category slugs. The field above has an autocomplete "
312
  "so simply start typing in the beginning of your category name and it will "
313
  "prompt you with options."
314
  msgstr ""
315
 
316
- #: admin/main-view.php:214
317
  msgid "Excluded category IDs are:"
318
  msgstr ""
319
 
320
- #: admin/main-view.php:215
321
  msgid " "
322
  msgstr ""
323
 
324
- #: admin/main-view.php:220
325
  #, php-format
326
  msgid ""
327
  "These might differ from the IDs visible in the Categories page which use the "
328
  "%1$s. CRP uses the %2$s which is unique to this taxonomy."
329
  msgstr ""
330
 
331
- #: admin/main-view.php:263
332
  msgid "Title of related posts:"
333
  msgstr ""
334
 
335
- #: admin/main-view.php:266
336
  #, php-format
337
  msgid ""
338
  "This is the main heading of the related posts. You can also display the "
339
  "current post title by using %1$s"
340
  msgstr ""
341
 
342
- #: admin/main-view.php:270
343
  msgid "When there are no posts, what should be shown?"
344
  msgstr ""
345
 
346
- #: admin/main-view.php:274
347
  msgid "Blank Output"
348
  msgstr ""
349
 
350
- #: admin/main-view.php:279
351
  msgid "Display:"
352
  msgstr ""
353
 
354
- #: admin/main-view.php:285 admin/main-view.php:722
355
  msgid "Show post excerpt in list?"
356
  msgstr ""
357
 
358
- #: admin/main-view.php:288
359
  #, php-format
360
  msgid ""
361
  "Displays the excerpt of the post. If you do not provide an explicit excerpt "
@@ -363,122 +382,122 @@ msgid ""
363
  "automatic excerpt which refers to the first %d words of the post's content"
364
  msgstr ""
365
 
366
- #: admin/main-view.php:291
367
  msgid ""
368
  "Rounded Thumbnails style selected under the Custom Styles. Excerpt display "
369
  "is disabled."
370
  msgstr ""
371
 
372
- #: admin/main-view.php:296
373
  msgid "Length of excerpt (in words):"
374
  msgstr ""
375
 
376
- #: admin/main-view.php:302
377
  msgid "Show post author in list?"
378
  msgstr ""
379
 
380
- #: admin/main-view.php:305
381
  msgid "Displays the author name prefixed with \"by\". e.g. by John Doe"
382
  msgstr ""
383
 
384
- #: admin/main-view.php:308
385
  msgid ""
386
  "Rounded Thumbnails style selected under the Custom Styles. Author display is "
387
  "disabled."
388
  msgstr ""
389
 
390
- #: admin/main-view.php:313
391
  msgid "Show post date in list?"
392
  msgstr ""
393
 
394
- #: admin/main-view.php:316
395
  msgid ""
396
  "Displays the date of the post. Uses the same date format set in General "
397
  "Options"
398
  msgstr ""
399
 
400
- #: admin/main-view.php:319
401
  msgid ""
402
  "Rounded Thumbnails style selected under the Custom Styles. Date display is "
403
  "disabled."
404
  msgstr ""
405
 
406
- #: admin/main-view.php:324
407
  msgid "Limit post title length (in characters)"
408
  msgstr ""
409
 
410
- #: admin/main-view.php:327
411
  msgid ""
412
  "Any title longer than the number of characters set above will be cut and "
413
  "appended with an ellipsis (&hellip;)"
414
  msgstr ""
415
 
416
- #: admin/main-view.php:331
417
  msgid "Open links in new window"
418
  msgstr ""
419
 
420
- #: admin/main-view.php:337
421
  msgid "Add nofollow attribute to links in the list"
422
  msgstr ""
423
 
424
- #: admin/main-view.php:370
425
  msgid "Exclusion settings:"
426
  msgstr ""
427
 
428
- #: admin/main-view.php:372
429
  msgid "Exclude display of related posts on these posts / pages"
430
  msgstr ""
431
 
432
- #: admin/main-view.php:378
433
  msgid "Exclude display of related posts on these post types."
434
  msgstr ""
435
 
436
- #: admin/main-view.php:385
437
  msgid ""
438
  "The related posts will not display on any of the above selected post types"
439
  msgstr ""
440
 
441
- #: admin/main-view.php:415
442
  msgid "Customize the output:"
443
  msgstr ""
444
 
445
- #: admin/main-view.php:417
446
  msgid "HTML to display before the list of posts: "
447
  msgstr ""
448
 
449
- #: admin/main-view.php:420
450
  msgid "HTML to display before each list item: "
451
  msgstr ""
452
 
453
- #: admin/main-view.php:423
454
  msgid "HTML to display after each list item: "
455
  msgstr ""
456
 
457
- #: admin/main-view.php:426
458
  msgid "HTML to display after the list of posts: "
459
  msgstr ""
460
 
461
- #: admin/main-view.php:467 admin/main-view.php:725
462
  msgid "Location of post thumbnail:"
463
  msgstr ""
464
 
465
- #: admin/main-view.php:471 admin/main-view.php:729
466
  msgid "Display thumbnails inline with posts, before title"
467
  msgstr ""
468
 
469
- #: admin/main-view.php:476 admin/main-view.php:733
470
  msgid "Display thumbnails inline with posts, after title"
471
  msgstr ""
472
 
473
- #: admin/main-view.php:481 admin/main-view.php:737
474
  msgid "Display only thumbnails, no text"
475
  msgstr ""
476
 
477
- #: admin/main-view.php:486 admin/main-view.php:741
478
  msgid "Do not display thumbnails, only text."
479
  msgstr ""
480
 
481
- #: admin/main-view.php:490
482
  #, php-format
483
  msgid ""
484
  "This setting cannot be changed because an inbuilt style has been selected "
@@ -486,140 +505,140 @@ msgid ""
486
  "select %1$s under the Styles section."
487
  msgstr ""
488
 
489
- #: admin/main-view.php:490 admin/main-view.php:637
490
  msgid "No styles"
491
  msgstr ""
492
 
493
- #: admin/main-view.php:494
494
  msgid "Thumbnail size:"
495
  msgstr ""
496
 
497
- #: admin/main-view.php:519
498
  msgid "Custom size"
499
  msgstr ""
500
 
501
- #: admin/main-view.php:522
502
  msgid "You can choose from existing image sizes above or create a custom size."
503
  msgstr ""
504
 
505
- #: admin/main-view.php:523
506
  msgid ""
507
  "If you choose an existing size, then the width, height and crop mode "
508
  "settings in the three options below will be automatically updated to reflect "
509
  "the correct dimensions of the setting."
510
  msgstr ""
511
 
512
- #: admin/main-view.php:524
513
  msgid ""
514
  "If you have chosen Custom size above, then enter the width, height and crop "
515
  "settings below. For best results, use a cropped image with the same width "
516
  "and height. The default setting is 150x150 cropped image."
517
  msgstr ""
518
 
519
- #: admin/main-view.php:525
520
  msgid ""
521
  "Any changes to the thumbnail settings doesn't automatically resize existing "
522
  "images."
523
  msgstr ""
524
 
525
- #: admin/main-view.php:527
526
  #, php-format
527
  msgid "I recommend using %1$s or %2$s to regenerate all image sizes."
528
  msgstr ""
529
 
530
- #: admin/main-view.php:534
531
  msgid "Width of the thumbnail:"
532
  msgstr ""
533
 
534
- #: admin/main-view.php:537
535
  msgid "Height of the thumbnail: "
536
  msgstr ""
537
 
538
- #: admin/main-view.php:542
539
  msgid "Crop mode:"
540
  msgstr ""
541
 
542
- #: admin/main-view.php:546
543
  msgid ""
544
  "By default, thumbnails will be hard cropped. Uncheck this box to "
545
  "proportionately/soft crop the thumbnails."
546
  msgstr ""
547
 
548
- #: admin/main-view.php:550
549
  msgid "Image size attributes:"
550
  msgstr ""
551
 
552
- #: admin/main-view.php:554
553
  msgid "Style attributes. e.g."
554
  msgstr ""
555
 
556
- #: admin/main-view.php:560
557
  msgid "HTML width and height attributes. e.g."
558
  msgstr ""
559
 
560
- #: admin/main-view.php:566
561
  msgid "No HTML or Style attributes"
562
  msgstr ""
563
 
564
- #: admin/main-view.php:571
565
  msgid "Post thumbnail meta field name:"
566
  msgstr ""
567
 
568
- #: admin/main-view.php:573
569
  #, php-format
570
  msgid ""
571
  "The value of this field should contain a direct link to the image. This is "
572
  "set in the meta box in the %1$s screen."
573
  msgstr ""
574
 
575
- #: admin/main-view.php:573
576
  msgid "Add New Post"
577
  msgstr ""
578
 
579
- #: admin/main-view.php:576
580
  msgid "Extract the first image from the post?"
581
  msgstr ""
582
 
583
- #: admin/main-view.php:578
584
  msgid ""
585
  "This will only happen if there is no post thumbnail set and no image URL is "
586
  "specified in the meta field."
587
  msgstr ""
588
 
589
- #: admin/main-view.php:581
590
  msgid "Use default thumbnail?"
591
  msgstr ""
592
 
593
- #: admin/main-view.php:583
594
  msgid ""
595
  "If checked, when no thumbnail is found, show a default one from the URL "
596
  "below. If not checked and no thumbnail is found, no image will be shown."
597
  msgstr ""
598
 
599
- #: admin/main-view.php:586
600
  msgid "Default thumbnail:"
601
  msgstr ""
602
 
603
- #: admin/main-view.php:593
604
  msgid ""
605
  "The plugin will first check if the post contains a thumbnail. If it doesn't "
606
  "then it will check the meta field. If this is not available, then it will "
607
  "show the default image as specified above."
608
  msgstr ""
609
 
610
- #: admin/main-view.php:634
611
  msgid "Style of the related posts:"
612
  msgstr ""
613
 
614
- #: admin/main-view.php:639
615
  msgid "Select this option if you plan to add your own styles"
616
  msgstr ""
617
 
618
- #: admin/main-view.php:643
619
  msgid "Rounded Thumbnails"
620
  msgstr ""
621
 
622
- #: admin/main-view.php:646
623
  msgid ""
624
  "Enabling this option will turn on the thumbnails and set their width and "
625
  "height to 150px. It will also turn off the display of the author, excerpt "
@@ -627,139 +646,139 @@ msgid ""
627
  "settings."
628
  msgstr ""
629
 
630
- #: admin/main-view.php:648
631
  #, php-format
632
  msgid "You can view the default style at %s"
633
  msgstr ""
634
 
635
- #: admin/main-view.php:654
636
  msgid "Text only"
637
  msgstr ""
638
 
639
- #: admin/main-view.php:656
640
  msgid ""
641
  "Enabling this option will disable thumbnails and no longer include the "
642
  "default style sheet included in the plugin."
643
  msgstr ""
644
 
645
- #: admin/main-view.php:671
646
  msgid "Custom CSS to add to header:"
647
  msgstr ""
648
 
649
- #: admin/main-view.php:676
650
  #, php-format
651
  msgid ""
652
  "Do not include %1$s tags. Check out the %2$s for available CSS classes to "
653
  "style."
654
  msgstr ""
655
 
656
- #: admin/main-view.php:717
657
  msgid ""
658
  "Below options override the related posts settings for your blog feed. These "
659
  "only apply if you have selected to add related posts to Feeds in the General "
660
  "Options tab."
661
  msgstr ""
662
 
663
- #: admin/main-view.php:745
664
  msgid "Maximum width of the thumbnail: "
665
  msgstr ""
666
 
667
- #: admin/main-view.php:748
668
  msgid "Maximum height of the thumbnail: "
669
  msgstr ""
670
 
671
- #: admin/main-view.php:783
672
  msgid "Default Options"
673
  msgstr ""
674
 
675
- #: admin/main-view.php:783
676
  msgid "Do you want to set options to Default?"
677
  msgstr ""
678
 
679
- #: admin/main-view.php:784
680
  msgid "Recreate Index"
681
  msgstr ""
682
 
683
- #: admin/main-view.php:784
684
  msgid "Are you sure you want to recreate the index?"
685
  msgstr ""
686
 
687
- #: admin/main-view.php:789
688
  #, php-format
689
  msgid ""
690
  "One or more FULLTEXT indices are missing. Please hit the %1$s at the bottom "
691
  "of the page to fix this."
692
  msgstr ""
693
 
694
- #: admin/main-view.php:789
695
  msgid "Recreate Index button"
696
  msgstr ""
697
 
698
- #: admin/main-view.php:794
699
  msgid ""
700
  "If the Recreate Index button fails, please run the following queries in "
701
  "phpMyAdmin or Adminer"
702
  msgstr ""
703
 
704
- #: admin/metabox.php:104
705
  msgid "Disable Related Posts display:"
706
  msgstr ""
707
 
708
- #: admin/metabox.php:107
709
  msgid ""
710
  "If this is checked, then Contextual Related Posts will not automatically "
711
  "insert the related posts at the end of post content."
712
  msgstr ""
713
 
714
- #: admin/metabox.php:111
715
  msgid "Exclude this post from the related posts list:"
716
  msgstr ""
717
 
718
- #: admin/metabox.php:114
719
  msgid ""
720
  "If this is checked, then this post will be excluded from the popular posts "
721
  "list."
722
  msgstr ""
723
 
724
- #: admin/metabox.php:118 admin/metabox.php:126
725
  msgid "Manual related posts:"
726
  msgstr ""
727
 
728
- #: admin/metabox.php:120
729
  msgid ""
730
  "Comma separated list of post, page or custom post type IDs. e.g. "
731
  "188,320,500. These will be given preference over the related posts generated "
732
  "by the plugin."
733
  msgstr ""
734
 
735
- #: admin/metabox.php:121
736
  msgid ""
737
  "Once you enter the list above and save this page, the plugin will display "
738
  "the titles of the posts below for your reference. Only IDs corresponding to "
739
  "published posts or custom post types will be retained."
740
  msgstr ""
741
 
742
- #: admin/metabox.php:136
743
  #, php-format
744
  msgid "This post type is: %s"
745
  msgstr ""
746
 
747
- #: admin/metabox.php:147
748
  msgid "Location of thumbnail"
749
  msgstr ""
750
 
751
- #: admin/metabox.php:149
752
  msgid ""
753
  "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This "
754
  "image will be used for the post. It will be resized to the thumbnail size "
755
  "set under Settings &raquo; Related Posts &raquo; Output Options"
756
  msgstr ""
757
 
758
- #: admin/metabox.php:150
759
  msgid "The URL above is saved in the meta field:"
760
  msgstr ""
761
 
762
- #: admin/metabox.php:155
763
  msgid ""
764
  "You have Top 10 WordPress Plugin installed. If you are trying to modify the "
765
  "thumbnail, then you'll need to make the same change in the Top 10 meta box "
@@ -818,19 +837,19 @@ msgstr ""
818
  msgid "Follow us"
819
  msgstr ""
820
 
821
- #: contextual-related-posts.php:262
822
- #, php-format
823
- msgid "Powered by <a href=\"%s\" rel=\"nofollow\">Contextual Related Posts</a>"
824
- msgstr ""
825
-
826
- #: contextual-related-posts.php:816
827
  msgid "<h3>Related Posts:</h3>"
828
  msgstr ""
829
 
830
- #: contextual-related-posts.php:818
831
  msgid "No related posts found"
832
  msgstr ""
833
 
 
 
 
 
 
834
  #: includes/media.php:65
835
  msgid "thumb_timthumb argument has been deprecated"
836
  msgstr ""
@@ -847,59 +866,59 @@ msgstr ""
847
  msgid "Related Posts [CRP]"
848
  msgstr ""
849
 
850
- #: includes/modules/class-crp-widget.php:33
851
  msgid "Display Related Posts"
852
  msgstr ""
853
 
854
- #: includes/modules/class-crp-widget.php:69
855
  msgid "Title"
856
  msgstr ""
857
 
858
- #: includes/modules/class-crp-widget.php:74
859
  msgid "No. of posts"
860
  msgstr ""
861
 
862
- #: includes/modules/class-crp-widget.php:79
863
  msgid "Offset"
864
  msgstr ""
865
 
866
- #: includes/modules/class-crp-widget.php:84
867
  msgid " Show excerpt?"
868
  msgstr ""
869
 
870
- #: includes/modules/class-crp-widget.php:89
871
  msgid " Show author?"
872
  msgstr ""
873
 
874
- #: includes/modules/class-crp-widget.php:94
875
  msgid " Show date?"
876
  msgstr ""
877
 
878
- #: includes/modules/class-crp-widget.php:100
879
  msgid "Thumbnails inline, before title"
880
  msgstr ""
881
 
882
- #: includes/modules/class-crp-widget.php:101
883
  msgid "Thumbnails inline, after title"
884
  msgstr ""
885
 
886
- #: includes/modules/class-crp-widget.php:102
887
  msgid "Only thumbnails, no text"
888
  msgstr ""
889
 
890
- #: includes/modules/class-crp-widget.php:103
891
  msgid "No thumbnails, only text."
892
  msgstr ""
893
 
894
- #: includes/modules/class-crp-widget.php:108
895
  msgid "Thumbnail height"
896
  msgstr ""
897
 
898
- #: includes/modules/class-crp-widget.php:113
899
  msgid "Thumbnail width"
900
  msgstr ""
901
 
902
- #: includes/modules/class-crp-widget.php:117
903
  msgid "Post types to include"
904
  msgstr ""
905
 
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
  "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
 
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
 
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"
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
 
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 "
281
  "different, so toggle this option to see which setting gives you better "
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
  "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
  "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
  "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 "
837
  msgid "Follow us"
838
  msgstr ""
839
 
840
+ #: contextual-related-posts.php:100
 
 
 
 
 
841
  msgid "<h3>Related Posts:</h3>"
842
  msgstr ""
843
 
844
+ #: contextual-related-posts.php:102
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 ""
852
+
853
  #: includes/media.php:65
854
  msgid "thumb_timthumb argument has been deprecated"
855
  msgstr ""
866
  msgid "Related Posts [CRP]"
867
  msgstr ""
868
 
869
+ #: includes/modules/class-crp-widget.php:34
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
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.7
8
  License: GPLv2 or later
9
 
10
  Display related posts on your WordPress blog and feed. Supports thumbnails, shortcodes, widgets and custom post types!
@@ -148,7 +148,10 @@ Usage: `<?php if ( function_exists( 'echo_crp' ) ) { echo_crp(); } ?>` to your t
148
 
149
  Takes a post ID and returns the related post IDs as an object.
150
 
151
- Usage: `<?php if ( function_exists( 'get_crp_posts_id' ) ) { get_crp_posts_id( array( 'postid' => $postid, 'limit' => $limit ) ); } ?>`
 
 
 
152
 
153
  Parameters:
154
 
@@ -178,6 +181,22 @@ In addition to the above, the shortcode takes every option that the plugin suppo
178
 
179
  == Changelog ==
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  = 2.3.1 =
182
 
183
  * Bug fixes:
@@ -316,7 +335,7 @@ For the changelog of earlier versions, please refer to the separate changelog.tx
316
 
317
  == Upgrade Notice ==
318
 
319
- = 2.3.1 =
320
- * New features. Deprecated functions. Upgrade highly recommended. Please do verify your settings after the upgrade.
321
  Check the Changelog for more details
322
 
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!
148
 
149
  Takes a post ID and returns the related post IDs as an object.
150
 
151
+ Usage: `<?php if ( function_exists( 'get_crp_posts_id' ) ) { get_crp_posts_id( array(
152
+ 'postid' => $postid,
153
+ 'limit' => $limit,
154
+ ) ); } ?>`
155
 
156
  Parameters:
157
 
181
 
182
  == Changelog ==
183
 
184
+ = 2.4.0 =
185
+
186
+ * Features:
187
+ * New option to randomize the related posts
188
+ * New option to limit related posts to the same post type
189
+ * "Automatically add related posts to" option applies to widgets
190
+
191
+ * Enhancements:
192
+ * `post_types` argument now takes a comma-separated list of post types. Default format when resaving options is also comma-separated
193
+
194
+ * Bug fixes:
195
+ * Trimming titles should now work with multibyte / non-English characters
196
+
197
+ * Deprecated:
198
+ * `crp_max_formatted_content` has been deprecated. Use `crp_trim_char` instead
199
+
200
  = 2.3.1 =
201
 
202
  * Bug fixes:
335
 
336
  == Upgrade Notice ==
337
 
338
+ = 2.4.0 =
339
+ * New features. Upgrade highly recommended. Please do verify your settings after the upgrade.
340
  Check the Changelog for more details
341
 
uninstall.php CHANGED
@@ -47,12 +47,12 @@ if ( ! is_multisite() ) {
47
  WHERE meta_key LIKE 'crp_related_posts%'
48
  " );
49
 
50
- delete_option( $option_name );
51
 
52
  }
53
 
54
  // Switch back to the current blog.
55
  restore_current_blog();
56
 
57
- }
58
 
47
  WHERE meta_key LIKE 'crp_related_posts%'
48
  " );
49
 
50
+ delete_option( $option_name );
51
 
52
  }
53
 
54
  // Switch back to the current blog.
55
  restore_current_blog();
56
 
57
+ }// End if().
58