Platinum SEO Pack - Version 2.3.7

Version Description

Download this release

Release Info

Developer Rajesh Babu
Plugin Icon 128x128 Platinum SEO Pack
Version 2.3.7
Comparing to
See all releases

Code changes from version 2.3.6 to 2.3.7

Changelog.txt CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  = 2.3.6=
2
  2021-03-10 - Removed the meta tag added by the newly introduced robots api in wordPress 5.7. Added the ability to specify currentyear to title and description formats. You can also directly add the tag variables in the title field and the meta description field. While the title description formats allow you to add the tag variables only towards the beginning or end, you can now add the tag variables anywhere in between the meta title or description text. You can add the tag variable manually to these Platinum SEO meta fields in Post types.
3
 
1
+ = 2.3.7=
2
+ 2021-04-24 - Platinum SEO is now integrated with WordPress REST API. You can now GET the SEO meta data for any Post/Page?Taxonomy/Home from the plugin asa filed psp_head included in responses to requests via the built-in WordPress REST API Enpoints like those for Posts, Types, etc. The other way to retrieve the SEO meta data is through the plugin's own custom Endpoint. You may find the details in the blog post.
3
+
4
  = 2.3.6=
5
  2021-03-10 - Removed the meta tag added by the newly introduced robots api in wordPress 5.7. Added the ability to specify currentyear to title and description formats. You can also directly add the tag variables in the title field and the meta description field. While the title description formats allow you to add the tag variables only towards the beginning or end, you can now add the tag variables anywhere in between the meta title or description text. You can add the tag variable manually to these Platinum SEO meta fields in Post types.
6
 
platinum-seo-pack.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Platinum SEO Pack
5
  Plugin URI: https://techblissonline.com/platinum-wordpress-seo-plugin/
6
  Description: Complete SEO and Social optimization solution for your Wordpress blog/site. It is Simple, Uncomplicated and User friendly with several useful features.
7
- Version: 2.3.6
8
  Author: Techblissonline.com (Rajesh)
9
  Author URI: https://techblissonline.com/
10
  Text Domain: platinum-seo-pack
@@ -56,6 +56,7 @@ include_once( PSP_PLUGIN_HOME . PSPINC . '/generators/psp_pts_seo_metas.php' );
56
  include_once( PSP_PLUGIN_HOME . PSPINC . '/generators/psp_tax_seo_metas.php' );
57
  include_once( PSP_PLUGIN_HOME . PSPINC . '/generators/psp_social_metas.php' );
58
  include_once( PSP_PLUGIN_HOME . PSPINC . '/generators/breadcrumbs.php' );
 
59
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_settings.php' );
60
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_pre_settings.php' );
61
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_rolecap_settings.php' );
@@ -70,6 +71,9 @@ include_once( PSP_PLUGIN_HOME . PSPINC . '/sitemap/psp_sitemap.php' );
70
  global $psp;
71
  $psp = PspMain::get_instance();
72
 
 
 
 
73
  global $psp_db_version;
74
  $psp_db_version = '2.1.0';
75
 
@@ -77,6 +81,8 @@ register_activation_hook ( __FILE__, array ($psp, 'psp_activate' ) );
77
  register_deactivation_hook ( __FILE__, array ($psp, 'psp_deactivate' ) );
78
  add_action( 'upgrader_process_complete', array ($psp, 'psp_plugin_upgrade'),10, 2);
79
  register_activation_hook ( __FILE__, array ($psp, 'psp_db_install' ) );
 
 
80
  add_action( 'plugins_loaded', array ($psp, 'psp_db_install'),10, 2);
81
  add_action( 'plugins_loaded', array ($psp, 'psp_loaded_filter'),10, 1);
82
 
4
  Plugin Name: Platinum SEO Pack
5
  Plugin URI: https://techblissonline.com/platinum-wordpress-seo-plugin/
6
  Description: Complete SEO and Social optimization solution for your Wordpress blog/site. It is Simple, Uncomplicated and User friendly with several useful features.
7
+ Version: 2.3.7
8
  Author: Techblissonline.com (Rajesh)
9
  Author URI: https://techblissonline.com/
10
  Text Domain: platinum-seo-pack
56
  include_once( PSP_PLUGIN_HOME . PSPINC . '/generators/psp_tax_seo_metas.php' );
57
  include_once( PSP_PLUGIN_HOME . PSPINC . '/generators/psp_social_metas.php' );
58
  include_once( PSP_PLUGIN_HOME . PSPINC . '/generators/breadcrumbs.php' );
59
+ include_once( PSP_PLUGIN_HOME . PSPINC . '/generators/psp_rest.php' );
60
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_settings.php' );
61
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_pre_settings.php' );
62
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_rolecap_settings.php' );
71
  global $psp;
72
  $psp = PspMain::get_instance();
73
 
74
+ global $psp_version;
75
+ $psp_version = '2.3.7';
76
+
77
  global $psp_db_version;
78
  $psp_db_version = '2.1.0';
79
 
81
  register_deactivation_hook ( __FILE__, array ($psp, 'psp_deactivate' ) );
82
  add_action( 'upgrader_process_complete', array ($psp, 'psp_plugin_upgrade'),10, 2);
83
  register_activation_hook ( __FILE__, array ($psp, 'psp_db_install' ) );
84
+ register_activation_hook ( __FILE__, array ($psp, 'psp_version_upgrade' ) );
85
+ add_action( 'plugins_loaded', array ($psp, 'psp_version_upgrade'),10, 2);
86
  add_action( 'plugins_loaded', array ($psp, 'psp_db_install'),10, 2);
87
  add_action( 'plugins_loaded', array ($psp, 'psp_loaded_filter'),10, 1);
88
 
psp-include/generators/psp_home_others_seo_metas.php CHANGED
@@ -44,6 +44,8 @@ class PspHomeOthersSeoMetas {
44
  public $date_archive_title = "";
45
  public $pt_archive_title = "";
46
 
 
 
47
  public static function get_instance() {
48
 
49
  if ( null == self::$obj_handle ) {
@@ -82,7 +84,7 @@ class PspHomeOthersSeoMetas {
82
  if (!empty($this->psp_home_settings)) $psp_home_settings = $this->psp_home_settings;
83
  if (!empty($this->psp_sitewide_settungs)) $psp_settings = $this->psp_sitewide_settungs;
84
 
85
- if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
86
  $robots_meta .= $this->noindex_tag;
87
  } else {
88
  $robots_meta .= $this->index_tag;
@@ -232,7 +234,7 @@ class PspHomeOthersSeoMetas {
232
  if (isset($psp_search_result_settings['robots']) && $psp_search_result_settings['robots']) {
233
  $robots_meta .= $this->noindex_tag;
234
  } else {
235
- if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
236
  //if ($psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
237
  $robots_meta .= $this->noindex_tag;
238
  } else {
@@ -415,7 +417,7 @@ class PspHomeOthersSeoMetas {
415
  $robots_meta .= $this->noindex_tag;
416
  } else {
417
 
418
- if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
419
  //if ($psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
420
  $robots_meta .= $this->noindex_tag;
421
  } else {
@@ -545,7 +547,7 @@ class PspHomeOthersSeoMetas {
545
  $robots_meta .= $this->noindex_tag;
546
  } else {
547
 
548
- if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
549
  $robots_meta .= $this->noindex_tag;
550
  } else {
551
  $robots_meta .= $this->index_tag;
@@ -609,9 +611,13 @@ class PspHomeOthersSeoMetas {
609
  $can_link = "";
610
 
611
  //$post_type = get_query_var( 'post_type' );
612
- //if ( is_array( $post_type ) ) $post_type = reset( $post_type );
613
 
614
  $post_type_archive_link = get_post_type_archive_link( $post_type );
 
 
 
 
615
  $can_link = $this->psp_helper->paged_link($post_type_archive_link);
616
  $this->archive_can_link = $can_link;
617
  if ($can_link != '' && ($canonical)) {
@@ -831,11 +837,17 @@ class PspHomeOthersSeoMetas {
831
 
832
  } // end get_date_archive_psp_title
833
 
834
- public function get_pt_archive_psp_title() {
835
 
836
  $title = "";
837
 
838
- $title = post_type_archive_title('', false);
 
 
 
 
 
 
839
 
840
  if (empty($this->psp_posttype_archive_settings)) $this->psp_posttype_archive_settings = get_option("psp_posttype_archive_settings");
841
 
@@ -868,14 +880,20 @@ class PspHomeOthersSeoMetas {
868
 
869
  } // end get_pt_archive_psp_title
870
 
871
- public function get_author_archive_psp_title() {
872
 
873
  $title = "";
874
  $author = "";
875
 
876
  if(empty($this->psp_author_archive_settings)) $this->psp_author_archive_settings = get_option("psp_author_archive_settings");
877
 
878
- $author_obj = get_userdata( get_query_var('author') );
 
 
 
 
 
 
879
 
880
  if ($author_obj) $author = $author_obj->display_name;
881
  //$author = $this->psp_helper->internationalize( $author_obj->display_name );
@@ -925,6 +943,7 @@ class PspHomeOthersSeoMetas {
925
  $home_meta = "";
926
 
927
  $this->psp_home_settings = get_option("psp_home_settings");
 
928
 
929
  $robots_meta_string = $this->get_home_robots_meta();
930
  if (!is_paged()) {
@@ -964,7 +983,7 @@ class PspHomeOthersSeoMetas {
964
  $json_schema_string = "";
965
  }
966
  }
967
- if (!empty($json_schema_string)) {
968
  $jsonld_script_tag = '<scri' . 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n". '</scri' . 'pt>';
969
  }
970
 
@@ -973,7 +992,34 @@ class PspHomeOthersSeoMetas {
973
 
974
  return $seo_meta_string;
975
 
976
- } // end get_home_seo_metas;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
977
 
978
  public function get_search_seo_metas($canonical) {
979
 
@@ -1083,7 +1129,7 @@ class PspHomeOthersSeoMetas {
1083
 
1084
  } // end get_date_archives_seo_metas;
1085
 
1086
- public function get_pt_archives_seo_metas($canonical) {
1087
 
1088
  $can_link = "";
1089
  $term_link = "";
@@ -1092,9 +1138,11 @@ class PspHomeOthersSeoMetas {
1092
  $canonical_meta_string = "";
1093
  $seo_meta_string = "";
1094
  $prevnext_meta_string = "";
1095
-
1096
- $post_type = get_query_var( 'post_type' );
1097
- if ( is_array( $post_type ) ) $post_type = reset( $post_type );
 
 
1098
  //$curr_post_type_obj = get_post_type_object( $post_type );
1099
  //$curr_post_type_obj_title = $post_type_obj->labels->name;
1100
  //if ( ! $curr_post_type_obj->has_archive ) $curr_post_type_obj_title = post_type_archive_title( '', false );
44
  public $date_archive_title = "";
45
  public $pt_archive_title = "";
46
 
47
+ public $current_pageno = 1;
48
+
49
  public static function get_instance() {
50
 
51
  if ( null == self::$obj_handle ) {
84
  if (!empty($this->psp_home_settings)) $psp_home_settings = $this->psp_home_settings;
85
  if (!empty($this->psp_sitewide_settungs)) $psp_settings = $this->psp_sitewide_settungs;
86
 
87
+ if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && ( get_query_var('paged') > 1 || $this->current_pageno > 1 ) ) {
88
  $robots_meta .= $this->noindex_tag;
89
  } else {
90
  $robots_meta .= $this->index_tag;
234
  if (isset($psp_search_result_settings['robots']) && $psp_search_result_settings['robots']) {
235
  $robots_meta .= $this->noindex_tag;
236
  } else {
237
+ if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && ( get_query_var('paged') > 1 || $this->current_pageno > 1 )) {
238
  //if ($psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
239
  $robots_meta .= $this->noindex_tag;
240
  } else {
417
  $robots_meta .= $this->noindex_tag;
418
  } else {
419
 
420
+ if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && ( get_query_var('paged') > 1 || $this->current_pageno > 1 )) {
421
  //if ($psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
422
  $robots_meta .= $this->noindex_tag;
423
  } else {
547
  $robots_meta .= $this->noindex_tag;
548
  } else {
549
 
550
+ if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && ( get_query_var('paged') > 1 || $this->current_pageno > 1 )) {
551
  $robots_meta .= $this->noindex_tag;
552
  } else {
553
  $robots_meta .= $this->index_tag;
611
  $can_link = "";
612
 
613
  //$post_type = get_query_var( 'post_type' );
614
+ //if ( is_array( $post_type ) ) $post_type = reset( $post_type );
615
 
616
  $post_type_archive_link = get_post_type_archive_link( $post_type );
617
+
618
+ if ( !$post_type_archive_link ) {
619
+ return "";
620
+ }
621
  $can_link = $this->psp_helper->paged_link($post_type_archive_link);
622
  $this->archive_can_link = $can_link;
623
  if ($can_link != '' && ($canonical)) {
837
 
838
  } // end get_date_archive_psp_title
839
 
840
+ public function get_pt_archive_psp_title($post_type = '') {
841
 
842
  $title = "";
843
 
844
+ if(! $post_type) {
845
+
846
+ $title = post_type_archive_title('', false);
847
+ } else {
848
+ $post_type_obj = get_post_type_object( $post_type );
849
+ $title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
850
+ }
851
 
852
  if (empty($this->psp_posttype_archive_settings)) $this->psp_posttype_archive_settings = get_option("psp_posttype_archive_settings");
853
 
880
 
881
  } // end get_pt_archive_psp_title
882
 
883
+ public function get_author_archive_psp_title( $user_id = 0 ) {
884
 
885
  $title = "";
886
  $author = "";
887
 
888
  if(empty($this->psp_author_archive_settings)) $this->psp_author_archive_settings = get_option("psp_author_archive_settings");
889
 
890
+ if (!$user_id) {
891
+
892
+ $author_obj = get_userdata( get_query_var('author') );
893
+
894
+ } else {
895
+ $author_obj = get_userdata($user_id);
896
+ }
897
 
898
  if ($author_obj) $author = $author_obj->display_name;
899
  //$author = $this->psp_helper->internationalize( $author_obj->display_name );
943
  $home_meta = "";
944
 
945
  $this->psp_home_settings = get_option("psp_home_settings");
946
+ $psp_settings = get_option("psp_sitewide_settings");
947
 
948
  $robots_meta_string = $this->get_home_robots_meta();
949
  if (!is_paged()) {
983
  $json_schema_string = "";
984
  }
985
  }
986
+ if (!empty($json_schema_string) && !empty($psp_settings['enable_schema']) ) {
987
  $jsonld_script_tag = '<scri' . 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n". '</scri' . 'pt>';
988
  }
989
 
992
 
993
  return $seo_meta_string;
994
 
995
+ } // end get_home_seo_metas;
996
+
997
+ public function psp_get_home_schema() {
998
+
999
+ $jsonld_script_tag = "";
1000
+
1001
+ if (isset($this->psp_home_settings['schema']) && !empty($this->psp_home_settings['schema'])) {
1002
+ $json_schema_string = $this->psp_home_settings['schema'];
1003
+ $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
1004
+ //validate it is a json object
1005
+ $schema_obj = json_decode($json_schema_string);
1006
+ if($schema_obj === null) {
1007
+ $json_schema_string = "";
1008
+ }
1009
+ }
1010
+ if (!empty($json_schema_string)) {
1011
+ $jsonld_script_tag = '<scri' . 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n". '</scri' . 'pt>';
1012
+ }
1013
+
1014
+ if (!empty($jsonld_script_tag) && !is_paged() ) {
1015
+
1016
+ return $jsonld_script_tag;
1017
+
1018
+ } else {
1019
+ return "";
1020
+ }
1021
+
1022
+ } // end psp_get_home_schema;
1023
 
1024
  public function get_search_seo_metas($canonical) {
1025
 
1129
 
1130
  } // end get_date_archives_seo_metas;
1131
 
1132
+ public function get_pt_archives_seo_metas($canonical, $post_type = null) {
1133
 
1134
  $can_link = "";
1135
  $term_link = "";
1138
  $canonical_meta_string = "";
1139
  $seo_meta_string = "";
1140
  $prevnext_meta_string = "";
1141
+
1142
+ if ( $post_type === null ) {
1143
+ $post_type = get_query_var( 'post_type' );
1144
+ if ( is_array( $post_type ) ) $post_type = reset( $post_type );
1145
+ }
1146
  //$curr_post_type_obj = get_post_type_object( $post_type );
1147
  //$curr_post_type_obj_title = $post_type_obj->labels->name;
1148
  //if ( ! $curr_post_type_obj->has_archive ) $curr_post_type_obj_title = post_type_archive_title( '', false );
psp-include/generators/psp_pts_seo_metas.php CHANGED
@@ -45,6 +45,8 @@ class PspPtsSeoMetas {
45
  public $psp_current_ptype_meta = array();
46
  public $psp_current_ptype_social_meta = array();
47
 
 
 
48
  private $default_post_types = array ('post', 'page', 'attachment', 'nav_menu_item', 'revision');
49
 
50
  public static function get_instance() {
@@ -633,6 +635,7 @@ class PspPtsSeoMetas {
633
 
634
  if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
635
  elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
 
636
  else { $paged = 1; }
637
 
638
  return $paged;
@@ -1434,7 +1437,7 @@ class PspPtsSeoMetas {
1434
  }
1435
 
1436
  //$paged = $this->is_this_paged($post);
1437
- $paged = $this->is_this_paged();
1438
 
1439
  $robots_meta_string = $this->get_pt_robots_meta($post, $psp_post_meta, $paged, $cpage);
1440
 
@@ -1455,7 +1458,7 @@ class PspPtsSeoMetas {
1455
  $canonical_meta_string = $this->get_pt_canonical_meta($post, $psp_post_meta, $canonical, $paged);
1456
  }
1457
 
1458
-
1459
 
1460
  $json_schema_string = !empty($this->psp_current_ptype_meta['schema_string']) ? $this->psp_current_ptype_meta['schema_string'] : '';
1461
  //error_log("Schema JSON ".$json_schema_string);
@@ -1467,7 +1470,7 @@ class PspPtsSeoMetas {
1467
  $json_schema_string = "";
1468
  }
1469
 
1470
- if (!empty($json_schema_string)) {
1471
  //$jsonld_script_tag = '<scri' + 'pt type="application/ld+json">'.' \r\n'. $json_schema_string . '\r\n </scri' . 'pt>';
1472
  $jsonld_script_tag = '<scri'.'pt type="application/ld+json">'. "\r\n" . $json_schema_string . "\r\n" . '</scri'.'pt>' ."\r\n";
1473
  }
@@ -1535,5 +1538,36 @@ class PspPtsSeoMetas {
1535
 
1536
  } // end get_pt_seo_metas;
1537
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1538
  }
1539
  ?>
45
  public $psp_current_ptype_meta = array();
46
  public $psp_current_ptype_social_meta = array();
47
 
48
+ public $current_pageno = 1;
49
+
50
  private $default_post_types = array ('post', 'page', 'attachment', 'nav_menu_item', 'revision');
51
 
52
  public static function get_instance() {
635
 
636
  if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
637
  elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
638
+ elseif ( $this->current_pageno > 1 ) { $paged = $this->current_pageno; }
639
  else { $paged = 1; }
640
 
641
  return $paged;
1437
  }
1438
 
1439
  //$paged = $this->is_this_paged($post);
1440
+ $paged = $this->is_this_paged();
1441
 
1442
  $robots_meta_string = $this->get_pt_robots_meta($post, $psp_post_meta, $paged, $cpage);
1443
 
1458
  $canonical_meta_string = $this->get_pt_canonical_meta($post, $psp_post_meta, $canonical, $paged);
1459
  }
1460
 
1461
+ $psp_settings = $this->psp_sitewide_settings;
1462
 
1463
  $json_schema_string = !empty($this->psp_current_ptype_meta['schema_string']) ? $this->psp_current_ptype_meta['schema_string'] : '';
1464
  //error_log("Schema JSON ".$json_schema_string);
1470
  $json_schema_string = "";
1471
  }
1472
 
1473
+ if (!empty($json_schema_string) && !empty($psp_settings['enable_schema']) ) {
1474
  //$jsonld_script_tag = '<scri' + 'pt type="application/ld+json">'.' \r\n'. $json_schema_string . '\r\n </scri' . 'pt>';
1475
  $jsonld_script_tag = '<scri'.'pt type="application/ld+json">'. "\r\n" . $json_schema_string . "\r\n" . '</scri'.'pt>' ."\r\n";
1476
  }
1538
 
1539
  } // end get_pt_seo_metas;
1540
 
1541
+ public function psp_get_pt_schema($post) {
1542
+
1543
+ $jsonld_script_tag = "";
1544
+ $json_schema_string = "";
1545
+ if($post) {
1546
+ $wp_post_meta_data_arr = get_metadata( 'platinumseo', $post->ID, '', false );
1547
+ $json_schema_string = !empty($wp_post_meta_data_arr['_techblissonline_psp_schema_string'][0]) ? $wp_post_meta_data_arr['_techblissonline_psp_schema_string'][0] : '';
1548
+
1549
+ $json_schema_string = html_entity_decode(stripcslashes(esc_html($json_schema_string)));
1550
+ //validate it is a json object
1551
+ $schema_obj = json_decode($json_schema_string);
1552
+ if($schema_obj === null) {
1553
+ $json_schema_string = "";
1554
+ }
1555
+
1556
+ if (!empty($json_schema_string)) {
1557
+ //$jsonld_script_tag = '<scri' + 'pt type="application/ld+json">'.' \r\n'. $json_schema_string . '\r\n </scri' . 'pt>';
1558
+ $jsonld_script_tag = '<scri'.'pt type="application/ld+json">'. "\r\n" . $json_schema_string . "\r\n" . '</scri'.'pt>' ."\r\n";
1559
+ }
1560
+
1561
+ if (!empty($jsonld_script_tag) && !is_paged() ) {
1562
+
1563
+ return $jsonld_script_tag;
1564
+
1565
+ } else {
1566
+ return "";
1567
+ }
1568
+ }
1569
+
1570
+ } // end psp_get_pt_schema;
1571
+
1572
  }
1573
  ?>
psp-include/generators/psp_rest.php ADDED
@@ -0,0 +1,782 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Platinum SEO Pack
4
+ Plugin URI: https://techblissonline.com/platinum-wordpress-seo-plugin/
5
+ Author: Rajesh - Techblissonline
6
+ Author URI: http://techblissonline.com/
7
+ */
8
+ class PspRestApi {
9
+
10
+ private static $obj_handle = null;
11
+
12
+ protected $psp_settings_handle;
13
+ protected $psp_sitewide_settings = array();
14
+ protected $psp_helper;
15
+ protected $psp_social_handle;
16
+ protected $psp_tax_handle;
17
+ protected $psp_pt_handle;
18
+ protected $psp_home_handle;
19
+
20
+ public $pagenumber = 1;
21
+
22
+ public $public_taxonomies = array();
23
+ public $public_post_types = array();
24
+
25
+ const PSP_HEAD_FIELD_NAME = 'psp_head';
26
+ const PSP_META_FOR_URL_ROUTE = 'get_psp_meta';
27
+ const API_V1_NAMESPACE = 'platinumseo/v1';
28
+ const FULL_HEAD_FOR_URL_ROUTE = self::API_V1_NAMESPACE . '/' . self::PSP_META_FOR_URL_ROUTE;
29
+
30
+ public function __construct() {
31
+
32
+ //create settings instance
33
+ $psp_settings_instance = PspSettings::get_instance();
34
+ $this->psp_settings_handle = $psp_settings_instance;
35
+
36
+ $psp_helper_instance = PspHelper::get_instance();
37
+ $this->psp_helper = $psp_helper_instance;
38
+
39
+ $psp_social_instance = PspSocialMetas::get_instance();
40
+ $this->psp_social_handle = $psp_social_instance;
41
+
42
+ $psp_tax_instance = PspTaxSeoMetas::get_instance();
43
+ $this->psp_tax_handle = $psp_tax_instance;
44
+
45
+ $psp_pt_instance = PspPtsSeoMetas::get_instance();
46
+ $this->psp_pt_handle = $psp_pt_instance;
47
+
48
+ $psp_ho_instance = PspHomeOthersSeoMetas::get_instance();
49
+ $this->psp_home_handle = $psp_ho_instance;
50
+
51
+ $psp_settings = array();
52
+ $psp_settings = get_option("psp_sitewide_settings");
53
+ $this->psp_sitewide_settings = $psp_settings;
54
+
55
+ add_action('rest_api_init', array($this, 'register_rest_routes_fields'));
56
+
57
+ }
58
+
59
+ public static function get_instance() {
60
+
61
+ if ( null == self::$obj_handle ) {
62
+ self::$obj_handle = new self;
63
+ }
64
+
65
+ return self::$obj_handle;
66
+
67
+ } // end get_instance;
68
+
69
+ public function register_rest_routes_fields() {
70
+
71
+ $this->psp_register_rest_routes();
72
+ $this->psp_register_rest_fields();
73
+
74
+ }
75
+
76
+ public function psp_register_rest_routes() {
77
+ $rest_route_args = [
78
+ 'methods' => 'GET',
79
+ 'callback' => [ $this, 'get_psp_meta' ],
80
+ 'permission_callback' => '__return_true',
81
+ 'args' => [
82
+ 'url' => [
83
+ 'validate_callback' => [ $this, 'is_valid_url' ],
84
+ 'required' => true,
85
+ ],
86
+ ],
87
+ ];
88
+ \register_rest_route( self::API_V1_NAMESPACE, self::PSP_META_FOR_URL_ROUTE, $rest_route_args );
89
+ }
90
+
91
+ public function get_psp_meta( WP_REST_Request $request ) {
92
+ $url = \esc_url_raw( $request['url'] );
93
+ $pagenum = $this->psp_get_pagenum('page', $url);
94
+ $psp_tax_instance = $this->psp_tax_handle;
95
+ $psp_pt_instance = $this->psp_pt_handle;
96
+ $psp_home_instance = $this->psp_home_handle;
97
+
98
+ if ($pagenum > 1) {
99
+
100
+ $url = $this->psp_get_url_wo_pagination( $url );
101
+ $this->pagenumber = $pagenum;
102
+ //error_log("pagenumber ".$pagenum);
103
+ $this->psp_helper->pagenumber = $pagenum;
104
+ $psp_tax_instance->current_pageno = $pagenum;
105
+ $psp_pt_instance->current_pageno = $pagenum;
106
+ $psp_home_instance->current_pageno = $pagenum;
107
+
108
+ }
109
+ $data = $this->get_psp_mets_from_url( $url );
110
+
111
+ return new WP_REST_Response( $data, $data->status );
112
+ }
113
+
114
+ public function psp_get_pagenum($name, $url)
115
+ {
116
+ //$strURL = $_SERVER['REQUEST_URI'];
117
+ $arrVals = explode("/",$url);
118
+ $found = 0;
119
+ foreach ($arrVals as $index => $value)
120
+ {
121
+ if($value == $name) $found = $index;
122
+ }
123
+ $position = $found + 1;
124
+ return ($found == 0) ? 1 : $arrVals[$position];
125
+ }
126
+
127
+ function psp_get_url_wo_pagination( $url ) {
128
+
129
+ $position = strpos( $url , '/page' );
130
+ $url_wo_pagination = ( $position ) ? substr( $url, 0, $position ) : $url;
131
+
132
+ return trailingslashit( $url_wo_pagination );
133
+
134
+ }
135
+
136
+
137
+ public function get_psp_mets_from_url( $url ) {
138
+
139
+ $psp_head_meta = '';
140
+
141
+ if ( trim( $url, '/' ) === home_url() ) {
142
+
143
+ $psp_head_meta = $this->get_psp_meta_for_frontpage();
144
+ if ($psp_head_meta ) {
145
+ return (object) [
146
+ 'psp_head' => $psp_head_meta,
147
+ 'status' => 200,
148
+ ];
149
+ } else {
150
+ return (object) [
151
+ 'psp_head' => 'No data',
152
+ 'status' => 404,
153
+ ];
154
+ }
155
+ }
156
+
157
+ $post_id = $this->psp_url_to_postid( $url );
158
+
159
+ if ( $post_id ) {
160
+
161
+ $psp_head_meta = $this->get_psp_meta_for_post( $post_id );
162
+
163
+ if ($psp_head_meta ) {
164
+ return (object) [
165
+ 'psp_head' => $psp_head_meta,
166
+ 'status' => 200,
167
+ ];
168
+ } else {
169
+
170
+ return (object) [
171
+ 'psp_head' => 'No data',
172
+ 'status' => 404,
173
+ ];
174
+
175
+ }
176
+
177
+ }
178
+
179
+ if (!$post_id) {
180
+ //error_log("url ".($url));
181
+ $term_id = $this->psp_url_to_term_id( $url );
182
+ //error_log("termid ".($term_id));
183
+
184
+ if ( $term_id ) {
185
+
186
+ $psp_head_meta = $this->get_psp_meta_for_term( $term_id );
187
+
188
+ if ( $psp_head_meta ) {
189
+ return (object) [
190
+ 'psp_head' => $psp_head_meta,
191
+ 'status' => 200,
192
+ ];
193
+ } else {
194
+ return (object) [
195
+ 'psp_head' => 'No data',
196
+ 'status' => 404,
197
+ ];
198
+ }
199
+
200
+ }
201
+
202
+ }
203
+
204
+ return (object) [
205
+ 'psp_head' => $psp_head_meta,
206
+ 'status' => 404,
207
+ ];
208
+
209
+ }
210
+
211
+ private function psp_url_to_postid( $url ) {
212
+ global $wp_rewrite;
213
+
214
+ /**
215
+ * Filters the URL to derive the post ID from.
216
+ *
217
+ * @since 2.2.0
218
+ *
219
+ * @param string $url The URL to derive the post ID from.
220
+ */
221
+ $url = apply_filters( 'psp_url_to_postid', $url );
222
+
223
+ $url_host = str_replace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );
224
+ $home_url_host = str_replace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
225
+
226
+ // Bail early if the URL does not belong to this site.
227
+ if ( $url_host && $url_host !== $home_url_host ) {
228
+ return 0;
229
+ }
230
+
231
+ // First, check to see if there is a 'p=N' or 'page_id=N' to match against.
232
+ if ( preg_match( '#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values ) ) {
233
+ $id = absint( $values[2] );
234
+ if ( $id ) {
235
+ return $id;
236
+ }
237
+ }
238
+
239
+ // Get rid of the #anchor.
240
+ $url_split = explode( '#', $url );
241
+ $url = $url_split[0];
242
+
243
+ // Get rid of URL ?query=string.
244
+ $url_split = explode( '?', $url );
245
+ $url = $url_split[0];
246
+
247
+ // Set the correct URL scheme.
248
+ $scheme = parse_url( home_url(), PHP_URL_SCHEME );
249
+ $url = set_url_scheme( $url, $scheme );
250
+
251
+ // Add 'www.' if it is absent and should be there.
252
+ if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) {
253
+ $url = str_replace( '://', '://www.', $url );
254
+ }
255
+
256
+ // Strip 'www.' if it is present and shouldn't be.
257
+ if ( false === strpos( home_url(), '://www.' ) ) {
258
+ $url = str_replace( '://www.', '://', $url );
259
+ }
260
+
261
+ if ( trim( $url, '/' ) === home_url() && 'page' === get_option( 'show_on_front' ) ) {
262
+ $page_on_front = get_option( 'page_on_front' );
263
+
264
+ if ( $page_on_front && get_post( $page_on_front ) instanceof WP_Post ) {
265
+ return (int) $page_on_front;
266
+ }
267
+ }
268
+
269
+ // Check to see if we are using rewrite rules.
270
+ $rewrite = $wp_rewrite->wp_rewrite_rules();
271
+
272
+ // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options.
273
+ if ( empty( $rewrite ) ) {
274
+ return 0;
275
+ }
276
+
277
+ // Strip 'index.php/' if we're not using path info permalinks.
278
+ if ( ! $wp_rewrite->using_index_permalinks() ) {
279
+ $url = str_replace( $wp_rewrite->index . '/', '', $url );
280
+ }
281
+
282
+ if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) {
283
+ // Chop off http://domain.com/[path].
284
+ $url = str_replace( home_url(), '', $url );
285
+ } else {
286
+ // Chop off /path/to/blog.
287
+ $home_path = parse_url( home_url( '/' ) );
288
+ $home_path = isset( $home_path['path'] ) ? $home_path['path'] : '';
289
+ $url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) );
290
+ }
291
+
292
+ // Trim leading and lagging slashes.
293
+ $url = trim( $url, '/' );
294
+
295
+ $request = $url;
296
+ $post_type_query_vars = array();
297
+
298
+ foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) {
299
+ if ( ! empty( $t->query_var ) ) {
300
+ $post_type_query_vars[ $t->query_var ] = $post_type;
301
+ }
302
+ }
303
+
304
+ // Look for matches.
305
+ $request_match = $request;
306
+ foreach ( (array) $rewrite as $match => $query ) {
307
+
308
+ // If the requesting file is the anchor of the match,
309
+ // prepend it to the path info.
310
+ if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) {
311
+ $request_match = $url . '/' . $request;
312
+ }
313
+
314
+ if ( preg_match( "#^$match#", $request_match, $matches ) ) {
315
+
316
+ if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
317
+ // This is a verbose page match, let's check to be sure about it.
318
+ $page = get_page_by_path( $matches[ $varmatch[1] ] );
319
+ if ( ! $page ) {
320
+ continue;
321
+ }
322
+
323
+ $post_status_obj = get_post_status_object( $page->post_status );
324
+ if ( ! $post_status_obj->public && ! $post_status_obj->protected
325
+ && ! $post_status_obj->private && $post_status_obj->exclude_from_search ) {
326
+ continue;
327
+ }
328
+ }
329
+
330
+ // Got a match.
331
+ // Trim the query of everything up to the '?'.
332
+ $query = preg_replace( '!^.+\?!', '', $query );
333
+
334
+ // Substitute the substring matches into the query.
335
+ $query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) );
336
+
337
+ // Filter out non-public query vars.
338
+ global $wp;
339
+ parse_str( $query, $query_vars );
340
+ $query = array();
341
+ foreach ( (array) $query_vars as $key => $value ) {
342
+ if ( in_array( (string) $key, $wp->public_query_vars, true ) ) {
343
+ $query[ $key ] = $value;
344
+ if ( isset( $post_type_query_vars[ $key ] ) ) {
345
+ $query['post_type'] = $post_type_query_vars[ $key ];
346
+ $query['name'] = $value;
347
+ }
348
+ }
349
+ }
350
+
351
+ // Resolve conflicts between posts with numeric slugs and date archive queries.
352
+ $query = wp_resolve_numeric_slug_conflicts( $query );
353
+
354
+ // Do the query.
355
+ $query = new WP_Query( $query );
356
+ if ( ! empty( $query->posts ) && $query->is_singular ) {
357
+ return $query->post->ID;
358
+ } else {
359
+ return 0;
360
+ }
361
+ }
362
+ }
363
+ return 0;
364
+ }
365
+
366
+ private function psp_url_to_postid_2( $request_url ) {
367
+
368
+ global $wpdb;
369
+ $ID = '';
370
+ $slug = '';
371
+ $pspurl = '';
372
+ $exts=array("/",".php",".html",".htm");
373
+ $psp_posts = $wpdb->prefix . "posts";
374
+
375
+ $request_url = apply_filters( 'psp_url_to_postid', $request_url );
376
+
377
+ $pspurl = filter_var( $request_url, FILTER_VALIDATE_URL, '' );
378
+
379
+ if (!$pspurl) {
380
+ return 0;
381
+ }
382
+
383
+ $url_host = str_replace( 'www.', '', parse_url( $pspurl, PHP_URL_HOST ) );
384
+ $home_url_host = str_replace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
385
+
386
+ // Bail early if the URL does not belong to this site.
387
+ if ( $url_host && $url_host !== $home_url_host ) {
388
+ return 0;
389
+ }
390
+
391
+ if ($pspurl) $slug = sanitize_title(basename( $pspurl ));
392
+
393
+ // This will also work with PHP version <= 5.x.x
394
+ foreach( $exts as $ext ) {
395
+ $slug = str_replace( $ext, "", $slug );
396
+ $slug = trim($slug);
397
+ }
398
+
399
+ if (!$slug) return 0;
400
+
401
+ if ($slug) {
402
+ $sql = $wpdb->prepare("SELECT ID FROM $psp_posts WHERE post_name = %s AND post_status = 'publish'", $slug);
403
+ $ID = $wpdb->get_var( $sql );
404
+ }
405
+ //error_log("post id ".$ID);
406
+ if (!$ID) return 0;
407
+ return $ID;
408
+
409
+ }
410
+
411
+ private function psp_url_to_term_id ( $url = "" ) {
412
+
413
+ if ( empty($url) ) return "";
414
+
415
+ $url = apply_filters( 'psp_url_to_term_id', $url );
416
+
417
+ $url_host = str_replace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );
418
+ $home_url_host = str_replace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
419
+
420
+ // Bail early if the URL does not belong to this site.
421
+ if ( $url_host && $url_host !== $home_url_host ) {
422
+ return 0;
423
+ }
424
+
425
+ $slug = basename( $url );
426
+
427
+ //error_log("slug ".$slug);
428
+
429
+ //$psp_wp_term = !empty($slug) ? get_term_by('slug', $slug, '', OBJECT) : false;
430
+ $psp_wp_term = !empty($slug) ? $this->get_taxonomy_by_slug($slug) : false;
431
+
432
+ //error_log("termobject ".print_r($psp_wp_term, "n"));
433
+
434
+ if (!$psp_wp_term) return false;
435
+
436
+ return $psp_wp_term->term_id;
437
+
438
+ }
439
+
440
+ public function psp_register_rest_fields() {
441
+ $public_post_types = $this->psp_get_public_post_types();
442
+
443
+ foreach ( $public_post_types as $post_type ) {
444
+ \register_rest_field( $post_type, self::PSP_HEAD_FIELD_NAME, [ 'get_callback' => [ $this, 'get_psp_meta_for_post' ] ] );
445
+ }
446
+
447
+ $public_taxonomies = $this->psp_get_public_taxonomies();
448
+
449
+ foreach ( $public_taxonomies as $taxonomy ) {
450
+ if ( $taxonomy === 'post_tag' ) {
451
+ $taxonomy = 'tag';
452
+ }
453
+ \register_rest_field( $taxonomy, self::PSP_HEAD_FIELD_NAME, [ 'get_callback' => [ $this, 'get_psp_meta_for_term' ] ] );
454
+ }
455
+
456
+ \register_rest_field( 'user', self::PSP_HEAD_FIELD_NAME, [ 'get_callback' => [ $this, 'get_psp_meta_for_author' ] ] );
457
+
458
+ \register_rest_field( 'type', self::PSP_HEAD_FIELD_NAME, [ 'get_callback' => [ $this, 'get_psp_meta_for_pt_archive' ] ] );
459
+ }
460
+
461
+ private function psp_get_public_post_types( $posttypes = 'names' ) {
462
+ return \get_post_types( [ 'public' => true ], $posttypes );
463
+ }
464
+
465
+ private function psp_get_public_taxonomies( $taxonomies = 'names' ) {
466
+ return \get_taxonomies( [ 'public' => true ], $taxonomies );
467
+ }
468
+
469
+ public function get_psp_meta_for_frontpage() {
470
+
471
+ $psp_meta = false;
472
+ $front_page_id = 0;
473
+
474
+ $psp_home_settings = get_option("psp_home_settings");
475
+ $use_front_page_settings = isset($psp_home_settings['use_front_page']) ? $psp_home_settings['use_front_page'] : '';
476
+ if(!$use_front_page_settings) {
477
+
478
+ $psp_meta = $this->get_psp_meta_for_home();
479
+
480
+ } else {
481
+
482
+ //$front_page_id = get_queried_object_id();
483
+ if (!$front_page_id) $front_page_id = get_option('page_on_front');
484
+ if ($front_page_id) {
485
+ $psp_meta = $this->get_psp_meta_for_post( $front_page_id );
486
+ if ( $psp_meta === false ) {
487
+ return null;
488
+ }
489
+ }
490
+
491
+ }
492
+
493
+ return $psp_meta;;
494
+
495
+ }
496
+
497
+ public function get_psp_meta_for_home() {
498
+
499
+ $seo_title = "";
500
+ $seo_meta_string = "";
501
+ $social_meta_string = "";
502
+ $psp_ho_instance = PspHomeOthersSeoMetas::get_instance();
503
+
504
+ $psp_settings = $this->psp_sitewide_settings;
505
+ $canonical = $psp_settings['use_canonical'];
506
+
507
+ $seo_meta_string = $psp_ho_instance->get_home_seo_metas($canonical);
508
+ $this->psp_rest_set_home_social_metas($psp_ho_instance);
509
+ $social_meta_string = $this->psp_social_handle->psp_get_social_metas();
510
+ if (!empty($social_meta_string)) $seo_meta_string .= "\r\n".$social_meta_string;
511
+
512
+ if (empty($seo_title)) $seo_title = $psp_ho_instance->get_home_psp_title();
513
+ return '<title>'. $seo_title. '</title>'. "\r\n" .$seo_meta_string;
514
+ }
515
+
516
+ public function get_psp_meta_for_post( $request = null ) {
517
+
518
+ $psp_meta = false;
519
+
520
+ if ( is_array( $request ) ) {
521
+
522
+ $psp_meta = $this->get_rest_psp_pt_data( $request['id'] );
523
+
524
+ } else {
525
+
526
+ $psp_meta = $this->get_rest_psp_pt_data( $request );
527
+
528
+ }
529
+
530
+ if ( $psp_meta === false ) {
531
+ return null;
532
+ }
533
+
534
+ return $psp_meta;
535
+ }
536
+
537
+ public function get_psp_meta_for_term( $request = null ) {
538
+
539
+ $psp_meta = false;
540
+
541
+ if ( is_array( $request ) ) {
542
+ $psp_meta = $this->get_rest_psp_term_data( $request['id'] );
543
+ } else {
544
+ $psp_meta = $this->get_rest_psp_term_data( $request );
545
+ }
546
+
547
+ if ( $psp_meta === false ) {
548
+ return null;
549
+ }
550
+
551
+ return $psp_meta;
552
+ }
553
+
554
+ public function get_psp_meta_for_pt_archive( $request ) {
555
+
556
+ $psp_post_type_obj = get_post_type_object( $request['slug'] );
557
+
558
+ //if(! $psp_post_type_obj['has_archive']) {
559
+ // return null;
560
+ //}
561
+
562
+ if($request['slug'] === 'post') {
563
+ $id_of_posts_page = (int) \get_option( 'page_for_posts' );
564
+ if ($id_of_posts_page) {
565
+ $psp_meta = $this->get_psp_meta_for_post( $id_of_posts_page );
566
+ if ( ! $psp_meta ) {
567
+ return null;
568
+ }
569
+ return $psp_meta;
570
+ }
571
+ }
572
+
573
+ $psp_meta = $this->get_rest_psp_ptarchives_data( $request['slug'] );
574
+
575
+ if ( $psp_meta === false ) {
576
+ return null;
577
+ }
578
+
579
+ return $psp_meta;
580
+ }
581
+
582
+ public function get_psp_meta_for_author( $request ) {
583
+
584
+ $psp_meta = $this->get_rest_psp_author_data( $request['id'] );
585
+
586
+ if ( $psp_meta === false ) {
587
+ return null;
588
+ }
589
+
590
+ return $psp_meta;
591
+ }
592
+
593
+ public function get_rest_psp_pt_data($post_id = 0) {
594
+
595
+ if (empty($post_id)) return "";
596
+
597
+ $psp_settings = $this->psp_sitewide_settings;
598
+ $canonical = $psp_settings['use_canonical'];
599
+
600
+ $post = get_post($post_id);
601
+
602
+ //$psp_pt_instance = PspPtsSeoMetas::get_instance();
603
+ $psp_pt_instance = $this->psp_pt_handle;
604
+
605
+ $seo_meta_string = $psp_pt_instance->get_pt_seo_metas($post, $canonical);
606
+
607
+ $this->psp_rest_set_post_social_metas($psp_pt_instance, $post);
608
+ $this->psp_social_handle->psp_set_post_image($post);
609
+ $social_meta_string = $this->psp_social_handle->psp_get_social_metas();
610
+ if (!empty($social_meta_string)) $seo_meta_string .= "\r\n".$social_meta_string;
611
+
612
+ $seo_title = $psp_pt_instance->get_pt_psp_title($post);
613
+
614
+ return '<title>'.$seo_title. "</title>"."\r\n" .$seo_meta_string;
615
+
616
+ } // end get_rest_psp_pt_data;
617
+
618
+
619
+ public function get_rest_psp_term_data($term_id = 0) {
620
+
621
+ //error_log("termid ".($term_id));
622
+
623
+ if (empty($term_id)) return "";
624
+
625
+ $seo_title = '';
626
+ $seo_meta_string = '';
627
+ $taxonomy = '';
628
+
629
+ //$psp_tax_instance = PspTaxSeoMetas::get_instance();
630
+ $psp_tax_instance = $this->psp_tax_handle;
631
+
632
+ $term = get_term( $term_id );
633
+
634
+ if ( $term ) {
635
+
636
+ $taxonomy = trim($term->taxonomy);
637
+
638
+ }
639
+
640
+ $psp_settings = $this->psp_sitewide_settings;
641
+ $canonical = $psp_settings['use_canonical'];
642
+
643
+ $seo_meta_string = $psp_tax_instance->get_tax_seo_metas_for_rest( $term_id, $canonical, $taxonomy);
644
+
645
+ $this->psp_rest_set_tax_social_metas($psp_tax_instance, $term_id, $taxonomy);
646
+ $social_meta_string = $this->psp_social_handle->psp_get_social_metas();
647
+ if (!empty($social_meta_string)) $seo_meta_string .= $social_meta_string;
648
+ $seo_title = $psp_tax_instance->get_tax_psp_title_for_rest($term_id, $taxonomy);
649
+
650
+ return '<title>'.$seo_title. "</title>"."\r\n" .$seo_meta_string;
651
+ }
652
+
653
+ public function get_rest_psp_ptarchives_data($type = '') {
654
+
655
+ if (!$type) return "";
656
+
657
+ $seo_title = "";
658
+ $seo_meta_string = "";
659
+ $social_meta_string = "";
660
+ $psp_ho_instance = PspHomeOthersSeoMetas::get_instance();
661
+ $psp_pt_instance = PspPtsSeoMetas::get_instance();
662
+
663
+ $post_type_archive_exists = get_post_type_archive_link($type);
664
+
665
+ if (!$post_type_archive_exists) return false;
666
+
667
+ $seo_title = $psp_ho_instance->get_pt_archive_psp_title($type);
668
+
669
+ $psp_settings = $this->psp_sitewide_settings;
670
+ $canonical = $psp_settings['use_canonical'];
671
+
672
+ if ( class_exists( 'WooCommerce' ) ) {
673
+ $shop_page = get_page_by_path( 'shop' );
674
+ if (isset($shop_page) && !empty($shop_page)) {
675
+ $seo_meta_string = $psp_pt_instance->get_pt_seo_metas($shop_page, $canonical);
676
+ $this->psp_rest_set_post_social_metas($psp_pt_instance, $shop_page);
677
+ $this->psp_social_handle->psp_set_post_image($shop_page);
678
+ $social_meta_string = $this->psp_social_handle->psp_get_social_metas();
679
+ if(!empty($social_meta_string)) $seo_meta_string .= "\r\n".$social_meta_string;
680
+ }
681
+ } else {
682
+ $seo_meta_string = $psp_ho_instance->get_pt_archives_seo_metas($canonical, $type);
683
+ $this->psp_rest_set_ptarchives_social_metas($psp_ho_instance, $type);
684
+ }
685
+
686
+ //return $seo_title. "\r\n" .$seo_meta_string;
687
+ return '<title>'.$seo_title. "</title>"."\r\n" .$seo_meta_string;
688
+
689
+ }
690
+
691
+ public function get_rest_psp_author_data($user_id) {
692
+
693
+ $seo_title = '';
694
+ $seo_meta_string = '';
695
+
696
+ $psp_ho_instance = PspHomeOthersSeoMetas::get_instance();
697
+
698
+ $psp_settings = $this->psp_sitewide_settings;
699
+ $canonical = $psp_settings['use_canonical'];
700
+
701
+ $seo_title = $psp_ho_instance->get_author_archive_psp_title($user_id);
702
+
703
+ $seo_meta_string = $psp_ho_instance->get_pt_archives_seo_metas($canonical);
704
+ //return $seo_title. "\r\n" .$seo_meta_string;
705
+ return '<title>'.$seo_title. "</title>"."\r\n" .$seo_meta_string;
706
+
707
+ }
708
+
709
+ //set social metas for home for rest api calls
710
+ public function psp_rest_set_home_social_metas($psp_type_instance) {
711
+
712
+ $seo_title = $psp_type_instance->get_home_psp_title();
713
+ $this->seo_title = $seo_title;
714
+ $this->psp_social_handle->psp_seo_title = $psp_type_instance->home_title;
715
+ $this->psp_social_handle->psp_seo_description = $psp_type_instance->home_description;
716
+ $this->psp_social_handle->psp_can_link = $psp_type_instance->home_can_link;
717
+ $this->psp_social_handle->psp_type = "Website";
718
+ //$this->psp_can_link = $psp_type_instance->home_can_link;
719
+ }
720
+
721
+ //set social metas for taxonomies for rest api calls
722
+ public function psp_rest_set_tax_social_metas($psp_type_instance, $term_id, $tax_name) {
723
+
724
+ $psp_tax_instance = $this->psp_tax_handle;
725
+
726
+ $seo_title = $psp_tax_instance->get_tax_psp_title_for_rest($term_id, $tax_name);
727
+
728
+ //$this->seo_title = $seo_title;
729
+ $this->psp_social_handle->psp_social_metas = $psp_type_instance->term_social_meta;
730
+ $this->psp_social_handle->psp_seo_title = $psp_type_instance->taxonomy_title;
731
+ $this->psp_social_handle->psp_seo_description = $psp_type_instance->taxonomy_description;
732
+ $this->psp_social_handle->psp_can_link = $psp_type_instance->taxonomy_can_link;
733
+ $this->psp_social_handle->psp_type = $psp_type_instance->taxonomy_name;
734
+ //$this->psp_can_link = $psp_type_instance->taxonomy_can_link;
735
+ }
736
+
737
+ public function psp_rest_set_post_social_metas($psp_type_instance, $post) {
738
+
739
+ $seo_title = $psp_type_instance->get_pt_psp_title($post);
740
+
741
+ //$this->seo_title = $seo_title;
742
+ $this->psp_social_handle->psp_social_metas = $psp_type_instance->psp_current_ptype_social_meta;
743
+ $this->psp_social_handle->psp_seo_title = $psp_type_instance->post_type_title;
744
+ $this->psp_social_handle->psp_seo_description = $psp_type_instance->post_type_description;
745
+ $this->psp_social_handle->psp_can_link = $psp_type_instance->post_type_can_link;
746
+ $this->psp_social_handle->psp_type = $psp_type_instance->post_type_name;
747
+ //$this->psp_can_link = $psp_type_instance->post_type_can_link;
748
+
749
+ }
750
+
751
+ public function psp_rest_set_ptarchives_social_metas ($psp_type_instance, $type) {
752
+
753
+ $seo_title = $psp_type_instance->get_pt_archive_psp_title($type);
754
+ //$this->seo_title = $seo_title;
755
+ $this->psp_social_handle->psp_seo_title = $seo_title;
756
+ $this->psp_social_handle->psp_can_link = $psp_type_instance->archive_can_link;
757
+ //$this->psp_can_link = $psp_type_instance->archive_can_link;
758
+
759
+ }
760
+
761
+ public function is_valid_url( $url ) {
762
+ if ( \filter_var( $url, \FILTER_VALIDATE_URL ) === false ) {
763
+ return false;
764
+ }
765
+ return true;
766
+ }
767
+
768
+ public function get_taxonomy_by_slug($term_slug){
769
+ $term_object = false;
770
+ $taxonomies = get_taxonomies();
771
+ foreach ($taxonomies as $tax_type_key => $taxonomy) {
772
+ // If term object is returned, break out of loop. (Returns false if there's no object);
773
+ if ($term_object = get_term_by('slug', $term_slug, $taxonomy)) {
774
+ break;
775
+ }else{
776
+ $term_object = false;
777
+ }
778
+ }
779
+ return $term_object;
780
+ }
781
+
782
+ }
psp-include/generators/psp_tax_seo_metas.php CHANGED
@@ -49,6 +49,8 @@ class PspTaxSeoMetas {
49
  public $taxonomy_keywords = "";
50
  public $taxonomy_can_link = "";
51
 
 
 
52
  public $term_social_meta = array();
53
 
54
  //public $options = array();
@@ -136,9 +138,9 @@ class PspTaxSeoMetas {
136
  if ($noindex_tax) {
137
  $robots_meta .= $this->noindex_tag;
138
  } else {
139
- if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && get_query_var('paged') > 1) {
140
  $robots_meta .= $this->noindex_tag;
141
- } else {
142
  $robots_meta .= $this->index_tag;
143
  }
144
  }
@@ -1124,6 +1126,8 @@ class PspTaxSeoMetas {
1124
 
1125
  $prevnext_meta_string = $this->psp_helper->get_prev_next_links();
1126
 
 
 
1127
  if (isset($term_meta['schema_string']) && !empty($term_meta['schema_string'])) {
1128
  $json_schema_string = $term_meta['schema_string'];
1129
  $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
@@ -1132,7 +1136,7 @@ class PspTaxSeoMetas {
1132
  $json_schema_string = "";
1133
  }
1134
  }
1135
- if (!empty($json_schema_string)) {
1136
  $jsonld_script_tag = '<scri'. 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n". '</scri' . 'pt>';
1137
  }
1138
 
@@ -1212,6 +1216,8 @@ class PspTaxSeoMetas {
1212
 
1213
  $prevnext_meta_string = $this->psp_helper->get_prev_next_links();
1214
 
 
 
1215
  if (isset($term_meta['schema_string']) && !empty($term_meta['schema_string'])) {
1216
  $json_schema_string = $term_meta['schema_string'];
1217
  $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
@@ -1220,7 +1226,7 @@ class PspTaxSeoMetas {
1220
  $json_schema_string = "";
1221
  }
1222
  }
1223
- if (!empty($json_schema_string)) {
1224
  $jsonld_script_tag = '<scri' . 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n". '</scri' . 'pt>';
1225
  }
1226
 
@@ -1308,6 +1314,8 @@ class PspTaxSeoMetas {
1308
 
1309
  $prevnext_meta_string = $this->psp_helper->get_prev_next_links();
1310
 
 
 
1311
  if (isset($term_meta['schema_string']) && !empty($term_meta['schema_string'])) {
1312
  $json_schema_string = $term_meta['schema_string'];
1313
  $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
@@ -1316,7 +1324,7 @@ class PspTaxSeoMetas {
1316
  $json_schema_string = "";
1317
  }
1318
  }
1319
- if (!empty($json_schema_string)) {
1320
  $jsonld_script_tag = '<scri' . 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n".'</scri' . 'pt>';
1321
  }
1322
 
@@ -1328,6 +1336,266 @@ class PspTaxSeoMetas {
1328
 
1329
  } // end get_tax_seo_metas;
1330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1331
 
1332
  }
1333
  ?>
49
  public $taxonomy_keywords = "";
50
  public $taxonomy_can_link = "";
51
 
52
+ public $current_pageno = 1;
53
+
54
  public $term_social_meta = array();
55
 
56
  //public $options = array();
138
  if ($noindex_tax) {
139
  $robots_meta .= $this->noindex_tag;
140
  } else {
141
+ if (isset($psp_settings['noindex_subpages']) && $psp_settings['noindex_subpages'] && (get_query_var('paged') > 1 || $this->current_pageno > 1) ) {
142
  $robots_meta .= $this->noindex_tag;
143
+ } else {
144
  $robots_meta .= $this->index_tag;
145
  }
146
  }
1126
 
1127
  $prevnext_meta_string = $this->psp_helper->get_prev_next_links();
1128
 
1129
+ $psp_settings = $this->psp_sitewide_settings;
1130
+
1131
  if (isset($term_meta['schema_string']) && !empty($term_meta['schema_string'])) {
1132
  $json_schema_string = $term_meta['schema_string'];
1133
  $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
1136
  $json_schema_string = "";
1137
  }
1138
  }
1139
+ if (!empty($json_schema_string) && !empty($psp_settings['enable_schema'])) {
1140
  $jsonld_script_tag = '<scri'. 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n". '</scri' . 'pt>';
1141
  }
1142
 
1216
 
1217
  $prevnext_meta_string = $this->psp_helper->get_prev_next_links();
1218
 
1219
+ $psp_settings = $this->psp_sitewide_settings;
1220
+
1221
  if (isset($term_meta['schema_string']) && !empty($term_meta['schema_string'])) {
1222
  $json_schema_string = $term_meta['schema_string'];
1223
  $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
1226
  $json_schema_string = "";
1227
  }
1228
  }
1229
+ if (!empty($json_schema_string) && !empty($psp_settings['enable_schema'])) {
1230
  $jsonld_script_tag = '<scri' . 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n". '</scri' . 'pt>';
1231
  }
1232
 
1314
 
1315
  $prevnext_meta_string = $this->psp_helper->get_prev_next_links();
1316
 
1317
+ $psp_settings = $this->psp_sitewide_settings;
1318
+
1319
  if (isset($term_meta['schema_string']) && !empty($term_meta['schema_string'])) {
1320
  $json_schema_string = $term_meta['schema_string'];
1321
  $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
1324
  $json_schema_string = "";
1325
  }
1326
  }
1327
+ if (!empty($json_schema_string) && !empty($psp_settings['enable_schema']) ) {
1328
  $jsonld_script_tag = '<scri' . 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n".'</scri' . 'pt>';
1329
  }
1330
 
1336
 
1337
  } // end get_tax_seo_metas;
1338
 
1339
+ public function psp_get_tax_schema($term_meta) {
1340
+
1341
+ $json_schema_string = "";
1342
+ $jsonld_script_tag = "";
1343
+
1344
+ if (isset($term_meta['schema_string']) && !empty($term_meta['schema_string'])) {
1345
+ $json_schema_string = $term_meta['schema_string'];
1346
+ $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
1347
+ $schema_obj = json_decode($json_schema_string);
1348
+ if($schema_obj === null) {
1349
+ $json_schema_string = "";
1350
+ }
1351
+ }
1352
+ if (!empty($json_schema_string)) {
1353
+ $jsonld_script_tag = '<scri'. 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n". '</scri' . 'pt>';
1354
+ }
1355
+
1356
+ if (!empty($jsonld_script_tag) && !is_paged() ) {
1357
+
1358
+ return $jsonld_script_tag;
1359
+
1360
+ } else {
1361
+ return "";
1362
+ }
1363
+
1364
+ }
1365
+
1366
+ public function get_tax_seo_metas_for_rest($term_id, $canonical, $tax_name){
1367
+
1368
+ //error_log("termid ".($term_id));
1369
+
1370
+ if (empty($term_id )) return "";
1371
+ if (empty($tax_name )) return "";
1372
+
1373
+ $can_link = "";
1374
+ $term_link = "";
1375
+ $robots_meta_string = "";
1376
+ $desc_keyword_meta_string = "";
1377
+ $canonical_meta_string = "";
1378
+ $seo_meta_string = "";
1379
+ $term_meta = array();
1380
+ $prevnext_meta_string = "";
1381
+ $json_schema_string = "";
1382
+ $jsonld_script_tag = "";
1383
+
1384
+ if ( 'category' == $tax_name ) {
1385
+
1386
+ $psp_seo_label = "psp_category_seo_metas_$term_id";
1387
+ $psp_social_label = "psp_category_social_metas_$term_id";
1388
+
1389
+ } else {
1390
+ $psp_seo_label = "psp_taxonomy_seo_metas_$term_id";
1391
+ $psp_social_label = "psp_taxonomy_social_metas_$term_id";
1392
+ }
1393
+
1394
+ //$current_tax_object = get_taxonomy( get_query_var( 'taxonomy' ));
1395
+ //$tax_name = $current_tax_object->labels->name;
1396
+
1397
+ if (!empty($this->psp_current_tax_format)){
1398
+ $current_tax_format = $this->psp_current_tax_format;
1399
+ } else {
1400
+
1401
+ //$tax_slug = get_query_var( 'taxonomy' );
1402
+ $tax_slug = $tax_name;
1403
+ $current_tax_format_option = "psp_". $tax_slug. "_settings";
1404
+ $current_tax_format = get_option($current_tax_format_option);
1405
+ $this->psp_current_tax_format = $current_tax_format;
1406
+ }
1407
+
1408
+ //$curr_term = get_query_var('term');
1409
+ if (isset($this->psp_current_term_obj) && !empty($this->psp_current_term_obj)){
1410
+ $term_object = $this->psp_current_term_obj;
1411
+ } else {
1412
+ //$term_object = get_term_by( 'slug', get_query_var('term'), get_query_var( 'taxonomy' ) );
1413
+ $term_object = get_term( $term_id );
1414
+ $this->psp_current_term_obj = $term_object;
1415
+ }
1416
+ if ( is_object($term_object)) {
1417
+ //$term_id = isset($term_object->term_id) ? $term_object->term_id : '';
1418
+ $term_name = isset($term_object->name) ? $term_object->name : '';
1419
+ }
1420
+
1421
+ if (empty($this->psp_term_meta)) {
1422
+
1423
+ //$term_meta_option_name = "psp_taxonomy_seo_metas_".$term_id;
1424
+ //$term_meta = get_option("$cat_name_$cat_id_metas");
1425
+ if (!empty($term_id)) {
1426
+ //$term_meta = get_term_meta( $term_id, "psp_taxonomy_seo_metas_$term_id");
1427
+ $term_meta = get_term_meta( $term_id, $psp_seo_label);
1428
+ if ($term_meta) $term_meta = $term_meta[0];
1429
+ //if (!$term_meta) $term_meta = get_option( "psp_taxonomy_seo_metas_$term_id");
1430
+ if (!$term_meta) $term_meta = get_option( $psp_seo_label);
1431
+ }
1432
+ $this->psp_term_meta = $term_meta;
1433
+
1434
+ } else {
1435
+ $term_meta = $this->psp_term_meta;
1436
+ }
1437
+
1438
+
1439
+
1440
+ if (empty($this->term_social_meta)) {
1441
+ if (!empty($term_id)) {
1442
+ //$term_social_meta = get_term_meta( $term_id, "psp_taxonomy_social_metas_$term_id");
1443
+ $term_social_meta = get_term_meta( $term_id, $psp_social_label);
1444
+ if ($term_social_meta) $this->term_social_meta = $term_social_meta[0];
1445
+ //if (!$this->term_social_meta) $this->term_social_meta = get_option( "psp_taxonomy_social_metas_$term_id");
1446
+ if (!$this->term_social_meta) $this->term_social_meta = get_option( "psp_taxonomy_social_metas_$term_id");
1447
+ }
1448
+ //if (!empty($term_id)) $this->term_social_meta = get_option( $psp_social_label);
1449
+ }
1450
+
1451
+ $robots_meta_string = $this->get_tax_robots_meta($term_meta);
1452
+
1453
+ if ($this->current_pageno < 2) {
1454
+ $desc_keyword_meta_string = $this->get_tax_description_meta($term_object, $term_meta, $tax_name);
1455
+ }
1456
+
1457
+ if (!empty($desc_keyword_meta_string)) $desc_keyword_meta_string .= "\r\n";
1458
+
1459
+ if ( $canonical ) {
1460
+ $canonical_meta_string = $this->get_tax_canonical_meta($term_object, $term_meta);
1461
+ }
1462
+
1463
+ $prevnext_meta_string = $this->psp_helper->get_prev_next_links();
1464
+
1465
+ if (isset($term_meta['schema_string']) && !empty($term_meta['schema_string'])) {
1466
+ $json_schema_string = $term_meta['schema_string'];
1467
+ $json_schema_string = html_entity_decode(esc_html(stripcslashes($json_schema_string)));
1468
+ $schema_obj = json_decode($json_schema_string);
1469
+ if($schema_obj === null) {
1470
+ $json_schema_string = "";
1471
+ }
1472
+ }
1473
+ if (!empty($json_schema_string)) {
1474
+ $jsonld_script_tag = '<scri' . 'pt type="application/ld+json">'. "\r\n". $json_schema_string . "\r\n".'</scri' . 'pt>';
1475
+ }
1476
+
1477
+ $seo_meta_string = $desc_keyword_meta_string.$robots_meta_string.$canonical_meta_string.$prevnext_meta_string;
1478
+ //if (!empty($jsonld_script_tag)) $seo_meta_string = $seo_meta_string.$jsonld_script_tag;
1479
+ if (!empty($jsonld_script_tag) ) $seo_meta_string = $seo_meta_string.$jsonld_script_tag;
1480
+
1481
+ return $seo_meta_string;
1482
+
1483
+ } // end get_tax_seo_metas_for_rest;
1484
+
1485
+ public function get_tax_psp_title_for_rest($term_id, $tax_name) {
1486
+
1487
+ $title = "";
1488
+ $term_meta = array();
1489
+ $psp_seo_label = "";
1490
+ $psp_social_label = "";
1491
+
1492
+ $term_name = "";
1493
+ $tax_slug = $tax_name;
1494
+
1495
+ $psp_settings = $this->psp_sitewide_settings;
1496
+
1497
+ $current_tax_format_option = "psp_". $tax_slug. "_settings";
1498
+ //error_log($current_tax_format_option);
1499
+ $current_tax_format = get_option($current_tax_format_option);
1500
+ $this->psp_current_tax_format = $current_tax_format;
1501
+
1502
+ if ( 'category' == $tax_name ) {
1503
+
1504
+ $psp_seo_label = "psp_category_seo_metas_$term_id";
1505
+ $psp_social_label = "psp_category_social_metas_$term_id";
1506
+
1507
+ } else {
1508
+ $psp_seo_label = "psp_taxonomy_seo_metas_$term_id";
1509
+ $psp_social_label = "psp_taxonomy_social_metas_$term_id";
1510
+ }
1511
+
1512
+ //$curr_term = get_query_var('term');
1513
+
1514
+ if (isset($this->psp_current_term_obj) && !empty($this->psp_current_term_obj)){
1515
+ $term_object = $this->psp_current_term_obj;
1516
+ } else {
1517
+ $term_object = get_term( $term_id );
1518
+ $this->psp_current_term_obj = $term_object;
1519
+ }
1520
+ if ( is_object($term_object)) {
1521
+ //$term_id = isset($term_object->term_id) ? $term_object->term_id : '';
1522
+ $term_name = isset($term_object->name) ? $term_object->name : '';
1523
+ }
1524
+ //$psp_term_meta = isset($this->psp_term_meta) ? $this->psp_term_meta : "";
1525
+ if (empty($this->psp_term_meta)) {
1526
+
1527
+ if (!empty($term_id)) {
1528
+ $term_meta = get_term_meta( $term_id, $psp_seo_label);
1529
+ if ($term_meta) $term_meta = $term_meta[0];
1530
+ if (!$term_meta) $term_meta = get_option( $psp_seo_label);
1531
+ }
1532
+ $this->psp_term_meta = $term_meta;
1533
+
1534
+ } else {
1535
+ $term_meta = $this->psp_term_meta;
1536
+ }
1537
+ $psp_term_social_meta = isset($this->term_social_meta) ? $this->term_social_meta : "";
1538
+ if (empty($psp_term_social_meta)) {
1539
+ if (!empty($term_id)) {
1540
+ $term_social_meta = get_term_meta( $term_id, $psp_social_label);
1541
+ if ($term_social_meta) $this->term_social_meta = $term_social_meta[0];
1542
+ if (!$this->term_social_meta) $this->term_social_meta = get_option( $psp_social_label);
1543
+ }
1544
+ }
1545
+ //continue
1546
+ //$title = $this->psp_helper->internationalize($term_meta->title);
1547
+ $title = isset($term_meta['title']) ? $this->psp_helper->internationalize($term_meta['title']) : "";
1548
+ $term_name = ucwords($this->psp_helper->internationalize($term_name));
1549
+ if (empty($title)) {
1550
+ $title = $term_name;
1551
+ }
1552
+ $title = trim(stripcslashes($title));
1553
+ $term_description = $this->psp_helper->internationalize(term_description());
1554
+
1555
+ $title_format = isset($current_tax_format['title']) ? $current_tax_format['title'] : "";
1556
+ $psp_term_title_format = isset($term_meta['titleformat']) ? $term_meta['titleformat'] : $title_format;
1557
+ $title_format = $psp_term_title_format;
1558
+ //$title_format = get_option($tax_title_format);
1559
+ //$title_format = get_option('psp_taxonomy_title_format');
1560
+ //error_log($title_format);
1561
+
1562
+ if (!isset($title_format) || empty($title_format)) {
1563
+ $title_format = "%seo_title%";
1564
+ //$new_title = str_replace('%seo_title%', $title, $title_format);
1565
+ //$new_title = isset($_GET['tag_ID'], $_GET['taxonomy']) ? $title_format : str_replace('%seo_title%', $title, $title_format);
1566
+ $new_title = !empty($term_id) ? str_replace('%seo_title%', $title, $title_format) : $title_format ;
1567
+ } else {
1568
+ //$new_title = isset($_GET['tag_ID'], $_GET['taxonomy']) ? $title_format : str_replace('%seo_title%', $title, $title_format);
1569
+ $new_title = !empty($term_id) ? str_replace('%seo_title%', $title, $title_format) : $title_format ;
1570
+ //$new_title = str_replace('%seo_title%', $title, $title_format);
1571
+ $new_title = str_replace('%title%', $term_name, $new_title);
1572
+ $new_title = str_replace('%wp_title%', $term_name, $new_title);
1573
+ $new_title = str_replace('%term_name%', $term_name, $new_title);
1574
+ // $new_title = str_replace('%sep%', htmlentities($psp_settings['separator']), $new_title);
1575
+ $new_title = str_replace('%sep%', $psp_settings['separator'], $new_title);
1576
+ //$new_title = str_replace('%term_description%', $term_description, $new_title);
1577
+ $new_title = str_replace('%description%', $term_description, $new_title);
1578
+ //$new_title = str_replace('%blog_title%', $this->sitename, $new_title);
1579
+ //$new_title = str_replace('%blog_description%', $this->sitedescription, $new_title);
1580
+ $new_title = str_replace('%site_name%', $this->sitename, $new_title);
1581
+ $new_title = str_replace('%site_description%', $this->sitedescription, $new_title);
1582
+ }
1583
+ $title = $this->psp_helper->paged_title($new_title);
1584
+ //$title = $new_title;
1585
+ $this->taxonomy_title = $title;
1586
+
1587
+
1588
+ $sitename = $this->sitename;
1589
+ $sitedescription = $this->sitedescription;
1590
+ //$psp_title_separator = isset($psp_settings['separator']) ? htmlentities($psp_settings['separator']) : '';
1591
+ $psp_title_separator = isset($psp_settings['separator']) ? ($psp_settings['separator']) : '';
1592
+
1593
+ $title = trim($title);
1594
+ $title = trim($title, $psp_title_separator);
1595
+ return $title;
1596
+
1597
+ } // end get_tax_psp_title_for_rest
1598
+
1599
 
1600
  }
1601
  ?>
psp-include/settings/psp_settings.php CHANGED
@@ -653,19 +653,33 @@ class PspSettings {
653
 
654
  //Fields
655
 
656
- //Disable platinum seo
657
- $platinum_seo_disable_field = array (
658
- 'label_for' => 'psp_'.$setting_name.'_disable_psp',
659
- 'option_name' => $psp_settings_name.'[disable_psp]',
660
- 'option_value' => isset($psp_settings['disable_psp']) ? $psp_settings['disable_psp'] : '',
661
- 'checkbox_label' => '<code>Disable</code>',
662
- 'option_description' => esc_html__( 'This will disable Platinum SEO titles, meta tags and structured data schema markups for all posts, pages, taxonomies and archives. You can however use the redirections, 404 error detection modules and sitemaps, if the corresponding modules are enabled in Platinum seo.', 'platinum-seo-pack' )
663
  );
664
 
665
- $platinum_seo_disable_id = 'psp_'.$setting_name.'_disable_psp';
666
- $platinum_seo_disable_title = esc_html__( 'Platinum SEO: ', 'platinum-seo-pack' );
667
 
668
- add_settings_field( $platinum_seo_disable_id, $platinum_seo_disable_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_general_settings_group, $section_id, $platinum_seo_disable_field );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
 
670
  //Noindex subpages
671
  $noindex_subpages_field = array (
653
 
654
  //Fields
655
 
656
+ //Enable platinum seo
657
+ $platinum_seo_enable_field = array (
658
+ 'label_for' => 'psp_'.$setting_name.'_enable_psp',
659
+ 'option_name' => $psp_settings_name.'[enable_psp]',
660
+ 'option_value' => isset($psp_settings['enable_psp']) ? $psp_settings['enable_psp'] : '',
661
+ 'checkbox_label' => '<code>Enable</code>',
662
+ 'option_description' => esc_html__( 'Switching this OFF will disable generation of Platinum SEO titles, meta tags (except structured data module i.e. JSON schema markups for all posts, pages, taxonomies and archives on the frontend. You can however use the Platinum SEO schema (Structured Data), redirections, 404 error detection modules and sitemaps, if the corresponding modules are enabled.', 'platinum-seo-pack' )
663
  );
664
 
665
+ $platinum_seo_enable_id = 'psp_'.$setting_name.'_enable_psp';
666
+ $platinum_seo_enable_title = esc_html__( 'Platinum SEO: ', 'platinum-seo-pack' );
667
 
668
+ add_settings_field( $platinum_seo_enable_id, $platinum_seo_enable_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_general_settings_group, $section_id, $platinum_seo_enable_field );
669
+
670
+ //Enable platinum seo structured data
671
+ $psp_schema_enable_field = array (
672
+ 'label_for' => 'psp_'.$setting_name.'_enable_schema',
673
+ 'option_name' => $psp_settings_name.'[enable_schema]',
674
+ 'option_value' => isset($psp_settings['enable_schema']) ? $psp_settings['enable_schema'] : '',
675
+ 'checkbox_label' => '<code>Enable</code>',
676
+ 'option_description' => esc_html__( 'Switching this ON will enable Platinum SEO structured data module i.e. JSON schema markups for all posts, pages, taxonomies and Home Page/Front Page.', 'platinum-seo-pack' )
677
+ );
678
+
679
+ $psp_schema_enable_id = 'psp_'.$setting_name.'_enable_schema';
680
+ $psp_schema_enable_title = esc_html__( 'Platinum SEO Schema (Structured Data): ', 'platinum-seo-pack' );
681
+
682
+ add_settings_field( $psp_schema_enable_id, $psp_schema_enable_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_general_settings_group, $section_id, $psp_schema_enable_field );
683
 
684
  //Noindex subpages
685
  $noindex_subpages_field = array (
psp-include/utilities/psp_helper.php CHANGED
@@ -19,11 +19,13 @@ class PspHelper {
19
  * as description. Touch only if you know what you're doing
20
  */
21
  private $min_description_length = 1;
22
- private $version = "2.3.6";
23
 
24
  public $sitename = "";
25
  public $sitedescription = "";
26
 
 
 
27
  public static function get_instance() {
28
 
29
  if ( null == self::$obj_handle ) {
@@ -234,11 +236,14 @@ class PspHelper {
234
  public function paged_title($title) {
235
  // the page number if paged
236
  global $paged;
 
 
 
237
 
238
  // simple tagging support
239
  global $STagging;
240
 
241
- if (is_paged() || (isset($STagging) && $STagging->is_tag_view() && $paged)) {
242
  //$part = $this->internationalize(get_option('aiosp_paged_format'));
243
  //$psp_settings = $this->psp_sitewide_settings;
244
  $psp_settings = get_option('psp_sitewide_settings');
@@ -246,7 +251,8 @@ class PspHelper {
246
 
247
  if (isset($part) || !empty($part)) {
248
  $part = " " . trim($part);
249
- $part = str_replace('%page%', $paged, $part);
 
250
  $part = str_replace('%sep%', $psp_settings['separator'], $part);
251
  //$this->log("paged_title() [$title] [$part]");
252
  $title .= $part;
@@ -256,8 +262,8 @@ class PspHelper {
256
  }
257
 
258
  public function psp_tracer( $which_tracer, $echo = false ) {
259
- $start_tracer = "<!-- Platinum Seo Pack, version ".$this->version." by Techblissonline-->\r\n";
260
- $end_tracer = "\r\n<!--Techblissonline Platinum SEO and Social Pack Tracer ends here -->\r\n";
261
  if ($which_tracer == "START") {
262
  $return_tracer = $start_tracer;
263
  } else {
@@ -273,6 +279,7 @@ class PspHelper {
273
  public function paged_link($link) {
274
  //$page = get_query_var('paged');
275
  $page = get_query_var( 'paged', 1 );
 
276
  $has_ut = function_exists('user_trailingslashit');
277
  if ($page && $page > 1) {
278
  $link = trailingslashit($link) ."page/". "$page";
19
  * as description. Touch only if you know what you're doing
20
  */
21
  private $min_description_length = 1;
22
+ private $version = "2.3.7";
23
 
24
  public $sitename = "";
25
  public $sitedescription = "";
26
 
27
+ public $pagenumber = 1;
28
+
29
  public static function get_instance() {
30
 
31
  if ( null == self::$obj_handle ) {
236
  public function paged_title($title) {
237
  // the page number if paged
238
  global $paged;
239
+ $pagenumber = $paged;
240
+
241
+ if($this->pagenumber > 1) $pagenumber = $this->pagenumber;
242
 
243
  // simple tagging support
244
  global $STagging;
245
 
246
+ if (is_paged() || $pagenumber > 1 || (isset($STagging) && $STagging->is_tag_view() && $pagenumber)) { //$pagenumber instead of $paged
247
  //$part = $this->internationalize(get_option('aiosp_paged_format'));
248
  //$psp_settings = $this->psp_sitewide_settings;
249
  $psp_settings = get_option('psp_sitewide_settings');
251
 
252
  if (isset($part) || !empty($part)) {
253
  $part = " " . trim($part);
254
+ //$part = str_replace('%page%', $paged, $part);
255
+ $part = str_replace('%page%', $pagenumber, $part);
256
  $part = str_replace('%sep%', $psp_settings['separator'], $part);
257
  //$this->log("paged_title() [$title] [$part]");
258
  $title .= $part;
262
  }
263
 
264
  public function psp_tracer( $which_tracer, $echo = false ) {
265
+ $start_tracer = "<!-- Platinum Seo Pack, version ".$this->version." by https://techblissonline.com/ -->\r\n";
266
+ $end_tracer = "\r\n<!--Techblissonline Platinum SEO Pack -->\r\n";
267
  if ($which_tracer == "START") {
268
  $return_tracer = $start_tracer;
269
  } else {
279
  public function paged_link($link) {
280
  //$page = get_query_var('paged');
281
  $page = get_query_var( 'paged', 1 );
282
+ if($this->pagenumber > 1) $page = $this->pagenumber;
283
  $has_ut = function_exists('user_trailingslashit');
284
  if ($page && $page > 1) {
285
  $link = trailingslashit($link) ."page/". "$page";
psp_main.php CHANGED
@@ -16,6 +16,7 @@ class PspMain {
16
 
17
  protected $psp_redirect_instance;
18
  protected $psp_sitemap_instance;
 
19
 
20
  public $psp_breadcrumb_settings = array();
21
  public $psp_ga_settings = array();
@@ -38,6 +39,8 @@ class PspMain {
38
  $this->psp_redirect_instance = PspRedirections::get_instance();
39
 
40
  $this->psp_sitemap_instance = PspSitemap::get_instance();
 
 
41
 
42
  $psp_settings = array();
43
  $psp_settings = get_option("psp_sitewide_settings");
@@ -77,9 +80,9 @@ class PspMain {
77
  add_action('wp_head', array(&$this, 'psp_head'), -99 );
78
  }
79
  *****/
80
- $disable_psp = isset( $psp_settings['disable_psp'] ) && !empty ( $psp_settings['disable_psp'] ) ? $psp_settings['disable_psp'] : '';
81
 
82
- if ( ! $disable_psp ) {
83
  $psp_rewrite_titles = isset($psp_settings['rewrite_titles']) ? $psp_settings['rewrite_titles'] : '';
84
  $psp_force_psp_titles = isset($psp_settings['force_psp_titles']) ? $psp_settings['force_psp_titles'] : '';
85
  if ($psp_rewrite_titles) {
@@ -93,6 +96,12 @@ class PspMain {
93
  } else {
94
  add_action('wp_head', array(&$this,'psp_tags_renderer'), 1);
95
  }
 
 
 
 
 
 
96
  }
97
 
98
  if ($noindex_feeds) {
@@ -290,14 +299,14 @@ class PspMain {
290
  $user_id = get_current_user_id();
291
  // Add the meta so that the notice is permanently dismissed.
292
  //delete_user_meta( $user_id, 'psp_ignore_notice_v_209' );
293
- update_user_meta( $user_id, 'psp_ignore_notice', "v_236" );
294
  };
295
  };
296
  }
297
 
298
  public function platinum_seo_admin_notice__success() {
299
  $user_id = get_current_user_id();
300
- if ( "v_236" === trim(get_user_meta( $user_id, 'psp_ignore_notice', true ) )) return;
301
  global $pagenow;
302
  $psp_pages = array('platinum-seo-social-pack-by-techblissonline', 'psp-social-by-techblissonline', 'psp-tools-by-techblissonline', 'pspp-licenses');
303
  if ('index.php' === $pagenow || ( $pagenow == 'admin.php' && in_array(sanitize_key($_GET['page']), $psp_pages))) {
@@ -307,7 +316,7 @@ class PspMain {
307
  'psp_ignore_notice' => '1',
308
  'action' => 'psp_delete_adminnotice',
309
  'nonce' => wp_create_nonce('psp_delete_adminnotice'),
310
- ] ) ) .'" style="float:right; display:block; border:none;">'.esc_html__( 'Dismiss permanently', 'platinum-seo-pack' ) .'</a>'.'<br>'. esc_html__( 'See What has Changed in this', 'platinum-seo-pack' ).'<a href="https://techblissonline.com/platinum-wordpress-seo-plugin/#what-is-new" target="_blank" rel="noopener"> '.esc_html__( ' Version ', 'platinum-seo-pack' ).'2.3.6'.esc_html__( ' and earlier Versions!', 'platinum-seo-pack' ) .'</a>'.'<br>'.esc_html__( 'Like this Plugin? Pls. give it a rating on WordPress', 'platinum-seo-pack' ).'<a href="https://wordpress.org/support/plugin/platinum-seo-pack/reviews/#new-post" target="_blank" rel="noopener">'.esc_html__(' here','platinum-seo-pack' ).'</a>'; ?></p></strong>
311
  </div>
312
  <?php
313
  }
@@ -801,6 +810,10 @@ class PspMain {
801
  $this->echo_psp_tags(true);
802
  }
803
 
 
 
 
 
804
  function echo_psp_tags($echo=true) {
805
 
806
  global $post;
@@ -926,6 +939,100 @@ class PspMain {
926
  return $echo_seo_meta_string;;
927
  }
928
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
929
 
930
  //set social metas
931
  public function psp_set_social_metas($psp_type_instance) {
@@ -1339,6 +1446,8 @@ class PspMain {
1339
  if ( !isset($psp_settings['autogenerate_description']) || empty($psp_settings['autogenerate_description']) ) $psp_settings['autogenerate_description'] = 1;
1340
  if ( !isset($psp_settings['use_canonical']) || empty($psp_settings['use_canonical']) ) $psp_settings['use_canonical'] = 1;
1341
  if ( !isset($psp_settings['hide_metabox_advanced']) || empty($psp_settings['hide_metabox_advanced']) ) $psp_settings['hide_metabox_advanced'] = 1;
 
 
1342
  //$psp_settings['sitelinks_search_box'] = 1;
1343
  //$psp_settings['sitelinks_searchbox_target'] = trailingslashit(get_home_url()).'?s={search_term}';
1344
 
@@ -1723,7 +1832,26 @@ class PspMain {
1723
 
1724
  update_option( 'psp_db_version', $psp_db_version );
1725
 
1726
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1727
 
1728
  public function psp_loaded_filter() {
1729
  add_filter('status_header', array($this->psp_redirect_instance, 'psp_log_404'), 10, 4);
16
 
17
  protected $psp_redirect_instance;
18
  protected $psp_sitemap_instance;
19
+ protected $psp_rest_instance;
20
 
21
  public $psp_breadcrumb_settings = array();
22
  public $psp_ga_settings = array();
39
  $this->psp_redirect_instance = PspRedirections::get_instance();
40
 
41
  $this->psp_sitemap_instance = PspSitemap::get_instance();
42
+
43
+ $this->psp_rest_instance = PspRestApi::get_instance();
44
 
45
  $psp_settings = array();
46
  $psp_settings = get_option("psp_sitewide_settings");
80
  add_action('wp_head', array(&$this, 'psp_head'), -99 );
81
  }
82
  *****/
83
+ $enable_psp = isset( $psp_settings['enable_psp'] ) && !empty ( $psp_settings['enable_psp'] ) ? $psp_settings['enable_psp'] : '';
84
 
85
+ if ( $enable_psp ) {
86
  $psp_rewrite_titles = isset($psp_settings['rewrite_titles']) ? $psp_settings['rewrite_titles'] : '';
87
  $psp_force_psp_titles = isset($psp_settings['force_psp_titles']) ? $psp_settings['force_psp_titles'] : '';
88
  if ($psp_rewrite_titles) {
96
  } else {
97
  add_action('wp_head', array(&$this,'psp_tags_renderer'), 1);
98
  }
99
+ } else {
100
+
101
+ $enable_schema = isset( $psp_settings['enable_schema'] ) && !empty ( $psp_settings['enable_schema'] ) ? $psp_settings['enable_schema'] : '';
102
+ if ($enable_schema) {
103
+ add_action('wp_head', array(&$this,'psp_schema_head'), 1);
104
+ }
105
  }
106
 
107
  if ($noindex_feeds) {
299
  $user_id = get_current_user_id();
300
  // Add the meta so that the notice is permanently dismissed.
301
  //delete_user_meta( $user_id, 'psp_ignore_notice_v_209' );
302
+ update_user_meta( $user_id, 'psp_ignore_notice', "v_237" );
303
  };
304
  };
305
  }
306
 
307
  public function platinum_seo_admin_notice__success() {
308
  $user_id = get_current_user_id();
309
+ if ( "v_237" === trim(get_user_meta( $user_id, 'psp_ignore_notice', true ) )) return;
310
  global $pagenow;
311
  $psp_pages = array('platinum-seo-social-pack-by-techblissonline', 'psp-social-by-techblissonline', 'psp-tools-by-techblissonline', 'pspp-licenses');
312
  if ('index.php' === $pagenow || ( $pagenow == 'admin.php' && in_array(sanitize_key($_GET['page']), $psp_pages))) {
316
  'psp_ignore_notice' => '1',
317
  'action' => 'psp_delete_adminnotice',
318
  'nonce' => wp_create_nonce('psp_delete_adminnotice'),
319
+ ] ) ) .'" style="float:right; display:block; border:none;">'.esc_html__( 'Dismiss permanently', 'platinum-seo-pack' ) .'</a>'.'<br>'. esc_html__( 'See What has Changed in this', 'platinum-seo-pack' ).'<a href="https://techblissonline.com/platinum-wordpress-seo-plugin/#what-is-new" target="_blank" rel="noopener"> '.esc_html__( ' Version ', 'platinum-seo-pack' ).'2.3.7'.esc_html__( ' and earlier Versions!', 'platinum-seo-pack' ) .'</a>'.'<br>'.esc_html__( 'Like this Plugin? Pls. give it a rating on WordPress', 'platinum-seo-pack' ).'<a href="https://wordpress.org/support/plugin/platinum-seo-pack/reviews/#new-post" target="_blank" rel="noopener">'.esc_html__(' here','platinum-seo-pack' ).'</a>'; ?></p></strong>
320
  </div>
321
  <?php
322
  }
810
  $this->echo_psp_tags(true);
811
  }
812
 
813
+ function psp_schema_head() {
814
+ $this->echo_psp_schema(true);
815
+ }
816
+
817
  function echo_psp_tags($echo=true) {
818
 
819
  global $post;
939
  return $echo_seo_meta_string;;
940
  }
941
  }
942
+
943
+ public function echo_psp_schema($echo=true) {
944
+
945
+ global $post;
946
+
947
+ //Add meta tags to the head
948
+ if (is_feed()) {
949
+ return;
950
+ }
951
+
952
+ $front_page_id = "";
953
+ $posts_page_id = "";
954
+ $seo_meta_string = "";
955
+
956
+ $psp_pt_instance = PspPtsSeoMetas::get_instance();
957
+ $psp_ho_instance = PspHomeOthersSeoMetas::get_instance();
958
+ $psp_tax_instance = PspTaxSeoMetas::get_instance();
959
+
960
+ if (is_front_page()) {
961
+ if (is_home()) {
962
+ $seo_meta_string = $psp_ho_instance->psp_get_home_schema();
963
+ } else {
964
+ $psp_home_settings = get_option("psp_home_settings");
965
+ $use_front_page_settings = isset($psp_home_settings['use_front_page']) ? $psp_home_settings['use_front_page'] : '';
966
+ if(!$use_front_page_settings) {
967
+ $seo_meta_string = $psp_ho_instance->psp_get_home_schema();
968
+ } else {
969
+ //$front_page_id = get_option('page_on_front');
970
+ $front_page_id = get_queried_object_id();
971
+ if (!$front_page_id) $front_page_id = get_option('page_on_front');
972
+ if ($front_page_id) {
973
+ $post = get_post($front_page_id);
974
+ $seo_meta_string = $psp_pt_instance->psp_get_pt_schema($post);
975
+ }
976
+ }
977
+ }
978
+ } else if (is_singular() || (is_home() && !is_front_page())) {
979
+ if (is_home() && !is_front_page()) {
980
+ $posts_page_id = get_queried_object_id();
981
+ if (!$posts_page_id) $posts_page_id = get_option('page_for_posts');
982
+ //$posts_page_id = get_option('page_for_posts');
983
+ if ($posts_page_id) $post = get_post($posts_page_id);
984
+ }
985
+ $seo_meta_string = $psp_pt_instance->psp_get_pt_schema($post);
986
+ } else if (is_category()) {
987
+
988
+ $cat_id = get_queried_object()->term_id;
989
+
990
+ if (!empty($cat_id)) {
991
+ $term_meta = get_term_meta( $cat_id, "psp_category_seo_metas_$cat_id");
992
+ if ($term_meta) $term_meta = $term_meta[0];
993
+ if (!$term_meta) $term_meta = get_option( "psp_category_seo_metas_$cat_id");
994
+ }
995
+ $seo_meta_string = $term_meta ? $psp_tax_instance->psp_get_tax_schema($term_meta) : "";
996
+ } else if (is_tag()) {
997
+ $tag_id = get_queried_object()->term_id;
998
+
999
+ if (!empty($tag_id)) {
1000
+ $term_meta = get_term_meta( $tag_id, "psp_taxonomy_seo_metas_$tag_id");
1001
+ if ($term_meta) $term_meta = $term_meta[0];
1002
+ if (!$term_meta) $term_meta = get_option( "psp_taxonomy_seo_metas_$tag_id");
1003
+ }
1004
+
1005
+ $seo_meta_string = $term_meta ? $psp_tax_instance->psp_get_tax_schema($term_meta) : "";
1006
+ } else if (is_tax()) {
1007
+ $tax_term_id = get_queried_object()->term_id;
1008
+
1009
+ if (!empty($tax_term_id)) {
1010
+ $term_meta = get_term_meta( $tax_term_id, "psp_taxonomy_seo_metas_$tax_term_id");
1011
+ if ($term_meta) $term_meta = $term_meta[0];
1012
+ if (!$term_meta) $term_meta = get_option( "psp_taxonomy_seo_metas_$tax_term_id");
1013
+ }
1014
+
1015
+ $seo_meta_string = $term_meta ? $psp_tax_instance->psp_get_tax_schema($term_meta) : "";
1016
+ }
1017
+
1018
+ $seo_scripts = $this->psp_settings_handle->psp_jsonld_for_google();
1019
+ if (!empty($seo_scripts)) {
1020
+ if (!empty($seo_meta_string)) {
1021
+ $seo_meta_string .= "\r\n".$seo_scripts;
1022
+ } else {
1023
+ $seo_meta_string .= $seo_scripts;
1024
+ }
1025
+ }
1026
+ //$echo_seo_meta_string = $this->psp_helper->psp_tracer("START").$seo_meta_string.$this->psp_helper->psp_tracer("END");
1027
+ if (!empty($seo_meta_string)) {
1028
+ $echo_seo_meta_string = $this->psp_helper->psp_tracer("START", true).$seo_meta_string.$this->psp_helper->psp_tracer("END");
1029
+ if ($echo) {
1030
+ echo $echo_seo_meta_string;
1031
+ } else {
1032
+ return $echo_seo_meta_string;;
1033
+ }
1034
+ }
1035
+ }
1036
 
1037
  //set social metas
1038
  public function psp_set_social_metas($psp_type_instance) {
1446
  if ( !isset($psp_settings['autogenerate_description']) || empty($psp_settings['autogenerate_description']) ) $psp_settings['autogenerate_description'] = 1;
1447
  if ( !isset($psp_settings['use_canonical']) || empty($psp_settings['use_canonical']) ) $psp_settings['use_canonical'] = 1;
1448
  if ( !isset($psp_settings['hide_metabox_advanced']) || empty($psp_settings['hide_metabox_advanced']) ) $psp_settings['hide_metabox_advanced'] = 1;
1449
+ if ( !isset($psp_settings['enable_psp']) || empty($psp_settings['enable_psp']) ) $psp_settings['enable_psp'] = 1;
1450
+ if ( !isset($psp_settings['enable_schema']) || empty($psp_settings['enable_schema']) ) $psp_settings['enable_schema'] = 1;
1451
  //$psp_settings['sitelinks_search_box'] = 1;
1452
  //$psp_settings['sitelinks_searchbox_target'] = trailingslashit(get_home_url()).'?s={search_term}';
1453
 
1832
 
1833
  update_option( 'psp_db_version', $psp_db_version );
1834
 
1835
+ }
1836
+
1837
+ public function psp_version_upgrade() {
1838
+ global $psp_version;
1839
+
1840
+ if ( get_site_option( 'psp_version' ) == $psp_version ) {
1841
+ return;
1842
+ }
1843
+
1844
+ if ( $psp_version == "2.3.7") {
1845
+ $psp_settings = get_option("psp_sitewide_settings");
1846
+ if ( !isset($psp_settings['enable_schema']) || empty($psp_settings['enable_schema']) ) $psp_settings['enable_schema'] = 1;
1847
+ if ( !isset($psp_settings['enable_psp']) || empty($psp_settings['enable_psp']) ) $psp_settings['enable_psp'] = 1;
1848
+ delete_option("psp_sitewide_settings");
1849
+ add_option("psp_sitewide_settings", $psp_settings);
1850
+ }
1851
+
1852
+ update_option( 'psp_version', $psp_version );
1853
+
1854
+ }
1855
 
1856
  public function psp_loaded_filter() {
1857
  add_filter('status_header', array($this->psp_redirect_instance, 'psp_log_404'), 10, 4);
readme.txt CHANGED
@@ -1,20 +1,32 @@
1
  === Platinum SEO ===
2
  Contributors: Rajesh Babu, Techblissonline (Rajesh)
3
  Donate link: https://www.patreon.com/join/techblissonline
4
- Plugin link: https://techblissonline.com/platinum-wordpress-seo-plugin/
5
- Tags: seo, wordpress seo, 301 redirects, google seo, platinum seo, redirection, schema markup, Json schema
6
  Requires at least: 4.0
7
  Tested up to: 5.7
8
  Requires PHP: 5.6
9
- Stable tag: 2.3.6
10
  License: GPLv2 or later
11
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
 
13
- Techblissonline Platinum WordPress SEO Plugin offers Complete onpage SEO solution for your WordPress blog or website.The latest version of this ultimate WordPress SEO Plugin has been completely rewritten and offers all the important features you need to do SEO to your blog or website. This is backward compatible and you don't have to change anything. If you are upgrading from an older version of Platinum SEO Pack (versions earlier than 2.0), make sure that you deactivate and activate the plugin once after upgrading to the latest version.
14
 
15
  == Description ==
16
 
17
- Techblissonline's **[ WordPress SEO Plugin](https://techblissonline.com/platinum-wordpress-seo-plugin/)** , [Platinum SEO Pack](https://techblissonline.com/platinum-seo-pack/) offers the ultimate onpage SEO solution to your WordPress blog or website.The latest version of Techblissonline Platinum SEO Plugin has been completely rewritten and offers all the essential features you need to do your SEO and be the best WordPress Blog or Website.
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  **[Fix 404 Errors](https://techblissonline.com/http-404-error/)**
20
  **[Manage HTTP Redirections](https://techblissonline.com/redirection-in-wordpress/)**
@@ -23,7 +35,7 @@ Techblissonline's **[ WordPress SEO Plugin](https://techblissonline.com/platinum
23
 
24
  [youtube https://www.youtube.com/watch?v=OlSIfRbao4w]
25
 
26
- Some features:
27
 
28
  1) Create and set any kind of Json-ld schema markup tag for any post, page or taxonomy. Thus Platinum SEO is now the easiest Plugin to add JSON Schema Markup. This can be generated using the free JSON Schema Markup Generator on Techblissonline.com.
29
  2) Canonical URLs are set automatically. Users can also override default canonical URLs for any POST or Page by explicitly setting the Canonical URL in the Techblissonline Platinum SEO MetaBox. You may even set Cross site Canonical URLs.
@@ -53,6 +65,17 @@ Some features:
53
  26) Role Manager that lets the admin configure which user role has access to which settings page or report in Platinum SEO.
54
  27) An easy and user friendly setup wizard that lets new users of plugin to migrate/import SEO data from other plugins and also configure the essential sitewide settings. The setup wizard is also accesible via the menu Platinum SEO and social Pack -> Setup wizard.
55
  28) Bulk Editor for Techblissonline SEO Title, Meta Description and JSON Schemas.
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  == Installation ==
58
 
@@ -76,6 +99,9 @@ Please read these **[FAQs](https://techblissonline.com/platinum-seo-pack-faq/)**
76
  4. Social Settings for Facebook, Twitter, Pinterest and LinkedIn. Generates Open Grah Tags and Twitter compatible Tags.
77
 
78
  == Changelog ==
 
 
 
79
  = 2.3.6=
80
  2021-03-10 - Removed the meta tag added by the newly introduced robots api in wordPress 5.7. Added the ability to specify currentyear to title and description formats. You can also directly add the tag variables in the title field and the meta description field. While the title description formats allow you to add the tag variables only towards the beginning or end, you can now add the tag variables anywhere in between the meta title or description text. You can add the tag variable manually to these Platinum SEO meta fields in Post types.
81
 
1
  === Platinum SEO ===
2
  Contributors: Rajesh Babu, Techblissonline (Rajesh)
3
  Donate link: https://www.patreon.com/join/techblissonline
4
+ Plugin link: https://techblissonline.com/wordpress-seo/
5
+ Tags: seo, wordpress seo, 301 redirects, xml sitemap, schema, 404 Errors, Redirection, content analysis
6
  Requires at least: 4.0
7
  Tested up to: 5.7
8
  Requires PHP: 5.6
9
+ Stable tag: 2.3.7
10
  License: GPLv2 or later
11
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
 
13
+ Be on top of your WordPress SEO with Techblissonline Platinum SEO Plugin, a complete SEO Pack for WordPress.
14
 
15
  == Description ==
16
 
17
+ ### Platinum SEO: The ultimate WordPress SEO plugin that has XML Sitemaps, 301 Redirects, 404 Error manager, JSON Schema for structured data representation and more.
18
+
19
+ Techblissonline Platinum WordPress SEO Plugin offers Complete onpage SEO solution for your WordPress blog or website. This includes easily implementable HTTP Redirections like 301 Redirects, 302 Redirects, finding and fixing 404 Errors, including any kind of structure data in the form of JSON schema markups and more.
20
+
21
+ Platinum SEO has been in existence since 2007! It was the most preferred plugin for several WordPress users, after the very first developer of All in one SEO Pack, Uberdose sropped contributing to it for a while anf then transferred it to another developer. Platinum SEO was then born to fill the gap and users loved it as it went beyond what was offered to do SEO in WordPress then. Platinum SEO has now been rewritten completely since those early days and it is one the light-weight and fully featured WordPress SEO plugin in the wordpress ecosystem now. This WordPress SEO plugin helps you with all your search engine optimization needs. If you aren't yet fully convinced, give it a try and see the ease of using this complete SEO Pack.
22
+
23
+ The goal of this plugin is to make "SEO Easy for everyone" in WordPress. Are you a beginner in wordPress? Don't worry as Platinum SEO is very intuitive and using it is a breeze! Even the WordPress SEO experts will love this plugin as it offers them complete control of On-page SEO on your site. For example, You can create your own JSON Schema and embed them in any Post or Page. To make life easy, the plugin also offers a tool to generate any Schema supported by Google.
24
+
25
+ #### WE TAKE CARE OF YOUR WORDPRESS SEO
26
+ Platinum SEO plugin offers a pack of features that helps you define all the important meta tags for every Post or Page. It doesn't stop there! It also lets you define redirections, where necessary and monitor and report all 404 Errors. You are thus promptly reported of all technical anomalies that might creep in for your take the necessay corrective action! You are thus in complete control of all technical issues that might affect your Posts or Pages from being crawled and indexed properly!
27
+
28
+
29
+ Techblissonline's **[ WordPress SEO Plugin](https://techblissonline.com/platinum-wordpress-seo-plugin/)** , [Platinum SEO Pack](https://techblissonline.com/platinum-seo-pack/) offers the ultimate onpage SEO solution to your WordPress blog or website. Techblissonline Platinum SEO Plugin offers all the essential features you need to do your SEO and be the best WordPress Blog or Website. These include tools to
30
 
31
  **[Fix 404 Errors](https://techblissonline.com/http-404-error/)**
32
  **[Manage HTTP Redirections](https://techblissonline.com/redirection-in-wordpress/)**
35
 
36
  [youtube https://www.youtube.com/watch?v=OlSIfRbao4w]
37
 
38
+ Platinum SEO is the most light-weight among all SEO plugin, yet packed with all the features you need to do Technical and OnPage SEO. The following is a brief summary of the features offered by this Plugin:
39
 
40
  1) Create and set any kind of Json-ld schema markup tag for any post, page or taxonomy. Thus Platinum SEO is now the easiest Plugin to add JSON Schema Markup. This can be generated using the free JSON Schema Markup Generator on Techblissonline.com.
41
  2) Canonical URLs are set automatically. Users can also override default canonical URLs for any POST or Page by explicitly setting the Canonical URL in the Techblissonline Platinum SEO MetaBox. You may even set Cross site Canonical URLs.
65
  26) Role Manager that lets the admin configure which user role has access to which settings page or report in Platinum SEO.
66
  27) An easy and user friendly setup wizard that lets new users of plugin to migrate/import SEO data from other plugins and also configure the essential sitewide settings. The setup wizard is also accesible via the menu Platinum SEO and social Pack -> Setup wizard.
67
  28) Bulk Editor for Techblissonline SEO Title, Meta Description and JSON Schemas.
68
+ 29) Support for REST API - If you are using WordPress as an headless CMS, then you need an SEO plugin that provides support via the REST API. Platinum SEO is one among the very few that provide such support.
69
+
70
+ Platinum SEO Premium is an unique WordPress SEO audit plugin that can work along with other WordPress SEO Plugins like Yoast SEO, RankMath, All in one SEO Pack, SeoPress and others. It is a real-time audit plugin that does a complete audit of your site and reports you on the various SEO parameters and issues for you to take corrective actions from the standpint of Technical SEO and On-Page SEO. And the audit happens in the background, by piggybacking user requests for a Post or Page on your site, on a continual basis. You just need to configure it once and you then get regularly updated dashboards and reports. The following are some of the features of Platinum SEO Premium as of now.
71
+
72
+ 30) [Premium] Automatic internal linking suggestions to Posts or Pages that are relevant to the Post or Page content you are editing.
73
+ 31) [Premium] The only audit plugin in the market that lets you build content hubs or silos with insights on how Posts or Pages are interlinked and using what keyphrases.
74
+ 32) [Premium] You can also ascertain Posts or Pages with no internal links or minimal internal links and find opportuites to build more internal links with aprropriate keyphrases.
75
+ 33) [Premium] You can monitor all links (both internal and external links) embedded in your content for their HTTP status codes. You are thus prompthly reported on broken links and redirected links for you to take appropriate action.
76
+ 34) [Premium] You can monitor all images and their HTTP status codes. You are also reported on images without alt text for you to take corrective action.
77
+ 35) [Premium] You are reported on Nofollow and Dofollow links embedded in your Post or Page content.
78
+ 36) [Premium] You are reported on links that open on new tabs or windows and also those that do not have noopener or noreferer tags on them.
79
 
80
  == Installation ==
81
 
99
  4. Social Settings for Facebook, Twitter, Pinterest and LinkedIn. Generates Open Grah Tags and Twitter compatible Tags.
100
 
101
  == Changelog ==
102
+ = 2.3.7=
103
+ 2021-04-24 - Platinum SEO is now integrated with WordPress REST API. You can now GET the SEO meta data for any Post/Page?Taxonomy/Home from the plugin asa filed psp_head included in responses to requests via the built-in WordPress REST API Enpoints like those for Posts, Types, etc. The other way to retrieve the SEO meta data is through the plugin's own custom Endpoint. You may find the details in the blog post.
104
+
105
  = 2.3.6=
106
  2021-03-10 - Removed the meta tag added by the newly introduced robots api in wordPress 5.7. Added the ability to specify currentyear to title and description formats. You can also directly add the tag variables in the title field and the meta description field. While the title description formats allow you to add the tag variables only towards the beginning or end, you can now add the tag variables anywhere in between the meta title or description text. You can add the tag variable manually to these Platinum SEO meta fields in Post types.
107