123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?php
- /**
- * Assembler functions and definitions
- *
- * @link https://developer.wordpress.org/themes/basics/theme-functions/
- *
- * @package Assembler
- * @since Assembler 1.0
- */
- declare( strict_types = 1 );
- if ( ! function_exists( 'assembler_unregister_patterns' ) ) :
- /**
- * Unregister Jetpack patterns and core patterns bundled in WordPress.
- */
- function assembler_unregister_patterns() {
- $pattern_names = array(
- // Jetpack form patterns.
- 'contact-form',
- 'newsletter-form',
- 'rsvp-form',
- 'registration-form',
- 'appointment-form',
- 'feedback-form',
- // Patterns bundled in WordPress core.
- // These would be removed by remove_theme_support( 'core-block-patterns' )
- // if it's called on the init action with priority 9 from a plugin, not from a theme.
- 'core/query-standard-posts',
- 'core/query-medium-posts',
- 'core/query-small-posts',
- 'core/query-grid-posts',
- 'core/query-large-title-posts',
- 'core/query-offset-posts',
- 'core/social-links-shared-background-color',
- );
- foreach ( $pattern_names as $pattern_name ) {
- $pattern = \WP_Block_Patterns_Registry::get_instance()->get_registered( $pattern_name );
- if ( $pattern ) {
- unregister_block_pattern( $pattern_name );
- }
- }
- }
- endif;
- if ( ! function_exists( 'assembler_setup' ) ) :
- /**
- * Sets up theme defaults and registers support for various WordPress features.
- *
- * @since Assembler 1.0
- *
- * @return void
- */
- function assembler_setup() {
- // Enqueue editor styles.
- add_editor_style( 'style.css' );
- // Unregister Jetpack form patterns and core patterns bundled in WordPress.
- // Simple sites
- assembler_unregister_patterns();
- add_filter( 'wp_loaded', function () {
- // Atomic sites
- assembler_unregister_patterns();
- } );
- // Remove theme support for the core and featured patterns coming from the Dotorg pattern directory.
- remove_theme_support( 'core-block-patterns' );
- }
- endif;
- add_action( 'after_setup_theme', 'assembler_setup' );
- if ( ! function_exists( 'assembler_styles' ) ) :
- /**
- * Enqueue styles.
- *
- * @since Assembler 1.0
- *
- * @return void
- */
- function assembler_styles() {
- // Register theme stylesheet.
- wp_register_style(
- 'assembler-style',
- get_stylesheet_directory_uri() . '/style.css',
- array(),
- wp_get_theme()->get( 'Version' )
- );
- // Enqueue theme stylesheet.
- wp_enqueue_style( 'assembler-style' );
- }
- endif;
- add_action( 'wp_enqueue_scripts', 'assembler_styles' );
- gutenberg_register_block_style(
- array( 'core/group', 'core/columns' ),
- array(
- 'name' => '2',
- 'label' => __( 'Light', 'assembler' ),
- 'style_data' => array(
- 'color' => array(
- 'background' => 'var(--wp--preset--color--theme-2)',
- )
- ),
- )
- );
- gutenberg_register_block_style(
- array( 'core/group', 'core/columns' ),
- array(
- 'name' => '3',
- 'label' => __( 'Dark', 'assembler' ),
- 'style_data' => array(
- 'color' => array(
- 'background' => 'var(--wp--preset--color--theme-4)',
- 'text' => 'var(--wp--preset--color--theme-2)',
- ),
- 'elements' => array(
- 'button' => array(
- 'color' => array(
- 'background' => 'var(--wp--preset--color--theme-1)',
- 'text' => 'var(--wp--preset--color--theme-4)',
- ),
- ':hover' => array(
- 'color' => array(
- 'background' => 'var(--wp--preset--color--theme-2)',
- ),
- ),
- ),
- 'heading' => array(
- 'color' => array(
- 'text' => 'var(--wp--preset--color--theme-1)',
- )
- ),
- 'link' => array(
- 'color' => array(
- 'text' => 'currentColor',
- ),
- ':hover' => array(
- 'color' => array(
- 'text' => 'currentColor',
- ),
- ),
- ),
- ),
- ),
- )
- );
- gutenberg_register_block_style(
- array( 'core/group', 'core/columns' ),
- array(
- 'name' => '4',
- 'label' => __( 'Darkest', 'assembler' ),
- 'style_data' => array(
- 'color' => array(
- 'background' => 'var(--wp--preset--color--theme-5)',
- 'text' => 'var(--wp--preset--color--theme-2)',
- ),
- 'elements' => array(
- 'button' => array(
- 'color' => array(
- 'background' => 'var(--wp--preset--color--theme-1)',
- 'text' => 'var(--wp--preset--color--theme-4)',
- ),
- ':hover' => array(
- 'color' => array(
- 'background' => 'var(--wp--preset--color--theme-2)',
- ),
- ),
- ),
- 'heading' => array(
- 'color' => array(
- 'text' => 'var(--wp--preset--color--theme-1)',
- )
- ),
- 'link' => array(
- 'color' => array(
- 'text' => 'currentColor',
- ),
- ':hover' => array(
- 'color' => array(
- 'text' => 'currentColor',
- ),
- ),
- ),
- ),
- ),
- )
- );
|