✏️ 正在编辑: theme-options.php
路径:
/home/h359620/public_html/wp-content/themes/datis/inc/theme-settings/theme-options.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * Theme settings management class for datis * This class uses the Redux Framework to create the theme settings page. * * @package Datis */ if (!defined('ABSPATH')) { exit; // Prevent direct access } if (!class_exists('Datis_Theme_Options')) { class Datis_Theme_Options { protected $opt_name = 'datis_theme_options'; private static $instance; private function __construct() { $this->init_hooks(); $this->init_redux(); } private function init_hooks() { add_action('wp_enqueue_scripts', [$this, 'output_custom_css'], 999); add_action('wp_footer', [$this, 'output_custom_js'], 999); add_action('wp_head', [$this, 'output_head_code'], 1); add_action('admin_enqueue_scripts', [$this, 'admin_assets']); add_action('redux/options/datis_theme_options/saved', [$this, 'datis_set_wp_logo_and_favicon']); } private function init_redux() { if (!class_exists('Redux')) { add_action('admin_notices', function () { echo '<div class="notice notice-error"><p>Redux Framework plugin is required for Datis theme options.</p></div>'; }); return; } $this->setup_redux_config(); } function datis_set_wp_logo_and_favicon($options) { if (!empty($options['logo']['id'])) { set_theme_mod('custom_logo', $options['logo']['id']); } if (!empty($options['favicon']['id'])) { update_option('site_icon', $options['favicon']['id']); } } private function get_elementor_templates() { $templates = get_posts([ 'post_type' => 'elementor_library', 'posts_per_page' => -1, 'post_status' => 'publish', 'orderby' => 'title', 'order' => 'ASC' ]); $options = []; if (!empty($templates)) { foreach ($templates as $template) { $options[$template->ID] = $template->post_title; } } return $options; } private function setup_redux_config() { $args = [ 'opt_name' => $this->opt_name, 'display_name' => esc_html__('Datis Theme Settings', 'datis'), 'display_version' => wp_get_theme()->get('Version'), 'menu_type' => 'menu', 'allow_sub_menu' => true, 'menu_title' => esc_html__('Theme Options', 'datis'), 'page_title' => esc_html__('Datis Theme Settings', 'datis'), 'google_api_key' => '', 'async_typography' => true, 'admin_bar' => true, 'admin_bar_icon' => 'dashicons-admin-generic', 'admin_bar_priority' => 50, 'global_variable' => $this->opt_name, 'dev_mode' => defined('WP_DEBUG') && WP_DEBUG, 'update_notice' => true, 'customizer' => true, 'page_priority' => 21, 'page_parent' => 'themes.php', 'page_permissions' => 'manage_options', 'menu_icon' => 'dashicons-admin-generic', 'page_slug' => 'datis-theme-options', 'save_defaults' => true, 'show_import_export' => true, 'transient_time' => 3600, 'output' => true, 'output_tag' => true, 'use_cdn' => true ]; Redux::setArgs($this->opt_name, $args); $this->add_general_section(); $this->add_typography_section(); $this->add_blog_section(); $this->add_templates_section(); $this->add_project_section(); $this->add_custom_code_section(); } private function add_general_section() { Redux::setSection($this->opt_name, [ 'title' => esc_html__('General Settings', 'datis'), 'id' => 'general-settings', 'icon' => 'el el-globe', ]); Redux::setSection($this->opt_name, [ 'title' => esc_html__('General Settings', 'datis'), 'desc' => esc_html__('In this section, configure the general settings of your site.', 'datis'), 'id' => 'general-setting', 'subsection' => true, 'fields' => [ [ 'id' => 'logo', 'type' => 'media', 'title' => esc_html__('Logo', 'datis'), 'subtitle' => esc_html__('Upload your site logo', 'datis'), ], [ 'id' => 'favicon', 'type' => 'media', 'title' => esc_html__('Favicon', 'datis'), 'subtitle' => esc_html__('Upload your site favicon', 'datis'), ], [ 'id' => 'container_size', 'type' => 'text', 'title' => esc_html__('Container Size', 'datis'), 'default' => '1320', ], // [ // 'id' => 'border_radius', // 'type' => 'text', // 'title' => esc_html__('Border Radius', 'datis'), // 'default' => '22px', // ] ] ]); Redux::setSection($this->opt_name, [ 'title' => esc_html__('Global Style', 'datis'), 'desc' => esc_html__('Style your theme', 'datis'), 'id' => 'global-style', 'subsection' => true, 'fields' => [ [ 'id' => 'body_bg_color', 'type' => 'color', 'title' => esc_html__('Body Background Color', 'datis'), 'subtitle' => esc_html__('Pick body background color', 'datis'), 'default' => '#ffffff', 'validate' => 'color', ], [ 'id' => 'preloader_bg_color', 'type' => 'color', 'title' => esc_html__('Preloader Background Color', 'datis'), 'subtitle' => esc_html__('Pick Preloader background color', 'datis'), 'default' => '#FFA84B', 'validate' => 'color', ], [ 'id' => 'preloader_color', 'type' => 'color', 'title' => esc_html__('loader Color', 'datis'), 'subtitle' => esc_html__('Pick loader color', 'datis'), 'default' => '#ffffff', 'validate' => 'color', ], [ 'id' => 'body_text_color', 'type' => 'color', 'title' => esc_html__('Text Color', 'datis'), 'subtitle' => esc_html__('Pick text color', 'datis'), 'default' => '#777777', 'validate' => 'color', ], [ 'id' => 'primary_color', 'type' => 'color', 'title' => esc_html__('Primary Color', 'datis'), 'subtitle' => esc_html__('Select Primary Color.', 'datis'), 'default' => '#083D59', 'validate' => 'color', ], [ 'id' => 'secondary_color', 'type' => 'color', 'title' => esc_html__('Secondary Color', 'datis'), 'subtitle' => esc_html__('Select Secondary Color.', 'datis'), 'default' => '#FFA84B', 'validate' => 'color', ], [ 'id' => 'partially_color', 'type' => 'color', 'title' => esc_html__('Partial Color', 'datis'), 'subtitle' => esc_html__('Select Partial Color.', 'datis'), 'default' => '#ffecec', 'validate' => 'color', ], [ 'id' => 'link_text_color', 'type' => 'color', 'title' => esc_html__('Link Color', 'datis'), 'subtitle' => esc_html__('Pick link color', 'datis'), 'default' => '#FFA84B', 'validate' => 'color', ], [ 'id' => 'link_hover_text_color', 'type' => 'color', 'title' => __('Link Hover Color', 'datis'), 'subtitle' => __('Pick link hover color', 'datis'), 'default' => '#083D59', 'validate' => 'color', ], ] ]); } private function add_typography_section() { Redux::setSection($this->opt_name, [ 'title' => esc_html__('Typography', 'datis'), 'id' => 'typography', 'icon' => 'el el-font', 'fields' => [ [ 'id' => 'custom_font', 'type' => 'custom_fonts', 'title' => esc_html__('Custom Fonts', 'datis'), 'subtitle' => esc_html__('In this section, upload your custom font.', 'datis'), ], [ 'id' => 'dashboard_typography', 'type' => 'typography', 'title' => esc_html__('Admin Typography', 'datis'), 'subtitle' => esc_html__('Adjust admin panel font.', 'datis'), 'output' => false, 'font-style' => false, 'font-weight' => false, 'font-size' => false, 'text-align' => false, 'line-height' => false, 'color' => false, 'google' => false, 'fonts' => [ 'Yekan Bakh FaNum' => '"Yekan Bakh FaNum", sans-serif', 'Dana' => '"Dana", sans-serif', 'IranSans' => '"IranSans", sans-serif', ], 'default' => [ 'font-family' => 'Yekan Bakh FaNum', 'font-weight' => '400', 'font-size' => '14px', ], ], [ 'id' => 'body_typography', 'type' => 'typography', 'title' => esc_html__('Body Typography', 'datis'), 'subtitle' => esc_html__('In this section, adjust the typography of the texts.', 'datis'), 'output' => ['body,html'], 'google' => false, 'font-style' => false, 'text-align' => false, 'fonts' => [ 'Yekan Bakh FaNum' => '"Yekan Bakh FaNum", sans-serif', 'Dana' => '"Dana", sans-serif', 'IranSans' => '"IranSans", sans-serif', ], 'default' => [ 'font-family' => 'Yekan Bakh FaNum', 'font-size' => '16px', ], 'weights' => [ '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900', ], ], [ 'id' => 'heading_typography_h1', 'type' => 'typography', 'title' => esc_html__('Heading h1 Typography', 'datis'), 'subtitle' => esc_html__('In this section, adjust the typography of the titles.', 'datis'), 'output' => ['h1'], 'font-style' => false, 'font-weight' => false, 'font-size' => true, 'text-align' => false, 'line-height' => true, 'color' => false, 'google' => false, 'fonts' => [ 'Yekan Bakh FaNum' => '"Yekan Bakh FaNum", sans-serif', 'Dana' => '"Dana", sans-serif', 'IranSans' => '"IranSans", sans-serif', ], 'default' => [ 'font-family' => 'Yekan Bakh FaNum', 'font-weight' => '700', 'font-size' => '20px', ], 'weights' => [ '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900', ], ], [ 'id' => 'heading_typography_h2', 'type' => 'typography', 'title' => esc_html__('Heading h2 Typography', 'datis'), 'subtitle' => esc_html__('In this section, adjust the typography of the titles.', 'datis'), 'output' => ['h2'], 'font-style' => false, 'font-weight' => false, 'font-size' => true, 'text-align' => false, 'line-height' => true, 'color' => false, 'google' => false, 'fonts' => [ 'Yekan Bakh FaNum' => '"Yekan Bakh FaNum", sans-serif', 'Dana' => '"Dana", sans-serif', 'IranSans' => '"IranSans", sans-serif', ], 'default' => [ 'font-family' => 'Yekan Bakh FaNum', 'font-weight' => '700', 'font-size' => '20px', ], 'weights' => [ '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900', ], ], [ 'id' => 'heading_typography_h3', 'type' => 'typography', 'title' => esc_html__('Heading h3 Typography', 'datis'), 'subtitle' => esc_html__('In this section, adjust the typography of the titles.', 'datis'), 'output' => ['h3'], 'font-style' => false, 'font-weight' => false, 'font-size' => true, 'text-align' => false, 'line-height' => true, 'color' => false, 'google' => false, 'fonts' => [ 'Yekan Bakh FaNum' => '"Yekan Bakh FaNum", sans-serif', 'Dana' => '"Dana", sans-serif', 'IranSans' => '"IranSans", sans-serif', ], 'default' => [ 'font-family' => 'Yekan Bakh FaNum', 'font-weight' => '700', 'font-size' => '20px', ], 'weights' => [ '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900', ], ], [ 'id' => 'heading_typography_h4', 'type' => 'typography', 'title' => esc_html__('Heading h4 Typography', 'datis'), 'subtitle' => esc_html__('In this section, adjust the typography of the titles.', 'datis'), 'output' => ['h4'], 'font-style' => false, 'font-weight' => false, 'font-size' => true, 'text-align' => false, 'line-height' => true, 'color' => false, 'google' => false, 'fonts' => [ 'Yekan Bakh FaNum' => '"Yekan Bakh FaNum", sans-serif', 'Dana' => '"Dana", sans-serif', 'IranSans' => '"IranSans", sans-serif', ], 'default' => [ 'font-family' => 'Yekan Bakh FaNum', 'font-weight' => '700', 'font-size' => '20px', ], 'weights' => [ '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900', ], ], [ 'id' => 'heading_typography_h5', 'type' => 'typography', 'title' => esc_html__('Heading h5 Typography', 'datis'), 'subtitle' => esc_html__('In this section, adjust the typography of the titles.', 'datis'), 'output' => ['h5'], 'font-style' => false, 'font-weight' => false, 'font-size' => true, 'text-align' => false, 'line-height' => true, 'color' => false, 'google' => false, 'fonts' => [ 'Yekan Bakh FaNum' => '"Yekan Bakh FaNum", sans-serif', 'Dana' => '"Dana", sans-serif', 'IranSans' => '"IranSans", sans-serif', ], 'default' => [ 'font-family' => 'Yekan Bakh FaNum', 'font-weight' => '700', 'font-size' => '20px', ], 'weights' => [ '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900', ], ], [ 'id' => 'heading_typography_h6', 'type' => 'typography', 'title' => esc_html__('Heading h6 Typography', 'datis'), 'subtitle' => esc_html__('In this section, adjust the typography of the titles.', 'datis'), 'output' => ['h6'], 'font-style' => false, 'font-weight' => false, 'font-size' => true, 'text-align' => false, 'line-height' => true, 'color' => false, 'google' => false, 'fonts' => [ 'Yekan Bakh FaNum' => '"Yekan Bakh FaNum", sans-serif', 'Dana' => '"Dana", sans-serif', 'IranSans' => '"IranSans", sans-serif', ], 'default' => [ 'font-family' => 'Yekan Bakh FaNum', 'font-weight' => '700', 'font-size' => '20px', ], 'weights' => [ '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900', ], ], ] ]); } private function add_blog_section() { Redux::setSection($this->opt_name, [ 'title' => esc_html__('Blog', 'datis'), 'id' => 'blog-settings', 'icon' => 'el el-globe', ]); Redux::setSection($this->opt_name, [ 'title' => esc_html__('Blog Archive', 'datis'), 'desc' => esc_html__("In this section, the template's blog archive settings are configured.", 'datis'), 'id' => 'blog-archive-setting', 'subsection' => true, 'fields' => [ [ 'id' => 'blog_archive_card_style', 'type' => 'select', 'title' => esc_html__('Blog Card Style', 'datis'), 'subtitle' => esc_html__('Choose which blog card layout to use in the archive.', 'datis'), 'options' => [ 'style-1' => esc_html__('Style 1', 'datis'), 'style-2' => esc_html__('Style 2', 'datis'), 'style-3' => esc_html__('Style 3', 'datis'), ], 'default' => 'style-1', ], // [ // 'id' => 'blog_archive_pagination_style', // 'type' => 'select', // 'title' => esc_html__('Blog Pagination Style', 'datis'), // 'subtitle' => esc_html__('Choose pagination style for blog archive.', 'datis'), // 'options' => [ // 'style-1' => esc_html__('Style 1', 'datis'), // 'style-2' => esc_html__('Style 2', 'datis'), // 'style-3' => esc_html__('Style 3', 'datis'), // ], // 'default' => 'style-1', // ], ] ]); } private function add_project_section() { Redux::setSection($this->opt_name, [ 'title' => esc_html__('project', 'datis'), 'id' => 'project-settings', 'icon' => 'el el-globe', ]); Redux::setSection($this->opt_name, [ 'title' => esc_html__('project Archive', 'datis'), 'desc' => esc_html__("In this section, the template's project archive settings are configured.", 'datis'), 'id' => 'project-archive-setting', 'subsection' => true, 'fields' => [ [ 'id' => 'project_archive_card_style', 'type' => 'select', 'title' => esc_html__('project Card Style', 'datis'), 'subtitle' => esc_html__('Choose which project card layout to use in the archive.', 'datis'), 'options' => [ 'style-1' => esc_html__('Style 1', 'datis'), 'style-2' => esc_html__('Style 2', 'datis'), ], 'default' => 'style-1', ], ] ]); } private function add_templates_section() { Redux::setSection($this->opt_name, [ 'title' => esc_html__('قالب ها', 'datis'), 'id' => 'templates-settings', 'icon' => 'el el-website', 'fields' => [ [ 'id' => 'datis_elementor_header', 'type' => 'select', 'title' => esc_html__('header template', 'datis'), 'subtitle' => esc_html__('Select an Elementor template to display above the header.', 'datis'), 'options' => $this->get_elementor_templates(), 'default' => '', 'placeholder' => esc_html__('Select a template...', 'datis'), ], [ 'id' => 'datis_elementor_footer', 'type' => 'select', 'title' => esc_html__('footer template', 'datis'), 'subtitle' => esc_html__('Select an Elementor template to display above the footer.', 'datis'), 'options' => $this->get_elementor_templates(), 'default' => '', 'placeholder' => esc_html__('Select a template...', 'datis'), ], [ 'id' => 'wc_login_slug', 'type' => 'text', 'title' => esc_html__('WooCommerce Login Slug', 'datis'), 'subtitle' => esc_html__('Example: login (site.com/login). Leave empty to use default WooCommerce behavior.', 'datis'), 'default' => '', ], [ 'id' => 'wc_register_slug', 'type' => 'text', 'title' => esc_html__('WooCommerce Register Slug', 'datis'), 'subtitle' => esc_html__('Example: register (site.com/register). Leave empty to use default WooCommerce behavior.', 'datis'), 'default' => '', ], [ 'id' => 'blog_archive_elementor_template', 'type' => 'select', 'title' => esc_html__('Blog Archive Top Template', 'datis'), 'subtitle' => esc_html__('Select an Elementor template to display above the blog archive.', 'datis'), 'options' => $this->get_elementor_templates(), 'default' => '', 'placeholder' => esc_html__('Select a template...', 'datis'), ], [ 'id' => 'project_archive_elementor_template', 'type' => 'select', 'title' => esc_html__('Project Archive Top Template', 'datis'), 'subtitle' => esc_html__('Select an Elementor template to display above the project archive.', 'datis'), 'options' => $this->get_elementor_templates(), 'default' => '', 'placeholder' => esc_html__('Select a template...', 'datis'), ], [ 'id' => 'project_single_elementor_template', 'type' => 'select', 'title' => esc_html__('Project Single Top Template', 'datis'), 'subtitle' => esc_html__('Select an Elementor template to display above the project single.', 'datis'), 'options' => $this->get_elementor_templates(), 'default' => '', 'placeholder' => esc_html__('Select a template...', 'datis'), ], [ 'id' => 'product_archive_elementor_template', 'type' => 'select', 'title' => esc_html__('Product Archive Top Template', 'datis'), 'subtitle' => esc_html__('Select an Elementor template to display above the product archive.', 'datis'), 'options' => $this->get_elementor_templates(), 'default' => '', 'placeholder' => esc_html__('Select a template...', 'datis'), ], [ 'id' => '404_elementor_template', 'type' => 'select', 'title' => esc_html__('404 Page Template', 'datis'), 'options' => $this->get_elementor_templates(), 'default' => '', 'placeholder' => esc_html__('Select a template...', 'datis'), ], ], ]); } private function add_custom_code_section() { Redux::setSection($this->opt_name, [ 'title' => esc_html__('Custom Codes', 'datis'), 'id' => 'custom-code', 'icon' => 'el el-css', 'fields' => [ [ 'id' => 'custom_css', 'type' => 'ace_editor', 'title' => esc_html__('Custom CSS', 'datis'), 'mode' => 'css', 'theme' => 'monokai', ], [ 'id' => 'custom_js', 'type' => 'ace_editor', 'title' => esc_html__('Custom JS', 'datis'), 'mode' => 'javascript', 'theme' => 'monokai', ], [ 'id' => 'head_code', 'type' => 'textarea', 'title' => esc_html__('Header Code', 'datis') ], ] ]); } public function output_custom_css() { $options = get_option($this->opt_name); if (!empty($options['custom_css'])) { echo '<style>' . $options['custom_css'] . '</style>'; } } public function output_custom_js() { $options = get_option($this->opt_name); if (!empty($options['custom_js'])) { echo '<script>' . $options['custom_js'] . '</script>'; } } public function output_head_code() { $options = get_option($this->opt_name); if (!empty($options['head_code'])) { echo $options['head_code']; } } public function admin_assets() { wp_enqueue_style('datis-admin', DATIS_URI . '/assets/css/admin.css', [], DATIS_VER); } public static function get_instance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; } } Datis_Theme_Options::get_instance(); }
💾 保存文件
← 返回文件管理器