WP Meta SEO - Version 4.2.4

Version Description

  • Add : Possibility to remove category prefix
    • Fix : The loader image to display incorrectly in the metabox
Download this release

Release Info

Developer JoomUnited
Plugin Icon 128x128 WP Meta SEO
Version 4.2.4
Comparing to
See all releases

Code changes from version 4.2.3 to 4.2.4

assets/js/wp-metaseo-metabox.js CHANGED
@@ -344,7 +344,7 @@ jQuery(document).ready(function ($) {
344
  dataSort = JSON.stringify([sorteditem.attr('data-sort'), sorteditem.attr('data-order')]);
345
  }
346
 
347
- $('tbody#the-list').html('<tr><td colspan="6" class="td-page-loader"><img class="page-loader-loadmore" src="'+wpmseoMetaboxL10n.image_loader+'"></td></tr>');
348
 
349
  $.ajax({
350
  url: ajaxurl,
@@ -545,9 +545,9 @@ jQuery(document).ready(function ($) {
545
  var loadder = '<tr><td colspan="6" class="td-page-loader"><img class="page-loader-loadmore" src="'+wpmseoMetaboxL10n.image_loader+'"></td></tr>';
546
  if (type === 1) {
547
  // Sort loader
548
- $('tbody#the-list').html(loadder);
549
  } else {
550
- $('tbody#the-list').append(loadder);
551
  }
552
  $.ajax({
553
  url: ajaxurl,
344
  dataSort = JSON.stringify([sorteditem.attr('data-sort'), sorteditem.attr('data-order')]);
345
  }
346
 
347
+ $('table#gsc_keywords_table tbody#the-list').html('<tr><td colspan="6" class="td-page-loader"><img class="page-loader-loadmore" src="'+wpmseoMetaboxL10n.image_loader+'"></td></tr>');
348
 
349
  $.ajax({
350
  url: ajaxurl,
545
  var loadder = '<tr><td colspan="6" class="td-page-loader"><img class="page-loader-loadmore" src="'+wpmseoMetaboxL10n.image_loader+'"></td></tr>';
546
  if (type === 1) {
547
  // Sort loader
548
+ $('table#gsc_keywords_table tbody#the-list').html(loadder);
549
  } else {
550
+ $('table#gsc_keywords_table tbody#the-list').append(loadder);
551
  }
552
  $.ajax({
553
  url: ajaxurl,
inc/class.metaseo-admin.php CHANGED
@@ -135,6 +135,13 @@ class MetaSeoAdmin
135
  add_action('wp_ajax_wpms', array($this, 'startProcess'));
136
  add_action('wp_ajax_wpms_ga_save_information', array($this, 'wpmsGASaveInformation'));
137
  add_filter('wpms_the_content', array($this, 'wpmsTheContent'), 10, 2);
 
 
 
 
 
 
 
138
  }
139
 
140
  /**
@@ -4003,4 +4010,19 @@ class MetaSeoAdmin
4003
 
4004
  return trim(home_url(), '/') . $url;
4005
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4006
  }
135
  add_action('wp_ajax_wpms', array($this, 'startProcess'));
136
  add_action('wp_ajax_wpms_ga_save_information', array($this, 'wpmsGASaveInformation'));
137
  add_filter('wpms_the_content', array($this, 'wpmsTheContent'), 10, 2);
138
+
139
+ $settings = get_option('_metaseo_settings');
140
+ if (isset($settings['metaseo_removecatprefix']) && $settings['metaseo_removecatprefix'] === '1') {
141
+ add_action('created_category', array($this, 'wpmsScheduleRewriteFlush'));
142
+ add_action('edited_category', array($this, 'wpmsScheduleRewriteFlush'));
143
+ add_action('delete_category', array($this, 'wpmsScheduleRewriteFlush'));
144
+ }
145
  }
146
 
147
  /**
4010
 
4011
  return trim(home_url(), '/') . $url;
4012
  }
4013
+
4014
+ /**
4015
+ * Schedules a rewrite flush.
4016
+ *
4017
+ * @return void
4018
+ */
4019
+ public function wpmsScheduleRewriteFlush()
4020
+ {
4021
+ // Bail if this is a multisite installation and the site has been switched.
4022
+ if (is_multisite() && ms_is_switched()) {
4023
+ return;
4024
+ }
4025
+
4026
+ add_action('shutdown', 'flush_rewrite_rules');
4027
+ }
4028
  }
inc/class.metaseo-rewrite.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Prohibit direct script loading */
3
+ defined('ABSPATH') || die('No direct script access allowed!');
4
+
5
+ /**
6
+ * MetaSeoRewrite class
7
+ */
8
+ class MetaSeoRewrite
9
+ {
10
+ /**
11
+ * Settings
12
+ *
13
+ * @var array
14
+ */
15
+ public $settings = array();
16
+
17
+ /**
18
+ * Class constructor.
19
+ */
20
+ public function __construct()
21
+ {
22
+ $this->settings = get_option('_metaseo_settings');
23
+
24
+ add_filter('query_vars', array($this, 'wpmsQueryVars'));
25
+
26
+ add_filter('request', array($this, 'wpmsRequest'));
27
+
28
+ add_filter('category_link', array($this, 'wpmsRemoveCategoryBase'));
29
+
30
+ add_filter('category_rewrite_rules', array($this, 'wpmsCategoryRewriteRules'));
31
+
32
+ add_action('init', array($this, 'wpmsFlush'), 999);
33
+
34
+ add_action('created_category', array($this, 'wpmsScheduleFlush'));
35
+ add_action('edited_category', array($this, 'wpmsScheduleFlush'));
36
+ add_action('delete_category', array($this, 'wpmsScheduleFlush'));
37
+ }
38
+
39
+ /**
40
+ * Save an option that triggers a flush on the next init.
41
+ *
42
+ * @since 1.2.8
43
+ * @return void
44
+ */
45
+ public function wpmsScheduleFlush()
46
+ {
47
+ update_option('wpms_reflush_rewrite', 1);
48
+ }
49
+
50
+ /**
51
+ * If the flush option is set, flush the rewrite rules.
52
+ *
53
+ * @return boolean
54
+ * @since 1.2.8
55
+ */
56
+ public function wpmsFlush()
57
+ {
58
+ $reflush = get_option('wpms_reflush_rewrite');
59
+ if ($reflush) {
60
+ add_action('shutdown', 'flush_rewrite_rules');
61
+ delete_option('wpms_reflush_rewrite');
62
+
63
+ return true;
64
+ }
65
+
66
+ return false;
67
+ }
68
+
69
+ /**
70
+ * Override the category link to remove the category base.
71
+ *
72
+ * @param string $link Unused, overridden by the function.
73
+ *
74
+ * @return string
75
+ */
76
+ public function wpmsRemoveCategoryBase($link)
77
+ {
78
+ $category_base = get_option('category_base');
79
+
80
+ if (empty($category_base)) {
81
+ $category_base = 'category';
82
+ }
83
+
84
+ /*
85
+ * Remove initial slash, if there is one (we remove the trailing slash
86
+ * in the regex replacement and don't want to end up short a slash).
87
+ */
88
+ if (substr($category_base, 0, 1) === '/') {
89
+ $category_base = substr($category_base, 1);
90
+ }
91
+
92
+ $category_base .= '/';
93
+
94
+ return preg_replace('`' . preg_quote($category_base, '`') . '`u', '', $link, 1);
95
+ }
96
+
97
+ /**
98
+ * Update the query vars with the redirect var when remove category prefix is active.
99
+ *
100
+ * @param array $query_vars Main query vars to filter.
101
+ *
102
+ * @return array
103
+ */
104
+ public function wpmsQueryVars($query_vars)
105
+ {
106
+
107
+ if (isset($this->settings['metaseo_removecatprefix']) && $this->settings['metaseo_removecatprefix'] === '1') {
108
+ $query_vars[] = 'wpms_category_redirect';
109
+ }
110
+
111
+ return $query_vars;
112
+ }
113
+
114
+ /**
115
+ * Checks whether the redirect needs to be created.
116
+ *
117
+ * @param array $query_vars Query vars to check for existence of redirect var.
118
+ *
119
+ * @return array|void The query vars.
120
+ */
121
+ public function wpmsRequest($query_vars)
122
+ {
123
+ if (!isset($query_vars['wpms_category_redirect'])) {
124
+ return $query_vars;
125
+ }
126
+
127
+ $this->redirect($query_vars['wpms_category_redirect']);
128
+ }
129
+
130
+ /**
131
+ * This function taken and only slightly adapted from WP No Category Base plugin by Saurabh Gupta.
132
+ *
133
+ * @return array
134
+ */
135
+ public function wpmsCategoryRewriteRules()
136
+ {
137
+ global $wp_rewrite;
138
+
139
+ $category_rewrite = array();
140
+
141
+ $taxonomy = get_taxonomy('category');
142
+ $permalink_structure = get_option('permalink_structure');
143
+
144
+ $blog_prefix = '';
145
+ if (is_multisite() && !is_subdomain_install() && is_main_site() && strpos($permalink_structure, '/blog/') === 0) {
146
+ $blog_prefix = 'blog/';
147
+ }
148
+
149
+ $categories = get_categories(array('hide_empty' => false));
150
+
151
+ if (is_array($categories) && !empty($categories)) {
152
+ foreach ($categories as $category) {
153
+ $category_nicename = $category->slug;
154
+ if ($category->parent === $category->cat_ID) {
155
+ // Recursive recursion.
156
+ $category->parent = 0;
157
+ } elseif ($taxonomy->rewrite['hierarchical'] !== false && $category->parent !== 0) {
158
+ $parents = get_category_parents($category->parent, false, '/', true);
159
+ if (!is_wp_error($parents)) {
160
+ $category_nicename = $parents . $category_nicename;
161
+ }
162
+ unset($parents);
163
+ }
164
+
165
+ $category_rewrite = $this->addCategoryRewrites($category_rewrite, $category_nicename, $blog_prefix, $wp_rewrite->pagination_base);
166
+
167
+ // Adds rules for the uppercase encoded URIs.
168
+ $category_nicename_filtered = $this->convertEncodedToUpper($category_nicename);
169
+
170
+ if ($category_nicename_filtered !== $category_nicename) {
171
+ $category_rewrite = $this->addCategoryRewrites($category_rewrite, $category_nicename_filtered, $blog_prefix, $wp_rewrite->pagination_base);
172
+ }
173
+ }
174
+ unset($categories, $category, $category_nicename, $category_nicename_filtered);
175
+ }
176
+
177
+ // Redirect support from Old Category Base.
178
+ $old_base = $wp_rewrite->get_category_permastruct();
179
+ $old_base = str_replace('%category%', '(.+)', $old_base);
180
+ $old_base = trim($old_base, '/');
181
+ $category_rewrite[$old_base . '$'] = 'index.php?wpms_category_redirect=$matches[1]';
182
+
183
+ return $category_rewrite;
184
+ }
185
+
186
+ /**
187
+ * Adds required category rewrites rules.
188
+ *
189
+ * @param array $rewrites The current set of rules.
190
+ * @param string $category_name Category nicename.
191
+ * @param string $blog_prefix Multisite blog prefix.
192
+ * @param string $pagination_base WP_Query pagination base.
193
+ *
194
+ * @return array The added set of rules.
195
+ */
196
+ protected function addCategoryRewrites($rewrites, $category_name, $blog_prefix, $pagination_base)
197
+ {
198
+ $rewrite_name = $blog_prefix . '(' . $category_name . ')';
199
+
200
+ $rewrites[$rewrite_name . '/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
201
+ $rewrites[$rewrite_name . '/' . $pagination_base . '/?([0-9]{1,})/?$'] = 'index.php?category_name=$matches[1]&paged=$matches[2]';
202
+ $rewrites[$rewrite_name . '/?$'] = 'index.php?category_name=$matches[1]';
203
+
204
+ return $rewrites;
205
+ }
206
+
207
+ /**
208
+ * Walks through category nicename and convert encoded parts
209
+ * into uppercase using $this->encodeToUpper().
210
+ *
211
+ * @param string $name The encoded category URI string.
212
+ *
213
+ * @return string The convered URI string.
214
+ */
215
+ protected function convertEncodedToUpper($name)
216
+ {
217
+ // Checks if name has any encoding in it.
218
+ if (strpos($name, '%') === false) {
219
+ return $name;
220
+ }
221
+
222
+ $names = explode('/', $name);
223
+ $names = array_map(array($this, 'encodeToUpper'), $names);
224
+
225
+ return implode('/', $names);
226
+ }
227
+
228
+ /**
229
+ * Converts the encoded URI string to uppercase.
230
+ *
231
+ * @param string $encoded The encoded string.
232
+ *
233
+ * @return string The uppercased string.
234
+ */
235
+ public function encodeToUpper($encoded)
236
+ {
237
+ if (strpos($encoded, '%') === false) {
238
+ return $encoded;
239
+ }
240
+
241
+ return strtoupper($encoded);
242
+ }
243
+
244
+ /**
245
+ * Redirect the "old" category URL to the new one.
246
+ *
247
+ * @param string $category_redirect The category page to redirect to.
248
+ *
249
+ * @return void
250
+ */
251
+ protected function redirect($category_redirect)
252
+ {
253
+ $catlink = trailingslashit(get_option('home')) . user_trailingslashit($category_redirect, 'category');
254
+
255
+ wp_redirect($catlink, 301, 'Yoast SEO');
256
+ exit;
257
+ }
258
+ } /* End of class */
inc/class.wp-metaseo.php CHANGED
@@ -49,6 +49,14 @@ class WpMetaSeo
49
  public static function pluginActivation($wp = '4.0', $php = '5.3.0')
50
  {
51
  global $wp_version;
 
 
 
 
 
 
 
 
52
  if (version_compare(PHP_VERSION, $php, '<')) {
53
  $flag = 'PHP';
54
  } elseif (version_compare($wp_version, $wp, '<')) {
@@ -88,6 +96,20 @@ class WpMetaSeo
88
  }
89
  }
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  /**
92
  * Create metaseo_images table
93
  *
49
  public static function pluginActivation($wp = '4.0', $php = '5.3.0')
50
  {
51
  global $wp_version;
52
+
53
+ if (is_multisite() && ms_is_switched()) {
54
+ delete_option('rewrite_rules');
55
+ } else {
56
+ $wpmsseo_rewrite = new MetaSeoRewrite();
57
+ $wpmsseo_rewrite->wpmsScheduleFlush();
58
+ }
59
+
60
  if (version_compare(PHP_VERSION, $php, '<')) {
61
  $flag = 'PHP';
62
  } elseif (version_compare($wp_version, $wp, '<')) {
96
  }
97
  }
98
 
99
+ /**
100
+ * Attached to deactivate_{ plugin_basename( __FILES__ ) } by register_activation_hook()
101
+ *
102
+ * @return void
103
+ */
104
+ public static function pluginDeactivation()
105
+ {
106
+ if (is_multisite() && ms_is_switched()) {
107
+ delete_option('rewrite_rules');
108
+ } else {
109
+ add_action('shutdown', 'flush_rewrite_rules');
110
+ }
111
+ }
112
+
113
  /**
114
  * Create metaseo_images table
115
  *
inc/pages/settings.php CHANGED
@@ -110,6 +110,10 @@ $setting_switch_fields = array(
110
  'metaseo_canonical' => array(
111
  'label' => __('Canonical URL', 'wp-meta-seo'),
112
  'help' => __('Add an option to force a canonical URL in each content. WordPress handles it by default but it can be useful in some 3rd party plugins.', 'wp-meta-seo'),
 
 
 
 
113
  )
114
  );
115
 
110
  'metaseo_canonical' => array(
111
  'label' => __('Canonical URL', 'wp-meta-seo'),
112
  'help' => __('Add an option to force a canonical URL in each content. WordPress handles it by default but it can be useful in some 3rd party plugins.', 'wp-meta-seo'),
113
+ ),
114
+ 'metaseo_removecatprefix' => array(
115
+ 'label' => __('Remove category archive', 'wp-meta-seo'),
116
+ 'help' => __('Remove category prefix (category/) in Category URLs', 'wp-meta-seo'),
117
  )
118
  );
119
 
languages/wp-meta-seo-en_US.mo CHANGED
Binary file
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: JoomUnited
3
  Tags: google, webmaster tools, keywords, meta, meta description, meta keywords, meta title, robots meta, search engine optimization, seo, wordpress seo, yahoo, image optimization, image resize, custom post seo, redirect, redirection, 301, broken link
4
  Requires at least: 4.7
5
- Tested up to: 5.3.2
6
- Stable tag: 4.2.3
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -259,6 +259,10 @@ Yes WP Meta SEO is compatible with Gutenberg editor since 3.7 version.
259
 
260
  == Changelog ==
261
 
 
 
 
 
262
  = 4.2.3 =
263
  * Fix : Update successfully message after save settings
264
  * Fix : See more posts in category in the sitemap
2
  Contributors: JoomUnited
3
  Tags: google, webmaster tools, keywords, meta, meta description, meta keywords, meta title, robots meta, search engine optimization, seo, wordpress seo, yahoo, image optimization, image resize, custom post seo, redirect, redirection, 301, broken link
4
  Requires at least: 4.7
5
+ Tested up to: 5.4.0
6
+ Stable tag: 4.2.4
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
259
 
260
  == Changelog ==
261
 
262
+ = 4.2.4 =
263
+ * Add : Possibility to remove category prefix
264
+ * Fix : The loader image to display incorrectly in the metabox
265
+
266
  = 4.2.3 =
267
  * Fix : Update successfully message after save settings
268
  * Fix : See more posts in category in the sitemap
wp-meta-seo.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: WP Meta SEO
5
  * Plugin URI: http://www.joomunited.com/wordpress-products/wp-meta-seo
6
  * Description: WP Meta SEO is a plugin for WordPress to fill meta for content, images and main SEO info in a single view.
7
- * Version: 4.2.3
8
  * Text Domain: wp-meta-seo
9
  * Domain Path: /languages
10
  * Author: JoomUnited
@@ -132,7 +132,7 @@ if (!defined('WPMSEO_VERSION')) {
132
  /**
133
  * Plugin version
134
  */
135
- define('WPMSEO_VERSION', '4.2.3');
136
  }
137
 
138
  if (!defined('WPMS_CLIENTID')) {
@@ -197,6 +197,7 @@ if (!defined('WPMSEO_TEMPLATE_BREADCRUMB')) {
197
  }
198
  include_once(ABSPATH . 'wp-admin/includes/plugin.php');
199
  register_activation_hook(__FILE__, array('WpMetaSeo', 'pluginActivation'));
 
200
 
201
  require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.wp-metaseo.php');
202
  add_action('init', array('WpMetaSeo', 'init'));
@@ -227,7 +228,8 @@ function wpmsGetDefaultSettings()
227
  'metaseo_follow' => 0,
228
  'metaseo_index' => 0,
229
  'metaseo_overridemeta' => 1,
230
- 'metaseo_canonical' => 0
 
231
  );
232
  }
233
 
@@ -384,6 +386,12 @@ function wpmsExtractTags(
384
  return $tags;
385
  }
386
 
 
 
 
 
 
 
387
  if (is_admin()) {
388
  require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-content-list-table.php');
389
  require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-image-list-table.php');
4
  * Plugin Name: WP Meta SEO
5
  * Plugin URI: http://www.joomunited.com/wordpress-products/wp-meta-seo
6
  * Description: WP Meta SEO is a plugin for WordPress to fill meta for content, images and main SEO info in a single view.
7
+ * Version: 4.2.4
8
  * Text Domain: wp-meta-seo
9
  * Domain Path: /languages
10
  * Author: JoomUnited
132
  /**
133
  * Plugin version
134
  */
135
+ define('WPMSEO_VERSION', '4.2.4');
136
  }
137
 
138
  if (!defined('WPMS_CLIENTID')) {
197
  }
198
  include_once(ABSPATH . 'wp-admin/includes/plugin.php');
199
  register_activation_hook(__FILE__, array('WpMetaSeo', 'pluginActivation'));
200
+ register_deactivation_hook(__FILE__, array('WpMetaSeo', 'pluginDeactivation'));
201
 
202
  require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.wp-metaseo.php');
203
  add_action('init', array('WpMetaSeo', 'init'));
228
  'metaseo_follow' => 0,
229
  'metaseo_index' => 0,
230
  'metaseo_overridemeta' => 1,
231
+ 'metaseo_canonical' => 0,
232
+ 'metaseo_removecatprefix' => 0
233
  );
234
  }
235
 
386
  return $tags;
387
  }
388
 
389
+ require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-rewrite.php');
390
+ $settings = get_option('_metaseo_settings');
391
+ if (isset($settings['metaseo_removecatprefix']) && $settings['metaseo_removecatprefix'] === '1') {
392
+ $GLOBALS['metaseo_rewrite'] = new MetaSeoRewrite;
393
+ }
394
+
395
  if (is_admin()) {
396
  require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-content-list-table.php');
397
  require_once(WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-image-list-table.php');