Yet Another Related Posts Plugin (YARPP) - Version 3.2b1

Version Description

Download this release

Release Info

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

Code changes from version 3.1.9 to 3.2b1

Files changed (9) hide show
  1. includes.php +16 -46
  2. intl.php +2 -0
  3. keywords.php +16 -68
  4. lang/words-bg_BG.php +3 -0
  5. lang/yarpp-bg_BG.mo +0 -0
  6. lang/yarpp-bg_BG.po +588 -0
  7. magic.php +60 -62
  8. readme.txt +5 -1
  9. yarpp.php +9 -3
includes.php CHANGED
@@ -9,8 +9,6 @@ if ( !defined('WP_CONTENT_URL') )
9
define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
10
if ( !defined('WP_CONTENT_DIR') )
11
define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
12
- if ( !defined('YARPP_UNLIKELY_DEFAULT') )
13
- define('YARPP_UNLIKELY_DEFAULT', "There's no way this is going to be the string.");
14
15
global $yarpp_value_options, $yarpp_binary_options;
16
// here's a list of all the options YARPP uses (except version), as well as their default values, sans the yarpp_ prefix, split up into binary options and value options. These arrays are used in updating settings (options.php) and other tasks.
@@ -63,16 +61,10 @@ function yarpp_enabled() {
63
global $wpdb;
64
$indexdata = $wpdb->get_results("show index from $wpdb->posts");
65
foreach ($indexdata as $index) {
66
- if ($index->Key_name == 'yarpp_title') {
67
- // now check for the cache tables
68
- $tabledata = $wpdb->get_col("show tables");
69
- if (array_search("{$wpdb->prefix}yarpp_related_cache",$tabledata) !== false and array_search("{$wpdb->prefix}yarpp_keyword_cache",$tabledata) !== false)
70
- return 1;
71
- else
72
- return 0;
73
- };
74
}
75
- return 0;
76
}
77
78
function yarpp_reinforce() {
@@ -84,11 +76,11 @@ function yarpp_reinforce() {
84
function yarpp_activate() {
85
global $yarpp_version, $wpdb, $yarpp_binary_options, $yarpp_value_options;
86
foreach (array_keys($yarpp_value_options) as $option) {
87
- if (get_option("yarpp_$option",YARPP_UNLIKELY_DEFAULT) == YARPP_UNLIKELY_DEFAULT)
88
add_option("yarpp_$option",$yarpp_value_options[$option] . ' ');
89
}
90
foreach (array_keys($yarpp_binary_options) as $option) {
91
- if (get_option("yarpp_$option",YARPP_UNLIKELY_DEFAULT) == YARPP_UNLIKELY_DEFAULT)
92
add_option("yarpp_$option",$yarpp_binary_options[$option]);
93
}
94
if (!yarpp_enabled()) {
@@ -102,31 +94,8 @@ function yarpp_activate() {
102
$wpdb->print_error();
103
echo "-->";
104
}
105
- if (!$wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}yarpp_keyword_cache` (
106
- `ID` bigint(20) unsigned NOT NULL default '0',
107
- `body` text collate utf8_unicode_ci NOT NULL,
108
- `title` text collate utf8_unicode_ci NOT NULL,
109
- `date` timestamp NOT NULL default CURRENT_TIMESTAMP,
110
- PRIMARY KEY (`ID`)
111
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='YARPP''s keyword cache table';")) {
112
- echo "<!--".__('MySQL error on creating yarpp_keyword_cache table','yarpp').": ";
113
- $wpdb->print_error();
114
- echo "-->";
115
- }
116
- if (!$wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}yarpp_related_cache` (
117
- `reference_ID` bigint(20) unsigned NOT NULL default '0',
118
- `ID` bigint(20) unsigned NOT NULL default '0',
119
- `score` float unsigned NOT NULL default '0',
120
- `date` timestamp NOT NULL default CURRENT_TIMESTAMP,
121
- PRIMARY KEY ( `score` , `date` , `reference_ID` , `ID` )
122
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;")) {
123
- echo "<!--".__('MySQL error on creating yarpp_related_cache table','yarpp').": ";
124
- $wpdb->print_error();
125
- echo "-->";
126
- }
127
- if (!yarpp_enabled()) {
128
return 0;
129
- }
130
}
131
add_option('yarpp_version',YARPP_VERSION);
132
update_option('yarpp_version',YARPP_VERSION);
@@ -135,7 +104,7 @@ function yarpp_activate() {
135
136
function yarpp_myisam_check() {
137
global $wpdb;
138
- $tables = $wpdb->get_results("show table status like '$wpdb->posts'");
139
foreach ($tables as $table) {
140
if ($table->Engine == 'MyISAM') return true;
141
else return $table->Engine;
@@ -147,11 +116,11 @@ function yarpp_upgrade_check($inuse = false) {
147
global $wpdb, $yarpp_value_options, $yarpp_binary_options;
148
149
foreach (array_keys($yarpp_value_options) as $option) {
150
- if (get_option("yarpp_$option",YARPP_UNLIKELY_DEFAULT) == YARPP_UNLIKELY_DEFAULT)
151
add_option("yarpp_$option",$yarpp_value_options[$option].' ');
152
}
153
foreach (array_keys($yarpp_binary_options) as $option) {
154
- if (get_option("yarpp_$option",YARPP_UNLIKELY_DEFAULT) == YARPP_UNLIKELY_DEFAULT)
155
add_option("yarpp_$option",$yarpp_binary_options[$option]);
156
}
157
@@ -163,9 +132,10 @@ function yarpp_upgrade_check($inuse = false) {
163
update_option('yarpp_version','1.5');
164
}
165
166
- if (version_compare('3.1.3',get_option('yarpp_version')) > 0) {
167
- $wpdb->query("ALTER TABLE {$wpdb->prefix}yarpp_related_cache DROP PRIMARY KEY ,
168
- ADD PRIMARY KEY ( score , date , reference_ID , ID )");
169
}
170
171
update_option('yarpp_version',YARPP_VERSION);
@@ -423,7 +393,7 @@ function yarpp_upgrade_one_five() {
423
global $wpdb;
424
$migrate_options = array('past_only','show_excerpt','show_pass_post','cross_relate','limit','threshold','before_title','after_title','before_post','after_post');
425
foreach ($migrate_options as $option) {
426
- if (get_option($option,YARPP_UNLIKELY_DEFAULT) != YARPP_UNLIKELY_DEFAULT) {
427
update_option("yarpp_$option",get_option($option));
428
delete_option($option);
429
}
@@ -468,7 +438,7 @@ function yarpp_get_option($option,$escapehtml = false) {
468
469
function yarpp_clear_cache() {
470
global $wpdb;
471
- return $wpdb->query("truncate table `{$wpdb->prefix}yarpp_related_cache`");
472
}
473
474
function yarpp_microtime_float()
@@ -495,6 +465,6 @@ function yarpp_metabox() {
495
if ($post->ID)
496
yarpp_related(array('post'),array('limit'=>1000),true,false,'metabox');
497
else
498
- echo "<p>Related entries may be displayed once you save your entry.</p>";
499
echo '</div>';
500
}
9
define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
10
if ( !defined('WP_CONTENT_DIR') )
11
define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
12
13
global $yarpp_value_options, $yarpp_binary_options;
14
// here's a list of all the options YARPP uses (except version), as well as their default values, sans the yarpp_ prefix, split up into binary options and value options. These arrays are used in updating settings (options.php) and other tasks.
61
global $wpdb;
62
$indexdata = $wpdb->get_results("show index from $wpdb->posts");
63
foreach ($indexdata as $index) {
64
+ if ($index->Key_name == 'yarpp_title')
65
+ return true;
66
}
67
+ return false;
68
}
69
70
function yarpp_reinforce() {
76
function yarpp_activate() {
77
global $yarpp_version, $wpdb, $yarpp_binary_options, $yarpp_value_options;
78
foreach (array_keys($yarpp_value_options) as $option) {
79
+ if (get_option("yarpp_$option") === false)
80
add_option("yarpp_$option",$yarpp_value_options[$option] . ' ');
81
}
82
foreach (array_keys($yarpp_binary_options) as $option) {
83
+ if (get_option("yarpp_$option") === false)
84
add_option("yarpp_$option",$yarpp_binary_options[$option]);
85
}
86
if (!yarpp_enabled()) {
94
$wpdb->print_error();
95
echo "-->";
96
}
97
+ if (!yarpp_enabled())
98
return 0;
99
}
100
add_option('yarpp_version',YARPP_VERSION);
101
update_option('yarpp_version',YARPP_VERSION);
104
105
function yarpp_myisam_check() {
106
global $wpdb;
107
+ $tables = $wpdb->get_results("show table status like '{$wpdb->posts}'");
108
foreach ($tables as $table) {
109
if ($table->Engine == 'MyISAM') return true;
110
else return $table->Engine;
116
global $wpdb, $yarpp_value_options, $yarpp_binary_options;
117
118
foreach (array_keys($yarpp_value_options) as $option) {
119
+ if (get_option("yarpp_$option") === false)
120
add_option("yarpp_$option",$yarpp_value_options[$option].' ');
121
}
122
foreach (array_keys($yarpp_binary_options) as $option) {
123
+ if (get_option("yarpp_$option") === false)
124
add_option("yarpp_$option",$yarpp_binary_options[$option]);
125
}
126
132
update_option('yarpp_version','1.5');
133
}
134
135
+ if (version_compare('3.2',get_option('yarpp_version')) > 0) {
136
+ // check for unnecessary cache tables
137
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'yarpp_related_cache');
138
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'yarpp_keyword_cache');
139
}
140
141
update_option('yarpp_version',YARPP_VERSION);
393
global $wpdb;
394
$migrate_options = array('past_only','show_excerpt','show_pass_post','cross_relate','limit','threshold','before_title','after_title','before_post','after_post');
395
foreach ($migrate_options as $option) {
396
+ if (get_option($option) !== null) {
397
update_option("yarpp_$option",get_option($option));
398
delete_option($option);
399
}
438
439
function yarpp_clear_cache() {
440
global $wpdb;
441
+ return $wpdb->query("delete from `{$wpdb->postmeta}` where meta_key = '" . YARPP_POSTMETA_RELATED_KEY . "'");
442
}
443
444
function yarpp_microtime_float()
465
if ($post->ID)
466
yarpp_related(array('post'),array('limit'=>1000),true,false,'metabox');
467
else
468
+ echo "<p>".__("Related entries may be displayed once you save your entry",'yarpp').".</p>";
469
echo '</div>';
470
}
intl.php CHANGED
@@ -12,6 +12,8 @@ function word_file_lang() {
12
return 'it_IT';
13
case preg_match("/^pl/i",WPLANG):
14
return 'pl_PL';
15
default:
16
return 'en_US';
17
}
12
return 'it_IT';
13
case preg_match("/^pl/i",WPLANG):
14
return 'pl_PL';
15
+ case preg_match("/^bg/i",WPLANG):
16
+ return 'bg_BG';
17
default:
18
return 'en_US';
19
}
keywords.php CHANGED
@@ -34,8 +34,7 @@ function yarpp_extract_keywords($source,$max = 20) {
34
}
35
36
function post_title_keywords($ID,$max = 20) {
37
- global $wpdb;
38
- return yarpp_extract_keywords(html_entity_strip($wpdb->get_var("select post_title from $wpdb->posts where ID = $ID")),$max);
39
}
40
41
function html_entity_strip($html) {
@@ -46,79 +45,28 @@ function html_entity_strip($html) {
46
}
47
48
function post_body_keywords($ID,$max = 20) {
49
- global $wpdb;
50
- $content = strip_tags(apply_filters_if_white('the_content',$wpdb->get_var("select post_content from $wpdb->posts where ID = $ID")));
51
$content = html_entity_strip($content);
52
return yarpp_extract_keywords($content,$max);
53
}
54
55
function yarpp_cache_keywords($ID) {
56
- global $wpdb, $yarpp_debug;
57
- $body_terms = post_body_keywords($ID);
58
- $title_terms = post_title_keywords($ID);
59
- /*
60
- CREATE TABLE `wp_yarpp_keyword_cache` (
61
- `ID` BIGINT( 20 ) UNSIGNED NOT NULL ,
62
- `body` TEXT NOT NULL ,
63
- `title` TEXT NOT NULL ,
64
- `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
65
- PRIMARY KEY ( `ID` )
66
- ) ENGINE = MYISAM COMMENT = 'YARPP\'s keyword cache table'
67
- */
68
-
69
- if (defined('DB_CHARSET') && DB_CHARSET) {
70
- $wpdb->query('set names '.DB_CHARSET);
71
- }
72
-
73
- $wpdb->query("insert into {$wpdb->prefix}yarpp_keyword_cache (ID,body,title) values ($ID,'$body_terms ','$title_terms ') on duplicate key update date = now(), body = '$body_terms ', title = '$title_terms '");
74
-
75
- }
76
-
77
- function yarpp_get_cached_keywords($ID,$type='body') {
78
- global $wpdb;
79
- $out = $wpdb->get_var("select $type from {$wpdb->prefix}yarpp_keyword_cache where ID = $ID");
80
- if ($out === false or $out == '') { // if empty, try caching them first.
81
- yarpp_cache_keywords($ID);
82
- $out = $wpdb->get_var("select $type from {$wpdb->prefix}yarpp_keyword_cache where ID = $ID");
83
- }
84
- if ($out === false or $out == '') { // if still empty... return false
85
- //echo "<!--YARPP ERROR: couldn't select/create yarpp $type keywords for $ID-->";
86
- return false;
87
- } else {
88
- return $out;
89
- }
90
}
91
92
- // replacement html_entity_decode code from php.net
93
- // author: laurynas dot butkus at gmail dot com
94
-
95
- function html_entity_decode_utf8($string) {
96
- static $trans_tbl;
97
-
98
- // replace numeric entities
99
- $string = preg_replace('~&#x([0-9a-f]+);~ei', 'code2utf(hexdec("\\1"))', $string);
100
- $string = preg_replace('~&#([0-9]+);~e', 'code2utf(\\1)', $string);
101
102
- // replace literal entities
103
- if (!isset($trans_tbl))
104
- {
105
- $trans_tbl = array();
106
-
107
- foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key)
108
- $trans_tbl[$key] = utf8_encode($val);
109
- }
110
-
111
- return strtr($string, $trans_tbl);
112
- }
113
114
- // Returns the utf string corresponding to the unicode value (from php.net, courtesy - romans@void.lv)
115
- function code2utf($num)
116
- {
117
- if ($num < 128) return chr($num);
118
- if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
119
- if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
120
- if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
121
- return '';
122
}
123
-
124
- ?>
34
}
35
36
function post_title_keywords($ID,$max = 20) {
37
+ return yarpp_extract_keywords(html_entity_strip(get_the_title($ID)),$max);
38
}
39
40
function html_entity_strip($html) {
45
}
46
47
function post_body_keywords($ID,$max = 20) {
48
+ $posts = get_posts(array('p'=>$ID));
49
+ if (count($posts) != 1)
50
+ return '';
51
+ $content = strip_tags(apply_filters_if_white('the_content',$posts[0]->post_content));
52
$content = html_entity_strip($content);
53
return yarpp_extract_keywords($content,$max);
54
}
55
56
function yarpp_cache_keywords($ID) {
57
+ update_post_meta($ID, YARPP_POSTMETA_BODY_KEYWORDS_KEY, post_body_keywords($ID));
58
+ update_post_meta($ID, YARPP_POSTMETA_TITLE_KEYWORDS_KEY, post_title_keywords($ID));
59
}
60
61
+ function yarpp_get_cached_keywords($ID, $type='body') {
62
+ $key = $type == 'body' ? YARPP_POSTMETA_BODY_KEYWORDS_KEY : YARPP_POSTMETA_TITLE_KEYWORDS_KEY;
63
+ $out = get_post_meta($ID, $key, true);
64
65
+ // if empty, try caching them first
66
+ if ($out === false) {
67
+ yarpp_cache_keywords($ID);
68
+ $out = get_post_meta($ID, $key, true);
69
+ }
70
71
+ return $out;
72
}
lang/words-bg_BG.php ADDED
@@ -0,0 +1,3 @@
1
+ <?php
2
+
3
+ $overusedwords = array('имат', 'май', 'скоро', 'голям', 'имам', 'понеже', 'сякаш', 'сред', 'бе', 'стане', 'голяма', 'супер', 'затова', 'всяка', 'могат', 'макар', 'тоя', 'нещата', 'бях', 'някои', 'значи', 'друго', 'някакъв', 'иска', 'ето', 'било', 'наистина', 'никой', 'имаш', 'себе', 'вярно', 'къде', 'съвсем', 'никога', 'ами', 'едва', 'пъти', 'неща', 'върху', 'тогава', 'колко', 'например', 'тук', 'можеш', 'тези', 'та', 'бъде', 'дали', 'мога', 'теб', 'вид', 'често', 'даже', 'друг', 'нали', 'повечето', 'такива', 'място', 'особено', 'иначе', 'всъщност', 'направо', 'примерно', 'знае', 'голямата', 'смисъл', 'имаше', 'едни', 'понякога', 'из', 'своя', 'искам', 'веднъж', 'явно', 'ей', 'какви', 'естествено', 'изобщо', 'почва', 'остава', 'зад', 'някъде', 'отново', 'плюс', 'някак', 'цяла', 'нов', 'бих', 'другите', 'коя', 'разни', 'що', 'накрая', 'тъй', 'някакви', 'някаква', 'въобще', 'първо', 'такъв', 'правят', 'цял', 'вместо', 'бяха', 'тая', 'тия', 'нито', 'име', 'сам', 'км', 'де', 'били', 'била', 'общо', 'искаш', 'сте', 'чак', 'абсолютно', 'успява', 'цена', 'някоя', 'колкото', 'идва', 'кво', 'цялата', 'лв', 'други', 'поне', 'как', 'какво', 'ги', 'когато', 'към', 'аз', 'още', 'нещо', 'или', 'съм', 'той', 'няма', 'което', 'ни', 'вече', 'им', 'все', 'дори', 'защото', 'едно', 'преди', 'малко', 'ме', 'беше', 'при', 'със', 'една', 'обаче', 'трябва', 'която', 'така', 'един', 'са', 'като', 'най', 'това', 'ще', 'но', 'по', 'че', 'се', 'да', 'не', 'от', 'си', 'за', 'му', 'го', 'до', 'след', 'който', 'които', 'има', 'може', 'само', 'през', 'ти', 'много', 'ми', 'ли', 'те', 'ако', 'всички', 'във', 'прави', 'две', 'смее', 'бил', 'под', 'тази', 'освен', 'между', 'пред', 'казва', 'то', 'път', 'кой', 'после', 'около', 'над', 'въпреки', 'щото', 'винаги', 'срещу', 'част', 'ви', 'два', 'нея', 'почти', 'заради', 'защо', 'където', 'късно', 'мен', 'нас', 'ден', 'повече', 'толкова', 'според', 'този', 'както', 'докато', 'пък', 'ама', 'без', 'би', 'всичко', 'просто', 'тя', 'него', 'става', 'пак', 'тях', 'сме', 'някой', 'доста', 'също', 'ние', 'нищо', 'точно', 'сега', 'добре', 'всеки', 'няколко', 'там', 'на');
lang/yarpp-bg_BG.mo ADDED
Binary file
lang/yarpp-bg_BG.po ADDED
@@ -0,0 +1,588 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Yet Another Related Posts Plugin v3.1.8\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2010-07-26 10:29+0000\n"
7
+ "Last-Translator: Flash Gallery <info@flashgallery.org>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Poedit-Language: Bulgarian\n"
14
+ "X-Poedit-Country: BULGARIA\n"
15
+ "X-Poedit-SourceCharset: utf-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
17
+ "X-Poedit-Basepath: ../\n"
18
+ "X-Poedit-Bookmarks: \n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+ "X-Textdomain-Support: yes"
21
+
22
+ #: includes.php:27
23
+ #: includes.php:38
24
+ #@ yarpp
25
+ msgid "Related posts:"
26
+ msgstr "Сродни публикации:"
27
+
28
+ #: includes.php:29
29
+ #: includes.php:40
30
+ #: template-metabox.php:28
31
+ #: template-widget.php:13
32
+ #@ yarpp
33
+ msgid "No related posts."
34
+ msgstr "Няма сродни публикации."
35
+
36
+ #: includes.php:96
37
+ #@ yarpp
38
+ msgid "MySQL error on adding yarpp_title"
39
+ msgstr "MySQL грешка при добавянето на yarpp_title"
40
+
41
+ #: includes.php:101
42
+ #@ yarpp
43
+ msgid "MySQL error on adding yarpp_content"
44
+ msgstr "MySQL грешка при добавянето на yarpp_content"
45
+
46
+ #: includes.php:112
47
+ #@ yarpp
48
+ msgid "MySQL error on creating yarpp_keyword_cache table"
49
+ msgstr "MySQL грешка при създаването на yarpp_keyword_cache table"
50
+
51
+ #: includes.php:123
52
+ #@ yarpp
53
+ msgid "MySQL error on creating yarpp_related_cache table"
54
+ msgstr "MySQL грешка при създаването на yarpp_related_cache table"
55
+
56
+ #: includes.php:182
57
+ #: includes.php:215
58
+ #: includes.php:236
59
+ #@ yarpp
60
+ msgid "Related Posts (YARPP)"
61
+ msgstr "Сродни публикации (YARPP)"
62
+
63
+ #: includes.php:191
64
+ #@ yarpp
65
+ msgid "Settings"
66
+ msgstr "Настройки"
67
+
68
+ #: includes.php:265
69
+ msgid "Title:"
70
+ msgstr "Заглавие:"
71
+
72
+ #: includes.php:279
73
+ #: options.php:460
74
+ #: options.php:529
75
+ #@ yarpp
76
+ msgid "Help promote Yet Another Related Posts Plugin?"
77
+ msgstr "Помогнете в популяризирането на Yet Another Related Posts Plugin?"
78
+
79
+ #: includes.php:489
80
+ #@ yarpp
81
+ msgid "Related Posts"
82
+ msgstr "Сродни публикации"
83
+
84
+ #: magic.php:71
85
+ #@ yarpp
86
+ msgid "Example post "
87
+ msgstr "Примерна публикация"
88
+
89
+ #: magic.php:351
90
+ #: options.php:462
91
+ #: options.php:530
92
+ #@ yarpp
93
+ msgid "Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>."
94
+ msgstr "Сродни публикации с помоща на <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>."
95
+
96
+ #: options.php:10
97
+ #@ yarpp
98
+ msgid "Please move the YARPP template files into your theme to complete installation. Simply move the sample template files (currently in <code>wp-content/plugins/yet-another-related-posts-plugin/yarpp-templates/</code>) to the <code>TEMPLATEPATH</code> directory."
99
+ msgstr "Моля, преместете шаблоните на YARPP във вашата тема за да приключите с инсталирането. Просто преместете примерните шаблони (в момента се намират в <code>wp-content/plugins/yet-another-related-posts-plugin/yarpp-templates/</code>) в папката <code>TEMPLATEPATH</code>."
100
+
101
+ #: options.php:15
102
+ #@ yarpp
103
+ msgid "No YARPP template files were found in your theme (<code>TEMPLATEPATH</code>) so the templating feature has been turned off."
104
+ msgstr "Не бяха намерени YARPP шаблони във вашата тема (<code>TEMPLATEPATH</code>) , следнователно възможноста за шаблони беше изключена."
105
+
106
+ #: options.php:26
107
+ #@ yarpp
108
+ msgid "The MyISAM check has been overridden. You may now use the \"consider titles\" and \"consider bodies\" relatedness criteria."
109
+ msgstr "Проверката за MyISAM е отменена. Сега може да използвате \"вземи в предвид заглавията\" и \"вземи в предвид основния текс\" критериите за сродност."
110
+
111
+ #: options.php:35
112
+ #, php-format
113
+ #@ yarpp
114
+ msgid "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."
115
+ msgstr "Критериите за сродност на YARPP \"вземи в предвид заглавията\" и \"вземи в предвид основния текст\" изискват таблицата <code>%s</code> да използва <a href='http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html'>MyISAM storage engine</a>, обаче таблицата използва <code>%s</code> engine. Тези две опции са изключени."
116
+
117
+ #: options.php:37
118
+ #, php-format
119
+ #@ yarpp
120
+ msgid "To restore these features, please update your <code>%s</code> table by executing the following SQL directive: <code>ALTER TABLE `%s` ENGINE = MyISAM;</code> . No data will be erased by altering the table's engine, although there are performance implications."
121
+ msgstr "За да възтановите тези опции, моля променете таблицата <code>%s</code> с изпълняването на тези SQL заявки: <code>ALTER TABLE `%s` ENGINE = MyISAM;</code> . Данните ви няма да бъдат изтрити от таблицата, въпреки че изпълнението на заявките може да се отрази на производителноста."
122
+
123
+ #: options.php:39
124
+ #, php-format
125
+ #@ yarpp
126
+ msgid "If, despite this check, you are sure that <code>%s</code> is using the MyISAM engine, press this magic button:"
127
+ msgstr "Ако въпреки тази проверка сте сигурни че <code>%s</code> ползва MyISAM engine, натиснете този магически бутон:"
128
+
129
+ #: options.php:42
130
+ #@ yarpp
131
+ msgid "Trust me. Let me use MyISAM features."
132
+ msgstr "Довери ми се, позволи ми да ползвам MyISAM."
133
+
134
+ #: options.php:65
135
+ #@ yarpp
136
+ msgid "The YARPP database had an error but has been fixed."
137
+ msgstr "Базата от данни на YARPP имаше грешка, но сега е оправена!"
138
+
139
+ #: options.php:67
140
+ #@ yarpp
141
+ msgid "The YARPP database has an error which could not be fixed."
142
+ msgstr "Базата от данни на YARPP има грешка която не може да бъде оправена."
143
+
144
+ #: options.php:68
145
+ #@ yarpp
146
+ msgid "Please try <A>manual SQL setup</a>."
147
+ msgstr "Моля, опитайте <A>ръчни SQL настройки</a>."
148
+
149
+ #: options.php:99
150
+ #@ yarpp
151
+ msgid "Options saved!"
152
+ msgstr "Настройките са запазени успешно!"
153
+
154
+ #: options.php:135
155
+ #@ yarpp
156
+ msgid "word"
157
+ msgstr "дума"
158
+
159
+ #: options.php:136
160
+ #@ yarpp
161
+ msgid "tag"
162
+ msgstr "таг"
163
+
164
+ #: options.php:137
165
+ #@ yarpp
166
+ msgid "category"
167
+ msgstr "категория"
168
+
169
+ #: options.php:141
170
+ #: options.php:158
171
+ #: options.php:170
172
+ #@ yarpp
173
+ msgid "do not consider"
174
+ msgstr "не взимай в предивид"
175
+
176
+ #: options.php:142
177
+ #: options.php:159
178
+ #: options.php:172
179
+ #@ yarpp
180
+ msgid "consider"
181
+ msgstr "вземи в предивид"
182
+
183
+ #: options.php:144
184
+ #: options.php:174
185
+ #, php-format
186
+ #@ yarpp
187
+ msgid "require at least one %s in common"
188
+ msgstr "изисквай поне един общ %s "
189
+
190
+ #: options.php:146
191
+ #: options.php:176
192
+ #, php-format
193
+ #@ yarpp
194
+ msgid "require more than one %s in common"
195
+ msgstr "изисквай повече от един общ %s"
196
+
197
+ #: options.php:160
198
+ #@ yarpp
199
+ msgid "consider with extra weight"
200
+ msgstr "вземи в предивид с по-голяма тежест"
201
+
202
+ #: options.php:188
203
+ #@ yarpp
204
+ msgid "Yet Another Related Posts Plugin version history (RSS 2.0)"
205
+ msgstr "Yet Another Related Posts Plugin история на версиите (RSS 2.0)"
206
+
207
+ #: options.php:242
208
+ #@ yarpp
209
+ msgid "Yet Another Related Posts Plugin Options"
210
+ msgstr "Yet Another Related Posts Plugin Настройки"
211
+
212
+ #: options.php:253
213
+ #@ yarpp
214
+ msgid "Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal"
215
+ msgstr "Донирай на mitcho (Michael Yoshitaka Erlewine) за това разширение чрез PayPal"
216
+
217
+ #: options.php:255
218
+ #@ yarpp
219
+ msgid "by <a href=\"http://mitcho.com/code/\">mitcho (Michael 芳貴 Erlewine)</a>"
220
+ msgstr "от <a href=\"http://mitcho.com/code/\">mitcho (Michael 芳貴 Erlewine)</a>"
221
+
222
+ #: options.php:255
223
+ #@ yarpp
224
+ msgid "Follow <a href=\"http://twitter.com/yarpp/\">Yet Another Related Posts Plugin on Twitter</a>"
225
+ msgstr "Следвай <a href=\"http://twitter.com/yarpp/\">Yet Another Related Posts Plugin на Twitter</a>"
226
+
227
+ #: options.php:271
228
+ #: options.php:304
229
+ #: options.php:401
230
+ #: options.php:469
231
+ msgid "Click to toggle"
232
+ msgstr "Натисни тук за да покажеш / скриеш опциите"
233
+
234
+ #: options.php:274
235
+ #@ yarpp
236
+ msgid "\"The Pool\""
237
+ msgstr "\"The Pool\""
238
+
239
+ #: options.php:276
240
+ #@ yarpp
241
+ msgid "\"The Pool\" refers to the pool of posts and pages that are candidates for display as related to the current entry."
242
+ msgstr "\"The Pool\" се отнася на всичките публикации и страници които са кандидати за показване като сродни постове."
243
+
244
+ #: options.php:281
245
+ #@ yarpp
246
+ msgid "Disallow by category:"
247
+ msgstr "Забрани по категория:"
248
+
249
+ #: options.php:283
250
+ #@ yarpp
251
+ msgid "Disallow by tag:"
252
+ msgstr "Забрани по таг:"
253
+
254
+ #: options.php:286
255
+ #@ yarpp
256
+ msgid "Show password protected posts?"
257
+ msgstr "Покажи публикациите заштитени с парола?"
258
+
259
+ #: options.php:290
260
+ #@ yarpp
261
+ msgid "day(s)"
262
+ msgstr "ден(дни)"
263
+
264
+ #: options.php:291
265
+ #@ yarpp
266
+ msgid "week(s)"
267
+ msgstr "седмица(седмици)"
268
+
269
+ #: options.php:292
270
+ #@ yarpp
271
+ msgid "month(s)"
272
+ msgstr "месец(и)"
273
+
274
+ #: options.php:294
275
+ #@ yarpp
276
+ msgid "Show only posts from the past NUMBER UNITS"
277
+ msgstr "Покажи публикации само от последните NUMBER UNITS"
278
+
279
+ #: options.php:307
280
+ #@ yarpp
281
+ msgid "\"Relatedness\" options"
282
+ msgstr "\"Сродност\" настройки"
283
+
284
+ #: options.php:310
285
+ #, php-format
286
+ #@ yarpp
287
+ msgid "YARPP is different than the <a href=\"http://wasabi.pbwiki.com/Related%20Entries\">previous plugins it is based on</a> as it limits the related posts list by (1) a maximum number and (2) a <em>match threshold</em>."
288
+ msgstr "YARPP е различен от <a href=\"http://wasabi.pbwiki.com/Related%20Entries\">предишните разширения на който е заснован</a> по ограничаването на сродните постове по (1) максимален брой (2) a <em>размер на сродност</em>."
289
+
290
+ #: options.php:310
291
+ #: options.php:325
292
+ #: options.php:409
293
+ #: options.php:414
294
+ #: options.php:461
295
+ #: options.php:478
296
+ #: options.php:479
297
+ #: options.php:483
298
+ #: options.php:529
299
+ #@ yarpp
300
+ msgid "more&gt;"
301
+ msgstr "повече&gt;"
302
+
303
+ #: options.php:310
304
+ #@ yarpp
305
+ msgid "The higher the match threshold, the more restrictive, and you get less related posts overall. The default match threshold is 5. If you want to find an appropriate match threshhold, take a look at some post's related posts display and their scores. You can see what kinds of related posts are being picked up and with what kind of match scores, and determine an appropriate threshold for your site."
306
+ msgstr "Колкото е поголям размера на сродност, толкова помалко сродни публикации се намират. Размера на сродност по подразбиране е 5. Ако искате да намерите подходящ размер на сходност погледнете сродните постове и техния резултат. Вижте какви резултати връща и какви публикации се появяват. По този начин ще определите размера на сродност който най-много ве устройва."
307
+
308
+ #: options.php:316
309
+ #@ yarpp
310
+ msgid "Match threshold:"
311
+ msgstr "Размер на сродност:"
312
+
313
+ #: options.php:317
314
+ #@ yarpp
315
+ msgid "Titles: "
316
+ msgstr "Заглавия:"
317
+
318
+ #: options.php:319
319
+ #@ yarpp
320
+ msgid "Bodies: "
321
+ msgstr "Основни текстове:"
322
+
323
+ #: options.php:321
324
+ #@ yarpp
325
+ msgid "Tags: "
326
+ msgstr "Тагове:"
327
+
328
+ #: options.php:323
329
+ #@ yarpp
330
+ msgid "Categories: "
331
+ msgstr "Категории:"
332
+
333
+ #: options.php:325
334
+ #@ yarpp
335
+ msgid "Cross-relate posts and pages?"
336
+ msgstr "Вкръстосана сродност на страници и публикации?"
337
+
338
+ #: options.php:325
339
+ #@ yarpp
340
+ msgid "When the \"Cross-relate posts and pages\" option is selected, the <code>related_posts()</code>, <code>related_pages()</code>, and <code>related_entries()</code> all will give the same output, returning both related pages and posts."
341
+ msgstr "Когато е избрана опцията \"Вкръстосана сродност на страници и публикации\", <code>related_posts()</code>, <code>related_pages()</code>, и <code>related_entries()</code> ще покажат същия резултат, връщайки сродни страници и публикации."
342
+
343
+ #: options.php:326
344
+ #@ yarpp
345
+ msgid "Show only previous posts?"
346
+ msgstr "Показвай само предишни публикации?"
347
+
348
+ #: options.php:388
349
+ #@ yarpp
350
+ msgid "There is a new beta (VERSION) of Yet Another Related Posts Plugin. You can <A>download it here</a> at your own risk."
351
+ msgstr "Има нова бета (VERSION) на Yet Another Related Posts Plugin. Можете да я <A>свалите тук</a> на ваш собствен риск."
352
+
353
+ #: options.php:390
354
+ #@ yarpp
355
+ msgid "There is a new version (VERSION) of Yet Another Related Posts Plugin available! You can <A>download it here</a>."
356
+ msgstr "Има нова версия (VERSION) на Yet Another Related Posts Plugin! Можете да я <A>свалите тук</a>."
357
+
358
+ #: options.php:404
359
+ #@ yarpp
360
+ msgid "Display options <small>for your website</small>"
361
+ msgstr "Настройки за показване <small>за уеб сайт</small>"
362
+
363
+ #: options.php:409
364
+ #@ yarpp
365
+ msgid "Automatically display related posts?"
366
+ msgstr "Автоматично показвай сродни публикации?"
367
+
368
+ #: options.php:409
369
+ #@ yarpp
370
+ msgid "This option automatically displays related posts right after the content on single entry pages. If this option is off, you will need to manually insert <code>related_posts()</code> or variants (<code>related_pages()</code> and <code>related_entries()</code>) into your theme files."
371
+ msgstr "Тази опция автоматично показва сродни публикации след съдържанието на веяка страница. Ако тази опция е изключена, трябва да вмъкнете на ръка <code>related_posts()</code> или варианти (<code>related_pages()</code> и<code>related_entries()</code>) във вашата тема."
372
+
373
+ #: options.php:410
374
+ #@ yarpp
375
+ msgid "Website display code example"
376
+ msgstr "Примерен код за показване на уеб сайт"
377
+
378
+ #: options.php:410
379
+ #: options.php:480
380
+ #@ yarpp
381
+ msgid "(Update options to reload.)"
382
+ msgstr "(Променете настройките за да презаредите.)"
383
+
384
+ #: options.php:413
385
+ #: options.php:482
386
+ #@ yarpp
387
+ msgid "Maximum number of related posts:"
388
+ msgstr "Най-много сродни публикации:"
389
+
390
+ #: includes.php:270
391
+ #: options.php:414
392
+ #: options.php:483
393
+ #@ yarpp
394
+ msgid "Display using a custom template file"
395
+ msgstr "Покажи със собствен шаблон"
396
+
397
+ #: options.php:483
398
+ #@ yarpp
399
+ msgid "NEW!"
400
+ msgstr "НОВО!"
401
+
402
+ #: options.php:414
403
+ #: options.php:483
404
+ #@ yarpp
405
+ msgid "This advanced option gives you full power to customize how your related posts are displayed. Templates (stored in your theme folder) are written in PHP."
406
+ msgstr "Тази опция за напреднали ви позволява пълен контрол върху това как сродни постове се показват. Шаблоните (които се съхраняват в папката с темите) са написани на PHP."
407
+
408
+ #: includes.php:271
409
+ #: options.php:416
410
+ #: options.php:485
411
+ #@ yarpp
412
+ msgid "Template file:"
413
+ msgstr "Шаблон:"
414
+
415
+ #: options.php:426
416
+ #@ yarpp
417
+ msgid "Before / after related entries:"
418
+ msgstr "Преди / След сродни публикации:"
419
+
420
+ #: options.php:427
421
+ #: options.php:432
422
+ #: options.php:441
423
+ #: options.php:496
424
+ #: options.php:501
425
+ #: options.php:510
426
+ #@ yarpp
427
+ msgid "For example:"
428
+ msgstr "Пример:"
429
+
430
+ #: options.php:427
431
+ #: options.php:432
432
+ #: options.php:441
433
+ #: options.php:496
434
+ #: options.php:501
435
+ #: options.php:510
436
+ #@ yarpp
437
+ msgid " or "
438
+ msgstr "или"
439
+
440
+ #: options.php:431
441
+ #: options.php:500
442
+ #@ yarpp
443
+ msgid "Before / after each related entry:"
444
+ msgstr "Преди / След всяка сродна публикация:"
445
+
446
+ #: options.php:435
447
+ #: options.php:504
448
+ #@ yarpp
449
+ msgid "Show excerpt?"
450
+ msgstr "Покажи откъс?"
451
+
452
+ #: options.php:436
453
+ #: options.php:505
454
+ #@ yarpp
455
+ msgid "Excerpt length (No. of words):"
456
+ msgstr "Дължина на откъсът (брой на думи):"
457
+
458
+ #: options.php:440
459
+ #@ yarpp
460
+ msgid "Before / after (Excerpt):"
461
+ msgstr "Преди / След (Откъс):"
462
+
463
+ #: options.php:446
464
+ #: options.php:515
465
+ #@ yarpp
466
+ msgid "Order results:"
467
+ msgstr "Подреди резултатите:"
468
+
469
+ #: options.php:448
470
+ #: options.php:517
471
+ #@ yarpp
472
+ msgid "score (high relevance to low)"
473
+ msgstr "резултат (висок към нисък)"
474
+
475
+ #: options.php:449
476
+ #: options.php:518
477
+ #@ yarpp
478
+ msgid "score (low relevance to high)"
479
+ msgstr "резултат (нисък към висок)"
480
+
481
+ #: options.php:450
482
+ #: options.php:519
483
+ #@ yarpp
484
+ msgid "date (new to old)"
485
+ msgstr "дата (нова към стара)"
486
+
487
+ #: options.php:451
488
+ #: options.php:520
489
+ #@ yarpp
490
+ msgid "date (old to new)"
491
+ msgstr "дата (стара към нова)"
492
+
493
+ #: options.php:452
494
+ #: options.php:521
495
+ #@ yarpp
496
+ msgid "title (alphabetical)"
497
+ msgstr "заглавие (по азбучен ред)"
498
+
499
+ #: options.php:453
500
+ #: options.php:522
501
+ #@ yarpp
502
+ msgid "title (reverse alphabetical)"
503
+ msgstr "заглавие (по обратен азбучен ред)"
504
+
505
+ #: options.php:458
506
+ #: options.php:527
507
+ #@ yarpp
508
+ msgid "Default display if no results:"
509
+ msgstr "Показване по подразбиране когато няма резултати:"
510
+
511
+ #: options.php:462
512
+ #: options.php:530
513
+ #, php-format
514
+ #@ yarpp
515
+ msgid "This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated."
516
+ msgstr "Тази опция ще добави кода %s. Опитайте да я включите, променяйки настройките, и ще видите примерния кода от дясно. Тези връзки и донации ще бъдат оценени."
517
+
518
+ #: options.php:472
519
+ #@ yarpp
520
+ msgid "Display options <small>for RSS</small>"
521
+ msgstr "Настройки за показване <small>за RSS</small>"
522
+
523
+ #: options.php:478
524
+ #@ yarpp
525
+ msgid "Display related posts in feeds?"
526
+ msgstr "Показвай сродни публикации в RSS хранилката?"
527
+
528
+ #: options.php:478
529
+ #@ yarpp
530
+ msgid "This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed."
531
+ msgstr "Тази опция показва сродни публикации на крайа на всяка публикация във вашият RSS и Atom. Не е нужно да променяте шаблоните."
532
+
533
+ #: options.php:479
534
+ #@ yarpp
535
+ msgid "Display related posts in the descriptions?"
536
+ msgstr "Покажи сродни публикации в описанията?"
537
+
538
+ #: options.php:479
539
+ #@ yarpp
540
+ msgid "This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all."
541
+ msgstr "Тази опция показва сродните публикации в полете за описание на RSS, не само в съдържанието. Ако вашите хранилища показват само откъси, само полето за описание се използва, така че тази опция е необходима за каквото и да е показване."
542
+
543
+ #: options.php:480
544
+ #@ yarpp
545
+ msgid "RSS display code example"
546
+ msgstr "Примерен код за показване в RSS "
547
+
548
+ #: options.php:495
549
+ #@ yarpp
550
+ msgid "Before / after related entries display:"
551
+ msgstr "Преди / След сродните публикации показвай:"
552
+
553
+ #: options.php:509
554
+ #@ yarpp
555
+ msgid "Before / after (excerpt):"
556
+ msgstr "Преди / След (откъс):"
557
+
558
+ #: options.php:538
559
+ #@ yarpp
560
+ msgid "Update options"
561
+ msgstr "Промени настройките"
562
+
563
+ #: options.php:539
564
+ #@ yarpp
565
+ msgid "Do you really want to reset your configuration?"
566
+ msgstr "Наистина ли искате да върнете настройките към тези по-подразбиране?"
567
+
568
+ #: options.php:539
569
+ #@ yarpp
570
+ msgid "Reset options"
571
+ msgstr "Върни настройките към тези по-подразбиране"
572
+
573
+ #: template-builtin.php:35
574
+ #, php-format
575
+ #@ yarpp
576
+ msgid "%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."
577
+ msgstr "%f е YARPP резултата на сродност помежду текущата публикация и тази свързана публикация. Виждате този резултат понеже сте влезли във WordPress като administrator. "
578
+
579
+ #: template-metabox.php:12
580
+ #@ yarpp
581
+ msgid "These are the related entries for this entry. Updating this post may change these related posts."
582
+ msgstr "Това са сродните публикации за тази публикация. Ако промените публикацията, сродните публикации може да бъдат променени."
583
+
584
+ #: template-metabox.php:26
585
+ #@ yarpp
586
+ msgid "Whether all of these related entries are actually displayed and how they are displayed depends on your YARPP display options."
587
+ msgstr "Дали всичките свързани публикации ще се показват и как ще се показват се управлява от опциите за показване на YARPP."
588
+
magic.php CHANGED
@@ -19,46 +19,42 @@ function yarpp_set_score_override_flag($q) {
19
}
20
}
21
22
- function yarpp_join_filter($arg) {
23
- global $wpdb, $yarpp_time;
24
- if ($yarpp_time) {
25
- $arg .= " join {$wpdb->prefix}yarpp_related_cache as yarpp on {$wpdb->posts}.ID = yarpp.ID";
26
- }
27
- return $arg;
28
- }
29
-
30
function yarpp_where_filter($arg) {
31
- global $wpdb, $yarpp_time;
32
$threshold = yarpp_get_option('threshold');
33
if ($yarpp_time) {
34
- $arg = str_replace("$wpdb->posts.ID = ","yarpp.score >= $threshold and yarpp.reference_ID = ",$arg);
35
if (yarpp_get_option("recent_only"))
36
$arg .= " and post_date > date_sub(now(), interval ".yarpp_get_option("recent_number")." ".yarpp_get_option("recent_units").") ";
37
- //echo "<!--YARPP TEST: $arg-->";
38
}
39
return $arg;
40
}
41
42
function yarpp_orderby_filter($arg) {
43
global $wpdb, $yarpp_time, $yarpp_score_override;
44
- if ($yarpp_time and $yarpp_score_override) {
45
- $arg = str_replace("$wpdb->posts.post_date","yarpp.score",$arg);
46
- }
47
return $arg;
48
}
49
50
function yarpp_limit_filter($arg) {
51
global $wpdb, $yarpp_time, $yarpp_online_limit;
52
- if ($yarpp_time and $yarpp_online_limit) {
53
return " limit $yarpp_online_limit ";
54
- }
55
return $arg;
56
}
57
58
function yarpp_fields_filter($arg) {
59
- global $wpdb, $yarpp_time;
60
if ($yarpp_time) {
61
- $arg .= ", yarpp.score";
62
}
63
return $arg;
64
}
@@ -67,7 +63,7 @@ function yarpp_demo_request_filter($arg) {
67
global $wpdb, $yarpp_demo_time, $yarpp_limit;
68
if ($yarpp_demo_time) {
69
$wpdb->query("set @count = 0;");
70
- $arg = "SELECT SQL_CALC_FOUND_ROWS ID + $yarpp_limit as ID, post_author, post_date, post_date_gmt, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' as post_content,
71
concat('".__('Example post ','yarpp')."',@count:=@count+1) as post_title, 0 as post_category, '' as post_excerpt, 'publish' as post_status, 'open' as comment_status, 'open' as ping_status, '' as post_password, concat('example-post-',@count) as post_name, '' as to_ping, '' as pinged, post_modified, post_modified_gmt, '' as post_content_filtered, 0 as post_parent, concat('PERMALINK',@count) as guid, 0 as menu_order, 'post' as post_type, '' as post_mime_type, 0 as comment_count, 'SCORE' as score
72
FROM $wpdb->posts
73
ORDER BY ID DESC LIMIT 0, $yarpp_limit";
@@ -152,17 +148,13 @@ function yarpp_sql($type,$args,$giveresults = true,$reference_ID=false,$domain='
152
if ($catweight)
153
$criteria['cat'] = "COUNT( DISTINCT cattax.term_taxonomy_id )";
154
155
- $newsql = "SELECT $reference_ID, ID, "; //post_title, post_date, post_content, post_excerpt,
156
-
157
- //foreach ($criteria as $key => $value) {
158
- // $newsql .= "$value as ${key}score, ";
159
- //}
160
161
- $newsql .= '(0';
162
foreach ($criteria as $key => $value) {
163
$newsql .= "+ $value * ".$weights[$key];
164
}
165
- $newsql .= ') as score';
166
167
$newsql .= "\n from $wpdb->posts \n";
168
@@ -239,7 +231,11 @@ function yarpp_sql($type,$args,$giveresults = true,$reference_ID=false,$domain='
239
/* new in 3.0! new query-based approach: EXTREMELY HACKY! */
240
241
function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'website') {
242
- global $wpdb, $post, $userdata, $yarpp_time, $yarpp_demo_time, $wp_query, $id, $page, $pages, $authordata, $day, $currentmonth, $multipage, $more, $numpages;
243
244
if ($domain != 'demo_web' and $domain != 'demo_rss') {
245
if ($yarpp_time) // if we're already in a YARPP loop, stop now.
@@ -282,9 +278,14 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
282
283
$output = '';
284
285
- if ($domain != 'demo_web' and $domain != 'demo_rss')
286
$yarpp_time = true; // get ready for YARPP TIME!
287
- else
288
$yarpp_demo_time = true;
289
// just so we can return to normal later
290
$current_query = $wp_query;
@@ -328,9 +329,10 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
328
}
329
330
unset($related_query);
331
- if ($domain != 'demo_web' and $domain != 'demo_rss')
332
$yarpp_time = false; // YARPP time is over... :(
333
- else
334
$yarpp_demo_time = false;
335
336
// restore the older wp_query.
@@ -354,7 +356,7 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
354
}
355
356
function yarpp_related_exist($type,$args,$reference_ID=false) {
357
- global $wpdb, $post, $yarpp_time;
358
359
if (is_object($post) and !$reference_ID)
360
$reference_ID = $post->ID;
@@ -365,11 +367,17 @@ function yarpp_related_exist($type,$args,$reference_ID=false) {
365
yarpp_cache_enforce($type,$reference_ID);
366
367
$yarpp_time = true; // get ready for YARPP TIME!
368
$related_query = new WP_Query();
369
$related_query->query(array('p'=>$reference_ID,'showposts'=>10000,'post_type'=>$type));
370
$return = $related_query->have_posts();
371
$yarpp_time = false; // YARPP time is over. :(
372
- unset($related_query);
373
374
return $return;
375
}
@@ -397,51 +405,41 @@ function yarpp_save_cache($post_ID,$force=true) {
397
398
}
399
400
- function yarpp_cache_clear($reference_IDs) {
401
- global $wpdb;
402
- if (is_array($reference_IDs) && count($reference_IDs))
403
- $wpdb->query("delete from {$wpdb->prefix}yarpp_related_cache where reference_ID in (".implode(',',$reference_IDs).")");
404
- }
405
-
406
function yarpp_cache_enforce($type=array('post'),$reference_ID,$force=false) {
407
global $wpdb, $yarpp_debug;
408
409
if ($reference_ID === '' || $reference_ID === false)
410
return false;
411
412
- if (!$force) {
413
- if ($wpdb->get_var("select count(*) as count from {$wpdb->prefix}yarpp_related_cache where reference_ID = $reference_ID")) {
414
- // 3.1.3: removed the cache timeout
415
- // and date > date_sub(now(),interval 600 minute)
416
- if ($yarpp_debug) echo "<!--YARPP is using the cache right now.-->";
417
- return false;
418
- }
419
}
420
421
yarpp_cache_keywords($reference_ID);
422
423
// clear out the cruft
424
- yarpp_cache_clear(array($reference_ID));
425
426
// let's update the related posts
427
- $wpdb->query("insert into {$wpdb->prefix}yarpp_related_cache (reference_ID,ID,score) ".yarpp_sql($type,array(),true,$reference_ID)." on duplicate key update date = now()");
428
429
- $affected = $wpdb->rows_affected;
430
-
431
- if ($affected and $yarpp_debug) echo "<!--YARPP just set the cache for post $reference_ID-->";
432
-
433
- // if changes were made, let's find out which ones are new. We'll want to clear their caches
434
- // so that they will be rebuilt when they're hit next.
435
- if ($affected && !yarpp_get_option('past_only')) {
436
- $new_relations = $wpdb->get_col("select ID from {$wpdb->prefix}yarpp_related_cache where reference_ID = $reference_ID and ID != 0");
437
- yarpp_cache_clear($new_relations);
438
}
439
440
- if (!$affected) {
441
- $wpdb->query("insert into {$wpdb->prefix}yarpp_related_cache (reference_ID,ID,score) values ($reference_ID,0,0) on duplicate key update date = now()");
442
- if (!$wpdb->rows_affected)
443
- return false;
444
- }
445
446
return true;
447
19
}
20
}
21
22
function yarpp_where_filter($arg) {
23
+ global $wpdb, $yarpp_time, $yarpp_related_postdata, $yarpp_related_IDs;
24
$threshold = yarpp_get_option('threshold');
25
if ($yarpp_time) {
26
+ // modify the where clause to use the related ID list.
27
+ $arg = preg_replace("!{$wpdb->posts}.ID = \d+!","{$wpdb->posts}.ID in (".join(',',$yarpp_related_IDs).")",$arg);
28
+
29
+ // if we have "recent only" set, add an additional condition
30
if (yarpp_get_option("recent_only"))
31
$arg .= " and post_date > date_sub(now(), interval ".yarpp_get_option("recent_number")." ".yarpp_get_option("recent_units").") ";
32
}
33
return $arg;
34
}
35
36
function yarpp_orderby_filter($arg) {
37
global $wpdb, $yarpp_time, $yarpp_score_override;
38
+ if ($yarpp_time and $yarpp_score_override)
39
+ return str_replace("$wpdb->posts.post_date","score",$arg);
40
return $arg;
41
}
42
43
function yarpp_limit_filter($arg) {
44
global $wpdb, $yarpp_time, $yarpp_online_limit;
45
+ if ($yarpp_time and $yarpp_online_limit)
46
return " limit $yarpp_online_limit ";
47
return $arg;
48
}
49
50
function yarpp_fields_filter($arg) {
51
+ global $wpdb, $yarpp_time, $wpdb, $yarpp_related_postdata;
52
if ($yarpp_time) {
53
+ $scores = array();
54
+ foreach ($yarpp_related_postdata as $related_entry) {
55
+ $scores[] = " WHEN {$related_entry['ID']} THEN {$related_entry['score']}";
56
+ }
57
+ $arg .= ", CASE {$wpdb->posts}.ID" . join('',$scores) ." END as score";
58
}
59
return $arg;
60
}
63
global $wpdb, $yarpp_demo_time, $yarpp_limit;
64
if ($yarpp_demo_time) {
65
$wpdb->query("set @count = 0;");
66
+ return "SELECT SQL_CALC_FOUND_ROWS ID + $yarpp_limit as ID, post_author, post_date, post_date_gmt, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' as post_content,
67
concat('".__('Example post ','yarpp')."',@count:=@count+1) as post_title, 0 as post_category, '' as post_excerpt, 'publish' as post_status, 'open' as comment_status, 'open' as ping_status, '' as post_password, concat('example-post-',@count) as post_name, '' as to_ping, '' as pinged, post_modified, post_modified_gmt, '' as post_content_filtered, 0 as post_parent, concat('PERMALINK',@count) as guid, 0 as menu_order, 'post' as post_type, '' as post_mime_type, 0 as comment_count, 'SCORE' as score
68
FROM $wpdb->posts
69
ORDER BY ID DESC LIMIT 0, $yarpp_limit";
148
if ($catweight)
149
$criteria['cat'] = "COUNT( DISTINCT cattax.term_taxonomy_id )";
150
151
+ $newsql = "SELECT ID, "; //post_title, post_date, post_content, post_excerpt,
152
153
+ $newsql .= 'ROUND(0';
154
foreach ($criteria as $key => $value) {
155
$newsql .= "+ $value * ".$weights[$key];
156
}
157
+ $newsql .= ',1) as score';
158
159
$newsql .= "\n from $wpdb->posts \n";
160
231
/* new in 3.0! new query-based approach: EXTREMELY HACKY! */
232
233
function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'website') {
234
+ global $wpdb, $post, $userdata, $yarpp_time, $yarpp_demo_time, $wp_query, $id, $page, $pages, $authordata, $day, $currentmonth, $multipage, $more, $numpages, $yarpp_related_postdata, $yarpp_related_IDs;
235
+
236
+ if ($yarpp_debug) {
237
+ echo "rar!";
238
+ }
239
240
if ($domain != 'demo_web' and $domain != 'demo_rss') {
241
if ($yarpp_time) // if we're already in a YARPP loop, stop now.
278
279
$output = '';
280
281
+ if ($domain != 'demo_web' and $domain != 'demo_rss') {
282
$yarpp_time = true; // get ready for YARPP TIME!
283
+ // get the related posts from postdata, and also construct the relate_IDs array
284
+ $yarpp_related_postdata = get_post_meta($reference_ID,YARPP_POSTMETA_RELATED_KEY,true);
285
+ $yarpp_related_IDs = array();
286
+ if ($yarpp_related_postdata)
287
+ $yarpp_related_IDs = array_map(create_function('$x','return $x["ID"];'), $yarpp_related_postdata);
288
+ } else
289
$yarpp_demo_time = true;
290
// just so we can return to normal later
291
$current_query = $wp_query;
329
}
330
331
unset($related_query);
332
+ if ($domain != 'demo_web' and $domain != 'demo_rss') {
333
$yarpp_time = false; // YARPP time is over... :(
334
+ unset($yarpp_related_IDs, $yarpp_related_postdata);
335
+ } else
336
$yarpp_demo_time = false;
337
338
// restore the older wp_query.
356
}
357
358
function yarpp_related_exist($type,$args,$reference_ID=false) {
359
+ global $wpdb, $post, $yarpp_time, $yarpp_related_postdata, $yarpp_related_IDs;
360
361
if (is_object($post) and !$reference_ID)
362
$reference_ID = $post->ID;
367
yarpp_cache_enforce($type,$reference_ID);
368
369
$yarpp_time = true; // get ready for YARPP TIME!
370
+ // get the related posts from postdata, and also construct the relate_IDs array
371
+ $yarpp_related_postdata = get_post_meta($reference_ID,YARPP_POSTMETA_RELATED_KEY,true);
372
+ $yarpp_related_IDs = array();
373
+ if ($yarpp_related_postdata)
374
+ $yarpp_related_IDs = array_map(create_function('$x','return $x["ID"];'), $yarpp_related_postdata);
375
+
376
$related_query = new WP_Query();
377
$related_query->query(array('p'=>$reference_ID,'showposts'=>10000,'post_type'=>$type));
378
$return = $related_query->have_posts();
379
$yarpp_time = false; // YARPP time is over. :(
380
+ unset($related_query, $yarpp_related_postdata, $yarpp_related_IDs);
381
382
return $return;
383
}
405
406
}
407
408
function yarpp_cache_enforce($type=array('post'),$reference_ID,$force=false) {
409
global $wpdb, $yarpp_debug;
410
411
if ($reference_ID === '' || $reference_ID === false)
412
return false;
413
414
+ if (!$force && get_post_meta($reference_ID, YARPP_POSTMETA_RELATED_KEY, true) != false) {
415
+ if ($yarpp_debug) echo "<!--YARPP is using the cache right now.-->";
416
+ return false;
417
}
418
419
yarpp_cache_keywords($reference_ID);
420
421
// clear out the cruft
422
+ delete_post_meta( $reference_ID, YARPP_POSTMETA_RELATED_KEY );
423
424
// let's update the related posts
425
+ $related = $wpdb->get_results(yarpp_sql($type,array(),true,$reference_ID), ARRAY_A);
426
427
+ if (count($related)) {
428
+ update_post_meta($reference_ID, YARPP_POSTMETA_RELATED_KEY, $related);
429
+ if ($yarpp_debug) echo "<!--YARPP just set the cache for post $reference_ID-->";
430
+
431
+ // We'll want to clear their caches
432
+ // so that they will be rebuilt when they're hit next.
433
+ if (count($related) && !yarpp_get_option('past_only')) {
434
+ foreach ($related as $related_entry) {
435
+ delete_post_meta( $related_entry['ID'], YARPP_POSTMETA_RELATED_KEY );
436
+ }
437
+ }
438
}
439
440
+ // if no results...
441
+ if (!count($related))
442
+ update_post_meta($reference_ID, YARPP_POSTMETA_RELATED_KEY, YARPP_NO_RELATED);
443
444
return true;
445
readme.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://mitcho.com/code/yarpp/
6
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=66G4DATK4999L&item_name=mitcho%2ecom%2fcode%3a%20donate%20to%20Michael%20Yoshitaka%20Erlewine&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&charset=UTF%2d8
7
Tags: related, posts, post, pages, page, RSS, feed, feeds
8
Requires at least: 2.8
9
- Tested up to: 3.0
10
Stable tag: 3.1.9
11
12
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.
@@ -142,6 +142,7 @@ YARPP is currently localized in the following languages:
142
* Egyptian Arabic (`ar_EG`) by Bishoy Antoun (yarpp-ar at mitcho dot com) of [cdmazika.com](http://www.cdmazika.com).
143
* Standard Arabic (`ar`) by [led](http://led24.de) (yarpp-ar at mitcho dot com)
144
* Belarussian (`by_BY`) by [Fat Cow](http://www.fatcow.com)
145
* Simplified Chinese (`zh_CN`) by Jor Wang (mail at jorwang dot com) of [jorwang.com](http://jorwang.com)
146
* Cypriot Greek (`el_CY`) by Aristidis Tonikidis (yarpp-el at mitcho dot com) of [akouseto.gr](http://www.akouseto.gr)
147
* Dutch (`nl_NL`) by Sybrand van der Werf (yarpp-nl at mitcho dot com)
@@ -178,6 +179,9 @@ If you are a bilingual speaker of English and another language and an avid user
178
179
== Changelog ==
180
181
= 3.1.9 =
182
* Added Standard Arabic localization (`ar`) by [led](http://led24.de)
183
* The Related Posts Widget now can also use custom templates. ([#1143](http://plugins.trac.wordpress.org/ticket/1143))
6
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=66G4DATK4999L&item_name=mitcho%2ecom%2fcode%3a%20donate%20to%20Michael%20Yoshitaka%20Erlewine&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&charset=UTF%2d8
7
Tags: related, posts, post, pages, page, RSS, feed, feeds
8
Requires at least: 2.8
9
+ Tested up to: 3.0.1
10
Stable tag: 3.1.9
11
12
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.
142
* Egyptian Arabic (`ar_EG`) by Bishoy Antoun (yarpp-ar at mitcho dot com) of [cdmazika.com](http://www.cdmazika.com).
143
* Standard Arabic (`ar`) by [led](http://led24.de) (yarpp-ar at mitcho dot com)
144
* Belarussian (`by_BY`) by [Fat Cow](http://www.fatcow.com)
145
+ * Bulgarian (`bg_BG`) by [Flash Gallery](www.flashgallery.org)
146
* Simplified Chinese (`zh_CN`) by Jor Wang (mail at jorwang dot com) of [jorwang.com](http://jorwang.com)
147
* Cypriot Greek (`el_CY`) by Aristidis Tonikidis (yarpp-el at mitcho dot com) of [akouseto.gr](http://www.akouseto.gr)
148
* Dutch (`nl_NL`) by Sybrand van der Werf (yarpp-nl at mitcho dot com)
179
180
== Changelog ==
181
182
+ = 3.2 =
183
+ * YARPP no longer uses custom tables! Both custom tables (`yarpp_related_cache` and `yarpp_keywords_cache`) are automatically removed if you have them. WordPress Post Meta is used instead for caching.
184
+ * Added Bulgarian localization (`bg_BG`) by [Flash Gallery](www.flashgallery.org)
185
= 3.1.9 =
186
* Added Standard Arabic localization (`ar`) by [led](http://led24.de)
187
* The Related Posts Widget now can also use custom templates. ([#1143](http://plugins.trac.wordpress.org/ticket/1143))
yarpp.php CHANGED
@@ -3,15 +3,22 @@
3
Plugin Name: Yet Another Related Posts Plugin
4
Plugin URI: http://mitcho.com/code/yarpp/
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.1.9
7
Author: mitcho (Michael Yoshitaka Erlewine)
8
Author URI: http://mitcho.com/
9
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=66G4DATK4999L&item_name=mitcho%2ecom%2fcode%3a%20donate%20to%20Michael%20Yoshitaka%20Erlewine&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&charset=UTF%2d8
10
*/
11
12
- define('YARPP_VERSION','3.1.9');
13
define('YARPP_DIR',dirname(__FILE__));
14
15
require_once(YARPP_DIR.'/includes.php');
16
require_once(YARPP_DIR.'/related-functions.php');
17
require_once(YARPP_DIR.'/template-functions.php');
@@ -45,7 +52,6 @@ add_action( 'admin_menu', 'yarpp_add_metabox');
45
// update cache on save
46
add_action('save_post','yarpp_save_cache');
47
48
- add_filter('posts_join','yarpp_join_filter');
49
add_filter('posts_where','yarpp_where_filter');
50
add_filter('posts_orderby','yarpp_orderby_filter');
51
add_filter('posts_fields','yarpp_fields_filter');
3
Plugin Name: Yet Another Related Posts Plugin
4
Plugin URI: http://mitcho.com/code/yarpp/
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.2b1
7
Author: mitcho (Michael Yoshitaka Erlewine)
8
Author URI: http://mitcho.com/
9
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=66G4DATK4999L&item_name=mitcho%2ecom%2fcode%3a%20donate%20to%20Michael%20Yoshitaka%20Erlewine&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&charset=UTF%2d8
10
*/
11
+ if (isset($_REQUEST['yarpp_debug']))
12
+ $yarpp_debug = true;
13
14
+ define('YARPP_VERSION','3.2b1');
15
define('YARPP_DIR',dirname(__FILE__));
16
17
+ define('YARPP_POSTMETA_TITLE_KEYWORDS_KEY','_yarpp_title_keywords');
18
+ define('YARPP_POSTMETA_BODY_KEYWORDS_KEY','_yarpp_body_keywords');
19
+ define('YARPP_POSTMETA_RELATED_KEY', '_yarpp_related');
20
+ define('YARPP_NO_RELATED', ':(');
21
+
22
require_once(YARPP_DIR.'/includes.php');
23
require_once(YARPP_DIR.'/related-functions.php');
24
require_once(YARPP_DIR.'/template-functions.php');
52
// update cache on save
53
add_action('save_post','yarpp_save_cache');
54
55
add_filter('posts_where','yarpp_where_filter');
56
add_filter('posts_orderby','yarpp_orderby_filter');
57
add_filter('posts_fields','yarpp_fields_filter');