PluginProbe
Redirection / 2.9
Redirection v2.9
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
← All changes | models/importer.php +18 -19 4.02.9 View file →
@@ -7,9 +7,9 @@
7 7 $importers = array(
8 8 'wp-simple-redirect',
9 9 'seo-redirection',
10 10 'safe-redirect-manager',
11 - 'wordpress-old-slugs',
11 + 'wordpress-old-slugs'
12 12 );
13 13
14 14 foreach ( $importers as $importer ) {
15 15 $importer = Red_Plugin_Importer::get_importer( $importer );
@@ -15,9 +15,9 @@
15 15 $importer = Red_Plugin_Importer::get_importer( $importer );
16 16 $results[] = $importer->get_data();
17 17 }
18 18
19 - return array_values( array_filter( $results ) );
19 + return array_filter( $results );
20 20 }
21 21
22 22 public static function get_importer( $id ) {
23 23 if ( $id === 'wp-simple-redirect' ) {
@@ -98,12 +98,11 @@
98 98 public function import_plugin( $group_id ) {
99 99 global $wpdb;
100 100
101 101 $count = 0;
102 - $redirects = $wpdb->get_results(
103 - "SELECT {$wpdb->prefix}postmeta.* FROM {$wpdb->prefix}postmeta INNER JOIN {$wpdb->prefix}posts ON {$wpdb->prefix}posts.ID={$wpdb->prefix}postmeta.post_id " .
104 - "WHERE {$wpdb->prefix}postmeta.meta_key = '_wp_old_slug' AND {$wpdb->prefix}posts.post_status='publish' AND {$wpdb->prefix}posts.post_type IN ('page', 'post')"
105 - );
102 + $sql = "SELECT wp_postmeta.* FROM wp_postmeta INNER JOIN wp_posts ON wp_posts.ID=wp_postmeta.post_id WHERE wp_postmeta.meta_key = '_wp_old_slug' AND wp_posts.post_status='publish' AND wp_posts.post_type IN ('page', 'post')";
103 + $sql = str_replace( 'wp_', $wpdb->prefix, $sql );
104 + $redirects = $wpdb->get_results( $sql );
106 105
107 106 foreach ( $redirects as $redirect ) {
108 107 $item = $this->create_for_item( $group_id, $redirect );
109 108
@@ -120,11 +119,10 @@
120 119 if ( is_wp_error( $new ) ) {
121 120 return false;
122 121 }
123 122
124 - $new_path = wp_parse_url( $new, PHP_URL_PATH );
125 - $old = rtrim( dirname( $new_path ), '/' ) . '/' . rtrim( $redirect->meta_value, '/' ) . '/';
126 - $old = str_replace( '\\', '', $old );
123 + $new = parse_url( $new, PHP_URL_PATH );
124 + $old = dirname( $new ).'/'.$redirect->meta_value;
127 125
128 126 $data = array(
129 127 'url' => $old,
130 128 'action_data' => array( 'url' => $new ),
@@ -140,11 +138,11 @@
140 138
141 139 public function get_data() {
142 140 global $wpdb;
143 141
144 - $total = $wpdb->get_var(
145 - "SELECT COUNT(*) FROM {$wpdb->prefix}postmeta INNER JOIN {$wpdb->prefix}posts ON {$wpdb->prefix}posts.ID={$wpdb->prefix}postmeta.post_id WHERE {$wpdb->prefix}postmeta.meta_key = '_wp_old_slug' AND {$wpdb->prefix}posts.post_status='publish' AND {$wpdb->prefix}posts.post_type IN ('page', 'post')"
146 - );
142 + $sql = "SELECT COUNT(*) FROM wp_postmeta INNER JOIN wp_posts ON wp_posts.ID=wp_postmeta.post_id WHERE wp_postmeta.meta_key = '_wp_old_slug' AND wp_posts.post_status='publish' AND wp_posts.post_type IN ('page', 'post')";
143 + $sql = str_replace( 'wp_', $wpdb->prefix, $sql );
144 + $total = $wpdb->get_var( $sql );
147 145
148 146 if ( $total ) {
149 147 return array(
150 148 'id' => 'wordpress-old-slugs',
@@ -224,11 +222,11 @@
224 222 public function import_plugin( $group_id ) {
225 223 global $wpdb;
226 224
227 225 $count = 0;
228 - $redirects = $wpdb->get_results(
229 - "SELECT {$wpdb->prefix}postmeta.* FROM {$wpdb->prefix}postmeta INNER JOIN {$wpdb->prefix}posts ON {$wpdb->prefix}posts.ID={$wpdb->prefix}postmeta.post_id WHERE {$wpdb->prefix}postmeta.meta_key LIKE '_redirect_rule_%' AND {$wpdb->prefix}posts.post_status='publish'"
230 - );
226 + $sql = "SELECT wp_postmeta.* FROM wp_postmeta INNER JOIN wp_posts ON wp_posts.ID=wp_postmeta.post_id WHERE wp_postmeta.meta_key LIKE '_redirect_rule_%' AND wp_posts.post_status='publish'";
227 + $sql = str_replace( 'wp_', $wpdb->prefix, $sql );
228 + $redirects = $wpdb->get_results( $sql );
231 229
232 230 // Group them by post ID
233 231 $by_post = array();
234 232 foreach ( $redirects as $redirect ) {
@@ -257,9 +255,9 @@
257 255
258 256 if ( strpos( $post['from'], '*' ) !== false ) {
259 257 $regex = true;
260 258 $source = str_replace( '*', '.*', $source );
261 - } elseif ( isset( $post['from_regex'] ) && $post['from_regex'] === '1' ) {
259 + } else if ( isset( $post['from_regex'] ) && $post['from_regex'] === '1' ) {
262 260 $regex = true;
263 261 }
264 262
265 263 $data = array(
@@ -277,11 +275,12 @@
277 275
278 276 public function get_data() {
279 277 global $wpdb;
280 278
281 - $total = $wpdb->get_var(
282 - "SELECT COUNT(*) FROM {$wpdb->prefix}postmeta INNER JOIN {$wpdb->prefix}posts ON {$wpdb->prefix}posts.ID={$wpdb->prefix}postmeta.post_id WHERE {$wpdb->prefix}postmeta.meta_key = '_redirect_rule_from' AND {$wpdb->prefix}posts.post_status='publish'"
283 - );
279 + $sql = "SELECT COUNT(*) FROM wp_postmeta INNER JOIN wp_posts ON wp_posts.ID=wp_postmeta.post_id WHERE wp_postmeta.meta_key = '_redirect_rule_from' AND wp_posts.post_status='publish'";
280 + $sql = str_replace( 'wp_', $wpdb->prefix, $sql );
281 +
282 + $total = $wpdb->get_var( $sql );
284 283
285 284 if ( $total ) {
286 285 return array(
287 286 'id' => 'safe-redirect-manager',