HEX
Server: Apache/2.4.65 (Debian)
System: Linux 88f31f35b0b8 6.1.0-38-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/wp-seopress/assets/js/seopress-primary-category-classic.js
'use strict';
/**
 * Inject the SEOPress primary category dropdown into the WordPress
 * Categories (or Product Categories) metabox in the Classic Editor.
 *
 * Self-contained: does not require any source <select> on the page.
 * The localized payload provides the rendered <select> markup (with
 * name="seopress_robots_primary_cat" so it ships with the post form)
 * and the dedicated nonce that the server-side save handler verifies.
 */
document.addEventListener('DOMContentLoaded', function () {
    var data = window.seopressPrimaryCategorySelectData;
    if (!data || !data.selectHTML) {
        return;
    }

    var categoriesMetabox = document.querySelector('#product_catdiv') || document.querySelector('#categorydiv');
    if (!categoriesMetabox) {
        return;
    }

    var inside = categoriesMetabox.querySelector('.inside');
    if (!inside) {
        return;
    }

    if (inside.querySelector('#seopress_robots_primary_cat')) {
        return;
    }

    var wrapper = document.createElement('div');
    wrapper.className = 'seopress-primary-category-wrapper';
    wrapper.innerHTML = data.selectHTML + (data.nonceField || '');
    inside.appendChild(wrapper);

    var select = wrapper.querySelector('#seopress_robots_primary_cat');
    if (select && data.primaryCategory) {
        select.value = data.primaryCategory;
    }
});