Beispiel #1
0
function _wpsc_filter_rewrite_controller_slugs($rules)
{
    $slugs = wpsc_get_page_slugs();
    $new_rules = array();
    foreach ($slugs as $page_name => $slug) {
        $controller_name = sanitize_title_with_dashes($page_name);
        $new_rules["({$slug})(/.+?)?/?\$"] = 'index.php?wpsc_controller=' . $controller_name . '&wpsc_controller_args=$matches[2]';
    }
    $rules = array_merge($new_rules, $rules);
    return $rules;
}
Beispiel #2
0
function _wpsc_get_page_url($page, $slug = '')
{
    require_once ABSPATH . '/wp-admin/includes/misc.php';
    $slugs = wpsc_get_page_slugs();
    if (!get_option('permalink_structure')) {
        $uri = add_query_arg('wpsc_page', $page, home_url('/'));
        if ($slug) {
            $uri = add_query_arg('wpsc_callback', $slug, $uri);
        }
        return $uri;
    }
    global $wp_rewrite;
    $prefix = $wp_rewrite->root;
    $uri = $prefix . $slugs[$page];
    if ($slug) {
        $uri = trailingslashit($uri) . ltrim($slug, '/');
    }
    return user_trailingslashit(home_url($uri));
}
Beispiel #3
0
 /**
  * Initialize $wp_query flags for WPEC controllers.
  *
  * @since  0.1
  * @access private
  *
  * @param  string $controller Controller name
  */
 private function init_query_flags($controller)
 {
     global $wp_query;
     // initialize all controller conditional flags to false
     $props = array_keys(wpsc_get_page_slugs());
     foreach ($props as $name) {
         $prop = 'wpsc_is_' . str_replace('-', '_', $name);
         $wp_query->{$prop} = false;
     }
     $wp_query->wpsc_is_controller = false;
     if (empty($controller)) {
         return;
     }
     // is_404 is always set to false for our pseudo-pages (cart, checkout,
     // account, login etc.)
     $wp_query->is_404 = false;
     // front page flags
     if (!$this->is_store_front_page()) {
         $wp_query->is_home = false;
         $wp_query->wpsc_is_store_front_page = false;
     }
     // flip the flag corresponding to this controller
     $wp_query->wpsc_is_controller = true;
     $prop = 'wpsc_is_' . str_replace('-', '_', $controller);
     $wp_query->{$prop} = true;
 }