/**
  * Rewrite rules
  * @return array
  */
 public function rewrites()
 {
     global $wp_rewrite;
     global $ap_rules;
     unset($wp_rewrite->extra_permastructs['question']);
     unset($wp_rewrite->extra_permastructs['answer']);
     $base_page_id = ap_opt('base_page');
     $slug = ap_base_page_slug() . '/';
     $question_slug = ap_opt('question_page_slug');
     $user_page = ap_opt('base_before_user_perma') ? $slug . 'user/' : ap_opt('user_page_slug') . '/';
     $new_rules = array($slug . "parent/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&parent=" . $wp_rewrite->preg_index(1), $slug . "category/([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&ap_page=category&q_cat=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2), $slug . "tag/([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&ap_page=tag&q_tag=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2), $slug . "category/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=category&q_cat=" . $wp_rewrite->preg_index(1), $slug . "tag/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=tag&q_tag=" . $wp_rewrite->preg_index(1), $slug . "page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&paged=" . $wp_rewrite->preg_index(1), $slug . "([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&ap_page=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2));
     if (!ap_opt('question_permalink_follow')) {
         $new_rules[$question_slug . "/([^/]+)/page/?([0-9]{1,})/?\$"] = "index.php?page_id=" . $base_page_id . "&question_name=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2);
         $new_rules[$question_slug . "/([^/]+)/?\$"] = "index.php?page_id=" . $base_page_id . "&question_name=" . $wp_rewrite->preg_index(1);
     } else {
         $new_rules[$slug . $question_slug . "/([^/]+)/page/?([0-9]{1,})/?\$"] = "index.php?page_id=" . $base_page_id . "&question_name=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2);
         $new_rules[$slug . $question_slug . "/([^/]+)/?\$"] = "index.php?page_id=" . $base_page_id . "&question_name=" . $wp_rewrite->preg_index(1);
     }
     $new_rules[$slug . $question_slug . "/([^/]+)/([^/]+)/?\$"] = "index.php?page_id=" . $base_page_id . "&question_id=" . $wp_rewrite->preg_index(1) . "&question_name=" . $wp_rewrite->preg_index(2);
     $new_rules[$user_page . "([^/]+)/([^/]+)/page/?([0-9]{1,})/?\$"] = "index.php?page_id=" . $base_page_id . "&ap_page=user&ap_user="******"&user_page=" . $wp_rewrite->preg_index(2) . "&paged=" . $wp_rewrite->preg_index(3);
     $new_rules[$user_page . "([^/]+)/([^/]+)/?"] = "index.php?page_id=" . $base_page_id . "&ap_page=user&ap_user="******"&user_page=" . $wp_rewrite->preg_index(2);
     $new_rules[$user_page . "([^/]+)/?\$"] = "index.php?page_id=" . $base_page_id . "&ap_page=user&ap_user="******"?\$"] = "index.php?page_id=" . $base_page_id . "&ap_page=user";
     $new_rules[$slug . "search/([^/]+)/?"] = "index.php?page_id=" . $base_page_id . "&ap_page=search&ap_s=" . $wp_rewrite->preg_index(1);
     $new_rules[$slug . "ask/([^/]+)/?"] = "index.php?page_id=" . $base_page_id . "&ap_page=ask&parent=" . $wp_rewrite->preg_index(1);
     $new_rules[$slug . "([^/]+)/?"] = "index.php?page_id=" . $base_page_id . "&ap_page=" . $wp_rewrite->preg_index(1);
     $ap_rules = apply_filters('ap_rewrite_rules', $new_rules);
     return $wp_rewrite->rules = $ap_rules + $wp_rewrite->rules;
 }
Exemple #2
0
 /**
  * Rewrite rules
  * @return array
  */
 public function rewrites()
 {
     global $wp_rewrite;
     global $ap_rules;
     unset($wp_rewrite->extra_permastructs['question']);
     unset($wp_rewrite->extra_permastructs['answer']);
     $base_page_id = ap_opt('base_page');
     $slug = ap_base_page_slug() . '/';
     $question_slug = ap_opt('question_page_slug');
     if (empty($question_slug)) {
         $question_slug = 'question';
     }
     $user_page = ap_opt('base_before_user_perma') ? $slug . ap_get_user_page_slug() . '/' : ap_get_user_page_slug() . '/';
     $new_rules = array($slug . 'parent/([^/]+)/?' => 'index.php?page_id=' . $base_page_id . '&parent=' . $wp_rewrite->preg_index(1), $slug . 'tag/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?page_id=' . $base_page_id . '&ap_page=tag&q_tag=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2), $slug . 'tag/([^/]+)/?' => 'index.php?page_id=' . $base_page_id . '&ap_page=tag&q_tag=' . $wp_rewrite->preg_index(1), $slug . 'page/?([0-9]{1,})/?$' => 'index.php?page_id=' . $base_page_id . '&paged=' . $wp_rewrite->preg_index(1), $slug . '([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?page_id=' . $base_page_id . '&ap_page=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2));
     if (!ap_opt('question_permalink_follow')) {
         $new_rules[$question_slug . '/([^/]+)/page/?([0-9]{1,})/?$'] = 'index.php?page_id=' . $base_page_id . '&question_name=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2);
         $new_rules[$question_slug . '/([^/]+)/?$'] = 'index.php?page_id=' . $base_page_id . '&question_name=' . $wp_rewrite->preg_index(1);
     } else {
         $new_rules[$slug . $question_slug . '/([^/]+)/page/?([0-9]{1,})/?$'] = 'index.php?page_id=' . $base_page_id . '&question_name=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2);
         $new_rules[$slug . $question_slug . '/([^/]+)/?$'] = 'index.php?page_id=' . $base_page_id . '&question_name=' . $wp_rewrite->preg_index(1);
     }
     $new_rules[$slug . $question_slug . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $base_page_id . '&question_id=' . $wp_rewrite->preg_index(1) . '&question_name=' . $wp_rewrite->preg_index(2);
     $new_rules[$user_page . '([^/]+)/([^/]+)/page/?([0-9]{1,})/?$'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . ap_get_user_page_slug() . '&ap_user='******'&user_page=' . $wp_rewrite->preg_index(2) . '&paged=' . $wp_rewrite->preg_index(3);
     $new_rules[$user_page . '([^/]+)/([^/]+)/?'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . ap_get_user_page_slug() . '&ap_user='******'&user_page=' . $wp_rewrite->preg_index(2);
     $new_rules[$user_page . '([^/]+)/?$'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . ap_get_user_page_slug() . '&ap_user='******'?$'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . ap_get_user_page_slug();
     $new_rules[$slug . 'search/([^/]+)/?'] = 'index.php?page_id=' . $base_page_id . '&ap_page=search&ap_s=' . $wp_rewrite->preg_index(1);
     $new_rules[$slug . 'ask/([^/]+)/?'] = 'index.php?page_id=' . $base_page_id . '&ap_page=ask&parent=' . $wp_rewrite->preg_index(1);
     $new_rules[$slug . '([^/]+)/?'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . $wp_rewrite->preg_index(1);
     $ap_rules = apply_filters('ap_rewrite_rules', $new_rules, $slug, $base_page_id);
     return $wp_rewrite->rules = $ap_rules + $wp_rewrite->rules;
 }
Exemple #3
0
 public function rewrites()
 {
     global $wp_rewrite;
     global $ap_rules;
     unset($wp_rewrite->extra_permastructs['question']);
     unset($wp_rewrite->extra_permastructs['answer']);
     $base_page_id = ap_opt('base_page');
     $base_page_slug = ap_opt('base_page_slug');
     $q_prefix = strlen(ap_opt('question_prefix')) > 0 ? ap_opt('question_prefix') . '/' : '';
     $slug = ap_base_page_slug();
     $question_slug = ap_opt('question_prefix');
     $question_slug = strlen($question_slug) > 0 ? $question_slug . '/' : '';
     $new_rules = array($slug . "parent/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&parent=" . $wp_rewrite->preg_index(1), $slug . $question_slug . "([^/]+)/([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&question_id=" . $wp_rewrite->preg_index(1) . "&question_name=" . $wp_rewrite->preg_index(2) . "&paged=" . $wp_rewrite->preg_index(3), $slug . $question_slug . "([^/]+)/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&question_id=" . $wp_rewrite->preg_index(1) . "&question_name=" . $wp_rewrite->preg_index(2), $slug . "category/([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&question_category=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2), $slug . "tag/([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&question_tags=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2), $slug . "category/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&question_category=" . $wp_rewrite->preg_index(1), $slug . "tag/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&question_tags=" . $wp_rewrite->preg_index(1), $slug . "page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&paged=" . $wp_rewrite->preg_index(1), $slug . "([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&ap_page=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2), $slug . "user/([^/]+)/([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&ap_page=user&user="******"&user_page=" . $wp_rewrite->preg_index(2) . "&paged=" . $wp_rewrite->preg_index(3), $slug . "user/([^/]+)/([^/]+)/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=user&user="******"&user_page=" . $wp_rewrite->preg_index(2) . "&message_id=" . $wp_rewrite->preg_index(3), $slug . "user/([^/]+)/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=user&user="******"&user_page=" . $wp_rewrite->preg_index(2), $slug . "user/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=user&user="******"search/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=search&ap_s=" . $wp_rewrite->preg_index(1), $slug . "ask/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=ask&parent=" . $wp_rewrite->preg_index(1), $slug . "([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=" . $wp_rewrite->preg_index(1));
     $ap_rules = $new_rules;
     return $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
 }