WP Meta SEO - Version 3.7.6

Version Description

  • Fix : Redirect to home page when WPMS Addon is not activated
Download this release

Release Info

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

Code changes from version 3.7.5 to 3.7.6

Files changed (3) hide show
  1. languages/wp-meta-seo-en_US.mo +0 -0
  2. readme.txt +5 -2
  3. wp-meta-seo.php +135 -133
languages/wp-meta-seo-en_US.mo CHANGED
Binary file
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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.0
5
Tested up to: 4.9.8
6
- Stable tag: 3.7.5
7
Requires PHP: 5.3
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -277,10 +277,13 @@ Yes WP Meta SEO is compatible with Gutenberg editor since 3.7 version.
277
278
== Changelog ==
279
280
= 3.7.5 =
281
* Fix : Warning returned on frontend
282
* Fix : Load Dashboard widget content using ajax method (large amount of data)
283
- * Fix : ¨PHP warning in redirect URL interface
284
285
= 3.7.4 =
286
* Fix : Update alt meta for Elementor image in content
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.0
5
Tested up to: 4.9.8
6
+ Stable tag: 3.7.6
7
Requires PHP: 5.3
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
277
278
== Changelog ==
279
280
+ = 3.7.6 =
281
+ * Fix : Redirect to home page when WPMS Addon is not activated
282
+
283
= 3.7.5 =
284
* Fix : Warning returned on frontend
285
* Fix : Load Dashboard widget content using ajax method (large amount of data)
286
+ * Fix : PHP warning in redirect URL interface
287
288
= 3.7.4 =
289
* Fix : Update alt meta for Elementor image in content
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: 3.7.5
8
* Text Domain: wp-meta-seo
9
* Domain Path: /languages
10
* Author: JoomUnited
@@ -90,7 +90,7 @@ if (!defined('WPMSEO_VERSION')) {
90
/**
91
* Plugin version
92
*/
93
- define('WPMSEO_VERSION', '3.7.5');
94
}
95
96
if (!defined('WPMS_CLIENTID')) {
@@ -637,53 +637,81 @@ function wpmsTemplateRedirect()
637
{
638
global $wpdb;
639
// redirect by rule
640
- if (is_plugin_active(WPMSEO_ADDON_FILENAME)) {
641
- $url = '';
642
- if (isset($_SERVER['REQUEST_URI'])) {
643
- $url = $_SERVER['REQUEST_URI'];
644
- }
645
646
- if (!is_home() && !is_front_page()) {
647
- $redirects = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'wpms_links WHERE (link_url = %s AND link_url != "/") OR type = "add_rule" OR type = "add_custom"', array(
648
- $url
649
- )));
650
- $target = '';
651
- $status_redirect = 302;
652
- foreach ($redirects as $link) {
653
- $link->link_url = str_replace(' ', '%20', $link->link_url);
654
- $matches = false;
655
- // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- remove warning if match the URL
656
- if ((($link->link_url === $url || $link->link_url === rtrim($url, '/') || $link->link_url === urldecode($url))) || (@preg_match('@' . str_replace('@', '\\@', $link->link_url) . '@', $url, $matches) > 0) || (@preg_match('@' . str_replace('@', '\\@', $link->link_url) . '@', urldecode($url), $matches) > 0)) {
657
- $target = $link->link_url_redirect;
658
- if ($link->type === 'add_custom') {
659
- $status_redirect = $link->meta_title;
660
- }
661
662
- break;
663
}
664
}
665
666
- if ($target) {
667
- if (empty($status_redirect)) {
668
- $status_redirect = 302;
669
- }
670
- wp_redirect($target, $status_redirect);
671
- exit();
672
- } else {
673
- if (is_404()) {
674
- if (isset($_SERVER['REQUEST_URI'])) {
675
- $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
676
- if (isset($_SERVER['HTTPS']) &&
677
- ($_SERVER['HTTPS'] === 'on' || (int) $_SERVER['HTTPS'] === 1) ||
678
- isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
679
- $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
680
- $protocol = 'https://';
681
- } else {
682
- $protocol = 'http://';
683
- }
684
- $esc_url = str_replace(array('http://', 'https://'), $protocol, esc_url($url));
685
- $check = $wpdb->get_results($wpdb->prepare(
686
- 'SELECT * FROM ' . $wpdb->prefix . 'wpms_links WHERE (link_url=%s OR link_url=%s OR link_url=%s)',
687
array(
688
$url,
689
$esc_url,
@@ -691,106 +719,80 @@ function wpmsTemplateRedirect()
691
)
692
));
693
694
- if (count($check) === 0) {
695
- // insert url
696
- $insert = array(
697
- 'link_url' => ($url),
698
- 'status_code' => '404 Not Found',
699
- 'status_text' => '404 Not Found',
700
- 'type' => '404_automaticaly',
701
- 'broken_indexed' => 1,
702
- 'broken_internal' => 0,
703
- 'warning' => 0,
704
- 'dismissed' => 0
705
);
706
707
- $wpdb->insert($wpdb->prefix . 'wpms_links', $insert);
708
- } else {
709
- // update url
710
- $links_broken = $wpdb->get_row($wpdb->prepare(
711
- 'SELECT * FROM ' . $wpdb->prefix . 'wpms_links WHERE (link_url=%s OR link_url=%s OR link_url=%s) ',
712
- array(
713
- $url,
714
- $esc_url,
715
- $_SERVER['REQUEST_URI']
716
- )
717
- ));
718
-
719
- if (!empty($links_broken)) {
720
- $value = array('hit' => (int) $links_broken->hit + 1);
721
- $wpdb->update(
722
- $wpdb->prefix . 'wpms_links',
723
- $value,
724
- array('id' => $links_broken->id),
725
- array('%d'),
726
- array('%d')
727
- );
728
-
729
- if (($url === $links_broken->link_url || esc_url($url) === $links_broken->link_url)
730
- && $links_broken->link_url_redirect !== '') {
731
- if ($links_broken->type === 'add_custom') {
732
- $status_redirect = $links_broken->meta_title;
733
- } else {
734
- $status_redirect = 302;
735
- }
736
- if (empty($status_redirect)) {
737
- $status_redirect = 302;
738
- }
739
- wp_redirect($links_broken->link_url_redirect, $status_redirect);
740
- exit();
741
}
742
}
743
}
744
}
745
746
- $defaul_settings_404 = array(
747
- 'wpms_redirect_homepage' => 0,
748
- 'wpms_type_404' => 'none',
749
- 'wpms_page_redirected' => 'none'
750
- );
751
- $wpms_settings_404 = get_option('wpms_settings_404');
752
753
- if (is_array($wpms_settings_404)) {
754
- $defaul_settings_404 = array_merge($defaul_settings_404, $wpms_settings_404);
755
- }
756
757
- // redirect url by settings
758
- if (isset($defaul_settings_404['wpms_redirect_homepage'])
759
- && (int) $defaul_settings_404['wpms_redirect_homepage'] === 1) {
760
- wp_redirect(get_home_url());
761
- exit();
762
- } else {
763
- if (isset($defaul_settings_404['wpms_type_404'])) {
764
- switch ($defaul_settings_404['wpms_type_404']) {
765
- case 'wp-meta-seo-page':
766
- global $wpdb;
767
- $wpms_page = $wpdb->get_row($wpdb->prepare(
768
- 'SELECT * FROM ' . $wpdb->prefix . 'posts WHERE post_title = %s AND post_excerpt = %s',
769
- array(
770
- '404 Error, content does not exist anymore',
771
- 'metaseo_404_page'
772
- )
773
- ));
774
- if (!empty($wpms_page)) {
775
- $link_redirect = get_permalink($wpms_page->ID);
776
- if ($link_redirect) {
777
- wp_redirect($link_redirect);
778
- exit();
779
- }
780
}
781
- break;
782
-
783
- case 'custom_page':
784
- if (isset($defaul_settings_404['wpms_page_redirected'])
785
- && $defaul_settings_404['wpms_page_redirected'] !== 'none') {
786
- $link_redirect = get_permalink($defaul_settings_404['wpms_page_redirected']);
787
- if ($link_redirect) {
788
- wp_redirect($link_redirect);
789
- exit();
790
- }
791
}
792
- break;
793
- }
794
}
795
}
796
}
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: 3.7.6
8
* Text Domain: wp-meta-seo
9
* Domain Path: /languages
10
* Author: JoomUnited
90
/**
91
* Plugin version
92
*/
93
+ define('WPMSEO_VERSION', '3.7.6');
94
}
95
96
if (!defined('WPMS_CLIENTID')) {
637
{
638
global $wpdb;
639
// redirect by rule
640
641
+ $url = '';
642
+ if (isset($_SERVER['REQUEST_URI'])) {
643
+ $url = $_SERVER['REQUEST_URI'];
644
+ }
645
646
+ if (!is_home() && !is_front_page()) {
647
+ $redirects = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'wpms_links WHERE (link_url = %s AND link_url != "/") OR type = "add_rule" OR type = "add_custom"', array(
648
+ $url
649
+ )));
650
+ $target = '';
651
+ $status_redirect = 302;
652
+ foreach ($redirects as $link) {
653
+ $link->link_url = str_replace(' ', '%20', $link->link_url);
654
+ $matches = false;
655
+ // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- remove warning if match the URL
656
+ if ((($link->link_url === $url || $link->link_url === rtrim($url, '/') || $link->link_url === urldecode($url))) || (@preg_match('@' . str_replace('@', '\\@', $link->link_url) . '@', $url, $matches) > 0) || (@preg_match('@' . str_replace('@', '\\@', $link->link_url) . '@', urldecode($url), $matches) > 0)) {
657
+ $target = $link->link_url_redirect;
658
+ if ($link->type === 'add_custom') {
659
+ if (!is_plugin_active(WPMSEO_ADDON_FILENAME)) {
660
+ return;
661
+ }
662
+ $status_redirect = $link->meta_title;
663
}
664
+
665
+ break;
666
}
667
+ }
668
669
+ if ($target) {
670
+ if (empty($status_redirect)) {
671
+ $status_redirect = 302;
672
+ }
673
+ wp_redirect($target, $status_redirect);
674
+ exit();
675
+ } else {
676
+ if (is_404()) {
677
+ if (isset($_SERVER['REQUEST_URI'])) {
678
+ $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
679
+ if (isset($_SERVER['HTTPS']) &&
680
+ ($_SERVER['HTTPS'] === 'on' || (int) $_SERVER['HTTPS'] === 1) ||
681
+ isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
682
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
683
+ $protocol = 'https://';
684
+ } else {
685
+ $protocol = 'http://';
686
+ }
687
+ $esc_url = str_replace(array('http://', 'https://'), $protocol, esc_url($url));
688
+ $check = $wpdb->get_results($wpdb->prepare(
689
+ 'SELECT * FROM ' . $wpdb->prefix . 'wpms_links WHERE (link_url=%s OR link_url=%s OR link_url=%s)',
690
+ array(
691
+ $url,
692
+ $esc_url,
693
+ $_SERVER['REQUEST_URI']
694
+ )
695
+ ));
696
+
697
+ if (count($check) === 0) {
698
+ // insert url
699
+ $insert = array(
700
+ 'link_url' => ($url),
701
+ 'status_code' => '404 Not Found',
702
+ 'status_text' => '404 Not Found',
703
+ 'type' => '404_automaticaly',
704
+ 'broken_indexed' => 1,
705
+ 'broken_internal' => 0,
706
+ 'warning' => 0,
707
+ 'dismissed' => 0
708
+ );
709
+
710
+ $wpdb->insert($wpdb->prefix . 'wpms_links', $insert);
711
+ } else {
712
+ // update url
713
+ $links_broken = $wpdb->get_row($wpdb->prepare(
714
+ 'SELECT * FROM ' . $wpdb->prefix . 'wpms_links WHERE (link_url=%s OR link_url=%s OR link_url=%s) ',
715
array(
716
$url,
717
$esc_url,
719
)
720
));
721
722
+ if (!empty($links_broken)) {
723
+ $value = array('hit' => (int) $links_broken->hit + 1);
724
+ $wpdb->update(
725
+ $wpdb->prefix . 'wpms_links',
726
+ $value,
727
+ array('id' => $links_broken->id),
728
+ array('%d'),
729
+ array('%d')
730
);
731
732
+ if (($url === $links_broken->link_url || esc_url($url) === $links_broken->link_url)
733
+ && $links_broken->link_url_redirect !== '') {
734
+ if (!empty($links_broken->meta_title)) {
735
+ $status_redirect = $links_broken->meta_title;
736
+ } else {
737
+ $status_redirect = 302;
738
+ }
739
+ if (empty($status_redirect)) {
740
+ $status_redirect = 302;
741
}
742
+ wp_redirect($links_broken->link_url_redirect, $status_redirect);
743
+ exit();
744
}
745
}
746
}
747
+ }
748
749
+ $defaul_settings_404 = array(
750
+ 'wpms_redirect_homepage' => 0,
751
+ 'wpms_type_404' => 'none',
752
+ 'wpms_page_redirected' => 'none'
753
+ );
754
+ $wpms_settings_404 = get_option('wpms_settings_404');
755
756
+ if (is_array($wpms_settings_404)) {
757
+ $defaul_settings_404 = array_merge($defaul_settings_404, $wpms_settings_404);
758
+ }
759
760
+ // redirect url by settings
761
+ if (isset($defaul_settings_404['wpms_redirect_homepage'])
762
+ && (int) $defaul_settings_404['wpms_redirect_homepage'] === 1) {
763
+ wp_redirect(get_home_url());
764
+ exit();
765
+ } else {
766
+ if (isset($defaul_settings_404['wpms_type_404'])) {
767
+ switch ($defaul_settings_404['wpms_type_404']) {
768
+ case 'wp-meta-seo-page':
769
+ global $wpdb;
770
+ $wpms_page = $wpdb->get_row($wpdb->prepare(
771
+ 'SELECT * FROM ' . $wpdb->prefix . 'posts WHERE post_title = %s AND post_excerpt = %s',
772
+ array(
773
+ '404 Error, content does not exist anymore',
774
+ 'metaseo_404_page'
775
+ )
776
+ ));
777
+ if (!empty($wpms_page)) {
778
+ $link_redirect = get_permalink($wpms_page->ID);
779
+ if ($link_redirect) {
780
+ wp_redirect($link_redirect);
781
+ exit();
782
}
783
+ }
784
+ break;
785
+
786
+ case 'custom_page':
787
+ if (isset($defaul_settings_404['wpms_page_redirected'])
788
+ && $defaul_settings_404['wpms_page_redirected'] !== 'none') {
789
+ $link_redirect = get_permalink($defaul_settings_404['wpms_page_redirected']);
790
+ if ($link_redirect) {
791
+ wp_redirect($link_redirect);
792
+ exit();
793
}
794
+ }
795
+ break;
796
}
797
}
798
}