Yet Another Related Posts Plugin (YARPP) - Version 3.5.4b4

Version Description

Download this release

Release Info

Developer mitchoyoshitaka
Plugin Icon 128x128 Yet Another Related Posts Plugin (YARPP)
Version 3.5.4b4
Comparing to
See all releases

Code changes from version 3.5.4b3 to 3.5.4b4

Files changed (5) hide show
  1. class-admin.php +75 -2
  2. class-core.php +2 -2
  3. options.php +0 -2
  4. readme.txt +12 -16
  5. yarpp.php +2 -2
class-admin.php CHANGED
@@ -17,7 +17,7 @@ class YARPP_Admin {
17
 
18
  add_action( 'admin_init', array( $this, 'ajax_register' ) );
19
  add_action( 'admin_menu', array( $this, 'ui_register' ) );
20
- add_action( 'yarpp_settings_page', array( $this, 'load_meta_boxes' ) );
21
  // new in 3.3: set default meta boxes to show:
22
  add_filter( 'default_hidden_meta_boxes', array( $this, 'default_hidden_meta_boxes' ), 10, 2 );
23
  }
@@ -66,9 +66,82 @@ class YARPP_Admin {
66
  }
67
 
68
  // 3.5.4: only load metabox code if we're going to be on the settings page
69
- function load_meta_boxes() {
 
 
 
70
  // new in 3.3: load options page sections as metaboxes
71
  require_once('options-meta-boxes.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
 
74
  // since 3.3
17
 
18
  add_action( 'admin_init', array( $this, 'ajax_register' ) );
19
  add_action( 'admin_menu', array( $this, 'ui_register' ) );
20
+ add_action( 'current_screen', array( $this, 'settings_screen' ), 10, 1 );
21
  // new in 3.3: set default meta boxes to show:
22
  add_filter( 'default_hidden_meta_boxes', array( $this, 'default_hidden_meta_boxes' ), 10, 2 );
23
  }
66
  }
67
 
68
  // 3.5.4: only load metabox code if we're going to be on the settings page
69
+ function settings_screen( $current_screen ) {
70
+ if ( $current_screen->id != 'settings_page_yarpp' )
71
+ return;
72
+
73
  // new in 3.3: load options page sections as metaboxes
74
  require_once('options-meta-boxes.php');
75
+
76
+ $current_screen->add_help_tab(array(
77
+ 'id' => 'faq',
78
+ 'title' => __('Frequently Asked Questions', 'yarpp'),
79
+ 'callback' => array( &$this, 'help_faq' )
80
+ ));
81
+
82
+ $current_screen->add_help_tab(array(
83
+ 'id' => 'dev',
84
+ 'title' => __('Developing with YARPP', 'yarpp'),
85
+ 'callback' => array( &$this, 'help_dev' )
86
+ ));
87
+ }
88
+
89
+ private $readme = null;
90
+
91
+ public function help_faq() {
92
+ if ( is_null($this->readme) )
93
+ $this->readme = file_get_contents( YARPP_DIR . '/readme.txt' );
94
+
95
+ $matches = array();
96
+ if ( preg_match('!== Frequently Asked Questions ==(.*?)^==!sm', $this->readme, $matches) )
97
+ echo $this->markdown( $matches[1] );
98
+ else
99
+ echo '<a href="https://wordpress.org/extend/plugins/yet-another-related-posts-plugin/faq/">' . __(
100
+ 'FAQ', 'yarpp') . '</a>';
101
+ }
102
+
103
+ public function help_dev() {
104
+ if ( is_null($this->readme) )
105
+ $this->readme = file_get_contents( YARPP_DIR . '/readme.txt' );
106
+
107
+ $matches = array();
108
+ if ( preg_match('!== Developing with YARPP ==(.*?)^==!sm', $this->readme, $matches) )
109
+ echo $this->markdown( $matches[1] );
110
+ else
111
+ echo '<a href="https://wordpress.org/extend/plugins/yet-another-related-posts-plugin/other_notes/">' . __(
112
+ 'Developing with YARPP', 'yarpp') . '</a>';
113
+ }
114
+
115
+ // faux-markdown, required for the help text rendering
116
+ protected function markdown( $text ) {
117
+ $replacements = array(
118
+ // strip each line
119
+ '!\s*[\r\n] *!' => "\n",
120
+
121
+ // headers
122
+ '!^=(.*?)=\s*$!m' => '<h3>\1</h3>',
123
+
124
+ // bullets
125
+ '!^(\* .*([\r\n]\* .*)*)$!m' => "<ul>\n\\1\n</ul>",
126
+ '!^\* (.*?)$!m' => '<li>\1</li>',
127
+ '!^(\d+\. .*([\r\n]\d+\. .*)*)$!m' => "<ol>\n\\1\n</ol>",
128
+ '!^\d+\. (.*?)$!m' => '<li>\1</li>',
129
+
130
+ // code block
131
+ '!^(\t.*([\r\n]\t.*)*)$!m' => "<pre>\n\\1\n</pre>",
132
+
133
+ // wrap p
134
+ '!^([^<\t].*[^>])$!m' => '<p>\1</p>',
135
+ // bold
136
+ '!\*([^*]*?)\*!' => '<strong>\1</strong>',
137
+ // code
138
+ '!`([^`]*?)`!' => '<code>\1</code>',
139
+ // links
140
+ '!\[([^]]+)\]\(([^)]+)\)!' => '<a href="\2" target="_new">\1</a>',
141
+ );
142
+ $text = preg_replace(array_keys($replacements), array_values($replacements), $text);
143
+
144
+ return $text;
145
  }
146
 
147
  // since 3.3
class-core.php CHANGED
@@ -81,7 +81,7 @@ class YARPP {
81
  'rss_after_related' => '</ol>',
82
  'rss_no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
83
  'rss_order' => 'score DESC',
84
- 'past_only' => true,
85
  'show_excerpt' => false,
86
  'rss_show_excerpt' => false,
87
  'template' => false, // new in 3.5
@@ -299,7 +299,7 @@ class YARPP {
299
  'tags' => '2',
300
  'distags' => '',
301
  'discats' => '',
302
- 'past_only' => true,
303
  'show_excerpt' => false,
304
  'recent_only' => false, // new in 3.0
305
  'use_template' => false, // new in 2.2
81
  'rss_after_related' => '</ol>',
82
  'rss_no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
83
  'rss_order' => 'score DESC',
84
+ 'past_only' => false,
85
  'show_excerpt' => false,
86
  'rss_show_excerpt' => false,
87
  'template' => false, // new in 3.5
299
  'tags' => '2',
300
  'distags' => '',
301
  'discats' => '',
302
+ 'past_only' => false,
303
  'show_excerpt' => false,
304
  'recent_only' => false, // new in 3.0
305
  'use_template' => false, // new in 2.2
options.php CHANGED
@@ -1,8 +1,6 @@
1
  <?php
2
  global $wpdb, $wp_version, $yarpp;
3
 
4
- do_action( 'yarpp_settings_page' );
5
-
6
  // Enforce YARPP setup:
7
  $yarpp->enforce();
8
 
1
  <?php
2
  global $wpdb, $wp_version, $yarpp;
3
 
 
 
4
  // Enforce YARPP setup:
5
  $yarpp->enforce();
6
 
readme.txt CHANGED
@@ -74,7 +74,7 @@ YARPP allows the advanced user with knowledge of PHP to customize the display of
74
 
75
  == Frequently Asked Questions ==
76
 
77
- If your question isn't here, ask your own question at [the Wordpress.org forums](http://wordpress.org/tags/yet-another-related-posts-plugin?forum_id=10#postform). *Please do not email with questions.*
78
 
79
  = How can I use the custom template feature? =
80
 
@@ -90,22 +90,15 @@ If you would like to add the Related Posts display elsewhere, edit your relevant
90
 
91
  The YARPP calculation of related content does make a little impact, yes. However, YARPP caches all of its results, so any post's results need only be calculated once. YARPP's queries have been significantly optimized in version 3.5.
92
 
93
- If you find that the YARPP database calls are still too database-intensive, try the following:
94
-
95
- * turning off "cross relate posts and pages";
96
- * turning on "show only previous posts";
97
-
98
- These options can be found in the "Relatedness" metabox which you can display from the "Screen Options" tab. All of these can improve database performance.
99
 
100
  If you are running a large site and need to throttle YARPP's computation, try the official [YARPP Experiments](http://wordpress.org/extend/plugins/yarpp-experiments/) plugin which adds this throttling functionality.
101
 
102
  If you are in the process of looking for a hosting provider whose databases will not balk under YARPP, I personally have had great success with [MediaTemple](http://www.mediatemple.net/#a_aid=4ed59d7ac5dae).
103
 
104
- = Every page just says "no related posts"! What's up with that? =
105
 
106
- Most likely you have "no related posts" right now as the default "match threshold" is too high. Here's what I recommend to find an appropriate match threshold: , lower your match threshold in the YARPP options to something very low, like 1. (If you don't see the match threshold, you may need to display the "Relatedness" options via the "Screen Options" at the top.) Most likely the really low threshold will pull up many posts that aren't actually related (false positives), so look at some of your posts' related posts and their match scores. This will help you find an appropriate threshold. You want it lower than what you have now, but high enough so it doesn't have many false positives.
107
-
108
- I am currently seeking information from users who cannot get related posts anywhere in order to debug this issue: [more information here](http://wordpress.org/support/topic/no-related-posts-1?replies=21#post-2464940).
109
 
110
  = Are there any plugins that are incompatible with YARPP? =
111
 
@@ -115,7 +108,7 @@ I am currently seeking information from users who cannot get related posts anywh
115
  * [WP Contact Form III plugin and Contact Form Plugin](http://wordpress.org/support/topic/392605);
116
  * Other related posts plugins, obviously, may also be incompatible.
117
 
118
- Please submit similar bugs by starting a new thread on [the WordPress.org forums](http://wordpress.org/tags/yet-another-related-posts-plugin?forum_id=10#postform). I check the forums regularly and will try to release a quick bugfix.
119
 
120
  = Does YARPP work with full-width characters or languages that don't use spaces between words? =
121
 
@@ -163,7 +156,7 @@ Developers can call YARPP's powerful relatedness algorithm from anywhere in thei
163
  ),
164
  // The threshold which must be met by the "match score"
165
  'threshold' => 5,
166
-
167
  // Display options:
168
  'template' => , // either the name of a file in your active theme or the boolean false to use the builtin template
169
  'limit' => 5, // maximum number of results
@@ -239,10 +232,13 @@ If you are a bilingual speaker of English and another language and an avid user
239
 
240
  = 3.5.4 =
241
 
 
242
  * Retina icons! Now served faster, in sprite form.
243
- * Bugfix: stopwords would not be loaded if WPLANG is defined but blank.
244
- * Added new `stats` method to `YARPP_Cache_*` objects.
245
- * Added `yarpp_settings_page` action to the options page and use it to load meta box code.
 
 
246
 
247
  = 3.5.3 =
248
 
74
 
75
  == Frequently Asked Questions ==
76
 
77
+ If your question isn't here, ask your own question at [the WordPress.org forums](http://wordpress.org/support/plugin/yet-another-related-posts-plugin). *Please do not email with questions.*
78
 
79
  = How can I use the custom template feature? =
80
 
90
 
91
  The YARPP calculation of related content does make a little impact, yes. However, YARPP caches all of its results, so any post's results need only be calculated once. YARPP's queries have been significantly optimized in version 3.5.
92
 
93
+ If you find that the YARPP database calls are still too database-intensive, try turning off "display results from all post types." This option can be found in the "Relatedness" metabox which you can display from the "Screen Options" tab.
 
 
 
 
 
94
 
95
  If you are running a large site and need to throttle YARPP's computation, try the official [YARPP Experiments](http://wordpress.org/extend/plugins/yarpp-experiments/) plugin which adds this throttling functionality.
96
 
97
  If you are in the process of looking for a hosting provider whose databases will not balk under YARPP, I personally have had great success with [MediaTemple](http://www.mediatemple.net/#a_aid=4ed59d7ac5dae).
98
 
99
+ = Many pages list "no related posts". =
100
 
101
+ Most likely you have "no related posts" right now as the default "match threshold" is too high. Here's what I recommend to find an appropriate match threshold: lower your match threshold in the YARPP options to something very low, like 1. (If you don't see the match threshold, you may need to display the "Relatedness" options via the "Screen Options" tab at the top.) Most likely the really low threshold will pull up many posts that aren't actually related (false positives), so look at some of your posts' related posts and their match scores. This will help you find an appropriate threshold. You want it lower than what you have now, but high enough so it doesn't have many false positives.
 
 
102
 
103
  = Are there any plugins that are incompatible with YARPP? =
104
 
108
  * [WP Contact Form III plugin and Contact Form Plugin](http://wordpress.org/support/topic/392605);
109
  * Other related posts plugins, obviously, may also be incompatible.
110
 
111
+ Please submit similar bugs by starting a new thread on [the WordPress.org forums](http://wordpress.org/support/plugin/yet-another-related-posts-plugin). I check the forums regularly and will try to release a quick bugfix.
112
 
113
  = Does YARPP work with full-width characters or languages that don't use spaces between words? =
114
 
156
  ),
157
  // The threshold which must be met by the "match score"
158
  'threshold' => 5,
159
+
160
  // Display options:
161
  'template' => , // either the name of a file in your active theme or the boolean false to use the builtin template
162
  'limit' => 5, // maximum number of results
232
 
233
  = 3.5.4 =
234
 
235
+ * New Help tab, which displays help text from the readme.
236
  * Retina icons! Now served faster, in sprite form.
237
+ * Cleanup:
238
+ * Bugfix: stopwords would not be loaded if WPLANG is defined but blank.
239
+ * Added new `stats` method to `YARPP_Cache_*` objects.
240
+ * Load meta boxes on `screen_option` hook. Improves performance on admin pages.
241
+ * Changed default option of "show only previous posts" to `false` and removed FAQ text, as it no longer improves performance much.
242
 
243
  = 3.5.3 =
244
 
yarpp.php CHANGED
@@ -3,13 +3,13 @@
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://yarpp.org/
5
  Description: Returns a list of related entries based on a unique algorithm for display on your blog and RSS feeds. Now with custom post type support!
6
- Version: 3.5.4b3
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: http://tinyurl.com/donatetomitcho
10
  */
11
 
12
- define('YARPP_VERSION', '3.5.4b3');
13
  define('YARPP_DIR', dirname(__FILE__));
14
  define('YARPP_NO_RELATED', ':(');
15
  define('YARPP_RELATED', ':)');
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://yarpp.org/
5
  Description: Returns a list of related entries based on a unique algorithm for display on your blog and RSS feeds. Now with custom post type support!
6
+ Version: 3.5.4b4
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: http://tinyurl.com/donatetomitcho
10
  */
11
 
12
+ define('YARPP_VERSION', '3.5.4b4');
13
  define('YARPP_DIR', dirname(__FILE__));
14
  define('YARPP_NO_RELATED', ':(');
15
  define('YARPP_RELATED', ':)');