_includes(); } /** * Include additional files. */ private function _includes() { require_once( SUKI_INCLUDES_DIR . '/admin/class-suki-admin-fields.php' ); // Only include metabox on post add/edit page and term add/edit page. global $pagenow; if ( in_array( $pagenow, array( 'post.php', 'post-new.php', 'edit-tags.php', 'term.php' ) ) ) { require_once( SUKI_INCLUDES_DIR . '/admin/class-suki-admin-metabox-page-settings.php' ); } } /** * ==================================================== * Hook functions * ==================================================== */ /** * Add admin submenu page: Appearance > Suki. */ public function register_admin_menu() { add_theme_page( suki_get_theme_info( 'name' ), suki_get_theme_info( 'name' ), 'edit_theme_options', 'suki', array( $this, 'render_admin_page' ) ); /** * Hook: suki/admin/menu */ do_action( 'suki/admin/menu' ); } /** * Add admin notice to import data like screenshot. */ public function add_theme_notice() { // Abort if we are on Child Theme. if ( is_child_theme() ) { return; } global $hook_suffix; if ( 'themes.php' == $hook_suffix ) : ?>

' . esc_html__( 'here', 'suki' ) . '' ); ?>

generate_active_google_fonts_embed_url() ); } /** * Add custom CSS to classic editor. * * @param array $settings * @return array */ public function add_classic_editor_custom_css( $settings ) { // echo 'halo'; global $post; if ( empty( $post ) ) { return $settings; } $css_array = array( 'global' => array(), ); // TinyMCE HTML $css_array['global']['html']['background-color'] = '#fcfcfc'; // Typography $active_google_fonts = array(); $typography_types = array( 'body' => 'body', 'blockquote' => 'blockquote', 'h1' => 'h1', 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', ); $fonts = suki_get_all_fonts(); foreach ( $typography_types as $type => $selector ) { // Font Family $font_family = suki_get_theme_mod( $type . '_font_family' ); $font_stack = $font_family; if ( '' !== $font_family && 'inherit' !== $font_family ) { $chunks = explode( '|', $font_family ); if ( 2 === count( $chunks ) ) { $font_stack = suki_array_value( $fonts[ $chunks[0] ], $chunks[1], $chunks[1] ); } } if ( ! empty( $font_stack ) ) { $css_array['global'][ $selector ]['font-family'] = $font_stack; } // Font weight $font_weight = suki_get_theme_mod( $type . '_font_weight' ); if ( ! empty( $font_weight ) ) { $css_array['global'][ $selector ]['font-weight'] = $font_weight; } // Font style $font_style = suki_get_theme_mod( $type . '_font_style' ); if ( ! empty( $font_style ) ) { $css_array['global'][ $selector ]['font-style'] = $font_style; } // Text transform $text_transform = suki_get_theme_mod( $type . '_text_transform' ); if ( ! empty( $text_transform ) ) { $css_array['global'][ $selector ]['text-transform'] = $text_transform; } // Font size $font_size = suki_get_theme_mod( $type . '_font_size' ); if ( ! empty( $font_size ) ) { $css_array['global'][ $selector ]['font-size'] = $font_size; } // Line height $line_height = suki_get_theme_mod( $type . '_line_height' ); if ( ! empty( $line_height ) ) { $css_array['global'][ $selector ]['line-height'] = $line_height; } // Letter spacing $letter_spacing = suki_get_theme_mod( $type . '_letter_spacing' ); if ( ! empty( $letter_spacing ) ) { $css_array['global'][ $selector ]['letter-spacing'] = $letter_spacing; } } // Content wrapper width for content layout with sidebar $css_array['global']['body.suki-editor-left-sidebar']['width'] = $css_array['global']['body.suki-editor-right-sidebar']['width'] = 'calc(' . suki_get_content_width_by_layout() . 'px + 2rem)'; // Content wrapper width for narrow content layout $css_array['global']['body.suki-editor-narrow']['width'] = 'calc(' . suki_get_content_width_by_layout( 'narrow' ) . 'px + 2rem)'; // Content wrapper width for full content layout $css_array['global']['body.suki-editor-wide']['width'] = 'calc(' . suki_get_content_width_by_layout( 'wide' ) . 'px + 2rem)'; // Build CSS string. // $styles = str_replace( '"', '\"', suki_convert_css_array_to_string( $css_array ) ); $styles = wp_slash( suki_convert_css_array_to_string( $css_array ) ); // Merge with existing styles or add new styles. if ( ! isset( $settings['content_style'] ) ) { $settings['content_style'] = $styles . ' '; } else { $settings['content_style'] .= ' ' . $styles . ' '; } return $settings; } /** * Add body class to classic editor. * * @param array $settings * @return array */ public function add_classic_editor_body_class( $settings ) { global $post; if ( empty( $post ) ) { return $settings; } $class = 'suki-editor-' . suki_get_page_setting_by_post_id( 'content_layout', $post->ID ); // Merge with existing classes or add new class. if ( ! isset( $settings['body_class'] ) ) { $settings['body_class'] = $class . ' '; } else { $settings['body_class'] .= ' ' . $class . ' '; } return $settings; } /** * Add custom CSS to Gutenberg editor. * * @param array $settings * @return array */ public function add_gutenberg_custom_css( $settings ) { $css_array = array(); // Content width $css_array['global']['.wp-block']['max-width'] = 'calc(' . suki_get_theme_mod( 'content_narrow_width' ) . ' + ' . '30px)'; $css_array['global']['.wp-block[data-align="wide"]']['max-width'] = 'calc(' . suki_get_theme_mod( 'container_width' ) . ' + ' . '30px)'; // Typography $active_google_fonts = array(); $typography_types = array( 'body' => 'body', 'blockquote' => 'blockquote', 'h1' => 'h1, .editor-post-title__block .editor-post-title__input', 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', 'title' => '.editor-post-title__block .editor-post-title__input', ); $fonts = suki_get_all_fonts(); foreach ( $typography_types as $type => $selector ) { // Font Family $font_family = suki_get_theme_mod( $type . '_font_family' ); $font_stack = $font_family; if ( '' !== $font_family && 'inherit' !== $font_family ) { $chunks = explode( '|', $font_family ); if ( 2 === count( $chunks ) ) { $font_stack = suki_array_value( $fonts[ $chunks[0] ], $chunks[1], $chunks[1] ); } } if ( ! empty( $font_stack ) ) { $css_array['global'][ $selector ]['font-family'] = $font_stack; } // Font weight $font_weight = suki_get_theme_mod( $type . '_font_weight' ); if ( ! empty( $font_weight ) ) { $css_array['global'][ $selector ]['font-weight'] = $font_weight; } // Font style $font_style = suki_get_theme_mod( $type . '_font_style' ); if ( ! empty( $font_style ) ) { $css_array['global'][ $selector ]['font-style'] = $font_style; } // Text transform $text_transform = suki_get_theme_mod( $type . '_text_transform' ); if ( ! empty( $text_transform ) ) { $css_array['global'][ $selector ]['text-transform'] = $text_transform; } // Font size $font_size = suki_get_theme_mod( $type . '_font_size' ); if ( ! empty( $font_size ) ) { $css_array['global'][ $selector ]['font-size'] = $font_size; } // Line height $line_height = suki_get_theme_mod( $type . '_line_height' ); if ( ! empty( $line_height ) ) { $css_array['global'][ $selector ]['line-height'] = $line_height; } // Letter spacing $letter_spacing = suki_get_theme_mod( $type . '_letter_spacing' ); if ( ! empty( $letter_spacing ) ) { $css_array['global'][ $selector ]['letter-spacing'] = $letter_spacing; } } // Add to settings array. $settings['styles'][] = array( 'css' => suki_convert_css_array_to_string( $css_array ), ); return $settings; } /** * ==================================================== * Render functions * ==================================================== */ /** * Render admin page. */ public function render_admin_page() { ?>

<?php echo esc_attr( get_admin_page_title() ); ?>

' . esc_html__( 'our website', 'suki' ) . '' ); ?>

$module_data ) : ?>
$action_data ) : if ( isset( $action_data['url'] ) ) : ?>