plugin = $plugin; } /** * Registers hooks. */ public function register() { add_action( 'admin_menu', array( $this, 'menu' ), 16 ); add_action( 'admin_post_' . self::ACTION, array( $this, 'handle' ) ); } /** * Adds the submenu page. */ public function menu() { add_submenu_page( Admin::SLUG, __( 'Repair', 'orbitstem-seo' ), __( 'Repair', 'orbitstem-seo' ), Admin::capability(), self::SLUG, array( $this, 'render' ) ); } /** * Handles apply and rollback. */ public function handle() { if ( ! current_user_can( Admin::capability() ) ) { wp_die( esc_html__( 'You do not have permission to do this.', 'orbitstem-seo' ), 403 ); } check_admin_referer( self::ACTION ); $task = isset( $_POST['task'] ) ? sanitize_key( wp_unslash( $_POST['task'] ) ) : ''; $args = array( 'page' => self::SLUG ); if ( 'apply' === $task ) { $fixer = isset( $_POST['fixer'] ) ? sanitize_key( wp_unslash( $_POST['fixer'] ) ) : ''; $keys = isset( $_POST['keys'] ) && is_array( $_POST['keys'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['keys'] ) ) : array(); $results = $this->plugin->repair->apply( $fixer, $keys, ! empty( $_POST['confirm'] ) ); if ( is_wp_error( $results ) ) { RedirectsPage::notice( 'error', $results->get_error_message() ); $args['fixer'] = $fixer; } elseif ( ! $results ) { RedirectsPage::notice( 'error', __( 'Select at least one item.', 'orbitstem-seo' ) ); $args['fixer'] = $fixer; } else { set_transient( 'orbitstem_seo_repair_results_' . get_current_user_id(), $results, 10 * MINUTE_IN_SECONDS ); $args['results'] = 1; } } elseif ( 'rollback' === $task ) { $result = $this->plugin->repair->rollback( isset( $_POST['change'] ) ? absint( $_POST['change'] ) : 0 ); RedirectsPage::notice( is_wp_error( $result ) ? 'error' : 'success', is_wp_error( $result ) ? $result->get_error_message() : __( 'Change rolled back.', 'orbitstem-seo' ) ); $args['tab'] = 'history'; } wp_safe_redirect( add_query_arg( $args, admin_url( 'admin.php' ) ) ); exit; } /** * Renders the page. */ public function render() { if ( ! current_user_can( Admin::capability() ) ) { wp_die( esc_html__( 'You do not have permission to view this page.', 'orbitstem-seo' ) ); } // phpcs:disable WordPress.Security.NonceVerification.Recommended -- view state only. $tab = isset( $_GET['tab'] ) && 'history' === $_GET['tab'] ? 'history' : 'repairs'; $preview = isset( $_GET['fixer'] ) ? sanitize_key( wp_unslash( $_GET['fixer'] ) ) : ''; $results = ! empty( $_GET['results'] ); // phpcs:enable Ui::open( self::SLUG, __( 'Repair Center', 'orbitstem-seo' ), __( 'Preview each repair, apply it, and roll it back from History if needed.', 'orbitstem-seo' ) ); ?> render_results(); } if ( 'history' === $tab ) { $this->render_history(); } elseif ( '' !== $preview && isset( $this->plugin->repair->repair_fixers()[ $preview ] ) ) { $this->render_preview( $preview ); } else { $this->render_repairs(); } Ui::close(); } /** * Overview of available repairs. */ private function render_repairs() { ?>
label(); } /* translators: %s: list of repairs */ echo esc_html( sprintf( __( 'On after each scan: %s.', 'orbitstem-seo' ), implode( ', ', $names ) ) ); $user = get_userdata( $autopilot->run_user() ); if ( $user ) { echo ' '; /* translators: %s: user display name */ echo esc_html( sprintf( __( 'Changes are made as %s.', 'orbitstem-seo' ), $user->display_name ) ); } ?>
description() ); ?>
plugin->settings->get( 'change_retention_days' ) ) ); ?>
| display_name : '—' ); ?> |
label() : $row['fixer'] ); ?> |
' . esc_html( $row['verify_note'] ) . ''; } ?> | — | |