Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup outdated addons tabs in metabox #20411

Merged
merged 11 commits into from
Jun 19, 2023
126 changes: 0 additions & 126 deletions css/src/metabox.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion inc/class-wpseo-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ public static function keyword_usage( $keyword, $post_id ) {
->find_array();

// Get object_id from each subarray in $post_ids.
$post_ids = array_column( $post_ids, 'object_id' );
$post_ids = ( is_array( $post_ids ) ) ? array_column( $post_ids, 'object_id' ) : [];

/*
* If Premium is installed, get the additional keywords as well.
Expand Down
12 changes: 0 additions & 12 deletions packages/js/src/analysis/TermDataCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,4 @@ TermDataCollector.prototype.saveInclusiveLanguageScore = function( score ) {
$( "#hidden_wpseo_inclusive_language_score" ).val( score );
};

/**
* Initializes keyword tab with the correct template.
*
* @returns {void}
*/
TermDataCollector.prototype.initKeywordTabTemplate = function() {
// Remove default functionality to prevent scrolling to top.
$( ".wpseo-metabox-tabs" ).on( "click", ".wpseo_tablink", function( ev ) {
ev.preventDefault();
} );
};

export default TermDataCollector;
31 changes: 0 additions & 31 deletions packages/js/src/initializers/metabox-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,34 +157,6 @@ export default function initTabs( jQuery ) {
* @returns {void}
*/
function wpseoInitTabs() {
// When there's only one add-on tab, change its link to a span element.
var addonsTabsLinks = jQuery( "#wpseo-meta-section-addons .wpseo_tablink" );
if ( addonsTabsLinks.length === 1 ) {
addonsTabsLinks.replaceWith( "<span class='" + addonsTabsLinks[ 0 ].className + "'>" + addonsTabsLinks.text() + "</span>" );
}

// Tabs within the main tabs, e.g.: Facebook, Twitter, Video, and News.
if ( jQuery( ".wpseo-metabox-tabs-div" ).length > 0 ) {
jQuery( ".wpseo-metabox-tabs" )
.on( "click", "a.wpseo_tablink", function( ev ) {
ev.preventDefault();

jQuery( ".wpseo-meta-section.active .wpseo-metabox-tabs li" ).removeClass( "active" );
jQuery( ".wpseo-meta-section.active .wpseotab" ).removeClass( "active" );

var targetElem = jQuery( jQuery( this ).attr( "href" ) );
targetElem.addClass( "active" );
jQuery( this ).parent( "li" ).addClass( "active" );

// Not used at the moment.
if ( jQuery( this ).hasClass( "scroll" ) ) {
jQuery( "html, body" ).animate( {
scrollTop: jQuery( targetElem ).offset().top,
}, 500 );
}
} );
}

// Main tabs.
if ( jQuery( ".wpseo-meta-section" ).length > 0 ) {
const tabLinks = jQuery( ".wpseo-meta-section-link" );
Expand Down Expand Up @@ -232,8 +204,6 @@ export default function initTabs( jQuery ) {
wpseoAriaTabSetActiveAttributes( this, tabLinks );
} );
}

jQuery( ".wpseo-metabox-tabs" ).show();
// End Tabs code.
}

Expand All @@ -243,7 +213,6 @@ export default function initTabs( jQuery ) {

// Set up the first tab and panel within the main tabs.
jQuery( ".wpseo-meta-section" ).each( function( index, el ) {
jQuery( el ).find( ".wpseo-metabox-tabs li:first" ).addClass( "active" );
jQuery( el ).find( ".wpseotab:first" ).addClass( "active" );
} );

Expand Down
10 changes: 2 additions & 8 deletions packages/js/src/initializers/term-scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,11 @@ export default function initTermScraper( $, store, editorData ) {
/**
* Initializes keyword analysis.
*
* @param {TermDataCollector} termScraper The post scraper object.
*
* @returns {void}
*/
function initializeKeywordAnalysis( termScraper ) {
function initializeKeywordAnalysis() {
var savedKeywordScore = $( "#hidden_wpseo_linkdex" ).val();

termScraper.initKeywordTabTemplate();

var indicator = getIndicatorForScore( savedKeywordScore );

updateTrafficLight( indicator );
Expand Down Expand Up @@ -373,8 +369,6 @@ export default function initTermScraper( $, store, editorData ) {
app.seoAssessorPresenter.assessor = app.seoAssessor;
}

termScraper.initKeywordTabTemplate();

// Init Plugins.
window.YoastSEO.wp = {};
window.YoastSEO.wp.replaceVarsPlugin = new YoastReplaceVarPlugin( app, store );
Expand All @@ -392,7 +386,7 @@ export default function initTermScraper( $, store, editorData ) {
), refreshDelay ) );

if ( isKeywordAnalysisActive() ) {
initializeKeywordAnalysis( termScraper );
initializeKeywordAnalysis();
}

if ( isContentAnalysisActive() ) {
Expand Down