diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist
index c71ab7fe143..6209556d799 100644
--- a/.phpcs.xml.dist
+++ b/.phpcs.xml.dist
@@ -227,6 +227,12 @@
/inc/wpseo-functions-deprecated\.php$
+
+
+ /src/deprecated/*
+ /inc/wpseo-functions-deprecated\.php$
+
+
diff --git a/admin/class-customizer.php b/admin/class-customizer.php
deleted file mode 100644
index bc6b9e8c7c1..00000000000
--- a/admin/class-customizer.php
+++ /dev/null
@@ -1,249 +0,0 @@
- '',
- 'type' => 'option',
- 'transport' => 'refresh',
- ];
-
- /**
- * Default arguments for the breadcrumbs customizer control object.
- *
- * @var array
- */
- private $default_control_args = [
- 'label' => '',
- 'type' => 'text',
- 'section' => 'wpseo_breadcrumbs_customizer_section',
- 'settings' => '',
- 'context' => '',
- ];
-
- /**
- * Construct Method.
- */
- public function __construct() {
- add_action( 'customize_register', [ $this, 'wpseo_customize_register' ] );
- }
-
- /**
- * Function to support WordPress Customizer.
- *
- * @param WP_Customize_Manager $wp_customize Manager class instance.
- *
- * @return void
- */
- public function wpseo_customize_register( $wp_customize ) {
- if ( ! WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ) ) {
- return;
- }
-
- $this->wp_customize = $wp_customize;
-
- $this->breadcrumbs_section();
- $this->breadcrumbs_blog_show_setting();
- $this->breadcrumbs_separator_setting();
- $this->breadcrumbs_home_setting();
- $this->breadcrumbs_prefix_setting();
- $this->breadcrumbs_archiveprefix_setting();
- $this->breadcrumbs_searchprefix_setting();
- $this->breadcrumbs_404_setting();
- }
-
- /**
- * Add the breadcrumbs section to the customizer.
- *
- * @return void
- */
- private function breadcrumbs_section() {
- $section_args = [
- /* translators: %s is the name of the plugin */
- 'title' => sprintf( __( '%s Breadcrumbs', 'wordpress-seo' ), 'Yoast SEO' ),
- 'priority' => 999,
- 'active_callback' => [ $this, 'breadcrumbs_active_callback' ],
- ];
-
- $this->wp_customize->add_section( 'wpseo_breadcrumbs_customizer_section', $section_args );
- }
-
- /**
- * Returns whether or not the breadcrumbs are active.
- *
- * @return bool
- */
- public function breadcrumbs_active_callback() {
- return current_theme_supports( 'yoast-seo-breadcrumbs' ) || WPSEO_Options::get( 'breadcrumbs-enable' );
- }
-
- /**
- * Adds the breadcrumbs show blog checkbox.
- *
- * @return void
- */
- private function breadcrumbs_blog_show_setting() {
- $index = 'breadcrumbs-display-blog-page';
- $control_args = [
- 'label' => __( 'Show blog page in breadcrumbs', 'wordpress-seo' ),
- 'type' => 'checkbox',
- 'active_callback' => [ $this, 'breadcrumbs_blog_show_active_cb' ],
- ];
-
- $this->add_setting_and_control( $index, $control_args );
- }
-
- /**
- * Returns whether or not to show the breadcrumbs blog show option.
- *
- * @return bool
- */
- public function breadcrumbs_blog_show_active_cb() {
- return get_option( 'show_on_front' ) === 'page';
- }
-
- /**
- * Adds the breadcrumbs separator text field.
- *
- * @return void
- */
- private function breadcrumbs_separator_setting() {
- $index = 'breadcrumbs-sep';
- $control_args = [
- 'label' => __( 'Breadcrumbs separator:', 'wordpress-seo' ),
- ];
- $id = 'wpseo-breadcrumbs-separator';
-
- $this->add_setting_and_control( $index, $control_args, $id );
- }
-
- /**
- * Adds the breadcrumbs home anchor text field.
- *
- * @return void
- */
- private function breadcrumbs_home_setting() {
- $index = 'breadcrumbs-home';
- $control_args = [
- 'label' => __( 'Anchor text for the homepage:', 'wordpress-seo' ),
- ];
-
- $this->add_setting_and_control( $index, $control_args );
- }
-
- /**
- * Adds the breadcrumbs prefix text field.
- *
- * @return void
- */
- private function breadcrumbs_prefix_setting() {
- $index = 'breadcrumbs-prefix';
- $control_args = [
- 'label' => __( 'Prefix for breadcrumbs:', 'wordpress-seo' ),
- ];
-
- $this->add_setting_and_control( $index, $control_args );
- }
-
- /**
- * Adds the breadcrumbs archive prefix text field.
- *
- * @return void
- */
- private function breadcrumbs_archiveprefix_setting() {
- $index = 'breadcrumbs-archiveprefix';
- $control_args = [
- 'label' => __( 'Prefix for archive pages:', 'wordpress-seo' ),
- ];
-
- $this->add_setting_and_control( $index, $control_args );
- }
-
- /**
- * Adds the breadcrumbs search prefix text field.
- *
- * @return void
- */
- private function breadcrumbs_searchprefix_setting() {
- $index = 'breadcrumbs-searchprefix';
- $control_args = [
- 'label' => __( 'Prefix for search result pages:', 'wordpress-seo' ),
- ];
-
- $this->add_setting_and_control( $index, $control_args );
- }
-
- /**
- * Adds the breadcrumb 404 prefix text field.
- *
- * @return void
- */
- private function breadcrumbs_404_setting() {
- $index = 'breadcrumbs-404crumb';
- $control_args = [
- 'label' => __( 'Breadcrumb for 404 pages:', 'wordpress-seo' ),
- ];
-
- $this->add_setting_and_control( $index, $control_args );
- }
-
- /**
- * Adds the customizer setting and control.
- *
- * @param string $index Array key index to use for the customizer setting.
- * @param array $control_args Customizer control object arguments.
- * Only those different from the default need to be passed.
- * @param string|null $id Optional. Customizer control object ID.
- * Will default to 'wpseo-' . $index.
- * @param array $custom_settings Optional. Customizer setting arguments.
- * Only those different from the default need to be passed.
- *
- * @return void
- */
- private function add_setting_and_control( $index, $control_args, $id = null, $custom_settings = [] ) {
- $setting = sprintf( $this->setting_template, $index );
- $control_args = array_merge( $this->default_control_args, $control_args );
- $control_args['settings'] = $setting;
-
- $settings_args = $this->default_setting_args;
- if ( ! empty( $custom_settings ) ) {
- $settings_args = array_merge( $settings_args, $custom_settings );
- }
-
- if ( ! isset( $id ) ) {
- $id = 'wpseo-' . $index;
- }
-
- $this->wp_customize->add_setting( $setting, $settings_args );
-
- $control = new WP_Customize_Control( $this->wp_customize, $id, $control_args );
- $this->wp_customize->add_control( $control );
- }
-}
diff --git a/composer.json b/composer.json
index fda1dd8e7f7..bd9aec02bd4 100644
--- a/composer.json
+++ b/composer.json
@@ -92,8 +92,8 @@
"Yoast\\WP\\SEO\\Composer\\Actions::check_coding_standards"
],
"check-cs-thresholds": [
- "@putenv YOASTCS_THRESHOLD_ERRORS=2548",
- "@putenv YOASTCS_THRESHOLD_WARNINGS=267",
+ "@putenv YOASTCS_THRESHOLD_ERRORS=2544",
+ "@putenv YOASTCS_THRESHOLD_WARNINGS=253",
"Yoast\\WP\\SEO\\Composer\\Actions::check_cs_thresholds"
],
"check-cs": [
diff --git a/package.json b/package.json
index dae11309341..deee438179a 100644
--- a/package.json
+++ b/package.json
@@ -75,7 +75,7 @@
"webpack-bundle-analyzer": "^4.9.1"
},
"yoast": {
- "pluginVersion": "22.7-RC3"
+ "pluginVersion": "22.7-RC5"
},
"version": "0.0.0"
}
diff --git a/packages/js/src/initializers/post-scraper.js b/packages/js/src/initializers/post-scraper.js
index 62ae0ed3d81..ecf210e63b1 100644
--- a/packages/js/src/initializers/post-scraper.js
+++ b/packages/js/src/initializers/post-scraper.js
@@ -248,7 +248,6 @@ export default function initPostScraper( $, store, editorData ) {
marker: getApplyMarks( store ),
contentAnalysisActive: isContentAnalysisActive(),
keywordAnalysisActive: isKeywordAnalysisActive(),
- hasSnippetPreview: false,
debouncedRefresh: false,
// eslint-disable-next-line new-cap
researcher: new window.yoast.Researcher.default(),
diff --git a/packages/js/src/initializers/term-scraper.js b/packages/js/src/initializers/term-scraper.js
index 00478ca506e..4467fc7085f 100644
--- a/packages/js/src/initializers/term-scraper.js
+++ b/packages/js/src/initializers/term-scraper.js
@@ -289,7 +289,6 @@ export default function initTermScraper( $, store, editorData ) {
locale: wpseoScriptData.metabox.contentLocale,
contentAnalysisActive: isContentAnalysisActive(),
keywordAnalysisActive: isKeywordAnalysisActive(),
- hasSnippetPreview: false,
debouncedRefresh: false,
// eslint-disable-next-line new-cap
researcher: new window.yoast.Researcher.default(),
diff --git a/packages/js/src/shared-admin/helpers/search-appearance-description-mention.js b/packages/js/src/shared-admin/helpers/search-appearance-description-mention.js
index 17050c6bee7..e01297fa4f6 100644
--- a/packages/js/src/shared-admin/helpers/search-appearance-description-mention.js
+++ b/packages/js/src/shared-admin/helpers/search-appearance-description-mention.js
@@ -66,7 +66,7 @@ const filterReplacementVariableEditorMentions = ( mentions, { fieldId } ) => {
const isProduct = select( "yoast-seo/editor" ).getIsProduct();
const isPreviewField = fieldId === "yoast-google-preview-description-metabox" || fieldId === "yoast-google-preview-description-modal";
const dateCharacters = getDate().length;
- const separatorCharacters = 3;
+ const emDashCharacters = 3;
const newMentions = [];
if ( ! isProduct && isPreviewField ) {
newMentions.push(
@@ -79,12 +79,13 @@ const filterReplacementVariableEditorMentions = ( mentions, { fieldId } ) => {
/* translators: %s expands to the amount of characters */
_n( "The 'Date' variable is fixed and adds %s character to the length of your meta description.", "The 'Date' variable is fixed and adds %s characters to the length of your meta description.", dateCharacters, "wordpress-seo" ), dateCharacters ) }
-
-
+
+
{ sprintf(
/* translators: %s expands to the amount of characters */
- _n( "The 'Separator' variable is fixed and adds %s character to the length of your meta description.", "The 'Separator' variable is fixed and adds %s characters to the length of your meta description.", separatorCharacters, "wordpress-seo" ), separatorCharacters ) }
+ _n( "The em dash (—) is fixed and adds %s character to the length of your meta description.", "The em dash (—) is fixed and adds %s characters to the length of your meta description.", emDashCharacters, "wordpress-seo" ), emDashCharacters ) }
+
);
diff --git a/packages/js/src/structured-data-blocks/faq/block.js b/packages/js/src/structured-data-blocks/faq/block.js
index 337ae5b0d7b..ef25c847114 100644
--- a/packages/js/src/structured-data-blocks/faq/block.js
+++ b/packages/js/src/structured-data-blocks/faq/block.js
@@ -1,4 +1,5 @@
/* External dependencies */
+import { useBlockProps } from "@wordpress/block-editor";
import { registerBlockType } from "@wordpress/blocks";
/* Internal dependencies */
@@ -17,12 +18,16 @@ registerBlockType( block, {
* @returns {Component} The editor component.
*/
edit: ( { attributes, setAttributes, className } ) => {
+ const blockProps = useBlockProps();
+
// Because setAttributes is quite slow right after a block has been added we fake having a single step.
if ( ! attributes.questions || attributes.questions.length === 0 ) {
attributes.questions = [ { id: Faq.generateId( "faq-question" ), question: [], answer: [] } ];
}
- return ;
+ return
+
+
;
},
/**
diff --git a/packages/js/src/structured-data-blocks/how-to/block.js b/packages/js/src/structured-data-blocks/how-to/block.js
index f28b1f63d51..4418191a8bc 100644
--- a/packages/js/src/structured-data-blocks/how-to/block.js
+++ b/packages/js/src/structured-data-blocks/how-to/block.js
@@ -1,4 +1,5 @@
/* External dependencies */
+import { useBlockProps } from "@wordpress/block-editor";
import { registerBlockType } from "@wordpress/blocks";
/* Internal dependencies */
@@ -17,12 +18,16 @@ registerBlockType( block, {
* @returns {Component} The editor component.
*/
edit: ( { attributes, setAttributes, className } ) => {
+ const blockProps = useBlockProps();
+
// Because setAttributes is quite slow right after a block has been added we fake having a single step.
if ( ! attributes.steps || attributes.steps.length === 0 ) {
attributes.steps = [ { id: HowTo.generateId( "how-to-step" ), name: [], text: [] } ];
}
- return ;
+ return
+
+
;
},
/**
diff --git a/packages/yoastseo/spec/appSpec.js b/packages/yoastseo/spec/appSpec.js
index c7f23c768a6..ea9f8f4aad8 100644
--- a/packages/yoastseo/spec/appSpec.js
+++ b/packages/yoastseo/spec/appSpec.js
@@ -1,13 +1,10 @@
import MissingArgument from "../src/errors/missingArgument.js";
-import SnippetPreview from "../src/snippetPreview/snippetPreview.js";
import App from "../src/app.js";
// Mock these function to prevent us from needing an actual DOM in the tests.
-App.prototype.createSnippetPreview = function() {};
App.prototype.showLoadingDialog = function() {};
App.prototype.updateLoadingDialog = function() {};
App.prototype.removeLoadingDialog = function() {};
-App.prototype.initSnippetPreview = function() {};
App.prototype.runAnalyzer = function() {};
// Makes lodash think this is a valid HTML element
@@ -53,37 +50,6 @@ describe( "Creating an App", function() {
} ).toThrowError( MissingArgument );
} );
- it( "throws on a missing snippet preview", function() {
- expect( function() {
- new App( {
- targets: {
- output: "outputID",
- },
- callbacks: {
- getData: () => {
- return {};
- },
- },
- } );
- } ).toThrowError( MissingArgument );
- } );
-
- it( "accepts a Snippet Preview object", function() {
- new App( {
- targets: {
- output: "outputID",
- },
- callbacks: {
- getData: () => {
- return {};
- },
- },
- snippetPreview: new SnippetPreview( {
- targetElement: mockElement,
- } ),
- } );
- } );
-
it( "should work without an output ID", function() {
new App( {
targets: {
diff --git a/packages/yoastseo/spec/languageProcessing/helpers/word/countMetaDescriptionLengthSpec.js b/packages/yoastseo/spec/languageProcessing/helpers/word/countMetaDescriptionLengthSpec.js
index 3dfbaa33c6e..3b18b2f3639 100644
--- a/packages/yoastseo/spec/languageProcessing/helpers/word/countMetaDescriptionLengthSpec.js
+++ b/packages/yoastseo/spec/languageProcessing/helpers/word/countMetaDescriptionLengthSpec.js
@@ -11,7 +11,12 @@ describe( "the meta description length research", function() {
expect( result ).toBe( 44 );
} );
- it( "returns the length (0) of the description", function() {
+ it( "returns the length of the description when the meta description is empty", function() {
+ const result = metaDescriptionLength( "9 September 2021", "" );
+ expect( result ).toBe( 19 );
+ } );
+
+ it( "returns the length of the description when both fields are empty", function() {
const result = metaDescriptionLength( "", "" );
expect( result ).toBe( 0 );
} );
diff --git a/packages/yoastseo/spec/snippetPreview/snippetPreviewSpec.js b/packages/yoastseo/spec/snippetPreview/snippetPreviewSpec.js
deleted file mode 100644
index 1176941b544..00000000000
--- a/packages/yoastseo/spec/snippetPreview/snippetPreviewSpec.js
+++ /dev/null
@@ -1,243 +0,0 @@
-import SnippetPreview from "../../src/snippetPreview/snippetPreview.js";
-import "../../src/app.js";
-import Factory from "../../src/helpers/factory.js";
-
-describe( "The snippet preview constructor", function() {
- it( "accepts an App object as an opts property", function() {
- var mockApp = {
- rawData: {
- snippetTitle: "",
- snippetCite: "",
- snippetMeta: "",
- },
- };
- // Makes lodash think this is a valid HTML element
- var mockElement = [];
- mockElement.nodeType = 1;
-
- var snippetPreview = new SnippetPreview( {
- analyzerApp: mockApp,
- targetElement: mockElement,
- } );
-
- expect( snippetPreview.refObj ).toBe( mockApp );
- } );
-} );
-
-describe( "The SnippetPreview format functions", function() {
- it( "formats texts to use in the SnippetPreview", function() {
- // Makes lodash think this is a valid HTML element
- var mockElement = [];
- mockElement.nodeType = 1;
-
- var mockApp = {
- rawData: {
- snippetTitle: "snippetTitle keyword",
- snippetCite: "homeurl",
- snippetMeta: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur lacinia eget neque ut porttitor. Quisque semper ligula leo. Nullam convallis ligula et dapibus dictum. Duis imperdiet nisl id orci hendrerit imperdiet. Praesent commodo ornare ante vitae placerat. Aliquam leo justo, imperdiet ut purus at, pharetra semper eros. In cursus faucibus efficitur.",
- keyword: "keyword",
- },
- pluggable: {
- loaded: true,
- /**
- * A mock applyModifications function.
- *
- * @param {string} name The name of the modification to apply.
- * @param {*} text Some data to apply modification to.
- *
- * @returns {*} The data to which the modification was applied.
- */
- _applyModifications: function( name, text ) {
- return text;
- },
- },
- };
-
- var snippetPreview = new SnippetPreview( {
- analyzerApp: mockApp,
- targetElement: mockElement,
- } );
-
- expect( snippetPreview.formatTitle() ).toBe( "snippetTitle keyword" );
- expect( snippetPreview.formatMeta() ).toBe( "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur lacinia eget neque ut porttitor. Quisque semper ligula leo. Nullam convallis ligula et da" );
- expect( snippetPreview.formatCite() ).toBe( "homeurl/" );
- expect( snippetPreview.formatKeyword( "a string with keyword" ) ).toBe( "a string with keyword" );
-
- mockApp = {
- rawData: {
- snippetCite: "key-word",
- keyword: "key word",
- },
- pluggable: {
- loaded: true,
- /**
- * A mock applyModifications function.
- *
- * @param {string} name The name of the modification to apply.
- * @param {*} text Some data to apply modification to.
- *
- * @returns {*} The data to which the modification was applied.
- */
- _applyModifications: function( name, text ) {
- return text;
- },
- },
- };
-
- snippetPreview = new SnippetPreview( {
- analyzerApp: mockApp,
- targetElement: mockElement,
- } );
- expect( snippetPreview.formatCite() ).toBe( "key-word/" );
- } );
-
- describe( "#formatKeywordUrl", function() {
- var snippetPreview, refObj, mockElement;
-
- beforeEach( function() {
- mockElement = Factory.buildMockElement();
-
- refObj = {
- rawData: { keyword: "key'word" },
- };
-
- snippetPreview = new SnippetPreview( {
- analyzerApp: refObj,
- targetElement: mockElement,
- } );
- } );
-
- it( "should highlight a keyword with an apostrophe", function() {
- // Var keyword = "apo's";
- snippetPreview.data.urlPath = "keyword";
-
- expect( snippetPreview.formatCite() ).toBe( "keyword/" );
- } );
- } );
-
- describe( "The snippet preview format functions with special characters like periods", function() {
- // Makes lodash think this is a valid HTML element
- var mockElement = [];
- mockElement.nodeType = 1;
-
- var mockApp = {
- rawData: {
- snippetMeta: "This is the Yoast SEO 3.9 release",
- keyword: "Yoast SEO 3.9",
- },
- pluggable: {
- loaded: true,
- /**
- * A mock applyModifications function.
- *
- * @param {string} name The name of the modification to apply.
- * @param {*} text Some data to apply modification to.
- *
- * @returns {*} The data to which the modification was applied.
- */
- _applyModifications: function( name, text ) {
- return text;
- },
- },
- };
-
- var snippetPreview = new SnippetPreview( {
- analyzerApp: mockApp,
- targetElement: mockElement,
- } );
-
- it( "should highlight the keywords", function() {
- expect( snippetPreview.formatMeta() ).toBe( "This is the Yoast SEO 3.9 release" );
- } );
- } );
- describe( "The snippet preview format functions with special characters like periods", function() {
- // Makes lodash think this is a valid HTML element
- var mockElement = [];
- mockElement.nodeType = 1;
-
- var mockApp = {
- rawData: {
- snippetMeta: "If you like Yoast SEO, please give a 5* rating",
- keyword: "5* rating",
- },
- pluggable: {
- loaded: true,
- /**
- * A mock applyModifications function.
- *
- * @param {string} name The name of the modification to apply.
- * @param {*} text Some data to apply modification to.
- *
- * @returns {*} The data to which the modification was applied.
- */
- _applyModifications: function( name, text ) {
- return text;
- },
- },
- };
-
- var snippetPreview = new SnippetPreview( {
- analyzerApp: mockApp,
- targetElement: mockElement,
- } );
-
- it( "should highlight the keywords", function() {
- expect( snippetPreview.formatMeta() ).toBe( "If you like Yoast SEO, please give a 5* rating" );
- } );
- } );
-} );
-
-describe( "Adds dashes to the keyword for highlighting in the snippet", function() {
- it( "returns a keyword with strong tags", function() {
- var mockApp = {
- rawData: {
- keyword: "keyword",
- },
- };
- var mockElement = [];
- mockElement.nodeType = 1;
-
- var snippetPreview = new SnippetPreview( {
- analyzerApp: mockApp,
- targetElement: mockElement,
- } );
-
- expect( snippetPreview.formatKeyword( "this is a keyword" ) ).toBe( "this is a keyword" );
- } );
-} );
-
-describe( "Adds dashes to the keyword for highlighting in the snippet", function() {
- it( "returns a keyword with strong tags", function() {
- var mockApp = {
- rawData: {
- keyword: "key-word",
- },
- };
- var mockElement = [];
- mockElement.nodeType = 1;
-
- var snippetPreview = new SnippetPreview( {
- analyzerApp: mockApp,
- targetElement: mockElement,
- } );
- expect( snippetPreview.formatKeyword( "this is a key-word with dash" ) ).toBe( "this is a key-word with dash" );
- } );
-} );
-
-describe( "Formats the keyword in the title with diacritics", function() {
- it( "returns a keyword with strong tags", function() {
- var mockApp = {
- rawData: {
- keyword: "Slovníček pojmû",
- },
- };
- var mockElement = [];
- mockElement.nodeType = 1;
-
- var snippetPreview = new SnippetPreview( {
- analyzerApp: mockApp,
- targetElement: mockElement,
- } );
- expect( snippetPreview.formatKeyword( "this is a Slovníček pojmû with diacritic" ) ).toBe( "this is a Slovníček pojmû with diacritic" );
- } );
-} );
diff --git a/packages/yoastseo/src/app.js b/packages/yoastseo/src/app.js
index 17f63fce75a..da808c96d21 100644
--- a/packages/yoastseo/src/app.js
+++ b/packages/yoastseo/src/app.js
@@ -1,7 +1,7 @@
import { setLocaleData } from "@wordpress/i18n";
-import { debounce, defaultsDeep, forEach, isArray, isEmpty, isFunction, isObject, isString, isUndefined, merge, noop, throttle } from "lodash";
+import { debounce, defaultsDeep, forEach, isArray, isEmpty, isFunction, isObject, isUndefined, merge, noop, throttle } from "lodash";
import MissingArgument from "./errors/missingArgument";
-import { measureTextWidth } from "./helpers/createMeasurementElement.js";
+import { measureTextWidth } from "./helpers";
import removeHtmlBlocks from "./languageProcessing/helpers/html/htmlParser.js";
import Pluggable from "./pluggable.js";
@@ -11,7 +11,6 @@ import CornerstoneSEOAssessor from "./scoring/cornerstone/seoAssessor.js";
import AssessorPresenter from "./scoring/renderers/AssessorPresenter.js";
import SEOAssessor from "./scoring/seoAssessor.js";
-import SnippetPreview from "./snippetPreview/snippetPreview.js";
import Paper from "./values/Paper.js";
var inputDebounceDelay = 800;
@@ -72,40 +71,9 @@ var defaults = {
marker: noop,
keywordAnalysisActive: true,
contentAnalysisActive: true,
- hasSnippetPreview: true,
debounceRefresh: true,
};
-/**
- * Creates a default snippet preview, this can be used if no snippet preview has been passed.
- *
- * @private
- * @this App
- *
- * @returns {SnippetPreview} The SnippetPreview object.
- */
-function createDefaultSnippetPreview() {
- var targetElement = document.getElementById( this.config.targets.snippet );
-
- return new SnippetPreview( {
- analyzerApp: this,
- targetElement: targetElement,
- callbacks: {
- saveSnippetData: this.config.callbacks.saveSnippetData,
- },
- } );
-}
-
-/**
- * Returns whether or not the given argument is a valid SnippetPreview object.
- *
- * @param {*} snippetPreview The 'object' to check against.
- * @returns {boolean} Whether or not it's a valid SnippetPreview object.
- */
-function isValidSnippetPreview( snippetPreview ) {
- return ! isUndefined( snippetPreview ) && Object.prototype.isPrototypeOf.call( SnippetPreview.prototype, snippetPreview );
-}
-
/**
* Check arguments passed to the App to check if all necessary arguments are set.
*
@@ -121,15 +89,6 @@ function verifyArguments( args ) {
if ( ! isObject( args.targets ) ) {
throw new MissingArgument( "`targets` is a required App argument, `targets` is not an object." );
}
-
- // The args.targets.snippet argument is only required if not SnippetPreview object has been passed.
- if (
- args.hasSnippetPreview &&
- ! isValidSnippetPreview( args.snippetPreview ) &&
- ! isString( args.targets.snippet ) ) {
- throw new MissingArgument( "A snippet preview is required. When no SnippetPreview object isn't passed to " +
- "the App, the `targets.snippet` is a required App argument. `targets.snippet` is not a string." );
- }
}
/**
@@ -227,7 +186,6 @@ function verifyArguments( args ) {
* @param {Function} args.callbacks.saveSnippetData Function called when the snippet data is changed.
* @param {Function} args.marker The marker to use to apply the list of marks retrieved from an assessment.
*
- * @param {SnippetPreview} args.snippetPreview The SnippetPreview object to be used.
* @param {boolean} [args.debouncedRefresh] Whether or not to debounce the
* refresh function. Defaults to true.
* @param {Researcher} args.researcher The Researcher object to be used.
@@ -266,24 +224,10 @@ var App = function( args ) {
this.showLoadingDialog();
}
- if ( isValidSnippetPreview( args.snippetPreview ) ) {
- this.snippetPreview = args.snippetPreview;
-
- /* Hack to make sure the snippet preview always has a reference to this App. This way we solve the circular
- dependency issue. In the future this should be solved by the snippet preview not having a reference to the
- app.*/
- if ( this.snippetPreview.refObj !== this ) {
- this.snippetPreview.refObj = this;
- }
- } else if ( args.hasSnippetPreview ) {
- this.snippetPreview = createDefaultSnippetPreview.call( this );
- }
-
this._assessorOptions = {
useCornerStone: false,
};
- this.initSnippetPreview();
this.initAssessorPresenters();
};
@@ -330,10 +274,7 @@ App.prototype.changeAssessorOptions = function( assessorOptions ) {
*/
App.prototype.getSeoAssessor = function() {
const { useCornerStone } = this._assessorOptions;
-
- const assessor = useCornerStone ? this.cornerStoneSeoAssessor : this.defaultSeoAssessor;
-
- return assessor;
+ return useCornerStone ? this.cornerStoneSeoAssessor : this.defaultSeoAssessor;
};
/**
@@ -470,15 +411,6 @@ App.prototype.getData = function() {
} );
}
- if ( this.hasSnippetPreview() ) {
- // Gets the data FOR the analyzer
- var data = this.snippetPreview.getAnalyzerData();
-
- this.rawData.metaTitle = data.title;
- this.rawData.url = data.url;
- this.rawData.meta = data.metaDesc;
- }
-
if ( this.pluggable.loaded ) {
this.rawData.metaTitle = this.pluggable._applyModifications( "data_page_title", this.rawData.metaTitle );
this.rawData.meta = this.pluggable._applyModifications( "data_meta_desc", this.rawData.meta );
@@ -515,29 +447,6 @@ App.prototype._pureRefresh = function() {
this.runAnalyzer();
};
-/**
- * Determines whether or not this app has a snippet preview.
- *
- * @returns {boolean} Whether or not this app has a snippet preview.
- */
-App.prototype.hasSnippetPreview = function() {
- return this.snippetPreview !== null && ! isUndefined( this.snippetPreview );
-};
-
-/**
- * Initializes the snippet preview for this App.
- *
- * @returns {void}
- */
-App.prototype.initSnippetPreview = function() {
- if ( this.hasSnippetPreview() ) {
- this.snippetPreview.renderTemplate();
- this.snippetPreview.callRegisteredEventBinder();
- this.snippetPreview.bindEvents();
- this.snippetPreview.init();
- }
-};
-
/**
* Initializes the assessor presenters for content and SEO.
*
@@ -565,29 +474,6 @@ App.prototype.initAssessorPresenters = function() {
}
};
-/**
- * Binds the refresh function to the input of the targetElement on the page.
- *
- * @returns {void}
- */
-App.prototype.bindInputEvent = function() {
- for ( var i = 0; i < this.config.elementTarget.length; i++ ) {
- var elem = document.getElementById( this.config.elementTarget[ i ] );
- elem.addEventListener( "input", this.refresh.bind( this ) );
- }
-};
-
-/**
- * Runs the rerender function of the snippetPreview if that object is defined.
- *
- * @returns {void}
- */
-App.prototype.reloadSnippetText = function() {
- if ( this.hasSnippetPreview() ) {
- this.snippetPreview.reRender();
- }
-};
-
/**
* Sets the startTime timestamp.
*
@@ -628,19 +514,12 @@ App.prototype.runAnalyzer = function() {
this.analyzerData = this.modifyData( this.rawData );
- if ( this.hasSnippetPreview() ) {
- this.snippetPreview.refresh();
- }
-
let text = this.analyzerData.text;
// Insert HTML stripping code
text = removeHtmlBlocks( text );
- let titleWidth = this.analyzerData.titleWidth;
- if ( this.hasSnippetPreview() ) {
- titleWidth = this.snippetPreview.getTitleWidth();
- }
+ const titleWidth = this.analyzerData.titleWidth;
// Create a paper object for the Researcher
this.paper = new Paper( text, {
@@ -665,10 +544,6 @@ App.prototype.runAnalyzer = function() {
if ( this.config.dynamicDelay ) {
this.endTime();
}
-
- if ( this.hasSnippetPreview() ) {
- this.snippetPreview.reRender();
- }
};
/**
@@ -925,19 +800,6 @@ App.prototype.registerTest = function() {
console.error( "This function is deprecated, please use registerAssessment" );
};
-/**
- * Creates the elements for the snippetPreview
- *
- * @deprecated Don't create a snippet preview using this method, create it directly using the prototype and pass it as
- * an argument instead.
- *
- * @returns {void}
- */
-App.prototype.createSnippetPreview = function() {
- this.snippetPreview = createDefaultSnippetPreview.call( this );
- this.initSnippetPreview();
-};
-
/**
* Switches between the cornerstone and default assessors.
*
diff --git a/packages/yoastseo/src/index.js b/packages/yoastseo/src/index.js
index 166555183cb..f7d32ee13a7 100644
--- a/packages/yoastseo/src/index.js
+++ b/packages/yoastseo/src/index.js
@@ -13,7 +13,6 @@ import ContentAssessor from "./scoring/contentAssessor";
import SeoAssessor from "./scoring/seoAssessor";
import TaxonomyAssessor from "./scoring/taxonomyAssessor";
import Pluggable from "./pluggable";
-import SnippetPreview from "./snippetPreview/snippetPreview";
import Paper from "./values/Paper";
import AssessmentResult from "./values/AssessmentResult";
import Assessment from "./scoring/assessments/assessment";
@@ -31,7 +30,6 @@ export {
SeoAssessor,
TaxonomyAssessor,
Pluggable,
- SnippetPreview,
Paper,
AssessmentResult,
@@ -65,7 +63,6 @@ export default {
ContentAssessor,
TaxonomyAssessor,
Pluggable,
- SnippetPreview,
Paper,
AssessmentResult,
diff --git a/packages/yoastseo/src/languageProcessing/helpers/word/countMetaDescriptionLength.js b/packages/yoastseo/src/languageProcessing/helpers/word/countMetaDescriptionLength.js
index 31035f3a525..749840d2956 100644
--- a/packages/yoastseo/src/languageProcessing/helpers/word/countMetaDescriptionLength.js
+++ b/packages/yoastseo/src/languageProcessing/helpers/word/countMetaDescriptionLength.js
@@ -1,16 +1,16 @@
/**
- * Check the length of the description.
+ * Returns the total length of the meta description (including the date if present).
*
* @param {string} date The date.
* @param {string} description The meta description.
*
- * @returns {number} The length of the description.
+ * @returns {number} The total length of the meta description.
*/
export default function( date, description ) {
let descriptionLength = description.length;
/* If the meta description is preceded by a date, two spaces and a hyphen (" - ") are added as well. Therefore,
three needs to be added to the total length. */
- if ( date !== "" && descriptionLength > 0 ) {
+ if ( date !== "" ) {
descriptionLength += date.length + 3;
}
diff --git a/packages/yoastseo/src/snippetPreview/snippetPreview.js b/packages/yoastseo/src/snippetPreview/snippetPreview.js
deleted file mode 100644
index 347039cd659..00000000000
--- a/packages/yoastseo/src/snippetPreview/snippetPreview.js
+++ /dev/null
@@ -1,1305 +0,0 @@
-import { __ } from "@wordpress/i18n";
-import { clone, debounce, defaultsDeep, forEach, isElement, isEmpty, isUndefined } from "lodash";
-
-import createWordRegex from "../languageProcessing/helpers/regex/createWordRegex";
-import { stripFullTags as stripHTMLTags } from "../languageProcessing/helpers/sanitize/stripHTMLTags";
-import stripSpaces from "../languageProcessing/helpers/sanitize/stripSpaces";
-import replaceDiacritics from "../languageProcessing/helpers/transliterate/replaceDiacritics";
-import transliterate from "../languageProcessing/helpers/transliterate/transliterate";
-
-import SnippetPreviewToggler from "./snippetPreviewToggler";
-import domManipulation from "../helpers/domManipulation.js";
-
-var defaults = {
- data: {
- title: "",
- metaDesc: "",
- urlPath: "",
- titleWidth: 0,
- metaHeight: 0,
- },
- placeholder: {
- title: "",
- metaDesc: "",
- urlPath: "example-post/",
- },
- defaultValue: {
- title: "",
- metaDesc: "",
- },
- baseURL: "http://example.com/",
- callbacks: {
- /**
- * Empty function.
- * @returns {void}
- */
- saveSnippetData: function() {},
- },
- addTrailingSlash: true,
- metaDescriptionDate: "",
- previewMode: "desktop",
-
-};
-
-var titleMaxLength = 600;
-const maximumMetaDescriptionLength = 156;
-
-var inputPreviewBindings = [
- {
- preview: "title_container",
- inputField: "title",
- },
- {
- preview: "url_container",
- inputField: "urlPath",
- },
- {
- preview: "meta_container",
- inputField: "metaDesc",
- },
-];
-
-/**
- * Get's the base URL for this instance of the Snippet Preview.
- *
- * @private
- * @this SnippetPreview
- *
- * @returns {string} The base URL.
- */
-var getBaseURL = function() {
- var baseURL = this.opts.baseURL;
-
- /*
- * For backwards compatibility, if no URL was passed to the snippet editor we try to retrieve the base URL from the
- * rawData in the App. This is because the scrapers used to be responsible for retrieving the baseURL, but the base
- * URL is static so we can just pass it to the snippet editor.
- */
- if ( this.hasApp() && ! isEmpty( this.refObj.rawData.baseUrl ) && this.opts.baseURL === defaults.baseURL ) {
- baseURL = this.refObj.rawData.baseUrl;
- }
-
- return baseURL;
-};
-
-/**
- * Retrieves unformatted text from the data object
- *
- * @private
- * @this SnippetPreview
- *
- * @param {string} key The key to retrieve.
- *
- * @returns {string} The unformatted text.
- */
-function retrieveUnformattedText( key ) {
- return this.data[ key ];
-}
-
-/**
- * Update data and DOM objects when the unformatted text is updated, here for backwards compatibility
- *
- * @private
- * @this SnippetPreview
- *
- * @param {string} key The data key to update.
- * @param {string} value The value to update.
- *
- * @returns {void}
- */
-function updateUnformattedText( key, value ) {
- this.element.input[ key ].value = value;
-
- this.data[ key ] = value;
-}
-
-/**
- * Returns if a url has a trailing slash or not.
- *
- * @param {string} url The url to check for a trailing slash.
- *
- * @returns {boolean} Whether or not the url contains a trailing slash.
- */
-function hasTrailingSlash( url ) {
- return url.indexOf( "/" ) === ( url.length - 1 );
-}
-
-/**
- * Detects if this browser has