"@import url('{$style}')", ]; return $settings; }); /** * Inject scripts into the block editor. * * @return void */ add_filter('admin_head', function () { if (! get_current_screen()?->is_block_editor()) { return; } $dependencies = json_decode(Vite::content('editor.deps.json')); foreach ($dependencies as $dependency) { if (! wp_script_is($dependency)) { wp_enqueue_script($dependency); } } echo Vite::withEntryPoints([ 'resources/js/editor.js', ])->toHtml(); }); /** * Use the generated theme.json file. * * @return string */ add_filter('theme_file_path', function ($path, $file) { return $file === 'theme.json' ? public_path('build/assets/theme.json') : $path; }, 10, 2); /** * Register the initial theme setup. * * @return void */ add_action('after_setup_theme', function () { /** * Disable full-site editing support. * * @link https://wptavern.com/gutenberg-10-5-embeds-pdfs-adds-verse-block-color-options-and-introduces-new-patterns */ remove_theme_support('block-templates'); \register_post_type('game', [ 'label' => 'Games', 'public' => true, 'show_in_rest' => true, 'supports' => [ 'title', 'editor', 'custom-fields', 'revisions', 'trackbacks', 'comments', 'author', 'excerpt', 'thumbnail' ], 'taxonomies' => [ 'game_tag', 'game_platform' ], 'register_meta_box_cb' => function () { \add_meta_box( 'screenshots', 'Screenshots', function () { global $post; wp_enqueue_media(); wp_enqueue_script('media-upload'); wp_enqueue_style( 'screenshot_css', Vite::asset('resources/css/screenshot.scss') ); // Add an nonce field so we can check for it later. wp_nonce_field( 'screenshots_metabox', 'screenshots_metabox' ); $value = get_post_custom_values('_screenshots', $post->ID); // Display the form, using the current value. ?>
false, 'show_ui' => true, 'supports' => [ 'title', 'custom-fields', 'thumbnail' ] ]); \register_taxonomy('game_tag', ['game'], [ 'labels' => [ 'name' => 'Tags', 'singular_name' => 'Tag' ], 'public' => true, 'show_in_rest' => true ]); \register_taxonomy('game_platform', ['game'], [ 'labels' => [ 'name' => 'Platforms', 'singular_name' => 'Platform' ], 'hierarchical' => true, 'public' => true, 'show_in_rest' => true ]); if (!term_exists('windows', 'game_platform')) { \wp_insert_term('windows', 'game_platform'); } if (!term_exists('macos', 'game_platform')) { \wp_insert_term('macos', 'game_platform'); } if (!term_exists('linux', 'game_platform')) { \wp_insert_term('linux', 'game_platform'); } if (!term_exists('android', 'game_platform')) { \wp_insert_term('android', 'game_platform'); } if (!term_exists('web', 'game_platform')) { \wp_insert_term('web', 'game_platform'); } /** * Register the navigation menus. * * @link https://developer.wordpress.org/reference/functions/register_nav_menus/ */ register_nav_menus([ 'primary_navigation' => __('Primary Navigation', 'sage'), ]); /** * Disable the default block patterns. * * @link https://developer.wordpress.org/block-editor/developers/themes/theme-support/#disabling-the-default-block-patterns */ remove_theme_support('core-block-patterns'); /** * Enable plugins to manage the document title. * * @link https://developer.wordpress.org/reference/functions/add_theme_support/#title-tag */ add_theme_support('title-tag'); /** * Enable post thumbnail support. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support('post-thumbnails'); /** * Enable responsive embed support. * * @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#responsive-embedded-content */ add_theme_support('responsive-embeds'); /** * Enable HTML5 markup support. * * @link https://developer.wordpress.org/reference/functions/add_theme_support/#html5 */ add_theme_support('html5', [ 'caption', 'comment-form', 'comment-list', 'gallery', 'search-form', 'script', 'style', ]); /** * Enable selective refresh for widgets in customizer. * * @link https://developer.wordpress.org/reference/functions/add_theme_support/#customize-selective-refresh-widgets */ add_theme_support('customize-selective-refresh-widgets'); }, 20); /** * Register the theme sidebars. * * @return void */ add_action('widgets_init', function () { $config = [ 'before_widget' => '', 'before_title' => '