文件操作 - editor-styles.php
返回文件管理
返回主菜单
删除本文件
文件: /storage/v12552/jimbrandstatter/public_html/wp-content/themes/Total/inc/editor/editor-styles.php
编辑文件内容
<?php namespace TotalTheme\Editor; \defined( 'ABSPATH' ) || exit; /** * Enqueues scripts and adds inline CSS for the WordPress editor. */ final class Editor_Styles { /** * Init. */ public static function init() { self::classic_editor_hooks(); self::gutenberg_hooks(); } /** * Classic editor hooks. */ public static function classic_editor_hooks() { \add_action( 'after_setup_theme', [ self::class, 'classic_editor_style' ], 10 ); \add_filter( 'tiny_mce_before_init', [ self::class, 'classic_editor_content_style' ] ); \add_action( 'admin_enqueue_scripts', [ self::class, 'enqueue_editor_fonts' ] ); } /** * Gutenberg editor hooks. */ public static function gutenberg_hooks() { if ( is_admin() ) { \add_action( 'enqueue_block_assets', [ self::class, 'on_enqueue_block_assets' ] ); } } /** * Add styles for the classic. */ public static function classic_editor_style() { \add_editor_style( 'assets/css/wpex-custom-properties.css' ); \add_editor_style( 'assets/css/wpex-utility.css' ); \add_editor_style( 'assets/css/admin/classic-editor.css' ); \add_editor_style( 'assets/lib/ticons/css/ticons.min.css' ); } /** * Adds inline CSS for the editor to match Customizer settings. */ public static function classic_editor_content_style( $settings ) { $content_style = ! empty( $settings['content_style'] ) ? $settings['content_style'] : ''; $content_style .= self::get_editor_css( 'classic' ); $settings['content_style'] = $content_style; return $settings; } /** * Enqueues fonts for the tiny mce editor. */ public static function enqueue_editor_fonts( $hook ) { if ( $hook === 'post-new.php' || $hook === 'post.php' ) { self::get_editor_css(); } } /** * Runs on the "on_enqueue_block_assets" hook. */ public static function on_enqueue_block_assets() { \wp_enqueue_style( 'totaltheme-gutenberg-editor', \get_theme_file_uri( '/assets/css/gutenberg/editor.css' ), [], \WPEX_THEME_VERSION, 'all' ); \wp_add_inline_style( 'totaltheme-gutenberg-editor', self::get_editor_css( 'gutenberg' ) ); } /** * Generate inline CSS for the WP editor based on Customizer settings. */ public static function get_editor_css( $editor_type = 'classic' ) { \ob_start(); // Loop through typography settings that should apply in the editor. // @todo use a tag in the typography array to define what settings should be added and how they // should target - 'block_editor' => [] if ( \class_exists( '\TotalTheme\Typography', false ) ) { $typography_settings = [ 'body_typography' => '', 'post_content_typography' => '', 'entry_h2_typography' => [ 'h2', 'h2.wp-block' ], 'entry_h3_typography' => [ 'h3', 'h3.wp-block' ], 'entry_h4_typography' => [ 'h4', 'h4.wp-block' ], ]; foreach ( $typography_settings as $typography_setting => $target_el ) { $value = \get_theme_mod( $typography_setting ); if ( ! empty( $value ) && \is_array( $value ) ) { foreach ( $value as $property => $value ) { if ( \is_array( $value ) ) { $value = \reset( $value ); } switch ( $editor_type ) { case 'gutenberg': $target = '.editor-styles-wrapper > *'; break; case 'classic': default: $target = 'body#tinymce.wp-editor'; break; } if ( 'color' === $property && self::is_white( $value ) ) { continue; } if ( $target_el ) { if ( \is_array( $target_el ) ) { $new_target = []; foreach ( $target_el as $k => $v ) { $new_target[] = $target . ' ' . $v; } $target = \implode( ',', $new_target ); } else { $target = $target . ' ' . $target_el; } } echo \wpex_parse_css( $value, $property, $target ); if ( 'font-family' === $property ) { if ( 'custom' === \wpex_get_font_type( $value ) ) { echo \wpex_render_custom_font_css( $value ); } else { $font = \wpex_enqueue_font( $value ); if ( 'classic' === $editor_type && $font ) { \add_editor_style( $font ); } } } } } } // End foreach typography_settings. // @todo add some customizer styles CSS here - such as button styles. // Classic editor only styles. if ( 'classic' === $editor_type ) { if ( \get_theme_mod( 'enable_font_smoothing', false ) ) { echo 'body#tinymce.wp-editor{-webkit-font-smoothing: antialiased !important;}'; } } // Link underline. if ( \get_theme_mod( 'link_underline' ) ) { echo 'body#tinymce.wp-editor{--wpex-link-decoration-line: underline;}'; } } return \ob_get_clean(); } /** * Check if a value is the color white. * * @todo there needs to be a better way of doing this. Perhaps we should be adding the site background to the editor? */ private static function is_white( $value = '' ): bool { return ( '#fff' === $value || '#ffffff' === $value || '#FFF' === $value || '#FFFFFF' === $value ); } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件