Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter gonza.ar

    (@gonzaar)

    Hi,

    Here is an example:
    We have 40 groups with 30 rules each.
    In the last group (Z) we have the following rule in the position 20 :

    “^(?i)test(.*)/?$” “/” [R=301,L]

    we have in the second group (B) the following rule in the position 30:

    “^testguest/?$” “https://test.com/test” [R=301,L]

    For the plugin, the rule of the group Z will be first because was created first, but we don’t want that. Of course I can just change the position of the rule in the second group to 19, and then the plugin will take the rule of the group B first.
    The problem is that we have 1200 rules, and every day we add and remove rules, will be hard to follow the position of the rules.

    For this reason I think that having orders in the groups, in addition to the orders of the rules within the groups, would be a great functionality.

    Regards

    • This reply was modified 4 years, 4 months ago by gonza.ar.
    • This reply was modified 4 years, 4 months ago by gonza.ar.
    • This reply was modified 4 years, 4 months ago by gonza.ar.
    Thread Starter gonza.ar

    (@gonzaar)

    John,

    The responose of the function “get_for_matched_url”
    I would like to know if there is a hook after the function that does that query to organize the response of possible all redirects that match the URL.

    Regards

    Thread Starter gonza.ar

    (@gonzaar)

    Hi John,

    Thanks for the reply, yes, we have complex rules and these rules follow priorities.
    Is there a hook that allows me to alter the response ?

    Regards

    Thread Starter gonza.ar

    (@gonzaar)

    Hi John,

    The problem is that it is difficult to follow the position of the rules when we have a lot. For example. we have 45 groups and 40 rules in each one. If we need to add a rule that needs to be validated before another rule, it will be difficult to find the position of the rules with similar matches, and it will also be difficult to reposition them.

    is there any way that the plugin solves it in another way?
    REgards

    Thread Starter gonza.ar

    (@gonzaar)

    	public static function get_for_matched_url( $url ) {
    		global $wpdb;
    
    		$url = new Red_Url_Match( $url );
    		$sql = "SELECT {$wpdb->prefix}redirection_items.*, {$wpdb->prefix}redirection_groups.position
                    FROM {$wpdb->prefix}redirection_items
                    JOIN {$wpdb->prefix}redirection_groups ON {$wpdb->prefix}redirection_items.group_id = {$wpdb->prefix}redirection_groups.id
                    WHERE match_url=%s OR match_url='regex'
                    ORDER BY {$wpdb->prefix}redirection_groups.position asc";
    		
    		$rows = $wpdb->get_results( $wpdb->prepare( $sql, $url->get_url() ) );
    
    		$items = array();
    		if ( count( $rows ) > 0 ) {
    			foreach ( $rows as $row ) {
    				$items[] = new Red_Item( $row );
    			}
    		}
    
    		usort( $items, array( 'Red_Item', 'sort_urls' ) );
    
    		return $items;
    	}
    Thread Starter gonza.ar

    (@gonzaar)

    Hi!

    There is a position column in the wp_redirection_groups table, but it is not queried at request time for all matching URLs.

    with just adding a joing and order by that position wil order all the rules following the groups order.
    I mean:
    file: plugins/redirection/models/redirect/redirect.php
    function: get_for_matched_url

    change:

    SELECT * FROM {$wpdb->prefix}redirection_items WHERE match_url=%s OR match_url='regex'

    to

    SELECT {$wpdb->prefix}redirection_items.*, {$wpdb->prefix}redirection_groups.position FROM {$wpdb->prefix}redirection_items 
    JOIN {$wpdb->prefix}redirection_groups ON {$wpdb->prefix}redirection_items.group_id = {$wpdb->prefix}redirection_groups.id
    WHERE match_url=%s OR match_url='regex'
    ORDER BY {$wpdb->prefix}redirection_groups.position asc
    • This reply was modified 4 years, 4 months ago by gonza.ar.
    Thread Starter gonza.ar

    (@gonzaar)

    Note: I have a pagination of 25 items

    • This reply was modified 4 years, 4 months ago by gonza.ar.
    Thread Starter gonza.ar

    (@gonzaar)

    John,

    yes you′re right.
    Thank you very much for your help!

    Hi!

    This version has many bugs fixed. What are the plans to update the version that comes with the core?

    Regards

    Thread Starter gonza.ar

    (@gonzaar)

    Hi!

    Yes, I saw the errors in the developer console of the browser, but I can’t reproduce it again. I’m going to reply if happens again with a screenshot.

    Regards

    • This reply was modified 6 years, 1 month ago by gonza.ar.

    Any updates on this? is not working

    Hi ggwicz!

    I followed all the steps and is not working.

    The function enqueue_map_scripts is never called

Viewing 12 replies - 1 through 12 (of 12 total)