Esempio n. 1
0
 /**
  * Save the settings
  */
 private function save()
 {
     // We need to save the options ourselves; settings api does not trigger save for the permalinks page
     if (isset($_POST['permalink_structure']) || isset($_POST['category_base']) && isset($_POST['product_permalink'])) {
         // Cat and tag bases
         $categorySlug = trim(strip_tags($_POST['jigoshop_product_category_slug']));
         $tagSlug = trim(strip_tags($_POST['jigoshop_product_tag_slug']));
         $permalinks = $this->options->get('permalinks');
         $helpers = $this->wp->getHelpers();
         $permalinks['category'] = $helpers->untrailingslashit($categorySlug);
         $permalinks['tag'] = $helpers->untrailingslashit($tagSlug);
         // Product base
         $product_permalink = trim(strip_tags($_POST['product_permalink']));
         if ($product_permalink == 'custom') {
             // Get permalink without slashes
             $product_permalink = trim(strip_tags($_POST['product_permalink_structure']), '/');
             // This is an invalid base structure and breaks pages
             if ('%' . Types::PRODUCT_CATEGORY . '%' == $product_permalink) {
                 $product_permalink = _x('product', 'slug', 'jigoshop') . '/' . $product_permalink;
             }
         } elseif (empty($product_permalink)) {
             $product_permalink = false;
         }
         $permalinks['product'] = $helpers->untrailingslashit($product_permalink);
         // Shop base may require verbose page rules if nesting pages
         $shopPageId = $this->options->getPageId(FrontendPages::SHOP);
         $shop_permalink = urldecode($shopPageId > 0 && $this->wp->getPost($shopPageId) ? $this->wp->getPageUri($shopPageId) : _x('shop', 'default-slug', 'jigoshop'));
         if ($shopPageId && trim($permalinks['product'], '/') === $shop_permalink) {
             $permalinks['verbose'] = true;
         }
         $this->options->update('permalinks', $permalinks);
         $this->options->saveOptions();
         $this->wp->getRewrite()->flush_rules();
     }
 }
Esempio n. 2
0
 private function _createPages()
 {
     // start out with basic page parameters, modify as we go
     $data = array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => $this->wp->getCurrentUserId(), 'post_name' => '', 'post_content' => '', 'comment_status' => 'closed', 'ping_status' => false);
     $this->_createPage(Pages::SHOP, array_merge($data, array('post_title' => __('Shop', 'jigoshop'))));
     $this->_createPage(Pages::CART, array_merge($data, array('post_title' => __('Cart', 'jigoshop'))));
     $this->_createPage(Pages::CHECKOUT, array_merge($data, array('post_title' => __('Checkout', 'jigoshop'))));
     $this->_createPage(Pages::THANK_YOU, array_merge($data, array('post_title' => __('Checkout - thank you', 'jigoshop'))));
     $this->_createPage(Pages::ACCOUNT, array_merge($data, array('post_title' => __('My account', 'jigoshop'))));
     $this->options->saveOptions();
 }
Esempio n. 3
0
 /**
  * @param $postId int Email template to add.
  * @param $hooks  array List of hooks to add to.
  */
 public function addTemplate($postId, $hooks)
 {
     $templates = $this->options->get('emails.templates');
     if (is_array($templates)) {
         $templates = array_map(function ($template) use($postId) {
             return array_filter($template, function ($templatePostId) use($postId) {
                 return $templatePostId != $postId;
             });
         }, $templates);
     }
     foreach ($hooks as $hook) {
         $templates[$hook][] = $postId;
     }
     $this->options->update('emails.templates', $templates);
     $this->options->saveOptions();
 }