valid_nonce() ) { $marker = new WPSEO_GSC_Marker( filter_input( INPUT_POST, 'url' ) ); wp_die( $marker->get_response() ); } wp_die( 'false' ); } /** * Handling the request to create a new redirect from the issued URL */ public function ajax_create_redirect() { if ( $this->valid_nonce() && class_exists( 'WPSEO_Redirect_Manager' ) && defined( 'WPSEO_PREMIUM_PATH' ) ) { $redirect_manager = new WPSEO_Redirect_Manager(); $old_url = filter_input( INPUT_POST, 'old_url' ); // Creates the redirect. $redirect = new WPSEO_Redirect( $old_url, filter_input( INPUT_POST, 'new_url' ), filter_input( INPUT_POST, 'type' ) ); if ( $redirect_manager->create_redirect( $redirect ) ) { if ( filter_input( INPUT_POST, 'mark_as_fixed' ) === 'true' ) { new WPSEO_GSC_Marker( $old_url ); } wp_die( 'true' ); } } wp_die( 'false' ); } /** * Handle the AJAX request and dismiss the GSC notice */ public function dismiss_notice() { check_ajax_referer( 'dismiss-gsc-notice' ); update_user_meta( get_current_user_id(), 'wpseo_dismissed_gsc_notice', true ); wp_die( 'true' ); } /** * Check if posted nonce is valid and return true if it is * * @return mixed */ private function valid_nonce() { return wp_verify_nonce( filter_input( INPUT_POST, 'ajax_nonce' ), 'wpseo-gsc-ajax-security' ); } }