Yet Another Related Posts Plugin (YARPP) - Version 3.4b5

Version Description

Download this release

Release Info

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

Code changes from version 3.4b4 to 3.4b5

cache-postmeta.php CHANGED
@@ -6,10 +6,13 @@ define('YARPP_POSTMETA_KEYWORDS_KEY','_yarpp_keywords');
6
define('YARPP_POSTMETA_RELATED_KEY', '_yarpp_related');
7
8
class YARPP_Cache_Postmeta {
9
// variables used for lookup
10
private $related_postdata = array();
11
private $related_IDs = array();
12
public $name = "postmeta";
13
private $yarpp_time = false;
14
public $demo_time = false;
15
public $score_override = false;
@@ -18,8 +21,8 @@ class YARPP_Cache_Postmeta {
18
/**
19
* SETUP/STATUS
20
*/
21
- function YARPP_Cache_Postmeta() {
22
- $this->name = __($this->name, 'yarpp');
23
add_filter('posts_where',array(&$this,'where_filter'));
24
add_filter('posts_orderby',array(&$this,'orderby_filter'));
25
add_filter('posts_fields',array(&$this,'fields_filter'));
@@ -165,7 +168,7 @@ class YARPP_Cache_Postmeta {
165
166
// @return YARPP_NO_RELATED | YARPP_RELATED | YARPP_NOT_CACHED
167
public function update($reference_ID) {
168
- global $wpdb, $yarpp_debug;
169
170
// $reference_ID must be numeric
171
if ( !$reference_ID = absint($reference_ID) )
@@ -177,7 +180,7 @@ class YARPP_Cache_Postmeta {
177
178
if ( count($new_related) ) {
179
update_post_meta($reference_ID, YARPP_POSTMETA_RELATED_KEY, $related);
180
- if ($yarpp_debug) echo "<!--YARPP just set the cache for post $reference_ID-->";
181
182
// Clear the caches of any items which are no longer related or are newly related.
183
if (count($original_related)) {
@@ -240,8 +243,8 @@ class YARPP_Cache_Postmeta {
240
// @return (array) with body and title keywords
241
private function cache_keywords($ID) {
242
$keywords = array(
243
- 'body' => post_body_keywords($ID),
244
- 'title' => post_title_keywords($ID)
245
);
246
update_post_meta($ID, YARPP_POSTMETA_KEYWORDS_KEY, $keywords);
247
return $keywords;
6
define('YARPP_POSTMETA_RELATED_KEY', '_yarpp_related');
7
8
class YARPP_Cache_Postmeta {
9
+
10
// variables used for lookup
11
private $related_postdata = array();
12
private $related_IDs = array();
13
+
14
public $name = "postmeta";
15
+
16
private $yarpp_time = false;
17
public $demo_time = false;
18
public $score_override = false;
21
/**
22
* SETUP/STATUS
23
*/
24
+ function __construct( &$core ) {
25
+ parent::__construct( $core );
26
add_filter('posts_where',array(&$this,'where_filter'));
27
add_filter('posts_orderby',array(&$this,'orderby_filter'));
28
add_filter('posts_fields',array(&$this,'fields_filter'));
168
169
// @return YARPP_NO_RELATED | YARPP_RELATED | YARPP_NOT_CACHED
170
public function update($reference_ID) {
171
+ global $wpdb;
172
173
// $reference_ID must be numeric
174
if ( !$reference_ID = absint($reference_ID) )
180
181
if ( count($new_related) ) {
182
update_post_meta($reference_ID, YARPP_POSTMETA_RELATED_KEY, $related);
183
+ if ($this->core->debug) echo "<!--YARPP just set the cache for post $reference_ID-->";
184
185
// Clear the caches of any items which are no longer related or are newly related.
186
if (count($original_related)) {
243
// @return (array) with body and title keywords
244
private function cache_keywords($ID) {
245
$keywords = array(
246
+ 'body' => $this->body_keywords($ID),
247
+ 'title' => $this->title_keywords($ID)
248
);
249
update_post_meta($ID, YARPP_POSTMETA_KEYWORDS_KEY, $keywords);
250
return $keywords;
cache-tables.php CHANGED
@@ -5,7 +5,7 @@ $yarpp_storage_class = 'YARPP_Cache_Tables';
5
define('YARPP_TABLES_RELATED_TABLE', 'yarpp_related_cache');
6
define('YARPP_TABLES_KEYWORDS_TABLE', 'yarpp_keyword_cache');
7
8
- class YARPP_Cache_Tables {
9
public $name = "custom tables";
10
private $yarpp_time = false;
11
public $demo_time = false;
@@ -15,8 +15,8 @@ class YARPP_Cache_Tables {
15
/**
16
* SETUP/STATUS
17
*/
18
- function YARPP_Cache_Tables() {
19
- $this->name = __($this->name, 'yarpp');
20
add_filter('posts_join',array(&$this,'join_filter'));
21
add_filter('posts_where',array(&$this,'where_filter'));
22
add_filter('posts_orderby',array(&$this,'orderby_filter'));
@@ -192,7 +192,7 @@ class YARPP_Cache_Tables {
192
193
// @return YARPP_RELATED | YARPP_NO_RELATED | YARPP_NOT_CACHED
194
public function update($reference_ID) {
195
- global $wpdb, $yarpp_debug;
196
197
// $reference_ID must be numeric
198
if ( !$reference_ID = absint($reference_ID) )
@@ -209,7 +209,7 @@ class YARPP_Cache_Tables {
209
if ( $wpdb->rows_affected ) {
210
$new_related = $this->related($reference_ID);
211
212
- if ($yarpp_debug) echo "<!--YARPP just set the cache for post $reference_ID-->";
213
214
// Clear the caches of any items which are no longer related or are newly related.
215
if (count($original_related)) {
@@ -268,8 +268,8 @@ class YARPP_Cache_Tables {
268
// @return (array) with body and title keywords
269
private function cache_keywords($ID) {
270
global $wpdb;
271
- $body_terms = post_body_keywords($ID);
272
- $title_terms = post_title_keywords($ID);
273
274
if (defined('DB_CHARSET') && DB_CHARSET) {
275
$wpdb->query('set names '.DB_CHARSET);
5
define('YARPP_TABLES_RELATED_TABLE', 'yarpp_related_cache');
6
define('YARPP_TABLES_KEYWORDS_TABLE', 'yarpp_keyword_cache');
7
8
+ class YARPP_Cache_Tables extends YARPP_Cache {
9
public $name = "custom tables";
10
private $yarpp_time = false;
11
public $demo_time = false;
15
/**
16
* SETUP/STATUS
17
*/
18
+ function __construct( &$core ) {
19
+ parent::__construct( $core );
20
add_filter('posts_join',array(&$this,'join_filter'));
21
add_filter('posts_where',array(&$this,'where_filter'));
22
add_filter('posts_orderby',array(&$this,'orderby_filter'));
192
193
// @return YARPP_RELATED | YARPP_NO_RELATED | YARPP_NOT_CACHED
194
public function update($reference_ID) {
195
+ global $wpdb;
196
197
// $reference_ID must be numeric
198
if ( !$reference_ID = absint($reference_ID) )
209
if ( $wpdb->rows_affected ) {
210
$new_related = $this->related($reference_ID);
211
212
+ if ($this->core->debug) echo "<!--YARPP just set the cache for post $reference_ID-->";
213
214
// Clear the caches of any items which are no longer related or are newly related.
215
if (count($original_related)) {
268
// @return (array) with body and title keywords
269
private function cache_keywords($ID) {
270
global $wpdb;
271
+ $body_terms = $this->body_keywords($ID);
272
+ $title_terms = $this->title_keywords($ID);
273
274
if (defined('DB_CHARSET') && DB_CHARSET) {
275
$wpdb->query('set names '.DB_CHARSET);
includes.php CHANGED
@@ -1,8 +1,424 @@
1
<?php
2
3
require_once(YARPP_DIR.'/magic.php');
4
- require_once(YARPP_DIR.'/keywords.php');
5
- require_once(YARPP_DIR.'/intl.php');
6
require_once(YARPP_DIR.'/services.php');
7
8
if ( !defined('WP_CONTENT_URL') )
@@ -41,9 +457,7 @@ $yarpp_value_options = array(
41
'title' => 2,
42
'body' => 2,
43
'categories' => 1, // changed default in 3.3
44
- 'tags' => 2,
45
- 'distags' => '',
46
- 'discats' => '');
47
$yarpp_binary_options = array(
48
'past_only' => true,
49
'show_excerpt' => false,
@@ -61,120 +475,9 @@ $yarpp_binary_options = array(
61
'myisam_override' => false);
62
// These are options which, when updated, will trigger a clearing of the cache
63
$yarpp_clear_cache_options = array(
64
- 'distags','discats','show_pass_post','recent_only','threshold','title','body','categories',
65
'tags');
66
67
- function yarpp_enabled() {
68
- global $wpdb, $yarpp_cache;
69
- if ($yarpp_cache->is_enabled() === false)
70
- return false;
71
- $indexdata = $wpdb->get_results("show index from $wpdb->posts");
72
- foreach ($indexdata as $index) {
73
- if ($index->Key_name == 'yarpp_title')
74
- return true;
75
- }
76
- return false;
77
- }
78
-
79
- function yarpp_activate() {
80
- global $yarpp_version, $wpdb, $yarpp_cache;
81
-
82
- $wpdb->get_results("show index from $wpdb->posts where Key_name='yarpp_title'");
83
- if (!$wpdb->num_rows)
84
- $wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_title` ( `post_title` )");
85
-
86
- $wpdb->get_results("show index from $wpdb->posts where Key_name='yarpp_content'");
87
- if (!$wpdb->num_rows)
88
- $wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_content` ( `post_content` )");
89
-
90
- if ( !yarpp_enabled() ) {
91
- // If we are still not enabled, run the cache abstraction's setup method.
92
- $yarpp_cache->setup();
93
- // If we're still not enabled, give up.
94
- if ( !yarpp_enabled() )
95
- return 0;
96
- }
97
-
98
- if ( !get_option('yarpp_version') ) {
99
- add_option( 'yarpp_version', YARPP_VERSION );
100
- yarpp_version_info(true);
101
- } else {
102
- yarpp_upgrade_check();
103
- }
104
-
105
- return 1;
106
- }
107
-
108
- function yarpp_myisam_check() {
109
- global $wpdb;
110
- $tables = $wpdb->get_results("show table status like '{$wpdb->posts}'");
111
- foreach ($tables as $table) {
112
- if ($table->Engine == 'MyISAM') return true;
113
- else return $table->Engine;
114
- }
115
- return 'UNKNOWN';
116
- }
117
-
118
- function yarpp_upgrade_check() {
119
- global $yarpp_cache;
120
-
121
- $last_version = get_option( 'yarpp_version' );
122
- if (version_compare(YARPP_VERSION, $last_version) === 0)
123
- return;
124
-
125
- if ( $last_version && version_compare('3.4b2', $last_version) > 0 ) {
126
- yarpp_upgrade_3_4();
127
- }
128
-
129
- $yarpp_cache->upgrade($last_version);
130
-
131
- yarpp_version_info(true);
132
-
133
- update_option('yarpp_version',YARPP_VERSION);
134
- }
135
-
136
- function yarpp_upgrade_3_4() {
137
- global $wpdb, $yarpp_value_options, $yarpp_binary_options;
138
-
139
- $yarpp_options = array();
140
- foreach ( $yarpp_value_options as $key => $default ) {
141
- $value = get_option( "yarpp_$key", null );
142
- if ( is_null($value) )
143
- continue;
144
-
145
- // value options used to be stored with a bajillion slashes...
146
- $value = stripslashes(stripslashes($value));
147
- // value options used to be stored with a blank space at the end... don't ask.
148
- $value = rtrim($value, ' ');
149
-
150
- if ( is_int($default) )
151
- $yarpp_options[$key] = absint($value);
152
- else
153
- $yarpp_options[$key] = $value;
154
- }
155
- foreach ( $yarpp_binary_options as $key => $default ) {
156
- $value = get_option( "yarpp_$key", null );
157
- if ( is_null($value) )
158
- continue;
159
- $yarpp_options[$key] = (boolean) $value;
160
- }
161
-
162
- // add the options directly first, then call set_option which will ensure defaults,
163
- // in case any new options have been added.
164
- update_option( 'yarpp', $yarpp_options );
165
- yarpp_set_option( $yarpp_options );
166
-
167
- $option_keys = array_keys( $yarpp_options );
168
- // append some keys for options which are long deprecated:
169
- $option_keys[] = 'ad_hoc_caching';
170
- $option_keys[] = 'excerpt_len';
171
- $option_keys[] = 'show_score';
172
- if ( count($option_keys) ) {
173
- $in = "('yarpp_" . join("', 'yarpp_", $option_keys) . "')";
174
- $wpdb->query("delete from {$wpdb->options} where option_name in {$in}");
175
- }
176
- }
177
-
178
function yarpp_admin_menu() {
179
$hook = add_options_page(__('Related Posts (YARPP)','yarpp'),__('Related Posts (YARPP)','yarpp'), 'manage_options', 'yarpp', 'yarpp_options_page');
180
add_action("load-$hook",'yarpp_load_thickbox');
@@ -190,6 +493,7 @@ function yarpp_admin_enqueue() {
190
if (is_object($current_screen) && $current_screen->id == 'settings_page_yarpp') {
191
wp_enqueue_script( 'postbox' );
192
wp_enqueue_style( 'yarpp_options', plugins_url( 'options.css', __FILE__ ), array(), YARPP_VERSION );
193
}
194
}
195
@@ -203,9 +507,7 @@ function yarpp_settings_link($links, $file) {
203
204
function yarpp_load_thickbox() {
205
wp_enqueue_script( 'thickbox' );
206
- if (function_exists('wp_enqueue_style')) {
207
- wp_enqueue_style( 'thickbox' );
208
- }
209
}
210
211
function yarpp_options_page() {
@@ -355,14 +657,8 @@ function yarpp_rss_excerpt($content) {
355
if (!defined('LOREMIPSUM'))
356
define('LOREMIPSUM','Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras tincidunt justo a urna. Ut turpis. Phasellus convallis, odio sit amet cursus convallis, eros orci scelerisque velit, ut sodales neque nisl at ante. Suspendisse metus. Curabitur auctor pede quis mi. Pellentesque lorem justo, condimentum ac, dapibus sit amet, ornare et, erat. Quisque velit. Etiam sodales dui feugiat neque suscipit bibendum. Integer mattis. Nullam et ante non sem commodo malesuada. Pellentesque ultrices fermentum lectus. Maecenas hendrerit neque ac est. Fusce tortor mi, tristique sed, cursus at, pellentesque non, dui. Suspendisse potenti.');
357
358
- function yarpp_excerpt($content,$length) {
359
- $content = strip_tags( (string) $content );
360
- preg_replace('/([,;.-]+)\s*/','\1 ',$content);
361
- return implode(' ',array_slice(preg_split('/\s+/',$content),0,$length)).'...';
362
- }
363
-
364
function yarpp_set_option($options, $value = null) {
365
- global $yarpp_clear_cache_options, $yarpp_cache;
366
367
$current_options = yarpp_get_option();
368
@@ -373,9 +669,10 @@ function yarpp_set_option($options, $value = null) {
373
$new_options = array_merge( $current_options, $options );
374
375
// new in 3.1: clear cache when updating certain settings.
376
- $new_options_which_require_flush = array_intersect( array_keys( array_diff($options, $current_options) ), $yarpp_clear_cache_options );
377
- if ( count($new_options_which_require_flush) )
378
- $yarpp_cache->flush();
379
380
update_option( 'yarpp', $new_options );
381
}
@@ -386,6 +683,8 @@ function yarpp_get_option($option = null) {
386
$options = get_option( 'yarpp' );
387
// ensure defaults if not set:
388
$options = array_merge( $yarpp_value_options, $yarpp_binary_options, $options );
389
390
if ( is_null( $option ) )
391
return $options;
@@ -394,35 +693,13 @@ function yarpp_get_option($option = null) {
394
return null;
395
}
396
397
- function yarpp_microtime_float() {
398
- list($usec, $sec) = explode(" ", microtime());
399
- return ((float)$usec + (float)$sec);
400
- }
401
-
402
- // new in 3.3: use PHP serialized format instead of JSON
403
- function yarpp_version_info($enforce_cache = false) {
404
- if (false === ($result = get_transient('yarpp_version_info')) || $enforce_cache) {
405
- $version = YARPP_VERSION;
406
- $remote = wp_remote_post("http://mitcho.com/code/yarpp/checkversion.php?format=php&version={$version}");
407
-
408
- if (is_wp_error($remote))
409
- return false;
410
-
411
- $result = unserialize($remote['body']);
412
- set_transient('yarpp_version_info', $result, 60*60*12);
413
- }
414
- return $result;
415
- }
416
-
417
function yarpp_add_metabox() {
418
- if (function_exists('add_meta_box')) {
419
- add_meta_box( 'yarpp_relatedposts', __( 'Related Posts' , 'yarpp') . ' <span class="postbox-title-action"><a href="' . esc_url( admin_url('options-general.php?page=yarpp') ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>', 'yarpp_metabox', 'post', 'normal' );
420
- }
421
}
422
function yarpp_metabox() {
423
global $post;
424
echo '<style>#yarpp_relatedposts h3 .postbox-title-action { right: 30px; top: 5px; position: absolute; padding: 0 }</style><div id="yarpp-related-posts">';
425
- if ($post->ID)
426
yarpp_related(array('post'),array('limit'=>1000),true,false,'metabox');
427
else
428
echo "<p>".__("Related entries may be displayed once you save your entry",'yarpp').".</p>";
1
<?php
2
3
+ // new in 3.4: put everything YARPP into an object, expected to be a singleton global $yarpp
4
+ class YARPP {
5
+
6
+ public $debug = false;
7
+
8
+ public $cache;
9
+ private $storage_class;
10
+
11
+ function __construct() {
12
+ require_once(YARPP_DIR . '/cache-' . YARPP_CACHE_TYPE . '.php');
13
+ $this->storage_class = $yarpp_storage_class;
14
+ $this->cache = new $this->storage_class( $this );
15
+
16
+ // update cache on save
17
+ add_action('save_post', array($this->cache, 'save_post') );
18
+ // new in 3.2: update cache on delete
19
+ add_action('delete_post', array($this->cache, 'delete_post') );
20
+ // new in 3.2.1: handle post_status transitions
21
+ add_action('transition_post_status', array($this->cache, 'transition_post_status'), 10, 3);
22
+ }
23
+
24
+ /*
25
+ * INFRASTRUCTURE
26
+ */
27
+
28
+ function enabled() {
29
+ global $wpdb;
30
+ if ( $this->cache->is_enabled() === false )
31
+ return false;
32
+ $indexdata = $wpdb->get_results("show index from $wpdb->posts");
33
+ foreach ($indexdata as $index) {
34
+ if ($index->Key_name == 'yarpp_title')
35
+ return true;
36
+ }
37
+ return false;
38
+ }
39
+
40
+ function activate() {
41
+ global $yarpp_version, $wpdb;
42
+
43
+ $wpdb->get_results("show index from $wpdb->posts where Key_name='yarpp_title'");
44
+ if (!$wpdb->num_rows)
45
+ $wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_title` ( `post_title` )");
46
+
47
+ $wpdb->get_results("show index from $wpdb->posts where Key_name='yarpp_content'");
48
+ if (!$wpdb->num_rows)
49
+ $wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_content` ( `post_content` )");
50
+
51
+ if ( !$this->enabled() ) {
52
+ // If we are still not enabled, run the cache abstraction's setup method.
53
+ $this->cache->setup();
54
+ // If we're still not enabled, give up.
55
+ if ( !$this->enabled() )
56
+ return 0;
57
+ }
58
+
59
+ if ( !get_option('yarpp_version') ) {
60
+ add_option( 'yarpp_version', YARPP_VERSION );
61
+ $this->version_info(true);
62
+ } else {
63
+ $this->upgrade_check();
64
+ }
65
+
66
+ return 1;
67
+ }
68
+
69
+ function myisam_check() {
70
+ global $wpdb;
71
+ $tables = $wpdb->get_results("show table status like '{$wpdb->posts}'");
72
+ foreach ($tables as $table) {
73
+ if ($table->Engine == 'MyISAM') return true;
74
+ else return $table->Engine;
75
+ }
76
+ return 'UNKNOWN';
77
+ }
78
+
79
+ function upgrade_check() {
80
+ $last_version = get_option( 'yarpp_version' );
81
+ if (version_compare(YARPP_VERSION, $last_version) === 0)
82
+ return;
83
+
84
+ if ( $last_version && version_compare('3.4b2', $last_version) > 0 )
85
+ $this->upgrade_3_4b2();
86
+ if ( $last_version && version_compare('3.4b5', $last_version) > 0 )
87
+ $this->upgrade_3_4b5();
88
+
89
+ $this->cache->upgrade($last_version);
90
+
91
+ $this->version_info(true);
92
+
93
+ update_option('yarpp_version',YARPP_VERSION);
94
+ }
95
+
96
+ function upgrade_3_4b2() {
97
+ global $wpdb, $yarpp_value_options, $yarpp_binary_options;
98
+
99
+ $yarpp_options = array();
100
+ foreach ( $yarpp_value_options as $key => $default ) {
101
+ $value = get_option( "yarpp_$key", null );
102
+ if ( is_null($value) )
103
+ continue;
104
+
105
+ // value options used to be stored with a bajillion slashes...
106
+ $value = stripslashes(stripslashes($value));
107
+ // value options used to be stored with a blank space at the end... don't ask.
108
+ $value = rtrim($value, ' ');
109
+
110
+ if ( is_int($default) )
111
+ $yarpp_options[$key] = absint($value);
112
+ else
113
+ $yarpp_options[$key] = $value;
114
+ }
115
+ foreach ( $yarpp_binary_options as $key => $default ) {
116
+ $value = get_option( "yarpp_$key", null );
117
+ if ( is_null($value) )
118
+ continue;
119
+ $yarpp_options[$key] = (boolean) $value;
120
+ }
121
+
122
+ // add the options directly first, then call set_option which will ensure defaults,
123
+ // in case any new options have been added.
124
+ update_option( 'yarpp', $yarpp_options );
125
+ yarpp_set_option( $yarpp_options );
126
+
127
+ $option_keys = array_keys( $yarpp_options );
128
+ // append some keys for options which are long deprecated:
129
+ $option_keys[] = 'ad_hoc_caching';
130
+ $option_keys[] = 'excerpt_len';
131
+ $option_keys[] = 'show_score';
132
+ if ( count($option_keys) ) {
133
+ $in = "('yarpp_" . join("', 'yarpp_", $option_keys) . "')";
134
+ $wpdb->query("delete from {$wpdb->options} where option_name in {$in}");
135
+ }
136
+ }
137
+
138
+ function upgrade_3_4b5() {
139
+ $options = yarpp_get_option();
140
+ $options['exclude'] = array(
141
+ 'post_tag' => $options['distags'],
142
+ 'category' => $options['discats']
143
+ );
144
+ unset( $options['distags'] );
145
+ unset( $options['discats'] );
146
+ update_option( 'yarpp', $options );
147
+ }
148
+
149
+ /*
150
+ * UTILS
151
+ */
152
+
153
+ // new in 3.3: use PHP serialized format instead of JSON
154
+ function version_info( $enforce_cache = false ) {
155
+ if (false === ($result = get_transient('yarpp_version_info')) || $enforce_cache) {
156
+ $version = YARPP_VERSION;
157
+ $remote = wp_remote_post("http://mitcho.com/code/yarpp/checkversion.php?format=php&version={$version}");
158
+
159
+ if (is_wp_error($remote))
160
+ return false;
161
+
162
+ $result = unserialize($remote['body']);
163
+ set_transient('yarpp_version_info', $result, 60*60*12);
164
+ }
165
+ return $result;
166
+ }
167
+
168
+ }
169
+
170
+ abstract class YARPP_Cache {
171
+
172
+ public $core;
173
+
174
+ function __construct( &$core ) {
175
+ $this->core = &$core;
176
+ $this->name = __($this->name, 'yarpp');
177
+ }
178
+
179
+ // Note: return value changed in 3.4
180
+ // return YARPP_NO_RELATED | YARPP_RELATED | YARPP_DONT_RUN | false if no good input
181
+ function enforce($reference_ID, $force = false) {
182
+ if ( !$reference_ID = absint($reference_ID) )
183
+ return false;
184
+
185
+ $status = $this->is_cached($reference_ID);
186
+ $status = apply_filters( 'yarpp_cache_enforce_status', $status, $reference_ID );
187
+
188
+ // There's a stop signal:
189
+ if ( YARPP_DONT_RUN === $status )
190
+ return YARPP_DONT_RUN;
191
+
192
+ // If not cached, process now:
193
+ if ( YARPP_NOT_CACHED == $status || $force ) {
194
+ $status = $this->update($reference_ID);
195
+ // if still not cached, there's a problem, but for the time being return NO RELATED
196
+ if ( YARPP_NOT_CACHED === $status )
197
+ return YARPP_NO_RELATED;
198
+ }
199
+
200
+ // There are no related posts
201
+ if ( YARPP_NO_RELATED === $status )
202
+ return YARPP_NO_RELATED;
203
+
204
+ // There are results
205
+ return YARPP_RELATED;
206
+ }
207
+
208
+ /*
209
+ * POST STATUS INTERACTIONS
210
+ */
211
+
212
+ function save_post($post_ID, $force=true) {
213
+ global $wpdb;
214
+
215
+ // new in 3.2: don't compute cache during import
216
+ if ( defined( 'WP_IMPORTING' ) )
217
+ return;
218
+
219
+ $sql = "select post_parent from $wpdb->posts where ID='$post_ID'";
220
+ $parent_ID = $wpdb->get_var($sql);
221
+
222
+ if ( $parent_ID != $post_ID && $parent_ID )
223
+ $post_ID = $parent_ID;
224
+
225
+ $this->enforce((int) $post_ID, $force);
226
+ }
227
+
228
+ // Clear the cache for this entry and for all posts which are "related" to it.
229
+ // New in 3.2: This is called when a post is deleted.
230
+ function delete_post($post_ID) {
231
+ // Clear the cache for this post.
232
+ $this->clear($post_ID);
233
+
234
+ // Find all "peers" which list this post as a related post.
235
+ $peers = $this->related(null, $post_ID);
236
+ // Clear the peers' caches.
237
+ $this->clear($peers);
238
+ }
239
+
240
+ // New in 3.2.1: handle various post_status transitions
241
+ function transition_post_status($new_status, $old_status, $post) {
242
+ switch ($new_status) {
243
+ case "draft":
244
+ $this->delete_post($post->ID);
245
+ break;
246
+ case "publish":
247
+ // find everything which is related to this post, and clear them, so that this
248
+ // post might show up as related to them.
249
+ $related = $this->related($post->ID, null);
250
+ $this->clear($related);
251
+ }
252
+ }
253
+
254
+ /*
255
+ * KEYWORDS
256
+ */
257
+
258
+ public function title_keywords($ID,$max = 20) {
259
+ return $this->extract_keywords(get_the_title($ID),$max);
260
+ }
261
+
262
+ public function body_keywords( $ID, $max = 20 ) {
263
+ $post = get_post( $ID );
264
+ if ( empty($post) )
265
+ return '';
266
+ $content = $this->apply_filters_if_white( 'the_content', $post->post_content );
267
+ return $this->extract_keywords( $content, $max );
268
+ }
269
+
270
+ private function extract_keywords($html, $max = 20) {
271
+
272
+ $lang = 'en_US';
273
+ if ( defined('WPLANG') ) {
274
+ $lang = substr(WPLANG, 0, 2);
275
+ switch ( $lang ) {
276
+ case 'de':
277
+ $lang = 'de_DE';
278
+ case 'it':
279
+ $lang = 'it_IT';
280
+ case 'pl':
281
+ $lang = 'pl_PL';
282
+ case 'bg':
283
+ $lang = 'bg_BG';
284
+ case 'fr':
285
+ $lang = 'fr_FR';
286
+ case 'cs':
287
+ $lang = 'cs_CZ';
288
+ case 'nl':
289
+ $lang = 'nl_NL';
290
+ }
291
+ }
292
+
293
+ $words_file = YARPP_DIR . '/lang/words-' . $lang . '.php';
294
+ if ( file_exists($words_file) )
295
+ include( $words_file );
296
+ if ( !isset($overusedwords) )
297
+ $overusedwords = array();
298
+
299
+ // strip tags and html entities
300
+ $text = preg_replace('/&(#x[0-9a-f]+|#[0-9]+|[a-zA-Z]+);/', '', strip_tags($html) );
301
+
302
+ // 3.2.2: ignore soft hyphens
303
+ // Requires PHP 5: http://bugs.php.net/bug.php?id=25670
304
+ $softhyphen = html_entity_decode('&#173;',ENT_NOQUOTES,'UTF-8');
305
+ $text = str_replace($softhyphen, '', $text);
306
+
307
+ $charset = get_option('blog_charset');
308
+ if ( function_exists('mb_split') && !empty($charset) ) {
309
+ mb_regex_encoding($charset);
310
+ $wordlist = mb_split('\s*\W+\s*', mb_strtolower($text, $charset));
311
+ } else
312
+ $wordlist = preg_split('%\s*\W+\s*%', strtolower($text));
313
+
314
+ // Build an array of the unique words and number of times they occur.
315
+ $tokens = array_count_values($wordlist);
316
+
317
+ // Remove the stop words from the list.
318
+ $overusedwords = apply_filters( 'yarpp_keywords_overused_words', $overusedwords );
319
+ if ( is_array($overusedwords) ) {
320
+ foreach ($overusedwords as $word) {
321
+ unset($tokens[$word]);
322
+ }
323
+ }
324
+ // Remove words which are only a letter
325
+ $mb_strlen_exists = function_exists('mb_strlen');
326
+ foreach (array_keys($tokens) as $word) {
327
+ if ($mb_strlen_exists)
328
+ if (mb_strlen($word) < 2) unset($tokens[$word]);
329
+ else
330
+ if (strlen($word) < 2) unset($tokens[$word]);
331
+ }
332
+
333
+ arsort($tokens, SORT_NUMERIC);
334
+
335
+ $types = array_keys($tokens);
336
+
337
+ if (count($types) > $max)
338
+ $types = array_slice($types, 0, $max);
339
+ return implode(' ', $types);
340
+ }
341
+
342
+ /* new in 2.0! apply_filters_if_white (previously apply_filters_without) now has a blacklist.
343
+ * It can be modified via the yarpp_blacklist and yarpp_blackmethods filters.
344
+ */
345
+ /* blacklisted so far:
346
+ - diggZ-Et
347
+ - reddZ-Et
348
+ - dzoneZ-Et
349
+ - WP-Syntax
350
+ - Viper's Video Quicktags
351
+ - WP-CodeBox
352
+ - WP shortcodes
353
+ - WP Greet Box
354
+ //- Tweet This - could not reproduce problem.
355
+ */
356
+ function white( $filter ) {
357
+ static $blacklist, $blackmethods;
358
+
359
+ if ( is_null($blacklist) || is_null($blackmethods) ) {
360
+ $yarpp_blacklist = array('yarpp_default', 'diggZEt_AddBut', 'reddZEt_AddBut', 'dzoneZEt_AddBut', 'wp_syntax_before_filter', 'wp_syntax_after_filter', 'wp_codebox_before_filter', 'wp_codebox_after_filter', 'do_shortcode');//,'insert_tweet_this'
361
+ $yarpp_blackmethods = array('addinlinejs', 'replacebbcode', 'filter_content');
362
+
363
+ $blacklist = (array) apply_filters( 'yarpp_blacklist', $yarpp_blacklist );
364
+ $blackmethods = (array) apply_filters( 'yarpp_blackmethods', $yarpp_blackmethods );
365
+ }
366
+
367
+ if ( is_array($filter) && in_array( $filter[1], $blackmethods ) )
368
+ return false;
369
+ return !in_array( $filter, $blacklist );
370
+ }
371
+
372
+ /* FYI, apply_filters_if_white was used here to avoid a loop in apply_filters('the_content') > yarpp_default() > yarpp_related() > current_post_keywords() > apply_filters('the_content').*/
373
+ function apply_filters_if_white($tag, $value) {
374
+ global $wp_filter, $merged_filters, $wp_current_filter;
375
+
376
+ $args = array();
377
+
378
+ // Do 'all' actions first
379
+ if ( isset($wp_filter['all']) ) {
380
+ $wp_current_filter[] = $tag;
381
+ $args = func_get_args();
382
+ _wp_call_all_hook($args);
383
+ }
384
+
385
+ if ( !isset($wp_filter[$tag]) ) {
386
+ if ( isset($wp_filter['all']) )
387
+ array_pop($wp_current_filter);
388
+ return $value;
389
+ }
390
+
391
+ if ( !isset($wp_filter['all']) )
392
+ $wp_current_filter[] = $tag;
393
+
394
+ // Sort
395
+ if ( !isset( $merged_filters[ $tag ] ) ) {
396
+ ksort($wp_filter[$tag]);
397
+ $merged_filters[ $tag ] = true;
398
+ }
399
+
400
+ reset( $wp_filter[ $tag ] );
401
+
402
+ if ( empty($args) )
403
+ $args = func_get_args();
404
+
405
+ do {
406
+ foreach( (array) current($wp_filter[$tag]) as $the_ )
407
+ if ( !is_null($the_['function'])
408
+ and $this->white($the_['function'])){ // HACK
409
+ $args[1] = $value;
410
+ $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
411
+ }
412
+
413
+ } while ( next($wp_filter[$tag]) !== false );
414
+
415
+ array_pop( $wp_current_filter );
416
+
417
+ return $value;
418
+ }
419
+ }
420
+
421
require_once(YARPP_DIR.'/magic.php');
422
require_once(YARPP_DIR.'/services.php');
423
424
if ( !defined('WP_CONTENT_URL') )
457
'title' => 2,
458
'body' => 2,
459
'categories' => 1, // changed default in 3.3
460
+ 'tags' => 2);
461
$yarpp_binary_options = array(
462
'past_only' => true,
463
'show_excerpt' => false,
475
'myisam_override' => false);
476
// These are options which, when updated, will trigger a clearing of the cache
477
$yarpp_clear_cache_options = array(
478
+ 'show_pass_post','recent_only','threshold','title','body','categories',
479
'tags');
480
481
function yarpp_admin_menu() {
482
$hook = add_options_page(__('Related Posts (YARPP)','yarpp'),__('Related Posts (YARPP)','yarpp'), 'manage_options', 'yarpp', 'yarpp_options_page');
483
add_action("load-$hook",'yarpp_load_thickbox');
493
if (is_object($current_screen) && $current_screen->id == 'settings_page_yarpp') {
494
wp_enqueue_script( 'postbox' );
495
wp_enqueue_style( 'yarpp_options', plugins_url( 'options.css', __FILE__ ), array(), YARPP_VERSION );
496
+ wp_enqueue_script( 'yarpp_options', plugins_url( 'options.js', __FILE__ ), array('jquery'), YARPP_VERSION );
497
}
498
}
499
507
508
function yarpp_load_thickbox() {
509
wp_enqueue_script( 'thickbox' );
510
+ wp_enqueue_style( 'thickbox' );
511
}
512
513
function yarpp_options_page() {
657
if (!defined('LOREMIPSUM'))
658
define('LOREMIPSUM','Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras tincidunt justo a urna. Ut turpis. Phasellus convallis, odio sit amet cursus convallis, eros orci scelerisque velit, ut sodales neque nisl at ante. Suspendisse metus. Curabitur auctor pede quis mi. Pellentesque lorem justo, condimentum ac, dapibus sit amet, ornare et, erat. Quisque velit. Etiam sodales dui feugiat neque suscipit bibendum. Integer mattis. Nullam et ante non sem commodo malesuada. Pellentesque ultrices fermentum lectus. Maecenas hendrerit neque ac est. Fusce tortor mi, tristique sed, cursus at, pellentesque non, dui. Suspendisse potenti.');
659
660
function yarpp_set_option($options, $value = null) {
661
+ global $yarpp_clear_cache_options, $yarpp;
662
663
$current_options = yarpp_get_option();
664
669
$new_options = array_merge( $current_options, $options );
670
671
// new in 3.1: clear cache when updating certain settings.
672
+ $new_options_which_require_flush = array_intersect( array_keys( array_diff_assoc($options, $current_options) ), $yarpp_clear_cache_options );
673
+ if ( count($new_options_which_require_flush) ||
674
+ ( isset($options['exclude']) && $options['exclude'] != $current_options['exclude'] ) )
675
+ $yarpp->cache->flush();
676
677
update_option( 'yarpp', $new_options );
678
}
683
$options = get_option( 'yarpp' );
684
// ensure defaults if not set:
685
$options = array_merge( $yarpp_value_options, $yarpp_binary_options, $options );
686
+ if ( !isset($options['exclude']) )
687
+ $options['exclude'] = array();
688
689
if ( is_null( $option ) )
690
return $options;
693
return null;
694
}
695
696
function yarpp_add_metabox() {
697
+ add_meta_box( 'yarpp_relatedposts', __( 'Related Posts' , 'yarpp') . ' <span class="postbox-title-action"><a href="' . esc_url( admin_url('options-general.php?page=yarpp') ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>', 'yarpp_metabox', 'post', 'normal' );
698
}
699
function yarpp_metabox() {
700
global $post;
701
echo '<style>#yarpp_relatedposts h3 .postbox-title-action { right: 30px; top: 5px; position: absolute; padding: 0 }</style><div id="yarpp-related-posts">';
702
+ if ( $post->ID )
703
yarpp_related(array('post'),array('limit'=>1000),true,false,'metabox');
704
else
705
echo "<p>".__("Related entries may be displayed once you save your entry",'yarpp').".</p>";
intl.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
-
3
- include( YARPP_DIR . '/lang/words-' . word_file_lang() . '.php' );
4
-
5
- function word_file_lang() {
6
- if ( !defined('WPLANG') )
7
- return 'en_US';
8
- $lang = substr(WPLANG, 0, 2);
9
- switch ( $lang ) {
10
- case 'de':
11
- return 'de_DE';
12
- case 'it':
13
- return 'it_IT';
14
- case 'pl':
15
- return 'pl_PL';
16
- case 'bg':
17
- return 'bg_BG';
18
- case 'fr':
19
- return 'fr_FR';
20
- case 'cs':
21
- return 'cs_CZ';
22
- case 'nl':
23
- return 'nl_NL';
24
- default:
25
- return 'en_US';
26
- }
27
- }
28
-
29
- function paypal_directory() {
30
- if ( !defined('WPLANG') )
31
- return 'en_US/';
32
- $lang = substr(WPLANG, 0, 2);
33
- switch ( $lang ) {
34
- case 'fr':
35
- return 'fr_FR/';
36
- case 'de':
37
- return 'de_DE/';
38
- case 'it':
39
- return 'it_IT/';
40
- case 'ja':
41
- return 'ja_JP/';
42
- case 'es':
43
- return 'es_XC/';
44
- case 'nl':
45
- return 'nl_NL/';
46
- case 'pl':
47
- return 'pl_PL/';
48
- case 'zh':
49
- if (preg_match("/^zh_(HK|TW)/i",WPLANG))
50
- return 'zh_HK/';
51
- // actually zh_CN, but interpret as default zh:
52
- return 'zh_XC/';
53
- default:
54
- return 'en_US/';
55
- }
56
- }
57
-
58
- ?>
keywords.php DELETED
@@ -1,134 +0,0 @@
1
- <?php
2
-
3
- function yarpp_extract_keywords($html, $max = 20) {
4
- global $overusedwords;
5
-
6
- // strip tags and html entities
7
- $text = preg_replace('/&(#x[0-9a-f]+|#[0-9]+|[a-zA-Z]+);/', '', strip_tags($html) );
8
-
9
- // 3.2.2: ignore soft hyphens
10
- // Requires PHP 5: http://bugs.php.net/bug.php?id=25670
11
- $softhyphen = html_entity_decode('&#173;',ENT_NOQUOTES,'UTF-8');
12
- $text = str_replace($softhyphen, '', $text);
13
-
14
- $charset = get_option('blog_charset');
15
- if ( function_exists('mb_split') && !empty($charset) ) {
16
- mb_regex_encoding($charset);
17
- $wordlist = mb_split('\s*\W+\s*', mb_strtolower($text, $charset));
18
- } else
19
- $wordlist = preg_split('%\s*\W+\s*%', strtolower($text));
20
-
21
- // Build an array of the unique words and number of times they occur.
22
- $tokens = array_count_values($wordlist);
23
-
24
- // Remove the stop words from the list.
25
- foreach ($overusedwords as $word) {
26
- unset($tokens[$word]);
27
- }
28
- // Remove words which are only a letter
29
- $mb_strlen_exists = function_exists('mb_strlen');
30
- foreach (array_keys($tokens) as $word) {
31
- if ($mb_strlen_exists)
32
- if (mb_strlen($word) < 2) unset($tokens[$word]);
33
- else
34
- if (strlen($word) < 2) unset($tokens[$word]);
35
- }
36
-
37
- arsort($tokens, SORT_NUMERIC);
38
-
39
- $types = array_keys($tokens);
40
-
41
- if (count($types) > $max)
42
- $types = array_slice($types, 0, $max);
43
- return implode(' ', $types);
44
- }
45
-
46
- function post_title_keywords($ID,$max = 20) {
47
- return yarpp_extract_keywords(get_the_title($ID),$max);
48
- }
49
-
50
- function post_body_keywords( $ID, $max = 20 ) {
51
- $post = get_post( $ID );
52
- if ( empty($post) )
53
- return '';
54
- $content = apply_filters_if_white( 'the_content', $post->post_content );
55
- return yarpp_extract_keywords( $content, $max );
56
- }
57
-
58
- /* new in 2.0! apply_filters_if_white (previously apply_filters_without) now has a blacklist.
59
- * It can be modified via the yarpp_blacklist and yarpp_blackmethods filters.
60
- */
61
- /* blacklisted so far:
62
- - diggZ-Et
63
- - reddZ-Et
64
- - dzoneZ-Et
65
- - WP-Syntax
66
- - Viper's Video Quicktags
67
- - WP-CodeBox
68
- - WP shortcodes
69
- - WP Greet Box
70
- //- Tweet This - could not reproduce problem.
71
- */
72
- function yarpp_white( $filter ) {
73
- static $blacklist, $blackmethods;
74
-
75
- if ( is_null($blacklist) || is_null($blackmethods) ) {
76
- $yarpp_blacklist = array('yarpp_default', 'diggZEt_AddBut', 'reddZEt_AddBut', 'dzoneZEt_AddBut', 'wp_syntax_before_filter', 'wp_syntax_after_filter', 'wp_codebox_before_filter', 'wp_codebox_after_filter', 'do_shortcode');//,'insert_tweet_this'
77
- $yarpp_blackmethods = array('addinlinejs', 'replacebbcode', 'filter_content');
78
-
79
- $blacklist = (array) apply_filters( 'yarpp_blacklist', $yarpp_blacklist );
80
- $blackmethods = (array) apply_filters( 'yarpp_blackmethods', $yarpp_blackmethods );
81
- }
82
-
83
- if ( is_array($filter) && in_array( $filter[1], $blackmethods ) )
84
- return false;
85
- return !in_array( $filter, $blacklist );
86
- }
87
-
88
- /* FYI, apply_filters_if_white was used here to avoid a loop in apply_filters('the_content') > yarpp_default() > yarpp_related() > current_post_keywords() > apply_filters('the_content').*/
89
- function apply_filters_if_white($tag, $value) {
90
- global $wp_filter, $merged_filters, $wp_current_filter;
91
-
92
- $args = array();
93
-
94
- // Do 'all' actions first
95
- if ( isset($wp_filter['all']) ) {
96
- $wp_current_filter[] = $tag;
97
- $args = func_get_args();
98
- _wp_call_all_hook($args);
99
- }
100
-
101
- if ( !isset($wp_filter[$tag]) ) {
102
- if ( isset($wp_filter['all']) )
103
- array_pop($wp_current_filter);
104
- return $value;
105
- }
106
-
107
- if ( !isset($wp_filter['all']) )
108
- $wp_current_filter[] = $tag;
109
-
110
- // Sort
111
- if ( !isset( $merged_filters[ $tag ] ) ) {
112
- ksort($wp_filter[$tag]);
113
- $merged_filters[ $tag ] = true;
114
- }
115
-
116
- reset( $wp_filter[ $tag ] );
117
-
118
- if ( empty($args) )
119
- $args = func_get_args();
120
-
121
- do {
122
- foreach( (array) current($wp_filter[$tag]) as $the_ )
123
- if ( !is_null($the_['function'])
124
- and yarpp_white($the_['function'])){ // HACK
125
- $args[1] = $value;
126
- $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
127
- }
128
-
129
- } while ( next($wp_filter[$tag]) !== false );
130
-
131
- array_pop( $wp_current_filter );
132
-
133
- return $value;
134
- }
magic.php CHANGED
@@ -3,31 +3,31 @@
3
//=TEMPLATING/DISPLAY===========
4
5
function yarpp_set_score_override_flag($q) {
6
- global $yarpp_cache;
7
- if ($yarpp_cache->is_yarpp_time()) {
8
- $yarpp_cache->score_override = ($q->query_vars['orderby'] == 'score');
9
10
if (!empty($q->query_vars['showposts'])) {
11
- $yarpp_cache->online_limit = $q->query_vars['showposts'];
12
} else {
13
- $yarpp_cache->online_limit = false;
14
}
15
} else {
16
- $yarpp_cache->score_override = false;
17
- $yarpp_cache->online_limit = false;
18
}
19
}
20
21
//=CACHING===========
22
23
function yarpp_sql( $reference_ID = false ) {
24
- global $wpdb, $post, $yarpp_debug, $yarpp_cache;
25
26
if ( is_object($post) && !$reference_ID ) {
27
$reference_ID = $post->ID;
28
}
29
30
- $options = array( 'threshold', 'show_pass_post', 'past_only', 'body', 'title', 'tags', 'categories', 'distags', 'discats', 'recent_only', 'recent_number', 'recent_units');
31
$yarpp_options = yarpp_get_option();
32
// mask it so we only get the ones specified in $options
33
$optvals = array_intersect_key($yarpp_options, array_flip($options));
@@ -36,7 +36,7 @@ function yarpp_sql( $reference_ID = false ) {
36
$limit = max(yarpp_get_option('limit'), yarpp_get_option('rss_limit'));
37
38
// Fetch keywords
39
- $keywords = $yarpp_cache->get_keywords($reference_ID);
40
41
// get weights
42
$weights = array(
@@ -48,12 +48,7 @@ function yarpp_sql( $reference_ID = false ) {
48
$totalweight = array_sum( array_values( $weights ) );
49
50
// get disallowed categories and tags
51
- $disterms = array_filter(
52
- array_merge(
53
- explode(',',$discats),
54
- explode(',',$distags)
55
- ),
56
- 'is_numeric');
57
$usedisterms = count($disterms);
58
$disterms = implode(',', $disterms);
59
@@ -134,7 +129,7 @@ function yarpp_sql( $reference_ID = false ) {
134
// use it or not.
135
$newsql = "($newsql) union (".str_replace("post_type = 'post'","post_type = 'page'",$newsql).")";
136
137
- if ($yarpp_debug) echo "<!--$newsql-->";
138
return $newsql;
139
}
140
@@ -143,20 +138,20 @@ function yarpp_sql( $reference_ID = false ) {
143
/* new in 3.0! new query-based approach: EXTREMELY HACKY! */
144
145
function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'website') {
146
- global $wp_query, $pagenow, $yarpp_cache;
147
148
- yarpp_upgrade_check();
149
150
if ($domain == 'demo_web' || $domain == 'demo_rss') {
151
- if ($yarpp_cache->demo_time) // if we're already in a YARPP loop, stop now.
152
return false;
153
} else {
154
- if ($yarpp_cache->is_yarpp_time()) // if we're already in a YARPP loop, stop now.
155
return false;
156
if ( !$reference_ID )
157
$reference_ID = get_the_ID();
158
159
- $cache_status = yarpp_cache_enforce($reference_ID);
160
161
// If cache status is YARPP_DONT_RUN, end here without returning or echoing anything.
162
if ( YARPP_DONT_RUN == $cache_status )
@@ -194,16 +189,16 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
194
195
if ($domain == 'demo_web' || $domain == 'demo_rss') {
196
// It's DEMO TIME!
197
- $yarpp_cache->demo_time = true;
198
if ($domain == 'demo_web')
199
- $yarpp_cache->demo_limit = yarpp_get_option('limit');
200
else
201
- $yarpp_cache->demo_limit = yarpp_get_option('rss_limit');
202
} else if ( YARPP_NO_RELATED == $cache_status ) {
203
// There are no results, so no yarpp time for us... :'(
204
} else {
205
// Get ready for YARPP TIME!
206
- $yarpp_cache->begin_yarpp_time($reference_ID);
207
}
208
209
// so we can return to normal later
@@ -247,11 +242,11 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
247
}
248
249
if ( 'demo_web' == $domain || 'demo_rss' == $domain ) {
250
- $yarpp_cache->demo_time = false;
251
} else if ( YARPP_NO_RELATED == $cache_status ) {
252
// Uh, do nothing. Stay very still.
253
} else {
254
- $yarpp_cache->end_yarpp_time(); // YARPP time is over... :(
255
}
256
257
// restore the older wp_query.
@@ -266,108 +261,31 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
266
}
267
268
function yarpp_related_exist($type,$args,$reference_ID=false) {
269
- global $post, $yarpp_cache;
270
271
- yarpp_upgrade_check();
272
273
if (is_object($post) && !$reference_ID)
274
$reference_ID = $post->ID;
275
276
- if ($yarpp_cache->is_yarpp_time()) // if we're already in a YARPP loop, stop now.
277
return false;
278
279
if (yarpp_get_option('cross_relate'))
280
$type = array('post','page');
281
282
- $cache_status = yarpp_cache_enforce($reference_ID);
283
284
if ( YARPP_NO_RELATED == $cache_status )
285
return false;
286
287
- $yarpp_cache->begin_yarpp_time($reference_ID); // get ready for YARPP TIME!
288
$related_query = new WP_Query();
289
- // Note: why is this 10000? Should we just make it 1?
290
$related_query->query(array('p'=>$reference_ID,'showposts'=>1,'post_type'=>$type));
291
$return = $related_query->have_posts();
292
unset($related_query);
293
- $yarpp_cache->end_yarpp_time(); // YARPP time is over. :(
294
295
return $return;
296
}
297
298
- function yarpp_save_cache($post_ID, $force=true) {
299
- global $wpdb;
300
-
301
- // new in 3.2: don't compute cache during import
302
- if ( defined( 'WP_IMPORTING' ) )
303
- return;
304
-
305
- $sql = "select post_parent from $wpdb->posts where ID='$post_ID'";
306
- $parent_ID = $wpdb->get_var($sql);
307
-
308
- if ($parent_ID != $post_ID and $parent_ID)
309
- $post_ID = $parent_ID;
310
-
311
- yarpp_cache_enforce((int) $post_ID, $force);
312
- }
313
-
314
- // Clear the cache for this entry and for all posts which are "related" to it.
315
- // New in 3.2: This is called when a post is deleted.
316
- function yarpp_delete_cache($post_ID) {
317
- global $yarpp_cache;
318
-
319
- // Clear the cache for this post.
320
- $yarpp_cache->clear($post_ID);
321
-
322
- // Find all "peers" which list this post as a related post.
323
- $peers = $yarpp_cache->related(null, $post_ID);
324
- // Clear the peers' caches.
325
- $yarpp_cache->clear($peers);
326
- }
327
-
328
- // New in 3.2.1: handle various post_status transitions
329
- function yarpp_status_transition($new_status, $old_status, $post) {
330
- global $yarpp_cache;
331
- switch ($new_status) {
332
- case "draft":
333
- yarpp_delete_cache($post->ID);
334
- break;
335
- case "publish":
336
- // find everything which is related to this post, and clear them, so that this
337
- // post might show up as related to them.
338
- $related = $yarpp_cache->related($post->ID, null);
339
- $yarpp_cache->clear($related);
340
- }
341
- }
342
-
343
- // Note: return value changed in 3.4
344
- // return YARPP_NO_RELATED | YARPP_RELATED | YARPP_DONT_RUN | false if no good input
345
- function yarpp_cache_enforce($reference_ID, $force = false) {
346
- global $yarpp_debug, $yarpp_cache;
347
-
348
- if ( !$reference_ID = absint($reference_ID) )
349
- return false;
350
-
351
- $status = $yarpp_cache->is_cached($reference_ID);
352
- $status = apply_filters( 'yarpp_cache_enforce_status', $status, $reference_ID );
353
-
354
- // There's a stop signal:
355
- if ( YARPP_DONT_RUN === $status )
356
- return YARPP_DONT_RUN;
357
-
358
- // If not cached, process now:
359
- if ( YARPP_NOT_CACHED == $status || $force ) {
360
- $status = $yarpp_cache->update($reference_ID);
361
- // if still not cached, there's a problem, but for the time being return NO RELATED
362
- if ( YARPP_NOT_CACHED === $status )
363
- return YARPP_NO_RELATED;
364
- }
365
-
366
- // There are no related posts
367
- if ( YARPP_NO_RELATED === $status )
368
- return YARPP_NO_RELATED;
369
-
370
- // There are results
371
- return YARPP_RELATED;
372
- }
373
-
3
//=TEMPLATING/DISPLAY===========
4
5
function yarpp_set_score_override_flag($q) {
6
+ global $yarpp;
7
+ if ( $yarpp->cache->is_yarpp_time() ) {
8
+ $yarpp->cache->score_override = ($q->query_vars['orderby'] == 'score');
9
10
if (!empty($q->query_vars['showposts'])) {
11
+ $yarpp->cache->online_limit = $q->query_vars['showposts'];
12
} else {
13
+ $yarpp->cache->online_limit = false;
14
}
15
} else {
16
+ $yarpp->cache->score_override = false;
17
+ $yarpp->cache->online_limit = false;
18
}
19
}
20
21
//=CACHING===========
22
23
function yarpp_sql( $reference_ID = false ) {
24
+ global $wpdb, $post, $yarpp;
25
26
if ( is_object($post) && !$reference_ID ) {
27
$reference_ID = $post->ID;
28
}
29
30
+ $options = array( 'threshold', 'show_pass_post', 'past_only', 'body', 'title', 'tags', 'categories', 'exclude', 'recent_only', 'recent_number', 'recent_units');
31
$yarpp_options = yarpp_get_option();
32
// mask it so we only get the ones specified in $options
33
$optvals = array_intersect_key($yarpp_options, array_flip($options));
36
$limit = max(yarpp_get_option('limit'), yarpp_get_option('rss_limit'));
37
38
// Fetch keywords
39
+ $keywords = $yarpp->cache->get_keywords($reference_ID);
40
41
// get weights
42
$weights = array(
48
$totalweight = array_sum( array_values( $weights ) );
49
50
// get disallowed categories and tags
51
+ $disterms = wp_parse_id_list($exclude['category'] . ',' . $exclude['post_tag']);
52
$usedisterms = count($disterms);
53
$disterms = implode(',', $disterms);
54
129
// use it or not.
130
$newsql = "($newsql) union (".str_replace("post_type = 'post'","post_type = 'page'",$newsql).")";
131
132
+ if ($yarpp->debug) echo "<!--$newsql-->";
133
return $newsql;
134
}
135
138
/* new in 3.0! new query-based approach: EXTREMELY HACKY! */
139
140
function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'website') {
141
+ global $yarpp, $wp_query, $pagenow, $yarpp;
142
143
+ $yarpp->upgrade_check();
144
145
if ($domain == 'demo_web' || $domain == 'demo_rss') {
146
+ if ($yarpp->cache->demo_time) // if we're already in a YARPP loop, stop now.
147
return false;
148
} else {
149
+ if ($yarpp->cache->is_yarpp_time()) // if we're already in a YARPP loop, stop now.
150
return false;
151
if ( !$reference_ID )
152
$reference_ID = get_the_ID();
153
154
+ $cache_status = $yarpp->cache->enforce($reference_ID);
155
156
// If cache status is YARPP_DONT_RUN, end here without returning or echoing anything.
157
if ( YARPP_DONT_RUN == $cache_status )
189
190
if ($domain == 'demo_web' || $domain == 'demo_rss') {
191
// It's DEMO TIME!
192
+ $yarpp->cache->demo_time = true;
193
if ($domain == 'demo_web')
194
+ $yarpp->cache->demo_limit = yarpp_get_option('limit');
195
else
196
+ $yarpp->cache->demo_limit = yarpp_get_option('rss_limit');
197
} else if ( YARPP_NO_RELATED == $cache_status ) {
198
// There are no results, so no yarpp time for us... :'(
199
} else {
200
// Get ready for YARPP TIME!
201
+ $yarpp->cache->begin_yarpp_time($reference_ID);
202
}
203
204
// so we can return to normal later
242
}
243
244
if ( 'demo_web' == $domain || 'demo_rss' == $domain ) {
245
+ $yarpp->cache->demo_time = false;
246
} else if ( YARPP_NO_RELATED == $cache_status ) {
247
// Uh, do nothing. Stay very still.
248
} else {
249
+ $yarpp->cache->end_yarpp_time(); // YARPP time is over... :(
250
}
251
252
// restore the older wp_query.
261
}
262
263
function yarpp_related_exist($type,$args,$reference_ID=false) {
264
+ global $yarpp, $post, $yarpp;
265
266
+ $yarpp->upgrade_check();
267
268
if (is_object($post) && !$reference_ID)
269
$reference_ID = $post->ID;
270
271
+ if ($yarpp->cache->is_yarpp_time()) // if we're already in a YARPP loop, stop now.
272
return false;
273
274
if (yarpp_get_option('cross_relate'))
275
$type = array('post','page');
276
277
+ $cache_status = $yarpp->cache->enforce($reference_ID);
278
279
if ( YARPP_NO_RELATED == $cache_status )
280
return false;
281
282
+ $yarpp->cache->begin_yarpp_time($reference_ID); // get ready for YARPP TIME!
283
$related_query = new WP_Query();
284
$related_query->query(array('p'=>$reference_ID,'showposts'=>1,'post_type'=>$type));
285
$return = $related_query->have_posts();
286
unset($related_query);
287
+ $yarpp->cache->end_yarpp_time(); // YARPP time is over. :(
288
289
return $return;
290
}
291
options-meta-boxes.php CHANGED
@@ -88,18 +88,34 @@ class YARPP_Meta_Box {
88
}
89
90
class YARPP_Meta_Box_Pool extends YARPP_Meta_Box {
91
function display() {
92
?>
93
<p><?php _e('"The Pool" refers to the pool of posts and pages that are candidates for display as related to the current entry.','yarpp');?></p>
94
95
<table class="form-table" style="margin-top: 0; clear:none;">
96
<tbody>
97
- <tr valign='top'>
98
- <th scope='row'><?php _e('Disallow by category:','yarpp');?></th><td><div id='display_discats' style="overflow:auto;max-height:100px;"></div></td></tr>
99
- <tr valign='top'>
100
- <th scope='row'><?php _e('Disallow by tag:','yarpp');?></th>
101
- <td><div id='display_distags' style="overflow:auto;max-height:100px;"></div></td></tr>
102
<?php
103
$this->checkbox('show_pass_post',__("Show password protected posts?",'yarpp'));
104
105
$recent_number = "<input name=\"recent_number\" type=\"text\" id=\"recent_number\" value=\"".esc_attr(yarpp_get_option('recent_number'))."\" size=\"2\" />";
@@ -289,10 +305,39 @@ class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
289
<li style="background: url(<?php echo $pluginurl . 'twitter.png' ; ?>) no-repeat left bottom;"><a href="http://twitter.com/yarpp" target="_blank"><?php _e('YARPP on Twitter', 'yarpp'); ?></a></li>
290
<li style="background: url(<?php echo $pluginurl . 'plugin.png'; ?>) no-repeat left bottom;"><a href="http://yarpp.org" target="_blank"><?php _e('YARPP on the Web', 'yarpp'); ?></a></li>
291
<li style="background: url(<?php echo $pluginurl . 'star.png'; ?>) no-repeat 3px 2px;"><a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/" target="_blank"><?php _e('Rate YARPP on WordPress.org', 'yarpp'); ?></a></li>
292
- <li style="background: url(<?php echo $pluginurl . 'paypal-icon.png'; ?>) no-repeat left bottom;"><a href='http://tinyurl.com/donatetomitcho' target='_new'><img src="https://www.paypal.com/<?php echo paypal_directory(); ?>i/btn/btn_donate_SM.gif" name="submit" alt="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal');?>" title="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal','yarpp');?>"/></a></li>
293
</ul>
294
<?php
295
}
296
}
297
298
add_meta_box('yarpp_display_contact', __('Contact YARPP','yarpp'), array(new YARPP_Meta_Box_Contact, 'display'), 'settings_page_yarpp', 'side', 'core');
88
}
89
90
class YARPP_Meta_Box_Pool extends YARPP_Meta_Box {
91
+ function exclude($taxonomy, $string) {
92
+ ?>
93
+ <tr valign='top'>
94
+ <th scope='row'><?php echo $string; ?></th>
95
+ <td><div class='scroll_wrapper' style="overflow:auto;max-height:100px;"><div id='exclude_<?php echo $taxonomy; ?>'>
96
+ <?php
97
+ $exclude_terms = yarpp_get_option('exclude');
98
+ if ( !empty($exclude_terms[$taxonomy]) ) {
99
+ $terms = get_terms($taxonomy, array('include' => $exclude_terms[$taxonomy]));
100
+ foreach ($terms as $term) {
101
+ echo "<input type='checkbox' name='exclude[{$taxonomy}][{$term->term_id}]' value='true' checked='checked' /> <label>" . esc_html($term->name) . "</label> ";
102
+ }
103
+ }
104
+ ?>
105
+ </div></div></td>
106
+ </tr>
107
+ <?php
108
+ }
109
+
110
function display() {
111
?>
112
<p><?php _e('"The Pool" refers to the pool of posts and pages that are candidates for display as related to the current entry.','yarpp');?></p>
113
114
<table class="form-table" style="margin-top: 0; clear:none;">
115
<tbody>
116
<?php
117
+ $this->exclude('category', __('Disallow by category:','yarpp'));
118
+ $this->exclude('post_tag', __('Disallow by tag:','yarpp'));
119
$this->checkbox('show_pass_post',__("Show password protected posts?",'yarpp'));
120
121
$recent_number = "<input name=\"recent_number\" type=\"text\" id=\"recent_number\" value=\"".esc_attr(yarpp_get_option('recent_number'))."\" size=\"2\" />";
305
<li style="background: url(<?php echo $pluginurl . 'twitter.png' ; ?>) no-repeat left bottom;"><a href="http://twitter.com/yarpp" target="_blank"><?php _e('YARPP on Twitter', 'yarpp'); ?></a></li>
306
<li style="background: url(<?php echo $pluginurl . 'plugin.png'; ?>) no-repeat left bottom;"><a href="http://yarpp.org" target="_blank"><?php _e('YARPP on the Web', 'yarpp'); ?></a></li>
307
<li style="background: url(<?php echo $pluginurl . 'star.png'; ?>) no-repeat 3px 2px;"><a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/" target="_blank"><?php _e('Rate YARPP on WordPress.org', 'yarpp'); ?></a></li>
308
+ <li style="background: url(<?php echo $pluginurl . 'paypal-icon.png'; ?>) no-repeat left bottom;"><a href='http://tinyurl.com/donatetomitcho' target='_new'><img src="https://www.paypal.com/<?php echo $this->paypal_lang(); ?>i/btn/btn_donate_SM.gif" name="submit" alt="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal');?>" title="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal','yarpp');?>"/></a></li>
309
</ul>
310
<?php
311
}
312
+
313
+ function paypal_lang() {
314
+ if ( !defined('WPLANG') )
315
+ return 'en_US/';
316
+ $lang = substr(WPLANG, 0, 2);
317
+ switch ( $lang ) {
318
+ case 'fr':
319
+ return 'fr_FR/';
320
+ case 'de':
321
+ return 'de_DE/';
322
+ case 'it':
323
+ return 'it_IT/';
324
+ case 'ja':
325
+ return 'ja_JP/';
326
+ case 'es':
327
+ return 'es_XC/';
328
+ case 'nl':
329
+ return 'nl_NL/';
330
+ case 'pl':
331
+ return 'pl_PL/';
332
+ case 'zh':
333
+ if (preg_match("/^zh_(HK|TW)/i",WPLANG))
334
+ return 'zh_HK/';
335
+ // actually zh_CN, but interpret as default zh:
336
+ return 'zh_XC/';
337
+ default:
338
+ return 'en_US/';
339
+ }
340
+ }
341
}
342
343
add_meta_box('yarpp_display_contact', __('Contact YARPP','yarpp'), array(new YARPP_Meta_Box_Contact, 'display'), 'settings_page_yarpp', 'side', 'core');
options.js ADDED
@@ -0,0 +1,129 @@
1
+ jQuery(function($) {
2
+ // since 3.3: add screen option toggles
3
+ postboxes.add_postbox_toggles(pagenow);
4
+
5
+ function template() {
6
+ if ($('.template').attr('checked')) {
7
+ $('.templated').show();
8
+ $('.not_templated').hide();
9
+ } else {
10
+ $('.templated').hide();
11
+ $('.not_templated').show();
12
+ }
13
+ excerpt();
14
+ }
15
+ $('.template').click(template);
16
+ template();
17
+
18
+ function excerpt() {
19
+ if (!$('.template').attr('checked') && $('.show_excerpt').attr('checked'))
20
+ $('.excerpted').show();
21
+ else
22
+ $('.excerpted').hide();
23
+ }
24
+ $('.show_excerpt,.template').click(excerpt);
25
+
26
+ var loaded_demo_rss = false;
27
+ function rss_display() {
28
+ if ($('.rss_display').attr('checked')) {
29
+ $('.rss_displayed').show();
30
+ if ( !loaded_demo_rss ) {
31
+ loaded_demo_rss = true;
32
+ var demo_rss = $('#display_demo_rss');
33
+ $.ajax({type:'POST',
34
+ url: ajaxurl,
35
+ data:'action=yarpp_display_demo_rss',
36
+ beforeSend:function(){demo_rss.html(loading)},
37
+ success:function(html){demo_rss.html('<pre>'+html+'</pre>')},
38
+ dataType:'html'});
39
+ }
40
+ } else {
41
+ $('.rss_displayed').hide();
42
+ }
43
+ rss_template();
44
+ }
45
+ $('.rss_display').click(rss_display);
46
+ rss_display();
47
+
48
+ function rss_template() {
49
+ if ($('.rss_template').attr('checked')) {
50
+ $('.rss_templated').show();
51
+ $('.rss_not_templated').hide();
52
+ } else {
53
+ $('.rss_templated').hide();
54
+ $('.rss_not_templated').show();
55
+ }
56
+ rss_excerpt();
57
+ }
58
+ $('.rss_template').click(rss_template);
59
+
60
+ function rss_excerpt() {
61
+ if ($('.rss_display').attr('checked') && $('.rss_show_excerpt').attr('checked'))
62
+ $('.rss_excerpted').show();
63
+ else
64
+ $('.rss_excerpted').hide();
65
+ }
66
+ $('.rss_display,.rss_show_excerpt').click(rss_excerpt);
67
+
68
+ var loaded_disallows = false;
69
+ function load_disallows() {
70
+ if ( loaded_disallows || !$('#yarpp_pool .inside').is(':visible') )
71
+ return;
72
+ loaded_disallows = true;
73
+
74
+ var finished_taxonomies = {},
75
+ term_indices = {};
76
+ function load_disallow(taxonomy) {
77
+ if (taxonomy in finished_taxonomies)
78
+ return;
79
+ var display = $('#exclude_' + taxonomy);
80
+ // only do one query at a time:
81
+ if (display.find('.loading').length)
82
+ return;
83
+
84
+ if ( taxonomy in term_indices )
85
+ term_indices[taxonomy] = term_indices[taxonomy] + 100;
86
+ else
87
+ term_indices[taxonomy] = 0;
88
+ $.ajax({type:'POST',
89
+ url: ajaxurl,
90
+ data: { action: 'yarpp_display_exclude_terms',
91
+ taxonomy: taxonomy,
92
+ offset: term_indices[taxonomy]
93
+ },
94
+ beforeSend:function(){
95
+ display.append(loading)
96
+ },
97
+ success:function(html){
98
+ display.find('.loading').remove();
99
+ if (':(' == html) { // no more :(
100
+ finished_taxonomies[taxonomy] = true;
101
+ return;
102
+ }
103
+ display.append(html);
104
+ },
105
+ dataType:'html'}
106
+ );
107
+ }
108
+
109
+ ['post_tag', 'category'].forEach(function(taxonomy) {
110
+ load_disallow(taxonomy);
111
+ $('#exclude_' + taxonomy).parent('.scroll_wrapper').scroll(function() {
112
+ var parent = $(this),
113
+ content = parent.children('div');
114
+ if ( parent.scrollTop() + parent.height() > content.height() - 10 )
115
+ load_disallow(taxonomy);
116
+ })
117
+ });
118
+ }
119
+ $('#yarpp_pool .handlediv, #yarpp_pool-hide').click(load_disallows);
120
+ load_disallows();
121
+
122
+ var demo_web = $('#display_demo_web');
123
+ $.ajax({type:'POST',
124
+ url: ajaxurl,
125
+ data:'action=yarpp_display_demo_web',
126
+ beforeSend:function(){demo_web.html(loading)},
127
+ success:function(html){demo_web.html('<pre>'+html+'</pre>')},
128
+ dataType:'html'});
129
+ });
options.php CHANGED
@@ -1,16 +1,16 @@
1
<?php
2
3
- global $wpdb, $yarpp_value_options, $yarpp_binary_options, $wp_version, $yarpp_cache, $yarpp_templates, $yarpp_myisam;
4
5
// Reenforce YARPP setup:
6
if ( !get_option('yarpp_version') )
7
- yarpp_activate();
8
else
9
- yarpp_upgrade_check();
10
11
// if action=flush, reset the cache
12
if (isset($_GET['action']) && $_GET['action'] == 'flush') {
13
- $yarpp_cache->flush();
14
}
15
16
// check to see that templates are in the right place
@@ -21,7 +21,7 @@ if ( !(is_array($yarpp_templates) && count($yarpp_templates)) ) {
21
22
// 3.3: move version checking here, in PHP:
23
if ( current_user_can('update_plugins' ) ) {
24
- $yarpp_version_info = yarpp_version_info();
25
26
// these strings are not localizable, as long as the plugin data on wordpress.org
27
// cannot be.
@@ -56,7 +56,7 @@ if (isset($_POST['myisam_override'])) {
56
57
$yarpp_myisam = true;
58
if ( !yarpp_get_option('myisam_override') ) {
59
- $yarpp_check_return = yarpp_myisam_check();
60
if ($yarpp_check_return !== true) { // if it's not *exactly* true
61
echo "<div class='updated'>"
62
.sprintf(__("YARPP's \"consider titles\" and \"consider bodies\" relatedness criteria require your <code>%s</code> table to use the <a href='http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html'>MyISAM storage engine</a>, but the table seems to be using the <code>%s</code> engine. These two options have been disabled.",'yarpp'),$wpdb->posts,$yarpp_check_return)
@@ -75,15 +75,15 @@ if ( !yarpp_get_option('myisam_override') ) {
75
}
76
}
77
78
- if ($yarpp_myisam && !yarpp_enabled()) {
79
- echo '<div class="updated"><p>';
80
- if (yarpp_activate()) {
81
- _e('The YARPP database had an error but has been fixed.','yarpp');
82
- } else {
83
- _e('The YARPP database has an error which could not be fixed.','yarpp');
84
- printf(__('Please try <a href="%s" target="_blank">manual SQL setup</a>.','yarpp'), 'http://mitcho.com/code/yarpp/sql.php?prefix='.urlencode($wpdb->prefix));
85
- }
86
- echo '</div></p>';
87
}
88
89
if (isset($_POST['update_yarpp'])) {
@@ -98,16 +98,13 @@ if (isset($_POST['update_yarpp'])) {
98
if ( !isset($_POST[$key]) )
99
$new_options[$key] = 1;
100
}
101
- if ( isset($_POST['discats']) ) {
102
- $new_options['discats'] = implode(',',array_keys($_POST['discats'])); // discats is different
103
- } else {
104
- $new_options['discats'] = '';
105
- }
106
107
- if ( isset($_POST['distags']) ) {
108
- $new_options['distags'] = implode(',',array_keys($_POST['distags'])); // distags is also different
109
- } else {
110
- $new_options['distags'] = '';
111
}
112
113
foreach (array_keys($yarpp_binary_options) as $option) {
@@ -121,58 +118,6 @@ if (isset($_POST['update_yarpp'])) {
121
}
122
123
?>
124
- <script type="text/javascript">
125
- //<!--
126
-
127
- // since 3.3: add screen option toggles
128
- jQuery(function() {
129
- postboxes.add_postbox_toggles(pagenow);
130
- });
131
-
132
- var spinner = '<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>';
133
-
134
- function load_display_demo_web() {
135
- jQuery.ajax({type:'POST',
136
- url: ajaxurl,
137
- data:'action=yarpp_display_demo_web',
138
- beforeSend:function(){jQuery('#display_demo_web').eq(0).html('<img src="' + spinner + '" alt="loading..."/>')},
139
- success:function(html){jQuery('#display_demo_web').eq(0).html('<pre>'+html+'</pre>')},
140
- dataType:'html'}
141
- )
142
- }
143
-
144
- function load_display_demo_rss() {
145
- jQuery.ajax({type:'POST',
146
- url: ajaxurl,
147
- data:'action=yarpp_display_demo_rss',
148
- beforeSend:function(){jQuery('#display_demo_rss').eq(0).html('<img src="'+spinner+'" alt="loading..."/>')},
149
- success:function(html){jQuery('#display_demo_rss').eq(0).html('<pre>'+html+'</pre>')},
150
- dataType:'html'}
151
- )
152
- }
153
-
154
- function load_display_distags() {
155
- jQuery.ajax({type:'POST',
156
- url: ajaxurl,
157
- data:'action=yarpp_display_distags',
158
- beforeSend:function(){jQuery('#display_distags').eq(0).html('<img src="'+spinner+'" alt="loading..."/>')},
159
- success:function(html){jQuery('#display_distags').eq(0).html(html)},
160
- dataType:'html'}
161
- )
162
- }
163
-
164
- function load_display_discats() {
165
- jQuery.ajax({type:'POST',
166
- url: ajaxurl,
167
- data:'action=yarpp_display_discats',
168
- beforeSend:function(){jQuery('#display_discats').eq(0).html('<img src="'+spinner+'" alt="loading..."/>')},
169
- success:function(html){jQuery('#display_discats').eq(0).html(html)},
170
- dataType:'html'}
171
- )
172
- }
173
- //-->
174
- </script>
175
-
176
<div class="wrap">
177
<h2>
178
<?php _e('Yet Another Related Posts Plugin Options','yarpp');?> <small><?php
@@ -180,8 +125,6 @@ function load_display_discats() {
180
?></small>
181
</h2>
182
183
- <?php echo "<div id='yarpp-version' style='display:none;'>" . esc_html(get_option('yarpp_version')) . "</div>"; ?>
184
-
185
<form method="post">
186
187
<div id="yarpp_author_text">
@@ -209,77 +152,14 @@ do_meta_boxes( 'settings_page_yarpp', 'normal', array() );
209
</div>
210
211
<script language="javascript">
212
- //<!--
213
- function template() {
214
- if (jQuery('.template').eq(0).attr('checked')) {
215
- jQuery('.templated').show();
216
- jQuery('.not_templated').hide();
217
- } else {
218
- jQuery('.templated').hide();
219
- jQuery('.not_templated').show();
220
- }
221
- excerpt();
222
- }
223
- jQuery('.template').click(template);
224
-
225
- function excerpt() {
226
- if (!jQuery('.template').eq(0).attr('checked') && jQuery('.show_excerpt').eq(0).attr('checked'))
227
- jQuery('.excerpted').show();
228
- else
229
- jQuery('.excerpted').hide();
230
- }
231
- jQuery('.show_excerpt,.template').click(excerpt);
232
-
233
- function rss_display() {
234
- if (jQuery('.rss_display').eq(0).attr('checked'))
235
- jQuery('.rss_displayed').show();
236
- else
237
- jQuery('.rss_displayed').hide();
238
- rss_excerpt();
239
- }
240
- jQuery('.rss_display').click(rss_display);
241
-
242
- function rss_template() {
243
- if (jQuery('.rss_template').eq(0).attr('checked')) {
244
- jQuery('.rss_templated').show();
245
- jQuery('.rss_not_templated').hide();
246
- } else {
247
- jQuery('.rss_templated').hide();
248
- jQuery('.rss_not_templated').show();
249
- }
250
- rss_excerpt();
251
- }
252
- jQuery('.rss_template').click(rss_template);
253
-
254
- function rss_excerpt() {
255
- if (jQuery('.rss_display').eq(0).attr('checked') && jQuery('.rss_show_excerpt').eq(0).attr('checked'))
256
- jQuery('.rss_excerpted').show();
257
- else
258
- jQuery('.rss_excerpted').hide();
259
- }
260
- jQuery('.rss_display,.rss_show_excerpt').click(rss_excerpt);
261
-
262
- function yarpp_js_init() {
263
- template();
264
- rss_template();
265
- load_display_discats();
266
- load_display_distags();
267
- load_display_demo_web();
268
- load_display_demo_rss();
269
-
270
- var version = jQuery('#yarpp-version').html();
271
- }
272
-
273
- jQuery(yarpp_js_init);
274
- //-->
275
- </script>
276
277
- <div>
278
- <p class="submit">
279
- <input type="submit" class='button-primary' name="update_yarpp" value="<?php _e("Update options",'yarpp')?>" />
280
- <!--<input type="submit" onclick='return confirm("<?php _e("Do you really want to reset your configuration?",'yarpp');?>");' class="yarpp_warning" name="reset_yarpp" value="<?php _e('Reset options','yarpp')?>" />-->
281
- </p>
282
- </div>
283
- <!--cache engine: <?php echo $yarpp_cache->name;?>; cache status: <?php echo $yarpp_cache->cache_status();?>-->
284
285
</form>
1
<?php
2
3
+ global $wpdb, $yarpp_value_options, $yarpp_binary_options, $wp_version, $yarpp, $yarpp_templates, $yarpp_myisam;
4
5
// Reenforce YARPP setup:
6
if ( !get_option('yarpp_version') )
7
+ $yarpp->activate();
8
else
9
+ $yarpp->upgrade_check();
10
11
// if action=flush, reset the cache
12
if (isset($_GET['action']) && $_GET['action'] == 'flush') {
13
+ $yarpp->cache->flush();
14
}
15
16
// check to see that templates are in the right place
21
22
// 3.3: move version checking here, in PHP:
23
if ( current_user_can('update_plugins' ) ) {
24
+ $yarpp_version_info = $yarpp->version_info();
25
26
// these strings are not localizable, as long as the plugin data on wordpress.org
27
// cannot be.
56
57
$yarpp_myisam = true;
58
if ( !yarpp_get_option('myisam_override') ) {
59
+ $yarpp_check_return = $yarpp->myisam_check();
60
if ($yarpp_check_return !== true) { // if it's not *exactly* true
61
echo "<div class='updated'>"
62
.sprintf(__("YARPP's \"consider titles\" and \"consider bodies\" relatedness criteria require your <code>%s</code> table to use the <a href='http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html'>MyISAM storage engine</a>, but the table seems to be using the <code>%s</code> engine. These two options have been disabled.",'yarpp'),$wpdb->posts,$yarpp_check_return)
75
}
76
}
77
78
+ if ( $yarpp_myisam && !$yarpp->enabled() ) {
79
+ echo '<div class="updated"><p>';
80
+ if ( $yarpp->activate() ) {
81
+ _e('The YARPP database had an error but has been fixed.','yarpp');
82
+ } else {
83
+ _e('The YARPP database has an error which could not be fixed.','yarpp');
84
+ printf(__('Please try <a href="%s" target="_blank">manual SQL setup</a>.','yarpp'), 'http://mitcho.com/code/yarpp/sql.php?prefix='.urlencode($wpdb->prefix));
85
+ }
86
+ echo '</div></p>';
87
}
88
89
if (isset($_POST['update_yarpp'])) {
98
if ( !isset($_POST[$key]) )
99
$new_options[$key] = 1;
100
}
101
102
+ // excludes are different
103
+ $new_options['exclude'] = array();
104
+ if ( isset($_POST['exclude']) ) {
105
+ $exclude = array_merge( array('category' => array(), 'post_tag' => array()), $_POST['exclude'] );
106
+ $new_options['exclude']['category'] = implode(',',array_keys($exclude['category']));
107
+ $new_options['exclude']['post_tag'] = implode(',',array_keys($exclude['post_tag']));
108
}
109
110
foreach (array_keys($yarpp_binary_options) as $option) {
118
}
119
120
?>
121
<div class="wrap">
122
<h2>
123
<?php _e('Yet Another Related Posts Plugin Options','yarpp');?> <small><?php
125
?></small>
126
</h2>
127
128
<form method="post">
129
130
<div id="yarpp_author_text">
152
</div>
153
154
<script language="javascript">
155
+ var spinner = '<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>',
156
+ loading = '<img class="loading" src="'+spinner+'" alt="loading..."/>';
157
+ </script>
158
159
+ <div>
160
+ <p class="submit">
161
+ <input type="submit" class='button-primary' name="update_yarpp" value="<?php _e("Update options",'yarpp')?>" />
162
+ </p>
163
+ </div>
164
165
</form>
readme.txt CHANGED
@@ -201,14 +201,18 @@ If you are a bilingual speaker of English and another language and an avid user
201
202
= 3.4 =
203
* [Bug fix](http://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-version-333-breaks-templates-in-widget): Custom templates could not be used in widget display
204
* Significant code cleanup
205
* Removed the many different options entries, replacing them with a single `yarpp` option (except `yarpp_version`)
206
* Fixed issues with display options field data escaping and slashing once and for all
207
* Performance improvements on pages with "no related posts"
208
- * Streamlined keyword storage in YARPP_Cache_Postmeta
209
* Updated minor bug for computing how many results should be cached
210
- * Adding some filters: yarpp_settings_save, yarpp_blacklist, yarpp_blackmethods
211
* New systematic use of YARPP_ constants to communicate cache status
212
* Support for [YARPP Experiments](http://wordpress.org/extend/plugins/yarpp-experiments/).
213
* Added Portuguese stopwords by Leandro Coelho ([LogĂ­stica Descomplicada](http://www.logisticadescomplicada.com))
214
= 3.3.3 =
201
202
= 3.4 =
203
* [Bug fix](http://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-version-333-breaks-templates-in-widget): Custom templates could not be used in widget display
204
+ * Implement lazy/infinite scrolling for the "disallow tags" and "disallow categories," so the YARPP settings screen doesn't lock up the browser for sites which have a crazy number or tags or categories
205
* Significant code cleanup
206
+ * Move many internal functions into a global object `$yarpp` of class `YARPP`; references to the global `$yarpp_cache` should now be to global `$yarpp->cache`.
207
* Removed the many different options entries, replacing them with a single `yarpp` option (except `yarpp_version`)
208
* Fixed issues with display options field data escaping and slashing once and for all
209
* Performance improvements on pages with "no related posts"
210
+ * Streamlined keyword storage in `YARPP_Cache_Postmeta`
211
+ * Create `YARPP_Cache` abstract class
212
* Updated minor bug for computing how many results should be cached
213
+ * Adding some filters: yarpp_settings_save, yarpp_blacklist, yarpp_blackmethods, yarpp_keywords_overused_words
214
* New systematic use of YARPP_ constants to communicate cache status
215
+ * Use `get_terms` to load terms
216
* Support for [YARPP Experiments](http://wordpress.org/extend/plugins/yarpp-experiments/).
217
* Added Portuguese stopwords by Leandro Coelho ([LogĂ­stica Descomplicada](http://www.logisticadescomplicada.com))
218
= 3.3.3 =
services.php CHANGED
@@ -1,37 +1,38 @@
1
<?php
2
3
// setup the ajax action hooks
4
- if (function_exists('add_action')) {
5
- add_action('wp_ajax_yarpp_display_discats', 'yarpp_ajax_display_discats');
6
- add_action('wp_ajax_yarpp_display_distags', 'yarpp_ajax_display_distags');
7
- add_action('wp_ajax_yarpp_display_demo_web', 'yarpp_ajax_display_demo_web');
8
- add_action('wp_ajax_yarpp_display_demo_rss', 'yarpp_ajax_display_demo_rss');
9
- }
10
11
- function yarpp_ajax_display_discats() {
12
global $wpdb;
13
14
- header("HTTP/1.1 200");
15
- header("Content-Type: text/html; charset=UTF-8");
16
17
- $discats = explode(',',yarpp_get_option('discats'));
18
- array_unshift($discats,' ');
19
- foreach ($wpdb->get_results("select $wpdb->terms.term_id, name from $wpdb->terms natural join $wpdb->term_taxonomy where $wpdb->term_taxonomy.taxonomy = 'category' order by name") as $cat) {
20
- echo "<input type='checkbox' name='discats[$cat->term_id]' value='true'". (array_search($cat->term_id,$discats) ? ' checked="checked"': '' )." /> <label>$cat->name</label> ";//for='discats[$cat->term_id]' it's not HTML. :(
21
- }
22
- exit;
23
- }
24
-
25
- function yarpp_ajax_display_distags() {
26
- global $wpdb;
27
28
header("HTTP/1.1 200");
29
header("Content-Type: text/html; charset=UTF-8");
30
31
- $distags = explode(',',yarpp_get_option('distags'));
32
- array_unshift($distags,' ');
33
- foreach ($wpdb->get_results("select $wpdb->terms.term_id, name from $wpdb->terms natural join $wpdb->term_taxonomy where $wpdb->term_taxonomy.taxonomy = 'post_tag' order by name") as $tag) {
34
- echo "<input type='checkbox' name='distags[$tag->term_id]' value='true'". (array_search($tag->term_id,$distags) ? ' checked="checked"': '' )." /> <label>$tag->name</label> ";// for='distags[$tag->term_id]'
35
}
36
exit;
37
}
1
<?php
2
3
// setup the ajax action hooks
4
+ add_action('wp_ajax_yarpp_display_exclude_terms', 'yarpp_ajax_display_exclude_terms');
5
+ add_action('wp_ajax_yarpp_display_demo_web', 'yarpp_ajax_display_demo_web');
6
+ add_action('wp_ajax_yarpp_display_demo_rss', 'yarpp_ajax_display_demo_rss');
7
8
+ function yarpp_ajax_display_exclude_terms() {
9
global $wpdb;
10
11
+ if ( !isset($_REQUEST['taxonomy']) )
12
+ return;
13
14
+ $taxonomy = (string) $_REQUEST['taxonomy'];
15
16
header("HTTP/1.1 200");
17
header("Content-Type: text/html; charset=UTF-8");
18
19
+ $exclude = yarpp_get_option('exclude');
20
+ if ( !isset($exclude[$taxonomy]) )
21
+ $exclude[$taxonomy] = array();
22
+ $terms = get_terms($taxonomy, array(
23
+ 'exclude' => $exclude[$taxonomy],
24
+ 'number' => 100,
25
+ 'offset' => $_REQUEST['offset']
26
+ ));
27
+
28
+ if ( !count($terms) ) {
29
+ echo ':('; // no more :(
30
+ exit;
31
+ }
32
+
33
+ foreach ($terms as $term) {
34
+ echo "<input type='checkbox' name='exclude[$taxonomy][$term->term_id]' value='true' /> <label>" . esc_html($term->name) . "</label> ";
35
+ //for='exclude[$taxonomy][$cat->term_id]' it's not HTML. :(
36
}
37
exit;
38
}
template-builtin.php CHANGED
@@ -31,9 +31,10 @@ if (have_posts()) {
31
$output .= ' <abbr title="'.sprintf(__('%f is the YARPP match score between the current entry and this related entry. You are seeing this value because you are logged in to WordPress as an administrator. It is not shown to regular visitors.','yarpp'),round(get_the_score(),3)).'">('.round(get_the_score(),3).')</abbr>';
32
$output .= '</a>';
33
if ($show_excerpt) {
34
- $output .= $before_post .
35
- yarpp_excerpt(get_the_excerpt(),$excerpt_length)
36
- . $after_post;
37
}
38
$output .= $after_title."\n";
39
31
$output .= ' <abbr title="'.sprintf(__('%f is the YARPP match score between the current entry and this related entry. You are seeing this value because you are logged in to WordPress as an administrator. It is not shown to regular visitors.','yarpp'),round(get_the_score(),3)).'">('.round(get_the_score(),3).')</abbr>';
32
$output .= '</a>';
33
if ($show_excerpt) {
34
+ $excerpt = strip_tags( (string) get_the_excerpt() );
35
+ preg_replace( '/([,;.-]+)\s*/','\1 ', $excerpt );
36
+ $excerpt = implode( ' ', array_slice( preg_split('/\s+/',$excerpt), 0, $excerpt_length ) ).'...';
37
+ $output .= $before_post . $excerpt . $after_post;
38
}
39
$output .= $after_title."\n";
40
template-metabox.php CHANGED
@@ -1,16 +1,20 @@
1
<?php
2
- global $yarpp_debug;
3
4
- yarpp_save_cache($reference_ID,false); // enforce the cache, but don't force it
5
6
- $keywords = $yarpp_cache->get_keywords($reference_ID);
7
8
- if ($yarpp_debug) $output .= "<p>body keywords: {$keywords['body']}</p>";
9
- if ($yarpp_debug) $output .= "<p>title keywords: {$keywords['title']}</p>";
10
11
$output .= '<p>'.__( 'These are the related entries for this entry. Updating this post may change these related posts.' , 'yarpp').'</p>';
12
13
- if ($yarpp_debug) $output .= "<p>last updated: ".$wpdb->get_var("select max(date) as updated from {$wpdb->prefix}yarpp_related_cache where reference_ID = '$reference_ID'")."</p>";
14
15
if (have_posts()) {
16
$output .= '<style>#yarpp-related-posts ol li { list-style-type: decimal; }</style>';
1
<?php
2
+ global $yarpp;
3
4
+ $yarpp->cache->save_post($reference_ID, false); // enforce the cache, but don't force it
5
6
+ $keywords = $yarpp->cache->get_keywords($reference_ID);
7
8
+ if ($yarpp->debug) {
9
+ $output .= "<p>body keywords: {$keywords['body']}</p>";
10
+ $output .= "<p>title keywords: {$keywords['title']}</p>";
11
+ }
12
13
$output .= '<p>'.__( 'These are the related entries for this entry. Updating this post may change these related posts.' , 'yarpp').'</p>';
14
15
+ if ($yarpp->debug) {
16
+ $output .= "<p>last updated: ".$wpdb->get_var("select max(date) as updated from {$wpdb->prefix}yarpp_related_cache where reference_ID = '$reference_ID'")."</p>";
17
+ }
18
19
if (have_posts()) {
20
$output .= '<style>#yarpp-related-posts ol li { list-style-type: decimal; }</style>';
yarpp-templates/yarpp-template-thumbnail.php CHANGED
@@ -7,9 +7,9 @@ Author: mitcho (Michael Yoshitaka Erlewine)
7
<?php if ($related_query->have_posts()):?>
8
<ol>
9
<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
10
- <?php if (function_exists('has_post_thumbnail')): if (has_post_thumbnail()):?>
11
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a></li>
12
- <?php endif; endif; ?>
13
<?php endwhile; ?>
14
</ol>
15
7
<?php if ($related_query->have_posts()):?>
8
<ol>
9
<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
10
+ <?php if (has_post_thumbnail()):?>
11
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a></li>
12
+ <?php endif; ?>
13
<?php endwhile; ?>
14
</ol>
15
yarpp-templates/yarpp-template-wpml.php CHANGED
@@ -4,8 +4,8 @@ Author: mitcho (Michael Yoshitaka Erlewine)
4
*/
5
6
if (function_exists("icl_register_string")) {
7
- icl_register_string("Yet Another Related Posts Plugin","related posts header","Related Posts");
8
- icl_register_string("Yet Another Related Posts Plugin","no related posts message","No related posts.");
9
}
10
11
?><h3><?php echo (function_exists("icl_t") ? icl_t("Yet Another Related Posts Plugin","related posts header","Related Posts") : "Related Posts B") ?></h3>
4
*/
5
6
if (function_exists("icl_register_string")) {
7
+ icl_register_string("Yet Another Related Posts Plugin","related posts header","Related Posts");
8
+ icl_register_string("Yet Another Related Posts Plugin","no related posts message","No related posts.");
9
}
10
11
?><h3><?php echo (function_exists("icl_t") ? icl_t("Yet Another Related Posts Plugin","related posts header","Related Posts") : "Related Posts B") ?></h3>
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. A templating feature allows customization of the display.
6
- Version: 3.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.4b4');
13
define('YARPP_DIR', dirname(__FILE__));
14
define('YARPP_NO_RELATED', ':(');
15
define('YARPP_RELATED', ':)');
@@ -30,11 +30,10 @@ if (!defined('YARPP_CACHE_TYPE'))
30
// new in 3.3.3: init yarpp on init
31
add_action( 'init', 'yarpp_init' );
32
function yarpp_init() {
33
- global $yarpp_cache, $yarpp_storage_class, $yarpp_debug;
34
35
- // set $yarpp_debug
36
if ( isset($_REQUEST['yarpp_debug']) )
37
- $yarpp_debug = true;
38
39
register_activation_hook( __FILE__, 'yarpp_activate' );
40
@@ -55,20 +54,11 @@ function yarpp_init() {
55
56
// new in 3.0: add meta box
57
add_action( 'admin_menu', 'yarpp_add_metabox');
58
-
59
- // update cache on save
60
- add_action('save_post','yarpp_save_cache');
61
-
62
- // new in 3.2: update cache on delete
63
- add_action('delete_post','yarpp_delete_cache');
64
- // new in 3.2.1: handle post_status transitions
65
- add_action('transition_post_status','yarpp_status_transition', 10, 3);
66
-
67
// sets the score override flag.
68
add_action('parse_query','yarpp_set_score_override_flag');
69
70
- require_once(YARPP_DIR . '/cache-' . YARPP_CACHE_TYPE . '.php');
71
- $yarpp_cache = new $yarpp_storage_class;
72
73
// new in 3.3: include BlogGlue meta box
74
if ( file_exists( YARPP_DIR . '/blogglue.php' ) )
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. A templating feature allows customization of the display.
6
+ Version: 3.4b5
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.4b5');
13
define('YARPP_DIR', dirname(__FILE__));
14
define('YARPP_NO_RELATED', ':(');
15
define('YARPP_RELATED', ':)');
30
// new in 3.3.3: init yarpp on init
31
add_action( 'init', 'yarpp_init' );
32
function yarpp_init() {
33
+ global $yarpp;
34
35
if ( isset($_REQUEST['yarpp_debug']) )
36
+ $yarpp->debug = true;
37
38
register_activation_hook( __FILE__, 'yarpp_activate' );
39
54
55
// new in 3.0: add meta box
56
add_action( 'admin_menu', 'yarpp_add_metabox');
57
+
58
// sets the score override flag.
59
add_action('parse_query','yarpp_set_score_override_flag');
60
61
+ $yarpp = new YARPP;
62
63
// new in 3.3: include BlogGlue meta box
64
if ( file_exists( YARPP_DIR . '/blogglue.php' ) )