| @@ -317,31 +317,88 @@ | ||
| 317 | 317 | wp_localize_script( |
| 318 | 318 | 'wdkit-editor-js', |
| 319 | 319 | 'wdkitData', |
| 320 | 320 | array( |
| 321 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 322 | - 'WDKIT_URL' => WDKIT_URL, | |
| 323 | - 'WDKIT_ASSETS' => WDKIT_ASSETS, | |
| 324 | - 'wdkit_server_url' => WDKIT_SERVER_SITE_URL, | |
| 325 | - 'wdkit_site_api_url' => WDKIT_SERVER_API_URL, | |
| 326 | - 'wdkit_wp_version' => get_bloginfo( 'version' ), | |
| 327 | - 'home_url' => esc_url( home_url( '/' ) ), | |
| 328 | - 'kit_nonce' => wp_create_nonce( 'wdkit_nonce' ), | |
| 329 | - 'post_id' => get_the_ID(), | |
| 330 | - 'post_type' => get_post_type(), | |
| 331 | - 'text_domain' => WDKIT_TEXT_DOMAIN, | |
| 332 | - 'use_editor' => $this->wdkit_use_editor(), | |
| 333 | - 'post_type_list' => $this->wdkit_get_post_type_list(), | |
| 334 | - 'WDKIT_onbording_end' => $onbording_end, | |
| 335 | - 'wdkit_white_label' => $white_label, | |
| 336 | - 'WDKIT_dark_mode' => $dark_mode, | |
| 321 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 322 | + // Mirrors the PHP side's WP_DEBUG gate on its own import timing/diagnostic | |
| 323 | + // error_log() calls, so the JS import flow's console diagnostics follow the | |
| 324 | + // same convention instead of always printing in every visitor's console. | |
| 325 | + 'debug' => (bool) ( defined( 'WP_DEBUG' ) && WP_DEBUG ), | |
| 326 | + 'WDKIT_URL' => WDKIT_URL, | |
| 327 | + 'WDKIT_ASSETS' => WDKIT_ASSETS, | |
| 328 | + 'wdkit_server_url' => WDKIT_SERVER_SITE_URL, | |
| 329 | + 'wdkit_site_api_url' => WDKIT_SERVER_API_URL, | |
| 330 | + 'wdkit_wp_version' => get_bloginfo( 'version' ), | |
| 331 | + 'home_url' => esc_url( home_url( '/' ) ), | |
| 332 | + 'kit_nonce' => wp_create_nonce( 'wdkit_nonce' ), | |
| 333 | + | |
| 334 | + /* Kit Import engine switch. 'yes' => the wizard drives the PHP runner in four | |
| 335 | + * stage calls; anything else => it falls back to its original ~25-call | |
| 336 | + * orchestration, which is still fully present. Flip with the | |
| 337 | + * `wdkit_use_php_runner` filter. | |
| 338 | + * | |
| 339 | + * Deliberately 'yes'/'no' rather than a boolean. wp_localize_script() casts | |
| 340 | + * booleans to "1" and "", and while "" is falsy in JS, relying on that is the | |
| 341 | + * same PHP/JS truthiness trap that bites elsewhere in the importer — a switch | |
| 342 | + * that silently failed to switch OFF would be the worst outcome for a | |
| 343 | + * rollback path. An explicit string compares the same in both languages. | |
| 344 | + * | |
| 345 | + * Fully qualified: this file is namespaced, and an unqualified reference here | |
| 346 | + * resolved to wdkit\WdKit_enqueue\Wdkit_Import_Wizard and fatalled. */ | |
| 347 | + 'use_php_runner' => ( class_exists( '\\Wdkit_Import_Wizard' ) && \Wdkit_Import_Wizard::is_enabled() ) ? 'yes' : 'no', | |
| 348 | + 'post_id' => get_the_ID(), | |
| 349 | + 'post_type' => get_post_type(), | |
| 350 | + 'text_domain' => WDKIT_TEXT_DOMAIN, | |
| 351 | + 'use_editor' => $this->wdkit_use_editor(), | |
| 352 | + 'post_type_list' => $this->wdkit_get_post_type_list(), | |
| 353 | + 'WDKIT_onbording_end' => $onbording_end, | |
| 354 | + 'wdkit_white_label' => $white_label, | |
| 355 | + 'WDKIT_dark_mode' => $dark_mode, | |
| 337 | 356 | /** Widget Builder — public URL only, no server filesystem paths */ |
| 338 | - 'WDKIT_SITE_URL' => WDKIT_GET_SITE_URL, | |
| 339 | - 'WDKIT_DOC_URL' => WDKIT_DOCUMENT, | |
| 340 | - 'WDKIT_SERVER_PATH' => WDKIT_SERVER_PATH, | |
| 341 | - 'WDKIT_VERSION' => WDKIT_VERSION, | |
| 357 | + 'WDKIT_SITE_URL' => WDKIT_GET_SITE_URL, | |
| 358 | + 'WDKIT_DOC_URL' => WDKIT_DOCUMENT, | |
| 359 | + 'WDKIT_SERVER_PATH' => WDKIT_SERVER_PATH, | |
| 360 | + 'WDKIT_VERSION' => WDKIT_VERSION, | |
| 342 | 361 | |
| 343 | - 'gutenberg_template' => Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg_template', 'template' ) | |
| 362 | + 'gutenberg_template' => Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg_template', 'template' ), | |
| 363 | + | |
| 364 | + /** | |
| 365 | + * Data Sharing switcher, Settings panel. | |
| 366 | + * | |
| 367 | + * Read as a SITE option — the consent is one answer per install, not per blog. The | |
| 368 | + * class guard matches the one in wdesignkit.php: on a white-labelled install, or when | |
| 369 | + * a sibling POSIMYTH plugin's SDK copy won the loader, the tracker class is never | |
| 370 | + * declared and the constant reference would fatal. | |
| 371 | + * | |
| 372 | + * Both references are root-namespaced. This file lives in wdkit\WdKit_enqueue while | |
| 373 | + * the SDK class is declared in the global namespace: a string class name is always | |
| 374 | + * global so the guard passed either way, but an unprefixed `Posimyth_Tracker_WDK::` | |
| 375 | + * resolves against THIS namespace and fatals on every admin page load. | |
| 376 | + */ | |
| 377 | + 'wdkit_data_sharing' => class_exists( '\Posimyth_Tracker_WDK' ) ? (bool) get_site_option( \Posimyth_Tracker_WDK::OPT_IN_OPTION, false ) : false, | |
| 378 | + 'wdkit_consent_nonce' => wp_create_nonce( 'posimyth_consent_wdk' ), | |
| 379 | + | |
| 380 | + /** | |
| 381 | + * Whether the Data Sharing card may be shown at all. | |
| 382 | + * | |
| 383 | + * Tracks the tracker class rather than the white-label flag: a rebranded install now | |
| 384 | + * keeps the feature (see wdesignkit.php), so this is false only when the SDK genuinely | |
| 385 | + * failed to load — a sibling POSIMYTH plugin winning the loader with a diverged copy. | |
| 386 | + * Rendering a switch in that case would offer a save with no handler behind it. | |
| 387 | + * | |
| 388 | + * Separate from wdkit_data_sharing on purpose: that one is false both when sharing is | |
| 389 | + * off and when the feature is absent, which cannot tell the two apart. | |
| 390 | + */ | |
| 391 | + 'wdkit_data_sharing_available' => class_exists( '\Posimyth_Tracker_WDK' ), | |
| 392 | + | |
| 393 | + /** | |
| 394 | + * Reseller's product name, for the Data Sharing copy that would otherwise say | |
| 395 | + * "WDesignKit" on a plugin they have rebranded as their own. | |
| 396 | + */ | |
| 397 | + 'wdkit_data_sharing_name' => ! empty( $white_label['plugin_name'] ) ? $white_label['plugin_name'] : 'WDesignKit', | |
| 398 | + | |
| 399 | + /** help_link is the reseller's "hide POSIMYTH documentation links" switch. */ | |
| 400 | + 'wdkit_data_sharing_docs' => empty( $white_label['help_link'] ) ? WDKIT_DOCUMENT . 'data-sharing/' : '' | |
| 344 | 401 | ) |
| 345 | 402 | ); |
| 346 | 403 | |
| 347 | 404 | /**Ace Editor files for Widget-builder */ |