Файловый менеджер - Редактировать - /home/avadvi5/public_html/wp-content/themes/code4rest/inc/dashboard/class-theme-dashboard.php
Ðазад
<?php /** * Build Welcome Page with settings. * * @package Code4rest */ if (! defined('ABSPATH')) { exit; } /** * Build Welcome Page class * * @category class */ class Code4rest_Dashboard_Settings { /** * Settings of this class * * @var array */ public static $settings = array(); /** * Instance of this class * * @var null */ private static $instance = null; /** * Static var active plugins * * @var $active_plugins */ private static $active_plugins; /** * Instance Control */ public static function get_instance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; } /** * Class Constructor. */ public function __construct() { // only load if admin. if (is_admin()) { add_action('admin_menu', array( $this, 'add_menu' )); } 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(__('Code4rest - Next Generation Theme', 'code4rest'), __('Code4rest', 'code4rest'), apply_filters('code4rest_admin_settings_capability', 'manage_options'), 'code4rest', array( $this, 'config_page' )); add_action('admin_print_styles-' . $page, array( $this, 'scripts' )); do_action('code4rest_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 Code4rest Starter Templates', 'code4rest'); $data_action = ''; if (! defined('CODE4REST_STARTER_TEMPLATES_VERSION')) { if (! isset($installed_plugins['code4rest-starter-templates/code4rest-starter-templates.php'])) { $button_label = esc_html__('Install Code4rest Starter Templates', 'code4rest'); $data_action = 'install'; } elseif (! self::active_plugin_check('code4rest-starter-templates/code4rest-starter-templates.php')) { $button_label = esc_html__('Activate Code4rest Starter Templates', 'code4rest'); $data_action = 'activate'; } } wp_enqueue_style('code4rest-dashboard', get_template_directory_uri() . '/inc/dashboard/react/dash-controls.min.css', array( 'wp-components' ), CODE4REST_VERSION); wp_enqueue_script('code4rest-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' ), CODE4REST_VERSION, true); wp_localize_script( 'code4rest-dashboard', 'code4restDashboardParams', array( 'adminURL' => esc_url(admin_url()), 'settings' => esc_attr(get_option('code4rest_theme_config')), 'changelog' => $this->get_changelog(), 'proChangelog' => (class_exists('Code4rest_Theme_Pro') ? $this->get_pro_changelog() : ''), 'starterTemplates' => (defined('CODE4REST_STARTER_TEMPLATES_VERSION') ? true : false), 'ajax_url' => admin_url('admin-ajax.php'), 'ajax_nonce' => wp_create_nonce('code4rest-ajax-verification'), 'status' => $data_action, 'starterLabel' => $button_label, 'starterImage' => esc_attr(get_template_directory_uri() . '/assets/images/starter-templates-banner.jpeg'), 'starterURL' => esc_url(admin_url('themes.php?page=code4rest-starter-templates')), 'videoImage' => esc_attr(get_template_directory_uri() . '/assets/images/getting-started-video.jpg'), ) ); if (function_exists('wp_set_script_translations')) { wp_set_script_translations('code4rest-dashboard', 'code4rest'); } } /** * 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( 'code4rest_theme_config', 'code4rest_theme_config', array( 'type' => 'string', 'description' => __('Config Code4rest Modules', 'code4rest'), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ) ); } /** * Loads config page */ public function config_page() { ?> <div class="code4rest_theme_dash_head"> <div class="code4rest_theme_dash_head_container"> <div class="code4rest_theme_dash_version"> <span> <?php echo esc_html(CODE4REST_VERSION); ?> </span> </div> </div> </div> <div class="wrap code4rest_theme_dash"> <div class="code4rest_theme_dashboard"> <h2 class="notices" style="display:none;"></h2> <?php settings_errors(); ?> <div class="page-grid"> <div class="code4rest_theme_dashboard_main"> </div> </div> </div> </div> <?php } } Code4rest_Dashboard_Settings::get_instance();
| ver. 1.1 | |
.
| PHP 8.3.30 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка