Is there a log for the ajax calls made when changing a post’s slug?

When changing the slug for a page (clicking OK) an ajax call is made to check if the slug is available and to generate a different one if not. Does anyone know if there is any logging for this, or any way to investigate what’s happening? Even knowing where the source is for this process would be helpful.

I’m experiencing a very strange behaviour whereby the slug of pages is changing to that of a post in a different post type but only when the slug isn’t being changed. It’s as if it’s determined that the slug is a duplicate of itself.

Not sure how to investigate this behaviour, any pokes in the right direction appreciated!

2 Answers
2

If we trace the Ajax process after you click OK, we would walk the following path from the core and into the database:

Press OK on Edit slug:
 \
  \-> AJAX POST request with action=sample-permalink  Action:  wp_ajax_sample-permalink
     \
      \-> function: wp_ajax_sample_permalink()
         \
          \-> function: get_sample_permalink_html()   Filter:  get_sample_permalink_html
             \
              \-> function: get_sample_permalink()    Filters: get_sample_permalink, editable_slug
                 \
                  \-> function: wp_unique_post_slug() Filter:  wp_unique_post_slug
                     \
                      \-> db call: $wpdb->get_var() 

So you could hook into some of those filters to check/log what’s happening to your slug generation. You could for example wrap your logging part within the wp_ajax_sample-permalink action:

add_action( 'wp_ajax_sample-permalink', function()
{
    add_filter( 'somefilter', function( $var )
    {
        // --> your EARLY logging part here <---

        return $var;
    }, 0 ); 

    add_filter( 'somefilter', function( $var )
    {
        // --> your LATE logging part here <---

        return $var;
    }, PHP_INT_MAX ); 
} );

where you can adjust the somefilter to your needs.

Leave a Comment