plugin_path . 'build/assets/admin/css/admin.css' ) ); wp_style_add_data( 'ghostkit-admin', 'rtl', 'replace' ); GhostKit_Assets::enqueue_style( 'ghostkit-settings', 'build/settings/style', array(), filemtime( ghostkit()->plugin_path . 'build/settings/style.css' ) ); wp_style_add_data( 'ghostkit-settings', 'rtl', 'replace' ); if ( 'toplevel_page_ghostkit' !== $screen->id ) { return; } $block_editor_context = new WP_Block_Editor_Context(); // Preload server-registered block schemas. wp_add_inline_script( 'wp-blocks', 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');' ); wp_add_inline_script( 'wp-blocks', sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $block_editor_context ) ) ), 'after' ); // The settings page is not a block editor screen, but it boots the block editor // scripts, so callbacks that check this flag have to see the editor context. add_filter( 'should_load_block_editor_scripts_and_styles', '__return_true' ); // phpcs:ignore do_action( 'enqueue_block_editor_assets' ); // phpcs:ignore do_action( 'enqueue_block_assets' ); remove_filter( 'should_load_block_editor_scripts_and_styles', '__return_true' ); // Ghost Kit Settings. GhostKit_Assets::enqueue_script( 'ghostkit-settings', 'build/settings/index', array( 'ghostkit-helper' ) ); wp_localize_script( 'ghostkit-settings', 'ghostkitSettingsData', array( 'api_nonce' => wp_create_nonce( 'wp_rest' ), 'api_url' => rest_url( 'ghostkit/v1/' ), ) ); wp_enqueue_style( 'wp-components' ); if ( function_exists( 'wp_enqueue_media' ) ) { wp_enqueue_media(); } } /** * Go Pro. * Redirect to the Pro purchase page. */ public function go_pro_redirect() { // phpcs:ignore if ( ! isset( $_GET['page'] ) || empty( $_GET['page'] ) ) { return; } // phpcs:ignore if ( 'ghostkit_go_pro' === $_GET['page'] ) { $medium = 'admin_menu'; // phpcs:ignore if ( isset( $_GET['utm_medium'] ) ) { // phpcs:ignore $medium = $_GET['utm_medium']; } // phpcs:ignore wp_redirect( ghostkit()->go_pro_link() . '?utm_source=plugin&utm_medium=' . esc_attr( $medium ) . '&utm_campaign=go_pro&utm_content=' . GHOSTKIT_VERSION ); exit(); } } /** * Add admin menu. */ public function admin_menu() { add_menu_page( esc_html__( 'Ghost Kit', 'ghostkit' ), esc_html__( 'Ghost Kit', 'ghostkit' ), 'manage_options', 'ghostkit', array( $this, 'display_admin_page' ), // phpcs:ignore 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( ghostkit()->plugin_path . 'assets/images/admin-icon.svg' ) ), 56.9 ); add_submenu_page( 'ghostkit', '', esc_html__( 'Blocks', 'ghostkit' ), 'manage_options', 'ghostkit' ); add_submenu_page( 'ghostkit', '', esc_html__( 'Icons', 'ghostkit' ), 'manage_options', 'admin.php?page=ghostkit&sub_page=icons' ); add_submenu_page( 'ghostkit', '', esc_html__( 'Typography', 'ghostkit' ), 'manage_options', 'admin.php?page=ghostkit&sub_page=typography' ); add_submenu_page( 'ghostkit', '', esc_html__( 'Fonts', 'ghostkit' ), 'manage_options', 'admin.php?page=ghostkit&sub_page=fonts' ); add_submenu_page( 'ghostkit', '', esc_html__( 'Breakpoints', 'ghostkit' ), 'manage_options', 'admin.php?page=ghostkit&sub_page=breakpoints' ); add_submenu_page( 'ghostkit', '', esc_html__( 'CSS & JavaScript', 'ghostkit' ), 'manage_options', 'admin.php?page=ghostkit&sub_page=css_js' ); if ( GhostKit_Templates::is_allowed() ) { add_submenu_page( 'ghostkit', '', esc_html__( 'Templates', 'ghostkit' ), 'manage_options', 'edit.php?post_type=ghostkit_template' ); } add_submenu_page( 'ghostkit', '', ' ' . esc_html__( 'Go Pro', 'ghostkit' ), 'manage_options', 'ghostkit_go_pro', array( $this, 'go_pro_redirect' ) ); global $wp_version; // Since WP 6.3 user have an ability to open the reusable blocks page // From the Appearance -> Editor -> Patterns. if ( ! version_compare( $wp_version, '6.3', '>=' ) ) { add_menu_page( esc_html__( 'Reusable Blocks', 'ghostkit' ), esc_html__( 'Reusable Blocks', 'ghostkit' ), 'read', 'edit.php?post_type=wp_block', '', 'dashicons-editor-table', 57 ); } } /** * Render the admin page. */ public function display_admin_page() { ?>