add_node([
'id' => 'extendify-quick-edit-toggle',
'title' => ''
. ''
. ''
. esc_html__('Quick Edit', 'extendify-local')
. '',
'href' => '#',
'meta' => [
'role' => 'switch',
'aria-label' => esc_attr__('Quick Edit', 'extendify-local'),
],
]);
}
public function enqueue()
{
// The Customizer preview iframe is a front-end render (is_admin() false),
// so QE would otherwise enqueue and mount inside it — bail before then.
if (!current_user_can(Config::$requiredCapability) || is_admin() || is_customize_preview()) {
return;
}
$version = constant('EXTENDIFY_DEVMODE') ? (string) time() : Config::$version;
$manifest = Config::$assetManifest;
$assetMeta = $manifest['extendify-quick-edit.php'] ?? null;
$jsFile = $manifest['extendify-quick-edit.js'] ?? null;
$cssFile = $manifest['extendify-quick-edit.css'] ?? null;
if (!$assetMeta || !$jsFile) {
return;
}
$assetPath = EXTENDIFY_PATH . 'public/build/' . $assetMeta;
$asset = file_exists($assetPath)
? require $assetPath
: ['dependencies' => [], 'version' => $version];
$jsHandle = 'extendify-quick-edit';
// wp-format-library isn't auto-detected — we access wp.formatLibrary
// at runtime to avoid invalid build-module/* handles.
$deps = array_merge(
$asset['dependencies'] ?? [],
['wp-format-library']
);
wp_enqueue_script(
$jsHandle,
EXTENDIFY_BASE_URL . 'public/build/' . $jsFile,
$deps,
$asset['version'] ?? $version,
true
);
wp_set_script_translations($jsHandle, 'extendify-local', EXTENDIFY_PATH . 'languages/js');
if ($cssFile) {
wp_enqueue_style(
$jsHandle,
EXTENDIFY_BASE_URL . 'public/build/' . $cssFile,
[],
$asset['version'] ?? $version
);
}
// Required for BlockEditor canvas + toolbar styling.
wp_enqueue_style('wp-components');
wp_enqueue_style('wp-block-editor');
wp_enqueue_style('wp-block-library');
wp_enqueue_style('wp-format-library');
wp_enqueue_media();
global $post;
$sourceForCurrentPost = ($post instanceof \WP_Post)
? ['kind' => 'post', 'id' => $post->ID]
: null;
$context = ['currentSource' => $sourceForCurrentPost];
if (function_exists('get_woocommerce_currency_symbol')) {
// WC returns HTML entities for some currencies (e.g. ₹ as
// `₹`); the price modal renders it as React text, so
// decode before shipping.
$context['currencySymbol'] = html_entity_decode(
get_woocommerce_currency_symbol(),
ENT_QUOTES,
'UTF-8'
);
}
// EXTENDIFY_QUICK_EDIT_DEBUG (wp-config constant) or ?qe-debug=1 turns
// on selector-layer console traces — used to repro the "second block
// selected" report without shipping logs in prod builds.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$debug = (defined('EXTENDIFY_QUICK_EDIT_DEBUG') && constant('EXTENDIFY_QUICK_EDIT_DEBUG'))
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|| (isset($_GET['qe-debug']) && $_GET['qe-debug'] === '1');
// QE off (showQuickEdit) keeps the selector bundle loaded for Ask AI
// but suppresses every inline-edit surface: no auto-on post-Launch
// (the agent's Select button is the entry point then) and the
// hover/keyboard pills gate on quickEditEnabled.
$quickEditEnabled = self::quickEditEnabled();
wp_add_inline_script(
$jsHandle,
'window.extQuickEditData = ' . wp_json_encode([
'restRoot' => esc_url_raw(rest_url('extendify/v1')),
'nonce' => wp_create_nonce('wp_rest'),
'schemas' => Registry::describe(),
'context' => $context,
'translatedContext' => TranslatedContext::detect(),
'quickEditEnabled' => $quickEditEnabled,
'defaultOn' => ((bool) constant('EXTENDIFY_DEVMODE') || Config::$launchCompleted) && $quickEditEnabled,
'debug' => $debug,
]) . ';',
'before'
);
}
}