芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/ithemes-security-pro/core/admin-pages/init.php
' . __( 'Get More Security', 'it-l10n-ithemes-security-pro' ) . '', $capability, 'itsec-go-pro', array( $this, 'show_page' ) ); } if ( defined( 'ITSEC_DEBUG' ) && ITSEC_DEBUG ) { $page_refs[] = add_submenu_page( $parent, __( 'Solid Security Debug', 'it-l10n-ithemes-security-pro' ), __( 'Debug', 'it-l10n-ithemes-security-pro' ), $capability, 'itsec-debug', array( $this, 'show_page' ) ); } foreach ( $page_refs as $page_ref ) { add_action( "load-$page_ref", array( $this, 'load' ) ); add_action( "admin_print_scripts-$page_ref", array( $this, 'enqueue' ), 0 ); } } private function get_page_id() { global $plugin_page; if ( isset( $this->page_id ) ) { return $this->page_id; } if ( wp_doing_ajax() ) { if ( isset( $_REQUEST['action'] ) && preg_match( '/^itsec_(.+)_page$/', $_REQUEST['action'], $match ) ) { $this->page_id = $match[1]; } } elseif ( strpos( $plugin_page, 'itsec-' ) === 0 ) { $this->page_id = substr( $plugin_page, 6 ); } elseif ( strpos( $plugin_page, 'itsec' ) === 0 ) { $this->page_id = 'settings'; } if ( ! isset( $this->page_id ) ) { $this->page_id = ''; } return $this->page_id; } public function load() { $this->load_file( 'page-%s.php' ); } public function enqueue() { foreach ( ITSEC_Modules::get_available_modules() as $module ) { $handle = "itsec-{$module}-global"; if ( wp_script_is( $handle, 'registered' ) ) { wp_enqueue_script( $handle ); } if ( wp_style_is( $handle, 'registered' ) ) { wp_enqueue_style( $handle ); } } ITSEC_Lib::preload_request_for_data_store( 'ithemes-security/core', 'receiveIndex', '/ithemes-security/v1', [ 'context' => 'help' ] ); ITSEC_Lib::preload_request_for_data_store( 'ithemes-security/modules', 'receiveModules', '/ithemes-security/v1/modules', [ 'context' => 'edit', '_embed' => 1 ] ); } public function show_page() { $page_id = $this->get_page_id(); if ( 'settings' === $page_id ) { $url = network_admin_url( 'admin.php?page=itsec' ); } else { $url = network_admin_url( 'admin.php?page=itsec-' . $this->get_page_id() ); } do_action( 'itsec-page-show', $url ); } public function handle_ajax_request() { $this->load_file( 'page-%s.php' ); do_action( 'itsec-page-ajax' ); } /** * Render the profile fields for managing user security. * * @param WP_User $user */ public function render_profile_fields( $user ) { ?>
set_query_params( [ 'context' => 'edit' ] ); $response = rest_do_request( $request ); if ( ! $response->is_error() ) { wp_add_inline_script( 'itsec-pages-profile', sprintf( "wp.data.dispatch('%s').receiveCurrentUserId( %d );", 'ithemes-security/core', $response->get_data()['id'] ) ); wp_add_inline_script( 'itsec-pages-profile', sprintf( "wp.data.dispatch('%s').receiveUser( %s );", 'ithemes-security/core', wp_json_encode( rest_get_server()->response_to_data( $response, false ) ) ) ); } foreach ( ITSEC_Modules::get_active_modules_to_run() as $module ) { $handle = "itsec-{$module}-profile"; if ( wp_script_is( $handle, 'registered' ) ) { wp_enqueue_script( $handle ); } if ( wp_style_is( $handle, 'registered' ) ) { wp_enqueue_style( $handle ); } } /** * Fires when scripts are enqueued for the User Profile JS code. * * @param WP_User $user */ do_action( 'itsec_enqueue_profile', $user ); } private function load_file( $file ) { $id = $this->get_page_id(); if ( empty( $id ) ) { if ( isset( $GLOBALS['pagenow'], $_GET['page'] ) && 'admin.php' === $GLOBALS['pagenow'] && strpos( $_GET['page'], 'itsec-' ) === 0 ) { $id = substr( $_GET['page'], 6 ); } else { return; } } $id = str_replace( '_', '-', $id ); $file = __DIR__ . '/' . sprintf( $file, $id ); $file = apply_filters( "itsec-admin-page-file-path-$id", $file ); if ( is_file( $file ) ) { require_once( $file ); } } public function handle_user_setting() { if ( 'itsec-settings-view' !== $_REQUEST['setting'] ) { wp_send_json_error(); } $_REQUEST['setting'] = sanitize_title_with_dashes( $_REQUEST['setting'] ); if ( ! wp_verify_nonce( $_REQUEST['itsec-user-setting-nonce'], 'set-user-setting-' . $_REQUEST['setting'] ) ) { wp_send_json_error(); } if ( ! apply_filters( 'itsec-user-setting-valid-' . $_REQUEST['setting'], true, $_REQUEST['value'] ) ) { wp_send_json_error(); } if ( false === update_user_meta( get_current_user_id(), $_REQUEST['setting'], $_REQUEST['value'] ) ) { wp_send_json_error(); } wp_send_json_success(); } public function validate_view( $valid, $view ) { return in_array( $view, array( 'grid', 'list' ) ); } } new ITSEC_Admin_Page_Loader();