add_category_color(); } add_action( 'init', array( $this, 'load_api_settings' ) ); } /** * Redirect to the settings page on activation. * * @param string $key setting key. */ public static function get_data_options( $key ) { if ( ! isset( self::$settings[ $key ] ) ) { self::$settings[ $key ] = get_option( $key, array() ); } return self::$settings[ $key ]; } /** * Add option page menu */ public function add_menu() { $page = add_theme_page( __( 'Kadence - Next Generation Theme', 'kadence' ), __( 'Kadence', 'kadence' ), apply_filters( 'kadence_admin_settings_capability', 'manage_options' ), 'kadence', array( $this, 'config_page' ) ); add_action( 'admin_print_styles-' . $page, array( $this, 'scripts' ) ); do_action( 'kadence_theme_admin_menu' ); } /** * Initialize getting the active plugins list. */ public static function get_active_plugins() { self::$active_plugins = (array) get_option( 'active_plugins', array() ); if ( is_multisite() ) { self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); } } /** * Active Plugin Check * * @param string $plugin_base_name is plugin folder/filename.php. */ public static function active_plugin_check( $plugin_base_name ) { if ( ! self::$active_plugins ) { self::get_active_plugins(); } return in_array( $plugin_base_name, self::$active_plugins, true ) || array_key_exists( $plugin_base_name, self::$active_plugins ); } /** * Loads admin style sheets and scripts */ public function scripts() { $installed_plugins = get_plugins(); $button_label = esc_html__( 'Browse Kadence Starter Templates', 'kadence' ); $data_action = ''; if ( ! defined( 'KADENCE_STARTER_TEMPLATES_VERSION' ) ) { if ( ! isset( $installed_plugins['kadence-starter-templates/kadence-starter-templates.php'] ) ) { $button_label = esc_html__( 'Install Kadence Starter Templates', 'kadence' ); $data_action = 'install'; } elseif ( ! self::active_plugin_check( 'kadence-starter-templates/kadence-starter-templates.php' ) ) { $button_label = esc_html__( 'Activate Kadence Starter Templates', 'kadence' ); $data_action = 'activate'; } } wp_enqueue_style( 'kadence-dashboard', get_template_directory_uri() . '/inc/dashboard/react/dash-controls.min.css', array( 'wp-components' ), KADENCE_VERSION ); wp_enqueue_script( 'kadence-dashboard', get_template_directory_uri() . '/assets/js/admin/dashboard.js', array( 'wp-i18n', 'wp-element', 'wp-plugins', 'wp-components', 'wp-api', 'wp-hooks', 'wp-edit-post', 'lodash', 'wp-block-library', 'wp-block-editor', 'wp-editor', 'jquery' ), KADENCE_VERSION, true ); wp_localize_script( 'kadence-dashboard', 'kadenceDashboardParams', array( 'adminURL' => esc_url( admin_url() ), 'settings' => esc_attr( get_option( 'kadence_theme_config' ) ), 'changelog' => $this->get_changelog(), 'proChangelog' => ( class_exists( 'Kadence_Theme_Pro' ) ? $this->get_pro_changelog() : '' ), 'starterTemplates' => ( defined( 'KADENCE_STARTER_TEMPLATES_VERSION' ) ? true : false ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_nonce' => wp_create_nonce( 'kadence-ajax-verification' ), 'proURL' => esc_url( \Kadence\kadence()->get_pro_url( 'https://www.kadencewp.com/kadence-theme/premium/', 'https://www.kadencewp.com/kadence-theme/premium/', 'in-app', 'theme-dash' ) ), 'status' => $data_action, 'starterLabel' => $button_label, 'starterImage' => esc_attr( get_template_directory_uri() . '/assets/images/starter-templates-banner.jpeg' ), 'starterURL' => $this->get_starter_templates_link(), 'videoImage' => esc_attr( get_template_directory_uri() . '/assets/images/getting-started-video.jpg' ), ) ); if ( function_exists( 'wp_set_script_translations' ) ) { wp_set_script_translations( 'kadence-dashboard', 'kadence' ); } } /** * Get Starter Templates Link */ public function get_starter_templates_link() { $config = get_option( 'kadence_starter_templates_config', '' ); $use_site_assist = apply_filters( 'kadence_starter_site_assist_enabled', true ); if ( ! empty( $config ) ) { $config = json_decode( $config, true ); if ( isset( $config['siteAssist'] ) && 'disable' === $config['siteAssist'] ) { $use_site_assist = false; } } if ( $use_site_assist || class_exists( '\\KadenceWP\\KadenceBlocks\\StellarWP\\Uplink\\Register' ) ) { return admin_url( 'admin.php?page=kadence-starter-templates' ); } return admin_url( 'themes.php?page=kadence-starter-templates' ); } /** * Get Changelog ( Largely Borrowed From Neve Theme ) */ public function get_changelog() { $changelog = array(); $changelog_path = get_template_directory() . '/changelog.txt'; if ( ! is_file( $changelog_path ) ) { return $changelog; } global $wp_filesystem; if ( ! is_object( $wp_filesystem ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } $changelog_string = $wp_filesystem->get_contents( $changelog_path ); if ( is_wp_error( $changelog_string ) ) { return $changelog; } $changelog = explode( PHP_EOL, $changelog_string ); $releases = []; foreach ( $changelog as $changelog_line ) { if ( empty( $changelog_line ) ) { continue; } if ( substr( ltrim( $changelog_line ), 0, 2 ) === '==' ) { if ( isset( $release ) ) { $releases[] = $release; } $changelog_line = trim( str_replace( '=', '', $changelog_line ) ); $release = array( 'head' => $changelog_line, ); } else { if ( preg_match( '/[*|-]?\s?(\[fix]|\[Fix]|fix|Fix)[:]?\s?\b/', $changelog_line ) ) { //$changelog_line = preg_replace( '/[*|-]?\s?(\[fix]|\[Fix]|fix|Fix)[:]?\s?\b/', '', $changelog_line ); $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['fix'][] = $changelog_line; continue; } if ( preg_match( '/[*|-]?\s?(\[add]|\[Add]|add|Add)[:]?\s?\b/', $changelog_line ) ) { //$changelog_line = preg_replace( '/[*|-]?\s?(\[add]|\[Add]|add|Add)[:]?\s?\b/', '', $changelog_line ); $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['add'][] = $changelog_line; continue; } $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['update'][] = $changelog_line; } } return $releases; } /** * Get Changelog ( Largely Borrowed From Neve Theme ) */ public function get_pro_changelog() { $changelog = array(); if ( ! defined( 'KTP_PATH' ) ) { return $changelog; } $changelog_path = KTP_PATH . '/changelog.txt'; if ( ! is_file( $changelog_path ) ) { return $changelog; } global $wp_filesystem; if ( ! is_object( $wp_filesystem ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } $changelog_string = $wp_filesystem->get_contents( $changelog_path ); if ( is_wp_error( $changelog_string ) ) { return $changelog; } $changelog = explode( PHP_EOL, $changelog_string ); $releases = []; foreach ( $changelog as $changelog_line ) { if ( empty( $changelog_line ) ) { continue; } if ( substr( ltrim( $changelog_line ), 0, 2 ) === '==' ) { if ( isset( $release ) ) { $releases[] = $release; } $changelog_line = trim( str_replace( '=', '', $changelog_line ) ); $release = array( 'head' => $changelog_line, ); } else { if ( preg_match( '/[*|-]?\s?(\[fix]|\[Fix]|fix|Fix)[:]?\s?\b/', $changelog_line ) ) { //$changelog_line = preg_replace( '/[*|-]?\s?(\[fix]|\[Fix]|fix|Fix)[:]?\s?\b/', '', $changelog_line ); $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['fix'][] = $changelog_line; continue; } if ( preg_match( '/[*|-]?\s?(\[add]|\[Add]|add|Add)[:]?\s?\b/', $changelog_line ) ) { //$changelog_line = preg_replace( '/[*|-]?\s?(\[add]|\[Add]|add|Add)[:]?\s?\b/', '', $changelog_line ); $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['add'][] = $changelog_line; continue; } $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['update'][] = $changelog_line; } } return $releases; } /** * Register settings */ public function load_api_settings() { register_setting( 'kadence_theme_config', 'kadence_theme_config', array( 'type' => 'string', 'description' => __( 'Config Kadence Modules', 'kadence' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ) ); } /** * Loads config page */ public function config_page() { ?>

term_id, 'archive_category_color', true); // Get the current color value ?>

term_id, 'archive_category_hover_color', true); // Get the current hover color value ?>