Trailing slashes for course action end points

Home Forums Legacy Support Support queries How-to & Troubleshooting Trailing slashes for course action end points

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #372586
    Physiotutors
    Participant
    Hello we have added an NGINX rule to add trailing slashes to all urls:
    if ($request_uri !~ "^/wp-json") {
    rewrite ^([^.]*[^/])$ $1/ permanent;
    }
    However the course action end points still don't add the trailing slashes. Is there a separate template that is used for those pages? See: https://prnt.sc/1vtnkj3 Where would we have to look or what can we do so that trailing slashes are also added to those pages? Manually editing the permalinks with a trailing slash "/" has no effect.
    #372812
    Anshuman Sahu
    Keymaster
    Well this trailing slash does not creates any issue and are added from wordpress itself . We have added this deliberately in our code . to prevent this please try adding this given code in your wplms-customizer.php file in wplms customizer pluign :
     add_filter('wplms_save_vibe_course_permalinks',function ($permalinks){
      foreach ($permalinks as $key => $permalink) {
        $permalinks[$key] = str_replace('/', '', $permalink);
      }
      return $permalinks;
     },99);
    
    #372824
    Physiotutors
    Participant
    This reply has been marked as private.
    #372925
    Anshuman Sahu
    Keymaster
    Yes absolutely correct .
    #372967
    Physiotutors
    Participant
    Okay, thanks for having a look. If it's added all correctly then it's not taking effect as trailing slashes are still missing from the URLs.
    #373107
    Anshuman Sahu
    Keymaster
    Ok perhaps I did not understood the issue properly . Can you please explain do you wish to add the slash ? also please share exactly where you want to add or remove the slashes from url?
    #373111
    Physiotutors
    Participant
    So far trailing slashes are added to all URLs using an NGINX rule. However this rule cannot add trailing slashes to the URLs of the course action touch points seen here: https://prnt.sc/1vtnkj3 I assume these have to do with WPLMS theme. Here you can see the difference of pages that get the trailing slash added (e.g. forum): http://prnt.sc/1wqfpxn Here is how google chrome sees the course action touch point URLs where the trailing slash is missing from the "curriculum" slug: http://prnt.sc/1wqfrx5 I hope this explains it clearly. We would like to have trailing slashes added to the URL slugs of the course action touch point permalinks listed here: https://prnt.sc/1vtnkj3
    #373183
    Anshuman Sahu
    Keymaster
    In such case you can try adding the trailing slash in the permalinks settings itself : https://prnt.sc/1vtnkj3 We are building the urls using wordpress functions. The trailing slash is added when the curriculum page is opened however its just not showing in the html generated . Why exactly you need trailing slash for , is there any error its causing when trailing slash is missing ?
    #373249
    Physiotutors
    Participant
    Hello Alex adding the trailing slashes manually in the permalink settings does not work/has no effect as mentioned in the initial support post. Our marketeer has asked us if it was possible to add the trailing slashes here for SEO benefits and would need to be displayed in the html generated.
    #373365
    Anshuman Sahu
    Keymaster
    Please try this code :
    
    add_filter('wplms_save_vibe_course_permalinks',function ($permalinks){
      foreach ($permalinks as $key => $permalink) {
        if(in_array($key, array('curriculum_slug','activity_slug','members_slug','admin_slug','submissions_slug','stats_slug','news_slug'))){
            $permalinks[$key] = $permalink.'/';
        }
        
      }
      return $permalinks;
     },99);
    #373914
    Physiotutors
    Participant
    Hello Alex, Thanks for the new filter. however this also did not results in the desired outcome. see: http://prnt.sc/1y1h43f I can see in the URLs that works that there is an added "charset UTF-8". is that necessary to add the trailing slash in the html?
    #374046
    Anshuman Sahu
    Keymaster
    Well actually this can only be done by editing the core files on wplms. you need to add slash here : https://prnt.sc/1y9bw28 change this line echo '<li id="'.$menu_item['id'].'" '.$class.'><a href="'.$menu_item['link'].''.((isset($menu_item['action']) && !isset($menu_item['external']))?$menu_item['action']:'').'">'.$menu_item['label'].'</a></li>'; to this :
    
    echo '<li id="'.$menu_item['id'].'" '.$class.'><a href="'.$menu_item['link'].''.((isset($menu_item['action']) && !isset($menu_item['external']))?$menu_item['action']:'').'/">'.$menu_item['label'].'</a></li>';
    #374090
    Physiotutors
    Participant
    Thanks Alex, this works! We can close the thread
    #374143
    Veronica
    Moderator
    ok thanks for your confirmation
Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Trailing slashes for course action end points’ is closed to new replies.