get( 'Version' ) ); /** * Add theme support for block styles and editor style. * * @since 1.0.0 * * @return void */ function abnomize_setup() { add_editor_style( './assets/css/style-shared.min.css' ); /* * Load additional block styles. * See details on how to add more styles in the readme.txt. */ $styled_blocks = [ 'button', 'quote', 'navigation', 'search' ]; foreach ( $styled_blocks as $block_name ) { $args = array( 'handle' => "abnomize-$block_name", 'src' => get_theme_file_uri( "assets/css/blocks/$block_name.min.css" ), 'path' => get_theme_file_path( "assets/css/blocks/$block_name.min.css" ), ); // Replace the "core" prefix if you are styling blocks from plugins. wp_enqueue_block_style( "core/$block_name", $args ); } } add_action( 'after_setup_theme', 'abnomize_setup' ); /** * Enqueue the CSS files. * * @since 1.0.0 * * @return void */ function abnomize_styles() { wp_enqueue_style( 'abnomize-style', get_stylesheet_uri(), [], GRABBER_VERSION ); wp_enqueue_style( 'abnomize-shared-styles', get_theme_file_uri( 'assets/css/style-shared.min.css' ), [], GRABBER_VERSION ); wp_enqueue_style( 'abnomize-swiper', get_theme_file_uri( 'assets/css/swiper-bundle.min.css' ), [], GRABBER_VERSION ); wp_enqueue_script( 'abnomize-script', get_theme_file_uri( 'assets/js/script-theme.js' ), array(), GRABBER_VERSION, array( 'strategy' => 'defer', ) ); wp_enqueue_style( 'abnomize-responsive-fixes', get_theme_file_uri( 'assets/css/responsive-fixes.css' ), array( 'abnomize-shared-styles' ), GRABBER_VERSION ); } add_action( 'wp_enqueue_scripts', 'abnomize_styles' ); function abnomize_styles_admin($hook) { if ( 'appearance_page_abnomize-info' != $hook ) { return; } wp_enqueue_style( 'abnomize-admin-style', get_stylesheet_uri(), [], GRABBER_VERSION ); wp_enqueue_style( 'abnomize-shared-styles', get_theme_file_uri( 'assets/css/admin-style.css' ), [], GRABBER_VERSION ); } add_action( 'admin_enqueue_scripts', 'abnomize_styles_admin' ); /** * Add Menu Page * * @return void */ function abnomize_add_menu_page() { add_theme_page( esc_html__( 'Abnomize', 'abnomize' ), esc_html__( 'Abnomize', 'abnomize' ), 'edit_theme_options', 'abnomize-info', 'abnomize_theme_page_display','2' ); } add_action( 'admin_menu', 'abnomize_add_menu_page' ); /** * Display About page */ function abnomize_theme_page_display() { $theme = wp_get_theme(); include_once 'inc/theme-info.php'; } // Filters. require_once get_theme_file_path( 'inc/filters.php' ); // Block variation example. require_once get_theme_file_path( 'inc/register-block-variations.php' ); // Block style examples. require_once get_theme_file_path( 'inc/register-block-styles.php' ); // Block pattern and block category examples. require_once get_theme_file_path( 'inc/register-block-patterns.php' ); add_action( 'after_switch_theme', 'abnomize_activation_message' ); function abnomize_activation_message() { // Get the current user. $user = wp_get_current_user(); $the_theme = wp_get_theme()->get( 'Name' ); // Check if the user has already dismissed the message. if ( get_user_meta( $user->ID, 'abnomize_activation_message', true ) ) { return; } $message = '
' . esc_attr( $the_theme ) . '

' . sprintf( /* translators: 1: Theme name, 2: Site editor URL */ esc_html__( 'Congratulations on activating %1$s! To get started, visit the %2$s to customize your theme.', 'abnomize' ), '' . esc_html( $the_theme ) . '', '' . esc_html__( 'Site Editor', 'abnomize' ) . '' ) . '

'; // Display the message. add_action( 'admin_notices', function() use ( $message ) { echo wp_kses_post( $message ); } ); } function abnomize_add_rand_orderby_rest_api( $query_params ) { $query_params['orderby']['enum'][] = 'rand'; return $query_params; } add_filter( 'rest_post_collection_params', 'abnomize_add_rand_orderby_rest_api' );