Support » Plugin: Permalink Manager Lite » Probleme with Classified Listing

  • Resolved walid91

    (@walid91)


    Hi,

    I am having a problem with Permalink Manager Lite.
    I have Classified Listing – Classified ads & Business Directory Plugin.
    This plugin creates a second page named my-account-2-2/
    If the Permalink Manager Lite plugin is activated I have several permalink problems with the Classified Listing plugin.
    If the Permalink Manager Lite plugin is deactivated everything is back to normal.
    If you can help me.
    Thank you for your help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi @walid91,

    Unfortunately, Classified Listing plugin is not officially supported by Permalink Manager :/

    Could you provide me with more details on the issue & send me a full URL of login page? I will try to provide you with some solution, if any available.

    Thread Starter walid91

    (@walid91)

    Okay I understand why I have this problem.
    As I told you the Classified Listing plugin creates a my-account-2-2/ page.
    This page contains the shortcode: [rtcl_my_account]
    This page contains :

    Dashboard
    My Listings
    Account details
    Logout

    The problem is in the page account details with a 404 page and in the my listings to edit a product.

    https://souq-sarmada.com/my-account-2-2

    Plugin Author Maciej Bis

    (@mbis)

    Hi @walid91,

    I have checked the Classified Listing plugin using a simple configuration, so I cannot guarantee that the below snippet will work under every condition. Basically, the source of the problem here is that Classified Listing uses an additional set of rewrite rules for “My account” sections’ permalinks:

    /**
     * Classified Listing
     */
    function pm_rtcl_endpoints($query, $old_query, $uri_parts, $pm_query, $content_type) {
    	if(function_exists('rtcl')) {
    		$rtcl = rtcl();
    
    		if(!empty($pm_query['endpoint']) && !empty($pm_query['id'])) {
    			$rtcl_endpoint = $pm_query['endpoint'];
    		} else if(empty($pm_query['endpoint']) && is_numeric($pm_query['endpoint_value'])) {
    			$rtcl_endpoint = basename($pm_query['uri']);
    		} else {
    			return $query;
    		}
    
    		// Get RTCL query variables and endpoint names
    		$rtcl_query_vars = $rtcl->query->get_query_vars();
    		$query_var_name = array_search($rtcl_endpoint, $rtcl_query_vars);
    
    		// A. Change query variable name ("Edit account")
    		if(!empty($query_var_name) && $query_var_name == 'edit-account') {
    			unset($query[$rtcl_endpoint]);
    			unset($query['pagename']);
    
    			$query['rtcl_edit_account'] = $rtcl_endpoint;
    			$query['page_id'] = $pm_query['id'];
    		}
    		// B. Restore original query if 'rtcl_action' or pagination endpoint is detected
    		else if(empty($pm_query['id']) && !empty($old_query['rtcl_action'])) {
    			$query = $old_query;
    			$query['do_not_redirect'] = 1;
    		}
    		// C. Restore original query if pagination endpoint is detected
    		else if(!empty($old_query['paged']) && in_array($query_var_name, array('listings', 'favourites', 'payments'))) {
    			$query = $old_query;
    			$query['do_not_redirect'] = 1;
    		}
    	}
    
    	return $query;
    }
    add_filter('permalink_manager_filter_query', 'pm_rtcl_endpoints', 10, 5);
    Thread Starter walid91

    (@walid91)

    Hi,
    I am very grateful that you took the time to find a solution to my problem.
    I copied the php function into the snippets plugin.
    The “edit account” link works with your code.
    But the “edit product” function does not work.
    I don’t want to occupy you more than that with this problem.
    Thank you.

    Plugin Author Maciej Bis

    (@mbis)

    Hi @walid91,

    Could you add “?debug_url=1” parameter to a sample “Edit product” link and send me the screenshot of the debug data displayed there?

    Best regards,
    Maciej

    Thread Starter walid91

    (@walid91)

    Hi,

    I did as you asked.
    Here is the result:

    Array
    (
    [uri_parts] => Array
    (
    [lang] =>
    [uri] => listing-form
    [endpoint] => edit
    [endpoint_value] => 6799
    )

    [old_query_vars] => Array
    (
    [page_id] => 4991
    [rtcl_listing_id] => 6799
    [rtcl_action] => edit
    )

    [new_query_vars] => Array
    (
    [pagename] => classified-ads/listing-form
    [edit] => 6799
    [do_not_redirect] => 1
    )

    [pm_query] => 4991
    [content_type] => Post type: page
    [version] => 2.2.19.1
    )

    • This reply was modified 1 month, 1 week ago by walid91.
    Plugin Author Maciej Bis

    (@mbis)

    Hi @walid91,

    Could you check if the below version of snippet works with all the sections?

    /**
     * Classified Listing
     */
    function pm_rtcl_endpoints($query, $old_query, $uri_parts, $pm_query, $content_type) {
    	if(function_exists('rtcl')) {
    		$rtcl = rtcl();
    
    		if(!empty($pm_query['endpoint']) && !empty($pm_query['id'])) {
    			$rtcl_endpoint = $pm_query['endpoint'];
    		} else if(empty($pm_query['endpoint']) && is_numeric($pm_query['endpoint_value'])) {
    			$rtcl_endpoint = basename($pm_query['uri']);
    		} else {
    			return $query;
    		}
    
    		// Get RTCL query variables and endpoint names
    		$rtcl_query_vars = $rtcl->query->get_query_vars();
    		$query_var_name = array_search($rtcl_endpoint, $rtcl_query_vars);
    
    		// A. Change query variable name ("Edit account")
    		if(!empty($query_var_name) && $query_var_name == 'edit-account') {
    			unset($query[$rtcl_endpoint]);
    			unset($query['pagename']);
    
    			$query['rtcl_edit_account'] = $rtcl_endpoint;
    			$query['page_id'] = $pm_query['id'];
    		}
    		// B. Restore original query if 'rtcl_action' is detected
    		else if(!empty($old_query['rtcl_action'])) {
    			$query = $old_query;
    			$query['do_not_redirect'] = 1;
    		}
    		// C. Restore original query if pagination endpoint is detected
    		else if(!empty($old_query['paged']) && in_array($query_var_name, array('listings', 'favourites', 'payments'))) {
    			$query = $old_query;
    			$query['do_not_redirect'] = 1;
    		}
    	}
    
    	return $query;
    }
    add_filter('permalink_manager_filter_query', 'pm_rtcl_endpoints', 10, 5);
    Thread Starter walid91

    (@walid91)

    Hi,

    Sorry for the delay, I was a bit busy.
    I did some tests with a staging site and everything seems to work fine.
    I think we can put this topic in resolved.
    Thank you for taking your time.

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