wdkit_default_category(); $this->wdkit_db_widgetlist(); $this->wdkit_elementor_load(); $this->wdkit_gutenberg_load(); $this->wdkit_bricks_load(); $this->wdkit_gutenberg_core_load(); } /** * This function is called to load Elementor files, categories, and everything needed for WDesignKit to build with Elementor. * * @since 1.0.0 */ public function wdkit_elementor_load() { if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'elementor', 'widget' ) ) { require_once WDKIT_INCLUDES . 'widget-load/elementor/class-wdkit-elementor-files-load.php'; } } /** * This function is called to load Gutenberg files, categories, and everything needed for WDesignKit to build with Gutenberg. * * @since 1.0.0 */ public function wdkit_gutenberg_load() { if ( ! Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg', 'widget' ) ) { return; } // Frontend: always load so register_block_type() runs and the style/script // handles attached to each widget (wp_register_style, render_callback) are // enqueued correctly on public pages. if ( ! is_admin() ) { require_once WDKIT_INCLUDES . 'widget-load/gutenberg/class-wdkit-gutenberg-files-load.php'; return; } // Skip Elementor editor — $_GET['action'] is set before plugins_loaded // and is the most reliable way to detect the Elementor edit screen. if ( isset( $_GET['action'] ) && 'elementor' === sanitize_key( wp_unslash( $_GET['action'] ) ) ) { return; } // Admin: whitelist pages where the block editor can be active. // $pagenow is set by WordPress before plugins_loaded — no timing issues, // no dependency on post-type registration. Covers all CPTs including // ACF-registered ones. Bricks and other builders are excluded automatically // because they do not use these pages. global $pagenow; $block_editor_pages = array( 'post.php', 'post-new.php', 'widgets.php', 'customize.php' ); if ( in_array( $pagenow, $block_editor_pages, true ) ) { require_once WDKIT_INCLUDES . 'widget-load/gutenberg/class-wdkit-gutenberg-files-load.php'; } } /** * This function is called to load Gutenberg Core files, categories, and everything needed for WDesignKit to build with Gutenberg. * * @since 1.2.5 */ public function wdkit_gutenberg_core_load() { if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg_core', 'widget' ) ) { require_once WDKIT_INCLUDES . 'widget-load/gutenberg_core/class-wdkit-gutenberg-core-files-load.php'; } } /** * This function is called to load Bricks files, categories, and everything needed for WDesignKit to build with bricks. * * @since 1.0.0 */ public function wdkit_bricks_load() { if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'bricks', 'widget' ) ) { require_once WDKIT_INCLUDES . 'widget-load/bricks/class-wdkit-bricks-files-load.php'; } } /** * Set widget Default Category as WDesignKit * * @since 1.0.0 */ public function wdkit_default_category() { $category_list = get_option( 'wkit_builder' ); $final_category = array( 'WDesignKit' ); if ( ! empty( $category_list ) && ! in_array( 'WDesignKit', $category_list, true ) ) { $final_category = array_merge( $final_category, $category_list ); update_option( 'wkit_builder', $final_category ); } elseif ( ! is_array( $category_list ) && empty( $category_list ) ) { do_action( 'wdkit_admin_create_default' ); } } /** * Store default widget list * * @since 1.0.19 */ public function wdkit_db_widgetlist(){ $get_db_widget = get_option( 'wkit_deactivate_widgets', [] ); if ( empty( $get_db_widget ) ) { add_option( 'wkit_deactivate_widgets', [], '', 'yes' ); } } } Wdkit_Widget_Load_Files::instance(); }