true, 'show_ui' => true, ); $post_types = get_post_types( $args, 'objects' ); $options = array(); foreach ( $post_types as $post_type ) { $exclude = array( 'attachment' ); if ( true === in_array( $post_type->name, $exclude, true ) ) { continue; } if ( ! empty( $post_type->name ) && ( 'post' === $post_type->name || 'page' === $post_type->name || 'elementor_library' === $post_type->name || 'nxt_builder' === $post_type->name ) ) { $options[ $post_type->name ] = $post_type->label; } } return $options; } /** * Get Editor Use. * * @since 1.0.0 */ protected function wdkit_use_editor() { global $current_screen; $editor = 'wdkit'; if ( isset( $_GET['action'] ) && 'elementor' === $_GET['action'] ) { $editor = 'elementor'; } if ( $current_screen->is_block_editor() && isset( $_GET['action'] ) && 'elementor' !== $_GET['action'] ) { $editor = 'gutenberg'; } return $editor; } /** * Load Admin Scripts. * * @since 1.0.0 */ public function wdkit_elementor_scripts() { $this->wdkit_admin_scripts( 'elementor' ); } /** * Elementor Preview Style Loaded * * @since 1.0.0 */ public function wdkit_elementor_preview_style() { wp_enqueue_style( 'wdkit-elementor-editor-css', WDKIT_URL . 'assets/css/elementor/wdkit_enqueue_preview_styles.css', array(), WDKIT_VERSION ); } /** * Enqueue Scripts admin area. * * @since 1.0.0 * * @param string $hook use for check page type. */ public function wdkit_admin_scripts( $hook ) { if ( ! in_array( $hook, array( 'toplevel_page_wdesign-kit', 'elementor', 'post-new.php', 'post.php' ), true ) ) { return; } $this->wdkit_enqueue_scripts( $hook ); $this->wdkit_enqueue_styles(); } /** * Enqueue Styles admin area. * * @since 1.0.0 */ public function wdkit_enqueue_styles() { wp_enqueue_style( 'wdkit-editor-css', WDKIT_URL . 'build/index.css', array(), WDKIT_VERSION ); } /** * Register the JavaScript for the admin area. * * @param string $hook give builder name. * @since 1.0.0 */ public function wdkit_enqueue_scripts( $hook ) { wp_enqueue_script( 'wdkit-editor-js', WDKIT_URL . 'build/index.js', array( 'wp-i18n', 'wp-element', 'wp-components' ), WDKIT_VERSION, true ); wp_localize_script( 'wdkit-editor-js', 'wdkitData', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'WDKIT_PATH' => WDKIT_PATH, 'WDKIT_URL' => WDKIT_URL, 'WDKIT_ASSETS' => WDKIT_ASSETS, 'wdkit_server_url' => WDKIT_SERVER_SITE_URL, 'home_url' => esc_url( home_url( '/' ) ), 'kit_nonce' => wp_create_nonce( 'wdkit_nonce' ), 'post_id' => get_the_ID(), 'post_type' => get_post_type(), 'text_domain' => WDKIT_TEXT_DOMAIN, 'use_editor' => $this->wdkit_use_editor(), 'post_type_list' => $this->wdkit_get_post_type_list(), /** Widget Builder Path */ 'WDKIT_SITE_URL' => WDKIT_GET_SITE_URL, 'WDKIT_SERVER_PATH' => WDKIT_SERVER_PATH, 'WDKIT_BUILDER_PATH' => WDKIT_BUILDER_PATH, 'WDKIT_VERSION' => WDKIT_VERSION, ) ); /**Ace Editor files for Widget-builder */ if ( 'toplevel_page_wdesign-kit' === $hook && Wdkit_Wdesignkit::wdkit_is_compatible( 'builder' ) ) { wp_enqueue_script( 'widgetBuilder-script-editor-js', WDKIT_URL . 'assets/js/extra/ace.min.js', array( 'wp-element' ), WDKIT_VERSION, true ); wp_enqueue_script( 'widgetBuilder-script-editor-cobalt', WDKIT_URL . 'assets/js/extra/theme-cobalt.js', array( 'wp-element' ), WDKIT_VERSION, true ); wp_enqueue_script( 'widgetBuilder-script-editor-html', WDKIT_URL . 'assets/js/extra//mode-html.js', array( 'wp-element' ), WDKIT_VERSION, true ); } if ( 'elementor' === $hook ) { wp_enqueue_script( 'wdkit-frontend-editor', WDKIT_ASSETS . '/js/main/elementor/elementor-editor.js', array( 'jquery', 'wp-i18n' ), WDKIT_VERSION, true ); } } /** * Add Menu Page WdKit. * * @since 1.0.0 */ public function wdkit_admin_menu() { $capability = 'manage_options'; if ( current_user_can( $capability ) ) { $hook = add_menu_page( __( 'WDesignKit', 'wdesignkit' ), __( 'WDesignKit', 'wdesignkit' ), 'manage_options', 'wdesign-kit', array( $this, 'wdkit_menu_page_template' ), WDKIT_ASSETS . 'images/svg/logo-icon.svg' ); } } /** * Load wdkit page content. * * @since 1.0.0 */ public function wdkit_menu_page_template() { echo '
'; } } Wdkit_Enqueue::get_instance(); }