Support » Plugin: Permalink Manager Lite » Is there any issue while remove the ‘p’ parameter from the url

  • Resolved Sakthivel Kanagaraj

    (@saravanankanagaraj)


    I have used the below code to remove the ‘p’ parameter from the URL. Is this causing any issue on admin or user view?
    I have faced an issue while previewing the post now I have added the condition to not apply for admin view only. Can you please confirm, is causes any other issues?

    /* To remove the parameter from the url */
    function remove_params_for_os_command_injection() {
    	if ( isset( $_SERVER ) && isset( $_GET ) && isset( $_SERVER['REQUEST_URI'] ) && !is_admin() ) {		
    		$get_all_params = $_GET;
    		$new_url_params = '';
    		$params_removed = false;
    		foreach ( $get_all_params as $key => $value ) {
    			if ( $key !== 'p' && $key !== 'ver' ) {
    				if ( empty( $new_url_params ) ) {
    					$new_url_params = $key . '=' . esc_html( $value );
    				} else {
    					$new_url_params .= '&' . $key . '=' . esc_html( $value );
    				} 
    			} else {
    				$params_removed = true;
    			}
    		}
    		if ( $params_removed ) {
    			$current_uri  = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
              if(empty( $new_url_params )){
              $new_url_path = $current_uri;
              } else {
              $new_url_path = $current_uri . '?' . $new_url_params;
              }
    			nocache_headers();
    			wp_safe_redirect( $new_url_path );
    			exit();		
    		}
    	}
    }
    add_action( 'init', remove_params_for_os_command_injection );

    Thanks,
    Saravanan

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.