Plugin Directory

Changeset 1500641


Ignore:
Timestamp:
09/22/2016 10:49:56 PM (9 years ago)
Author:
pushpress
Message:

Added new shortcode: wp-pushpress-events to show events. Added filter on products to only show items you designed as show on wordpress. Removed events from the wp-pushpress-plans shortcode.

Location:
pushpress-integration/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • pushpress-integration/trunk/inc/wp_pushpress_model.php

    r1498520 r1500641  
    1717    public function get_products() {
    1818
    19         if (! $productsObj = get_transient("pp_client_active_products")) {
     19        $key = "pp_client_active_products";
     20        if (! $productsObj = get_transient($key)) {
    2021            $params = array(
    21                 'active' => 1
     22                'active' => 1,
     23                'show_on_wp' => 1
    2224            );
    2325            //get products object
    2426            $productsObj = Pushpress_Product::all($params);
    25             set_transient( 'pp_client_active_products', $productsObj, 300 ); // 5m           
    26         }
    27 
     27
     28            set_transient( $key, $productsObj, 300 ); // 5m                       
     29        }
     30       
    2831
    2932        $productsList = array();
    3033
    3134        foreach ($productsObj['data'] as $product) {
    32             if($product->is_public){
    3335                //get categories
    3436                $catId = $product->category->uuid;
     
    4749                sort($prices);
    4850                $productsList[$catId]['products'][$product->uuid]['price'] = $prices;
    49             }
    50         }
     51           
     52        }
     53
     54
    5155
    5256
     
    9195    }
    9296
     97    public function get_products_by_id($id) {
     98        $productsList = array();
     99       
     100        $key  = "pp_client_active_product_" . $id;
     101
     102        if (! $product = get_transient($key)) {
     103           
     104            //get products object
     105            $product = Pushpress_Product::retrieve($id);
     106            set_transient( $key, $productsObj, 300 ); // 5m
     107
     108            $productsList[$product->category->uuid]['products'][$product->uuid]['slug'] = $product->slug;
     109            $productsList[$product->category->uuid]['products'][$product->uuid]['name'] = $product->name;
     110            $productsList[$product->category->uuid]['products'][$product->uuid]['description'] = $product->description;
     111            $prices = array();
     112            $options = $product->options;
     113            foreach ($options as $option) {
     114                $prices[] = $option->price;
     115            }
     116            sort($prices);
     117            $productsList[$product->category->uuid]['products'][$product->uuid]['price'] = $prices;
     118        }
     119
     120        return $productsList;
     121
     122    }
     123
    93124    public function get_products_by_category($category) {
    94125       
     
    103134            //get products object
    104135            $productsObj = Pushpress_Product::all($params);
    105             set_transient( $key, $productsObj, 600 ); // 5m
     136            set_transient( $key, $productsObj, 300 ); // 5m
    106137        }
    107138
     
    159190    public function get_plans_by_id($id) {
    160191        $plansList = array();
     192       
    161193        try {
    162194
    163195            $planType = array('R' => 'Recurring', 'N' => 'Non-Recurring', 'P' => 'Punchcards');
    164196
    165             if (!empty($id) && $this->plan_exist($id)) {
     197            if (!empty($id)) {
    166198                //get all products object
    167199                $plan = Pushpress_Plan::retrieve($id);
     
    229261        $end = strtotime("today 00:00:00 +1 year"); // 1 year later
    230262
    231         $cache_key = "pp_client_calendar" . $isEvent . "_" . $start . "_" . $end;
     263        $cache_key = "pp_client_calendar_" . $isEvent . "_" . $start . "_" . $end;
    232264       
    233265        if (! $calendar = get_transient($cache_key)) {
  • pushpress-integration/trunk/inc/wp_pushpress_shortcode.php

    r1287386 r1500641  
    1212
    1313    public function products($atts) {
    14         if (empty($atts['category'])) {
     14
     15        if (($atts['category'])) {
     16            $products = $this->model->get_products_by_category($atts['category']);           
     17        }
     18        else if (($atts['id'])) {
     19            $products = $this->model->get_products_by_id($atts['id']);
     20        } else {
    1521            $products = $this->model->get_products();
    16         } else {
    17             $products = $this->model->get_products_by_category($atts['category']);
    1822        }
    1923
     
    3034            $plans = $this->model->get_plans();
    3135            $courses = $this->model->get_events("course", $atts);
     36            // $events = $this->model->get_events("event", $atts);
     37        } else {
     38            // $events = $this->model->get_event_by_id($atts['id']);
     39            $plans = $this->model->get_plans_by_id($atts['id']);           
     40        }
     41
     42        ob_start();
     43        include PUSHPRESS_FRONTEND . 'shortcode_plans.php';
     44        $output = ob_get_contents();
     45        ob_end_clean();
     46        return $output;
     47    }
     48
     49    public function events($atts) {
     50
     51        if (empty($atts['id'])) {
    3252            $events = $this->model->get_events("event", $atts);
    3353        } else {
    34             $events = $this->model->get_event_by_id($atts['id']);
    35             $plans = $this->model->get_plans_by_id($atts['id']);
     54            $events = $this->model->get_event_by_id($atts['id']);           
    3655        }
    3756
  • pushpress-integration/trunk/lib/php-sdk/lib/Pushpress/ApiRequestor.php

    r1230496 r1500641  
    125125    if (PushpressApi::$apiVersion)
    126126      $headers[] = 'Pushpress-Version: ' . PushpressApi::$apiVersion;
     127
     128   
    127129    list($rbody, $rcode) = $this->_curlRequest($meth, $absUrl, $headers, $params);
    128130    return array($rbody, $rcode, $myApiKey);
  • pushpress-integration/trunk/pushpress.php

    r1498520 r1500641  
    22/**
    33 * @package WP-PushPress
    4  * @version 1.5.5
     4 * @version 1.5.6
    55 */
    66/*
     
    99Description: Easily integrate your workouts, calendar, products, membership plans, events and more with your Wordpress blog!  This plugin is a free add-on for existing PushPress clients.  See https://pushpress.com for more info.
    1010Author: PushPress, Inc
    11 Version: 1.5.5
     11Version: 1.5.6
    1212Author URI: https://pushpress.com
    1313*/
    1414define('PUSHPRESS_DEV', FALSE);
    15 define( 'PP_PLUGIN_VERSION', '1.5.5');
     15define( 'PP_PLUGIN_VERSION', '1.5.6');
    1616define( 'PUSHPRESS_ERROR_REPORT', 0 );
    1717define( 'PUSHPRESS_BUTTON_CLASS',  'pushpress-button-class-' . rand(0, 10000));
     
    3939                $this->prefixPagesSlug = 'pushpress-';
    4040                $this->prefixShortcodes = 'wp-pushpress-';
    41                 $this->listPagesSlug = array('products', 'plans', 'schedule', 'workouts', 'leads');
     41                $this->listPagesSlug = array('products', 'plans', 'events', 'schedule', 'workouts', 'leads');
    4242   
    4343                if ( is_admin() ){
  • pushpress-integration/trunk/readme.txt

    r1498520 r1500641  
    44Requires at least: 3.0.1
    55Tested up to: 4.6.1
    6 Stable tag: 1.5.5
     6Stable tag: 1.5.6
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    105105= 1.5.5 =
    106106Enhanced mobile version of plans, products and events pages.
     107
     108= 1.5.6 =
     109Added new shortcode: wp-pushpress-events to show events.
     110Removed events from the wp-pushpress-plans shortcode.
     111Added filter on products to only show items you designed as "show on wordpress".
     112Remove the header from shortcodes that are invoked using an ID to show only one item. [wp-pushpress-plans id="uniqueIDofPlan"]
  • pushpress-integration/trunk/templates/frontend/shortcode_plans.php

    r1498520 r1500641  
    66   
    77    <div class="wp-pushpress">
     8
    89    <?php
    910        if( !empty( $plans ) && count($plans) > 0 ){
     
    1213
    1314        <ul class="wp-pushpress-list">
     15            <?php if (!$atts['id']) { ?>
    1416            <li class="item-first">
    1517                <h3><?php echo $planType[$k];?></h3>           
    1618            </li>
    1719            <?php
     20                }
    1821                foreach ($item as $key => $value) {
    1922            ?>
     
    7477
    7578        <ul class="wp-pushpress-list">
    76             <li class="item-first"><h3>Events</h3>
    77                 <div class="clear"></div></li>
     79            <?php if (!$atts['id']) { ?>
     80            <li class="item-first">
     81                <h3>Events</h3>
     82            </li>
     83           
    7884            <?php
     85            }   
    7986                foreach ($events as $key => $value) {
    8087            ?>
  • pushpress-integration/trunk/templates/frontend/shortcode_products.php

    r1498520 r1500641  
    2121
    2222                <ul class="wp-pushpress-list">
     23                    <?php if (!$atts['id']) { ?>
    2324                    <li class="item-first">
    2425                        <h3><?php echo $item['category_name'];?></h3>                       
    2526                    </li>
     27                    <?php } ?>
    2628                <?php
    2729                foreach ($item['products'] as $key => $value) {
Note: See TracChangeset for help on using the changeset viewer.