Example #1
0
 /**
  * Add the Edit Author Slug rewrite tags
  *
  * @since 1.0.0
  *
  * @return void
  */
 public function add_rewrite_tags()
 {
     // Should we be here?
     if (!ba_eas_do_role_based_author_base()) {
         return;
     }
     // Get the role slugs to add the rewrite tag.
     $role_slugs = wp_list_pluck($this->role_slugs, 'slug');
     $role_slugs = array_filter(array_values($role_slugs));
     // Add the author base as a fallback.
     $role_slugs[] = ba_eas()->author_base;
     // Add the role-based rewrite tag, and the expected role slugs.
     add_rewrite_tag('%ba_eas_author_role%', '(' . implode('|', array_unique($role_slugs)) . ')');
 }
function ba_eas_author_rewrite_rules($author_rewrite_rules)
{
    if (ba_eas_do_role_based_author_base()) {
        // Filter out the rules without the author_name parameter
        // We don't need them
        foreach ($author_rewrite_rules as $rule => $query) {
            if (false === strpos($query, 'author_name')) {
                unset($author_rewrite_rules[$rule]);
            }
        }
    }
    return $author_rewrite_rules;
}