Platinum SEO Pack - Version 2.1.2

Version Description

  • 2020-06-01 - Sitemap has been further enhanced with the latest WordPress sitemap files. Also a few styling changes have been implemented to the sitemap rendered by the plugin. A few other cosmetic changes have been done to Help text wordings in a few files.
Download this release

Release Info

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

Code changes from version 2.1.1 to 2.1.2

Files changed (25) hide show
  1. Changelog.txt +3 -0
  2. platinum-seo-pack.php +1 -1
  3. psp-include/settings/js/snippetpreview.js +1 -1
  4. psp-include/settings/psp_analysis_metabox_renderer.php +1 -1
  5. psp-include/settings/psp_basic_metabox_renderer.php +4 -0
  6. psp-include/settings/psp_settings.php +8 -5
  7. psp-include/sitemap/inc/{class-core-sitemaps-index.php → class-wp-sitemaps-index.php} +16 -12
  8. psp-include/sitemap/inc/{class-core-sitemaps-provider.php → class-wp-sitemaps-provider.php} +33 -65
  9. psp-include/sitemap/inc/{class-core-sitemaps-registry.php → class-wp-sitemaps-registry.php} +9 -9
  10. psp-include/sitemap/inc/{class-core-sitemaps-renderer.php → class-wp-sitemaps-renderer.php} +14 -24
  11. psp-include/sitemap/inc/{class-core-sitemaps-stylesheet.php → class-wp-sitemaps-stylesheet.php} +5 -5
  12. psp-include/sitemap/inc/{class-core-sitemaps.php → class-wp-sitemaps.php} +30 -31
  13. psp-include/sitemap/inc/functions.php +24 -24
  14. psp-include/sitemap/inc/providers/class-core-sitemaps-posts.php +0 -160
  15. psp-include/sitemap/inc/providers/class-core-sitemaps-taxonomies.php +0 -143
  16. psp-include/sitemap/inc/providers/class-core-sitemaps-users.php +0 -111
  17. psp-include/sitemap/inc/providers/class-wp-sitemaps-posts.php +211 -0
  18. psp-include/sitemap/inc/providers/class-wp-sitemaps-taxonomies.php +193 -0
  19. psp-include/sitemap/inc/providers/class-wp-sitemaps-users.php +163 -0
  20. psp-include/sitemap/psp_sitemap.php +161 -71
  21. psp-include/sitemap/psp_sitemap_settings.php +28 -5
  22. psp-include/sitemap/sitemap-image.xsl +12 -4
  23. psp-include/utilities/psp_helper.php +1 -1
  24. psp_main.php +4 -4
  25. readme.txt +4 -1
Changelog.txt CHANGED
@@ -1,3 +1,6 @@
1
= 2.1.1 =
2
* 2020-05-22 - Platinum SEO Plugin becomes the first SEO plugin to integrate with the upcoming SiteMap functionality in WordPress Core. The Core siteMap is still in development and Platinum SEO has integrated with the currently available version of the Core Module. If you do like to generate a sitemap with Platinum SEO, do enable it and enable the Object Types for which you want to generate a sitemap in SiteMap settings in Platinum SEO.
3
1
+ = 2.1.2 =
2
+ * 2020-06-01 - Sitemap has been further enhanced with the latest WordPress sitemap files. Also a few styling changes have been implemented to the sitemap rendered by the plugin. A few other cosmetic changes have been done to Help text wordings in a few files.
3
+
4
= 2.1.1 =
5
* 2020-05-22 - Platinum SEO Plugin becomes the first SEO plugin to integrate with the upcoming SiteMap functionality in WordPress Core. The Core siteMap is still in development and Platinum SEO has integrated with the currently available version of the Core Module. If you do like to generate a sitemap with Platinum SEO, do enable it and enable the Object Types for which you want to generate a sitemap in SiteMap settings in Platinum SEO.
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.1.1
8
Author: Techblissonline.com (Rajesh)
9
Author URI: https://techblissonline.com/
10
Text Domain: platinum-seo-pack
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.1.2
8
Author: Techblissonline.com (Rajesh)
9
Author URI: https://techblissonline.com/
10
Text Domain: platinum-seo-pack
psp-include/settings/js/snippetpreview.js CHANGED
@@ -1 +1 @@
1
- function escapeRegExp(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\amp;")}function wordCount(e){var t=e.match(/\S+/g);return t?t.length:0}function pspSortArray(e,t){var s=[],i=[];for(let r=0;r<e.length;r++)i=[],void 0!==(i=wp.data.select("core").getEntityRecord("taxonomy",t,e[r]))&&(s[r]=i.name);return s?(s.sort(),s[0]):"%"+t+"%"}function pspSortClassicArray(e,t){var s=[];return jQuery('input[name="'+e+'"]:checked').each(function(){s.push(jQuery(this).parent("label").text())}),s&&s.length?(s.sort(),s[0]):"%"+t+"%"}function boldWords(e){var t=e,s=jQuery("#psp_seo_meta\\[keywords\\]").val().match(/\S+/g);if(s)for(i=0;i<s.length;i++)t=(t=t.replace(new RegExp("(^|[\\W])("+escapeRegExp(s[i])+")([\\W]|$)","gi"),"$1<b>$2</b>$3")).replace(new RegExp("(^|[\\W])("+escapeRegExp(s[i])+")([\\W]|$)","gi"),"$1<b>$2</b>$3");return t}function boldText(e){var t=e,s=jQuery("#psp_seo_meta\\[keywords\\]").val().match(/\S+/g);if(s)for(i=0;i<s.length;i++)t=t.replace(new RegExp("("+escapeRegExp(s[i])+")","gi"),"<b>$1</b>");return t}function htmlEncode(e){return jQuery("<div/>").text(e).html()}function setGtbUrlPreview(e){var t="";(t=e)&&(t=t.replace(/^https?\:\/\//i,""));var s=htmlEncode(t),i=(s=s.replace(/\/#x2F;,"")).length;jQuery("#permalinkSizer").html(s);var r=s=s.replace(/([^https?:\/\/])(\/)/g,"$1 > ");t=s,jQuery("#urlSizer").html(s),jQuery("#murlSizer").html(r);var n=new RegExp("W(.*)quot;);for(trimmed=!1;jQuery("#urlSizer").width()>566;){var a=s;a=(a=(a=(a=a.substring(0,a.length-1)).trim()).replace(/\>#x2F;,"")).trim(),jQuery("#urlSizer").html(a),s=a,trimmed=!0}trimmed&&(s+=" ...",jQuery("#urlSizer").html(s)),info=i+" characters, ",jQuery("#urlInfo").html(s.length+" characters, "+jQuery("#urlSizer").width()+" pixels"),jQuery("#urlSizer").width()<=584?jQuery("#urlInfo").html(info+'<span style="color:green;">'+jQuery("#urlSizer").width()+"/584 pixels</span>"):jQuery("#urlInfo").html(info+'<span style="color:red;">'+jQuery("#urlSizer").width()+"/584 pixels</span>"),jQuery("#techblissonlineSnippetUrl").html(s),mtrimmed=!1;for(var l=r;r.length>42;)r=jQuery.trim(r.replace(" ...","")),(l=(l=(l=jQuery.trim(l.replace(n,""))).trim()).replace(/\>#x2F;,"")).length>=42&&(l=(l=jQuery.trim(r.replace(" ...",""))).substring(0,l.length-1)),l=l.trim(),r=l+=" ...",mtrimmed=!0;mtrimmed&&jQuery("#murlSizer").html(r),info=r.length+" characters, ",jQuery("#murlInfo").html(r.length+" characters, "+jQuery("#murlSizer").width()+" pixels"),jQuery("#murlSizer").width()<=282?jQuery("#murlInfo").html(info+'<span style="color:green;">'+jQuery("#urlSizer").width()+" pixels</span>"):jQuery("#murlInfo").html(info+'<span style="color:red;">'+jQuery("#murlSizer").width()+" pixels</span>"),jQuery("#techblissonlineMSnippetUrl").html(r)}function setUrlPreview(){var e=jQuery.trim(jQuery("#pspHomePermalink").text())+"slug-name/",t=!1;if(window.wpEditorL10n&&wpEditorL10n.tinymce&&wpEditorL10n.tinymce.settings&&(t=wpEditorL10n.tinymce.settings),jQuery("#editable-post-name").length){e=jQuery.trim(jQuery("#sample-permalink").text());var s=jQuery.trim(jQuery("#editable-post-name").text());e=(e=e.replace(s,"")).replace(/\/#x2F;g,"")}else jQuery("#name").length?e=jQuery.trim(jQuery("#pspPostPermalink").text()):jQuery("#slug").length?e=jQuery.trim(jQuery("#pspPostPermalink").text()):t&&wp.data&&wp.data.select&&(e=wp.data.select("core/editor").getPermalink(),wp.data.subscribe(function(){setGtbUrlPreview(wp.data.select("core/editor").getPermalink())}));if(jQuery("#new-post-slug").length>0)e+=jQuery("#new-post-slug").val();else if(jQuery("#editable-post-name-full").length){e+=jQuery("#editable-post-name-full").text()}e&&(e=e.replace(/^https?\:\/\//i,""));var i=htmlEncode(e),r=i.length;r=(i=i.replace(/\/#x2F;,"")).length;jQuery("#permalinkSizer").html(i);var n=i=i.replace(/([^https?:\/\/])(\/)/g,"$1 > ");e=i,jQuery("#urlSizer").html(i),jQuery("#murlSizer").html(n);var a=new RegExp("W(.*)quot;);for(trimmed=!1;jQuery("#urlSizer").width()>584;){var l=i;l=(l=(l=(l=l.substring(0,l.length-1)).trim()).replace(/\>#x2F;,"")).trim(),jQuery("#urlSizer").html(l),i=l,trimmed=!0}trimmed&&(i+=" ..."),info=r+" characters, ",jQuery("#urlInfo").html(r+" characters, "+jQuery("#urlSizer").width()+" pixels"),jQuery("#urlSizer").width()<=584?jQuery("#urlInfo").html(info+'<span style="color:green;">'+jQuery("#urlSizer").width()+"/584 pixels</span>"):jQuery("#urlInfo").html(info+'<span style="color:red;">'+jQuery("#urlSizer").width()+"/584 pixels</span>"),jQuery("#techblissonlineSnippetUrl").html(i),mtrimmed=!1;for(var o=n;o.length>42;)n=jQuery.trim(n.replace(" ...","")),(o=(o=(o=jQuery.trim(o.replace(a,""))).trim()).replace(/\>#x2F;,"")).length>=42&&(o=(o=jQuery.trim(n.replace(" ...",""))).substring(0,o.length-1)),o=o.trim(),n=o+=" ...",mtrimmed=!0;mtrimmed&&jQuery("#murlSizer").html(n),info=n.length+" characters, ",jQuery("#murlInfo").html(n.length+" characters, "+jQuery("#murlSizer").width()+" pixels"),jQuery("#murlSizer").width()<=282?jQuery("#murlInfo").html(info+'<span style="color:green;">'+jQuery("#urlSizer").width()+" pixels</span>"):jQuery("#murlInfo").html(info+'<span style="color:red;">'+jQuery("#murlSizer").width()+" pixels</span>"),jQuery("#techblissonlineMSnippetUrl").html(n)}function stripTrailingSlash(e){return"/"==e.substr(-1)?e.substr(0,e.length-1):e}function setGtbTitlePreview(e,t){var s=jQuery("#psp_seo_meta\\[titleformat\\]").val(),i=!1,r=!1;jQuery("#psp_seo_meta\\[disable_title_format\\]:checked").length>0&&(i=!0),jQuery("#psp_seo_meta\\[disable_psp\\]:checked").length>0&&(r=!0),i&&(s="%seo_title%"),r&&(s="%wp_title%");var n=jQuery("#pspPostTypeArrayFormat").text(),a=JSON.parse(n),l=jQuery("#psp_seo_meta\\[title\\]"),o=s.replace("%seo_title%",e);if(""===e&&(o=o.replace("%seo_title%",l.attr("placeholder"))),o=(o=(o=(o=(o=(o=o.replace("%wp_title%",a.wp_title)).replace("%site_name%",a.site_name)).replace("%site_description%",a.site_description)).replace("%category%",t)).replace("%taxonomy%",t)).replace(/%sep%/g,a.sep),""!==(o=(o=jQuery.trim(o)).trim(a.sep))){var p=htmlEncode(o),c=p;jQuery("#titleSizer").html(p),jQuery("#actualTitleSizer").html(p);var d=new RegExp("sw+(.*)quot;);trimmed=!1;for(var u=p;jQuery("#titleSizer").width()>584;)p=jQuery.trim(p.replace(" ...","")),(u=jQuery.trim(u.replace(d,""))).length>=p.length&&(u=u.substring(0,u.length-1)),p=u+" ...",jQuery("#titleSizer").html(p),trimmed=!0;trimmed,jQuery("#titleSizer").html(p),mtrimmed=!1;for(var h=c;h.length>78;)c=jQuery.trim(c.replace(" ...","")),(h=jQuery.trim(h.replace(d,""))).length>=78&&(h=(h=jQuery.trim(h.replace(" ...",""))).substring(0,h.length-1)),c=h+=" ...",mtrimmed=!0;mtrimmed,jQuery("#mtitleSizer").html(c),info=jQuery("<textarea />").html(p).text().length+" characters, "+wordCount(p)+" words ",jQuery("#titleInfo").html(p.length+" characters, "+jQuery("#titleSizer").width()+" pixels, "+wordCount(p)+" words"),jQuery("#titleSizer").width()<=584?jQuery("#titleInfo").html(info+'<span style="color:green;">'+jQuery("#titleSizer").width()+"/584 pixels</span>"):jQuery("#titleInfo").html(info+'<span style="color:red;">'+jQuery("#titleSizer").width()+"/584 pixels</span>"),minfo=jQuery("<textarea />").html(c).text().length+" characters/ 78 characters "+wordCount(c)+" words ",jQuery("#mtitleInfo").html(c.length+" characters, "+jQuery("#mtitleSizer").width()+" pixels, "+wordCount(c)+" words"),c.length<=78?jQuery("#mtitleInfo").html('<span style="color:green;">'+minfo+"</span> "+jQuery("#mtitleSizer").width()+" pixels"):jQuery("#mtitleInfo").html('<span style="color:red;">'+minfo+"</span> "+jQuery("#mtitleSizer").width()+" pixels"),jQuery("#techblissonlineSnippetTitle").html(p),jQuery("#techblissonlineMSnippetTitle").html(c),setPSPSeoAnalysis()}}function setTitlePreview(){var e,t,s="",i="",r="",n=!1,a="";window.wpEditorL10n&&wpEditorL10n.tinymce&&wpEditorL10n.tinymce.settings&&(n=wpEditorL10n.tinymce.settings);var l=jQuery("#pspPostTypeArrayFormat").text(),o=JSON.parse(l),p=jQuery("#psp_seo_meta\\[titleformat\\]").val(),c=!1,d=!1,u=!1;jQuery("#psp_seo_meta\\[disable_title_format\\]:checked").length>0&&(c=!0),jQuery("#psp_seo_meta\\[disable_title\\]:checked").length>0&&(d=!0),jQuery("#psp_seo_meta\\[disable_psp\\]:checked").length>0&&(u=!0);a=o.category,p.toLowerCase().indexOf("%wp_title%");var h=jQuery("#title"),m=jQuery("#psp_seo_meta\\[title\\]");i=m.attr("placeholder");var y=jQuery("#psp_seo_meta\\[preferred_tax\\]"),g="categories",j="post_category[]",Q="category";if(y&&y.val()&&"category"!==(Q=jQuery("#psp_seo_meta\\[preferred_tax\\] option:selected").text())&&(g=Q,j="tax_input["+Q+"][]"),h&&(a=pspSortClassicArray(j,Q)),!m.val()||d||u?(jQuery("#title").val()?i=jQuery.trim(jQuery("#title").val()):jQuery("#name").val()?i=jQuery.trim(jQuery("#name").val()):n&&wp.data&&wp.data.select&&(i=wp.data.select("core/editor").getEditedPostAttribute("title"),t=wp.data.select("core/editor").getEditedPostAttribute(g),a="%"+Q+"%",void 0!==t&&t.length>0&&(a=pspSortArray(t,Q)),wp.data.subscribe(function(){i=wp.data.select("core/editor").getEditedPostAttribute("title"),t=wp.data.select("core/editor").getEditedPostAttribute(g),a="%"+Q+"%",void 0!==t&&t.length>0&&(a=pspSortArray(t,Q)),void 0===i&&(m=jQuery("#psp_seo_meta\\[title\\]")),""===i&&(m=jQuery("#psp_seo_meta\\[title\\]"),i=m.attr("placeholder")),a&&setGtbTitlePreview(i,a)})),s=i,(c||u)&&(p="%wp_title%"),s=(s=(s=(s=(s=(s=(s=p.replace("%seo_title%",i)).replace("%wp_title%",i)).replace("%site_name%",o.site_name)).replace("%site_description%",o.site_description)).replace("%taxonomy%",a)).replace("%category%",a)).replace(/%sep%/g,o.sep),s=(s=jQuery.trim(s)).trim(o.sep)):(s=m.val(),r=m.val(),jQuery("#title").val()?i=jQuery.trim(jQuery("#title").val()):jQuery("#name").val()?i=jQuery.trim(jQuery("#name").val()):n&&wp.data&&wp.data.select&&(i=wp.data.select("core/editor").getEditedPostAttribute("title"),e=wp.data.select("core/editor").getEditedPostAttribute(g),a="%"+Q+"%",void 0!==e&&e.length>0&&(a=pspSortArray(e,Q)),wp.data.subscribe(function(){i=wp.data.select("core/editor").getEditedPostAttribute("title"),e=wp.data.select("core/editor").getEditedPostAttribute(g),a="%"+Q+"%",r=m.val(),void 0!==e&&e.length>0&&(a=pspSortArray(e,Q)),r&&a&&setGtbTitlePreview(r,a)})),c&&(p="%seo_title%"),s=(s=(s=(s=(s=(s=(s=p.replace("%seo_title%",r)).replace("%wp_title%",i)).replace("%site_name%",o.site_name)).replace("%site_description%",o.site_description)).replace("%taxonomy%",a)).replace("%category%",a)).replace(/%sep%/g,o.sep),s=(s=jQuery.trim(s)).trim(o.sep)),""!==s){""===i||n||i;var f=htmlEncode(s),w=f;jQuery("#titleSizer").html(f),jQuery("#actualTitleSizer").html(f);var v=new RegExp("sw+(.*)quot;),S=f;for(trimmed=!1;jQuery("#titleSizer").width()>584;)f=jQuery.trim(f.replace(" ...","")),(S=jQuery.trim(S.replace(v,""))).length>=f.length&&(S=S.substring(0,S.length-1)),f=S+" ...",jQuery("#titleSizer").text(f),trimmed=!0;trimmed,jQuery("#titleSizer").text(f),jQuery("body").append(jQuery("#titleSizer")).width(),jQuery("body#titleSizer").remove(),info=jQuery("<textarea />").html(f).text().length+" characters, "+wordCount(f)+" words ",jQuery("#titleInfo").html(f.length+" characters, "+jQuery("#titleSizer").width()+" pixels, "+wordCount(f)+" words"),jQuery("#titleSizer").width()<=584?jQuery("#titleInfo").html(info+'<span style="color:green;">'+jQuery("#titleSizer").width()+"/584 pixels</span>"):jQuery("#titleInfo").html(info+'<span style="color:red;">'+jQuery("#titleSizer").width()+"/584 pixels</span>"),jQuery("#techblissonlineSnippetTitle").html(f);var _=w;for(mtrimmed=!1;_.length>78;)w=jQuery.trim(w.replace(" ...","")),(_=jQuery.trim(_.replace(v,""))).length>=78&&(_=(_=jQuery.trim(_.replace(" ...",""))).substring(0,_.length-1)),w=_+=" ...",mtrimmed=!0;mtrimmed,jQuery("#mtitleSizer").text(w),jQuery("body").append(jQuery("#mtitleSizer")).width(),jQuery("body#mtitleSizer").remove(),minfo=jQuery("<textarea />").html(w).text().length+" characters/ 78 characters "+wordCount(w)+" words ",jQuery("#mtitleInfo").html(w.length+" characters, "+jQuery("#mtitleSizer").width()+" pixels, "+wordCount(w)+" words"),w.length<=78?jQuery("#mtitleInfo").html('<span style="color:green;">'+minfo+"</span> "+jQuery("#mtitleSizer").width()+" pixels"):jQuery("#mtitleInfo").html('<span style="color:red;">'+minfo+"</span> "+jQuery("#mtitleSizer").width()+" pixels"),jQuery("#techblissonlineMSnippetTitle").html(w),setPSPSeoAnalysis()}}function setDescriptionPreview(){var e,t=!1,s=jQuery("#psp_seo_meta\\[description\\]");window.wpEditorL10n&&wpEditorL10n.tinymce&&wpEditorL10n.tinymce.settings&&(t=wpEditorL10n.tinymce.settings);var i=jQuery.trim(jQuery("#psp_seo_meta\\[maxsnippet\\]").val()),r=i;parseInt(i)<0&&(i=230,r=285),jQuery.inArray(parseInt(i),[-1,0,1,2,3,4])>-1&&(i=230,r=285),""===i&&(i=230,r=285),i=parseInt(i),r=parseInt(r);var n="",a=!1,l=!1,o=jQuery("#pspPostTypeArrayFormat").text();if(e=JSON.parse(o).autogendesc,jQuery("#psp_seo_meta\\[disable_psp\\]:checked").length>0&&(a=!0),jQuery("#psp_seo_meta\\[disable_description\\]:checked").length>0&&(l=!0),""!==n||a||l||(n=jQuery.trim(jQuery("#psp_seo_meta\\[description\\]").val())),""===n){if(""===n&&t&&wp.data&&wp.data.select){var p=wp.data.select("core/editor").getEditedPostContent();return""!==e&&(n=(n=p.replace(/(<([^>]+)>)/gi,"")).substring(0,r)),n||(n=s.attr("placeholder")),void setGTBDescPreview(n)}var c=jQuery.trim(jQuery("#content").val());if(!s.val()||a||l)return""!==e&&(n=(n=c.replace(/(<([^>]+)>)/gi,"")).substring(0,r)),n||(n=s.attr("placeholder")),void setGTBDescPreview(n)}return n?void setGTBDescPreview(n):void 0}function setGTBDescPreview(e){jQuery("#psp_seo_meta\\[description\\]");var t=e;placeholder_desc=e;var s=jQuery.trim(jQuery("#psp_seo_meta\\[maxsnippet\\]").val()),i=s;parseInt(s)<0&&(s=230,i=285),jQuery.inArray(parseInt(s),[-1,0,1,2,3,4])>-1&&(s=230,i=285),""===s&&(s=230,i=285),s=parseInt(s),i=parseInt(i);var r=htmlEncode(t),n=r+=" ...";jQuery("#descriptionSizer").html(r),jQuery("#mdescriptionSizer").html(n);for(var a=new RegExp("sw+(.*)quot;),l=r;l.length>s;)r=jQuery.trim(r.replace(" ...","")),l=jQuery.trim(l.replace(a,"")),t=jQuery.trim(t.replace(a,"")),l.length>=s&&(l=(l=jQuery.trim(l.replace(" ...",""))).substring(0,l.length-1),t=t.substring(0,t.length-1)),l+=" ...";r=l,jQuery("#descriptionSizer").html(r);for(var o=n;o.length>i;)n=jQuery.trim(n.replace(" ...","")),(o=jQuery.trim(o.replace(a,""))).length>=i&&(o=(o=jQuery.trim(o.replace(" ...",""))).substring(0,o.length-1)),o+=" ...";n=o,jQuery("#descriptionSizer").html(n),jQuery("body").append(jQuery("#descriptionSizer")).width(),jQuery("body").append(jQuery("#mdescriptionSizer")).width(),jQuery("body").remove("#descriptionSizer"),jQuery("body").remove("#mdescriptionSizer"),jQuery("#descriptionInfo").html(r.length+" characters, "+jQuery("#descriptionSizer").width()+" pixels, "+wordCount(r)+" words"),info=jQuery("#descriptionSizer").width()+" pixels, "+wordCount(r)+" words ",jQuery("#mdescriptionInfo").html(n.length+" characters, "+jQuery("#mdescriptionSizer").width()+" pixels, "+wordCount(n)+" words"),minfo=jQuery("#mdescriptionSizer").width()+" pixels, "+wordCount(n)+" words ",r.length<=146?jQuery("#descriptionInfo").html(info+'<span style="color:green;">'+r.length+"/~170 characters"):r.length<=160?jQuery("#descriptionInfo").html(info+'<span style="color:orange;">'+r.length+"/~170 characters</span>"):r.length<=166?jQuery("#descriptionInfo").html(info+'<span style="color:purple;">'+r.length+"/~170 characters</span>"):jQuery("#descriptionInfo").html(info+'<span style="color:red;">'+r.length+"/~170 characters</span>"),n.length<=146?jQuery("#mdescriptionInfo").html(minfo+'<span style="color:green;">'+n.length+"/~170 characters"):n.length<=160?jQuery("#mdescriptionInfo").html(minfo+'<span style="color:orange;">'+n.length+"/~170 characters</span>"):n.length<=166?jQuery("#mdescriptionInfo").html(minfo+'<span style="color:purple;">'+n.length+"/~170 characters</span>"):jQuery("#mdescriptionInfo").html(minfo+'<span style="color:red;">'+n.length+"/~170 characters</span>"),jQuery("#techblissonlineSnippetDescription").html(r),jQuery("#techblissonlineMSnippetDescription").html(n)}function updateDateText(){var e=htmlEncode(jQuery.trim(jQuery("#DateText").val()));e.length>0?jQuery("#resultDateText").html(e+" - "):jQuery("#resultDateText").html("")}function setPSPSeoAnalysis(){var e,t=!1,s="",i="";window.wpEditorL10n&&wpEditorL10n.tinymce&&wpEditorL10n.tinymce.settings&&(t=wpEditorL10n.tinymce.settings),t&&wp.data&&wp.data.select?(""==(i=wp.data.select("core/editor").getEditedPostContent())&&(i=wp.data.select("core/editor").getEditedPostAttribute("content")),s=wp.data.select("core/editor").getEditedPostAttribute("title")):(i=jQuery.trim(jQuery("#content").val()),s=jQuery.trim(jQuery("#title").val()));var r=[],n=0;e=i,""!=i&&(i=(i=(i=(i=i.replace(/(<([^>]+)>)/gi,"")).replace(/['"]+/g,"")).replace(/[^a-zA-Z]+/g," ")).toLowerCase(),r=i.split(/[\/\s]+/),n=r.length);var a,l=window.location.hostname,o=!1,p=!1;a=jQuery("<div />",{html:e}).find("a").map(function(){if(jQuery(this).attr("href")&&(-1==jQuery(this).attr("href").indexOf(l)&&(o=!0),-1!==jQuery(this).attr("href").indexOf(l)&&(p=!0)),""!==jQuery(this).text())return jQuery(this).text()}).get();var c;c=jQuery(e).find("img").map(function(){if(jQuery(this).attr("alt")&&""!==jQuery(this).attr("alt"))return jQuery(this).attr("alt")}).get();var d=!1,u=jQuery(e).find("img");void 0!==u&&u.length>0&&(d=!0);var h=!1,m=jQuery("<div />",{html:e}).find("h2, h3, h4, h5, h6");void 0!==m&&m.length>0&&(h=!0);var y;y=jQuery("<div />",{html:e}).find("h1").map(function(){if(""!==jQuery(this).text())return jQuery(this).text()}).get();var g;g=jQuery("<div />",{html:e}).find("h2").map(function(){if(""!==jQuery(this).text())return jQuery(this).text()}).get();var j=jQuery("#urlSizer").html(),Q=jQuery("#techblissonlineSnippetTitle").html(),f=jQuery("#techblissonlineSnippetDescription").val(),w=jQuery("#psp_seo_meta\\[description\\]").val(),v=jQuery("#psp_seo_meta\\[schema_string\\]").val(),S=!1,_=!1;""!==w&&(_=!0),""!==v&&"Invalid JSON Schema"!==v&&(S=!0);var x=jQuery.trim(jQuery("#permalinkSizer").html()),b=jQuery.trim(jQuery("#actualTitleSizer").html());jQuery("#actualTitleSizers").html(b);var z=0,P=0,E=0;""!==x&&(z=x.length),""!==x&&jQuery("#permalinkSizer").width(),""!==b&&(P=jQuery("<textarea />").html(b).text().length),""!==b&&(E=jQuery("#actualTitleSizer").width()),0==E&&(E=jQuery("#actualTitleSizers").width()-1),""!==j&&(j=j.trim());var T=0,k=0,I=0,C=0,A="",L=[0,2,4],U=[1,3,4],D=[],$=jQuery("#psp_seo_meta\\[keywords\\]").val();if(void 0!==amp;&(D=$.split(",")),A+='<div class="psp-bs">',A+='<div class="container-fluid">',A+="<h1>Platinum SEO Analysis</h1>",A+='<p>This is a basic content analysis of this page and your focus keywords. Assigning a score does not mean anything and so we do not do that. Rather, make sure that all these basic recommendations are adhered to. We also recommend you to try our <a href="https://techblissonline.com/tools/" target="_blank">Techblissonline SEO Tools</a> for a detailed analysis of your pages and your competitor pages for your focus keywords, co-occuring words (related entities) and improve your content accordingly. </p>',A+='<div class="panel-group">',A+='<div class="row"><div class="col-sm-12">',A+='<div class="panel panel-primary">',A+='<div class="panel-heading">General</div>',A+='<div class="panel-body">',A+="<ul>",z>0&&z<75?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> URL Length is '+z+" characters </li>":z>75&&(A=A+'<li><span class="dashicons dashicons-dismiss"></span> URL lLength is '+z+' characters <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="URL might get truncated in Google SERPS if it is more than 75 characters wide. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>'),P>0&&P<70?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> SEO Title lLength is '+P+" characters </li>":P>70&&(A=A+'<li><span class="dashicons dashicons-dismiss"></span> Actual SEO Title lLength is '+P+' characters. <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Title might get truncated in Google SERPS if it is more than 70 characters wide. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>'),E>0&&E<574?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> SEO Title pixel width is '+E+" pixels </li>":E>574&&(A=A+'<li><span class="dashicons dashicons-dismiss"></span> SEO Title pixel width is '+E+' pixels including Title format. <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Title might get truncated in Google SERPS if it is more than 574 pixels wide. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>'),A+=_?'<li><span class="dashicons dashicons-yes-alt"></span> Platinum SEO Description is used </li>':'<li><span class="dashicons dashicons-dismiss"></span> Platinum SEO Description field is not filled in. You may be using auto-generated description. <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Using optimized description improves CTR from search and social engines"><sup><span class="dashicons dashicons-info"></span></sup></a></li>',A+=S?'<li><span class="dashicons dashicons-yes-alt"></span> Json Schema is used on this page using Platinum SEO </li>':'<li><span class="dashicons dashicons-dismiss"></span> Json Schema is not used on this page using Platinum SEO <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Using Json Schema has a positive impact on Google. Use our Schema generator tool to generate and add one in the Advanced SEO section."><sup><span class="dashicons dashicons-info"></span></sup></a></li>',""!=i&&(A=n>0&&n>500?A+'<li><span class="dashicons dashicons-yes-alt"></span> Total number of words in Content is '+n+' <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Content length does not matter as long as user intent is matched for the topic covered. Write related articles and link them internally "><sup><span class="dashicons dashicons-info"></span></sup></a></li>':A+'<li><span class="dashicons dashicons-dismiss"></span> Total number of words in Content is '+n+' <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Content length does not matter as long as user intent is matched for the topic covered. Write related articles and link them internally "><sup><span class="dashicons dashicons-info"></span></sup></a></li>',A+=d?'<li><span class="dashicons dashicons-yes-alt"></span> Images used in Content </li>':'<li><span class="dashicons dashicons-dismiss"></span> Images not used in Content <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Using relevant high quality images can increase user engagement and bring in more traffic"><sup><span class="dashicons dashicons-info"></span></sup></a></li>',A+=p?'<li><span class="dashicons dashicons-yes-alt"></span> Internal links used in content. </li>':'<li><span class="dashicons dashicons-dismiss"></span> Internal links not used in Content <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Linking to other relevant internal resources improves Time on site. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>',A+=o?'<li><span class="dashicons dashicons-yes-alt"></span> External links found in content. </li>':'<li><span class="dashicons dashicons-dismiss"></span> External links not found in Content <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Linking to other relevant external resources as references improves trust on content. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>',h&&(A+='<li><span class="dashicons dashicons-yes-alt"></span> Subheaders like h2 are used in Content </li>')),A+="</ul>",A+="</div>",A+="</div>",A+="</div></div>",(void 0!==D||D.length<1)&&""==$)return A+="</div>",A+="</div></div>",void jQuery("#techblissonlineseoanalysis").html(A);jQuery.each(D,function(e,t){if(T=0,k=0,I=0,C=0,searchlc=t.toLowerCase().trim(),!(""==searchlc||e>4)){if(jQuery.each([y,g,c,a],function(e,t){jQuery.each(t,function(t,s){-1!==s.toLowerCase().trim().indexOf(searchlc)&&(0==e&&(T+=1),1==e&&(k+=1),2==e&&(I+=1),3==e&&(C+=1))})}),jQuery.inArray(parseInt(e),L)>-1&&(A+='<div class="row">'),A+='<div class="col-sm-6">',A=(A+='<div class="panel panel-primary">')+'<div class="panel-heading">'+t+"</div>",A+='<div class="panel-body">',A+="<ul>",j&&(searchlcurl=searchlc.replace(/ /g,"-"),-1!==j.search(searchlcurl)?A+='<li><span class="dashicons dashicons-yes-alt"></span> Used in URL </li>':A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in URL </li>'),Q&&(psplctitle=Q.toLowerCase().trim(),-1!==psplctitle.search(searchlc)?(A+='<li><span class="dashicons dashicons-yes-alt"></span> Used in Title </li>',psplctitle.indexOf(searchlc)<20?A+='<li><span class="dashicons dashicons-yes-alt"></span> Found in the beginning of Title </li>':A+='<li><span class="dashicons dashicons-dismiss"></span> Not found in the beginning of Title </li>'):A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in Title </li>'),f&&(psplcdesc=f.toLowerCase().trim(),-1!==psplcdesc.search(searchlc)?(psplcdesc,A+='<li><span class="dashicons dashicons-yes-alt"></span> Used in Meta Description </li>'):A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in Meta Description </li>'),s&&(psplcwptitle=s.toLowerCase().trim(),-1!==psplcwptitle.search(searchlc)?A+='<li><span class="dashicons dashicons-yes-alt"></span> Used in h1 tag (Wordpress Title) </li>':A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in h1 tag (Wordpress Title) </li>'),A+="</ul>",""==i)return A+="</div>",A+="</div>",A+="</div>",void(jQuery.inArray(parseInt(e),U)>-1&&(A+="</div>"));var l,o=[];o=(l=pspGetCounOfIndices(searchlc,r,!1))[1],pspkd=0,pspkeycounter=0,n>0&&o&&(pspkd=o.length/n*100);var p=l[0];p&&(pspkeycounter=p.length),A+="<ul>",o.length>0?(A=pspkd.toFixed(2)<3?A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in content '+o.length+" time(s) </li>":A+'<li><span class="dashicons dashicons-dismiss"></span> Used in content '+o.length+" time(s) </li>",pspkeycounter>0&&pspkeycounter<6?A=A+'<li><li><span class="dashicons dashicons-yes-alt"></span> Found in first 100 words of content '+pspkeycounter+" time(s) </li>":0==pspkeycounter?A+='<li><span class="dashicons dashicons-dismiss"></span> Not found in first 100 words of content </li>':A=A+'<li><span class="dashicons dashicons-dismiss"></span> Found in first 100 words of content '+pspkeycounter+" time(s) </li>",A=pspkd.toFixed(2)<3?A+'<li><span class="dashicons dashicons-yes-alt"></span> Keyword Density of '+t+" is "+pspkd.toFixed(2):A+'<li><span class="dashicons dashicons-dismiss"></span> Keyword Density of '+t+" is "+pspkd.toFixed(2)):A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in Content </li>',T>0&&(A=A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in other h1 tags '+T+" time(s) </li>"),k>0?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in h2 tags '+k+" time(s) </li>":A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in h2 tags </li>',I>0?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in image alt attributes '+I+" time(s) </li>":A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in image alt attributes </li>',C>0?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in anchor texts '+C+" time(s) </li>":A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in anchor texts </li>',A+="</ul>",A+="</div>",A+="</div>",A+="</div>",jQuery.inArray(parseInt(e),U)>-1&&(A+="</div>")}}),A+="</div>",A+="</div></div>",jQuery("#techblissonlineseoanalysis").html(A)}function pspGetCounOfIndices(e,t,s){if(0==e.length)return[];var i,r=[],n=[],a=[];s||(e=e.toLowerCase()),i=t.length;for(let a=0;a<i;a++)str=t[a],str&&(s||(str=str.toLowerCase()),str.indexOf(e,0)>-1&&(n.push(str),a<100&&r.push(str)));return a.push(r),a.push(n),a}function updateAll(){setUrlPreview(),setTitlePreview(),setDescriptionPreview()}String.prototype.trimEnd=function(e){e=e||" ";for(var t=this.length-1;t>=0&&this.charAt(t)==e;t--);return this.substring(0,t+1)},jQuery(document).ready(function(){jQuery("#URL").keyup(function(){setUrlPreview()}),jQuery(document).on("keyup","#new-post-slug",function(){setUrlPreview()}),jQuery(document).on("click",".cancel, .save",function(){setUrlPreview()}),jQuery('input[name="post_category[]"]').click(function(){setTitlePreview()}),jQuery("input[name^='tax_input[']").click(function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[title\\]").keyup(function(){setTitlePreview()}),jQuery("#title").keyup(function(){setTitlePreview()}),jQuery("#name").keyup(function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[titleformat\\]").bind("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[titleformat\\]").on("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[preferred_tax\\]").on("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[disable_title_format\\]").on("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[disable_title\\]").on("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[disable_psp\\]").on("change",function(){setTitlePreview(),setDescriptionPreview()}),jQuery("#psp_seo_meta\\[disable_description\\]").on("change",function(){setDescriptionPreview()}),jQuery("#psp_seo_meta\\[description\\]").keyup(function(){setDescriptionPreview()}),jQuery("#content").keyup(function(){setDescriptionPreview()}),jQuery("#psp_seo_meta\\[maxsnippet\\]").on("change",function(){setDescriptionPreview()}),jQuery("#DateText").keyup(function(){updateDateText()}),jQuery("#psp_seo_meta\\[keywords\\]").keyup(function(){setPSPSeoAnalysis()}),jQuery("#psp_analyse_btn").on("click",function(){updateAll()}),updateAll()});
1
+ function escapeRegExp(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\amp;")}function wordCount(e){var t=e.match(/\S+/g);return t?t.length:0}function pspSortArray(e,t){var s=[],i=[];for(let r=0;r<e.length;r++)i=[],void 0!==(i=wp.data.select("core").getEntityRecord("taxonomy",t,e[r]))&&(s[r]=i.name);return s?(s.sort(),s[0]):"%"+t+"%"}function pspSortClassicArray(e,t){var s=[];return jQuery('input[name="'+e+'"]:checked').each(function(){s.push(jQuery(this).parent("label").text())}),s&&s.length?(s.sort(),s[0]):"%"+t+"%"}function boldWords(e){var t=e,s=jQuery("#psp_seo_meta\\[keywords\\]").val().match(/\S+/g);if(s)for(i=0;i<s.length;i++)t=(t=t.replace(new RegExp("(^|[\\W])("+escapeRegExp(s[i])+")([\\W]|$)","gi"),"$1<b>$2</b>$3")).replace(new RegExp("(^|[\\W])("+escapeRegExp(s[i])+")([\\W]|$)","gi"),"$1<b>$2</b>$3");return t}function boldText(e){var t=e,s=jQuery("#psp_seo_meta\\[keywords\\]").val().match(/\S+/g);if(s)for(i=0;i<s.length;i++)t=t.replace(new RegExp("("+escapeRegExp(s[i])+")","gi"),"<b>$1</b>");return t}function htmlEncode(e){return jQuery("<div/>").text(e).html()}function setGtbUrlPreview(e){var t="";(t=e)&&(t=t.replace(/^https?\:\/\//i,""));var s=htmlEncode(t),i=(s=s.replace(/\/#x2F;,"")).length;jQuery("#permalinkSizer").html(s);var r=s=s.replace(/([^https?:\/\/])(\/)/g,"$1 > ");t=s,jQuery("#urlSizer").html(s),jQuery("#murlSizer").html(r);var n=new RegExp("W(.*)quot;);for(trimmed=!1;jQuery("#urlSizer").width()>566;){var a=s;a=(a=(a=(a=a.substring(0,a.length-1)).trim()).replace(/\>#x2F;,"")).trim(),jQuery("#urlSizer").html(a),s=a,trimmed=!0}trimmed&&(s+=" ...",jQuery("#urlSizer").html(s)),info=i+" characters, ",jQuery("#urlInfo").html(s.length+" characters, "+jQuery("#urlSizer").width()+" pixels"),jQuery("#urlSizer").width()<=584?jQuery("#urlInfo").html(info+'<span style="color:green;">'+jQuery("#urlSizer").width()+"/584 pixels</span>"):jQuery("#urlInfo").html(info+'<span style="color:red;">'+jQuery("#urlSizer").width()+"/584 pixels</span>"),jQuery("#techblissonlineSnippetUrl").html(s),mtrimmed=!1;for(var l=r;r.length>42;)r=jQuery.trim(r.replace(" ...","")),(l=(l=(l=jQuery.trim(l.replace(n,""))).trim()).replace(/\>#x2F;,"")).length>=42&&(l=(l=jQuery.trim(r.replace(" ...",""))).substring(0,l.length-1)),l=l.trim(),r=l+=" ...",mtrimmed=!0;mtrimmed&&jQuery("#murlSizer").html(r),info=r.length+" characters, ",jQuery("#murlInfo").html(r.length+" characters, "+jQuery("#murlSizer").width()+" pixels"),jQuery("#murlSizer").width()<=282?jQuery("#murlInfo").html(info+'<span style="color:green;">'+jQuery("#urlSizer").width()+" pixels</span>"):jQuery("#murlInfo").html(info+'<span style="color:red;">'+jQuery("#murlSizer").width()+" pixels</span>"),jQuery("#techblissonlineMSnippetUrl").html(r)}function setUrlPreview(){var e=jQuery.trim(jQuery("#pspHomePermalink").text())+"slug-name/",t=!1;if(window.wpEditorL10n&&wpEditorL10n.tinymce&&wpEditorL10n.tinymce.settings&&(t=wpEditorL10n.tinymce.settings),jQuery("#editable-post-name").length){e=jQuery.trim(jQuery("#sample-permalink").text());var s=jQuery.trim(jQuery("#editable-post-name").text());e=(e=e.replace(s,"")).replace(/\/#x2F;g,"")}else jQuery("#name").length?e=jQuery.trim(jQuery("#pspPostPermalink").text()):jQuery("#slug").length?e=jQuery.trim(jQuery("#pspPostPermalink").text()):t&&wp.data&&wp.data.select&&(e=wp.data.select("core/editor").getPermalink(),wp.data.subscribe(function(){setGtbUrlPreview(wp.data.select("core/editor").getPermalink())}));if(jQuery("#new-post-slug").length>0)e+=jQuery("#new-post-slug").val();else if(jQuery("#editable-post-name-full").length){e+=jQuery("#editable-post-name-full").text()}e&&(e=e.replace(/^https?\:\/\//i,""));var i=htmlEncode(e),r=i.length;r=(i=i.replace(/\/#x2F;,"")).length;jQuery("#permalinkSizer").html(i);var n=i=i.replace(/([^https?:\/\/])(\/)/g,"$1 > ");e=i,jQuery("#urlSizer").html(i),jQuery("#murlSizer").html(n);var a=new RegExp("W(.*)quot;);for(trimmed=!1;jQuery("#urlSizer").width()>584;){var l=i;l=(l=(l=(l=l.substring(0,l.length-1)).trim()).replace(/\>#x2F;,"")).trim(),jQuery("#urlSizer").html(l),i=l,trimmed=!0}trimmed&&(i+=" ..."),info=r+" characters, ",jQuery("#urlInfo").html(r+" characters, "+jQuery("#urlSizer").width()+" pixels"),jQuery("#urlSizer").width()<=584?jQuery("#urlInfo").html(info+'<span style="color:green;">'+jQuery("#urlSizer").width()+"/584 pixels</span>"):jQuery("#urlInfo").html(info+'<span style="color:red;">'+jQuery("#urlSizer").width()+"/584 pixels</span>"),jQuery("#techblissonlineSnippetUrl").html(i),mtrimmed=!1;for(var o=n;o.length>42;)n=jQuery.trim(n.replace(" ...","")),(o=(o=(o=jQuery.trim(o.replace(a,""))).trim()).replace(/\>#x2F;,"")).length>=42&&(o=(o=jQuery.trim(n.replace(" ...",""))).substring(0,o.length-1)),o=o.trim(),n=o+=" ...",mtrimmed=!0;mtrimmed&&jQuery("#murlSizer").html(n),info=n.length+" characters, ",jQuery("#murlInfo").html(n.length+" characters, "+jQuery("#murlSizer").width()+" pixels"),jQuery("#murlSizer").width()<=282?jQuery("#murlInfo").html(info+'<span style="color:green;">'+jQuery("#urlSizer").width()+" pixels</span>"):jQuery("#murlInfo").html(info+'<span style="color:red;">'+jQuery("#murlSizer").width()+" pixels</span>"),jQuery("#techblissonlineMSnippetUrl").html(n)}function stripTrailingSlash(e){return"/"==e.substr(-1)?e.substr(0,e.length-1):e}function setGtbTitlePreview(e,t){var s=jQuery("#psp_seo_meta\\[titleformat\\]").val(),i=!1,r=!1;jQuery("#psp_seo_meta\\[disable_title_format\\]:checked").length>0&&(i=!0),jQuery("#psp_seo_meta\\[disable_psp\\]:checked").length>0&&(r=!0),i&&(s="%seo_title%"),r&&(s="%wp_title%");var n=jQuery("#pspPostTypeArrayFormat").text(),a=JSON.parse(n),l=jQuery("#psp_seo_meta\\[title\\]"),o=s.replace("%seo_title%",e);if(""===e&&(o=o.replace("%seo_title%",l.attr("placeholder"))),o=(o=(o=(o=(o=(o=o.replace("%wp_title%",a.wp_title)).replace("%site_name%",a.site_name)).replace("%site_description%",a.site_description)).replace("%category%",t)).replace("%taxonomy%",t)).replace(/%sep%/g,a.sep),""!==(o=(o=jQuery.trim(o)).trim(a.sep))){var p=htmlEncode(o),c=p;jQuery("#titleSizer").html(p),jQuery("#actualTitleSizer").html(p);var d=new RegExp("sw+(.*)quot;);trimmed=!1;for(var u=p;jQuery("#titleSizer").width()>584;)p=jQuery.trim(p.replace(" ...","")),(u=jQuery.trim(u.replace(d,""))).length>=p.length&&(u=u.substring(0,u.length-1)),p=u+" ...",jQuery("#titleSizer").html(p),trimmed=!0;trimmed,jQuery("#titleSizer").html(p),mtrimmed=!1;for(var h=c;h.length>78;)c=jQuery.trim(c.replace(" ...","")),(h=jQuery.trim(h.replace(d,""))).length>=78&&(h=(h=jQuery.trim(h.replace(" ...",""))).substring(0,h.length-1)),c=h+=" ...",mtrimmed=!0;mtrimmed,jQuery("#mtitleSizer").html(c),info=jQuery("<textarea />").html(p).text().length+" characters, "+wordCount(p)+" words ",jQuery("#titleInfo").html(p.length+" characters, "+jQuery("#titleSizer").width()+" pixels, "+wordCount(p)+" words"),jQuery("#titleSizer").width()<=584?jQuery("#titleInfo").html(info+'<span style="color:green;">'+jQuery("#titleSizer").width()+"/584 pixels</span>"):jQuery("#titleInfo").html(info+'<span style="color:red;">'+jQuery("#titleSizer").width()+"/584 pixels</span>"),minfo=jQuery("<textarea />").html(c).text().length+" characters/ 78 characters "+wordCount(c)+" words ",jQuery("#mtitleInfo").html(c.length+" characters, "+jQuery("#mtitleSizer").width()+" pixels, "+wordCount(c)+" words"),c.length<=78?jQuery("#mtitleInfo").html('<span style="color:green;">'+minfo+"</span> "+jQuery("#mtitleSizer").width()+" pixels"):jQuery("#mtitleInfo").html('<span style="color:red;">'+minfo+"</span> "+jQuery("#mtitleSizer").width()+" pixels"),jQuery("#techblissonlineSnippetTitle").html(p),jQuery("#techblissonlineMSnippetTitle").html(c),setPSPSeoAnalysis()}}function setTitlePreview(){var e,t,s="",i="",r="",n=!1,a="";window.wpEditorL10n&&wpEditorL10n.tinymce&&wpEditorL10n.tinymce.settings&&(n=wpEditorL10n.tinymce.settings);var l=jQuery("#pspPostTypeArrayFormat").text(),o=JSON.parse(l),p=jQuery("#psp_seo_meta\\[titleformat\\]").val(),c=!1,d=!1,u=!1;jQuery("#psp_seo_meta\\[disable_title_format\\]:checked").length>0&&(c=!0),jQuery("#psp_seo_meta\\[disable_title\\]:checked").length>0&&(d=!0),jQuery("#psp_seo_meta\\[disable_psp\\]:checked").length>0&&(u=!0);a=o.category,p.toLowerCase().indexOf("%wp_title%");var h=jQuery("#title"),m=jQuery("#psp_seo_meta\\[title\\]");i=m.attr("placeholder");var y=jQuery("#psp_seo_meta\\[preferred_tax\\]"),g="categories",j="post_category[]",Q="category";if(y&&y.val()&&"category"!==(Q=jQuery("#psp_seo_meta\\[preferred_tax\\] option:selected").text())&&(g=Q,j="tax_input["+Q+"][]"),h&&(a=pspSortClassicArray(j,Q)),!m.val()||d||u?(jQuery("#title").val()?i=jQuery.trim(jQuery("#title").val()):jQuery("#name").val()?i=jQuery.trim(jQuery("#name").val()):n&&wp.data&&wp.data.select&&(i=wp.data.select("core/editor").getEditedPostAttribute("title"),t=wp.data.select("core/editor").getEditedPostAttribute(g),a="%"+Q+"%",void 0!==t&&t.length>0&&(a=pspSortArray(t,Q)),wp.data.subscribe(function(){i=wp.data.select("core/editor").getEditedPostAttribute("title"),t=wp.data.select("core/editor").getEditedPostAttribute(g),a="%"+Q+"%",void 0!==t&&t.length>0&&(a=pspSortArray(t,Q)),void 0===i&&(m=jQuery("#psp_seo_meta\\[title\\]")),""===i&&(m=jQuery("#psp_seo_meta\\[title\\]"),i=m.attr("placeholder")),a&&setGtbTitlePreview(i,a)})),s=i,(c||u)&&(p="%wp_title%"),s=(s=(s=(s=(s=(s=(s=p.replace("%seo_title%",i)).replace("%wp_title%",i)).replace("%site_name%",o.site_name)).replace("%site_description%",o.site_description)).replace("%taxonomy%",a)).replace("%category%",a)).replace(/%sep%/g,o.sep),s=(s=jQuery.trim(s)).trim(o.sep)):(s=m.val(),r=m.val(),jQuery("#title").val()?i=jQuery.trim(jQuery("#title").val()):jQuery("#name").val()?i=jQuery.trim(jQuery("#name").val()):n&&wp.data&&wp.data.select&&(i=wp.data.select("core/editor").getEditedPostAttribute("title"),e=wp.data.select("core/editor").getEditedPostAttribute(g),a="%"+Q+"%",void 0!==e&&e.length>0&&(a=pspSortArray(e,Q)),wp.data.subscribe(function(){i=wp.data.select("core/editor").getEditedPostAttribute("title"),e=wp.data.select("core/editor").getEditedPostAttribute(g),a="%"+Q+"%",r=m.val(),void 0!==e&&e.length>0&&(a=pspSortArray(e,Q)),r&&a&&setGtbTitlePreview(r,a)})),c&&(p="%seo_title%"),s=(s=(s=(s=(s=(s=(s=p.replace("%seo_title%",r)).replace("%wp_title%",i)).replace("%site_name%",o.site_name)).replace("%site_description%",o.site_description)).replace("%taxonomy%",a)).replace("%category%",a)).replace(/%sep%/g,o.sep),s=(s=jQuery.trim(s)).trim(o.sep)),""!==s){""===i||n||i;var f=htmlEncode(s),w=f;jQuery("#titleSizer").html(f),jQuery("#actualTitleSizer").html(f);var v=new RegExp("sw+(.*)quot;),S=f;for(trimmed=!1;jQuery("#titleSizer").width()>584;)f=jQuery.trim(f.replace(" ...","")),(S=jQuery.trim(S.replace(v,""))).length>=f.length&&(S=S.substring(0,S.length-1)),f=S+" ...",jQuery("#titleSizer").text(f),trimmed=!0;trimmed,jQuery("#titleSizer").text(f),jQuery("body").append(jQuery("#titleSizer")).width(),jQuery("body#titleSizer").remove(),info=jQuery("<textarea />").html(f).text().length+" characters, "+wordCount(f)+" words ",jQuery("#titleInfo").html(f.length+" characters, "+jQuery("#titleSizer").width()+" pixels, "+wordCount(f)+" words"),jQuery("#titleSizer").width()<=584?jQuery("#titleInfo").html(info+'<span style="color:green;">'+jQuery("#titleSizer").width()+"/584 pixels</span>"):jQuery("#titleInfo").html(info+'<span style="color:red;">'+jQuery("#titleSizer").width()+"/584 pixels</span>"),jQuery("#techblissonlineSnippetTitle").html(f);var _=w;for(mtrimmed=!1;_.length>78;)w=jQuery.trim(w.replace(" ...","")),(_=jQuery.trim(_.replace(v,""))).length>=78&&(_=(_=jQuery.trim(_.replace(" ...",""))).substring(0,_.length-1)),w=_+=" ...",mtrimmed=!0;mtrimmed,jQuery("#mtitleSizer").text(w),jQuery("body").append(jQuery("#mtitleSizer")).width(),jQuery("body#mtitleSizer").remove(),minfo=jQuery("<textarea />").html(w).text().length+" characters/ 78 characters "+wordCount(w)+" words ",jQuery("#mtitleInfo").html(w.length+" characters, "+jQuery("#mtitleSizer").width()+" pixels, "+wordCount(w)+" words"),w.length<=78?jQuery("#mtitleInfo").html('<span style="color:green;">'+minfo+"</span> "+jQuery("#mtitleSizer").width()+" pixels"):jQuery("#mtitleInfo").html('<span style="color:red;">'+minfo+"</span> "+jQuery("#mtitleSizer").width()+" pixels"),jQuery("#techblissonlineMSnippetTitle").html(w),setPSPSeoAnalysis()}}function setDescriptionPreview(){var e,t=!1,s=jQuery("#psp_seo_meta\\[description\\]");window.wpEditorL10n&&wpEditorL10n.tinymce&&wpEditorL10n.tinymce.settings&&(t=wpEditorL10n.tinymce.settings);var i=jQuery.trim(jQuery("#psp_seo_meta\\[maxsnippet\\]").val()),r=i;parseInt(i)<0&&(i=230,r=285),jQuery.inArray(parseInt(i),[-1,0,1,2,3,4])>-1&&(i=230,r=285),""===i&&(i=230,r=285),i=parseInt(i),r=parseInt(r);var n="",a=!1,l=!1,o=jQuery("#pspPostTypeArrayFormat").text();if(e=JSON.parse(o).autogendesc,jQuery("#psp_seo_meta\\[disable_psp\\]:checked").length>0&&(a=!0),jQuery("#psp_seo_meta\\[disable_description\\]:checked").length>0&&(l=!0),""!==n||a||l||(n=jQuery.trim(jQuery("#psp_seo_meta\\[description\\]").val())),""===n){if(""===n&&t&&wp.data&&wp.data.select){var p=wp.data.select("core/editor").getEditedPostContent();return""!==e&&(n=(n=p.replace(/(<([^>]+)>)/gi,"")).substring(0,r)),n||(n=s.attr("placeholder")),void setGTBDescPreview(n)}var c=jQuery.trim(jQuery("#content").val());if(!s.val()||a||l)return""!==e&&(n=(n=c.replace(/(<([^>]+)>)/gi,"")).substring(0,r)),n||(n=s.attr("placeholder")),void setGTBDescPreview(n)}return n?void setGTBDescPreview(n):void 0}function setGTBDescPreview(e){jQuery("#psp_seo_meta\\[description\\]");var t=e;placeholder_desc=e;var s=jQuery.trim(jQuery("#psp_seo_meta\\[maxsnippet\\]").val()),i=s;parseInt(s)<0&&(s=230,i=285),jQuery.inArray(parseInt(s),[-1,0,1,2,3,4])>-1&&(s=230,i=285),""===s&&(s=230,i=285),s=parseInt(s),i=parseInt(i);var r=htmlEncode(t),n=r+=" ...";jQuery("#descriptionSizer").html(r),jQuery("#mdescriptionSizer").html(n);for(var a=new RegExp("sw+(.*)quot;),l=r;l.length>s;)r=jQuery.trim(r.replace(" ...","")),l=jQuery.trim(l.replace(a,"")),t=jQuery.trim(t.replace(a,"")),l.length>=s&&(l=(l=jQuery.trim(l.replace(" ...",""))).substring(0,l.length-1),t=t.substring(0,t.length-1)),l+=" ...";r=l,jQuery("#descriptionSizer").html(r);for(var o=n;o.length>i;)n=jQuery.trim(n.replace(" ...","")),(o=jQuery.trim(o.replace(a,""))).length>=i&&(o=(o=jQuery.trim(o.replace(" ...",""))).substring(0,o.length-1)),o+=" ...";n=o,jQuery("#descriptionSizer").html(n),jQuery("body").append(jQuery("#descriptionSizer")).width(),jQuery("body").append(jQuery("#mdescriptionSizer")).width(),jQuery("body").remove("#descriptionSizer"),jQuery("body").remove("#mdescriptionSizer"),jQuery("#descriptionInfo").html(r.length+" characters, "+jQuery("#descriptionSizer").width()+" pixels, "+wordCount(r)+" words"),info=jQuery("#descriptionSizer").width()+" pixels, "+wordCount(r)+" words ",jQuery("#mdescriptionInfo").html(n.length+" characters, "+jQuery("#mdescriptionSizer").width()+" pixels, "+wordCount(n)+" words"),minfo=jQuery("#mdescriptionSizer").width()+" pixels, "+wordCount(n)+" words ",r.length<=146?jQuery("#descriptionInfo").html(info+'<span style="color:green;">'+r.length+"/~170 characters"):r.length<=160?jQuery("#descriptionInfo").html(info+'<span style="color:orange;">'+r.length+"/~170 characters</span>"):r.length<=166?jQuery("#descriptionInfo").html(info+'<span style="color:purple;">'+r.length+"/~170 characters</span>"):jQuery("#descriptionInfo").html(info+'<span style="color:red;">'+r.length+"/~170 characters</span>"),n.length<=146?jQuery("#mdescriptionInfo").html(minfo+'<span style="color:green;">'+n.length+"/~170 characters"):n.length<=160?jQuery("#mdescriptionInfo").html(minfo+'<span style="color:orange;">'+n.length+"/~170 characters</span>"):n.length<=166?jQuery("#mdescriptionInfo").html(minfo+'<span style="color:purple;">'+n.length+"/~170 characters</span>"):jQuery("#mdescriptionInfo").html(minfo+'<span style="color:red;">'+n.length+"/~170 characters</span>"),jQuery("#techblissonlineSnippetDescription").html(r),jQuery("#techblissonlineMSnippetDescription").html(n)}function updateDateText(){var e=htmlEncode(jQuery.trim(jQuery("#DateText").val()));e.length>0?jQuery("#resultDateText").html(e+" - "):jQuery("#resultDateText").html("")}function setPSPSeoAnalysis(){var e,t=!1,s="",i="";window.wpEditorL10n&&wpEditorL10n.tinymce&&wpEditorL10n.tinymce.settings&&(t=wpEditorL10n.tinymce.settings),t&&wp.data&&wp.data.select?(""==(i=wp.data.select("core/editor").getEditedPostContent())&&(i=wp.data.select("core/editor").getEditedPostAttribute("content")),s=wp.data.select("core/editor").getEditedPostAttribute("title")):(i=jQuery.trim(jQuery("#content").val()),s=jQuery.trim(jQuery("#title").val()));var r=[],n=0;e=i,""!=i&&(i=(i=(i=(i=i.replace(/(<([^>]+)>)/gi,"")).replace(/['"]+/g,"")).replace(/[^a-zA-Z]+/g," ")).toLowerCase(),r=i.split(/[\/\s]+/),n=r.length);var a,l=window.location.hostname,o=!1,p=!1;a=jQuery("<div />",{html:e}).find("a").map(function(){if(jQuery(this).attr("href")&&(-1==jQuery(this).attr("href").indexOf(l)&&(o=!0),-1!==jQuery(this).attr("href").indexOf(l)&&(p=!0)),""!==jQuery(this).text())return jQuery(this).text()}).get();var c;c=jQuery(e).find("img").map(function(){if(jQuery(this).attr("alt")&&""!==jQuery(this).attr("alt"))return jQuery(this).attr("alt")}).get();var d=!1,u=jQuery(e).find("img");void 0!==u&&u.length>0&&(d=!0);var h=!1,m=jQuery("<div />",{html:e}).find("h2, h3, h4, h5, h6");void 0!==m&&m.length>0&&(h=!0);var y;y=jQuery("<div />",{html:e}).find("h1").map(function(){if(""!==jQuery(this).text())return jQuery(this).text()}).get();var g;g=jQuery("<div />",{html:e}).find("h2").map(function(){if(""!==jQuery(this).text())return jQuery(this).text()}).get();var j=jQuery("#urlSizer").html(),Q=jQuery("#techblissonlineSnippetTitle").html(),f=jQuery("#techblissonlineSnippetDescription").val(),w=jQuery("#psp_seo_meta\\[description\\]").val(),v=jQuery("#psp_seo_meta\\[schema_string\\]").val(),S=!1,_=!1;""!==w&&(_=!0),""!==v&&"Invalid JSON Schema"!==v&&(S=!0);var x=jQuery.trim(jQuery("#permalinkSizer").html()),b=jQuery.trim(jQuery("#actualTitleSizer").html());jQuery("#actualTitleSizers").html(b);var z=0,P=0,E=0;""!==x&&(z=x.length),""!==x&&jQuery("#permalinkSizer").width(),""!==b&&(P=jQuery("<textarea />").html(b).text().length),""!==b&&(E=jQuery("#actualTitleSizer").width()),0==E&&(E=jQuery("#actualTitleSizers").width()-1),""!==j&&(j=j.trim());var k=0,T=0,I=0,C=0,A="",L=[0,2,4],U=[1,3,4],D=[],R=jQuery("#psp_seo_meta\\[keywords\\]").val();if(void 0!==R&&(D=R.split(",")),A+='<div class="psp-bs">',A+='<div class="container-fluid">',A+="<h1>Platinum SEO Analysis</h1>",A+='<p>This is a basic content analysis of this page and your focus keywords. Assigning a score does not mean anything and so we do not do that. Rather, make sure that all these basic recommendations are adhered to. We also recommend you to try our <a href="https://techblissonline.com/tools/" target="_blank">Techblissonline SEO Tools</a> for a detailed analysis of your pages and your competitor pages for your focus keywords, co-occuring words (related entities) and improve your content accordingly. </p>',A+='<div class="panel-group">',A+='<div class="row"><div class="col-sm-12">',A+='<div class="panel panel-primary">',A+='<div class="panel-heading">General</div>',A+='<div class="panel-body">',A+="<ul>",z>0&&z<75?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> URL Length is '+z+" characters </li>":z>75&&(A=A+'<li><span class="psp-info dashicons dashicons-info"></span> URL lLength is '+z+' characters <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="URL might get truncated in Google SERPS if it is more than 75 characters wide. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>'),P>0&&P<70?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> SEO Title lLength is '+P+" characters </li>":P>70&&(A=A+'<li><span class="dashicons dashicons-dismiss"></span> Actual SEO Title lLength is '+P+' characters. <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Title might get truncated in Google SERPS if it is more than 70 characters wide. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>'),E>0&&E<574?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> SEO Title pixel width is '+E+" pixels </li>":E>574&&(A=A+'<li><span class="dashicons dashicons-dismiss"></span> SEO Title pixel width is '+E+' pixels including Title format. <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Title might get truncated in Google SERPS if it is more than 574 pixels wide. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>'),A+=_?'<li><span class="dashicons dashicons-yes-alt"></span> Platinum SEO Description is used </li>':'<li><span class="dashicons dashicons-dismiss"></span> Platinum SEO Description field is not filled in. You may have an auto-generated description. <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Using optimized description improves CTR from search and social engines"><sup><span class="dashicons dashicons-info"></span></sup></a></li>',A+=S?'<li><span class="dashicons dashicons-yes-alt"></span> Json Schema is used on this page using Platinum SEO </li>':'<li><span class="dashicons dashicons-dismiss"></span> Json Schema is not used on this page using Platinum SEO <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Using Json Schema has a positive impact on Google. Use our Schema generator tool to generate and add one in the Advanced SEO section."><sup><span class="dashicons dashicons-info"></span></sup></a></li>',""!=i&&(A=n>0&&n>500?A+'<li><span class="dashicons dashicons-yes-alt"></span> Total number of words in Content is '+n+' <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Content length does not matter as long as user intent is matched for the topic covered. Write related articles and link them internally "><sup><span class="dashicons dashicons-info"></span></sup></a></li>':A+'<li><span class="psp-info dashicons dashicons-info"></span> Total number of words in Content is '+n+' <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Content length does not matter as long as user intent is matched for the topic covered. Write related articles and link them internally "><sup><span class="dashicons dashicons-info"></span></sup></a></li>',A+=d?'<li><span class="dashicons dashicons-yes-alt"></span> Images used in Content </li>':'<li><span class="dashicons dashicons-dismiss"></span> Images not used in Content <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Using relevant high quality images can increase user engagement and bring in more traffic"><sup><span class="dashicons dashicons-info"></span></sup></a></li>',A+=p?'<li><span class="dashicons dashicons-yes-alt"></span> Internal links used in content. </li>':'<li><span class="dashicons dashicons-dismiss"></span> Internal links not used in Content <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Linking to other relevant internal resources improves Time on site. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>',A+=o?'<li><span class="dashicons dashicons-yes-alt"></span> External links found in content. Referring to an authoritative source on which the underlying research for the content was done or linking to the creator of the product the page is about, is always a good practice that improves trust. </li>':'<li><span class="psp-info dashicons dashicons-info"></span> External links not found in Content.Referring to an authoritative source on which the underlying research for the content was done or linking to the creator of the product this page is about, is always a good practice that improves trust. <a href="#" class="psptip" data-toggle="tooltip" data-placement="top" title="Linking to other relevant external resources as references improves trust on content. "><sup><span class="dashicons dashicons-info"></span></sup></a></li>',h&&(A+='<li><span class="dashicons dashicons-yes-alt"></span> Subheaders like h2 are used in Content </li>')),A+="</ul>",A+="</div>",A+="</div>",A+="</div></div>",(void 0!==D||D.length<1)&&""==R)return A+="</div>",A+="</div></div>",void jQuery("#techblissonlineseoanalysis").html(A);jQuery.each(D,function(e,t){if(k=0,T=0,I=0,C=0,searchlc=t.toLowerCase().trim(),!(""==searchlc||e>4)){if(jQuery.each([y,g,c,a],function(e,t){jQuery.each(t,function(t,s){-1!==s.toLowerCase().trim().indexOf(searchlc)&&(0==e&&(k+=1),1==e&&(T+=1),2==e&&(I+=1),3==e&&(C+=1))})}),jQuery.inArray(parseInt(e),L)>-1&&(A+='<div class="row">'),A+='<div class="col-sm-6">',A=(A+='<div class="panel panel-primary">')+'<div class="panel-heading">'+t+"</div>",A+='<div class="panel-body">',A+="<ul>",j&&(searchlcurl=searchlc.replace(/ /g,"-"),-1!==j.search(searchlcurl)?A+='<li><span class="dashicons dashicons-yes-alt"></span> Used in URL </li>':A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in URL </li>'),Q&&(psplctitle=Q.toLowerCase().trim(),-1!==psplctitle.search(searchlc)?(A+='<li><span class="dashicons dashicons-yes-alt"></span> Used in Title </li>',psplctitle.indexOf(searchlc)<20?A+='<li><span class="dashicons dashicons-yes-alt"></span> Found in the beginning of Title </li>':A+='<li><span class="dashicons dashicons-dismiss"></span> Not found in the beginning of Title </li>'):A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in Title </li>'),f&&(psplcdesc=f.toLowerCase().trim(),-1!==psplcdesc.search(searchlc)?(psplcdesc,A+='<li><span class="dashicons dashicons-yes-alt"></span> Used in Meta Description </li>'):A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in Meta Description </li>'),s&&(psplcwptitle=s.toLowerCase().trim(),-1!==psplcwptitle.search(searchlc)?A+='<li><span class="dashicons dashicons-yes-alt"></span> Used in h1 tag (Wordpress Title) </li>':A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in h1 tag (Wordpress Title) </li>'),A+="</ul>",""==i)return A+="</div>",A+="</div>",A+="</div>",void(jQuery.inArray(parseInt(e),U)>-1&&(A+="</div>"));var l,o=[];o=(l=pspGetCounOfIndices(searchlc,r,!1))[1],pspkd=0,pspkeycounter=0,n>0&&o&&(pspkd=o.length/n*100);var p=l[0];p&&(pspkeycounter=p.length),A+="<ul>",o.length>0?(A=pspkd.toFixed(2)<3?A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in content '+o.length+" time(s) </li>":A+'<li><span class="dashicons dashicons-dismiss"></span> Used in content '+o.length+" time(s) </li>",pspkeycounter>0&&pspkeycounter<6?A=A+'<li><li><span class="dashicons dashicons-yes-alt"></span> Found in first 100 words of content '+pspkeycounter+" time(s) </li>":0==pspkeycounter?A+='<li><span class="dashicons dashicons-dismiss"></span> Not found in first 100 words of content </li>':A=A+'<li><span class="dashicons dashicons-dismiss"></span> Found in first 100 words of content '+pspkeycounter+" time(s) </li>",A=pspkd.toFixed(2)<3?A+'<li><span class="dashicons dashicons-yes-alt"></span> Keyword Density of '+t+" is "+pspkd.toFixed(2):A+'<li><span class="dashicons dashicons-dismiss"></span> Keyword Density of '+t+" is "+pspkd.toFixed(2)):A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in Content </li>',k>0&&(A=A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in other h1 tags '+k+" time(s) </li>"),T>0?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in h2 tags '+T+" time(s) </li>":A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in h2 tags </li>',I>0?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in image alt attributes '+I+" time(s) </li>":A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in image alt attributes </li>',C>0?A=A+'<li><span class="dashicons dashicons-yes-alt"></span> Used in anchor texts '+C+" time(s) </li>":A+='<li><span class="dashicons dashicons-dismiss"></span> Not used in anchor texts </li>',A+="</ul>",A+="</div>",A+="</div>",A+="</div>",jQuery.inArray(parseInt(e),U)>-1&&(A+="</div>")}}),A+="</div>",A+="</div></div>",jQuery("#techblissonlineseoanalysis").html(A)}function pspGetCounOfIndices(e,t,s){if(0==e.length)return[];var i,r=[],n=[],a=[];s||(e=e.toLowerCase()),i=t.length;for(let a=0;a<i;a++)str=t[a],str&&(s||(str=str.toLowerCase()),str.indexOf(e,0)>-1&&(n.push(str),a<100&&r.push(str)));return a.push(r),a.push(n),a}function updateAll(){setUrlPreview(),setTitlePreview(),setDescriptionPreview()}String.prototype.trimEnd=function(e){e=e||" ";for(var t=this.length-1;t>=0&&this.charAt(t)==e;t--);return this.substring(0,t+1)},jQuery(document).ready(function(){jQuery("#URL").keyup(function(){setUrlPreview()}),jQuery(document).on("keyup","#new-post-slug",function(){setUrlPreview()}),jQuery(document).on("click",".cancel, .save",function(){setUrlPreview()}),jQuery('input[name="post_category[]"]').click(function(){setTitlePreview()}),jQuery("input[name^='tax_input[']").click(function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[title\\]").keyup(function(){setTitlePreview()}),jQuery("#title").keyup(function(){setTitlePreview()}),jQuery("#name").keyup(function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[titleformat\\]").bind("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[titleformat\\]").on("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[preferred_tax\\]").on("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[disable_title_format\\]").on("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[disable_title\\]").on("change",function(){setTitlePreview()}),jQuery("#psp_seo_meta\\[disable_psp\\]").on("change",function(){setTitlePreview(),setDescriptionPreview()}),jQuery("#psp_seo_meta\\[disable_description\\]").on("change",function(){setDescriptionPreview()}),jQuery("#psp_seo_meta\\[description\\]").keyup(function(){setDescriptionPreview()}),jQuery("#content").keyup(function(){setDescriptionPreview()}),jQuery("#psp_seo_meta\\[maxsnippet\\]").on("change",function(){setDescriptionPreview()}),jQuery("#DateText").keyup(function(){updateDateText()}),jQuery("#psp_seo_meta\\[keywords\\]").keyup(function(){setPSPSeoAnalysis()}),jQuery("#psp_analyse_btn").on("click",function(){updateAll()}),updateAll()});
psp-include/settings/psp_analysis_metabox_renderer.php CHANGED
@@ -14,7 +14,7 @@ Author URI: https://techblissonline.com/
14
echo "<div class='psp-bs'><input ".esc_attr($diskey_checked)." id='psp_seo_meta[disable_keywords]' name='psp_seo_meta[disable_keywords]' type='checkbox' data-toggle='toggle' data-on='Off' data-onstyle='default' data-off='On' data-offstyle='success' data-style='ios' /></div><br />";
15
?><?php } ?></th>
16
<td><input type="text" name="psp_seo_meta[keywords]" id="psp_seo_meta[keywords]" value="<?php echo ( isset($psp_seo_meta['keywords']) ? esc_attr($psp_seo_meta['keywords']) : ''); ?>"><br />
17
- <p class="description"><?php esc_html_e('Set comma separated meta keywords to be used for this post/page.Meta Keywords tag should also be switched on sitewide in Platinum SEO General setthings. These are also used as the Focus keywords for Platinum SEO Analysis of this page,', 'platinum-seo-pack'); ?></p>
18
<p class="description"><strong><?php esc_html_e('Enter comma separated focus keywords in the input above and find the analysis below', 'platinum-seo-pack'); ?></strong></p>
19
<div class="psp-bs"><input style="width:20%;display:block;margin:auto" id="psp_analyse_btn" class="psp_analyser btn btn-primary" type="hidden" value="Analyse" /></div>
20
</td>
14
echo "<div class='psp-bs'><input ".esc_attr($diskey_checked)." id='psp_seo_meta[disable_keywords]' name='psp_seo_meta[disable_keywords]' type='checkbox' data-toggle='toggle' data-on='Off' data-onstyle='default' data-off='On' data-offstyle='success' data-style='ios' /></div><br />";
15
?><?php } ?></th>
16
<td><input type="text" name="psp_seo_meta[keywords]" id="psp_seo_meta[keywords]" value="<?php echo ( isset($psp_seo_meta['keywords']) ? esc_attr($psp_seo_meta['keywords']) : ''); ?>"><br />
17
+ <p class="description"><?php esc_html_e('Set comma separated keywords or entities for this post/page. These are used as the Focus or primary keywords for Platinum SEO Analysis of this page. If you intend using these in meta keywords tag, which is not supported by Google and many other Search Engines, you should turn it on sitewide in Platinum SEO General setthings. By default, these are used for your internal Post/Page analysis only.', 'platinum-seo-pack'); ?></p>
18
<p class="description"><strong><?php esc_html_e('Enter comma separated focus keywords in the input above and find the analysis below', 'platinum-seo-pack'); ?></strong></p>
19
<div class="psp-bs"><input style="width:20%;display:block;margin:auto" id="psp_analyse_btn" class="psp_analyser btn btn-primary" type="hidden" value="Analyse" /></div>
20
</td>
psp-include/settings/psp_basic_metabox_renderer.php CHANGED
@@ -96,6 +96,10 @@ label {
96
color: red !important;
97
}
98
99
#psp-meta-box .psp-metabox-tabs, #psp-preview-box .psp-preview-tabs {
100
background: #fff;
101
border-width: 0px 1px 1px 1px;
96
color: red !important;
97
}
98
99
+ .psp-info {
100
+ color: #3073AC !important;
101
+ }
102
+
103
#psp-meta-box .psp-metabox-tabs, #psp-preview-box .psp-preview-tabs {
104
background: #fff;
105
border-width: 0px 1px 1px 1px;
psp-include/settings/psp_settings.php CHANGED
@@ -379,6 +379,7 @@ class PspSettings {
379
'label_for' => 'psp_home_keywords',
380
'option_name' => $psp_home_settings_name.'[keywords]',
381
'option_value' => isset($psp_home_settings['keywords']) ? stripcslashes(esc_attr($psp_home_settings['keywords'])) : '',
382
);
383
384
$home_header_metas = isset($psp_home_settings['headers']) ? html_entity_decode(stripcslashes(esc_attr($psp_home_settings['headers']))) : '';
@@ -644,7 +645,8 @@ class PspSettings {
644
'label_for' => 'psp_'.$setting_name.'_autogenerate_description',
645
'option_name' => $psp_settings_name.'[autogenerate_description]',
646
'option_value' => isset($psp_settings['autogenerate_description']) ? $psp_settings['autogenerate_description'] : '',
647
- 'checkbox_label' => esc_html__( 'Autogenerate description for all post types, if no SEO description is set for any post.', 'platinum-seo-pack' )
648
);
649
650
$autogenerate_desc_field_id = 'psp_'.$setting_name.'_autogenerate_description';
@@ -670,7 +672,8 @@ class PspSettings {
670
'label_for' => 'psp_'.$setting_name.'_use_meta_keywords',
671
'option_name' => $psp_settings_name.'[use_meta_keywords]',
672
'option_value' => isset($psp_settings['use_meta_keywords']) ? $psp_settings['use_meta_keywords'] : '',
673
- 'checkbox_label' => esc_html__( 'Use meta keywords tag.', 'platinum-seo-pack' )
674
);
675
676
$use_meta_keywords_field_id = 'psp_'.$setting_name.'_use_meta_keywords';
@@ -2839,7 +2842,7 @@ class PspSettings {
2839
wp_enqueue_media();
2840
wp_enqueue_script( 'psp-meta-box', plugins_url( '/js/pspmetabox.js', __FILE__ ), array( 'jquery-ui-tabs') );
2841
//wp_enqueue_script( 'psp-image-uploader', plugins_url( '/js/pspmediauploader.js', __FILE__ ), array( 'jquery' ) );
2842
- wp_enqueue_script( 'psp-meta-box-snippet', plugins_url( '/js/snippetpreview.js', __FILE__ ),'', '2.1');
2843
//wp_enqueue_script( 'psp-social', plugins_url( '/js/pspsocialhandler.js', __FILE__ ), array( 'jquery' ) );
2844
//wp_enqueue_script( 'psp-cm', plugins_url( '/js/cm.js', __FILE__ ), array(), false, true);
2845
@@ -3085,7 +3088,7 @@ class PspSettings {
3085
//wp_enqueue_media();
3086
wp_enqueue_script( 'psp-meta-box', plugins_url( '/js/pspmetabox.js', __FILE__ ), array( 'jquery-ui-tabs') );
3087
//wp_enqueue_script( 'psp-image-uploader', plugins_url( '/js/pspmediauploader.js', __FILE__ ), array( 'jquery' ) );
3088
- wp_enqueue_script( 'psp-meta-box-snippet', plugins_url( '/js/snippetpreview.js', __FILE__ ), '', '2.1');
3089
//wp_enqueue_script( 'psp-social', plugins_url( '/js/pspsocialhandler.js', __FILE__ ), array( 'jquery' ) );
3090
3091
$psp_cm_json_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'json', 'codemirror'=> array('autoRefresh' => true)));
@@ -3327,7 +3330,7 @@ class PspSettings {
3327
//wp_enqueue_media();
3328
wp_enqueue_script( 'psp-meta-box', plugins_url( '/js/pspmetabox.js', __FILE__ ), array('jquery', 'jquery-ui-tabs' ) );
3329
//wp_enqueue_script( 'psp-image-uploader', plugins_url( '/js/pspmediauploader.js', __FILE__ ), array( 'jquery' ) );
3330
- wp_enqueue_script( 'psp-meta-box-snippet', plugins_url( '/js/snippetpreview.js', __FILE__ ), '', '2.1');
3331
//wp_enqueue_script( 'psp-social', plugins_url( '/js/pspsocialhandler.js', __FILE__ ), array( 'jquery' ) );
3332
3333
$psp_cm_json_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'json', 'codemirror'=> array('autoRefresh' => true)));
379
'label_for' => 'psp_home_keywords',
380
'option_name' => $psp_home_settings_name.'[keywords]',
381
'option_value' => isset($psp_home_settings['keywords']) ? stripcslashes(esc_attr($psp_home_settings['keywords'])) : '',
382
+ 'option_description' => esc_html__( 'Google and most other Search engines do not use or support the meta keywords tag. If you still find it necessary to use this tag for any specific reason of yours, you may add comma separated primary entities or keywords for the Home page here.These will be displayed as meta keywords tag. Leaving it empty will disable this tag for the Jome Page.', 'platinum-seo-pack' ),
383
);
384
385
$home_header_metas = isset($psp_home_settings['headers']) ? html_entity_decode(stripcslashes(esc_attr($psp_home_settings['headers']))) : '';
645
'label_for' => 'psp_'.$setting_name.'_autogenerate_description',
646
'option_name' => $psp_settings_name.'[autogenerate_description]',
647
'option_value' => isset($psp_settings['autogenerate_description']) ? $psp_settings['autogenerate_description'] : '',
648
+ 'checkbox_label' => esc_html__( 'Autogenerate description for all post types', 'platinum-seo-pack' ),
649
+ 'option_description' => esc_html__( 'If no SEO description is set for any post, an auto-generated description will be set against the meta description tag for the Post or Page. Post Excerpt, if it exists, will be used. If not, the first few words from the Post or Page will be used.', 'platinum-seo-pack' )
650
);
651
652
$autogenerate_desc_field_id = 'psp_'.$setting_name.'_autogenerate_description';
672
'label_for' => 'psp_'.$setting_name.'_use_meta_keywords',
673
'option_name' => $psp_settings_name.'[use_meta_keywords]',
674
'option_value' => isset($psp_settings['use_meta_keywords']) ? $psp_settings['use_meta_keywords'] : '',
675
+ 'checkbox_label' => esc_html__( 'Use meta keywords tag.', 'platinum-seo-pack' ),
676
+ 'option_description' => esc_html__( 'Note that Google and many other Search engines do not read/use this tag. If for any specific reason, you intend to display meta keywords tag on your site, you may enable this. Your focus or primary keywords will be shown against this tag on the respective Post or Page.', 'platinum-seo-pack' )
677
);
678
679
$use_meta_keywords_field_id = 'psp_'.$setting_name.'_use_meta_keywords';
2842
wp_enqueue_media();
2843
wp_enqueue_script( 'psp-meta-box', plugins_url( '/js/pspmetabox.js', __FILE__ ), array( 'jquery-ui-tabs') );
2844
//wp_enqueue_script( 'psp-image-uploader', plugins_url( '/js/pspmediauploader.js', __FILE__ ), array( 'jquery' ) );
2845
+ wp_enqueue_script( 'psp-meta-box-snippet', plugins_url( '/js/snippetpreview.js', __FILE__ ),'', '2.1.2');
2846
//wp_enqueue_script( 'psp-social', plugins_url( '/js/pspsocialhandler.js', __FILE__ ), array( 'jquery' ) );
2847
//wp_enqueue_script( 'psp-cm', plugins_url( '/js/cm.js', __FILE__ ), array(), false, true);
2848
3088
//wp_enqueue_media();
3089
wp_enqueue_script( 'psp-meta-box', plugins_url( '/js/pspmetabox.js', __FILE__ ), array( 'jquery-ui-tabs') );
3090
//wp_enqueue_script( 'psp-image-uploader', plugins_url( '/js/pspmediauploader.js', __FILE__ ), array( 'jquery' ) );
3091
+ wp_enqueue_script( 'psp-meta-box-snippet', plugins_url( '/js/snippetpreview.js', __FILE__ ), '', '2.1.2');
3092
//wp_enqueue_script( 'psp-social', plugins_url( '/js/pspsocialhandler.js', __FILE__ ), array( 'jquery' ) );
3093
3094
$psp_cm_json_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'json', 'codemirror'=> array('autoRefresh' => true)));
3330
//wp_enqueue_media();
3331
wp_enqueue_script( 'psp-meta-box', plugins_url( '/js/pspmetabox.js', __FILE__ ), array('jquery', 'jquery-ui-tabs' ) );
3332
//wp_enqueue_script( 'psp-image-uploader', plugins_url( '/js/pspmediauploader.js', __FILE__ ), array( 'jquery' ) );
3333
+ wp_enqueue_script( 'psp-meta-box-snippet', plugins_url( '/js/snippetpreview.js', __FILE__ ), '', '2.1.2');
3334
//wp_enqueue_script( 'psp-social', plugins_url( '/js/pspsocialhandler.js', __FILE__ ), array( 'jquery' ) );
3335
3336
$psp_cm_json_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'json', 'codemirror'=> array('autoRefresh' => true)));
psp-include/sitemap/inc/{class-core-sitemaps-index.php → class-wp-sitemaps-index.php} RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
/**
3
- * Sitemaps: Core_Sitemaps_Index class.
4
*
5
* Generates the sitemap index.
6
*
@@ -10,27 +10,27 @@
10
*/
11
12
/**
13
- * Class Core_Sitemaps_Index.
14
* Builds the sitemap index page that lists the links to all of the sitemaps.
15
*
16
* @since 5.5.0
17
*/
18
- class Core_Sitemaps_Index {
19
20
/**
21
* The main registry of supported sitemaps.
22
*
23
* @since 5.5.0
24
- * @var Core_Sitemaps_Registry
25
*/
26
protected $registry;
27
28
/**
29
- * Core_Sitemaps_Index constructor.
30
*
31
* @since 5.5.0
32
*
33
- * @param Core_Sitemaps_Registry $registry Sitemap provider registry.
34
*/
35
public function __construct( $registry ) {
36
$this->registry = $registry;
@@ -47,12 +47,17 @@ class Core_Sitemaps_Index {
47
$sitemaps = array();
48
49
$providers = $this->registry->get_sitemaps();
50
- /* @var Core_Sitemaps_Provider $provider */
51
foreach ( $providers as $provider ) {
52
// Using array_push is more efficient than array_merge in a loop.
53
- $sitemap = $provider->get_sitemap_entries();
54
- //array_push( $sitemaps, ...$provider->get_sitemap_entries() );
55
- if($sitemap) array_push( $sitemaps, ...$sitemap );
56
}
57
58
return $sitemaps;
@@ -63,14 +68,13 @@ class Core_Sitemaps_Index {
63
*
64
* @since 5.5.0
65
*
66
- * @return string the sitemap index url.
67
*/
68
public function get_index_url() {
69
/* @var WP_Rewrite $wp_rewrite */
70
global $wp_rewrite;
71
72
$url = home_url( '/wp-sitemap.xml' );
73
- //$url = home_url( '/sitemap.xml' );
74
75
if ( ! $wp_rewrite->using_permalinks() ) {
76
$url = add_query_arg( 'sitemap', 'index', home_url( '/' ) );
1
<?php
2
/**
3
+ * Sitemaps: WP_Sitemaps_Index class.
4
*
5
* Generates the sitemap index.
6
*
10
*/
11
12
/**
13
+ * Class WP_Sitemaps_Index.
14
* Builds the sitemap index page that lists the links to all of the sitemaps.
15
*
16
* @since 5.5.0
17
*/
18
+ class WP_Sitemaps_Index {
19
20
/**
21
* The main registry of supported sitemaps.
22
*
23
* @since 5.5.0
24
+ * @var WP_Sitemaps_Registry
25
*/
26
protected $registry;
27
28
/**
29
+ * WP_Sitemaps_Index constructor.
30
*
31
* @since 5.5.0
32
*
33
+ * @param WP_Sitemaps_Registry $registry Sitemap provider registry.
34
*/
35
public function __construct( $registry ) {
36
$this->registry = $registry;
47
$sitemaps = array();
48
49
$providers = $this->registry->get_sitemaps();
50
+ /* @var WP_Sitemaps_Provider $provider */
51
foreach ( $providers as $provider ) {
52
+ $sitemap_entries = $provider->get_sitemap_entries();
53
+
54
+ // Prevent issues with array_push and empty arrays on PHP < 7.3.
55
+ if ( ! $sitemap_entries ) {
56
+ continue;
57
+ }
58
+
59
// Using array_push is more efficient than array_merge in a loop.
60
+ array_push( $sitemaps, ...$sitemap_entries );
61
}
62
63
return $sitemaps;
68
*
69
* @since 5.5.0
70
*
71
+ * @return string The sitemap index url.
72
*/
73
public function get_index_url() {
74
/* @var WP_Rewrite $wp_rewrite */
75
global $wp_rewrite;
76
77
$url = home_url( '/wp-sitemap.xml' );
78
79
if ( ! $wp_rewrite->using_permalinks() ) {
80
$url = add_query_arg( 'sitemap', 'index', home_url( '/' ) );
psp-include/sitemap/inc/{class-core-sitemaps-provider.php → class-wp-sitemaps-provider.php} RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
/**
3
- * Sitemaps: Core_Sitemaps_Provider class
4
*
5
* This class is a base class for other sitemap providers to extend and contains shared functionality.
6
*
@@ -10,11 +10,11 @@
10
*/
11
12
/**
13
- * Class Core_Sitemaps_Provider.
14
*
15
* @since 5.5.0
16
*/
17
- abstract class Core_Sitemaps_Provider {
18
19
/**
20
* Provider name.
@@ -36,18 +36,6 @@ abstract class Core_Sitemaps_Provider {
36
*/
37
protected $object_type = '';
38
39
- /**
40
- * Object subtype name.
41
- *
42
- * For example, this should be a post type name for object type 'post' or
43
- * a taxonomy name for object type 'term').
44
- *
45
- * @since 5.5.0
46
- *
47
- * @var string
48
- */
49
- protected $object_subtype = '';
50
-
51
/**
52
* Gets a URL list for a sitemap.
53
*
@@ -55,25 +43,10 @@ abstract class Core_Sitemaps_Provider {
55
*
56
* @param int $page_num Page of results.
57
* @param string $object_subtype Optional. Object subtype name. Default empty.
58
- * @return array List of URLs for a sitemap.
59
*/
60
abstract public function get_url_list( $page_num, $object_subtype = '' );
61
62
- /**
63
- * Returns the name of the object type or object subtype being queried.
64
- *
65
- * @since 5.5.0
66
- *
67
- * @return string Object subtype if set, otherwise object type.
68
- */
69
- public function get_queried_type() {
70
- if ( empty( $this->object_subtype ) ) {
71
- return $this->object_type;
72
- }
73
-
74
- return $this->object_subtype;
75
- }
76
-
77
/**
78
* Gets the max number of pages available for the object type.
79
*
@@ -82,21 +55,7 @@ abstract class Core_Sitemaps_Provider {
82
* @param string $object_subtype Optional. Object subtype. Default empty.
83
* @return int Total number of pages.
84
*/
85
- abstract public function max_num_pages( $object_subtype = '' );
86
-
87
- /**
88
- * Sets the object subtype.
89
- *
90
- * @since 5.5.0
91
- *
92
- * @param string $object_subtype The name of the object subtype.
93
- * @return bool Returns true on success.
94
- */
95
- public function set_object_subtype( $object_subtype ) {
96
- $this->object_subtype = $object_subtype;
97
-
98
- return true;
99
- }
100
101
/**
102
* Gets data about each sitemap type.
@@ -110,10 +69,23 @@ abstract class Core_Sitemaps_Provider {
110
111
$object_subtypes = $this->get_object_subtypes();
112
113
foreach ( $object_subtypes as $object_subtype_name => $data ) {
114
$sitemap_data[] = array(
115
- 'name' => $object_subtype_name,
116
- 'pages' => $this->max_num_pages( $object_subtype_name ),
117
);
118
}
119
@@ -190,30 +162,26 @@ abstract class Core_Sitemaps_Provider {
190
191
return home_url( $basename );
192
}
193
194
/**
195
- * Returns the list of supported object sub-types exposed by the provider.
196
*
197
* @since 5.5.0
198
*
199
* @return array List of object subtypes objects keyed by their name.
200
*/
201
public function get_object_subtypes() {
202
- if ( ! empty( $this->object_subtype ) ) {
203
- return array(
204
- $this->object_subtype => (object) array( 'name' => $this->object_subtype ),
205
- );
206
- }
207
-
208
- /**
209
- * To prevent complexity in code calling this function, such as `get_sitemap_type_data()`
210
- * in this class, a non-empty array is returned, so that sitemaps for providers without
211
- * object subtypes are still registered correctly.
212
- *
213
- * @link https://github.com/GoogleChromeLabs/wp-sitemaps/pull/72#discussion_r347496750
214
- */
215
- return array(
216
- '' => (object) array( 'name' => '' ),
217
- );
218
}
219
}
1
<?php
2
/**
3
+ * Sitemaps: WP_Sitemaps_Provider class
4
*
5
* This class is a base class for other sitemap providers to extend and contains shared functionality.
6
*
10
*/
11
12
/**
13
+ * Class WP_Sitemaps_Provider.
14
*
15
* @since 5.5.0
16
*/
17
+ abstract class WP_Sitemaps_Provider {
18
19
/**
20
* Provider name.
36
*/
37
protected $object_type = '';
38
39
/**
40
* Gets a URL list for a sitemap.
41
*
43
*
44
* @param int $page_num Page of results.
45
* @param string $object_subtype Optional. Object subtype name. Default empty.
46
+ * @return array $url_list Array of URLs for a sitemap.
47
*/
48
abstract public function get_url_list( $page_num, $object_subtype = '' );
49
50
/**
51
* Gets the max number of pages available for the object type.
52
*
55
* @param string $object_subtype Optional. Object subtype. Default empty.
56
* @return int Total number of pages.
57
*/
58
+ abstract public function get_max_num_pages( $object_subtype = '' );
59
60
/**
61
* Gets data about each sitemap type.
69
70
$object_subtypes = $this->get_object_subtypes();
71
72
+ // If there are no object subtypes, include a single sitemap for the
73
+ // entire object type.
74
+ if ( empty( $object_subtypes ) ) {
75
+ $sitemap_data[] = array(
76
+ 'name' => '',
77
+ 'pages' => $this->get_max_num_pages(),
78
+ );
79
+ return $sitemap_data;
80
+ }
81
+
82
+ // Otherwise, include individual sitemaps for every object subtype.
83
foreach ( $object_subtypes as $object_subtype_name => $data ) {
84
+ $object_subtype_name = (string) $object_subtype_name;
85
+
86
$sitemap_data[] = array(
87
+ 'name' => $object_subtype_name,
88
+ 'pages' => $this->get_max_num_pages( $object_subtype_name ),
89
);
90
}
91
162
163
return home_url( $basename );
164
}
165
+
166
+ /**
167
+ * Returns the object type of the provider.
168
+ *
169
+ * @since 5.5.0
170
+ *
171
+ * @return string The object type of the provider.
172
+ */
173
+ public function get_object_type() {
174
+ return $this->object_type;
175
+ }
176
177
/**
178
+ * Returns the list of supported object subtypes exposed by the provider.
179
*
180
* @since 5.5.0
181
*
182
* @return array List of object subtypes objects keyed by their name.
183
*/
184
public function get_object_subtypes() {
185
+ return array();
186
}
187
}
psp-include/sitemap/inc/{class-core-sitemaps-registry.php → class-wp-sitemaps-registry.php} RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
/**
3
- * Sitemaps: Core_Sitemaps_Registry class
4
*
5
* Handles registering sitemaps.
6
*
@@ -10,11 +10,11 @@
10
*/
11
12
/**
13
- * Class Core_Sitemaps_Registry.
14
*
15
* @since 5.5.0
16
*/
17
- class Core_Sitemaps_Registry {
18
/**
19
* Registered sitemaps.
20
*
@@ -29,8 +29,8 @@ class Core_Sitemaps_Registry {
29
*
30
* @since 5.5.0
31
*
32
- * @param string $name Name of the sitemap.
33
- * @param Core_Sitemaps_Provider $provider Instance of a Core_Sitemaps_Provider.
34
* @return bool True if the sitemap was added, false if it is already registered.
35
*/
36
public function add_sitemap( $name, $provider ) {
@@ -38,7 +38,7 @@ class Core_Sitemaps_Registry {
38
return false;
39
}
40
41
- if ( ! $provider instanceof Core_Sitemaps_Provider ) {
42
return false;
43
}
44
@@ -53,7 +53,7 @@ class Core_Sitemaps_Registry {
53
* @since 5.5.0
54
*
55
* @param string $name Sitemap provider name.
56
- * @return Core_Sitemaps_Provider|null Sitemaps provider if it exists, null otherwise.
57
*/
58
public function get_sitemap( $name ) {
59
if ( ! isset( $this->sitemaps[ $name ] ) ) {
@@ -73,8 +73,8 @@ class Core_Sitemaps_Registry {
73
public function get_sitemaps() {
74
$total_sitemaps = count( $this->sitemaps );
75
76
- if ( $total_sitemaps > CORE_SITEMAPS_MAX_SITEMAPS ) {
77
- return array_slice( $this->sitemaps, 0, CORE_SITEMAPS_MAX_SITEMAPS, true );
78
}
79
80
return $this->sitemaps;
1
<?php
2
/**
3
+ * Sitemaps: WP_Sitemaps_Registry class
4
*
5
* Handles registering sitemaps.
6
*
10
*/
11
12
/**
13
+ * Class WP_Sitemaps_Registry.
14
*
15
* @since 5.5.0
16
*/
17
+ class WP_Sitemaps_Registry {
18
/**
19
* Registered sitemaps.
20
*
29
*
30
* @since 5.5.0
31
*
32
+ * @param string $name Name of the sitemap.
33
+ * @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider.
34
* @return bool True if the sitemap was added, false if it is already registered.
35
*/
36
public function add_sitemap( $name, $provider ) {
38
return false;
39
}
40
41
+ if ( ! $provider instanceof WP_Sitemaps_Provider ) {
42
return false;
43
}
44
53
* @since 5.5.0
54
*
55
* @param string $name Sitemap provider name.
56
+ * @return WP_Sitemaps_Provider|null Sitemaps provider if it exists, null otherwise.
57
*/
58
public function get_sitemap( $name ) {
59
if ( ! isset( $this->sitemaps[ $name ] ) ) {
73
public function get_sitemaps() {
74
$total_sitemaps = count( $this->sitemaps );
75
76
+ if ( $total_sitemaps > WP_SITEMAPS_MAX_SITEMAPS ) {
77
+ return array_slice( $this->sitemaps, 0, WP_SITEMAPS_MAX_SITEMAPS, true );
78
}
79
80
return $this->sitemaps;
psp-include/sitemap/inc/{class-core-sitemaps-renderer.php → class-wp-sitemaps-renderer.php} RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
/**
3
- * Sitemaps: Core_Sitemaps_Renderer class
4
*
5
* Responsible for rendering Sitemaps data to XML in accordance with sitemap protocol.
6
*
@@ -10,11 +10,11 @@
10
*/
11
12
/**
13
- * Class Core_Sitemaps_Renderer
14
*
15
* @since 5.5.0
16
*/
17
- class Core_Sitemaps_Renderer {
18
/**
19
* XSL stylesheet for styling a sitemap for web browsers.
20
*
@@ -34,7 +34,7 @@ class Core_Sitemaps_Renderer {
34
protected $stylesheet_index = '';
35
36
/**
37
- * Core_Sitemaps_Renderer constructor.
38
*
39
* @since 5.5.0
40
*/
@@ -54,7 +54,7 @@ class Core_Sitemaps_Renderer {
54
*
55
* @since 5.5.0
56
*
57
- * @return string the sitemap stylesheet url.
58
*/
59
public function get_sitemap_stylesheet_url() {
60
/* @var WP_Rewrite $wp_rewrite */
@@ -76,7 +76,7 @@ class Core_Sitemaps_Renderer {
76
*
77
* @param string $sitemap_url Full URL for the sitemaps xsl file.
78
*/
79
- return apply_filters( 'core_sitemaps_stylesheet_url', $sitemap_url );
80
}
81
82
/**
@@ -84,7 +84,7 @@ class Core_Sitemaps_Renderer {
84
*
85
* @since 5.5.0
86
*
87
- * @return string the sitemap index stylesheet url.
88
*/
89
public function get_sitemap_index_stylesheet_url() {
90
/* @var WP_Rewrite $wp_rewrite */
@@ -106,7 +106,7 @@ class Core_Sitemaps_Renderer {
106
*
107
* @param string $sitemap_url Full URL for the sitemaps index xsl file.
108
*/
109
- return apply_filters( 'core_sitemaps_stylesheet_index_url', $sitemap_url );
110
}
111
112
/**
@@ -114,7 +114,7 @@ class Core_Sitemaps_Renderer {
114
*
115
* @since 5.5.0
116
*
117
- * @param array $sitemaps List of sitemap entries.
118
*/
119
public function render_index( $sitemaps ) {
120
header( 'Content-type: application/xml; charset=UTF-8' );
@@ -135,7 +135,7 @@ class Core_Sitemaps_Renderer {
135
*
136
* @since 5.5.0
137
*
138
- * @param array $sitemaps List of sitemap entries.
139
* @return string|false A well-formed XML string for a sitemap index. False on error.
140
*/
141
public function get_sitemap_index_xml( $sitemaps ) {
@@ -163,12 +163,12 @@ class Core_Sitemaps_Renderer {
163
*
164
* @param array $url_list A list of URLs for a sitemap.
165
*/
166
- public function render_sitemap( $url_list, $object_subtype ) {
167
header( 'Content-type: application/xml; charset=UTF-8' );
168
169
$this->check_for_simple_xml_availability();
170
171
- $sitemap_xml = apply_filters( "core_sitemaps_get_sitemap_xml", $url_list, $object_subtype );
172
173
if ( empty( $sitemap_xml ) ) {
174
@@ -193,7 +193,7 @@ class Core_Sitemaps_Renderer {
193
*
194
* @since 5.5.0
195
*
196
- * @param array $url_list A list of URLs for a sitemap.
197
* @return string|false A well-formed XML string for a sitemap index. False on error.
198
*/
199
public function get_sitemap_xml( $url_list ) {
@@ -202,8 +202,7 @@ class Core_Sitemaps_Renderer {
202
'%1$s%2$s%3$s',
203
'<?xml version="1.0" encoding="UTF-8" ?>',
204
$this->stylesheet,
205
- //'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
206
- '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
207
)
208
);
209
@@ -214,15 +213,6 @@ class Core_Sitemaps_Renderer {
214
foreach ( $url_item as $attr => $value ) {
215
if ( 'url' === $attr ) {
216
$url->addChild( $attr, esc_url( $value ) );
217
- } else if ('image' === $attr) {
218
- //$image = $url->addChild('image:image');
219
- //$image = $url->addChild('image:image', null, 'http://www.google.com/schemas/sitemap-image/1.1');
220
- foreach ($value as $imageattr) {
221
- $image = $url->addChild('image:image', null, 'http://www.google.com/schemas/sitemap-image/1.1');
222
- if(array_key_exists("loc", $imageattr)) $image->addChild('image:loc',esc_url( $imageattr['loc'] ), 'http://www.google.com/schemas/sitemap-image/1.1');
223
- if(array_key_exists("title", $imageattr)) $image->addChild('image:title',esc_attr( $imageattr['title'] ), 'http://www.google.com/schemas/sitemap-image/1.1');
224
- if(array_key_exists("caption", $imageattr)) $image->addChild('image:caption',esc_attr( $imageattr['caption'] ), 'http://www.google.com/schemas/sitemap-image/1.1');
225
- }
226
} else {
227
$url->addChild( $attr, esc_attr( $value ) );
228
}
1
<?php
2
/**
3
+ * Sitemaps: WP_Sitemaps_Renderer class
4
*
5
* Responsible for rendering Sitemaps data to XML in accordance with sitemap protocol.
6
*
10
*/
11
12
/**
13
+ * Class WP_Sitemaps_Renderer
14
*
15
* @since 5.5.0
16
*/
17
+ class WP_Sitemaps_Renderer {
18
/**
19
* XSL stylesheet for styling a sitemap for web browsers.
20
*
34
protected $stylesheet_index = '';
35
36
/**
37
+ * WP_Sitemaps_Renderer constructor.
38
*
39
* @since 5.5.0
40
*/
54
*
55
* @since 5.5.0
56
*
57
+ * @return string The sitemap stylesheet url.
58
*/
59
public function get_sitemap_stylesheet_url() {
60
/* @var WP_Rewrite $wp_rewrite */
76
*
77
* @param string $sitemap_url Full URL for the sitemaps xsl file.
78
*/
79
+ return apply_filters( 'wp_sitemaps_stylesheet_url', $sitemap_url );
80
}
81
82
/**
84
*
85
* @since 5.5.0
86
*
87
+ * @return string The sitemap index stylesheet url.
88
*/
89
public function get_sitemap_index_stylesheet_url() {
90
/* @var WP_Rewrite $wp_rewrite */
106
*
107
* @param string $sitemap_url Full URL for the sitemaps index xsl file.
108
*/
109
+ return apply_filters( 'wp_sitemaps_stylesheet_index_url', $sitemap_url );
110
}
111
112
/**
114
*
115
* @since 5.5.0
116
*
117
+ * @param array $sitemaps Array of sitemap URLs.
118
*/
119
public function render_index( $sitemaps ) {
120
header( 'Content-type: application/xml; charset=UTF-8' );
135
*
136
* @since 5.5.0
137
*
138
+ * @param array $sitemaps Array of sitemap URLs.
139
* @return string|false A well-formed XML string for a sitemap index. False on error.
140
*/
141
public function get_sitemap_index_xml( $sitemaps ) {
163
*
164
* @param array $url_list A list of URLs for a sitemap.
165
*/
166
+ public function render_sitemap( $url_list, $object_type, $object_subtype ) {
167
header( 'Content-type: application/xml; charset=UTF-8' );
168
169
$this->check_for_simple_xml_availability();
170
171
+ $sitemap_xml = apply_filters( "wp_sitemaps_get_sitemap_xml", $url_list, $object_type, $object_subtype );
172
173
if ( empty( $sitemap_xml ) ) {
174
193
*
194
* @since 5.5.0
195
*
196
+ * @param array $url_list Array of URLs for a sitemap.
197
* @return string|false A well-formed XML string for a sitemap index. False on error.
198
*/
199
public function get_sitemap_xml( $url_list ) {
202
'%1$s%2$s%3$s',
203
'<?xml version="1.0" encoding="UTF-8" ?>',
204
$this->stylesheet,
205
+ '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
206
)
207
);
208
213
foreach ( $url_item as $attr => $value ) {
214
if ( 'url' === $attr ) {
215
$url->addChild( $attr, esc_url( $value ) );
216
} else {
217
$url->addChild( $attr, esc_attr( $value ) );
218
}
psp-include/sitemap/inc/{class-core-sitemaps-stylesheet.php → class-wp-sitemaps-stylesheet.php} RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
/**
3
- * Sitemaps: Core_Sitemaps_Stylesheet class
4
*
5
* This class provides the XSL stylesheets to style all sitemaps.
6
*
@@ -14,7 +14,7 @@
14
*
15
* @since 5.5.0
16
*/
17
- class Core_Sitemaps_Stylesheet {
18
/**
19
* Renders the xsl stylesheet depending on whether its the sitemap index or not.
20
*
@@ -117,7 +117,7 @@ XSL;
117
*
118
* @param string $xsl Full content for the xml stylesheet.
119
*/
120
- return apply_filters( 'core_sitemaps_stylesheet_content', $xsl_content );
121
}
122
123
/**
@@ -201,7 +201,7 @@ XSL;
201
*
202
* @param string $xsl Full content for the xml stylesheet.
203
*/
204
- return apply_filters( 'core_sitemaps_index_stylesheet_content', $xsl_content );
205
}
206
207
/**
@@ -247,6 +247,6 @@ XSL;
247
*
248
* @param string $css CSS to be applied to default xsl file.
249
*/
250
- return apply_filters( 'core_sitemaps_stylesheet_css', $css );
251
}
252
}
1
<?php
2
/**
3
+ * Sitemaps: WP_Sitemaps_Stylesheet class
4
*
5
* This class provides the XSL stylesheets to style all sitemaps.
6
*
14
*
15
* @since 5.5.0
16
*/
17
+ class WP_Sitemaps_Stylesheet {
18
/**
19
* Renders the xsl stylesheet depending on whether its the sitemap index or not.
20
*
117
*
118
* @param string $xsl Full content for the xml stylesheet.
119
*/
120
+ return apply_filters( 'wp_sitemaps_stylesheet_content', $xsl_content );
121
}
122
123
/**
201
*
202
* @param string $xsl Full content for the xml stylesheet.
203
*/
204
+ return apply_filters( 'wp_sitemaps_index_stylesheet_content', $xsl_content );
205
}
206
207
/**
247
*
248
* @param string $css CSS to be applied to default xsl file.
249
*/
250
+ return apply_filters( 'wp_sitemaps_stylesheet_css', $css );
251
}
252
}
psp-include/sitemap/inc/{class-core-sitemaps.php → class-wp-sitemaps.php} RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
/**
3
- * Sitemaps: Core_Sitemaps class
4
*
5
* This is the main class integrating all other classes.
6
*
@@ -10,17 +10,17 @@
10
*/
11
12
/**
13
- * Class Core_Sitemaps.
14
*
15
* @since 5.5.0
16
*/
17
- class Core_Sitemaps {
18
/**
19
* The main index of supported sitemaps.
20
*
21
* @since 5.5.0
22
*
23
- * @var Core_Sitemaps_Index
24
*/
25
public $index;
26
@@ -29,7 +29,7 @@ class Core_Sitemaps {
29
*
30
* @since 5.5.0
31
*
32
- * @var Core_Sitemaps_Registry
33
*/
34
public $registry;
35
@@ -38,19 +38,19 @@ class Core_Sitemaps {
38
*
39
* @since 5.5.0
40
*
41
- * @var Core_Sitemaps_Renderer
42
*/
43
public $renderer;
44
45
/**
46
- * Core_Sitemaps constructor.
47
*
48
* @since 5.5.0
49
*/
50
public function __construct() {
51
- $this->registry = new Core_Sitemaps_Registry();
52
- $this->renderer = new Core_Sitemaps_Renderer();
53
- $this->index = new Core_Sitemaps_Index( $this->registry );
54
}
55
56
/**
@@ -63,7 +63,7 @@ class Core_Sitemaps {
63
$this->register_sitemaps();
64
65
// Add additional action callbacks.
66
- add_action( 'core_sitemaps_init', array( $this, 'register_rewrites' ) );
67
add_action( 'template_redirect', array( $this, 'render_sitemaps' ) );
68
add_action( 'wp_loaded', array( $this, 'maybe_flush_rewrites' ) );
69
add_filter( 'pre_handle_404', array( $this, 'redirect_sitemapxml' ), 10, 2 );
@@ -82,19 +82,25 @@ class Core_Sitemaps {
82
*
83
* @since 5.5.0
84
*
85
- * @param array $providers Array of Core_Sitemap_Provider objects keyed by their name.
86
*/
87
$providers = apply_filters(
88
- 'core_sitemaps_register_providers',
89
array(
90
- 'posts' => new Core_Sitemaps_Posts(),
91
- 'taxonomies' => new Core_Sitemaps_Taxonomies(),
92
- 'users' => new Core_Sitemaps_Users(),
93
)
94
);
95
96
// Register each supported provider.
97
- /* @var Core_Sitemaps_Provider $provider */
98
foreach ( $providers as $name => $provider ) {
99
$this->registry->add_sitemap( $name, $provider );
100
}
@@ -158,7 +164,7 @@ class Core_Sitemaps {
158
* @since 5.5.0
159
*/
160
public function maybe_flush_rewrites() {
161
- if ( update_option( 'core_sitemaps_rewrite_version', CORE_SITEMAPS_REWRITE_VERSION ) ) {
162
flush_rewrite_rules( false );
163
}
164
}
@@ -183,7 +189,7 @@ class Core_Sitemaps {
183
184
// Render stylesheet if this is stylesheet route.
185
if ( $stylesheet_type ) {
186
- $stylesheet = new Core_Sitemaps_Stylesheet();
187
188
$stylesheet->render_stylesheet( $stylesheet_type );
189
exit;
@@ -207,14 +213,8 @@ class Core_Sitemaps {
207
$paged = 1;
208
}
209
210
- $object_subtypes = $provider->get_object_subtypes();
211
-
212
- // Only set the current object sub-type if it's supported.
213
- if ( isset( $object_subtypes[ $object_subtype ] ) ) {
214
- $provider->set_object_subtype( $object_subtype );
215
- }
216
-
217
$url_list = $provider->get_url_list( $paged, $object_subtype );
218
219
// Force a 404 and bail early if no URLs are present.
220
if ( empty( $url_list ) ) {
@@ -222,7 +222,7 @@ class Core_Sitemaps {
222
return;
223
}
224
225
- $this->renderer->render_sitemap( $url_list, $object_subtype );
226
exit;
227
}
228
@@ -233,8 +233,7 @@ class Core_Sitemaps {
233
*
234
* @param bool $bypass Pass-through of the pre_handle_404 filter value.
235
* @param WP_Query $query The WP_Query object.
236
- *
237
- * @return bool bypass value.
238
*/
239
public function redirect_sitemapxml( $bypass, $query ) {
240
// If a plugin has already utilized the pre_handle_404 function, return without action to avoid conflicts.
@@ -259,7 +258,7 @@ class Core_Sitemaps {
259
*
260
* @param string $output robots.txt output.
261
* @param bool $public Whether the site is public or not.
262
- * @return string robots.txt output.
263
*/
264
public function add_robots( $output, $public ) {
265
if ( $public ) {
@@ -275,7 +274,7 @@ class Core_Sitemaps {
275
* @since 5.5.0
276
*
277
* @param string $redirect The redirect URL currently determined.
278
- * @return bool|string $redirect
279
*/
280
public function redirect_canonical( $redirect ) {
281
if ( get_query_var( 'sitemap' ) || get_query_var( 'sitemap-stylesheet' ) ) {
1
<?php
2
/**
3
+ * Sitemaps: WP_Sitemaps class
4
*
5
* This is the main class integrating all other classes.
6
*
10
*/
11
12
/**
13
+ * Class WP_Sitemaps.
14
*
15
* @since 5.5.0
16
*/
17
+ class WP_Sitemaps {
18
/**
19
* The main index of supported sitemaps.
20
*
21
* @since 5.5.0
22
*
23
+ * @var WP_Sitemaps_Index
24
*/
25
public $index;
26
29
*
30
* @since 5.5.0
31
*
32
+ * @var WP_Sitemaps_Registry
33
*/
34
public $registry;
35
38
*
39
* @since 5.5.0
40
*
41
+ * @var WP_Sitemaps_Renderer
42
*/
43
public $renderer;
44
45
/**
46
+ * WP_Sitemaps constructor.
47
*
48
* @since 5.5.0
49
*/
50
public function __construct() {
51
+ $this->registry = new WP_Sitemaps_Registry();
52
+ $this->renderer = new WP_Sitemaps_Renderer();
53
+ $this->index = new WP_Sitemaps_Index( $this->registry );
54
}
55
56
/**
63
$this->register_sitemaps();
64
65
// Add additional action callbacks.
66
+ add_action( 'wp_sitemaps_init', array( $this, 'register_rewrites' ) );
67
add_action( 'template_redirect', array( $this, 'render_sitemaps' ) );
68
add_action( 'wp_loaded', array( $this, 'maybe_flush_rewrites' ) );
69
add_filter( 'pre_handle_404', array( $this, 'redirect_sitemapxml' ), 10, 2 );
82
*
83
* @since 5.5.0
84
*
85
+ * @param array $providers {
86
+ * Array of WP_Sitemap_Provider objects keyed by their name.
87
+ *
88
+ * @type object $posts The WP_Sitemaps_Posts object.
89
+ * @type object $taxonomies The WP_Sitemaps_Taxonomies object.
90
+ * @type object $users The WP_Sitemaps_Users object.
91
+ * }
92
*/
93
$providers = apply_filters(
94
+ 'wp_sitemaps_register_providers',
95
array(
96
+ 'posts' => new WP_Sitemaps_Posts(),
97
+ 'taxonomies' => new WP_Sitemaps_Taxonomies(),
98
+ 'users' => new WP_Sitemaps_Users(),
99
)
100
);
101
102
// Register each supported provider.
103
+ /* @var WP_Sitemaps_Provider $provider */
104
foreach ( $providers as $name => $provider ) {
105
$this->registry->add_sitemap( $name, $provider );
106
}
164
* @since 5.5.0
165
*/
166
public function maybe_flush_rewrites() {
167
+ if ( update_option( 'wp_sitemaps_rewrite_version', WP_SITEMAPS_REWRITE_VERSION ) ) {
168
flush_rewrite_rules( false );
169
}
170
}
189
190
// Render stylesheet if this is stylesheet route.
191
if ( $stylesheet_type ) {
192
+ $stylesheet = new WP_Sitemaps_Stylesheet();
193
194
$stylesheet->render_stylesheet( $stylesheet_type );
195
exit;
213
$paged = 1;
214
}
215
216
$url_list = $provider->get_url_list( $paged, $object_subtype );
217
+ $object_type = $provider->get_object_type();
218
219
// Force a 404 and bail early if no URLs are present.
220
if ( empty( $url_list ) ) {
222
return;
223
}
224
225
+ $this->renderer->render_sitemap( $url_list, $object_type, $object_subtype );
226
exit;
227
}
228
233
*
234
* @param bool $bypass Pass-through of the pre_handle_404 filter value.
235
* @param WP_Query $query The WP_Query object.
236
+ * @return bool Bypass value.
237
*/
238
public function redirect_sitemapxml( $bypass, $query ) {
239
// If a plugin has already utilized the pre_handle_404 function, return without action to avoid conflicts.
258
*
259
* @param string $output robots.txt output.
260
* @param bool $public Whether the site is public or not.
261
+ * @return string The robots.txt output.
262
*/
263
public function add_robots( $output, $public ) {
264
if ( $public ) {
274
* @since 5.5.0
275
*
276
* @param string $redirect The redirect URL currently determined.
277
+ * @return bool|string $redirect The canonical redirect URL.
278
*/
279
public function redirect_canonical( $redirect ) {
280
if ( get_query_var( 'sitemap' ) || get_query_var( 'sitemap-stylesheet' ) ) {
psp-include/sitemap/inc/functions.php CHANGED
@@ -15,17 +15,17 @@
15
*
16
* @since 5.5.0
17
*
18
- * @return Core_Sitemaps|null Core_Sitemaps instance, or null of sitemaps are disabled.
19
*/
20
- function core_sitemaps_get_server() {
21
/**
22
* Global Core Sitemaps instance.
23
*
24
* @since 5.5.0
25
*
26
- * @var Core_Sitemaps $core_sitemaps
27
*/
28
- global $core_sitemaps;
29
30
$is_enabled = (bool) get_option( 'blog_public' );
31
@@ -36,30 +36,30 @@ function core_sitemaps_get_server() {
36
*
37
* @param bool $is_enabled Whether XML Sitemaps are enabled or not. Defaults to true for public sites.
38
*/
39
- $is_enabled = (bool) apply_filters( 'core_sitemaps_is_enabled', $is_enabled );
40
41
if ( ! $is_enabled ) {
42
return null;
43
}
44
45
// If there isn't a global instance, set and bootstrap the sitemaps system.
46
- if ( empty( $core_sitemaps ) ) {
47
- $core_sitemaps = new Core_Sitemaps();
48
- $core_sitemaps->init();
49
50
/**
51
- * Fires when initializing the Core_Sitemaps object.
52
*
53
* Additional sitemaps should be registered on this hook.
54
*
55
* @since 5.5.0
56
*
57
- * @param core_sitemaps $core_sitemaps Server object.
58
*/
59
- do_action( 'core_sitemaps_init', $core_sitemaps );
60
}
61
62
- return $core_sitemaps;
63
}
64
65
/**
@@ -69,14 +69,14 @@ function core_sitemaps_get_server() {
69
*
70
* @return array $sitemaps A list of registered sitemap providers.
71
*/
72
- function core_sitemaps_get_sitemaps() {
73
- $core_sitemaps = core_sitemaps_get_server();
74
75
- if ( ! $core_sitemaps ) {
76
return array();
77
}
78
79
- return $core_sitemaps->registry->get_sitemaps();
80
}
81
82
/**
@@ -84,18 +84,18 @@ function core_sitemaps_get_sitemaps() {
84
*
85
* @since 5.5.0
86
*
87
- * @param string $name Unique name for the sitemap provider.
88
- * @param Core_Sitemaps_Provider $provider The `Core_Sitemaps_Provider` instance implementing the sitemap.
89
* @return bool Returns true if the sitemap was added. False on failure.
90
*/
91
- function core_sitemaps_register_sitemap( $name, $provider ) {
92
- $core_sitemaps = core_sitemaps_get_server();
93
94
- if ( ! $core_sitemaps ) {
95
return false;
96
}
97
98
- return $core_sitemaps->registry->add_sitemap( $name, $provider );
99
}
100
101
/**
@@ -106,7 +106,7 @@ function core_sitemaps_register_sitemap( $name, $provider ) {
106
* @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user').
107
* @return int The maximum number of URLs.
108
*/
109
- function core_sitemaps_get_max_urls( $object_type ) {
110
/**
111
* Filters the maximum number of URLs displayed on a sitemap.
112
*
@@ -115,5 +115,5 @@ function core_sitemaps_get_max_urls( $object_type ) {
115
* @param int $max_urls The maximum number of URLs included in a sitemap. Default 2000.
116
* @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user').
117
*/
118
- return apply_filters( 'core_sitemaps_max_urls', CORE_SITEMAPS_MAX_URLS, $object_type );
119
}
15
*
16
* @since 5.5.0
17
*
18
+ * @return WP_Sitemaps|null Sitemaps instance, or null if sitemaps are disabled.
19
*/
20
+ function wp_sitemaps_get_server() {
21
/**
22
* Global Core Sitemaps instance.
23
*
24
* @since 5.5.0
25
*
26
+ * @var WP_Sitemaps $wp_sitemaps
27
*/
28
+ global $wp_sitemaps;
29
30
$is_enabled = (bool) get_option( 'blog_public' );
31
36
*
37
* @param bool $is_enabled Whether XML Sitemaps are enabled or not. Defaults to true for public sites.
38
*/
39
+ $is_enabled = (bool) apply_filters( 'wp_sitemaps_is_enabled', $is_enabled );
40
41
if ( ! $is_enabled ) {
42
return null;
43
}
44
45
// If there isn't a global instance, set and bootstrap the sitemaps system.
46
+ if ( empty( $wp_sitemaps ) ) {
47
+ $wp_sitemaps = new WP_Sitemaps();
48
+ $wp_sitemaps->init();
49
50
/**
51
+ * Fires when initializing the Sitemaps object.
52
*
53
* Additional sitemaps should be registered on this hook.
54
*
55
* @since 5.5.0
56
*
57
+ * @param WP_Sitemaps $sitemaps Server object.
58
*/
59
+ do_action( 'wp_sitemaps_init', $wp_sitemaps );
60
}
61
62
+ return $wp_sitemaps;
63
}
64
65
/**
69
*
70
* @return array $sitemaps A list of registered sitemap providers.
71
*/
72
+ function wp_get_sitemaps() {
73
+ $sitemaps = wp_sitemaps_get_server();
74
75
+ if ( ! $sitemaps ) {
76
return array();
77
}
78
79
+ return $sitemaps->registry->get_sitemaps();
80
}
81
82
/**
84
*
85
* @since 5.5.0
86
*
87
+ * @param string $name Unique name for the sitemap provider.
88
+ * @param WP_Sitemaps_Provider $provider The `Sitemaps_Provider` instance implementing the sitemap.
89
* @return bool Returns true if the sitemap was added. False on failure.
90
*/
91
+ function wp_register_sitemap( $name, $provider ) {
92
+ $sitemaps = wp_sitemaps_get_server();
93
94
+ if ( ! $sitemaps ) {
95
return false;
96
}
97
98
+ return $sitemaps->registry->add_sitemap( $name, $provider );
99
}
100
101
/**
106
* @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user').
107
* @return int The maximum number of URLs.
108
*/
109
+ function wp_sitemaps_get_max_urls( $object_type ) {
110
/**
111
* Filters the maximum number of URLs displayed on a sitemap.
112
*
115
* @param int $max_urls The maximum number of URLs included in a sitemap. Default 2000.
116
* @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user').
117
*/
118
+ return apply_filters( 'wp_sitemaps_max_urls', WP_SITEMAPS_MAX_URLS, $object_type );
119
}
psp-include/sitemap/inc/providers/class-core-sitemaps-posts.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * Sitemaps: Core_Sitemaps_Posts class
4
- *
5
- * Builds the sitemaps for the 'post' object type.
6
- *
7
- * @package WordPress
8
- * @subpackage Sitemaps
9
- * @since 5.5.0
10
- */
11
-
12
- /**
13
- * Posts XML sitemap provider.
14
- *
15
- * @since 5.5.0
16
- */
17
- class Core_Sitemaps_Posts extends Core_Sitemaps_Provider {
18
- /**
19
- * Core_Sitemaps_Posts constructor.
20
- *
21
- * @since 5.5.0
22
- */
23
- public function __construct() {
24
- $this->name = 'posts';
25
- $this->object_type = 'post';
26
- }
27
-
28
- /**
29
- * Returns the public post types, which excludes nav_items and similar types.
30
- * Attachments are also excluded. This includes custom post types with public = true.
31
- *
32
- * @since 5.5.0
33
- *
34
- * @return array Map of registered post type objects keyed by their name.
35
- */
36
- public function get_object_subtypes() {
37
- $post_types = get_post_types( array( 'public' => true ), 'objects' );
38
- unset( $post_types['attachment'] );
39
-
40
- /**
41
- * Filters the list of post object sub types available within the sitemap.
42
- *
43
- * @since 5.5.0
44
- *
45
- * @param array $post_types Map of registered post type objects keyed by their name.
46
- */
47
- return apply_filters( 'core_sitemaps_post_types', $post_types );
48
- }
49
-
50
- /**
51
- * Gets a URL list for a post type sitemap.
52
- *
53
- * @since 5.5.0
54
- *
55
- * @param int $page_num Page of results.
56
- * @param string $post_type Optional. Post type name. Default empty.
57
- * @return array List of URLs for a sitemap.
58
- */
59
- public function get_url_list( $page_num, $post_type = '' ) {
60
- if ( ! $post_type ) {
61
- $post_type = $this->get_queried_type();
62
- }
63
-
64
- // Return an empty array if the type is not supported.
65
- $supported_types = $this->get_object_subtypes();
66
-
67
- if ( ! isset( $supported_types[ $post_type ] ) ) {
68
- return array();
69
- }
70
-
71
- $query = new WP_Query(
72
- array(
73
- 'fields' => 'ids',
74
- 'orderby' => 'ID',
75
- 'order' => 'ASC',
76
- 'post_type' => $post_type,
77
- 'posts_per_page' => core_sitemaps_get_max_urls( $this->object_type ),
78
- 'post_status' => array( 'publish' ),
79
- 'paged' => $page_num,
80
- 'no_found_rows' => true,
81
- 'update_post_term_cache' => false,
82
- 'update_post_meta_cache' => false,
83
- )
84
- );
85
-
86
- /**
87
- * Returns an array of posts.
88
- *
89
- * @var array<int, \WP_Post> $posts
90
- */
91
- $posts = $query->get_posts();
92
-
93
- $posts = apply_filters( 'core_sitemaps_posts_list', $posts, $post_type, $page_num );
94
-
95
- $url_list = array();
96
-
97
- $post_sitemap_attributes = array();
98
-
99
- /*
100
- * Add a URL for the homepage in the pages sitemap.
101
- * Shows only on the first page if the reading settings are set to display latest posts.
102
- */
103
- if ( 'page' === $post_type && 1 === $page_num && 'posts' === get_option( 'show_on_front' ) ) {
104
- // Extract the data needed for home URL to add to the array.
105
- $url_list[] = array(
106
- 'loc' => home_url(),
107
- );
108
- }
109
-
110
- foreach ( $posts as $post ) {
111
- $post_sitemap_attributes = array( 'loc' => get_permalink( $post )) ;
112
- $url_list[] = apply_filters( 'core_sitemaps_post_attributes', $post_sitemap_attributes, $post );
113
- /***
114
- $url_list[] = array(
115
- 'loc' => get_permalink( $post ),
116
- );
117
- ***/
118
- }
119
-
120
- /**
121
- * Filters the list of URLs for a sitemap before rendering.
122
- *
123
- * @since 5.5.0
124
- *
125
- * @param array $url_list List of URLs for a sitemap.
126
- * @param string $post_type Name of the post_type.
127
- * @param int $page_num Page number of the results.
128
- */
129
- return apply_filters( 'core_sitemaps_posts_url_list', $url_list, $post_type, $page_num );
130
- }
131
-
132
- /**
133
- * Gets the max number of pages available for the object type.
134
- *
135
- * @since 5.5.0
136
- *
137
- * @param string $post_type Optional. Post type name. Default empty.
138
- * @return int Total number of pages.
139
- */
140
- public function max_num_pages( $post_type = '' ) {
141
- if ( empty( $post_type ) ) {
142
- $post_type = $this->get_queried_type();
143
- }
144
-
145
- $query = new WP_Query(
146
- array(
147
- 'fields' => 'ids',
148
- 'orderby' => 'ID',
149
- 'order' => 'ASC',
150
- 'post_type' => $post_type,
151
- 'posts_per_page' => core_sitemaps_get_max_urls( $this->object_type ),
152
- 'paged' => 1,
153
- 'update_post_term_cache' => false,
154
- 'update_post_meta_cache' => false,
155
- )
156
- );
157
-
158
- return isset( $query->max_num_pages ) ? $query->max_num_pages : 1;
159
- }
160
- }
psp-include/sitemap/inc/providers/class-core-sitemaps-taxonomies.php DELETED
@@ -1,143 +0,0 @@
1
- <?php
2
- /**
3
- * Sitemaps: Core_Sitemaps_Taxonomies class
4
- *
5
- * Builds the sitemaps for the 'taxonomy' object type.
6
- *
7
- * @package WordPress
8
- * @subpackage Sitemaps
9
- * @since 5.5.0
10
- */
11
-
12
- /**
13
- * Taxonomies XML sitemap provider.
14
- *
15
- * @since 5.5.0
16
- */
17
- class Core_Sitemaps_Taxonomies extends Core_Sitemaps_Provider {
18
- /**
19
- * Core_Sitemaps_Taxonomies constructor.
20
- *
21
- * @since 5.5.0
22
- */
23
- public function __construct() {
24
- $this->name = 'taxonomies';
25
- $this->object_type = 'term';
26
- }
27
-
28
- /**
29
- * Returns all public, registered taxonomies.
30
- *
31
- * @since 5.5.0
32
- *
33
- * @return array Map of registered taxonomy objects keyed by their name.
34
- */
35
- public function get_object_subtypes() {
36
- $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
37
-
38
- /**
39
- * Filter the list of taxonomy object subtypes available within the sitemap.
40
- *
41
- * @since 5.5.0
42
- *
43
- * @param array $taxonomies Map of registered taxonomy objects keyed by their name.
44
- */
45
- return apply_filters( 'core_sitemaps_taxonomies', $taxonomies );
46
- }
47
-
48
- /**
49
- * Gets a URL list for a taxonomy sitemap.
50
- *
51
- * @since 5.5.0
52
- *
53
- * @param int $page_num Page of results.
54
- * @param string $taxonomy Optional. Taxonomy name. Default empty.
55
- * @return array List of URLs for a sitemap.
56
- */
57
- public function get_url_list( $page_num, $taxonomy = '' ) {
58
- // Find the query_var for subtype.
59
- if ( ! $taxonomy ) {
60
- $taxonomy = $this->get_queried_type();
61
- }
62
-
63
- // Bail early if we don't have a taxonomy.
64
- if ( empty( $taxonomy ) ) {
65
- return array();
66
- }
67
-
68
- $supported_types = $this->get_object_subtypes();
69
-
70
- // Bail early if the queried taxonomy is not a supported type.
71
- if ( ! isset( $supported_types[ $taxonomy ] ) ) {
72
- return array();
73
- }
74
-
75
- $url_list = array();
76
-
77
- // Offset by how many terms should be included in previous pages.
78
- $offset = ( $page_num - 1 ) * core_sitemaps_get_max_urls( $this->object_type );
79
-
80
- $args = array(
81
- 'fields' => 'ids',
82
- 'taxonomy' => $taxonomy,
83
- 'orderby' => 'term_order',
84
- 'number' => core_sitemaps_get_max_urls( $this->object_type ),
85
- 'offset' => $offset,
86
- 'hide_empty' => true,
87
-
88
- /*
89
- * Limits aren't included in queries when hierarchical is set to true (by default).
90
- *
91
- * @link: https://github.com/WordPress/WordPress/blob/5.3/wp-includes/class-wp-term-query.php#L558-L567
92
- */
93
- 'hierarchical' => false,
94
- 'update_term_meta_cache' => false,
95
- );
96
-
97
- $taxonomy_terms = new WP_Term_Query( $args );
98
-
99
- $taxonomy_terms = apply_filters( 'core_sitemaps_terms_list', $taxonomy_terms, $taxonomy, $page_num );
100
-
101
- if ( ! empty( $taxonomy_terms->terms ) ) {
102
- foreach ( $taxonomy_terms->terms as $term ) {
103
-
104
- $term_sitemap_attributes = array( 'loc' => get_term_link( $term )) ;
105
- $url_list[] = apply_filters( 'core_sitemaps_term_attributes', $term_sitemap_attributes, $term );
106
- /**
107
- $url_list[] = array(
108
- 'loc' => get_term_link( $term ),
109
- );
110
- **/
111
- }
112
- }
113
-
114
- /**
115
- * Filters the list of URLs for a sitemap before rendering.
116
- *
117
- * @since 5.5.0
118
- *
119
- * @param array $url_list List of URLs for a sitemap.
120
- * @param string $taxonomy Taxonomy name.
121
- * @param int $page_num Page of results.
122
- */
123
- return apply_filters( 'core_sitemaps_taxonomies_url_list', $url_list, $taxonomy, $page_num );
124
- }
125
-
126
- /**
127
- * Gets the max number of pages available for the object type.
128
- *
129
- * @since 5.5.0
130
- *
131
- * @param string $taxonomy Taxonomy name.
132
- * @return int Total number of pages.
133
- */
134
- public function max_num_pages( $taxonomy = '' ) {
135
- if ( empty( $taxonomy ) ) {
136
- $taxonomy = $this->get_queried_type();
137
- }
138
-
139
- $term_count = wp_count_terms( $taxonomy, array( 'hide_empty' => true ) );
140
-
141
- return (int) ceil( $term_count / core_sitemaps_get_max_urls( $this->object_type ) );
142
- }
143
- }
psp-include/sitemap/inc/providers/class-core-sitemaps-users.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
- /**
3
- * Sitemaps: Core_Sitemaps_Users class
4
- *
5
- * Builds the sitemaps for the 'user' object type.
6
- *
7
- * @package WordPress
8
- * @subpackage Sitemaps
9
- * @since 5.5.0
10
- */
11
-
12
- /**
13
- * Users XML sitemap provider.
14
- *
15
- * @since 5.5.0
16
- */
17
- class Core_Sitemaps_Users extends Core_Sitemaps_Provider {
18
- /**
19
- * Core_Sitemaps_Users constructor.
20
- *
21
- * @since 5.5.0
22
- */
23
- public function __construct() {
24
- $this->name = 'users';
25
- $this->object_type = 'user';
26
- }
27
-
28
- /**
29
- * Gets a URL list for a user sitemap.
30
- *
31
- * @since 5.5.0
32
- *
33
- * @param int $page_num Page of results.
34
- * @param string $object_subtype Optional. Not applicable for Users but
35
- * required for compatibility with the parent
36
- * provider class. Default empty.
37
- * @return array List of URLs for a sitemap.
38
- */
39
- public function get_url_list( $page_num, $object_subtype = '' ) {
40
- $query = $this->get_public_post_authors_query( $page_num );
41
- $users = $query->get_results();
42
- $url_list = array();
43
-
44
- foreach ( $users as $user ) {
45
- $url_list[] = array(
46
- 'loc' => get_author_posts_url( $user->ID ),
47
- );
48
- }
49
-
50
- /**
51
- * Filters the list of URLs for a sitemap before rendering.
52
- *
53
- * @since 5.5.0
54
- *
55
- * @param array $url_list List of URLs for a sitemap.
56
- * @param int $page_num Page of results.
57
- */
58
- return apply_filters( 'core_sitemaps_users_url_list', $url_list, $page_num );
59
- }
60
-
61
- /**
62
- * Gets the max number of pages available for the object type.
63
- *
64
- * @since 5.5.0
65
- *
66
- * @see Core_Sitemaps_Provider::max_num_pages
67
- *
68
- * @param string $object_subtype Optional. Not applicable for Users but
69
- * required for compatibility with the parent
70
- * provider class. Default empty.
71
- * @return int Total page count.
72
- */
73
- public function max_num_pages( $object_subtype = '' ) {
74
- $query = $this->get_public_post_authors_query();
75
-
76
- $total_users = $query->get_total();
77
-
78
- return (int) ceil( $total_users / core_sitemaps_get_max_urls( $this->object_type ) );
79
- }
80
-
81
- /**
82
- * Returns a query for authors with public posts.
83
- *
84
- * Implementation must support `$query->max_num_pages`.
85
- *
86
- * @since 5.5.0
87
- *
88
- * @param integer $page_num Optional. Default is 1. Page of query results to return.
89
- * @return WP_User_Query
90
- */
91
- public function get_public_post_authors_query( $page_num = 1 ) {
92
- $public_post_types = get_post_types(
93
- array(
94
- 'public' => true,
95
- )
96
- );
97
-
98
- // We're not supporting sitemaps for author pages for attachments.
99
- unset( $public_post_types['attachment'] );
100
-
101
- $query = new WP_User_Query(
102
- array(
103
- 'has_published_posts' => array_keys( $public_post_types ),
104
- 'number' => core_sitemaps_get_max_urls( $this->object_type ),
105
- 'paged' => absint( $page_num ),
106
- )
107
- );
108
-
109
- return $query;
110
- }
111
- }
psp-include/sitemap/inc/providers/class-wp-sitemaps-posts.php ADDED
@@ -0,0 +1,211 @@
1
+ <?php
2
+ /**
3
+ * Sitemaps: WP_Sitemaps_Posts class
4
+ *
5
+ * Builds the sitemaps for the 'post' object type.
6
+ *
7
+ * @package WordPress
8
+ * @subpackage Sitemaps
9
+ * @since 5.5.0
10
+ */
11
+
12
+ /**
13
+ * Posts XML sitemap provider.
14
+ *
15
+ * @since 5.5.0
16
+ */
17
+ class WP_Sitemaps_Posts extends WP_Sitemaps_Provider {
18
+ /**
19
+ * WP_Sitemaps_Posts constructor.
20
+ *
21
+ * @since 5.5.0
22
+ */
23
+ public function __construct() {
24
+ $this->name = 'posts';
25
+ $this->object_type = 'post';
26
+ }
27
+
28
+ /**
29
+ * Returns the public post types, which excludes nav_items and similar types.
30
+ * Attachments are also excluded. This includes custom post types with public = true.
31
+ *
32
+ * @since 5.5.0
33
+ *
34
+ * @return array Map of registered post type objects (WP_Post_Type) keyed by their name.
35
+ */
36
+ public function get_object_subtypes() {
37
+ $post_types = get_post_types( array( 'public' => true ), 'objects' );
38
+ unset( $post_types['attachment'] );
39
+
40
+ /**
41
+ * Filters the list of post object sub types available within the sitemap.
42
+ *
43
+ * @since 5.5.0
44
+ *
45
+ * @param array $post_types Map of registered post type objects (WP_Post_Type) keyed by their name.
46
+ */
47
+ return apply_filters( 'wp_sitemaps_post_types', $post_types );
48
+ }
49
+
50
+ /**
51
+ * Gets a URL list for a post type sitemap.
52
+ *
53
+ * @since 5.5.0
54
+ *
55
+ * @param int $page_num Page of results.
56
+ * @param string $post_type Optional. Post type name. Default empty.
57
+ * @return array $url_list Array of URLs for a sitemap.
58
+ */
59
+ public function get_url_list( $page_num, $post_type = '' ) {
60
+ // Bail early if the queried post type is not supported.
61
+ $supported_types = $this->get_object_subtypes();
62
+
63
+ if ( ! isset( $supported_types[ $post_type ] ) ) {
64
+ return array();
65
+ }
66
+
67
+ /**
68
+ * Filters the posts URL list before it is generated.
69
+ *
70
+ * Passing a non-null value will effectively short-circuit the generation,
71
+ * returning that value instead.
72
+ *
73
+ * @since 5.5.0
74
+ *
75
+ * @param array $url_list The URL list. Default null.
76
+ * @param string $post_type Post type name.
77
+ * @param int $page_num Page of results.
78
+ */
79
+ $url_list = apply_filters(
80
+ 'wp_sitemaps_posts_pre_url_list',
81
+ null,
82
+ $post_type,
83
+ $page_num
84
+ );
85
+
86
+ if ( null !== $url_list ) {
87
+ return $url_list;
88
+ }
89
+
90
+ $args = $this->get_posts_query_args( $post_type );
91
+ $args['paged'] = $page_num;
92
+
93
+ $query = new WP_Query( $args );
94
+
95
+ /**
96
+ * Returns an array of posts.
97
+ *
98
+ * @var array<int, \WP_Post> $posts
99
+ */
100
+ $posts = $query->get_posts();
101
+
102
+ $url_list = array();
103
+
104
+ /*
105
+ * Add a URL for the homepage in the pages sitemap.
106
+ * Shows only on the first page if the reading settings are set to display latest posts.
107
+ */
108
+ if ( 'page' === $post_type && 1 === $page_num && 'posts' === get_option( 'show_on_front' ) ) {
109
+ // Extract the data needed for home URL to add to the array.
110
+ $url_list[] = array(
111
+ 'loc' => home_url(),
112
+ );
113
+ }
114
+
115
+ foreach ( $posts as $post ) {
116
+ $sitemap_entry = array(
117
+ 'loc' => get_permalink( $post ),
118
+ );
119
+
120
+ /**
121
+ * Filters the sitemap entry for an individual post.
122
+ *
123
+ * @since 5.5.0
124
+ *
125
+ * @param array $sitemap_entry Sitemap entry for the post.
126
+ * @param WP_Post $post Post object.
127
+ * @param string $post_type Name of the post_type.
128
+ */
129
+ $sitemap_entry = apply_filters( 'wp_sitemaps_posts_entry', $sitemap_entry, $post, $post_type );
130
+ $url_list[] = $sitemap_entry;
131
+ }
132
+
133
+ return $url_list;
134
+ }
135
+
136
+ /**
137
+ * Gets the max number of pages available for the object type.
138
+ *
139
+ * @since 5.5.0
140
+ *
141
+ * @param string $post_type Optional. Post type name. Default empty.
142
+ * @return int Total number of pages.
143
+ */
144
+ public function get_max_num_pages( $post_type = '' ) {
145
+ if ( empty( $post_type ) ) {
146
+ return 0;
147
+ }
148
+
149
+ /**
150
+ * Filters the max number of pages before it is generated.
151
+ *
152
+ * Passing a non-null value will effectively short-circuit the generation,
153
+ * returning that value instead.
154
+ *
155
+ * @since 5.5.0
156
+ *
157
+ * @param int $max_num_pages The maximum number of pages. Default null.
158
+ * @param string $post_type Post type name.
159
+ */
160
+ $max_num_pages = apply_filters( 'wp_sitemaps_posts_pre_max_num_pages', null, $post_type );
161
+
162
+ if ( null !== $max_num_pages ) {
163
+ return $max_num_pages;
164
+ }
165
+
166
+ $args = $this->get_posts_query_args( $post_type );
167
+ $args['fields'] = 'ids';
168
+ $args['no_found_rows'] = false;
169
+
170
+ $query = new WP_Query( $args );
171
+
172
+ return isset( $query->max_num_pages ) ? $query->max_num_pages : 1;
173
+ }
174
+
175
+ /**
176
+ * Returns the query args for retrieving posts to list in the sitemap.
177
+ *
178
+ * @since 5.5.0
179
+ *
180
+ * @param string $post_type Post type name.
181
+ * @return array $args Array of WP_Query arguments.
182
+ */
183
+ protected function get_posts_query_args( $post_type ) {
184
+ /**
185
+ * Filters the query arguments for post type sitemap queries.
186
+ *
187
+ * @see WP_Query for a full list of arguments.
188
+ *
189
+ * @since 5.5.0
190
+ *
191
+ * @param array $args Array of WP_Query arguments.
192
+ * @param string $post_type Post type name.
193
+ */
194
+ $args = apply_filters(
195
+ 'wp_sitemaps_posts_query_args',
196
+ array(
197
+ 'orderby' => 'ID',
198
+ 'order' => 'ASC',
199
+ 'post_type' => $post_type,
200
+ 'posts_per_page' => wp_sitemaps_get_max_urls( $this->object_type ),
201
+ 'post_status' => array( 'publish' ),
202
+ 'no_found_rows' => true,
203
+ 'update_post_term_cache' => false,
204
+ 'update_post_meta_cache' => false,
205
+ ),
206
+ $post_type
207
+ );
208
+
209
+ return $args;
210
+ }
211
+ }
psp-include/sitemap/inc/providers/class-wp-sitemaps-taxonomies.php ADDED
@@ -0,0 +1,193 @@
1
+ <?php
2
+ /**
3
+ * Sitemaps: WP_Sitemaps_Taxonomies class
4
+ *
5
+ * Builds the sitemaps for the 'taxonomy' object type.
6
+ *
7
+ * @package WordPress
8
+ * @subpackage Sitemaps
9
+ * @since 5.5.0
10
+ */
11
+
12
+ /**
13
+ * Taxonomies XML sitemap provider.
14
+ *
15
+ * @since 5.5.0
16
+ */
17
+ class WP_Sitemaps_Taxonomies extends WP_Sitemaps_Provider {
18
+ /**
19
+ * WP_Sitemaps_Taxonomies constructor.
20
+ *
21
+ * @since 5.5.0
22
+ */
23
+ public function __construct() {
24
+ $this->name = 'taxonomies';
25
+ $this->object_type = 'term';
26
+ }
27
+
28
+ /**
29
+ * Returns all public, registered taxonomies.
30
+ *
31
+ * @since 5.5.0
32
+ *
33
+ * @return array Map of registered taxonomy objects keyed by their name.
34
+ */
35
+ public function get_object_subtypes() {
36
+ $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
37
+
38
+ /**
39
+ * Filter the list of taxonomy object subtypes available within the sitemap.
40
+ *
41
+ * @since 5.5.0
42
+ *
43
+ * @param array $taxonomies Map of registered taxonomy objects keyed by their name.
44
+ */
45
+ return apply_filters( 'wp_sitemaps_taxonomies', $taxonomies );
46
+ }
47
+
48
+ /**
49
+ * Gets a URL list for a taxonomy sitemap.
50
+ *
51
+ * @since 5.5.0
52
+ *
53
+ * @param int $page_num Page of results.
54
+ * @param string $taxonomy Optional. Taxonomy name. Default empty.
55
+ * @return array $url_list Array of URLs for a sitemap.
56
+ */
57
+ public function get_url_list( $page_num, $taxonomy = '' ) {
58
+ $supported_types = $this->get_object_subtypes();
59
+
60
+ // Bail early if the queried taxonomy is not supported.
61
+ if ( ! isset( $supported_types[ $taxonomy ] ) ) {
62
+ return array();
63
+ }
64
+
65
+ /**
66
+ * Filters the taxonomies URL list before it is generated.
67
+ *
68
+ * Passing a non-null value will effectively short-circuit the generation,
69
+ * returning that value instead.
70
+ *
71
+ * @since 5.5.0
72
+ *
73
+ * @param array $url_list The URL list. Default null.
74
+ * @param string $taxonomy Taxonomy name.
75
+ * @param int $page_num Page of results.
76
+ */
77
+ $url_list = apply_filters(
78
+ 'wp_sitemaps_taxonomies_pre_url_list',
79
+ null,
80
+ $taxonomy,
81
+ $page_num
82
+ );
83
+
84
+ if ( null !== $url_list ) {
85
+ return $url_list;
86
+ }
87
+
88
+ $url_list = array();
89
+
90
+ // Offset by how many terms should be included in previous pages.
91
+ $offset = ( $page_num - 1 ) * wp_sitemaps_get_max_urls( $this->object_type );
92
+
93
+ $args = $this->get_taxonomies_query_args( $taxonomy );
94
+ $args['offset'] = $offset;
95
+
96
+ $taxonomy_terms = new WP_Term_Query( $args );
97
+
98
+ if ( ! empty( $taxonomy_terms->terms ) ) {
99
+ foreach ( $taxonomy_terms->terms as $term ) {
100
+ $sitemap_entry = array(
101
+ 'loc' => get_term_link( $term ),
102
+ );
103
+
104
+ /**
105
+ * Filters the sitemap entry for an individual term.
106
+ *
107
+ * @since 5.5.0
108
+ *
109
+ * @param array $sitemap_entry Sitemap entry for the term.
110
+ * @param WP_Term $term Term object.
111
+ * @param string $taxonomy Taxonomy name.
112
+ */
113
+ $sitemap_entry = apply_filters( 'wp_sitemaps_taxonomies_entry', $sitemap_entry, $term, $taxonomy );
114
+ $url_list[] = $sitemap_entry;
115
+ }
116
+ }
117
+
118
+ return $url_list;
119
+ }
120
+
121
+ /**
122
+ * Gets the max number of pages available for the object type.
123
+ *
124
+ * @since 5.5.0
125
+ *
126
+ * @param string $taxonomy Taxonomy name.
127
+ * @return int Total number of pages.
128
+ */
129
+ public function get_max_num_pages( $taxonomy = '' ) {
130
+ if ( empty( $taxonomy ) ) {
131
+ return 0;
132
+ }
133
+
134
+ /**
135
+ * Filters the max number of pages before it is generated.
136
+ *
137
+ * Passing a non-null value will effectively short-circuit the generation,
138
+ * returning that value instead.
139
+ *
140
+ * @since 5.5.0
141
+ *
142
+ * @param int $max_num_pages The maximum number of pages. Default null.
143
+ * @param string $taxonomy Taxonomy name.
144
+ */
145
+ $max_num_pages = apply_filters( 'wp_sitemaps_taxonomies_pre_max_num_pages', null, $taxonomy );
146
+
147
+ if ( null !== $max_num_pages ) {
148
+ return $max_num_pages;
149
+ }
150
+
151
+ $term_count = wp_count_terms( $taxonomy, $this->get_taxonomies_query_args( $taxonomy ) );
152
+
153
+ return (int) ceil( $term_count / wp_sitemaps_get_max_urls( $this->object_type ) );
154
+ }
155
+
156
+ /**
157
+ * Returns the query args for retrieving taxonomy terms to list in the sitemap.
158
+ *
159
+ * @since 5.5.0
160
+ *
161
+ * @param string $taxonomy Taxonomy name.
162
+ * @return array $args Array of WP_Term_Query arguments.
163
+ */
164
+ protected function get_taxonomies_query_args( $taxonomy ) {
165
+ /**
166
+ * Filters the taxonomy terms query arguments.
167
+ *
168
+ * Allows modification of the taxonomy query arguments before querying.
169
+ *
170
+ * @see WP_Term_Query for a full list of arguments
171
+ *
172
+ * @since 5.5.0
173
+ *
174
+ * @param array $args Array of WP_Term_Query arguments.
175
+ * @param string $taxonomy Taxonomy name.
176
+ */
177
+ $args = apply_filters(
178
+ 'wp_sitemaps_taxonomies_query_args',
179
+ array(
180
+ 'fields' => 'ids',
181
+ 'taxonomy' => $taxonomy,
182
+ 'orderby' => 'term_order',
183
+ 'number' => wp_sitemaps_get_max_urls( $this->object_type ),
184
+ 'hide_empty' => true,
185
+ 'hierarchical' => false,
186
+ 'update_term_meta_cache' => false,
187
+ ),
188
+ $taxonomy
189
+ );
190
+
191
+ return $args;
192
+ }
193
+ }
psp-include/sitemap/inc/providers/class-wp-sitemaps-users.php ADDED
@@ -0,0 +1,163 @@
1
+ <?php
2
+ /**
3
+ * Sitemaps: WP_Sitemaps_Users class
4
+ *
5
+ * Builds the sitemaps for the 'user' object type.
6
+ *
7
+ * @package WordPress
8
+ * @subpackage Sitemaps
9
+ * @since 5.5.0
10
+ */
11
+
12
+ /**
13
+ * Users XML sitemap provider.
14
+ *
15
+ * @since 5.5.0
16
+