- Timestamp:
- 12/14/2018 02:32:33 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43808,43821,43842,43860,43892,43904,43909,43926-43929,43956,43961-43963
- Property svn:mergeinfo changed
-
trunk/src/wp-content/themes/twentynineteen/functions.php
r43808 r44149 7 7 * @package WordPress 8 8 * @subpackage Twenty_Nineteen 9 */ 9 * @since 1.0.0 10 */ 11 12 /** 13 * Twenty Nineteen only works in WordPress 4.7 or later. 14 */ 15 if ( version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) { 16 require get_template_directory() . '/inc/back-compat.php'; 17 return; 18 } 10 19 11 20 if ( ! function_exists( 'twentynineteen_setup' ) ) : … … 48 57 register_nav_menus( 49 58 array( 50 'menu-1' => esc_html__( 'Primary', 'twentynineteen' ), 59 'menu-1' => __( 'Primary', 'twentynineteen' ), 60 'footer' => __( 'Footer Menu', 'twentynineteen' ), 51 61 'social' => __( 'Social Links Menu', 'twentynineteen' ), 52 62 ) … … 68 78 ); 69 79 70 // Set up the WordPress core custom background feature.71 add_theme_support(72 'custom-background',73 apply_filters(74 'twentynineteen_custom_background_args',75 array(76 'default-color' => 'ffffff',77 'default-image' => '',78 )79 )80 );81 82 80 /** 83 81 * Add support for core custom logo. … … 95 93 ); 96 94 97 // Add support for Block Styles 95 // Add theme support for selective refresh for widgets. 96 add_theme_support( 'customize-selective-refresh-widgets' ); 97 98 // Add support for Block Styles. 98 99 add_theme_support( 'wp-block-styles' ); 99 100 … … 101 102 add_theme_support( 'align-wide' ); 102 103 103 // Add support for editor styles 104 // Add support for editor styles. 104 105 add_theme_support( 'editor-styles' ); 105 106 106 // Enqueue editor styles 107 // Enqueue editor styles. 107 108 add_editor_style( 'style-editor.css' ); 108 109 110 // Add custom editor font sizes. 111 add_theme_support( 112 'editor-font-sizes', 113 array( 114 array( 115 'name' => __( 'Small', 'twentynineteen' ), 116 'shortName' => __( 'S', 'twentynineteen' ), 117 'size' => 19.5, 118 'slug' => 'small', 119 ), 120 array( 121 'name' => __( 'Normal', 'twentynineteen' ), 122 'shortName' => __( 'M', 'twentynineteen' ), 123 'size' => 22, 124 'slug' => 'normal', 125 ), 126 array( 127 'name' => __( 'Large', 'twentynineteen' ), 128 'shortName' => __( 'L', 'twentynineteen' ), 129 'size' => 36.5, 130 'slug' => 'large', 131 ), 132 array( 133 'name' => __( 'Huge', 'twentynineteen' ), 134 'shortName' => __( 'XL', 'twentynineteen' ), 135 'size' => 49.5, 136 'slug' => 'huge', 137 ), 138 ) 139 ); 140 141 // Editor color palette. 142 add_theme_support( 143 'editor-color-palette', 144 array( 145 array( 146 'name' => __( 'Primary', 'twentynineteen' ), 147 'slug' => 'primary', 148 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 33 ), 149 ), 150 array( 151 'name' => __( 'Secondary', 'twentynineteen' ), 152 'slug' => 'secondary', 153 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 23 ), 154 ), 155 array( 156 'name' => __( 'Dark Gray', 'twentynineteen' ), 157 'slug' => 'dark-gray', 158 'color' => '#111', 159 ), 160 array( 161 'name' => __( 'Light Gray', 'twentynineteen' ), 162 'slug' => 'light-gray', 163 'color' => '#767676', 164 ), 165 array( 166 'name' => __( 'White', 'twentynineteen' ), 167 'slug' => 'white', 168 'color' => '#FFF', 169 ), 170 ) 171 ); 172 173 // Add support for responsive embedded content. 174 add_theme_support( 'responsive-embeds' ); 109 175 } 110 176 endif; … … 112 178 113 179 /** 180 * Register widget area. 181 * 182 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar 183 */ 184 function twentynineteen_widgets_init() { 185 186 register_sidebar( 187 array( 188 'name' => __( 'Footer', 'twentynineteen' ), 189 'id' => 'sidebar-1', 190 'description' => __( 'Add widgets here to appear in your footer.', 'twentynineteen' ), 191 'before_widget' => '<section id="%1$s" class="widget %2$s">', 192 'after_widget' => '</section>', 193 'before_title' => '<h2 class="widget-title">', 194 'after_title' => '</h2>', 195 ) 196 ); 197 198 } 199 add_action( 'widgets_init', 'twentynineteen_widgets_init' ); 200 201 /** 114 202 * Set the content width in pixels, based on the theme's design and stylesheet. 115 203 * 116 204 * Priority 0 to make it available to lower priority callbacks. 117 205 * 118 * @global int $content_width 206 * @global int $content_width Content width. 119 207 */ 120 208 function twentynineteen_content_width() { … … 130 218 */ 131 219 function twentynineteen_scripts() { 132 wp_enqueue_style( 'twentynineteen-style', get_stylesheet_uri() );220 wp_enqueue_style( 'twentynineteen-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) ); 133 221 134 222 wp_style_add_data( 'twentynineteen-style', 'rtl', 'replace' ); … … 136 224 wp_enqueue_script( 'twentynineteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true ); 137 225 226 if ( has_nav_menu( 'menu-1' ) ) { 227 wp_enqueue_script( 'twentynineteen-priority-menu', get_theme_file_uri( '/js/priority-menu.js' ), array(), '1.0', true ); 228 wp_enqueue_script( 'twentynineteen-touch-navigation', get_theme_file_uri( '/js/touch-keyboard-navigation.js' ), array(), '1.0', true ); 229 } 230 138 231 wp_enqueue_style( 'twentynineteen-print-style', get_template_directory_uri() . '/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' ); 139 140 if ( is_singular() && twentynineteen_can_show_post_thumbnail() ) {141 wp_add_inline_style( 'twentynineteen-style', twentynineteen_header_featured_image_css() );142 }143 232 144 233 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { … … 149 238 150 239 /** 151 * Enqueue supplemental block editor styles 152 */ 153 function twentynineteen_editor_frame_styles() { 154 wp_enqueue_style( 'twentynineteen-editor-frame-styles', get_theme_file_uri( '/style-editor-frame.css' ), false, '1.0', 'all' ); 155 } 156 157 add_action( 'enqueue_block_editor_assets', 'twentynineteen_editor_frame_styles' ); 240 * Enqueue supplemental block editor styles. 241 */ 242 function twentynineteen_editor_customizer_styles() { 243 244 wp_enqueue_style( 'twentynineteen-editor-customizer-styles', get_theme_file_uri( '/style-editor-customizer.css' ), false, '1.0', 'all' ); 245 246 if ( 'custom' === get_theme_mod( 'primary_color' ) ) { 247 // Include color patterns. 248 require_once get_parent_theme_file_path( '/inc/color-patterns.php' ); 249 wp_add_inline_style( 'twentynineteen-editor-customizer-styles', twentynineteen_custom_colors_css() ); 250 } 251 } 252 add_action( 'enqueue_block_editor_assets', 'twentynineteen_editor_customizer_styles' ); 253 254 /** 255 * Display custom color CSS in customizer and on frontend. 256 */ 257 function twentynineteen_colors_css_wrap() { 258 259 // Only include custom colors in customizer or frontend. 260 if ( ( ! is_customize_preview() && 'default' === get_theme_mod( 'primary_color', 'default' ) ) || is_admin() ) { 261 return; 262 } 263 264 require_once get_parent_theme_file_path( '/inc/color-patterns.php' ); 265 266 if ( 'default' === get_theme_mod( 'primary_color', 'default' ) ) { 267 $primary_color = 199; 268 } else { 269 $primary_color = absint( get_theme_mod( 'primary_color_hue', 199 ) ); 270 } 271 ?> 272 273 <style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . $primary_color . '"' : ''; ?>> 274 <?php echo twentynineteen_custom_colors_css(); ?> 275 </style> 276 <?php 277 } 278 add_action( 'wp_head', 'twentynineteen_colors_css_wrap' ); 158 279 159 280 /**
Note: See TracChangeset
for help on using the changeset viewer.