File Editor
Directories:
.. (Back)
externals
languages
Files:
academy.js
addon-installation.js
admin-global.js
admin-modules.js
analysis-worker.js
api-client.js
block-editor.js
bulk-editor.js
classic-editor.js
crawl-settings.js
dashboard-widget.js
dynamic-blocks.js
edit-page.js
editor-modules.js
elementor.js
externals-components.js
externals-contexts.js
externals-redux.js
faq-block.js
filter-explanation.js
first-time-configuration.js
frontend-inspector-resources.js
help-scout-beacon.js
how-to-block.js
import.js
indexation.js
installation-success.js
integrations-page.js
introductions.js
network-admin.js
new-dashboard.js
new-settings.js
post-edit.js
quick-edit-handler.js
react-select.js
redirect-old-features-tab.js
reindex-links.js
settings.js
support.js
term-edit.js
used-keywords-assessment.js
wincher-dashboard-widget.js
workouts.js
Create New File
Create
Edit File: dashboard-widget.js
(()=>{"use strict";const e=window.React,t=window.wp.element,s=window.yoast.componentsNew,o=window.yoast.styleGuide,i=window.yoast.analysisReport,a=window.yoast.helpers;class r extends t.Component{constructor(){super(),this.state={statistics:null,feed:null,isDataFetched:!1}}componentDidMount(){const e=jQuery("#wpseo-dashboard-overview-hide");e.is(":checked")&&this.fetchData(),e.on("click",(()=>{this.fetchData()}))}fetchData(){this.state.isDataFetched||(this.getStatistics(),this.getFeed(),this.setState({isDataFetched:!0}))}static getColorFromScore(e){return o.colors[`$color_${e}`]||o.colors.$color_grey}getStatistics(){wpseoApi.get("statistics",(e=>{const t={};e&&e.seo_scores&&(t.seoScores=e.seo_scores.map((e=>({value:parseInt(e.count,10),color:r.getColorFromScore(e.seo_rank),html:`<a href="${e.link}">${e.label}</a>`}))),t.header=jQuery(`<div>${e.header}</div>`).text(),this.setState({statistics:t}))}))}getFeed(){(0,a.getPostFeed)("https://yoast.com/feed/widget/?wp_version="+wpseoDashboardWidgetL10n.wp_version+"&php_version="+wpseoDashboardWidgetL10n.php_version,2).then((e=>{e.items=e.items.map((e=>(e.description=jQuery(`<div>${e.description}</div>`).text(),e.description=e.description.replace(`The post ${e.title} appeared first on Yoast.`,"").trim(),e))),this.setState({feed:e})})).catch((e=>console.log(e)))}getSeoAssessment(){return null===this.state.statistics?null:(0,e.createElement)(i.SiteSEOReport,{key:"yoast-seo-posts-assessment",seoAssessmentText:this.state.statistics.header,seoAssessmentItems:this.state.statistics.seoScores})}getYoastFeed(){return null===this.state.feed?null:(0,e.createElement)(s.ArticleList,{className:"wordpress-feed",key:"yoast-seo-blog-feed",title:wpseoDashboardWidgetL10n.feed_header,feed:this.state.feed,footerLinkText:wpseoDashboardWidgetL10n.feed_footer})}render(){const t=[this.getSeoAssessment(),this.getYoastFeed()].filter((e=>null!==e));return 0===t.length?null:(0,e.createElement)("div",null,t)}}const n=document.getElementById("yoast-seo-dashboard-widget");n&&(0,t.render)((0,e.createElement)(r,null),n)})();
Save Changes
Rename File
Rename