Plugin Directory

Changeset 2984954


Ignore:
Timestamp:
10/27/2023 01:24:50 PM (2 years ago)
Author:
diagnoseo
Message:

fixes & improvements

Location:
diagnoseo
Files:
10 edited
30 copied

Legend:

Unmodified
Added
Removed
  • diagnoseo/tags/1.2.16/diagnoseo.php

    r2963171 r2984954  
    44 * Plugin URI: https://diagnoseo.com/wordpress-seo-plugin/
    55 * Description: Powerful SEO plugin for WordPress. The most lightweight and complete SEO solution on the market! It includes best-in-class content analyzer and keyword placement checkpoints.
    6  * Version: 1.2.15
     6 * Version: 1.2.16
    77 * Author: DiagnoSEO
    88 * Author URI: https://diagnoseo.com/
     
    178178        // only post editor.
    179179        if ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) {
     180            require_once DIAGNOSEO_INCLUDES_PATH . 'api-endpoints.php';
    180181            require_once DIAGNOSEO_INCLUDES_PATH . 'content-watcher-meta.php';
    181             require_once DIAGNOSEO_INCLUDES_PATH . 'api-endpoints.php';
    182182            require_once DIAGNOSEO_INCLUDES_PATH . 'class-diagnoseo-settingshelper.php';
    183183            require_once DIAGNOSEO_INCLUDES_PATH . 'blocks.php';
     
    186186            require_once DIAGNOSEO_INCLUDES_PATH . 'css-variables.php';
    187187            require_once DIAGNOSEO_INCLUDES_PATH . 'content-watcher-scripts.php';
    188             require_once DIAGNOSEO_INCLUDES_PATH . 'api-endpoints.php';
     188            require_once DIAGNOSEO_INCLUDES_PATH . 'openai.php';
     189            require_once DIAGNOSEO_INCLUDES_PATH . 'related-keywords.php';
    189190        }
    190191    } else {
  • diagnoseo/tags/1.2.16/includes/class-diagnoseo-breadcrumbs.php

    r2920588 r2984954  
    497497    public function render_schema() {
    498498        $this->build_structured_data();
     499        if ( empty( $this->schema ) ) {
     500            return;
     501        }
    499502        ?>
    500         <script type="application/ld+json">
     503    <script type="application/ld+json">
    501504        <?php echo wp_json_encode( $this->schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); ?>
    502         </script>
     505    </script>
    503506        <?php
    504507    }
  • diagnoseo/tags/1.2.16/includes/class-diagnoseo-generalsettings.php

    r2825827 r2984954  
    1414 */
    1515class Diagnoseo_GeneralSettings {
     16
     17    /**
     18     * Option group name
     19     *
     20     * @var $option_group
     21     */
     22    private $option_group = 'diagnoseo_general_options';
    1623
    1724    /**
     
    174181        add_option( 'diagnoseo_redirect_attachment', true );
    175182        register_setting(
    176             'diagnoseo_general_options',
     183            $this->option_group,
    177184            'diagnoseo_redirect_attachment',
    178185            array(
     
    189196            add_option( $index_name, 'index' );
    190197            register_setting(
    191                 'diagnoseo_general_options',
     198                $this->option_group,
    192199                $index_name,
    193200                array(
     
    200207            add_option( $follow_name, 'follow' );
    201208            register_setting(
    202                 'diagnoseo_general_options',
     209                $this->option_group,
    203210                $follow_name,
    204211                array(
     
    213220        add_option( 'diagnoseo_author_index', 'index' );
    214221        register_setting(
    215             'diagnoseo_general_options',
     222            $this->option_group,
    216223            'diagnoseo_author_index',
    217224            array(
     
    224231        add_option( 'diagnoseo_author_follow', 'follow' );
    225232        register_setting(
    226             'diagnoseo_general_options',
     233            $this->option_group,
    227234            'diagnoseo_author_follow',
    228235            array(
     
    235242        add_option( 'diagnoseo_tag_index', 'index' );
    236243        register_setting(
    237             'diagnoseo_general_options',
     244            $this->option_group,
    238245            'diagnoseo_tag_index',
    239246            array(
     
    246253        add_option( 'diagnoseo_tag_follow', 'follow' );
    247254        register_setting(
    248             'diagnoseo_general_options',
     255            $this->option_group,
    249256            'diagnoseo_tag_follow',
    250257            array(
     
    258265        add_option( 'diagnoseo_date_archive_index', 'noindex' );
    259266        register_setting(
    260             'diagnoseo_general_options',
     267            $this->option_group,
    261268            'diagnoseo_date_archive_index',
    262269            array(
     
    269276        add_option( 'diagnoseo_date_archive_follow', 'follow' );
    270277        register_setting(
    271             'diagnoseo_general_options',
     278            $this->option_group,
    272279            'diagnoseo_date_archive_follow',
    273280            array(
     
    280287        add_option( 'diagnoseo_archive_index', 'index' );
    281288        register_setting(
    282             'diagnoseo_general_options',
     289            $this->option_group,
    283290            'diagnoseo_archive_index',
    284291            array(
     
    291298        add_option( 'diagnoseo_archive_follow', 'follow' );
    292299        register_setting(
    293             'diagnoseo_general_options',
     300            $this->option_group,
    294301            'diagnoseo_archive_follow',
    295302            array(
     
    302309        add_option( 'diagnoseo_fix_category_url_base', false );
    303310        register_setting(
    304             'diagnoseo_general_options',
     311            $this->option_group,
    305312            'diagnoseo_fix_category_url_base',
    306313            array(
     
    313320        add_option( 'diagnoseo_sitemap_lastmod', true );
    314321        register_setting(
    315             'diagnoseo_general_options',
     322            $this->option_group,
    316323            'diagnoseo_sitemap_lastmod',
    317324            array(
     
    325332            add_option( 'diagnoseo_fix_product_cat_url_base', false );
    326333            register_setting(
    327                 'diagnoseo_general_options',
     334                $this->option_group,
    328335                'diagnoseo_fix_product_cat_url_base',
    329336                array(
  • diagnoseo/tags/1.2.16/includes/class-diagnoseo-settings.php

    r2928487 r2984954  
    108108            array( $this, 'render_settings' )
    109109        );
     110        add_submenu_page(
     111            'diagnoseo-settings',
     112            __( 'Breadcrumbs', 'diagnoseo' ),
     113            __( 'Breadcrumbs', 'diagnoseo' ),
     114            'manage_options',
     115            '/customize.php?autofocus[section]=diagnoseo_breadcrumbs'
     116        );
    110117    }
    111118
  • diagnoseo/tags/1.2.16/includes/content-watcher-meta.php

    r2920588 r2984954  
    3232        '',
    3333        'diagnoseo_meta_additional_keywords',
     34        array(
     35            'auth_callback'     => function() {
     36                return current_user_can( 'edit_posts' );
     37            },
     38            'sanitize_callback' => 'sanitize_text_field',
     39            'show_in_rest'      => true,
     40            'single'            => true,
     41            'type'              => 'string',
     42        )
     43    );
     44
     45    register_post_meta(
     46        '',
     47        'diagnoseo_meta_language',
    3448        array(
    3549            'auth_callback'     => function() {
  • diagnoseo/tags/1.2.16/includes/structured-data.php

    r2920588 r2984954  
    6363            $schema->url           = get_the_permalink( $post_data->ID );
    6464            $schema->headline      = $post_data->post_title;
    65             $schema->commentCount  = get_comment_count( $post_data->ID )['total_comments']; // phpcs:ignore
     65            $schema->commentCount  = get_comment_count( $post_data->ID )['approved']; // phpcs:ignore
    6666            $schema->datePublished = get_the_date( 'Y-m-d', $post_data->ID ); // phpcs:ignore
     67            if ( has_post_thumbnail( $post_data->ID ) ) {
     68                $schema->image = get_the_post_thumbnail_url( $post_data->ID );
     69            }
    6770
    6871            $schema->author        = new stdClass();
  • diagnoseo/tags/1.2.16/js/build/index.js

    r2920588 r2984954  
    1 !function(){"use strict";var e=window.wp.element,t=window.wp.plugins,a=function(){return(0,e.createElement)("svg",{"enable-background":"new 0 0 20 20",height:"20",width:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",className:"diagnoseo-icon"},(0,e.createElement)("clipPath",{id:"a"},(0,e.createElement)("path",{d:"m0 0h20v20h-20z"})),(0,e.createElement)("path",{className:"diagnoseo-icon-part-tick",d:"m12.377 5.866 1.835 1.612-4.839 5.508-4.11-3.576 1.672-1.902 2.256 1.982z"}),(0,e.createElement)("path",{className:"diagnoseo-icon-part-magnifier","clip-path":"url(#a)",d:"m16.298 15.209c1.745-1.983 2.548-4.603 2.208-7.228-.315-2.426-1.555-4.584-3.493-6.077s-4.341-2.139-6.768-1.828c-2.426.315-4.584 1.555-6.077 3.493s-2.142 4.341-1.827 6.767c.649 5.007 5.251 8.554 10.259 7.905 1.441-.188 2.824-.717 4.014-1.536l3.749 3.295 1.476-1.68zm-1.471-1.887c-1.111 1.443-2.72 2.368-4.527 2.602-1.808.235-3.598-.247-5.041-1.361-1.444-1.111-2.368-2.719-2.602-4.527-.483-3.73 2.158-7.158 5.889-7.642.296-.038.59-.057.881-.057 3.375 0 6.316 2.511 6.761 5.946.235 1.806-.249 3.596-1.361 5.039"}))},o=window.wp.data;class i extends React.Component{constructor(e){super(e),this.state={score:0,timeout:null},this.handleCheckChanged=this.handleCheckChanged.bind(this),this.calculateScore=this.calculateScore.bind(this),this.runAllChecks=this.runAllChecks.bind(this)}calculateScore(){const e=window.diagnoseo.checks.filter((e=>"check"===e.type));let t=e.length+1,a=e.filter((e=>e.checked)),o=window.diagnoseo.additionalKeywordCount===window.diagnoseo.RelatedKeywordsInPost?a.length+1:a.length,i=Math.round(100*o/t);this.setState({score:i})}runAllChecks(){const e=window.diagnoseo.checks.filter((e=>"check"===e.type)),t={postTitle:(0,o.select)("core/editor").getEditedPostAttribute("title"),postContent:(0,o.select)("core/editor").getEditedPostContent(),keyword:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,featuredImageId:(0,o.select)("core/editor").getEditedPostAttribute("featured_media"),featuredImage:(0,o.select)("core").getMedia((0,o.select)("core/editor").getEditedPostAttribute("featured_media")),metaTitle:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_title,metaDescription:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_description,slug:(0,o.select)("core/editor").getEditedPostAttribute("slug"),blocks:(0,o.select)("core/block-editor").getBlocks(),optimalKeywordDensity:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density,optimalWordNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_word_number,optimalHeadingNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_heading_number,optimalImageNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_image_number};if(!t.featuredImageId||t.featuredImage)t.metaTitle=seoHelper.replaceVariables(t.metaTitle)||(document.querySelector("#seo-title")?seoHelper.replaceVariables(document.querySelector("#seo-title").getAttribute("placeholder")):""),t.metaDescription=seoHelper.replaceVariables(t.metaDescription)||(document.querySelector("#seo-description")?seoHelper.replaceVariables(document.querySelector("#seo-description").value):""),e.forEach(((e,a)=>{if(!e.test)return;let o="ok"===e.test(t),i=window.diagnoseo.checks.findIndex((t=>t.id===e.id));window.diagnoseo.checks[i].checked=o})),this.calculateScore();else var a=setInterval((()=>{(0,o.select)("core").getMedia(t.featuredImageId)&&(clearInterval(a),this.runAllChecks())}),500)}handleCheckChanged(){clearTimeout(this.state.timeout),this.setState({timeout:setTimeout(this.calculateScore,300)})}async componentDidMount(){window.addEventListener("check-changed",this.handleCheckChanged),setTimeout(this.runAllChecks,1e3)}componentWillUnmount(){window.removeEventListener("check-changed",this.handleCheckChanged)}render(){let t,o=this.state.score;switch(!0){case o<60:t="score-low";break;case o>=60&&o<90:t="score-medium";break;case o>=90:t="score-high"}let i=`diagnoseo-button-content ${t}`;return(0,e.createElement)("span",{className:i},(0,e.createElement)(a,null),(0,e.createElement)("b",{className:"diagnoseo-score"},this.state.score,"/100"))}whenEditorIsReady(){return new Promise((e=>{const t=(0,o.subscribe)((()=>{((0,o.select)("core/editor").isCleanNewPost()||(0,o.select)("core/block-editor").getBlockCount()>0)&&(t(),e())}))}))}}var n=i,l=window.wp.editPost,r=window.wp.components,s=window.wp.i18n,d=window.wp.compose,c=(0,d.compose)((0,o.withDispatch)(((e,t)=>({setMetaValue:a=>{var o={};o[t.fieldName]=a,e("core/editor").editPost({meta:o}),t.changeCallback&&t.changeCallback(a)}}))),(0,o.withSelect)(((e,t)=>({metaValue:e("core/editor").getEditedPostAttribute("meta")[t.fieldName]}))))((t=>(0,e.createElement)(r.TextControl,{label:t.label,value:t.metaValue,onChange:e=>t.setMetaValue(e)}))),m=(0,d.compose)((0,o.withSelect)((e=>({content:e("core/editor").getEditedPostContent(),keyword:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,optimalKeywordDensity:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density}))))((t=>{var a=0;if(t.keyword){var o=t.content.replace(/<\!--.*?-->/g,""),i=(o=(o=o.replace(/(\r\n|\n|\r)/gm," ")).toLowerCase()).split(" ");i=i.filter((e=>""!==e));var n=seoHelper.countOccurences(t.keyword,o);n&&(a=(a=n/i.length*100).toFixed(2))}let l;if(window.diagnoseoPro){let o="diagnoseo-check optimal-keyword-density",i=.7*parseFloat(t.optimalKeywordDensity),n=1.3*parseFloat(t.optimalKeywordDensity);o+=a>=i&&a<=n?" ok":" nok",l=(0,e.createElement)("p",{className:o},(0,s.__)("Optimal keyword density","diagnoseo")," ",(0,e.createElement)("b",{className:"value"},t.optimalKeywordDensity||""))}else l=(0,e.createElement)("p",{className:"diagnoseo-check optimal-keyword-density"},(0,e.createElement)("i",{className:"dashicons dashicons-lock"})," ",(0,s.__)("Optimal keyword density","diagnoseo"));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",{className:"diagnoseo-stats keyword-density"},(0,s.__)("Keyword density","diagnoseo")," ",(0,e.createElement)("b",{className:"value"},a,"%")),l)})),u=t=>{let a=["diagnoseo-check",t.id];if(t.test){let e=t.test(t.postData);"string"==typeof e&&a.push(e);let o="ok"===e,i=t.checkConfig.findIndex((e=>e.id===t.id));t.checkConfig[i].checked!==o&&window.dispatchEvent(new Event("check-changed")),t.checkConfig[i].checked=o}if(t.inPro)return(0,e.createElement)("p",{className:a.join(" ")},(0,e.createElement)("i",{className:"dashicons dashicons-lock"})," ",t.label," ",(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))));const o=t.valueFieldName&&t.postData[t.valueFieldName]?(0,e.createElement)("b",null,t.postData[t.valueFieldName]):"";return(0,e.createElement)("p",{className:a.join(" ")},t.label," ",o)},g=t=>{let a=["diagnoseo-stats",t.id];if(t.inPro)return(0,e.createElement)("p",{className:a.join(" ")},(0,e.createElement)("i",{className:"dashicons dashicons-lock"}),"  ",t.label," ",(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))));let o,i=(0,e.createElement)("b",{className:"value"}),n="";if(t.test){let o=t.test(t.postData);i=(0,e.createElement)("b",{className:"value"},o.value),n=o.comment?(0,e.createElement)("span",{className:"comment"},o.comment):"",o.status&&a.push(o.status)}return o=t.order&&"value label"!==t.order?(0,e.createElement)(e.Fragment,null,t.label," ",i," ",n):(0,e.createElement)(e.Fragment,null,i," ",t.label),(0,e.createElement)("p",{className:a.join(" ")},o)},p=(0,d.compose)((0,o.withSelect)((e=>({postTitle:e("core/editor").getEditedPostAttribute("title"),postContent:e("core/editor").getEditedPostContent(),featuredImage:e("core").getMedia(e("core/editor").getEditedPostAttribute("featured_media")),keyword:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,metaTitle:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_title,metaDescription:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_description,urlSlug:e("core/editor").getEditedPostAttribute("slug"),blocks:e("core/block-editor").getBlocks(),optimalKeywordDensity:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density,optimalWordNumber:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_word_number,optimalHeadingNumber:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_heading_number,optimalImageNumber:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_image_number,postType:e("core/editor").getCurrentPostType()}))))((t=>{const a=window.diagnoseo.checks,o=a.filter((e=>e.section===t.sectionName)),i={postTitle:t.postTitle,postContent:t.postContent,keyword:t.keyword,metaTitle:seoHelper.replaceVariables(t.metaTitle)||(document.querySelector("#seo-title")?seoHelper.replaceVariables(document.querySelector("#seo-title").getAttribute("placeholder")):""),metaDescription:seoHelper.replaceVariables(t.metaDescription)||(document.querySelector("#seo-description")?seoHelper.replaceVariables(document.querySelector("#seo-description").value):""),slug:t.urlSlug,blocks:t.blocks,featuredImage:t.featuredImage,optimalKeywordDensity:t.optimalKeywordDensity,optimalWordNumber:t.optimalWordNumber,optimalHeadingNumber:t.optimalHeadingNumber,optimalImageNumber:t.optimalImageNumber},n=o.map((o=>{let n=!0;if(o.postTypes&&(n=o.postTypes.includes(t.postType)),!o.hidden&&n)switch(o.type){case"check":return o.inPro?(0,e.createElement)(u,{id:o.id,label:o.label,inPro:o.inPro}):(0,e.createElement)(u,{id:o.id,label:o.label,test:o.test,postData:i,checkConfig:a,valueFieldName:o.valueFieldName});case"stats":return o.inPro?(0,e.createElement)(g,{id:o.id,label:o.label,inPro:o.inPro}):(0,e.createElement)(g,{id:o.id,label:o.label,test:o.test,order:o.order,postData:i})}}));return(0,e.createElement)(e.Fragment,null,n.map(((t,a)=>(0,e.createElement)(React.Fragment,{key:a},t))))}));class h extends React.Component{constructor(e){super(e),this.state={keyword:"",keywordList:[],keywordLimit:window.diagnoseoPro?window.diagnoseoPro.additionalKeywordLimit:window.diagnoseo.additionalKeywordLimit,apiKey:"",language:diagnoseo_settings?diagnoseo_settings.locale.substr(0,2):"",loading:!1},this.handleChange=this.handleChange.bind(this),this.handleLangChange=this.handleLangChange.bind(this),this.handleLoadButtonClick=this.handleLoadButtonClick.bind(this),this.relatedKeywordsApiUrl="diagnoseo/v1/related-keywords"}stripKeywordData(e){return(e=-1===e.indexOf("|")?e:e.substr(0,e.indexOf(" |"))).trim()}async loadRelatedKeywords(){const e=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword;if(!e)return void alert((0,s.__)('Please enter the "focus keyword" first',"diagnoseo"));if(!this.state.language)return void alert((0,s.__)("Please select language.","diagnoseo"));if(!this.state.apiKey)return void alert((0,s.__)("Please enter the API key in the DiagnoSEO Pro settings.","diagnoseo"));this.setState({loading:!0});let t=`https://api.diagnoseo.com/contentapi/?api_key=${this.state.apiKey}&keyword=${e}&engine=${this.state.language}`;await fetch(t).then((e=>e.json())).then((e=>{let t=e.seo_data;this.props.seoDataCollector&&this.props.seoDataCollector(t);let a=t.related_keywords,o=this.state.keywordList;a.forEach((e=>{let t=o.findIndex((t=>t.name===e.name));-1===t?o.push(e):(o[t].repeat_min=e.repeat_min,o[t].repeat_max=e.repeat_max)})),this.saveKeywords(o)})),this.setState({loading:!1})}saveKeywords(e){const t=[...new Set(e)];t.splice(this.state.keywordLimit),this.setState({keywordList:t}),window.onbeforeunload=null,(0,o.dispatch)("core/editor").editPost({meta:{diagnoseo_meta_additional_keywords:JSON.stringify(t)}})}componentDidMount(){let e=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_additional_keywords;try{e=JSON.parse(e)}catch{e=""}this.setState({keyword:this.props.focusKeyword,keywordList:e||[]})}async handleLoadButtonClick(){await wp.apiFetch({path:"diagnoseo/v1/apikey"}).then((e=>{this.setState({apiKey:e})})).catch((()=>{alert((0,s.__)("Related keywords and Pro data require DiagnoSEO Pro and API key.","diagnoseo"))})),window.diagnoseoPro?this.loadRelatedKeywords():alert((0,s.__)("Related keywords and Pro data require DiagnoSEO Pro and API key.","diagnoseo"))}handleChange(e){const t=this.state.keywordList,{stripKeywordData:a}=this;let o=e.map((e=>{let o=a(e.value||e),i=t.findIndex((e=>o===e.name));return{name:o,repeat_min:-1!==i?t[i].repeat_min:0,repeat_max:-1!==i?t[i].repeat_max:0}}));this.saveKeywords(o)}handleLangChange(e){this.setState({language:e})}render(){let{postTitle:t,postContent:a,featuredMedia:o}=this.props;const{countOccurences:i}=seoHelper;let n=0,l=this.state.keywordList.map((e=>{let l=e.name||"",r="error",s=function(e){a=seoHelper.stripTags(a);let n=0;return n+=i(e,t),n+=i(e,a),n+=seoHelper.isKeywordInAnyAlt(e,a),n+=o?i(e,o.alt_text):0,n}(l);s&&(r=e.repeat_min&&e.repeat_max?s>=e.repeat_min&&s<=e.repeat_max?"success":"validating":"success",n++);let d=` | ${s}`;return e.repeat_min&&e.repeat_max&&(d+=` (${e.repeat_min} - ${e.repeat_max})`),{value:l+d,status:r}})),d=!1;window.diagnoseo.RelatedKeywordsInPost!==n&&(window.diagnoseo.RelatedKeywordsInPost=n,d=!0),window.diagnoseo.additionalKeywordCount!==l.length&&(window.diagnoseo.additionalKeywordCount=l.length,d=!0),d&&window.dispatchEvent(new Event("check-changed"));let c=this.state.loading?(0,s.__)("Please wait... Loading related keywords. It can take up to a few minutes.","diagnoseo"):(0,e.createElement)("button",{className:"button get-related-keywords",onClick:this.handleLoadButtonClick},(0,s.__)("Get related keywords and Pro data","diagnoseo"));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"components-base-control__field add-keyword diagnoseo-related-keywords"},(0,e.createElement)(r.FormTokenField,{label:(0,e.createElement)("b",null,(0,s.__)("Related keywords","diagnoseo")),onChange:this.handleChange,value:l,maxLength:this.state.keywordLimit+10}),(0,e.createElement)("p",{className:"components-form-token-field__help"},(0,s.__)("Limits: 10 keywords in free, 100 keywords in Pro","diagnoseo")),(0,e.createElement)(r.SelectControl,{options:[{value:"ar",label:"Bahrain"},{value:"bg",label:"Bulgaria"},{value:"hr",label:"Croatia"},{value:"zh_TW",label:"Taiwan"},{value:"cs",label:"Czechia"},{value:"da",label:"Denmark"},{value:"nl",label:"Netherlands"},{value:"en",label:"United States"},{value:"fi",label:"Finland"},{value:"fr",label:"France"},{value:"de",label:"Austria"},{value:"el",label:"Cyprus"},{value:"he",label:"Israel"},{value:"hi",label:"India"},{value:"hu",label:"Hungary"},{value:"id",label:"Indonesia"},{value:"it",label:"Italy"},{value:"ja",label:"Japan"},{value:"ko",label:"South Korea"},{value:"lv",label:"Latvia"},{value:"lt",label:"Lithuania"},{value:"no",label:"Norway"},{value:"pl",label:"Poland"},{value:"pt",label:"Portugal"},{value:"ro",label:"Romania"},{value:"ru",label:"Russia"},{value:"sr",label:"Serbia"},{value:"sk",label:"Slovakia"},{value:"sl",label:"Slovenia"},{value:"es",label:"Argentina"},{value:"sv",label:"Sweden"},{value:"th",label:"Thailand"},{value:"tr",label:"Turkey"},{value:"uk",label:"Ukraine"},{value:"vi",label:"Vietnam"}],value:this.state.language,onChange:this.handleLangChange,label:(0,s.__)("Language","diagnoseo")}),(0,e.createElement)("p",null,c)))}}var w=(0,d.compose)((0,o.withSelect)((e=>{const t=e("core/editor").getEditedPostAttribute("featured_media");return{postTitle:e("core/editor").getEditedPostAttribute("title"),postContent:e("core/editor").getEditedPostContent(),featuredMedia:e("core").getMedia(t,{context:"embed"})||{}}})))((t=>(0,e.createElement)(h,{postTitle:t.postTitle,postContent:t.postContent,featuredMedia:t.featuredMedia,seoDataCollector:t.seoDataCollector}))),b=(0,d.compose)((0,o.withSelect)((e=>{if(!window.diagnoseoPro)return{};const t={categories:e("core/editor").getEditedPostAttribute("categories"),status:"publish",per_page:10,exclude:[e("core/editor").getEditedPostAttribute("id")]};return{suggestedPosts:wp.data.select("core").getEntityRecords("postType","post",t)||[]}})))((t=>{if(window.diagnoseoPro){var a="";return t.suggestedPosts.length?(a=t.suggestedPosts.map((t=>(0,e.createElement)("li",null,(0,e.createElement)("a",{href:t.link},t.title.raw)))),a=(0,e.createElement)("ol",null,a)):a=(0,e.createElement)("p",null,(0,s.__)("Could not prepare suggestions as there are no posts related to this one")),a}return(0,e.createElement)("p",null,(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))))})),_=(0,d.compose)((0,o.withDispatch)((e=>({setMetaValues:t=>{e("core/editor").editPost({meta:{diagnoseo_optimal_word_number:t.number_of_words.toString(),diagnoseo_optimal_keyword_density:t.focus_keyword_density.toString(),diagnoseo_optimal_heading_number:t.number_of_headings.toString(),diagnoseo_optimal_image_number:t.number_of_images.toString()}})}}))))((t=>{let a=window.diagnoseoPro?"DiagnoSEO Pro":"DiagnoSEO";return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.PluginSidebarMoreMenuItem,{target:"diagnoseo-content-analyzer"},(0,s.__)("DiagnoSEO Content Watcher","diagnoseo")),(0,e.createElement)(l.PluginSidebar,{title:a,name:"diagnoseo-content-analyzer"},(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Content analyzer","diagnoseo"),initialOpen:"true"},(0,e.createElement)(p,{sectionName:"content"})),(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Keyword placement","diagnoseo"),initialOpen:"true"},(0,e.createElement)(c,{fieldName:"diagnoseo_meta_keyword",label:(0,e.createElement)("b",null,(0,s.__)("Focus keyword","diagnoseo"))}),(0,e.createElement)(m,null),(0,e.createElement)(w,{seoDataCollector:t.setMetaValues}),(0,e.createElement)(p,{sectionName:"keyword"})),(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Internal linking suggestions","diagnoseo"),initialOpen:"true"},(0,e.createElement)(b,null))))}));(0,t.registerPlugin)("diagnoseo-sidebar",{icon:(0,e.createElement)(n,null),render:_})}();
     1!function(){"use strict";var e=window.wp.element,t=window.wp.plugins,a=function(){return(0,e.createElement)("svg",{"enable-background":"new 0 0 20 20",height:"20",width:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",className:"diagnoseo-icon"},(0,e.createElement)("clipPath",{id:"a"},(0,e.createElement)("path",{d:"m0 0h20v20h-20z"})),(0,e.createElement)("path",{className:"diagnoseo-icon-part-tick",d:"m12.377 5.866 1.835 1.612-4.839 5.508-4.11-3.576 1.672-1.902 2.256 1.982z"}),(0,e.createElement)("path",{className:"diagnoseo-icon-part-magnifier","clip-path":"url(#a)",d:"m16.298 15.209c1.745-1.983 2.548-4.603 2.208-7.228-.315-2.426-1.555-4.584-3.493-6.077s-4.341-2.139-6.768-1.828c-2.426.315-4.584 1.555-6.077 3.493s-2.142 4.341-1.827 6.767c.649 5.007 5.251 8.554 10.259 7.905 1.441-.188 2.824-.717 4.014-1.536l3.749 3.295 1.476-1.68zm-1.471-1.887c-1.111 1.443-2.72 2.368-4.527 2.602-1.808.235-3.598-.247-5.041-1.361-1.444-1.111-2.368-2.719-2.602-4.527-.483-3.73 2.158-7.158 5.889-7.642.296-.038.59-.057.881-.057 3.375 0 6.316 2.511 6.761 5.946.235 1.806-.249 3.596-1.361 5.039"}))},o=window.wp.data;class i extends React.Component{constructor(e){super(e),this.state={score:0,timeout:null},this.handleCheckChanged=this.handleCheckChanged.bind(this),this.calculateScore=this.calculateScore.bind(this),this.runAllChecks=this.runAllChecks.bind(this)}calculateScore(){const e=window.diagnoseo.checks.filter((e=>"check"===e.type));let t=e.length+1,a=e.filter((e=>e.checked)),o=window.diagnoseo.additionalKeywordCount===window.diagnoseo.RelatedKeywordsInPost?a.length+1:a.length,i=Math.round(100*o/t);this.setState({score:i})}runAllChecks(){const e=window.diagnoseo.checks.filter((e=>"check"===e.type)),t={postTitle:(0,o.select)("core/editor").getEditedPostAttribute("title"),postContent:(0,o.select)("core/editor").getEditedPostContent(),keyword:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,featuredImageId:(0,o.select)("core/editor").getEditedPostAttribute("featured_media"),featuredImage:(0,o.select)("core").getMedia((0,o.select)("core/editor").getEditedPostAttribute("featured_media")),metaTitle:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_title,metaDescription:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_description,slug:(0,o.select)("core/editor").getEditedPostAttribute("slug"),blocks:(0,o.select)("core/block-editor").getBlocks(),optimalKeywordDensity:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density,optimalWordNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_word_number,optimalHeadingNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_heading_number,optimalImageNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_image_number};if(!t.featuredImageId||t.featuredImage)t.metaTitle=seoHelper.replaceVariables(t.metaTitle)||(document.querySelector("#seo-title")?seoHelper.replaceVariables(document.querySelector("#seo-title").getAttribute("placeholder")):""),t.metaDescription=seoHelper.replaceVariables(t.metaDescription)||(document.querySelector("#seo-description")?seoHelper.replaceVariables(document.querySelector("#seo-description").value):""),e.forEach(((e,a)=>{if(!e.test)return;let o="ok"===e.test(t),i=window.diagnoseo.checks.findIndex((t=>t.id===e.id));window.diagnoseo.checks[i].checked=o})),this.calculateScore();else var a=setInterval((()=>{(0,o.select)("core").getMedia(t.featuredImageId)&&(clearInterval(a),this.runAllChecks())}),500)}handleCheckChanged(){clearTimeout(this.state.timeout),this.setState({timeout:setTimeout(this.calculateScore,300)})}async componentDidMount(){window.addEventListener("check-changed",this.handleCheckChanged),setTimeout(this.runAllChecks,1e3)}componentWillUnmount(){window.removeEventListener("check-changed",this.handleCheckChanged)}render(){let t,o=this.state.score;switch(!0){case o<60:t="score-low";break;case o>=60&&o<90:t="score-medium";break;case o>=90:t="score-high"}let i=`diagnoseo-button-content ${t}`;return(0,e.createElement)("span",{className:i},(0,e.createElement)(a,null),(0,e.createElement)("b",{className:"diagnoseo-score"},this.state.score,"/100"))}whenEditorIsReady(){return new Promise((e=>{const t=(0,o.subscribe)((()=>{((0,o.select)("core/editor").isCleanNewPost()||(0,o.select)("core/block-editor").getBlockCount()>0)&&(t(),e())}))}))}}var n=i,l=window.wp.editPost,r=window.wp.components,s=window.wp.i18n,d=window.wp.compose,c=(0,d.compose)((0,o.withDispatch)(((e,t)=>({setMetaValue:a=>{var o={};o[t.fieldName]=a,e("core/editor").editPost({meta:o}),t.changeCallback&&t.changeCallback(a)}}))),(0,o.withSelect)(((e,t)=>({metaValue:e("core/editor").getEditedPostAttribute("meta")[t.fieldName]}))))((t=>(0,e.createElement)(r.TextControl,{label:t.label,value:t.metaValue,onChange:e=>t.setMetaValue(e)}))),m=(0,d.compose)((0,o.withSelect)((e=>({content:e("core/editor").getEditedPostContent(),keyword:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,optimalKeywordDensity:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density}))))((t=>{var a=0;if(t.keyword){var o=t.content.replace(/<\!--.*?-->/g,""),i=(o=(o=o.replace(/(\r\n|\n|\r)/gm," ")).toLowerCase()).split(" ");i=i.filter((e=>""!==e));var n=seoHelper.countOccurences(t.keyword,o);n&&(a=(a=n/i.length*100).toFixed(2))}let l;if(window.diagnoseoPro){let o="diagnoseo-check optimal-keyword-density";parseFloat(t.optimalKeywordDensity),parseFloat(t.optimalKeywordDensity),o+=a>=1&&a<=3?" ok":" nok",l=(0,e.createElement)("p",{className:o},(0,s.__)("Optimal keyword density","diagnoseo")," ",(0,e.createElement)("b",{className:"value"},"1% - 3%"))}else l=(0,e.createElement)("p",{className:"diagnoseo-check optimal-keyword-density"},(0,e.createElement)("i",{className:"dashicons dashicons-lock"})," ",(0,s.__)("Optimal keyword density","diagnoseo"));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",{className:"diagnoseo-stats keyword-density"},(0,s.__)("Keyword density","diagnoseo")," ",(0,e.createElement)("b",{className:"value"},a,"%")),l)})),u=t=>{let a=["diagnoseo-check",t.id];if(t.test){let e=t.test(t.postData);"string"==typeof e&&a.push(e);let o="ok"===e,i=t.checkConfig.findIndex((e=>e.id===t.id));t.checkConfig[i].checked!==o&&window.dispatchEvent(new Event("check-changed")),t.checkConfig[i].checked=o}if(t.inPro)return(0,e.createElement)("p",{className:a.join(" ")},(0,e.createElement)("i",{className:"dashicons dashicons-lock"})," ",t.label," ",(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))));const o=t.valueFieldName&&t.postData[t.valueFieldName]?(0,e.createElement)("b",null,t.postData[t.valueFieldName]):"";return(0,e.createElement)("p",{className:a.join(" ")},t.label," ",o)},g=t=>{let a=["diagnoseo-stats",t.id];if(t.inPro)return(0,e.createElement)("p",{className:a.join(" ")},(0,e.createElement)("i",{className:"dashicons dashicons-lock"}),"  ",t.label," ",(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))));let o,i=(0,e.createElement)("b",{className:"value"}),n="";if(t.test){let o=t.test(t.postData);i=(0,e.createElement)("b",{className:"value"},o.value),n=o.comment?(0,e.createElement)("span",{className:"comment"},o.comment):"",o.status&&a.push(o.status)}return o=t.order&&"value label"!==t.order?(0,e.createElement)(e.Fragment,null,t.label," ",i," ",n):(0,e.createElement)(e.Fragment,null,i," ",t.label),(0,e.createElement)("p",{className:a.join(" ")},o)},p=(0,d.compose)((0,o.withSelect)((e=>({postTitle:e("core/editor").getEditedPostAttribute("title"),postContent:e("core/editor").getEditedPostContent(),featuredImage:e("core").getMedia(e("core/editor").getEditedPostAttribute("featured_media")),keyword:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,metaTitle:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_title,metaDescription:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_description,urlSlug:e("core/editor").getEditedPostAttribute("slug"),blocks:e("core/block-editor").getBlocks(),optimalKeywordDensity:2,optimalWordNumber:300,optimalHeadingNumber:1,optimalImageNumber:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_image_number,postType:e("core/editor").getCurrentPostType()}))))((t=>{const a=window.diagnoseo.checks,o=a.filter((e=>e.section===t.sectionName)),i={postTitle:t.postTitle,postContent:t.postContent,keyword:t.keyword,metaTitle:seoHelper.replaceVariables(t.metaTitle)||(document.querySelector("#seo-title")?seoHelper.replaceVariables(document.querySelector("#seo-title").getAttribute("placeholder")):""),metaDescription:seoHelper.replaceVariables(t.metaDescription)||(document.querySelector("#seo-description")?seoHelper.replaceVariables(document.querySelector("#seo-description").value):""),slug:t.urlSlug,blocks:t.blocks,featuredImage:t.featuredImage,optimalKeywordDensity:t.optimalKeywordDensity,optimalWordNumber:t.optimalWordNumber,optimalHeadingNumber:t.optimalHeadingNumber,optimalImageNumber:t.optimalImageNumber},n=o.map((o=>{let n=!0;if(o.postTypes&&(n=o.postTypes.includes(t.postType)),!o.hidden&&n)switch(o.type){case"check":return o.inPro?(0,e.createElement)(u,{id:o.id,label:o.label,inPro:o.inPro}):(0,e.createElement)(u,{id:o.id,label:o.label,test:o.test,postData:i,checkConfig:a,valueFieldName:o.valueFieldName});case"stats":return o.inPro?(0,e.createElement)(g,{id:o.id,label:o.label,inPro:o.inPro}):(0,e.createElement)(g,{id:o.id,label:o.label,test:o.test,order:o.order,postData:i})}}));return(0,e.createElement)(e.Fragment,null,n.map(((t,a)=>(0,e.createElement)(React.Fragment,{key:a},t))))}));class h extends React.Component{constructor(e){super(e),this.state={keyword:"",keywordList:[],keywordLimit:window.diagnoseoPro?window.diagnoseoPro.additionalKeywordLimit:window.diagnoseo.additionalKeywordLimit,apiKey:"",language:diagnoseo_settings?diagnoseo_settings.locale.substr(0,2):"",loading:!1},this.handleChange=this.handleChange.bind(this),this.handleLangChange=this.handleLangChange.bind(this),this.handleLoadButtonClick=this.handleLoadButtonClick.bind(this),this.relatedKeywordsApiUrl="diagnoseo/v1/related-keywords"}stripKeywordData(e){return(e=-1===e.indexOf("|")?e:e.substr(0,e.indexOf(" |"))).trim()}async loadRelatedKeywords(){const e=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,t=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_language;if(!e)return void alert((0,s.__)('Please enter the "focus keyword" first',"diagnoseo"));if(!this.state.language)return void alert((0,s.__)("Please select language.","diagnoseo"));this.setState({loading:!0});let a=await this.getRelatedKeywords(e,t);if(a=a.split(","),a.length){let e=this.state.keywordList;a.forEach((t=>{t={name:t.trim()};let a=e.findIndex((e=>e.name===t));-1===a?e.push(t):(e[a].repeat_min=t.repeat_min,e[a].repeat_max=t.repeat_max)})),this.saveKeywords(e)}this.setState({loading:!1})}saveKeywords(e){const t=[...new Set(e)];t.splice(this.state.keywordLimit),this.setState({keywordList:t}),window.onbeforeunload=null,(0,o.dispatch)("core/editor").editPost({meta:{diagnoseo_meta_additional_keywords:JSON.stringify(t)}})}saveLanguage(e){(0,o.dispatch)("core/editor").editPost({meta:{diagnoseo_meta_language:e}})}componentDidMount(){let e=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_additional_keywords,t=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_language;try{e=JSON.parse(e)}catch{e=""}this.setState({language:t,keyword:this.props.focusKeyword,keywordList:e||[]})}async handleLoadButtonClick(){window.diagnoseoPro?this.loadRelatedKeywords():alert((0,s.__)("Related keywords and Pro data require DiagnoSEO Pro.","diagnoseo"))}handleChange(e){const t=this.state.keywordList,{stripKeywordData:a}=this;let o=e.map((e=>{let o=a(e.value||e),i=t.findIndex((e=>o===e.name));return{name:o,repeat_min:-1!==i?t[i].repeat_min:0,repeat_max:-1!==i?t[i].repeat_max:0}}));this.saveKeywords(o)}handleLangChange(e){this.setState({language:e}),this.saveLanguage(e)}render(){let{postTitle:t,postContent:a,featuredMedia:o}=this.props;const{countOccurences:i}=seoHelper;let n=0,l=this.state.keywordList.map((e=>{let l=e.name||"",r="error",s=function(e){a=seoHelper.stripTags(a);let n=0;return n+=i(e,t),n+=i(e,a),n+=seoHelper.isKeywordInAnyAlt(e,a),n+=o?i(e,o.alt_text):0,n}(l);s&&(r=e.repeat_min&&e.repeat_max?s>=e.repeat_min&&s<=e.repeat_max?"success":"validating":"success",n++);let d=` | ${s}`;return e.repeat_min&&e.repeat_max&&(d+=` (${e.repeat_min} - ${e.repeat_max})`),{value:l+d,status:r}})),d=!1;window.diagnoseo.RelatedKeywordsInPost!==n&&(window.diagnoseo.RelatedKeywordsInPost=n,d=!0),window.diagnoseo.additionalKeywordCount!==l.length&&(window.diagnoseo.additionalKeywordCount=l.length,d=!0),d&&window.dispatchEvent(new Event("check-changed"));let c=this.state.loading?(0,s.__)("Please wait... Loading related keywords. It can take up to a few minutes.","diagnoseo"):(0,e.createElement)("button",{className:"button get-related-keywords",onClick:this.handleLoadButtonClick},(0,s.__)("Get related keywords and Pro data","diagnoseo"));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"components-base-control__field add-keyword diagnoseo-related-keywords"},(0,e.createElement)(r.FormTokenField,{label:(0,e.createElement)("b",null,(0,s.__)("Related keywords","diagnoseo")),onChange:this.handleChange,value:l,maxLength:this.state.keywordLimit+10}),(0,e.createElement)("p",{className:"components-form-token-field__help"},(0,s.__)("Limits: 10 keywords in free, 100 keywords in Pro","diagnoseo")),(0,e.createElement)(r.SelectControl,{options:[{value:"chinese",label:"Taiwan"},{value:"arabic",label:"Bahrain"},{value:"bulgarian",label:"Bulgaria"},{value:"croatian",label:"Croatia"},{value:"czech",label:"Czechia"},{value:"danish",label:"Denmark"},{value:"dutch",label:"Netherlands"},{value:"english",label:"United States"},{value:"finnish",label:"Finland"},{value:"french",label:"France"},{value:"austrian",label:"Austria"},{value:"greek",label:"Cyprus"},{value:"israeli",label:"Israel"},{value:"indian",label:"India"},{value:"hungarian",label:"Hungary"},{value:"indonesian",label:"Indonesia"},{value:"italian",label:"Italy"},{value:"japanese",label:"Japan"},{value:"korean",label:"South Korea"},{value:"latvian",label:"Latvia"},{value:"lithuanian",label:"Lithuania"},{value:"norwegian",label:"Norway"},{value:"polish",label:"Poland"},{value:"portugese",label:"Portugal"},{value:"romanian",label:"Romania"},{value:"russian",label:"Russia"},{value:"serbian",label:"Serbia"},{value:"slovak",label:"Slovakia"},{value:"slovenian",label:"Slovenia"},{value:"spanish",label:"Argentina"},{value:"swedish",label:"Sweden"},{value:"thai",label:"Thailand"},{value:"turkish",label:"Turkey"},{value:"ukrainian",label:"Ukraine"},{value:"vietnamese",label:"Vietnam"}],value:this.state.language,onChange:this.handleLangChange,label:(0,s.__)("Language","diagnoseo")}),(0,e.createElement)("p",null,c)))}getRelatedKeywords(e,t){return new Promise((a=>{const o=new FormData;o.append("keyword",e),o.append("language",t),o.append("count",30),fetch("/wp-json/diagnoseo/v1/related-keywords",{method:"POST",body:o}).then((e=>e.json())).then((e=>{"ok"===e.status?a(e.keywords):a("")})).catch((e=>{console.error(e),a("")}))}))}}var w=(0,d.compose)((0,o.withSelect)((e=>{const t=e("core/editor").getEditedPostAttribute("featured_media");return{postTitle:e("core/editor").getEditedPostAttribute("title"),postContent:e("core/editor").getEditedPostContent(),featuredMedia:e("core").getMedia(t,{context:"embed"})||{}}})))((t=>(0,e.createElement)(h,{postTitle:t.postTitle,postContent:t.postContent,featuredMedia:t.featuredMedia,seoDataCollector:t.seoDataCollector}))),b=(0,d.compose)((0,o.withSelect)((e=>{if(!window.diagnoseoPro)return{};const t={categories:e("core/editor").getEditedPostAttribute("categories"),status:"publish",per_page:10,exclude:[e("core/editor").getEditedPostAttribute("id")]};return{suggestedPosts:wp.data.select("core").getEntityRecords("postType","post",t)||[]}})))((t=>{if(window.diagnoseoPro){var a="";return t.suggestedPosts.length?(a=t.suggestedPosts.map((t=>(0,e.createElement)("li",null,(0,e.createElement)("a",{href:t.link},t.title.raw)))),a=(0,e.createElement)("ol",null,a)):a=(0,e.createElement)("p",null,(0,s.__)("Could not prepare suggestions as there are no posts related to this one")),a}return(0,e.createElement)("p",null,(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))))})),_=(0,d.compose)((0,o.withDispatch)((e=>({setMetaValues:t=>{e("core/editor").editPost({meta:{diagnoseo_optimal_word_number:t.number_of_words.toString(),diagnoseo_optimal_keyword_density:t.focus_keyword_density.toString(),diagnoseo_optimal_heading_number:t.number_of_headings.toString(),diagnoseo_optimal_image_number:t.number_of_images.toString()}})}}))))((t=>{let a=window.diagnoseoPro?"DiagnoSEO Pro":"DiagnoSEO";return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.PluginSidebarMoreMenuItem,{target:"diagnoseo-content-analyzer"},(0,s.__)("DiagnoSEO Content Watcher","diagnoseo")),(0,e.createElement)(l.PluginSidebar,{title:a,name:"diagnoseo-content-analyzer"},(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Content analyzer","diagnoseo"),initialOpen:"true"},(0,e.createElement)(p,{sectionName:"content"})),(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Keyword placement","diagnoseo"),initialOpen:"true"},(0,e.createElement)(c,{fieldName:"diagnoseo_meta_keyword",label:(0,e.createElement)("b",null,(0,s.__)("Focus keyword","diagnoseo"))}),(0,e.createElement)(m,null),(0,e.createElement)(w,{seoDataCollector:t.setMetaValues}),(0,e.createElement)(p,{sectionName:"keyword"})),(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Internal linking suggestions","diagnoseo"),initialOpen:"true"},(0,e.createElement)(b,null))))}));(0,t.registerPlugin)("diagnoseo-sidebar",{icon:(0,e.createElement)(n,null),render:_})}();
  • diagnoseo/tags/1.2.16/js/diagnoseo-checks.min.js

    r2920588 r2984954  
    1 const{__}=window.wp.i18n;window.diagnoseo={additionalKeywordLimit:10,additionalKeywordCount:0,RelatedKeywordsInPost:0,checks:[{id:"title-not-too-long",type:"check",label:__("Title not too long"),section:"content",test:e=>{var{metaTitle:t,postTitle:e}=e;if(!t&&!e)return"nok";t=t||e;const o=document.querySelector(".title-sample");o.textContent=t;e=o.clientWidth,t=t.length;return e<=600?60<t?"nok medium-nok":t<=60?"ok":"nok":"nok"}},{id:"title-not-too-short",type:"check",label:__("Title not too short"),section:"content",test:e=>{var{metaTitle:t,postTitle:e}=e;if(!t&&!e)return"nok";e=(t||e).length;return 30<=e?30<=e&&e<35?"nok medium-nok":35<=e?"ok":"nok":"nok"}},{id:"description-not-too-long",type:"check",label:__("Description not too long"),section:"content",test:e=>{var{metaDescription:t}=e;if(!t)return"nok";e=document.querySelector(".description-sample"),t=t.length;if(e.clientWidth<=990){if(155<t)return"nok medium-nok";if(t<=155)return"ok"}return"nok"}},{id:"description-not-too-short",type:"check",label:__("Description not too short"),section:"content",test:e=>{var{metaDescription:e}=e;if(!e)return"nok";e=e.length;if(70<=e){if(e<130)return"nok medium-nok";if(130<=e)return"ok"}return"nok"}},{id:"too-long-sentences",type:"check",label:__("No sentences with more than 20 words"),section:"content",test:e=>{var{postContent:e}=e;e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll("</p>",".</p>")).replaceAll("</h1>",".</h1>")).replaceAll("</h2>",".</h2>")).replaceAll("</h3>",".</h3>")).replaceAll("</h4>",".</h4>")).replaceAll("</h5>",".</h5>")).replaceAll("</h6>",".</h6>")).replaceAll("</li>",".</li>");const t=(e=seoHelper.stripTags(e)).split(/\.|\?|!/);var o=!1;return t.length&&t.forEach(e=>{o=o||20<seoHelper.countWords(e)}),o?"nok":"ok"}},{id:"too-many-words",type:"check",label:__("No paragraphs with more than 100 words"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("p");var n=!1;return o.length&&o.forEach(e=>{100<seoHelper.countWords(e.textContent)&&(n=!0)}),n?"nok":"ok"}},{id:"too-many-sentences",type:"check",label:__("No paragraphs with more than 5 sentences"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("p");var n=!1;return o.length&&o.forEach(e=>{5<e.textContent.split(/\.|\?|!/).filter(e=>!!e.trim()).length&&(n=!0)}),n?"nok":"ok"}},{id:"internal-links-present",type:"check",label:__("Contains internal links"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("a");var n=!1;return o.forEach(e=>{e=e.getAttribute("href")||"";e&&(e.includes("http://"+window.location.hostname)||e.includes("https://"+window.location.hostname)||"/"===e.substr(0,1)||"./"===e.substr(0,2))&&(n=!0)}),n?"ok":"nok"}},{id:"strong-present",type:"check",label:__("Contains bold text (strong tag)"),section:"content",test:e=>seoHelper.countElements(e.postContent,"strong")?"ok":"nok"},{id:"readability",type:"stats",label:__("Readability score"),order:"label value comment",section:"content",test:e=>{var{postContent:t}=e,o=(t=seoHelper.stripTags(t)).split(/\.|\?|!/);o=(o=o.map(e=>e.trim())).filter(e=>e&&" "!==e&&"\n"!==e);e=(t=t.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/g," ")).split(" ");e=(e=e.map(e=>e.trim())).filter(e=>e&&""!==e&&"\n"!==e);var t=seoHelper.countSyllables(t),n=206.835-e.length/o.length*1.015-t/e.length*84.6;(n=n.toFixed(2))<0?n=0:100<n&&(n=100);var r="",s="";switch(!0){case isNaN(n):n=__("N/A"),r="",s="nok";break;case 90<n:r=__("Very easy to read","diagnoseo"),s="ok";break;case 80<n&&n<=90:r=__("Easy to read","diagnoseo"),s="ok";break;case 70<n&&n<=80:r=__("Fairly easy to read","diagnoseo"),s="ok";break;case 60<n&&n<=70:r=__("Average reading ease","diagnoseo"),s="nok medium-nok";break;case 50<n&&n<=60:r=__("Fairly difficult to read","diagnoseo"),s="nok";break;case 30<n&&n<=50:r=__("Difficult to read","diagnoseo"),s="nok";break;case 10<n&&n<=30:r=__("Very difficult to read","diagnoseo"),s="nok";break;case n<=10:r=__("Extremely difficult to read","diagnoseo"),s="nok"}return{value:n,comment:r=r&&` (${r})`,status:s}}},{id:"est-reading-time",type:"stats",label:__("Estimated reading time"),section:"content",order:"label value",test:e=>{var{postContent:t}=e,e=seoHelper.countWords(t),t=Math.floor(e/225),e=Math.floor(e%225/3.75);return{value:`${t} ${__("min")} ${e} ${__("s")}`}}},{id:"minimal-word-count",type:"check",label:__("Minimal word count"),section:"content",postTypes:["post","page"],inPro:!0},{id:"words",type:"stats",label:__("words"),section:"content",test:e=>{var{postContent:e}=e;return{value:seoHelper.countWords(e)}}},{id:"optimal-word-number",type:"check",label:__("Optimal number of words"),inPro:!0,section:"content"},{id:"chars",type:"stats",label:__("characters"),section:"content",test:e=>({value:e.postContent.length||0})},{id:"sentences",type:"stats",label:__("sentences"),section:"content",test:e=>{var{postContent:e}=e,e=(e=e.replace(/(\r\n|\n|\r)/gm," ")).split(/\.|\?|!/);return{value:(e=(e=e.map(e=>e.trim())).filter(e=>e&&" "!==e&&"\n"!==e)).length||0}}},{id:"paragraphs",type:"stats",label:__("paragraphs"),section:"content",test:e=>({value:seoHelper.countElements(e.postContent,"p")})},{id:"headings",type:"stats",label:__("Headings"),inPro:!0,section:"content"},{id:"optimal-heading-number",type:"check",label:__("Optimal number of headings"),inPro:!0,section:"content"},{id:"images",type:"stats",label:__("Images"),inPro:!0,section:"content"},{id:"optimal-image-number",type:"check",label:__("Optimal number of images"),inPro:!0,section:"content"},{id:"too-long-headings",type:"check",label:__("No too long headings"),inPro:!0,section:"content"},{id:"toc-block",type:"check",label:__("Use Table of Contents block"),inPro:!0,section:"content"},{id:"keyword-exists",type:"check",label:__("Keyword is provided"),section:"keyword",test:e=>e.keyword?"ok":"nok"},{id:"keyword-unique",type:"check",label:__("Focus Keyword not used before"),section:"keyword",test:async o=>{var n=document.querySelector(".keyword-unique");if(o.keyword){let e=new URLSearchParams(window.location.search);var r=Object.fromEntries(e.entries()),r=`${diagnoseoRestUrl}diagnoseo/v1/check-posts-keyword/${o.keyword}/${r.post||0}`;let t=0===await(await fetch(r)).json()?"ok":"nok";n?n&&(n.classList.remove("ok","nok"),n.classList.add(t)):setTimeout(()=>{(n=document.querySelector(".keyword-unique"))&&(n.classList.remove("ok","nok"),n.classList.add(t))},200)}else n&&n.classList.add("ok")}},{id:"keyword-in-title",type:"check",label:__("Keyword present in title tag"),section:"keyword",test:e=>{var{keyword:t,postTitle:o,metaTitle:e}=e;return seoHelper.isKeywordInText(t,e||o)?"ok":"nok"}},{id:"keyword-in-title-beginning",type:"check",label:__("Keyword in the beginning of the title tag"),section:"keyword",test:e=>{var{keyword:t,postTitle:o,metaTitle:e}=e;if(!t)return"nok";o=(o=e||o).toLowerCase(),t=t.toLowerCase();const n=new RegExp("^"+t);return n.test(o)?"ok":"nok"}},{id:"keyword-in-descr",type:"check",label:__("Keyword present in meta description tag"),section:"keyword",test:e=>{var{keyword:t,metaDescription:e}=e;return seoHelper.isKeywordInText(t,e)?"ok":"nok"}},{id:"keyword-in-slug",type:"check",label:__("Keyword present in URL slug"),section:"keyword",test:e=>{var{keyword:t,slug:o,postTitle:e}=e;return t&&(o=o||seoHelper.slugify(e)).includes(seoHelper.slugify(t))?"ok":"nok"}},{id:"slug-length-ok",type:"check",label:__("URL slug length"),section:"keyword",test:e=>{var{slug:t,postTitle:e}=e;if(!t&&!e)return"nok";if((t=t||seoHelper.slugify(e)).length<=60&&t.split("-").length<=5)return"ok";return"nok"}},{id:"keyword-in-h1",type:"check",label:__("Keyword present in H1 element"),section:"keyword",test:e=>{var{keyword:t,postContent:o,postTitle:e}=e;return seoHelper.isKeywordInText(t,e)||seoHelper.isKeywordInAnyElement(t,o,"h1")?"ok":"nok"}},{id:"keyword-in-image-alt",type:"check",label:__("Keyword present in any image alt attribute"),section:"keyword",test:e=>{var{keyword:t,postContent:o,featuredImage:e}=e;return seoHelper.isKeywordInAnyAlt(t,o,e)?"ok":"nok"}},{id:"keyword-in-image-filename",type:"check",label:__("Keyword in image file name"),section:"keyword",inPro:!0,hidden:!0},{id:"keyword-not-in-ext-link",type:"check",label:__("Keyword NOT present in external link text"),section:"keyword",test:e=>{const{keyword:o,postContent:t}=e;if(!o)return"ok";const n=seoHelper.createMarkupEl(t);var r=!1;const s=n.querySelectorAll("a");return s.forEach(e=>{const t=e.getAttribute("href")||"";t.includes("http://"+window.location.hostname)||t.includes("https://"+window.location.hostname)||"/"===t.substr(0,1)||"./"===t.substr(0,2)||!seoHelper.isKeywordInText(o,e.textContent)||(r=!0)}),r?"nok":"ok"}},{id:"keyword-in-first-words",type:"check",label:__("Keyword present within first 100 words"),section:"keyword",test:e=>{var{keyword:t,postContent:e}=e;if(!t)return"nok";var t=t.trim(),o=(e=seoHelper.stripTags(e)).toLowerCase().split(/\s|\n/),n=100<=(o=o.filter(e=>e)).length?100:o.length;if(o=o.splice(0,n),!seoHelper.isKeywordInText(t,o.join(" ")))return"nok";if(1<t.split(" ").length)return"ok";if(o.length)for(let e=0;e<n;e++)o[e]=o[e].replace(".",""),o[e]=o[e].replace(",",""),o[e]=o[e].replace("?",""),o[e]=o[e].replace("!",""),o[e]=o[e].replace(":",""),o[e]=o[e].replace(";","");return o.includes(t)?"ok":"nok"}},{id:"more",type:"check",label:__("Many more powerful SEO checkpoints"),inPro:!0,section:"content"},{id:"more",type:"check",label:__("Many more powerful SEO checkpoints"),inPro:!0,section:"keyword"}],checkResults:{}};
     1const{__}=window.wp.i18n;window.diagnoseo={additionalKeywordLimit:10,additionalKeywordCount:0,RelatedKeywordsInPost:0,checks:[{id:"title-not-too-long",type:"check",label:__("Title not too long"),section:"content",test:e=>{var{metaTitle:t,postTitle:e}=e;if(!t&&!e)return"nok";t=t||e;const o=document.querySelector(".title-sample");o.textContent=t;e=o.clientWidth,t=t.length;return e<=600?60<t?"nok medium-nok":t<=60?"ok":"nok":"nok"}},{id:"title-not-too-short",type:"check",label:__("Title not too short"),section:"content",test:e=>{var{metaTitle:t,postTitle:e}=e;if(!t&&!e)return"nok";e=(t||e).length;return 30<=e?30<=e&&e<35?"nok medium-nok":35<=e?"ok":"nok":"nok"}},{id:"description-not-too-long",type:"check",label:__("Description not too long"),section:"content",test:e=>{var{metaDescription:t}=e;if(!t)return"nok";e=document.querySelector(".description-sample"),t=t.length;if(e.clientWidth<=990){if(155<t)return"nok medium-nok";if(t<=155)return"ok"}return"nok"}},{id:"description-not-too-short",type:"check",label:__("Description not too short"),section:"content",test:e=>{var{metaDescription:e}=e;if(!e)return"nok";e=e.length;if(70<=e){if(e<130)return"nok medium-nok";if(130<=e)return"ok"}return"nok"}},{id:"too-long-sentences",type:"check",label:__("No sentences with more than 20 words"),section:"content",test:e=>{var{postContent:e}=e;e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll("</p>",".</p>")).replaceAll("</h1>",".</h1>")).replaceAll("</h2>",".</h2>")).replaceAll("</h3>",".</h3>")).replaceAll("</h4>",".</h4>")).replaceAll("</h5>",".</h5>")).replaceAll("</h6>",".</h6>")).replaceAll("</li>",".</li>");const t=(e=seoHelper.stripTags(e)).split(/\.|\?|!/);var o=!1;return t.length&&t.forEach(e=>{o=o||20<seoHelper.countWords(e)}),o?"nok":"ok"}},{id:"too-many-words",type:"check",label:__("No paragraphs with more than 100 words"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("p");var n=!1;return o.length&&o.forEach(e=>{100<seoHelper.countWords(e.textContent)&&(n=!0)}),n?"nok":"ok"}},{id:"too-many-sentences",type:"check",label:__("No paragraphs with more than 5 sentences"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("p");var n=!1;return o.length&&o.forEach(e=>{5<e.textContent.split(/\.|\?|!/).filter(e=>!!e.trim()).length&&(n=!0)}),n?"nok":"ok"}},{id:"internal-links-present",type:"check",label:__("Contains internal links"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("a");var n=!1;return o.forEach(e=>{e=e.getAttribute("href")||"";e&&(e.includes("http://"+window.location.hostname)||e.includes("https://"+window.location.hostname)||"/"===e.substr(0,1)||"./"===e.substr(0,2))&&(n=!0)}),n?"ok":"nok"}},{id:"strong-present",type:"check",label:__("Contains bold text (strong tag)"),section:"content",test:e=>seoHelper.countElements(e.postContent,"strong")?"ok":"nok"},{id:"readability",type:"stats",label:__("Readability score"),order:"label value comment",section:"content",test:e=>{var{postContent:t}=e,o=(t=seoHelper.stripTags(t)).split(/\.|\?|!/);o=(o=o.map(e=>e.trim())).filter(e=>e&&" "!==e&&"\n"!==e);e=(t=t.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/g," ")).split(" ");e=(e=e.map(e=>e.trim())).filter(e=>e&&""!==e&&"\n"!==e);var t=seoHelper.countSyllables(t),n=206.835-e.length/o.length*1.015-t/e.length*84.6;(n=n.toFixed(2))<0?n=0:100<n&&(n=100);var r="",s="";switch(!0){case isNaN(n):n=__("N/A"),r="",s="nok";break;case 90<n:r=__("Very easy to read","diagnoseo"),s="ok";break;case 80<n&&n<=90:r=__("Easy to read","diagnoseo"),s="ok";break;case 70<n&&n<=80:r=__("Fairly easy to read","diagnoseo"),s="ok";break;case 60<n&&n<=70:r=__("Average reading ease","diagnoseo"),s="nok medium-nok";break;case 50<n&&n<=60:r=__("Fairly difficult to read","diagnoseo"),s="nok";break;case 30<n&&n<=50:r=__("Difficult to read","diagnoseo"),s="nok";break;case 10<n&&n<=30:r=__("Very difficult to read","diagnoseo"),s="nok";break;case n<=10:r=__("Extremely difficult to read","diagnoseo"),s="nok"}return{value:n,comment:r=r&&` (${r})`,status:s}}},{id:"est-reading-time",type:"stats",label:__("Estimated reading time"),section:"content",order:"label value",test:e=>{var{postContent:t}=e,e=seoHelper.countWords(t),t=Math.floor(e/225),e=Math.floor(e%225/3.75);return{value:`${t} ${__("min")} ${e} ${__("s")}`}}},{id:"minimal-word-count",type:"check",label:__("Minimal word count"),section:"content",postTypes:["post","page"],inPro:!0},{id:"words",type:"stats",label:__("words"),section:"content",test:e=>{var{postContent:e}=e;return{value:seoHelper.countWords(e)}}},{id:"chars",type:"stats",label:__("characters"),section:"content",test:e=>({value:e.postContent.length||0})},{id:"sentences",type:"stats",label:__("sentences"),section:"content",test:e=>{var{postContent:e}=e,e=(e=e.replace(/(\r\n|\n|\r)/gm," ")).split(/\.|\?|!/);return{value:(e=(e=e.map(e=>e.trim())).filter(e=>e&&" "!==e&&"\n"!==e)).length||0}}},{id:"paragraphs",type:"stats",label:__("paragraphs"),section:"content",test:e=>({value:seoHelper.countElements(e.postContent,"p")})},{id:"headings",type:"stats",label:__("Headings"),inPro:!0,section:"content"},{id:"optimal-heading-number",type:"check",label:__("Optimal number of headings"),inPro:!0,section:"content"},{id:"images",type:"stats",label:__("Images"),inPro:!0,section:"content"},{id:"optimal-image-number",type:"check",label:__("Optimal number of images"),inPro:!0,section:"content"},{id:"too-long-headings",type:"check",label:__("No too long headings"),inPro:!0,section:"content"},{id:"toc-block",type:"check",label:__("Use Table of Contents block"),inPro:!0,section:"content"},{id:"keyword-exists",type:"check",label:__("Keyword is provided"),section:"keyword",test:e=>e.keyword?"ok":"nok"},{id:"keyword-unique",type:"check",label:__("Focus Keyword not used before"),section:"keyword",test:async o=>{var n=document.querySelector(".keyword-unique");if(o.keyword){let e=new URLSearchParams(window.location.search);var r=Object.fromEntries(e.entries()),r=`${diagnoseoRestUrl}diagnoseo/v1/check-posts-keyword/${o.keyword}/${r.post||0}`;let t=0===await(await fetch(r)).json()?"ok":"nok";n?n&&(n.classList.remove("ok","nok"),n.classList.add(t)):setTimeout(()=>{(n=document.querySelector(".keyword-unique"))&&(n.classList.remove("ok","nok"),n.classList.add(t))},200)}else n&&n.classList.add("ok")}},{id:"keyword-in-title",type:"check",label:__("Keyword present in title tag"),section:"keyword",test:e=>{var{keyword:t,postTitle:o,metaTitle:e}=e;return seoHelper.isKeywordInText(t,e||o)?"ok":"nok"}},{id:"keyword-in-title-beginning",type:"check",label:__("Keyword in the beginning of the title tag"),section:"keyword",test:e=>{var{keyword:t,postTitle:o,metaTitle:e}=e;if(!t)return"nok";o=(o=e||o).toLowerCase(),t=t.toLowerCase();const n=new RegExp("^"+t);return n.test(o)?"ok":"nok"}},{id:"keyword-in-descr",type:"check",label:__("Keyword present in meta description tag"),section:"keyword",test:e=>{var{keyword:t,metaDescription:e}=e;return seoHelper.isKeywordInText(t,e)?"ok":"nok"}},{id:"keyword-in-slug",type:"check",label:__("Keyword present in URL slug"),section:"keyword",test:e=>{var{keyword:t,slug:o,postTitle:e}=e;return t&&(o=o||seoHelper.slugify(e)).includes(seoHelper.slugify(t))?"ok":"nok"}},{id:"slug-length-ok",type:"check",label:__("URL slug length"),section:"keyword",test:e=>{var{slug:t,postTitle:e}=e;if(!t&&!e)return"nok";if((t=t||seoHelper.slugify(e)).length<=60&&t.split("-").length<=5)return"ok";return"nok"}},{id:"keyword-in-h1",type:"check",label:__("Keyword present in H1 element"),section:"keyword",test:e=>{var{keyword:t,postContent:o,postTitle:e}=e;return seoHelper.isKeywordInText(t,e)||seoHelper.isKeywordInAnyElement(t,o,"h1")?"ok":"nok"}},{id:"keyword-in-image-alt",type:"check",label:__("Keyword present in any image alt attribute"),section:"keyword",test:e=>{var{keyword:t,postContent:o,featuredImage:e}=e;return seoHelper.isKeywordInAnyAlt(t,o,e)?"ok":"nok"}},{id:"keyword-in-image-filename",type:"check",label:__("Keyword in image file name"),section:"keyword",inPro:!0,hidden:!0},{id:"keyword-not-in-ext-link",type:"check",label:__("Keyword NOT present in external link text"),section:"keyword",test:e=>{const{keyword:o,postContent:t}=e;if(!o)return"ok";const n=seoHelper.createMarkupEl(t);var r=!1;const s=n.querySelectorAll("a");return s.forEach(e=>{const t=e.getAttribute("href")||"";t.includes("http://"+window.location.hostname)||t.includes("https://"+window.location.hostname)||"/"===t.substr(0,1)||"./"===t.substr(0,2)||!seoHelper.isKeywordInText(o,e.textContent)||(r=!0)}),r?"nok":"ok"}},{id:"keyword-in-first-words",type:"check",label:__("Keyword present within first 100 words"),section:"keyword",test:e=>{var{keyword:t,postContent:e}=e;if(!t)return"nok";var t=t.trim(),o=(e=seoHelper.stripTags(e)).toLowerCase().split(/\s|\n/),n=100<=(o=o.filter(e=>e)).length?100:o.length;if(o=o.splice(0,n),!seoHelper.isKeywordInText(t,o.join(" ")))return"nok";if(1<t.split(" ").length)return"ok";if(o.length)for(let e=0;e<n;e++)o[e]=o[e].replace(".",""),o[e]=o[e].replace(",",""),o[e]=o[e].replace("?",""),o[e]=o[e].replace("!",""),o[e]=o[e].replace(":",""),o[e]=o[e].replace(";","");return o.includes(t)?"ok":"nok"}},{id:"more",type:"check",label:__("Many more powerful SEO checkpoints"),inPro:!0,section:"content"},{id:"more",type:"check",label:__("Many more powerful SEO checkpoints"),inPro:!0,section:"keyword"}],checkResults:{}};
  • diagnoseo/tags/1.2.16/readme.txt

    r2963171 r2984954  
    33Tags: SEO, AI, ChatGPT, GPT, OpenAI, schema, XML sitemap, content analysis, breadcrumbs, meta title, meta description, readability, open graph, knowledge graph, google analytics, rich snippets, google, twitter card, performance, sitemap, redirection, woocommerce seo, local seo, seo audit, seo plugin, canonical, robots, content, metatags, indexnow, schema.org
    44Requires at least: 4.7
    5 Tested up to: 6.2.2
    6 Stable tag: 1.2.15
     5Tested up to: 6.3.2
     6Stable tag: 1.2.16
    77Requires PHP: 5.0
    88License: GPLv2 or later
  • diagnoseo/trunk/diagnoseo.php

    r2963171 r2984954  
    44 * Plugin URI: https://diagnoseo.com/wordpress-seo-plugin/
    55 * Description: Powerful SEO plugin for WordPress. The most lightweight and complete SEO solution on the market! It includes best-in-class content analyzer and keyword placement checkpoints.
    6  * Version: 1.2.15
     6 * Version: 1.2.16
    77 * Author: DiagnoSEO
    88 * Author URI: https://diagnoseo.com/
     
    178178        // only post editor.
    179179        if ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) {
     180            require_once DIAGNOSEO_INCLUDES_PATH . 'api-endpoints.php';
    180181            require_once DIAGNOSEO_INCLUDES_PATH . 'content-watcher-meta.php';
    181             require_once DIAGNOSEO_INCLUDES_PATH . 'api-endpoints.php';
    182182            require_once DIAGNOSEO_INCLUDES_PATH . 'class-diagnoseo-settingshelper.php';
    183183            require_once DIAGNOSEO_INCLUDES_PATH . 'blocks.php';
     
    186186            require_once DIAGNOSEO_INCLUDES_PATH . 'css-variables.php';
    187187            require_once DIAGNOSEO_INCLUDES_PATH . 'content-watcher-scripts.php';
    188             require_once DIAGNOSEO_INCLUDES_PATH . 'api-endpoints.php';
     188            require_once DIAGNOSEO_INCLUDES_PATH . 'openai.php';
     189            require_once DIAGNOSEO_INCLUDES_PATH . 'related-keywords.php';
    189190        }
    190191    } else {
  • diagnoseo/trunk/includes/class-diagnoseo-breadcrumbs.php

    r2920588 r2984954  
    497497    public function render_schema() {
    498498        $this->build_structured_data();
     499        if ( empty( $this->schema ) ) {
     500            return;
     501        }
    499502        ?>
    500         <script type="application/ld+json">
     503    <script type="application/ld+json">
    501504        <?php echo wp_json_encode( $this->schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); ?>
    502         </script>
     505    </script>
    503506        <?php
    504507    }
  • diagnoseo/trunk/includes/class-diagnoseo-generalsettings.php

    r2825827 r2984954  
    1414 */
    1515class Diagnoseo_GeneralSettings {
     16
     17    /**
     18     * Option group name
     19     *
     20     * @var $option_group
     21     */
     22    private $option_group = 'diagnoseo_general_options';
    1623
    1724    /**
     
    174181        add_option( 'diagnoseo_redirect_attachment', true );
    175182        register_setting(
    176             'diagnoseo_general_options',
     183            $this->option_group,
    177184            'diagnoseo_redirect_attachment',
    178185            array(
     
    189196            add_option( $index_name, 'index' );
    190197            register_setting(
    191                 'diagnoseo_general_options',
     198                $this->option_group,
    192199                $index_name,
    193200                array(
     
    200207            add_option( $follow_name, 'follow' );
    201208            register_setting(
    202                 'diagnoseo_general_options',
     209                $this->option_group,
    203210                $follow_name,
    204211                array(
     
    213220        add_option( 'diagnoseo_author_index', 'index' );
    214221        register_setting(
    215             'diagnoseo_general_options',
     222            $this->option_group,
    216223            'diagnoseo_author_index',
    217224            array(
     
    224231        add_option( 'diagnoseo_author_follow', 'follow' );
    225232        register_setting(
    226             'diagnoseo_general_options',
     233            $this->option_group,
    227234            'diagnoseo_author_follow',
    228235            array(
     
    235242        add_option( 'diagnoseo_tag_index', 'index' );
    236243        register_setting(
    237             'diagnoseo_general_options',
     244            $this->option_group,
    238245            'diagnoseo_tag_index',
    239246            array(
     
    246253        add_option( 'diagnoseo_tag_follow', 'follow' );
    247254        register_setting(
    248             'diagnoseo_general_options',
     255            $this->option_group,
    249256            'diagnoseo_tag_follow',
    250257            array(
     
    258265        add_option( 'diagnoseo_date_archive_index', 'noindex' );
    259266        register_setting(
    260             'diagnoseo_general_options',
     267            $this->option_group,
    261268            'diagnoseo_date_archive_index',
    262269            array(
     
    269276        add_option( 'diagnoseo_date_archive_follow', 'follow' );
    270277        register_setting(
    271             'diagnoseo_general_options',
     278            $this->option_group,
    272279            'diagnoseo_date_archive_follow',
    273280            array(
     
    280287        add_option( 'diagnoseo_archive_index', 'index' );
    281288        register_setting(
    282             'diagnoseo_general_options',
     289            $this->option_group,
    283290            'diagnoseo_archive_index',
    284291            array(
     
    291298        add_option( 'diagnoseo_archive_follow', 'follow' );
    292299        register_setting(
    293             'diagnoseo_general_options',
     300            $this->option_group,
    294301            'diagnoseo_archive_follow',
    295302            array(
     
    302309        add_option( 'diagnoseo_fix_category_url_base', false );
    303310        register_setting(
    304             'diagnoseo_general_options',
     311            $this->option_group,
    305312            'diagnoseo_fix_category_url_base',
    306313            array(
     
    313320        add_option( 'diagnoseo_sitemap_lastmod', true );
    314321        register_setting(
    315             'diagnoseo_general_options',
     322            $this->option_group,
    316323            'diagnoseo_sitemap_lastmod',
    317324            array(
     
    325332            add_option( 'diagnoseo_fix_product_cat_url_base', false );
    326333            register_setting(
    327                 'diagnoseo_general_options',
     334                $this->option_group,
    328335                'diagnoseo_fix_product_cat_url_base',
    329336                array(
  • diagnoseo/trunk/includes/class-diagnoseo-settings.php

    r2928487 r2984954  
    108108            array( $this, 'render_settings' )
    109109        );
     110        add_submenu_page(
     111            'diagnoseo-settings',
     112            __( 'Breadcrumbs', 'diagnoseo' ),
     113            __( 'Breadcrumbs', 'diagnoseo' ),
     114            'manage_options',
     115            '/customize.php?autofocus[section]=diagnoseo_breadcrumbs'
     116        );
    110117    }
    111118
  • diagnoseo/trunk/includes/content-watcher-meta.php

    r2920588 r2984954  
    3232        '',
    3333        'diagnoseo_meta_additional_keywords',
     34        array(
     35            'auth_callback'     => function() {
     36                return current_user_can( 'edit_posts' );
     37            },
     38            'sanitize_callback' => 'sanitize_text_field',
     39            'show_in_rest'      => true,
     40            'single'            => true,
     41            'type'              => 'string',
     42        )
     43    );
     44
     45    register_post_meta(
     46        '',
     47        'diagnoseo_meta_language',
    3448        array(
    3549            'auth_callback'     => function() {
  • diagnoseo/trunk/includes/structured-data.php

    r2920588 r2984954  
    6363            $schema->url           = get_the_permalink( $post_data->ID );
    6464            $schema->headline      = $post_data->post_title;
    65             $schema->commentCount  = get_comment_count( $post_data->ID )['total_comments']; // phpcs:ignore
     65            $schema->commentCount  = get_comment_count( $post_data->ID )['approved']; // phpcs:ignore
    6666            $schema->datePublished = get_the_date( 'Y-m-d', $post_data->ID ); // phpcs:ignore
     67            if ( has_post_thumbnail( $post_data->ID ) ) {
     68                $schema->image = get_the_post_thumbnail_url( $post_data->ID );
     69            }
    6770
    6871            $schema->author        = new stdClass();
  • diagnoseo/trunk/js/build/index.js

    r2920588 r2984954  
    1 !function(){"use strict";var e=window.wp.element,t=window.wp.plugins,a=function(){return(0,e.createElement)("svg",{"enable-background":"new 0 0 20 20",height:"20",width:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",className:"diagnoseo-icon"},(0,e.createElement)("clipPath",{id:"a"},(0,e.createElement)("path",{d:"m0 0h20v20h-20z"})),(0,e.createElement)("path",{className:"diagnoseo-icon-part-tick",d:"m12.377 5.866 1.835 1.612-4.839 5.508-4.11-3.576 1.672-1.902 2.256 1.982z"}),(0,e.createElement)("path",{className:"diagnoseo-icon-part-magnifier","clip-path":"url(#a)",d:"m16.298 15.209c1.745-1.983 2.548-4.603 2.208-7.228-.315-2.426-1.555-4.584-3.493-6.077s-4.341-2.139-6.768-1.828c-2.426.315-4.584 1.555-6.077 3.493s-2.142 4.341-1.827 6.767c.649 5.007 5.251 8.554 10.259 7.905 1.441-.188 2.824-.717 4.014-1.536l3.749 3.295 1.476-1.68zm-1.471-1.887c-1.111 1.443-2.72 2.368-4.527 2.602-1.808.235-3.598-.247-5.041-1.361-1.444-1.111-2.368-2.719-2.602-4.527-.483-3.73 2.158-7.158 5.889-7.642.296-.038.59-.057.881-.057 3.375 0 6.316 2.511 6.761 5.946.235 1.806-.249 3.596-1.361 5.039"}))},o=window.wp.data;class i extends React.Component{constructor(e){super(e),this.state={score:0,timeout:null},this.handleCheckChanged=this.handleCheckChanged.bind(this),this.calculateScore=this.calculateScore.bind(this),this.runAllChecks=this.runAllChecks.bind(this)}calculateScore(){const e=window.diagnoseo.checks.filter((e=>"check"===e.type));let t=e.length+1,a=e.filter((e=>e.checked)),o=window.diagnoseo.additionalKeywordCount===window.diagnoseo.RelatedKeywordsInPost?a.length+1:a.length,i=Math.round(100*o/t);this.setState({score:i})}runAllChecks(){const e=window.diagnoseo.checks.filter((e=>"check"===e.type)),t={postTitle:(0,o.select)("core/editor").getEditedPostAttribute("title"),postContent:(0,o.select)("core/editor").getEditedPostContent(),keyword:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,featuredImageId:(0,o.select)("core/editor").getEditedPostAttribute("featured_media"),featuredImage:(0,o.select)("core").getMedia((0,o.select)("core/editor").getEditedPostAttribute("featured_media")),metaTitle:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_title,metaDescription:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_description,slug:(0,o.select)("core/editor").getEditedPostAttribute("slug"),blocks:(0,o.select)("core/block-editor").getBlocks(),optimalKeywordDensity:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density,optimalWordNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_word_number,optimalHeadingNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_heading_number,optimalImageNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_image_number};if(!t.featuredImageId||t.featuredImage)t.metaTitle=seoHelper.replaceVariables(t.metaTitle)||(document.querySelector("#seo-title")?seoHelper.replaceVariables(document.querySelector("#seo-title").getAttribute("placeholder")):""),t.metaDescription=seoHelper.replaceVariables(t.metaDescription)||(document.querySelector("#seo-description")?seoHelper.replaceVariables(document.querySelector("#seo-description").value):""),e.forEach(((e,a)=>{if(!e.test)return;let o="ok"===e.test(t),i=window.diagnoseo.checks.findIndex((t=>t.id===e.id));window.diagnoseo.checks[i].checked=o})),this.calculateScore();else var a=setInterval((()=>{(0,o.select)("core").getMedia(t.featuredImageId)&&(clearInterval(a),this.runAllChecks())}),500)}handleCheckChanged(){clearTimeout(this.state.timeout),this.setState({timeout:setTimeout(this.calculateScore,300)})}async componentDidMount(){window.addEventListener("check-changed",this.handleCheckChanged),setTimeout(this.runAllChecks,1e3)}componentWillUnmount(){window.removeEventListener("check-changed",this.handleCheckChanged)}render(){let t,o=this.state.score;switch(!0){case o<60:t="score-low";break;case o>=60&&o<90:t="score-medium";break;case o>=90:t="score-high"}let i=`diagnoseo-button-content ${t}`;return(0,e.createElement)("span",{className:i},(0,e.createElement)(a,null),(0,e.createElement)("b",{className:"diagnoseo-score"},this.state.score,"/100"))}whenEditorIsReady(){return new Promise((e=>{const t=(0,o.subscribe)((()=>{((0,o.select)("core/editor").isCleanNewPost()||(0,o.select)("core/block-editor").getBlockCount()>0)&&(t(),e())}))}))}}var n=i,l=window.wp.editPost,r=window.wp.components,s=window.wp.i18n,d=window.wp.compose,c=(0,d.compose)((0,o.withDispatch)(((e,t)=>({setMetaValue:a=>{var o={};o[t.fieldName]=a,e("core/editor").editPost({meta:o}),t.changeCallback&&t.changeCallback(a)}}))),(0,o.withSelect)(((e,t)=>({metaValue:e("core/editor").getEditedPostAttribute("meta")[t.fieldName]}))))((t=>(0,e.createElement)(r.TextControl,{label:t.label,value:t.metaValue,onChange:e=>t.setMetaValue(e)}))),m=(0,d.compose)((0,o.withSelect)((e=>({content:e("core/editor").getEditedPostContent(),keyword:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,optimalKeywordDensity:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density}))))((t=>{var a=0;if(t.keyword){var o=t.content.replace(/<\!--.*?-->/g,""),i=(o=(o=o.replace(/(\r\n|\n|\r)/gm," ")).toLowerCase()).split(" ");i=i.filter((e=>""!==e));var n=seoHelper.countOccurences(t.keyword,o);n&&(a=(a=n/i.length*100).toFixed(2))}let l;if(window.diagnoseoPro){let o="diagnoseo-check optimal-keyword-density",i=.7*parseFloat(t.optimalKeywordDensity),n=1.3*parseFloat(t.optimalKeywordDensity);o+=a>=i&&a<=n?" ok":" nok",l=(0,e.createElement)("p",{className:o},(0,s.__)("Optimal keyword density","diagnoseo")," ",(0,e.createElement)("b",{className:"value"},t.optimalKeywordDensity||""))}else l=(0,e.createElement)("p",{className:"diagnoseo-check optimal-keyword-density"},(0,e.createElement)("i",{className:"dashicons dashicons-lock"})," ",(0,s.__)("Optimal keyword density","diagnoseo"));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",{className:"diagnoseo-stats keyword-density"},(0,s.__)("Keyword density","diagnoseo")," ",(0,e.createElement)("b",{className:"value"},a,"%")),l)})),u=t=>{let a=["diagnoseo-check",t.id];if(t.test){let e=t.test(t.postData);"string"==typeof e&&a.push(e);let o="ok"===e,i=t.checkConfig.findIndex((e=>e.id===t.id));t.checkConfig[i].checked!==o&&window.dispatchEvent(new Event("check-changed")),t.checkConfig[i].checked=o}if(t.inPro)return(0,e.createElement)("p",{className:a.join(" ")},(0,e.createElement)("i",{className:"dashicons dashicons-lock"})," ",t.label," ",(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))));const o=t.valueFieldName&&t.postData[t.valueFieldName]?(0,e.createElement)("b",null,t.postData[t.valueFieldName]):"";return(0,e.createElement)("p",{className:a.join(" ")},t.label," ",o)},g=t=>{let a=["diagnoseo-stats",t.id];if(t.inPro)return(0,e.createElement)("p",{className:a.join(" ")},(0,e.createElement)("i",{className:"dashicons dashicons-lock"}),"  ",t.label," ",(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))));let o,i=(0,e.createElement)("b",{className:"value"}),n="";if(t.test){let o=t.test(t.postData);i=(0,e.createElement)("b",{className:"value"},o.value),n=o.comment?(0,e.createElement)("span",{className:"comment"},o.comment):"",o.status&&a.push(o.status)}return o=t.order&&"value label"!==t.order?(0,e.createElement)(e.Fragment,null,t.label," ",i," ",n):(0,e.createElement)(e.Fragment,null,i," ",t.label),(0,e.createElement)("p",{className:a.join(" ")},o)},p=(0,d.compose)((0,o.withSelect)((e=>({postTitle:e("core/editor").getEditedPostAttribute("title"),postContent:e("core/editor").getEditedPostContent(),featuredImage:e("core").getMedia(e("core/editor").getEditedPostAttribute("featured_media")),keyword:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,metaTitle:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_title,metaDescription:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_description,urlSlug:e("core/editor").getEditedPostAttribute("slug"),blocks:e("core/block-editor").getBlocks(),optimalKeywordDensity:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density,optimalWordNumber:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_word_number,optimalHeadingNumber:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_heading_number,optimalImageNumber:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_image_number,postType:e("core/editor").getCurrentPostType()}))))((t=>{const a=window.diagnoseo.checks,o=a.filter((e=>e.section===t.sectionName)),i={postTitle:t.postTitle,postContent:t.postContent,keyword:t.keyword,metaTitle:seoHelper.replaceVariables(t.metaTitle)||(document.querySelector("#seo-title")?seoHelper.replaceVariables(document.querySelector("#seo-title").getAttribute("placeholder")):""),metaDescription:seoHelper.replaceVariables(t.metaDescription)||(document.querySelector("#seo-description")?seoHelper.replaceVariables(document.querySelector("#seo-description").value):""),slug:t.urlSlug,blocks:t.blocks,featuredImage:t.featuredImage,optimalKeywordDensity:t.optimalKeywordDensity,optimalWordNumber:t.optimalWordNumber,optimalHeadingNumber:t.optimalHeadingNumber,optimalImageNumber:t.optimalImageNumber},n=o.map((o=>{let n=!0;if(o.postTypes&&(n=o.postTypes.includes(t.postType)),!o.hidden&&n)switch(o.type){case"check":return o.inPro?(0,e.createElement)(u,{id:o.id,label:o.label,inPro:o.inPro}):(0,e.createElement)(u,{id:o.id,label:o.label,test:o.test,postData:i,checkConfig:a,valueFieldName:o.valueFieldName});case"stats":return o.inPro?(0,e.createElement)(g,{id:o.id,label:o.label,inPro:o.inPro}):(0,e.createElement)(g,{id:o.id,label:o.label,test:o.test,order:o.order,postData:i})}}));return(0,e.createElement)(e.Fragment,null,n.map(((t,a)=>(0,e.createElement)(React.Fragment,{key:a},t))))}));class h extends React.Component{constructor(e){super(e),this.state={keyword:"",keywordList:[],keywordLimit:window.diagnoseoPro?window.diagnoseoPro.additionalKeywordLimit:window.diagnoseo.additionalKeywordLimit,apiKey:"",language:diagnoseo_settings?diagnoseo_settings.locale.substr(0,2):"",loading:!1},this.handleChange=this.handleChange.bind(this),this.handleLangChange=this.handleLangChange.bind(this),this.handleLoadButtonClick=this.handleLoadButtonClick.bind(this),this.relatedKeywordsApiUrl="diagnoseo/v1/related-keywords"}stripKeywordData(e){return(e=-1===e.indexOf("|")?e:e.substr(0,e.indexOf(" |"))).trim()}async loadRelatedKeywords(){const e=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword;if(!e)return void alert((0,s.__)('Please enter the "focus keyword" first',"diagnoseo"));if(!this.state.language)return void alert((0,s.__)("Please select language.","diagnoseo"));if(!this.state.apiKey)return void alert((0,s.__)("Please enter the API key in the DiagnoSEO Pro settings.","diagnoseo"));this.setState({loading:!0});let t=`https://api.diagnoseo.com/contentapi/?api_key=${this.state.apiKey}&keyword=${e}&engine=${this.state.language}`;await fetch(t).then((e=>e.json())).then((e=>{let t=e.seo_data;this.props.seoDataCollector&&this.props.seoDataCollector(t);let a=t.related_keywords,o=this.state.keywordList;a.forEach((e=>{let t=o.findIndex((t=>t.name===e.name));-1===t?o.push(e):(o[t].repeat_min=e.repeat_min,o[t].repeat_max=e.repeat_max)})),this.saveKeywords(o)})),this.setState({loading:!1})}saveKeywords(e){const t=[...new Set(e)];t.splice(this.state.keywordLimit),this.setState({keywordList:t}),window.onbeforeunload=null,(0,o.dispatch)("core/editor").editPost({meta:{diagnoseo_meta_additional_keywords:JSON.stringify(t)}})}componentDidMount(){let e=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_additional_keywords;try{e=JSON.parse(e)}catch{e=""}this.setState({keyword:this.props.focusKeyword,keywordList:e||[]})}async handleLoadButtonClick(){await wp.apiFetch({path:"diagnoseo/v1/apikey"}).then((e=>{this.setState({apiKey:e})})).catch((()=>{alert((0,s.__)("Related keywords and Pro data require DiagnoSEO Pro and API key.","diagnoseo"))})),window.diagnoseoPro?this.loadRelatedKeywords():alert((0,s.__)("Related keywords and Pro data require DiagnoSEO Pro and API key.","diagnoseo"))}handleChange(e){const t=this.state.keywordList,{stripKeywordData:a}=this;let o=e.map((e=>{let o=a(e.value||e),i=t.findIndex((e=>o===e.name));return{name:o,repeat_min:-1!==i?t[i].repeat_min:0,repeat_max:-1!==i?t[i].repeat_max:0}}));this.saveKeywords(o)}handleLangChange(e){this.setState({language:e})}render(){let{postTitle:t,postContent:a,featuredMedia:o}=this.props;const{countOccurences:i}=seoHelper;let n=0,l=this.state.keywordList.map((e=>{let l=e.name||"",r="error",s=function(e){a=seoHelper.stripTags(a);let n=0;return n+=i(e,t),n+=i(e,a),n+=seoHelper.isKeywordInAnyAlt(e,a),n+=o?i(e,o.alt_text):0,n}(l);s&&(r=e.repeat_min&&e.repeat_max?s>=e.repeat_min&&s<=e.repeat_max?"success":"validating":"success",n++);let d=` | ${s}`;return e.repeat_min&&e.repeat_max&&(d+=` (${e.repeat_min} - ${e.repeat_max})`),{value:l+d,status:r}})),d=!1;window.diagnoseo.RelatedKeywordsInPost!==n&&(window.diagnoseo.RelatedKeywordsInPost=n,d=!0),window.diagnoseo.additionalKeywordCount!==l.length&&(window.diagnoseo.additionalKeywordCount=l.length,d=!0),d&&window.dispatchEvent(new Event("check-changed"));let c=this.state.loading?(0,s.__)("Please wait... Loading related keywords. It can take up to a few minutes.","diagnoseo"):(0,e.createElement)("button",{className:"button get-related-keywords",onClick:this.handleLoadButtonClick},(0,s.__)("Get related keywords and Pro data","diagnoseo"));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"components-base-control__field add-keyword diagnoseo-related-keywords"},(0,e.createElement)(r.FormTokenField,{label:(0,e.createElement)("b",null,(0,s.__)("Related keywords","diagnoseo")),onChange:this.handleChange,value:l,maxLength:this.state.keywordLimit+10}),(0,e.createElement)("p",{className:"components-form-token-field__help"},(0,s.__)("Limits: 10 keywords in free, 100 keywords in Pro","diagnoseo")),(0,e.createElement)(r.SelectControl,{options:[{value:"ar",label:"Bahrain"},{value:"bg",label:"Bulgaria"},{value:"hr",label:"Croatia"},{value:"zh_TW",label:"Taiwan"},{value:"cs",label:"Czechia"},{value:"da",label:"Denmark"},{value:"nl",label:"Netherlands"},{value:"en",label:"United States"},{value:"fi",label:"Finland"},{value:"fr",label:"France"},{value:"de",label:"Austria"},{value:"el",label:"Cyprus"},{value:"he",label:"Israel"},{value:"hi",label:"India"},{value:"hu",label:"Hungary"},{value:"id",label:"Indonesia"},{value:"it",label:"Italy"},{value:"ja",label:"Japan"},{value:"ko",label:"South Korea"},{value:"lv",label:"Latvia"},{value:"lt",label:"Lithuania"},{value:"no",label:"Norway"},{value:"pl",label:"Poland"},{value:"pt",label:"Portugal"},{value:"ro",label:"Romania"},{value:"ru",label:"Russia"},{value:"sr",label:"Serbia"},{value:"sk",label:"Slovakia"},{value:"sl",label:"Slovenia"},{value:"es",label:"Argentina"},{value:"sv",label:"Sweden"},{value:"th",label:"Thailand"},{value:"tr",label:"Turkey"},{value:"uk",label:"Ukraine"},{value:"vi",label:"Vietnam"}],value:this.state.language,onChange:this.handleLangChange,label:(0,s.__)("Language","diagnoseo")}),(0,e.createElement)("p",null,c)))}}var w=(0,d.compose)((0,o.withSelect)((e=>{const t=e("core/editor").getEditedPostAttribute("featured_media");return{postTitle:e("core/editor").getEditedPostAttribute("title"),postContent:e("core/editor").getEditedPostContent(),featuredMedia:e("core").getMedia(t,{context:"embed"})||{}}})))((t=>(0,e.createElement)(h,{postTitle:t.postTitle,postContent:t.postContent,featuredMedia:t.featuredMedia,seoDataCollector:t.seoDataCollector}))),b=(0,d.compose)((0,o.withSelect)((e=>{if(!window.diagnoseoPro)return{};const t={categories:e("core/editor").getEditedPostAttribute("categories"),status:"publish",per_page:10,exclude:[e("core/editor").getEditedPostAttribute("id")]};return{suggestedPosts:wp.data.select("core").getEntityRecords("postType","post",t)||[]}})))((t=>{if(window.diagnoseoPro){var a="";return t.suggestedPosts.length?(a=t.suggestedPosts.map((t=>(0,e.createElement)("li",null,(0,e.createElement)("a",{href:t.link},t.title.raw)))),a=(0,e.createElement)("ol",null,a)):a=(0,e.createElement)("p",null,(0,s.__)("Could not prepare suggestions as there are no posts related to this one")),a}return(0,e.createElement)("p",null,(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))))})),_=(0,d.compose)((0,o.withDispatch)((e=>({setMetaValues:t=>{e("core/editor").editPost({meta:{diagnoseo_optimal_word_number:t.number_of_words.toString(),diagnoseo_optimal_keyword_density:t.focus_keyword_density.toString(),diagnoseo_optimal_heading_number:t.number_of_headings.toString(),diagnoseo_optimal_image_number:t.number_of_images.toString()}})}}))))((t=>{let a=window.diagnoseoPro?"DiagnoSEO Pro":"DiagnoSEO";return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.PluginSidebarMoreMenuItem,{target:"diagnoseo-content-analyzer"},(0,s.__)("DiagnoSEO Content Watcher","diagnoseo")),(0,e.createElement)(l.PluginSidebar,{title:a,name:"diagnoseo-content-analyzer"},(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Content analyzer","diagnoseo"),initialOpen:"true"},(0,e.createElement)(p,{sectionName:"content"})),(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Keyword placement","diagnoseo"),initialOpen:"true"},(0,e.createElement)(c,{fieldName:"diagnoseo_meta_keyword",label:(0,e.createElement)("b",null,(0,s.__)("Focus keyword","diagnoseo"))}),(0,e.createElement)(m,null),(0,e.createElement)(w,{seoDataCollector:t.setMetaValues}),(0,e.createElement)(p,{sectionName:"keyword"})),(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Internal linking suggestions","diagnoseo"),initialOpen:"true"},(0,e.createElement)(b,null))))}));(0,t.registerPlugin)("diagnoseo-sidebar",{icon:(0,e.createElement)(n,null),render:_})}();
     1!function(){"use strict";var e=window.wp.element,t=window.wp.plugins,a=function(){return(0,e.createElement)("svg",{"enable-background":"new 0 0 20 20",height:"20",width:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",className:"diagnoseo-icon"},(0,e.createElement)("clipPath",{id:"a"},(0,e.createElement)("path",{d:"m0 0h20v20h-20z"})),(0,e.createElement)("path",{className:"diagnoseo-icon-part-tick",d:"m12.377 5.866 1.835 1.612-4.839 5.508-4.11-3.576 1.672-1.902 2.256 1.982z"}),(0,e.createElement)("path",{className:"diagnoseo-icon-part-magnifier","clip-path":"url(#a)",d:"m16.298 15.209c1.745-1.983 2.548-4.603 2.208-7.228-.315-2.426-1.555-4.584-3.493-6.077s-4.341-2.139-6.768-1.828c-2.426.315-4.584 1.555-6.077 3.493s-2.142 4.341-1.827 6.767c.649 5.007 5.251 8.554 10.259 7.905 1.441-.188 2.824-.717 4.014-1.536l3.749 3.295 1.476-1.68zm-1.471-1.887c-1.111 1.443-2.72 2.368-4.527 2.602-1.808.235-3.598-.247-5.041-1.361-1.444-1.111-2.368-2.719-2.602-4.527-.483-3.73 2.158-7.158 5.889-7.642.296-.038.59-.057.881-.057 3.375 0 6.316 2.511 6.761 5.946.235 1.806-.249 3.596-1.361 5.039"}))},o=window.wp.data;class i extends React.Component{constructor(e){super(e),this.state={score:0,timeout:null},this.handleCheckChanged=this.handleCheckChanged.bind(this),this.calculateScore=this.calculateScore.bind(this),this.runAllChecks=this.runAllChecks.bind(this)}calculateScore(){const e=window.diagnoseo.checks.filter((e=>"check"===e.type));let t=e.length+1,a=e.filter((e=>e.checked)),o=window.diagnoseo.additionalKeywordCount===window.diagnoseo.RelatedKeywordsInPost?a.length+1:a.length,i=Math.round(100*o/t);this.setState({score:i})}runAllChecks(){const e=window.diagnoseo.checks.filter((e=>"check"===e.type)),t={postTitle:(0,o.select)("core/editor").getEditedPostAttribute("title"),postContent:(0,o.select)("core/editor").getEditedPostContent(),keyword:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,featuredImageId:(0,o.select)("core/editor").getEditedPostAttribute("featured_media"),featuredImage:(0,o.select)("core").getMedia((0,o.select)("core/editor").getEditedPostAttribute("featured_media")),metaTitle:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_title,metaDescription:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_description,slug:(0,o.select)("core/editor").getEditedPostAttribute("slug"),blocks:(0,o.select)("core/block-editor").getBlocks(),optimalKeywordDensity:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density,optimalWordNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_word_number,optimalHeadingNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_heading_number,optimalImageNumber:(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_image_number};if(!t.featuredImageId||t.featuredImage)t.metaTitle=seoHelper.replaceVariables(t.metaTitle)||(document.querySelector("#seo-title")?seoHelper.replaceVariables(document.querySelector("#seo-title").getAttribute("placeholder")):""),t.metaDescription=seoHelper.replaceVariables(t.metaDescription)||(document.querySelector("#seo-description")?seoHelper.replaceVariables(document.querySelector("#seo-description").value):""),e.forEach(((e,a)=>{if(!e.test)return;let o="ok"===e.test(t),i=window.diagnoseo.checks.findIndex((t=>t.id===e.id));window.diagnoseo.checks[i].checked=o})),this.calculateScore();else var a=setInterval((()=>{(0,o.select)("core").getMedia(t.featuredImageId)&&(clearInterval(a),this.runAllChecks())}),500)}handleCheckChanged(){clearTimeout(this.state.timeout),this.setState({timeout:setTimeout(this.calculateScore,300)})}async componentDidMount(){window.addEventListener("check-changed",this.handleCheckChanged),setTimeout(this.runAllChecks,1e3)}componentWillUnmount(){window.removeEventListener("check-changed",this.handleCheckChanged)}render(){let t,o=this.state.score;switch(!0){case o<60:t="score-low";break;case o>=60&&o<90:t="score-medium";break;case o>=90:t="score-high"}let i=`diagnoseo-button-content ${t}`;return(0,e.createElement)("span",{className:i},(0,e.createElement)(a,null),(0,e.createElement)("b",{className:"diagnoseo-score"},this.state.score,"/100"))}whenEditorIsReady(){return new Promise((e=>{const t=(0,o.subscribe)((()=>{((0,o.select)("core/editor").isCleanNewPost()||(0,o.select)("core/block-editor").getBlockCount()>0)&&(t(),e())}))}))}}var n=i,l=window.wp.editPost,r=window.wp.components,s=window.wp.i18n,d=window.wp.compose,c=(0,d.compose)((0,o.withDispatch)(((e,t)=>({setMetaValue:a=>{var o={};o[t.fieldName]=a,e("core/editor").editPost({meta:o}),t.changeCallback&&t.changeCallback(a)}}))),(0,o.withSelect)(((e,t)=>({metaValue:e("core/editor").getEditedPostAttribute("meta")[t.fieldName]}))))((t=>(0,e.createElement)(r.TextControl,{label:t.label,value:t.metaValue,onChange:e=>t.setMetaValue(e)}))),m=(0,d.compose)((0,o.withSelect)((e=>({content:e("core/editor").getEditedPostContent(),keyword:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,optimalKeywordDensity:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_keyword_density}))))((t=>{var a=0;if(t.keyword){var o=t.content.replace(/<\!--.*?-->/g,""),i=(o=(o=o.replace(/(\r\n|\n|\r)/gm," ")).toLowerCase()).split(" ");i=i.filter((e=>""!==e));var n=seoHelper.countOccurences(t.keyword,o);n&&(a=(a=n/i.length*100).toFixed(2))}let l;if(window.diagnoseoPro){let o="diagnoseo-check optimal-keyword-density";parseFloat(t.optimalKeywordDensity),parseFloat(t.optimalKeywordDensity),o+=a>=1&&a<=3?" ok":" nok",l=(0,e.createElement)("p",{className:o},(0,s.__)("Optimal keyword density","diagnoseo")," ",(0,e.createElement)("b",{className:"value"},"1% - 3%"))}else l=(0,e.createElement)("p",{className:"diagnoseo-check optimal-keyword-density"},(0,e.createElement)("i",{className:"dashicons dashicons-lock"})," ",(0,s.__)("Optimal keyword density","diagnoseo"));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",{className:"diagnoseo-stats keyword-density"},(0,s.__)("Keyword density","diagnoseo")," ",(0,e.createElement)("b",{className:"value"},a,"%")),l)})),u=t=>{let a=["diagnoseo-check",t.id];if(t.test){let e=t.test(t.postData);"string"==typeof e&&a.push(e);let o="ok"===e,i=t.checkConfig.findIndex((e=>e.id===t.id));t.checkConfig[i].checked!==o&&window.dispatchEvent(new Event("check-changed")),t.checkConfig[i].checked=o}if(t.inPro)return(0,e.createElement)("p",{className:a.join(" ")},(0,e.createElement)("i",{className:"dashicons dashicons-lock"})," ",t.label," ",(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))));const o=t.valueFieldName&&t.postData[t.valueFieldName]?(0,e.createElement)("b",null,t.postData[t.valueFieldName]):"";return(0,e.createElement)("p",{className:a.join(" ")},t.label," ",o)},g=t=>{let a=["diagnoseo-stats",t.id];if(t.inPro)return(0,e.createElement)("p",{className:a.join(" ")},(0,e.createElement)("i",{className:"dashicons dashicons-lock"}),"  ",t.label," ",(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))));let o,i=(0,e.createElement)("b",{className:"value"}),n="";if(t.test){let o=t.test(t.postData);i=(0,e.createElement)("b",{className:"value"},o.value),n=o.comment?(0,e.createElement)("span",{className:"comment"},o.comment):"",o.status&&a.push(o.status)}return o=t.order&&"value label"!==t.order?(0,e.createElement)(e.Fragment,null,t.label," ",i," ",n):(0,e.createElement)(e.Fragment,null,i," ",t.label),(0,e.createElement)("p",{className:a.join(" ")},o)},p=(0,d.compose)((0,o.withSelect)((e=>({postTitle:e("core/editor").getEditedPostAttribute("title"),postContent:e("core/editor").getEditedPostContent(),featuredImage:e("core").getMedia(e("core/editor").getEditedPostAttribute("featured_media")),keyword:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,metaTitle:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_title,metaDescription:e("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_description,urlSlug:e("core/editor").getEditedPostAttribute("slug"),blocks:e("core/block-editor").getBlocks(),optimalKeywordDensity:2,optimalWordNumber:300,optimalHeadingNumber:1,optimalImageNumber:e("core/editor").getEditedPostAttribute("meta").diagnoseo_optimal_image_number,postType:e("core/editor").getCurrentPostType()}))))((t=>{const a=window.diagnoseo.checks,o=a.filter((e=>e.section===t.sectionName)),i={postTitle:t.postTitle,postContent:t.postContent,keyword:t.keyword,metaTitle:seoHelper.replaceVariables(t.metaTitle)||(document.querySelector("#seo-title")?seoHelper.replaceVariables(document.querySelector("#seo-title").getAttribute("placeholder")):""),metaDescription:seoHelper.replaceVariables(t.metaDescription)||(document.querySelector("#seo-description")?seoHelper.replaceVariables(document.querySelector("#seo-description").value):""),slug:t.urlSlug,blocks:t.blocks,featuredImage:t.featuredImage,optimalKeywordDensity:t.optimalKeywordDensity,optimalWordNumber:t.optimalWordNumber,optimalHeadingNumber:t.optimalHeadingNumber,optimalImageNumber:t.optimalImageNumber},n=o.map((o=>{let n=!0;if(o.postTypes&&(n=o.postTypes.includes(t.postType)),!o.hidden&&n)switch(o.type){case"check":return o.inPro?(0,e.createElement)(u,{id:o.id,label:o.label,inPro:o.inPro}):(0,e.createElement)(u,{id:o.id,label:o.label,test:o.test,postData:i,checkConfig:a,valueFieldName:o.valueFieldName});case"stats":return o.inPro?(0,e.createElement)(g,{id:o.id,label:o.label,inPro:o.inPro}):(0,e.createElement)(g,{id:o.id,label:o.label,test:o.test,order:o.order,postData:i})}}));return(0,e.createElement)(e.Fragment,null,n.map(((t,a)=>(0,e.createElement)(React.Fragment,{key:a},t))))}));class h extends React.Component{constructor(e){super(e),this.state={keyword:"",keywordList:[],keywordLimit:window.diagnoseoPro?window.diagnoseoPro.additionalKeywordLimit:window.diagnoseo.additionalKeywordLimit,apiKey:"",language:diagnoseo_settings?diagnoseo_settings.locale.substr(0,2):"",loading:!1},this.handleChange=this.handleChange.bind(this),this.handleLangChange=this.handleLangChange.bind(this),this.handleLoadButtonClick=this.handleLoadButtonClick.bind(this),this.relatedKeywordsApiUrl="diagnoseo/v1/related-keywords"}stripKeywordData(e){return(e=-1===e.indexOf("|")?e:e.substr(0,e.indexOf(" |"))).trim()}async loadRelatedKeywords(){const e=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_keyword,t=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_language;if(!e)return void alert((0,s.__)('Please enter the "focus keyword" first',"diagnoseo"));if(!this.state.language)return void alert((0,s.__)("Please select language.","diagnoseo"));this.setState({loading:!0});let a=await this.getRelatedKeywords(e,t);if(a=a.split(","),a.length){let e=this.state.keywordList;a.forEach((t=>{t={name:t.trim()};let a=e.findIndex((e=>e.name===t));-1===a?e.push(t):(e[a].repeat_min=t.repeat_min,e[a].repeat_max=t.repeat_max)})),this.saveKeywords(e)}this.setState({loading:!1})}saveKeywords(e){const t=[...new Set(e)];t.splice(this.state.keywordLimit),this.setState({keywordList:t}),window.onbeforeunload=null,(0,o.dispatch)("core/editor").editPost({meta:{diagnoseo_meta_additional_keywords:JSON.stringify(t)}})}saveLanguage(e){(0,o.dispatch)("core/editor").editPost({meta:{diagnoseo_meta_language:e}})}componentDidMount(){let e=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_additional_keywords,t=(0,o.select)("core/editor").getEditedPostAttribute("meta").diagnoseo_meta_language;try{e=JSON.parse(e)}catch{e=""}this.setState({language:t,keyword:this.props.focusKeyword,keywordList:e||[]})}async handleLoadButtonClick(){window.diagnoseoPro?this.loadRelatedKeywords():alert((0,s.__)("Related keywords and Pro data require DiagnoSEO Pro.","diagnoseo"))}handleChange(e){const t=this.state.keywordList,{stripKeywordData:a}=this;let o=e.map((e=>{let o=a(e.value||e),i=t.findIndex((e=>o===e.name));return{name:o,repeat_min:-1!==i?t[i].repeat_min:0,repeat_max:-1!==i?t[i].repeat_max:0}}));this.saveKeywords(o)}handleLangChange(e){this.setState({language:e}),this.saveLanguage(e)}render(){let{postTitle:t,postContent:a,featuredMedia:o}=this.props;const{countOccurences:i}=seoHelper;let n=0,l=this.state.keywordList.map((e=>{let l=e.name||"",r="error",s=function(e){a=seoHelper.stripTags(a);let n=0;return n+=i(e,t),n+=i(e,a),n+=seoHelper.isKeywordInAnyAlt(e,a),n+=o?i(e,o.alt_text):0,n}(l);s&&(r=e.repeat_min&&e.repeat_max?s>=e.repeat_min&&s<=e.repeat_max?"success":"validating":"success",n++);let d=` | ${s}`;return e.repeat_min&&e.repeat_max&&(d+=` (${e.repeat_min} - ${e.repeat_max})`),{value:l+d,status:r}})),d=!1;window.diagnoseo.RelatedKeywordsInPost!==n&&(window.diagnoseo.RelatedKeywordsInPost=n,d=!0),window.diagnoseo.additionalKeywordCount!==l.length&&(window.diagnoseo.additionalKeywordCount=l.length,d=!0),d&&window.dispatchEvent(new Event("check-changed"));let c=this.state.loading?(0,s.__)("Please wait... Loading related keywords. It can take up to a few minutes.","diagnoseo"):(0,e.createElement)("button",{className:"button get-related-keywords",onClick:this.handleLoadButtonClick},(0,s.__)("Get related keywords and Pro data","diagnoseo"));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"components-base-control__field add-keyword diagnoseo-related-keywords"},(0,e.createElement)(r.FormTokenField,{label:(0,e.createElement)("b",null,(0,s.__)("Related keywords","diagnoseo")),onChange:this.handleChange,value:l,maxLength:this.state.keywordLimit+10}),(0,e.createElement)("p",{className:"components-form-token-field__help"},(0,s.__)("Limits: 10 keywords in free, 100 keywords in Pro","diagnoseo")),(0,e.createElement)(r.SelectControl,{options:[{value:"chinese",label:"Taiwan"},{value:"arabic",label:"Bahrain"},{value:"bulgarian",label:"Bulgaria"},{value:"croatian",label:"Croatia"},{value:"czech",label:"Czechia"},{value:"danish",label:"Denmark"},{value:"dutch",label:"Netherlands"},{value:"english",label:"United States"},{value:"finnish",label:"Finland"},{value:"french",label:"France"},{value:"austrian",label:"Austria"},{value:"greek",label:"Cyprus"},{value:"israeli",label:"Israel"},{value:"indian",label:"India"},{value:"hungarian",label:"Hungary"},{value:"indonesian",label:"Indonesia"},{value:"italian",label:"Italy"},{value:"japanese",label:"Japan"},{value:"korean",label:"South Korea"},{value:"latvian",label:"Latvia"},{value:"lithuanian",label:"Lithuania"},{value:"norwegian",label:"Norway"},{value:"polish",label:"Poland"},{value:"portugese",label:"Portugal"},{value:"romanian",label:"Romania"},{value:"russian",label:"Russia"},{value:"serbian",label:"Serbia"},{value:"slovak",label:"Slovakia"},{value:"slovenian",label:"Slovenia"},{value:"spanish",label:"Argentina"},{value:"swedish",label:"Sweden"},{value:"thai",label:"Thailand"},{value:"turkish",label:"Turkey"},{value:"ukrainian",label:"Ukraine"},{value:"vietnamese",label:"Vietnam"}],value:this.state.language,onChange:this.handleLangChange,label:(0,s.__)("Language","diagnoseo")}),(0,e.createElement)("p",null,c)))}getRelatedKeywords(e,t){return new Promise((a=>{const o=new FormData;o.append("keyword",e),o.append("language",t),o.append("count",30),fetch("/wp-json/diagnoseo/v1/related-keywords",{method:"POST",body:o}).then((e=>e.json())).then((e=>{"ok"===e.status?a(e.keywords):a("")})).catch((e=>{console.error(e),a("")}))}))}}var w=(0,d.compose)((0,o.withSelect)((e=>{const t=e("core/editor").getEditedPostAttribute("featured_media");return{postTitle:e("core/editor").getEditedPostAttribute("title"),postContent:e("core/editor").getEditedPostContent(),featuredMedia:e("core").getMedia(t,{context:"embed"})||{}}})))((t=>(0,e.createElement)(h,{postTitle:t.postTitle,postContent:t.postContent,featuredMedia:t.featuredMedia,seoDataCollector:t.seoDataCollector}))),b=(0,d.compose)((0,o.withSelect)((e=>{if(!window.diagnoseoPro)return{};const t={categories:e("core/editor").getEditedPostAttribute("categories"),status:"publish",per_page:10,exclude:[e("core/editor").getEditedPostAttribute("id")]};return{suggestedPosts:wp.data.select("core").getEntityRecords("postType","post",t)||[]}})))((t=>{if(window.diagnoseoPro){var a="";return t.suggestedPosts.length?(a=t.suggestedPosts.map((t=>(0,e.createElement)("li",null,(0,e.createElement)("a",{href:t.link},t.title.raw)))),a=(0,e.createElement)("ol",null,a)):a=(0,e.createElement)("p",null,(0,s.__)("Could not prepare suggestions as there are no posts related to this one")),a}return(0,e.createElement)("p",null,(0,e.createElement)("b",null,(0,e.createElement)("a",{href:"https://diagnoseo.com/wordpress-seo-plugin/?utm_source=wp&utm_medium=link&utm_campaign=available_in_pro",target:"_blank",rel:"noreferrer noopener"},(0,s.__)("Available in Pro","diagnoseo"))))})),_=(0,d.compose)((0,o.withDispatch)((e=>({setMetaValues:t=>{e("core/editor").editPost({meta:{diagnoseo_optimal_word_number:t.number_of_words.toString(),diagnoseo_optimal_keyword_density:t.focus_keyword_density.toString(),diagnoseo_optimal_heading_number:t.number_of_headings.toString(),diagnoseo_optimal_image_number:t.number_of_images.toString()}})}}))))((t=>{let a=window.diagnoseoPro?"DiagnoSEO Pro":"DiagnoSEO";return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.PluginSidebarMoreMenuItem,{target:"diagnoseo-content-analyzer"},(0,s.__)("DiagnoSEO Content Watcher","diagnoseo")),(0,e.createElement)(l.PluginSidebar,{title:a,name:"diagnoseo-content-analyzer"},(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Content analyzer","diagnoseo"),initialOpen:"true"},(0,e.createElement)(p,{sectionName:"content"})),(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Keyword placement","diagnoseo"),initialOpen:"true"},(0,e.createElement)(c,{fieldName:"diagnoseo_meta_keyword",label:(0,e.createElement)("b",null,(0,s.__)("Focus keyword","diagnoseo"))}),(0,e.createElement)(m,null),(0,e.createElement)(w,{seoDataCollector:t.setMetaValues}),(0,e.createElement)(p,{sectionName:"keyword"})),(0,e.createElement)(r.PanelBody,{title:(0,s.__)("Internal linking suggestions","diagnoseo"),initialOpen:"true"},(0,e.createElement)(b,null))))}));(0,t.registerPlugin)("diagnoseo-sidebar",{icon:(0,e.createElement)(n,null),render:_})}();
  • diagnoseo/trunk/js/diagnoseo-checks.min.js

    r2920588 r2984954  
    1 const{__}=window.wp.i18n;window.diagnoseo={additionalKeywordLimit:10,additionalKeywordCount:0,RelatedKeywordsInPost:0,checks:[{id:"title-not-too-long",type:"check",label:__("Title not too long"),section:"content",test:e=>{var{metaTitle:t,postTitle:e}=e;if(!t&&!e)return"nok";t=t||e;const o=document.querySelector(".title-sample");o.textContent=t;e=o.clientWidth,t=t.length;return e<=600?60<t?"nok medium-nok":t<=60?"ok":"nok":"nok"}},{id:"title-not-too-short",type:"check",label:__("Title not too short"),section:"content",test:e=>{var{metaTitle:t,postTitle:e}=e;if(!t&&!e)return"nok";e=(t||e).length;return 30<=e?30<=e&&e<35?"nok medium-nok":35<=e?"ok":"nok":"nok"}},{id:"description-not-too-long",type:"check",label:__("Description not too long"),section:"content",test:e=>{var{metaDescription:t}=e;if(!t)return"nok";e=document.querySelector(".description-sample"),t=t.length;if(e.clientWidth<=990){if(155<t)return"nok medium-nok";if(t<=155)return"ok"}return"nok"}},{id:"description-not-too-short",type:"check",label:__("Description not too short"),section:"content",test:e=>{var{metaDescription:e}=e;if(!e)return"nok";e=e.length;if(70<=e){if(e<130)return"nok medium-nok";if(130<=e)return"ok"}return"nok"}},{id:"too-long-sentences",type:"check",label:__("No sentences with more than 20 words"),section:"content",test:e=>{var{postContent:e}=e;e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll("</p>",".</p>")).replaceAll("</h1>",".</h1>")).replaceAll("</h2>",".</h2>")).replaceAll("</h3>",".</h3>")).replaceAll("</h4>",".</h4>")).replaceAll("</h5>",".</h5>")).replaceAll("</h6>",".</h6>")).replaceAll("</li>",".</li>");const t=(e=seoHelper.stripTags(e)).split(/\.|\?|!/);var o=!1;return t.length&&t.forEach(e=>{o=o||20<seoHelper.countWords(e)}),o?"nok":"ok"}},{id:"too-many-words",type:"check",label:__("No paragraphs with more than 100 words"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("p");var n=!1;return o.length&&o.forEach(e=>{100<seoHelper.countWords(e.textContent)&&(n=!0)}),n?"nok":"ok"}},{id:"too-many-sentences",type:"check",label:__("No paragraphs with more than 5 sentences"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("p");var n=!1;return o.length&&o.forEach(e=>{5<e.textContent.split(/\.|\?|!/).filter(e=>!!e.trim()).length&&(n=!0)}),n?"nok":"ok"}},{id:"internal-links-present",type:"check",label:__("Contains internal links"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("a");var n=!1;return o.forEach(e=>{e=e.getAttribute("href")||"";e&&(e.includes("http://"+window.location.hostname)||e.includes("https://"+window.location.hostname)||"/"===e.substr(0,1)||"./"===e.substr(0,2))&&(n=!0)}),n?"ok":"nok"}},{id:"strong-present",type:"check",label:__("Contains bold text (strong tag)"),section:"content",test:e=>seoHelper.countElements(e.postContent,"strong")?"ok":"nok"},{id:"readability",type:"stats",label:__("Readability score"),order:"label value comment",section:"content",test:e=>{var{postContent:t}=e,o=(t=seoHelper.stripTags(t)).split(/\.|\?|!/);o=(o=o.map(e=>e.trim())).filter(e=>e&&" "!==e&&"\n"!==e);e=(t=t.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/g," ")).split(" ");e=(e=e.map(e=>e.trim())).filter(e=>e&&""!==e&&"\n"!==e);var t=seoHelper.countSyllables(t),n=206.835-e.length/o.length*1.015-t/e.length*84.6;(n=n.toFixed(2))<0?n=0:100<n&&(n=100);var r="",s="";switch(!0){case isNaN(n):n=__("N/A"),r="",s="nok";break;case 90<n:r=__("Very easy to read","diagnoseo"),s="ok";break;case 80<n&&n<=90:r=__("Easy to read","diagnoseo"),s="ok";break;case 70<n&&n<=80:r=__("Fairly easy to read","diagnoseo"),s="ok";break;case 60<n&&n<=70:r=__("Average reading ease","diagnoseo"),s="nok medium-nok";break;case 50<n&&n<=60:r=__("Fairly difficult to read","diagnoseo"),s="nok";break;case 30<n&&n<=50:r=__("Difficult to read","diagnoseo"),s="nok";break;case 10<n&&n<=30:r=__("Very difficult to read","diagnoseo"),s="nok";break;case n<=10:r=__("Extremely difficult to read","diagnoseo"),s="nok"}return{value:n,comment:r=r&&` (${r})`,status:s}}},{id:"est-reading-time",type:"stats",label:__("Estimated reading time"),section:"content",order:"label value",test:e=>{var{postContent:t}=e,e=seoHelper.countWords(t),t=Math.floor(e/225),e=Math.floor(e%225/3.75);return{value:`${t} ${__("min")} ${e} ${__("s")}`}}},{id:"minimal-word-count",type:"check",label:__("Minimal word count"),section:"content",postTypes:["post","page"],inPro:!0},{id:"words",type:"stats",label:__("words"),section:"content",test:e=>{var{postContent:e}=e;return{value:seoHelper.countWords(e)}}},{id:"optimal-word-number",type:"check",label:__("Optimal number of words"),inPro:!0,section:"content"},{id:"chars",type:"stats",label:__("characters"),section:"content",test:e=>({value:e.postContent.length||0})},{id:"sentences",type:"stats",label:__("sentences"),section:"content",test:e=>{var{postContent:e}=e,e=(e=e.replace(/(\r\n|\n|\r)/gm," ")).split(/\.|\?|!/);return{value:(e=(e=e.map(e=>e.trim())).filter(e=>e&&" "!==e&&"\n"!==e)).length||0}}},{id:"paragraphs",type:"stats",label:__("paragraphs"),section:"content",test:e=>({value:seoHelper.countElements(e.postContent,"p")})},{id:"headings",type:"stats",label:__("Headings"),inPro:!0,section:"content"},{id:"optimal-heading-number",type:"check",label:__("Optimal number of headings"),inPro:!0,section:"content"},{id:"images",type:"stats",label:__("Images"),inPro:!0,section:"content"},{id:"optimal-image-number",type:"check",label:__("Optimal number of images"),inPro:!0,section:"content"},{id:"too-long-headings",type:"check",label:__("No too long headings"),inPro:!0,section:"content"},{id:"toc-block",type:"check",label:__("Use Table of Contents block"),inPro:!0,section:"content"},{id:"keyword-exists",type:"check",label:__("Keyword is provided"),section:"keyword",test:e=>e.keyword?"ok":"nok"},{id:"keyword-unique",type:"check",label:__("Focus Keyword not used before"),section:"keyword",test:async o=>{var n=document.querySelector(".keyword-unique");if(o.keyword){let e=new URLSearchParams(window.location.search);var r=Object.fromEntries(e.entries()),r=`${diagnoseoRestUrl}diagnoseo/v1/check-posts-keyword/${o.keyword}/${r.post||0}`;let t=0===await(await fetch(r)).json()?"ok":"nok";n?n&&(n.classList.remove("ok","nok"),n.classList.add(t)):setTimeout(()=>{(n=document.querySelector(".keyword-unique"))&&(n.classList.remove("ok","nok"),n.classList.add(t))},200)}else n&&n.classList.add("ok")}},{id:"keyword-in-title",type:"check",label:__("Keyword present in title tag"),section:"keyword",test:e=>{var{keyword:t,postTitle:o,metaTitle:e}=e;return seoHelper.isKeywordInText(t,e||o)?"ok":"nok"}},{id:"keyword-in-title-beginning",type:"check",label:__("Keyword in the beginning of the title tag"),section:"keyword",test:e=>{var{keyword:t,postTitle:o,metaTitle:e}=e;if(!t)return"nok";o=(o=e||o).toLowerCase(),t=t.toLowerCase();const n=new RegExp("^"+t);return n.test(o)?"ok":"nok"}},{id:"keyword-in-descr",type:"check",label:__("Keyword present in meta description tag"),section:"keyword",test:e=>{var{keyword:t,metaDescription:e}=e;return seoHelper.isKeywordInText(t,e)?"ok":"nok"}},{id:"keyword-in-slug",type:"check",label:__("Keyword present in URL slug"),section:"keyword",test:e=>{var{keyword:t,slug:o,postTitle:e}=e;return t&&(o=o||seoHelper.slugify(e)).includes(seoHelper.slugify(t))?"ok":"nok"}},{id:"slug-length-ok",type:"check",label:__("URL slug length"),section:"keyword",test:e=>{var{slug:t,postTitle:e}=e;if(!t&&!e)return"nok";if((t=t||seoHelper.slugify(e)).length<=60&&t.split("-").length<=5)return"ok";return"nok"}},{id:"keyword-in-h1",type:"check",label:__("Keyword present in H1 element"),section:"keyword",test:e=>{var{keyword:t,postContent:o,postTitle:e}=e;return seoHelper.isKeywordInText(t,e)||seoHelper.isKeywordInAnyElement(t,o,"h1")?"ok":"nok"}},{id:"keyword-in-image-alt",type:"check",label:__("Keyword present in any image alt attribute"),section:"keyword",test:e=>{var{keyword:t,postContent:o,featuredImage:e}=e;return seoHelper.isKeywordInAnyAlt(t,o,e)?"ok":"nok"}},{id:"keyword-in-image-filename",type:"check",label:__("Keyword in image file name"),section:"keyword",inPro:!0,hidden:!0},{id:"keyword-not-in-ext-link",type:"check",label:__("Keyword NOT present in external link text"),section:"keyword",test:e=>{const{keyword:o,postContent:t}=e;if(!o)return"ok";const n=seoHelper.createMarkupEl(t);var r=!1;const s=n.querySelectorAll("a");return s.forEach(e=>{const t=e.getAttribute("href")||"";t.includes("http://"+window.location.hostname)||t.includes("https://"+window.location.hostname)||"/"===t.substr(0,1)||"./"===t.substr(0,2)||!seoHelper.isKeywordInText(o,e.textContent)||(r=!0)}),r?"nok":"ok"}},{id:"keyword-in-first-words",type:"check",label:__("Keyword present within first 100 words"),section:"keyword",test:e=>{var{keyword:t,postContent:e}=e;if(!t)return"nok";var t=t.trim(),o=(e=seoHelper.stripTags(e)).toLowerCase().split(/\s|\n/),n=100<=(o=o.filter(e=>e)).length?100:o.length;if(o=o.splice(0,n),!seoHelper.isKeywordInText(t,o.join(" ")))return"nok";if(1<t.split(" ").length)return"ok";if(o.length)for(let e=0;e<n;e++)o[e]=o[e].replace(".",""),o[e]=o[e].replace(",",""),o[e]=o[e].replace("?",""),o[e]=o[e].replace("!",""),o[e]=o[e].replace(":",""),o[e]=o[e].replace(";","");return o.includes(t)?"ok":"nok"}},{id:"more",type:"check",label:__("Many more powerful SEO checkpoints"),inPro:!0,section:"content"},{id:"more",type:"check",label:__("Many more powerful SEO checkpoints"),inPro:!0,section:"keyword"}],checkResults:{}};
     1const{__}=window.wp.i18n;window.diagnoseo={additionalKeywordLimit:10,additionalKeywordCount:0,RelatedKeywordsInPost:0,checks:[{id:"title-not-too-long",type:"check",label:__("Title not too long"),section:"content",test:e=>{var{metaTitle:t,postTitle:e}=e;if(!t&&!e)return"nok";t=t||e;const o=document.querySelector(".title-sample");o.textContent=t;e=o.clientWidth,t=t.length;return e<=600?60<t?"nok medium-nok":t<=60?"ok":"nok":"nok"}},{id:"title-not-too-short",type:"check",label:__("Title not too short"),section:"content",test:e=>{var{metaTitle:t,postTitle:e}=e;if(!t&&!e)return"nok";e=(t||e).length;return 30<=e?30<=e&&e<35?"nok medium-nok":35<=e?"ok":"nok":"nok"}},{id:"description-not-too-long",type:"check",label:__("Description not too long"),section:"content",test:e=>{var{metaDescription:t}=e;if(!t)return"nok";e=document.querySelector(".description-sample"),t=t.length;if(e.clientWidth<=990){if(155<t)return"nok medium-nok";if(t<=155)return"ok"}return"nok"}},{id:"description-not-too-short",type:"check",label:__("Description not too short"),section:"content",test:e=>{var{metaDescription:e}=e;if(!e)return"nok";e=e.length;if(70<=e){if(e<130)return"nok medium-nok";if(130<=e)return"ok"}return"nok"}},{id:"too-long-sentences",type:"check",label:__("No sentences with more than 20 words"),section:"content",test:e=>{var{postContent:e}=e;e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll("</p>",".</p>")).replaceAll("</h1>",".</h1>")).replaceAll("</h2>",".</h2>")).replaceAll("</h3>",".</h3>")).replaceAll("</h4>",".</h4>")).replaceAll("</h5>",".</h5>")).replaceAll("</h6>",".</h6>")).replaceAll("</li>",".</li>");const t=(e=seoHelper.stripTags(e)).split(/\.|\?|!/);var o=!1;return t.length&&t.forEach(e=>{o=o||20<seoHelper.countWords(e)}),o?"nok":"ok"}},{id:"too-many-words",type:"check",label:__("No paragraphs with more than 100 words"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("p");var n=!1;return o.length&&o.forEach(e=>{100<seoHelper.countWords(e.textContent)&&(n=!0)}),n?"nok":"ok"}},{id:"too-many-sentences",type:"check",label:__("No paragraphs with more than 5 sentences"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("p");var n=!1;return o.length&&o.forEach(e=>{5<e.textContent.split(/\.|\?|!/).filter(e=>!!e.trim()).length&&(n=!0)}),n?"nok":"ok"}},{id:"internal-links-present",type:"check",label:__("Contains internal links"),section:"content",test:e=>{const t=seoHelper.createMarkupEl(e.postContent),o=t.querySelectorAll("a");var n=!1;return o.forEach(e=>{e=e.getAttribute("href")||"";e&&(e.includes("http://"+window.location.hostname)||e.includes("https://"+window.location.hostname)||"/"===e.substr(0,1)||"./"===e.substr(0,2))&&(n=!0)}),n?"ok":"nok"}},{id:"strong-present",type:"check",label:__("Contains bold text (strong tag)"),section:"content",test:e=>seoHelper.countElements(e.postContent,"strong")?"ok":"nok"},{id:"readability",type:"stats",label:__("Readability score"),order:"label value comment",section:"content",test:e=>{var{postContent:t}=e,o=(t=seoHelper.stripTags(t)).split(/\.|\?|!/);o=(o=o.map(e=>e.trim())).filter(e=>e&&" "!==e&&"\n"!==e);e=(t=t.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/g," ")).split(" ");e=(e=e.map(e=>e.trim())).filter(e=>e&&""!==e&&"\n"!==e);var t=seoHelper.countSyllables(t),n=206.835-e.length/o.length*1.015-t/e.length*84.6;(n=n.toFixed(2))<0?n=0:100<n&&(n=100);var r="",s="";switch(!0){case isNaN(n):n=__("N/A"),r="",s="nok";break;case 90<n:r=__("Very easy to read","diagnoseo"),s="ok";break;case 80<n&&n<=90:r=__("Easy to read","diagnoseo"),s="ok";break;case 70<n&&n<=80:r=__("Fairly easy to read","diagnoseo"),s="ok";break;case 60<n&&n<=70:r=__("Average reading ease","diagnoseo"),s="nok medium-nok";break;case 50<n&&n<=60:r=__("Fairly difficult to read","diagnoseo"),s="nok";break;case 30<n&&n<=50:r=__("Difficult to read","diagnoseo"),s="nok";break;case 10<n&&n<=30:r=__("Very difficult to read","diagnoseo"),s="nok";break;case n<=10:r=__("Extremely difficult to read","diagnoseo"),s="nok"}return{value:n,comment:r=r&&` (${r})`,status:s}}},{id:"est-reading-time",type:"stats",label:__("Estimated reading time"),section:"content",order:"label value",test:e=>{var{postContent:t}=e,e=seoHelper.countWords(t),t=Math.floor(e/225),e=Math.floor(e%225/3.75);return{value:`${t} ${__("min")} ${e} ${__("s")}`}}},{id:"minimal-word-count",type:"check",label:__("Minimal word count"),section:"content",postTypes:["post","page"],inPro:!0},{id:"words",type:"stats",label:__("words"),section:"content",test:e=>{var{postContent:e}=e;return{value:seoHelper.countWords(e)}}},{id:"chars",type:"stats",label:__("characters"),section:"content",test:e=>({value:e.postContent.length||0})},{id:"sentences",type:"stats",label:__("sentences"),section:"content",test:e=>{var{postContent:e}=e,e=(e=e.replace(/(\r\n|\n|\r)/gm," ")).split(/\.|\?|!/);return{value:(e=(e=e.map(e=>e.trim())).filter(e=>e&&" "!==e&&"\n"!==e)).length||0}}},{id:"paragraphs",type:"stats",label:__("paragraphs"),section:"content",test:e=>({value:seoHelper.countElements(e.postContent,"p")})},{id:"headings",type:"stats",label:__("Headings"),inPro:!0,section:"content"},{id:"optimal-heading-number",type:"check",label:__("Optimal number of headings"),inPro:!0,section:"content"},{id:"images",type:"stats",label:__("Images"),inPro:!0,section:"content"},{id:"optimal-image-number",type:"check",label:__("Optimal number of images"),inPro:!0,section:"content"},{id:"too-long-headings",type:"check",label:__("No too long headings"),inPro:!0,section:"content"},{id:"toc-block",type:"check",label:__("Use Table of Contents block"),inPro:!0,section:"content"},{id:"keyword-exists",type:"check",label:__("Keyword is provided"),section:"keyword",test:e=>e.keyword?"ok":"nok"},{id:"keyword-unique",type:"check",label:__("Focus Keyword not used before"),section:"keyword",test:async o=>{var n=document.querySelector(".keyword-unique");if(o.keyword){let e=new URLSearchParams(window.location.search);var r=Object.fromEntries(e.entries()),r=`${diagnoseoRestUrl}diagnoseo/v1/check-posts-keyword/${o.keyword}/${r.post||0}`;let t=0===await(await fetch(r)).json()?"ok":"nok";n?n&&(n.classList.remove("ok","nok"),n.classList.add(t)):setTimeout(()=>{(n=document.querySelector(".keyword-unique"))&&(n.classList.remove("ok","nok"),n.classList.add(t))},200)}else n&&n.classList.add("ok")}},{id:"keyword-in-title",type:"check",label:__("Keyword present in title tag"),section:"keyword",test:e=>{var{keyword:t,postTitle:o,metaTitle:e}=e;return seoHelper.isKeywordInText(t,e||o)?"ok":"nok"}},{id:"keyword-in-title-beginning",type:"check",label:__("Keyword in the beginning of the title tag"),section:"keyword",test:e=>{var{keyword:t,postTitle:o,metaTitle:e}=e;if(!t)return"nok";o=(o=e||o).toLowerCase(),t=t.toLowerCase();const n=new RegExp("^"+t);return n.test(o)?"ok":"nok"}},{id:"keyword-in-descr",type:"check",label:__("Keyword present in meta description tag"),section:"keyword",test:e=>{var{keyword:t,metaDescription:e}=e;return seoHelper.isKeywordInText(t,e)?"ok":"nok"}},{id:"keyword-in-slug",type:"check",label:__("Keyword present in URL slug"),section:"keyword",test:e=>{var{keyword:t,slug:o,postTitle:e}=e;return t&&(o=o||seoHelper.slugify(e)).includes(seoHelper.slugify(t))?"ok":"nok"}},{id:"slug-length-ok",type:"check",label:__("URL slug length"),section:"keyword",test:e=>{var{slug:t,postTitle:e}=e;if(!t&&!e)return"nok";if((t=t||seoHelper.slugify(e)).length<=60&&t.split("-").length<=5)return"ok";return"nok"}},{id:"keyword-in-h1",type:"check",label:__("Keyword present in H1 element"),section:"keyword",test:e=>{var{keyword:t,postContent:o,postTitle:e}=e;return seoHelper.isKeywordInText(t,e)||seoHelper.isKeywordInAnyElement(t,o,"h1")?"ok":"nok"}},{id:"keyword-in-image-alt",type:"check",label:__("Keyword present in any image alt attribute"),section:"keyword",test:e=>{var{keyword:t,postContent:o,featuredImage:e}=e;return seoHelper.isKeywordInAnyAlt(t,o,e)?"ok":"nok"}},{id:"keyword-in-image-filename",type:"check",label:__("Keyword in image file name"),section:"keyword",inPro:!0,hidden:!0},{id:"keyword-not-in-ext-link",type:"check",label:__("Keyword NOT present in external link text"),section:"keyword",test:e=>{const{keyword:o,postContent:t}=e;if(!o)return"ok";const n=seoHelper.createMarkupEl(t);var r=!1;const s=n.querySelectorAll("a");return s.forEach(e=>{const t=e.getAttribute("href")||"";t.includes("http://"+window.location.hostname)||t.includes("https://"+window.location.hostname)||"/"===t.substr(0,1)||"./"===t.substr(0,2)||!seoHelper.isKeywordInText(o,e.textContent)||(r=!0)}),r?"nok":"ok"}},{id:"keyword-in-first-words",type:"check",label:__("Keyword present within first 100 words"),section:"keyword",test:e=>{var{keyword:t,postContent:e}=e;if(!t)return"nok";var t=t.trim(),o=(e=seoHelper.stripTags(e)).toLowerCase().split(/\s|\n/),n=100<=(o=o.filter(e=>e)).length?100:o.length;if(o=o.splice(0,n),!seoHelper.isKeywordInText(t,o.join(" ")))return"nok";if(1<t.split(" ").length)return"ok";if(o.length)for(let e=0;e<n;e++)o[e]=o[e].replace(".",""),o[e]=o[e].replace(",",""),o[e]=o[e].replace("?",""),o[e]=o[e].replace("!",""),o[e]=o[e].replace(":",""),o[e]=o[e].replace(";","");return o.includes(t)?"ok":"nok"}},{id:"more",type:"check",label:__("Many more powerful SEO checkpoints"),inPro:!0,section:"content"},{id:"more",type:"check",label:__("Many more powerful SEO checkpoints"),inPro:!0,section:"keyword"}],checkResults:{}};
  • diagnoseo/trunk/readme.txt

    r2963171 r2984954  
    33Tags: SEO, AI, ChatGPT, GPT, OpenAI, schema, XML sitemap, content analysis, breadcrumbs, meta title, meta description, readability, open graph, knowledge graph, google analytics, rich snippets, google, twitter card, performance, sitemap, redirection, woocommerce seo, local seo, seo audit, seo plugin, canonical, robots, content, metatags, indexnow, schema.org
    44Requires at least: 4.7
    5 Tested up to: 6.2.2
    6 Stable tag: 1.2.15
     5Tested up to: 6.3.2
     6Stable tag: 1.2.16
    77Requires PHP: 5.0
    88License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.