Version Description
Download this release
Release Info
Developer | barrykooij |
Plugin | Related Posts for WordPress |
Version | 1.6.0 |
Comparing to | |
See all releases |
Code changes from version 1.5.0 to 1.6.0
- assets/css/install.css +1 -1
- assets/css/install.less +11 -0
- assets/js/install.js +34 -14
- assets/js/install.min.js +1 -1
- classes/class-installer.php +1 -1
- classes/class-related-post-manager.php +29 -21
- classes/class-related-word-manager.php +68 -56
- classes/hooks/class-hook-ajax-install-link-posts.php +17 -9
- classes/hooks/class-hook-ajax-install-save-words.php +8 -10
- classes/hooks/class-hook-page-install.php +10 -2
- readme.txt +16 -2
- related-posts-for-wp.php +4 -4
- uninstall.php +7 -5
assets/css/install.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.install-steps li{width:33%;padding:10px 15px;font-weight:700;color:#eee;background:#222;float:left;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.install-steps li.step-bar-active{background:#0074a2}.install-steps li:first-child{margin-left:0}.rp4wp-step .rp4wp-install-link-box label{padding-right:20px}.rp4wp-step .rp4wp-install-link-box input{width:40px;text-align:center}.rp4wp-step .rp4wp-install-link-box a.rp4wp-link-now-btn{margin-left:20px;margin-right:10px}.rp4wp-install-link-box{display:inline;padding:15px;border:1px solid #0074a2}.rp4wp-step-2 #progressbar{margin-top:30px}
|
1 |
+
.install-steps li{width:33%;padding:10px 15px;font-weight:700;color:#eee;background:#222;float:left;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.install-steps li.step-bar-active{background:#0074a2}.install-steps li:first-child{margin-left:0}.rp4wp-step #progressbar span{line-height:28px;display:block;text-align:right;padding-right:10px;color:#3B3B3B}.rp4wp-step .rp4wp-install-link-box label{padding-right:20px}.rp4wp-step .rp4wp-install-link-box input{width:40px;text-align:center}.rp4wp-step .rp4wp-install-link-box a.rp4wp-link-now-btn{margin-left:20px;margin-right:10px}.rp4wp-install-link-box{display:inline;padding:15px;border:1px solid #0074a2}.rp4wp-step-2 #progressbar{margin-top:30px}
|
assets/css/install.less
CHANGED
@@ -21,6 +21,17 @@
|
|
21 |
}
|
22 |
|
23 |
.rp4wp-step {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
.rp4wp-install-link-box {
|
25 |
label {
|
26 |
padding-right: 20px;
|
21 |
}
|
22 |
|
23 |
.rp4wp-step {
|
24 |
+
|
25 |
+
#progressbar {
|
26 |
+
span {
|
27 |
+
line-height: 28px;
|
28 |
+
display: block;
|
29 |
+
text-align: right;
|
30 |
+
padding-right: 10px;
|
31 |
+
color: #3B3B3B;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
.rp4wp-install-link-box {
|
36 |
label {
|
37 |
padding-right: 20px;
|
assets/js/install.js
CHANGED
@@ -23,30 +23,39 @@ jQuery(document).ready(function ($) {
|
|
23 |
this.step = step;
|
24 |
this.total_posts = 0;
|
25 |
this.ppr = null;
|
26 |
-
this.req_nr = 0;
|
27 |
this.action = null;
|
|
|
28 |
|
29 |
this.do_request = function () {
|
30 |
var instance = this;
|
31 |
$.post(ajaxurl, {
|
32 |
'action' : this.action,
|
|
|
33 |
'rel_amount': $('#rp4wp_related_posts_amount').val()
|
34 |
}, function (response) {
|
35 |
|
36 |
-
//
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
// Do Progressbar
|
42 |
-
instance.do_progressbar();
|
43 |
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
} else if ('done' == response) {
|
48 |
-
// Done
|
49 |
-
instance.done();
|
50 |
} else {
|
51 |
alert("Woops! Something went wrong while linking.\n\nResponse:\n\n" + response);
|
52 |
}
|
@@ -63,8 +72,12 @@ jQuery(document).ready(function ($) {
|
|
63 |
window.location = $('#rp4wp_admin_url').val() + '?page=rp4wp_install&step=' + ( this.step + 1 );
|
64 |
};
|
65 |
|
66 |
-
this.do_progressbar = function () {
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
};
|
69 |
|
70 |
this.init = function () {
|
@@ -72,13 +85,20 @@ jQuery(document).ready(function ($) {
|
|
72 |
// Setup the progressbar
|
73 |
$('#progressbar').progressbar({value: false});
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
// Get the total posts
|
76 |
this.total_posts = $('#rp4wp_total_posts').val();
|
77 |
|
78 |
// Set the correct action
|
79 |
switch (this.step) {
|
80 |
case 1:
|
81 |
-
this.ppr =
|
82 |
this.action = 'rp4wp_install_save_words';
|
83 |
break;
|
84 |
case 2:
|
23 |
this.step = step;
|
24 |
this.total_posts = 0;
|
25 |
this.ppr = null;
|
|
|
26 |
this.action = null;
|
27 |
+
this.percentage_object = null;
|
28 |
|
29 |
this.do_request = function () {
|
30 |
var instance = this;
|
31 |
$.post(ajaxurl, {
|
32 |
'action' : this.action,
|
33 |
+
'ppr' : this.ppr,
|
34 |
'rel_amount': $('#rp4wp_related_posts_amount').val()
|
35 |
}, function (response) {
|
36 |
|
37 |
+
// The RegExp
|
38 |
+
var response_regex = new RegExp("^[0-9]+$");
|
39 |
+
|
40 |
+
// Trim that string o/
|
41 |
+
response = response.trim();
|
42 |
+
|
43 |
+
// Test it
|
44 |
+
if (response_regex.test(response)) {
|
45 |
+
|
46 |
+
var posts_left = parseInt(response);
|
47 |
|
48 |
// Do Progressbar
|
49 |
+
instance.do_progressbar(posts_left);
|
50 |
|
51 |
+
if (posts_left > 0) {
|
52 |
+
// Do request
|
53 |
+
instance.do_request();
|
54 |
+
} else {
|
55 |
+
// Done
|
56 |
+
instance.done();
|
57 |
+
}
|
58 |
|
|
|
|
|
|
|
59 |
} else {
|
60 |
alert("Woops! Something went wrong while linking.\n\nResponse:\n\n" + response);
|
61 |
}
|
72 |
window.location = $('#rp4wp_admin_url').val() + '?page=rp4wp_install&step=' + ( this.step + 1 );
|
73 |
};
|
74 |
|
75 |
+
this.do_progressbar = function (posts_left) {
|
76 |
+
var progress = Math.round(( ( this.total_posts - posts_left ) / this.total_posts ) * 100);
|
77 |
+
if (progress > 0) {
|
78 |
+
this.percentage_object.html(progress + '%');
|
79 |
+
$('#progressbar').progressbar({value: progress});
|
80 |
+
}
|
81 |
};
|
82 |
|
83 |
this.init = function () {
|
85 |
// Setup the progressbar
|
86 |
$('#progressbar').progressbar({value: false});
|
87 |
|
88 |
+
// Create the span
|
89 |
+
this.percentage_object = jQuery('<span>');
|
90 |
+
$('#progressbar').find('div:first').append(this.percentage_object);
|
91 |
+
|
92 |
+
// Set the current progress
|
93 |
+
this.do_progressbar($('#rp4wp_uncached_posts').val());
|
94 |
+
|
95 |
// Get the total posts
|
96 |
this.total_posts = $('#rp4wp_total_posts').val();
|
97 |
|
98 |
// Set the correct action
|
99 |
switch (this.step) {
|
100 |
case 1:
|
101 |
+
this.ppr = 25;
|
102 |
this.action = 'rp4wp_install_save_words';
|
103 |
break;
|
104 |
case 2:
|
assets/js/install.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(a){function b(b){this.step=b,this.total_posts=0,this.ppr=null,this.
|
1 |
+
jQuery(document).ready(function(a){function b(b){this.step=b,this.total_posts=0,this.ppr=null,this.action=null,this.percentage_object=null,this.do_request=function(){var b=this;a.post(ajaxurl,{action:this.action,ppr:this.ppr,rel_amount:a("#rp4wp_related_posts_amount").val()},function(a){var c=new RegExp("^[0-9]+$");if(a=a.trim(),c.test(a)){var d=parseInt(a);b.do_progressbar(d),d>0?b.do_request():b.done()}else alert("Woops! Something went wrong while linking.\n\nResponse:\n\n"+a)})},this.done=function(){a("#progressbar").progressbar({value:100}),window.location=a("#rp4wp_admin_url").val()+"?page=rp4wp_install&step="+(this.step+1)},this.do_progressbar=function(b){var c=Math.round((this.total_posts-b)/this.total_posts*100);c>0&&(this.percentage_object.html(c+"%"),a("#progressbar").progressbar({value:c}))},this.init=function(){switch(a("#progressbar").progressbar({value:!1}),this.percentage_object=jQuery("<span>"),a("#progressbar").find("div:first").append(this.percentage_object),this.do_progressbar(a("#rp4wp_uncached_posts").val()),this.total_posts=a("#rp4wp_total_posts").val(),this.step){case 1:this.ppr=25,this.action="rp4wp_install_save_words";break;case 2:this.ppr=5,this.action="rp4wp_install_link_posts"}this.do_request()},this.init()}var c=a(".rp4wp-step").attr("rel");1==c?b(1):2==c&&a("#rp4wp-link-now").click(function(){b(2)})});
|
classes/class-installer.php
CHANGED
@@ -17,7 +17,7 @@ class RP4WP_Installer {
|
|
17 |
`word` varchar(255) CHARACTER SET utf8 NOT NULL,
|
18 |
`weight` float unsigned NOT NULL,
|
19 |
`post_type` varchar(20) CHARACTER SET utf8 NOT NULL,
|
20 |
-
PRIMARY KEY (`post_id`,`word`) );";
|
21 |
|
22 |
$wpdb->query( $sql );
|
23 |
}
|
17 |
`word` varchar(255) CHARACTER SET utf8 NOT NULL,
|
18 |
`weight` float unsigned NOT NULL,
|
19 |
`post_type` varchar(20) CHARACTER SET utf8 NOT NULL,
|
20 |
+
PRIMARY KEY (`post_id`,`word`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
21 |
|
22 |
$wpdb->query( $sql );
|
23 |
}
|
classes/class-related-post-manager.php
CHANGED
@@ -16,11 +16,9 @@ class RP4WP_Related_Post_Manager {
|
|
16 |
public function get_related_posts( $post_id, $limit = - 1 ) {
|
17 |
global $wpdb;
|
18 |
|
19 |
-
$related_posts = array();
|
20 |
-
|
21 |
// Build SQl
|
22 |
$sql = "
|
23 |
-
SELECT
|
24 |
FROM `" . RP4WP_Related_Word_Manager::get_database_table() . "` O
|
25 |
INNER JOIN `" . RP4WP_Related_Word_Manager::get_database_table() . "` R ON R.`word` = O.`word`
|
26 |
INNER JOIN `" . $wpdb->posts . "` P ON P.`ID` = R.`post_id`
|
@@ -30,7 +28,7 @@ class RP4WP_Related_Post_Manager {
|
|
30 |
AND R.`post_id` != %d
|
31 |
AND P.`post_status` = 'publish'
|
32 |
GROUP BY P.`id`
|
33 |
-
ORDER BY `
|
34 |
";
|
35 |
|
36 |
// Check & Add Limit
|
@@ -43,18 +41,7 @@ class RP4WP_Related_Post_Manager {
|
|
43 |
$sql = $wpdb->prepare( $sql, $post_id, $post_id, $limit );
|
44 |
|
45 |
// Get post from related cache
|
46 |
-
|
47 |
-
|
48 |
-
if ( count( $rposts ) > 0 ) {
|
49 |
-
foreach ( $rposts as $rpost ) {
|
50 |
-
if ( ! isset( $related_posts[$rpost->ID] ) ) {
|
51 |
-
$related_posts[] = $rpost;
|
52 |
-
}
|
53 |
-
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
return $related_posts;
|
58 |
}
|
59 |
|
60 |
/**
|
@@ -64,8 +51,9 @@ class RP4WP_Related_Post_Manager {
|
|
64 |
*
|
65 |
* @return array
|
66 |
*/
|
67 |
-
public function
|
68 |
return get_posts( array(
|
|
|
69 |
'post_type' => 'post',
|
70 |
'posts_per_page' => $limit,
|
71 |
'post_status' => 'publish',
|
@@ -79,6 +67,26 @@ class RP4WP_Related_Post_Manager {
|
|
79 |
) );
|
80 |
}
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
/**
|
83 |
* Link x related posts to post
|
84 |
*
|
@@ -116,12 +124,12 @@ class RP4WP_Related_Post_Manager {
|
|
116 |
global $wpdb;
|
117 |
|
118 |
// Get uncached posts
|
119 |
-
$
|
120 |
|
121 |
// Check & Loop
|
122 |
-
if ( count( $
|
123 |
-
foreach ( $
|
124 |
-
$this->link_related_post( $
|
125 |
}
|
126 |
}
|
127 |
|
16 |
public function get_related_posts( $post_id, $limit = - 1 ) {
|
17 |
global $wpdb;
|
18 |
|
|
|
|
|
19 |
// Build SQl
|
20 |
$sql = "
|
21 |
+
SELECT P.`ID`
|
22 |
FROM `" . RP4WP_Related_Word_Manager::get_database_table() . "` O
|
23 |
INNER JOIN `" . RP4WP_Related_Word_Manager::get_database_table() . "` R ON R.`word` = O.`word`
|
24 |
INNER JOIN `" . $wpdb->posts . "` P ON P.`ID` = R.`post_id`
|
28 |
AND R.`post_id` != %d
|
29 |
AND P.`post_status` = 'publish'
|
30 |
GROUP BY P.`id`
|
31 |
+
ORDER BY SUM( R.`weight` ) DESC
|
32 |
";
|
33 |
|
34 |
// Check & Add Limit
|
41 |
$sql = $wpdb->prepare( $sql, $post_id, $post_id, $limit );
|
42 |
|
43 |
// Get post from related cache
|
44 |
+
return $wpdb->get_results( $sql );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
/**
|
51 |
*
|
52 |
* @return array
|
53 |
*/
|
54 |
+
public function get_not_auto_linked_posts_ids( $limit ) {
|
55 |
return get_posts( array(
|
56 |
+
'fields' => 'ids',
|
57 |
'post_type' => 'post',
|
58 |
'posts_per_page' => $limit,
|
59 |
'post_status' => 'publish',
|
67 |
) );
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
+
* Get the uncached post count
|
72 |
+
*
|
73 |
+
* @since 1.6.0
|
74 |
+
* @access public
|
75 |
+
*
|
76 |
+
* @return mixed
|
77 |
+
*/
|
78 |
+
public function get_uncached_post_count() {
|
79 |
+
global $wpdb;
|
80 |
+
|
81 |
+
$post_count = $wpdb->get_var( "SELECT COUNT(P.ID) FROM " . $wpdb->posts . " P LEFT JOIN wp_postmeta PM ON (P.ID = PM.post_id AND PM.meta_key = '" . RP4WP_Constants::PM_POST_AUTO_LINKED . "') WHERE 1=1 AND P.post_type = 'post' AND P.post_status = 'publish' AND PM.post_id IS NULL GROUP BY P.post_status" );
|
82 |
+
|
83 |
+
if ( ! is_numeric( $post_count ) ) {
|
84 |
+
$post_count = 0;
|
85 |
+
}
|
86 |
+
|
87 |
+
return $post_count;
|
88 |
+
}
|
89 |
+
|
90 |
/**
|
91 |
* Link x related posts to post
|
92 |
*
|
124 |
global $wpdb;
|
125 |
|
126 |
// Get uncached posts
|
127 |
+
$post_ids = $this->get_not_auto_linked_posts_ids( $post_amount );
|
128 |
|
129 |
// Check & Loop
|
130 |
+
if ( count( $post_ids ) > 0 ) {
|
131 |
+
foreach ( $post_ids as $post_id ) {
|
132 |
+
$this->link_related_post( $post_id, $rel_amount );
|
133 |
}
|
134 |
}
|
135 |
|
classes/class-related-word-manager.php
CHANGED
@@ -8,6 +8,8 @@ class RP4WP_Related_Word_Manager {
|
|
8 |
|
9 |
const DB_TABLE = 'rp4wp_cache';
|
10 |
|
|
|
|
|
11 |
/**
|
12 |
* Get the database table
|
13 |
*
|
@@ -63,36 +65,40 @@ class RP4WP_Related_Word_Manager {
|
|
63 |
*/
|
64 |
private function get_ignored_words( $lang = '' ) {
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
$lang
|
69 |
-
|
|
|
70 |
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
return array();
|
92 |
}
|
93 |
|
94 |
-
|
95 |
-
return apply_filters( 'rp4wp_ignored_words', $ignored_words );
|
96 |
}
|
97 |
|
98 |
/**
|
@@ -136,12 +142,7 @@ class RP4WP_Related_Word_Manager {
|
|
136 |
|
137 |
// Check, Loop
|
138 |
if ( is_array( $title_words ) && count( $title_words ) > 0 ) {
|
139 |
-
|
140 |
-
|
141 |
-
$title_word_multiplied = array_fill( 0, 20, $title_word );
|
142 |
-
$linked_words = array_merge( $linked_words, $title_word_multiplied );
|
143 |
-
|
144 |
-
}
|
145 |
}
|
146 |
}
|
147 |
|
@@ -165,6 +166,10 @@ class RP4WP_Related_Word_Manager {
|
|
165 |
// Split string into words
|
166 |
$words = explode( ' ', $content );
|
167 |
|
|
|
|
|
|
|
|
|
168 |
// Add the $linked_words
|
169 |
$words = array_merge( $words, $linked_words );
|
170 |
|
@@ -188,7 +193,7 @@ class RP4WP_Related_Word_Manager {
|
|
188 |
}
|
189 |
|
190 |
foreach ( $words as $word ) {
|
191 |
-
$word_multiplied_by_weight = array_fill( 0, $weight, $word );
|
192 |
$base_words = array_merge( $base_words, $word_multiplied_by_weight );
|
193 |
}
|
194 |
|
@@ -204,13 +209,15 @@ class RP4WP_Related_Word_Manager {
|
|
204 |
*/
|
205 |
public function get_words_of_post( $post_id ) {
|
206 |
|
|
|
|
|
207 |
$post = get_post( $post_id );
|
208 |
|
209 |
$title_weight = apply_filters( 'rp4wp_weight_title', 80 );
|
210 |
$tag_weight = apply_filters( 'rp4wp_weight_tag', 10 );
|
211 |
$cat_weight = apply_filters( 'rp4wp_weight_cat', 20 );
|
212 |
|
213 |
-
// Get words
|
214 |
$raw_words = $this->get_content_words( $post );
|
215 |
|
216 |
// Get words from title
|
@@ -248,11 +255,6 @@ class RP4WP_Related_Word_Manager {
|
|
248 |
// Trim word
|
249 |
$word = strtolower( trim( $word ) );
|
250 |
|
251 |
-
// Skip empty words
|
252 |
-
if ( '' == $word ) {
|
253 |
-
continue;
|
254 |
-
}
|
255 |
-
|
256 |
// Only use words longer than 1 charecter
|
257 |
if ( strlen( $word ) < 2 ) {
|
258 |
continue;
|
@@ -273,11 +275,6 @@ class RP4WP_Related_Word_Manager {
|
|
273 |
}
|
274 |
}
|
275 |
|
276 |
-
// Sort words
|
277 |
-
arsort( $words );
|
278 |
-
|
279 |
-
// Only return words that occur more than X(3)
|
280 |
-
|
281 |
$new_words = array();
|
282 |
$total_raw_words = count( $raw_words );
|
283 |
$length_weight = 0.6;
|
@@ -285,7 +282,7 @@ class RP4WP_Related_Word_Manager {
|
|
285 |
foreach ( $words as $word => $amount ) {
|
286 |
|
287 |
if ( $amount < 3 ) {
|
288 |
-
|
289 |
}
|
290 |
|
291 |
// Add word and turn amount into weight (make it relative)
|
@@ -293,12 +290,7 @@ class RP4WP_Related_Word_Manager {
|
|
293 |
|
294 |
}
|
295 |
|
296 |
-
|
297 |
-
$words = $new_words;
|
298 |
-
|
299 |
-
// Return words
|
300 |
-
return $words;
|
301 |
-
|
302 |
}
|
303 |
|
304 |
/**
|
@@ -315,9 +307,6 @@ class RP4WP_Related_Word_Manager {
|
|
315 |
// Check words
|
316 |
if ( is_array( $words ) && count( $words ) > 0 ) {
|
317 |
|
318 |
-
// Get post type
|
319 |
-
$post_type = get_post_type( $post_id );
|
320 |
-
|
321 |
// Delete all currents words of post
|
322 |
$this->delete_words( $post_id );
|
323 |
|
@@ -331,7 +320,7 @@ class RP4WP_Related_Word_Manager {
|
|
331 |
'post_id' => $post_id,
|
332 |
'word' => $word,
|
333 |
'weight' => $amount,
|
334 |
-
'post_type' =>
|
335 |
),
|
336 |
array(
|
337 |
'%d',
|
@@ -357,9 +346,11 @@ class RP4WP_Related_Word_Manager {
|
|
357 |
*
|
358 |
* @return array
|
359 |
*/
|
360 |
-
public function
|
|
|
361 |
// Get Posts without 'cached' PM
|
362 |
return get_posts( array(
|
|
|
363 |
'post_type' => 'post',
|
364 |
'posts_per_page' => $limit,
|
365 |
'post_status' => 'publish',
|
@@ -371,6 +362,27 @@ class RP4WP_Related_Word_Manager {
|
|
371 |
),
|
372 |
)
|
373 |
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
}
|
375 |
|
376 |
/**
|
@@ -380,12 +392,12 @@ class RP4WP_Related_Word_Manager {
|
|
380 |
global $wpdb;
|
381 |
|
382 |
// Get uncached posts
|
383 |
-
$
|
384 |
|
385 |
// Check & Loop
|
386 |
-
if ( count( $
|
387 |
-
foreach ( $
|
388 |
-
$this->save_words_of_post( $
|
389 |
}
|
390 |
}
|
391 |
|
8 |
|
9 |
const DB_TABLE = 'rp4wp_cache';
|
10 |
|
11 |
+
private $ignored_words = null;
|
12 |
+
|
13 |
/**
|
14 |
* Get the database table
|
15 |
*
|
65 |
*/
|
66 |
private function get_ignored_words( $lang = '' ) {
|
67 |
|
68 |
+
if ( null == $this->ignored_words ) {
|
69 |
+
// Set the language
|
70 |
+
if ( '' == $lang ) {
|
71 |
+
$lang = get_locale();
|
72 |
+
}
|
73 |
|
74 |
+
// Require the lang file
|
75 |
+
$relative_path = '/ignored-words/' . $lang . '.php';
|
76 |
|
77 |
+
// Validate the file path to prevent traversal attacks
|
78 |
+
if ( 0 !== validate_file( $relative_path ) ) {
|
79 |
+
return array();
|
80 |
+
}
|
81 |
|
82 |
+
$filename = dirname( __FILE__ ) . $relative_path;
|
83 |
|
84 |
+
// Check if file exists
|
85 |
+
if ( ! file_exists( $filename ) ) {
|
86 |
+
return array();
|
87 |
+
}
|
88 |
|
89 |
+
// Require the file
|
90 |
+
$ignored_words = require( $filename );
|
91 |
+
|
92 |
+
// Check if the the $ignored_words are set
|
93 |
+
if ( is_null( $ignored_words ) || ! is_array( $ignored_words ) ) {
|
94 |
+
return array();
|
95 |
+
}
|
96 |
|
97 |
+
// Words to ignore
|
98 |
+
$this->ignored_words = apply_filters( 'rp4wp_ignored_words', $ignored_words );
|
|
|
99 |
}
|
100 |
|
101 |
+
return $this->ignored_words;
|
|
|
102 |
}
|
103 |
|
104 |
/**
|
142 |
|
143 |
// Check, Loop
|
144 |
if ( is_array( $title_words ) && count( $title_words ) > 0 ) {
|
145 |
+
$linked_words = $this->add_words_from_array( $linked_words, $title_words, 20 );
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
}
|
148 |
|
166 |
// Split string into words
|
167 |
$words = explode( ' ', $content );
|
168 |
|
169 |
+
foreach ( $words as $word_key => $word_val ) {
|
170 |
+
$words[$word_key] = iconv( "utf-8", "us-ascii//TRANSLIT", $word_val );
|
171 |
+
}
|
172 |
+
|
173 |
// Add the $linked_words
|
174 |
$words = array_merge( $words, $linked_words );
|
175 |
|
193 |
}
|
194 |
|
195 |
foreach ( $words as $word ) {
|
196 |
+
$word_multiplied_by_weight = array_fill( 0, $weight, iconv( "utf-8", "us-ascii//TRANSLIT", $word ) );
|
197 |
$base_words = array_merge( $base_words, $word_multiplied_by_weight );
|
198 |
}
|
199 |
|
209 |
*/
|
210 |
public function get_words_of_post( $post_id ) {
|
211 |
|
212 |
+
setlocale( LC_CTYPE, 'en_US.UTF8' );
|
213 |
+
|
214 |
$post = get_post( $post_id );
|
215 |
|
216 |
$title_weight = apply_filters( 'rp4wp_weight_title', 80 );
|
217 |
$tag_weight = apply_filters( 'rp4wp_weight_tag', 10 );
|
218 |
$cat_weight = apply_filters( 'rp4wp_weight_cat', 20 );
|
219 |
|
220 |
+
// Get raw words
|
221 |
$raw_words = $this->get_content_words( $post );
|
222 |
|
223 |
// Get words from title
|
255 |
// Trim word
|
256 |
$word = strtolower( trim( $word ) );
|
257 |
|
|
|
|
|
|
|
|
|
|
|
258 |
// Only use words longer than 1 charecter
|
259 |
if ( strlen( $word ) < 2 ) {
|
260 |
continue;
|
275 |
}
|
276 |
}
|
277 |
|
|
|
|
|
|
|
|
|
|
|
278 |
$new_words = array();
|
279 |
$total_raw_words = count( $raw_words );
|
280 |
$length_weight = 0.6;
|
282 |
foreach ( $words as $word => $amount ) {
|
283 |
|
284 |
if ( $amount < 3 ) {
|
285 |
+
continue; // Don't add words that occur less than 3 times
|
286 |
}
|
287 |
|
288 |
// Add word and turn amount into weight (make it relative)
|
290 |
|
291 |
}
|
292 |
|
293 |
+
return $new_words;
|
|
|
|
|
|
|
|
|
|
|
294 |
}
|
295 |
|
296 |
/**
|
307 |
// Check words
|
308 |
if ( is_array( $words ) && count( $words ) > 0 ) {
|
309 |
|
|
|
|
|
|
|
310 |
// Delete all currents words of post
|
311 |
$this->delete_words( $post_id );
|
312 |
|
320 |
'post_id' => $post_id,
|
321 |
'word' => $word,
|
322 |
'weight' => $amount,
|
323 |
+
'post_type' => 'post'
|
324 |
),
|
325 |
array(
|
326 |
'%d',
|
346 |
*
|
347 |
* @return array
|
348 |
*/
|
349 |
+
public function get_uncached_post_ids( $limit = - 1 ) {
|
350 |
+
|
351 |
// Get Posts without 'cached' PM
|
352 |
return get_posts( array(
|
353 |
+
'fields' => 'ids',
|
354 |
'post_type' => 'post',
|
355 |
'posts_per_page' => $limit,
|
356 |
'post_status' => 'publish',
|
362 |
),
|
363 |
)
|
364 |
) );
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Get the uncached post count
|
370 |
+
*
|
371 |
+
* @since 1.6.0
|
372 |
+
* @access public
|
373 |
+
*
|
374 |
+
* @return mixed
|
375 |
+
*/
|
376 |
+
public function get_uncached_post_count() {
|
377 |
+
global $wpdb;
|
378 |
+
|
379 |
+
$post_count = $wpdb->get_var( "SELECT COUNT(P.ID) FROM " . $wpdb->posts . " P LEFT JOIN wp_postmeta PM ON (P.ID = PM.post_id AND PM.meta_key = '" . RP4WP_Constants::PM_CACHED . "') WHERE 1=1 AND P.post_type = 'post' AND P.post_status = 'publish' AND PM.post_id IS NULL GROUP BY P.post_status" );
|
380 |
+
|
381 |
+
if ( ! is_numeric( $post_count ) ) {
|
382 |
+
$post_count = 0;
|
383 |
+
}
|
384 |
+
|
385 |
+
return $post_count;
|
386 |
}
|
387 |
|
388 |
/**
|
392 |
global $wpdb;
|
393 |
|
394 |
// Get uncached posts
|
395 |
+
$post_ids = $this->get_uncached_post_ids( $limit );
|
396 |
|
397 |
// Check & Loop
|
398 |
+
if ( count( $post_ids ) > 0 ) {
|
399 |
+
foreach ( $post_ids as $post_id ) {
|
400 |
+
$this->save_words_of_post( $post_id );
|
401 |
}
|
402 |
}
|
403 |
|
classes/hooks/class-hook-ajax-install-link-posts.php
CHANGED
@@ -9,24 +9,32 @@ class RP4WP_Hook_Ajax_Install_Link_Posts extends RP4WP_Hook {
|
|
9 |
|
10 |
public function run() {
|
11 |
|
|
|
|
|
|
|
12 |
// Get the rel amount
|
13 |
-
$rel_amount = isset( $_POST['rel_amount'] ) ? $_POST['rel_amount'] :
|
14 |
|
15 |
// Related Post Manager object
|
16 |
$related_post_manager = new RP4WP_Related_Post_Manager();
|
17 |
|
18 |
-
// Link
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
echo 'done';
|
24 |
-
} else {
|
25 |
-
echo 'more';
|
26 |
-
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
|
|
|
|
|
|
30 |
exit;
|
31 |
}
|
32 |
|
9 |
|
10 |
public function run() {
|
11 |
|
12 |
+
// Get the PPR
|
13 |
+
$ppr = isset( $_POST['ppr'] ) ? $_POST['ppr'] : 5;
|
14 |
+
|
15 |
// Get the rel amount
|
16 |
+
$rel_amount = isset( $_POST['rel_amount'] ) ? $_POST['rel_amount'] : 3;
|
17 |
|
18 |
// Related Post Manager object
|
19 |
$related_post_manager = new RP4WP_Related_Post_Manager();
|
20 |
|
21 |
+
// Link posts
|
22 |
+
$related_post_manager->link_related_posts( $rel_amount, $ppr );
|
23 |
|
24 |
+
// Get uncached post count
|
25 |
+
$uncached_post_count = $related_post_manager->get_uncached_post_count();
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
// Check if we're done
|
28 |
+
if ( $uncached_post_count == 0 ) {
|
29 |
+
// Save the wizard setting as the option
|
30 |
+
$options = RP4WP()->settings->get_options();
|
31 |
+
$options['automatic_linking_post_amount'] = $rel_amount;
|
32 |
+
update_option( 'rp4wp', $options );
|
33 |
}
|
34 |
|
35 |
+
// Echo the uncached posts
|
36 |
+
echo $uncached_post_count;
|
37 |
+
|
38 |
exit;
|
39 |
}
|
40 |
|
classes/hooks/class-hook-ajax-install-save-words.php
CHANGED
@@ -9,22 +9,20 @@ class RP4WP_Hook_Ajax_Install_Save_Words extends RP4WP_Hook {
|
|
9 |
|
10 |
public function run() {
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
// Related Post Manager
|
15 |
$related_word_manager = new RP4WP_Related_Word_Manager();
|
16 |
|
17 |
-
// Save
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
echo 'done';
|
23 |
-
} else {
|
24 |
-
echo 'more';
|
25 |
-
}
|
26 |
|
27 |
-
|
|
|
28 |
|
29 |
exit;
|
30 |
}
|
9 |
|
10 |
public function run() {
|
11 |
|
12 |
+
// Get the PPR
|
13 |
+
$ppr = isset( $_POST['ppr'] ) ? $_POST['ppr'] : 25;
|
14 |
|
15 |
// Related Post Manager
|
16 |
$related_word_manager = new RP4WP_Related_Word_Manager();
|
17 |
|
18 |
+
// Save words
|
19 |
+
$related_word_manager->save_all_words( $ppr );
|
20 |
|
21 |
+
// Get uncached post count
|
22 |
+
$uncached_post_count = $related_word_manager->get_uncached_post_count();
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
// Echo the uncached posts
|
25 |
+
echo $uncached_post_count;
|
26 |
|
27 |
exit;
|
28 |
}
|
classes/hooks/class-hook-page-install.php
CHANGED
@@ -39,7 +39,6 @@ class RP4WP_Hook_Page_Install extends RP4WP_Hook {
|
|
39 |
if ( isset( $_GET['reinstall'] ) ) {
|
40 |
|
41 |
// Check nonce
|
42 |
-
|
43 |
if ( ! wp_verify_nonce( ( isset( $_GET['rp4wp_nonce'] ) ? $_GET['rp4wp_nonce'] : '' ), RP4WP_Constants::NONCE_REINSTALL ) ) {
|
44 |
wp_die( 'Woah! It looks like something else tried to run the Related Posts for WordPress installation wizard! We were able to stop them, nothing was lost. Please report this incident at <a href="http://wordpress.org/support/plugin/related-posts-for-wp" target="_blank">our forums.</a>' );
|
45 |
}
|
@@ -114,6 +113,11 @@ class RP4WP_Hook_Page_Install extends RP4WP_Hook {
|
|
114 |
echo "<input type='hidden' id='rp4wp_admin_url' value='" . admin_url() . "' />" . PHP_EOL;
|
115 |
|
116 |
if ( 1 == $cur_step ) {
|
|
|
|
|
|
|
|
|
|
|
117 |
?>
|
118 |
<p><?php _e( 'Thank you for choosing Related Posts for WordPress!', 'related-posts-for-wp' ); ?></p>
|
119 |
<p><?php _e( 'Before you can start using Related Posts for WordPress we need to cache your current posts.', 'related-posts-for-wp' ); ?></p>
|
@@ -124,6 +128,10 @@ class RP4WP_Hook_Page_Install extends RP4WP_Hook {
|
|
124 |
<div id="progressbar"></div>
|
125 |
<?php
|
126 |
} elseif ( 2 == $cur_step ) {
|
|
|
|
|
|
|
|
|
127 |
?>
|
128 |
<p style="font-weight: bold;"><?php _e( 'Great! All your posts were successfully cached!', 'related-posts-for-wp' ); ?></p>
|
129 |
<p><?php _e( "You can let me link your posts, based on what I think is related, to each other. And don't worry, if I made a mistake at one of your posts you can easily correct this by editing it manually!", 'related-posts-for-wp' ); ?></p>
|
@@ -131,7 +139,7 @@ class RP4WP_Hook_Page_Install extends RP4WP_Hook {
|
|
131 |
<p style="font-weight: bold;"><?php _e( 'Do NOT close this window if you click the "Link now" button, wait for this process to finish and this wizard to take you to the next step.', 'related-posts-for-wp' ); ?></p>
|
132 |
<br class="clear" />
|
133 |
<p class="rp4wp-install-link-box">
|
134 |
-
<label for="rp4wp_related_posts_amount"><?php _e( 'Amount of related posts per post:', 'related-posts-for-wp' ); ?></label><input class="form-input-tip" type="text" id="rp4wp_related_posts_amount" value="
|
135 |
<a href="javascript:;" class="button button-primary button-large rp4wp-link-now-btn" id="rp4wp-link-now"><?php _e( 'Link now', 'related-posts-for-wp' ); ?></a>
|
136 |
<a href="<?php echo admin_url(); ?>?page=rp4wp_install&step=3" class="button"><?php _e( 'Skip linking', 'related-posts-for-wp' ); ?></a>
|
137 |
</p>
|
39 |
if ( isset( $_GET['reinstall'] ) ) {
|
40 |
|
41 |
// Check nonce
|
|
|
42 |
if ( ! wp_verify_nonce( ( isset( $_GET['rp4wp_nonce'] ) ? $_GET['rp4wp_nonce'] : '' ), RP4WP_Constants::NONCE_REINSTALL ) ) {
|
43 |
wp_die( 'Woah! It looks like something else tried to run the Related Posts for WordPress installation wizard! We were able to stop them, nothing was lost. Please report this incident at <a href="http://wordpress.org/support/plugin/related-posts-for-wp" target="_blank">our forums.</a>' );
|
44 |
}
|
113 |
echo "<input type='hidden' id='rp4wp_admin_url' value='" . admin_url() . "' />" . PHP_EOL;
|
114 |
|
115 |
if ( 1 == $cur_step ) {
|
116 |
+
|
117 |
+
// Echo current uncached posts
|
118 |
+
$related_word_manager = new RP4WP_Related_Word_Manager();
|
119 |
+
echo "<input type='hidden' id='rp4wp_uncached_posts' value='" . $related_word_manager->get_uncached_post_count() . "' />" . PHP_EOL;
|
120 |
+
|
121 |
?>
|
122 |
<p><?php _e( 'Thank you for choosing Related Posts for WordPress!', 'related-posts-for-wp' ); ?></p>
|
123 |
<p><?php _e( 'Before you can start using Related Posts for WordPress we need to cache your current posts.', 'related-posts-for-wp' ); ?></p>
|
128 |
<div id="progressbar"></div>
|
129 |
<?php
|
130 |
} elseif ( 2 == $cur_step ) {
|
131 |
+
|
132 |
+
// Echo current uncached posts
|
133 |
+
$related_post_manager = new RP4WP_Related_Post_Manager();
|
134 |
+
echo "<input type='hidden' id='rp4wp_uncached_posts' value='" . $related_post_manager->get_uncached_post_count() . "' />" . PHP_EOL;
|
135 |
?>
|
136 |
<p style="font-weight: bold;"><?php _e( 'Great! All your posts were successfully cached!', 'related-posts-for-wp' ); ?></p>
|
137 |
<p><?php _e( "You can let me link your posts, based on what I think is related, to each other. And don't worry, if I made a mistake at one of your posts you can easily correct this by editing it manually!", 'related-posts-for-wp' ); ?></p>
|
139 |
<p style="font-weight: bold;"><?php _e( 'Do NOT close this window if you click the "Link now" button, wait for this process to finish and this wizard to take you to the next step.', 'related-posts-for-wp' ); ?></p>
|
140 |
<br class="clear" />
|
141 |
<p class="rp4wp-install-link-box">
|
142 |
+
<label for="rp4wp_related_posts_amount"><?php _e( 'Amount of related posts per post:', 'related-posts-for-wp' ); ?></label><input class="form-input-tip" type="text" id="rp4wp_related_posts_amount" value="<?php echo RP4WP()->settings->get_option( 'automatic_linking_post_amount' ); ?>" />
|
143 |
<a href="javascript:;" class="button button-primary button-large rp4wp-link-now-btn" id="rp4wp-link-now"><?php _e( 'Link now', 'related-posts-for-wp' ); ?></a>
|
144 |
<a href="<?php echo admin_url(); ?>?page=rp4wp_install&step=3" class="button"><?php _e( 'Skip linking', 'related-posts-for-wp' ); ?></a>
|
145 |
</p>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.relatedpostsforwp.com/
|
|
4 |
Tags: related posts for wordpress, related posts for wp, simple related posts, easy related posts, related posts, related, relations, internal links, seo, bounce rate
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.0
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -33,6 +33,9 @@ Related Posts for WordPress is fully compatible with WPML. You can automatically
|
|
33 |
= Shortcode =
|
34 |
Related Posts for WordPress has a shortcode allowing you to display related posts on any position within your content.
|
35 |
|
|
|
|
|
|
|
36 |
**More information**
|
37 |
|
38 |
- Visit the [Related Posts for WordPress website](http://www.relatedpostsforwp.com/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=more-information)
|
@@ -70,6 +73,9 @@ Not yet, we're working on this and this will be added soon!
|
|
70 |
= Is there a shortcode? =
|
71 |
Yes, use [rp4wp]
|
72 |
|
|
|
|
|
|
|
73 |
= Does Related Posts for WordPress uses it's own database table ? =
|
74 |
There is one custom table created for the post cache, this table will however not be used at the frontend of your website. Related Posts are fetched with normal WP_Query objects.
|
75 |
|
@@ -82,6 +88,14 @@ There is one custom table created for the post cache, this table will however no
|
|
82 |
|
83 |
== Changelog ==
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
= 1.5.0: September 5, 2014 =
|
86 |
* Added Related Posts widget.
|
87 |
* Changed 'Delete Post' label to 'Unlink Related Post'.
|
@@ -146,4 +160,4 @@ There is one custom table created for the post cache, this table will however no
|
|
146 |
* Initial version
|
147 |
|
148 |
== Upgrade Notice ==
|
149 |
-
This version is safe to upgrade.
|
4 |
Tags: related posts for wordpress, related posts for wp, simple related posts, easy related posts, related posts, related, relations, internal links, seo, bounce rate
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.0
|
7 |
+
Stable tag: 1.6.0
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
33 |
= Shortcode =
|
34 |
Related Posts for WordPress has a shortcode allowing you to display related posts on any position within your content.
|
35 |
|
36 |
+
= Widget =
|
37 |
+
Related Posts for Wordpress has a widget allowing you to display related posts in any sidebar you'd like.
|
38 |
+
|
39 |
**More information**
|
40 |
|
41 |
- Visit the [Related Posts for WordPress website](http://www.relatedpostsforwp.com/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=more-information)
|
73 |
= Is there a shortcode? =
|
74 |
Yes, use [rp4wp]
|
75 |
|
76 |
+
= Is there a widget? =
|
77 |
+
Yes there is!
|
78 |
+
|
79 |
= Does Related Posts for WordPress uses it's own database table ? =
|
80 |
There is one custom table created for the post cache, this table will however not be used at the frontend of your website. Related Posts are fetched with normal WP_Query objects.
|
81 |
|
88 |
|
89 |
== Changelog ==
|
90 |
|
91 |
+
= 1.6.0: September 12, 2014 =
|
92 |
+
* We're now replacing 'special' characters with their 'normal' equivalent.
|
93 |
+
* Save the wizard settings to options to improve defaults.
|
94 |
+
* Added a percentage to the progressbar to improve progress clarity.
|
95 |
+
* The wizard progress is now updated when returned to wizard.
|
96 |
+
* Various caching tweaks.
|
97 |
+
* Added utf8 charset to cache database table in installer.
|
98 |
+
|
99 |
= 1.5.0: September 5, 2014 =
|
100 |
* Added Related Posts widget.
|
101 |
* Changed 'Delete Post' label to 'Unlink Related Post'.
|
160 |
* Initial version
|
161 |
|
162 |
== Upgrade Notice ==
|
163 |
+
This version is safe to upgrade. If all of your related posts are linked automatically, we do recommend rerunning the wizard for better results.
|
related-posts-for-wp.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Related Posts for WordPress
|
4 |
Plugin URI: http://www.relatedpostsforwp.com/
|
5 |
-
Description: Related Posts for WordPress, related posts
|
6 |
-
Version: 1.
|
7 |
Author: Barry Kooij
|
8 |
Author URI: http://www.barrykooij.com/
|
9 |
License: GPL v3
|
@@ -26,7 +26,7 @@ class RP4WP {
|
|
26 |
|
27 |
private static $instance = null;
|
28 |
|
29 |
-
const VERSION = '1.
|
30 |
|
31 |
/**
|
32 |
* @var RP4WP_Settings
|
@@ -130,7 +130,7 @@ class RP4WP {
|
|
130 |
$manager_hook->load_hooks();
|
131 |
|
132 |
// Include template functions
|
133 |
-
if ( !is_admin() ) {
|
134 |
require_once( plugin_dir_path( self::get_plugin_file() ) . '/includes/template-functions.php' );
|
135 |
}
|
136 |
|
2 |
/*
|
3 |
Plugin Name: Related Posts for WordPress
|
4 |
Plugin URI: http://www.relatedpostsforwp.com/
|
5 |
+
Description: Related Posts for WordPress, the best way to display related posts in WordPress.
|
6 |
+
Version: 1.6.0
|
7 |
Author: Barry Kooij
|
8 |
Author URI: http://www.barrykooij.com/
|
9 |
License: GPL v3
|
26 |
|
27 |
private static $instance = null;
|
28 |
|
29 |
+
const VERSION = '1.6.0';
|
30 |
|
31 |
/**
|
32 |
* @var RP4WP_Settings
|
130 |
$manager_hook->load_hooks();
|
131 |
|
132 |
// Include template functions
|
133 |
+
if ( ! is_admin() ) {
|
134 |
require_once( plugin_dir_path( self::get_plugin_file() ) . '/includes/template-functions.php' );
|
135 |
}
|
136 |
|
uninstall.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// What is happening?
|
4 |
-
if ( !defined( 'ABSPATH' ) || !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
5 |
exit();
|
6 |
}
|
7 |
|
@@ -27,11 +27,13 @@ if ( isset( $options['clean_on_uninstall'] ) && 1 == $options['clean_on_uninstal
|
|
27 |
)
|
28 |
);
|
29 |
|
30 |
-
|
31 |
-
|
|
|
32 |
|
33 |
-
|
34 |
-
|
|
|
35 |
|
36 |
|
37 |
// Delete the options
|
1 |
<?php
|
2 |
|
3 |
// What is happening?
|
4 |
+
if ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
5 |
exit();
|
6 |
}
|
7 |
|
27 |
)
|
28 |
);
|
29 |
|
30 |
+
if ( count( $link_ids ) > 0 ) {
|
31 |
+
// Delete all link posts
|
32 |
+
$wpdb->query( "DELETE FROM $wpdb->posts WHERE `ID` IN (" . implode( ",", $link_ids ) . ");" );
|
33 |
|
34 |
+
// Delete all link post meta
|
35 |
+
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE `post_id` IN (" . implode( ",", $link_ids ) . ");" );
|
36 |
+
}
|
37 |
|
38 |
|
39 |
// Delete the options
|