Plugin Directory

Changeset 2328310


Ignore:
Timestamp:
06/21/2020 08:00:10 PM (6 years ago)
Author:
transact
Message:

Version: 4.3.0 shortcode options, option to disable transact, allow admin to view posts

  • new short code options: call_to_action and display_promo
  • admin options for default button type or disable transact button.
  • alow admin user to see premium without paying
Location:
transact
Files:
13 edited
12 copied

Legend:

Unmodified
Added
Removed
  • transact/tags/4.3.0/README.md

    r2256774 r2328310  
    21212. Is possible to set up new texts for purchase and subscribe buttons, also choose between the 3 model buttons (as in the post settings)
    22223. You can choose to show "Only Purchase Button", "Only Subscribe button", "Purchase and Subscribe button".
    23 4. Shortcode is [transact_button]
     234. Shortcode is `[transact_button]`
    24245. If you do not set up any option, it will use default transact buttons.
    25 5. Options are 'button_text' 'subscribe_text', 'button_type'
    26 6. "Purchase and Subscribe button" = 1, "Only Purchase Button" = 2, "Only Subscribe button" = 3
    27 6. Example: [transact_button button_text="purchase me" subscribe_text="subscribe to the site" button_type="1"]
     256. Options are:
     26   -  `button_text` : Text to display on purchase button
     27   -  `subscribe_text` : Text to display on subscribe button
     28   -  `button_type`
     29       *  "Purchase and Subscribe button" = 1, "Only Purchase Button" = 2, "Only Subscribe button" = 3
     30   -  `call_to_action`
     31      * `0` = don't display call to action text
     32      * `1` = Display call to action text (default)
     33   -  `display_promo`
     34      * `0` = don't display call to transact promotion text
     35      * `1` = Display call to promotion text (free credit text) (default)
     367. Example:
     37   - `[transact_button button_text="purchase me" subscribe_text="subscribe to the site" button_type="1" call_to_action="1" display_promo="1"]`
    2838
    2939## Google Tag Manager integration
     
    3444### Events Emitted
    3545
    36 - `start-purchase` 
     46- `start-purchase`
    3747    - Emitted when purchase button is clicked
    3848    - Also exposes a `purchaseType` flag, set to either `purchase`, `donation`, or `subscription`.
  • transact/tags/4.3.0/admin/controllers/transact-admin-settings-menu.php

    r2256774 r2328310  
    232232                'id' => 'transact_purchase_button_text',
    233233                'default_val' => 'cents') // Default value
     234        );
     235
     236        add_settings_field(
     237            'efault_purchase_type',
     238            'Default Post Purchase Type',
     239            array( $this, 'default_purchase_type_callback' ),
     240            'transact-settings',
     241            'xct_button_style',
     242            array(
     243                'id' => 'transact_default_purchase_type',
     244                'default_val' => 'subscribe_purchase') // Default value
    234245        );
    235246
     
    481492        ?>
    482493        <script>
    483             // Handles checkbox for subscription
     494            // Sets the real setting field
    484495            function setButtonFormatValue(val) {
    485496                jQuery('#display_cents_dollars').val(val);
     
    513524    }
    514525
     526    public function default_purchase_type_callback($args)
     527    {
     528        $purchase_type_options = array('subscribe_purchase', 'purchase_only', 'subscribe_only', 'disable_transact');
     529        $option_labels = array(
     530            'subscribe_purchase' => 'Display Purchase and Subscribe Button',
     531            'purchase_only' => 'Display Only Purchase Button',
     532            'subscribe_only' => 'Display Only Subscribe Button',
     533            'disable_transact' => 'Disable Transact by Default');
     534        $options = get_option('transact-settings');
     535        $selected_option = isset($options['default_purchase_type']) ? $options['default_purchase_type'] : 'subscribe_purchase';
     536        ?>
     537        <script>
     538            // Sets the real setting field
     539            function setPurchaseTypeValue(val) {
     540                jQuery('#default_purchase_type').val(val);
     541            }
     542        </script>
     543        <input
     544            id="default_purchase_type"
     545            type="hidden"
     546            name="transact-settings[default_purchase_type]"
     547            value="<?php echo esc_attr($selected_option); ?>"
     548            />
     549
     550        <?php
     551        for($i = 0; $i < count($purchase_type_options); $i++) {
     552            $i_option = $purchase_type_options[$i];
     553            $field_id = "default_purchase_type_" . $i_option;
     554            $is_checked = $i_option === $selected_option ? 'checked' : '';
     555
     556            ?>
     557                <input <?php echo esc_attr($is_checked); ?>
     558                    id="<?php echo esc_html($field_id); ?>"
     559                    type="radio"
     560                    onclick="setPurchaseTypeValue('<?php echo esc_attr($i_option); ?>')"
     561                    name="uf-default_purchase_type"
     562                    value="<?php echo esc_attr($i_option); ?>"
     563                />
     564                <label for="<?php echo esc_html($field_id); ?>"><?php echo esc_html($option_labels[$i_option]); ?></label>
     565                <br />
     566            <?php
     567        }
     568    }
     569
    515570    /**
    516571     * Individual settings callback to be created
     
    620675    protected function settings_user_validates($account_id, $secret_key)
    621676    {
    622 
    623677        $validate_url = (new ConfigParser())->getValidationUrl();
    624678        $response = (new TransactApi())->validates($validate_url, $account_id, $secret_key);
  • transact/tags/4.3.0/admin/controllers/transact-admin-settings-post.php

    r2264141 r2328310  
    404404            $subscription_options = isset($options['subscription']) ? $options['subscription'] : 0;
    405405            if ($subscription_options) {
     406                if(!$value[4] && $options['default_purchase_type']) {
     407                    switch($options['default_purchase_type']) {
     408                        case 'subscribe_purchase':
     409                            $value[4] = self::PURCHASE_AND_SUBSCRIPTION;
     410                            break;
     411                        case 'purchase_only':
     412                            $value[4] = self::ONLY_PURCHASE;
     413                            break;
     414                        case 'subscribe_only':
     415                            $value[4] = self::ONLY_SUBSCRIBE;
     416                            break;
     417                        case 'disable_transact':
     418                            $value[4] = self::DISABLE;
     419                            break;
     420                    }
     421                }
     422               
    406423                $selected_purchased_and_subscription = ($value[4] == self::PURCHASE_AND_SUBSCRIPTION) ? 'selected' : '';
    407424                $selected_purchased = ($value[4] == self::ONLY_PURCHASE) ? 'selected' : '';
  • transact/tags/4.3.0/admin/controllers/transact-shortcode.php

    r2266126 r2328310  
    4747            'subscribe_text' => '',
    4848            'button_type' => '1',
     49            'call_to_action' => '1',
     50            'display_promo' => '1',
    4951        ), $this->attributes );
    5052
     
    5456            $atts['button_text'],
    5557            $atts['subscribe_text'],
    56             $atts['button_type']
     58            $atts['button_type'],
     59            $atts['call_to_action'],
     60            $atts['display_promo']
    5761        );
    5862
  • transact/tags/4.3.0/frontend/assets/transact_post.js

    r2306325 r2328310  
    5454                    tokenUrl += '/' + transact_params.affiliate_id;
    5555                }
    56                 jQuery.get(tokenUrl)
     56                ajaxGet(tokenUrl)
    5757                    .done(function(data) {
    5858                        loadingPurchase = false;
     
    9090                    subscribeTokenUrl += '/' + transact_params.affiliate_id;
    9191                }
    92                 jQuery.get(subscribeTokenUrl)
     92                ajaxGet(subscribeTokenUrl)
    9393                    .done(function(data) {
    9494                        loadingSubscribe = false;
     
    108108
    109109        transactApi.getCurrentPromo('en', function(arg, result) {
    110             var promoBlock = jQuery('#transact_promo');
    111             promoBlock.css('color', transact_params.theme.background_color)
    112             // this text comes from transact.io who we trust
    113             // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
    114             promoBlock.html(result.text);
     110            let promoBlock = jQuery('#transact_promo');
     111
     112            if (promoBlock && promoBlock.length) {
     113                promoBlock.css('color', transact_params.theme.background_color);
     114                // this text comes from transact.io who we trust
     115                // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
     116                promoBlock.html(result.text);
     117            }
    115118        });
    116119    });
     
    120123
    121124        var premiumUrl = transact_params.ajaxurl + 'premium/' + transact_params.post_id;
    122         jQuery.get(premiumUrl)
     125        ajaxGet(premiumUrl)
    123126            .done(function(data) {
    124127                if(data.is_premium) {
     
    130133                    // Get comments
    131134                    var commentsUrl = transact_params.ajaxurl + 'comments_template/' + transact_params.post_id;
    132                     jQuery.get(commentsUrl)
     135                    ajaxGet(commentsUrl)
    133136                        .done(function(data) {
    134137                            // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.append
     
    138141                            console.log('Could not fetch comments', data);
    139142                        });
    140                    
     143
    141144                    reloadKnownScripts();
    142145                } else {
     
    191194            donateUrl += '/' + transact_params.affiliate_id;
    192195        }
    193         jQuery.get(donateUrl)
     196        ajaxGet(donateUrl)
    194197            .done(function(data) {
    195198                jQuery('#button_purchase_donation_loading').css('display', 'none');
     
    426429        });
    427430    }
    428    
     431
    429432    function gtmEvent(name, addtlParams) {
    430433        if(window.dataLayer !== undefined) {
     
    442445        }
    443446    }
     447
     448    function ajaxGet(url) {
     449        // Set the nonce token so we can get the user object in wordpress
     450        return $.ajax({
     451            url: url,
     452            type: "GET",
     453            beforeSend: function(xhr){
     454                if(window.WP_REST_NONCE) {
     455                    xhr.setRequestHeader('X-WP-Nonce', window.WP_REST_NONCE);
     456                }
     457            }
     458         });
     459    }
    444460})();
  • transact/tags/4.3.0/frontend/controllers/transact-api.php

    r2269448 r2328310  
    252252    public function is_premium()
    253253    {
     254        // Admins with edit post permissions can always view premium
     255        if(current_user_can( 'edit_posts' )) {
     256            return true;
     257        }
    254258        $cookie_manager = new CookieManager();
    255259        if ($cookie_manager->validate_cookie($this->post_id)) {
  • transact/tags/4.3.0/frontend/controllers/transact-handle-buttons-shortcode.php

    r2266126 r2328310  
    2424    protected $is_single;
    2525
    26     public function __construct($post_id, $transact_api, $purchase_text, $subscribe_text, $button_type)
     26    public function __construct($post_id, $transact_api, $purchase_text,
     27        $subscribe_text, $button_type, $call_to_action, $display_promo)
    2728    {
    2829        parent::__construct($post_id, $transact_api);
     
    3132        $this->button_type = $button_type;
    3233        $this->is_single = (is_single() || get_post_type() === 'page');
     34        $this->call_to_action = $call_to_action;
     35        $this->display_promo = $display_promo;
    3336    }
    3437
     
    4649        } else {
    4750            return '';
     51        }
     52    }
     53
     54    public function should_display_call_to_action()
     55    {
     56
     57        if (empty($this->call_to_action)) {
     58            return FALSE;
     59        } else if ($this->call_to_action == "1") {
     60            return TRUE;
     61        } else {
     62            return FALSE;
     63        }
     64    }
     65
     66
     67    public function should_display_promo()
     68    {
     69
     70        if (!isset($this->display_promo)) {
     71            return TRUE;
     72        } else if ($this->display_promo == "0") {
     73            return FALSE;
     74        } else {
     75            return TRUE;
    4876        }
    4977    }
  • transact/tags/4.3.0/frontend/controllers/transact-handle-buttons.php

    r2266126 r2328310  
    104104    }
    105105
     106    public function should_display_call_to_action()
     107    {
     108         //  with short code you can override this to false
     109        return TRUE;
     110    }
     111
     112    public function should_display_promo()
     113    {
     114       //  with short code you can override this to false
     115       return TRUE;
     116    }
    106117    /**
    107118     * Get button type from post options
     
    141152        if($is_donation) {
    142153            $output .= '<div class="transact-purchase_button" style="%s">';
    143         } else {
     154        } else if ($this->should_display_call_to_action()) {
    144155            $background_fade_color_style = '';
    145156            if(isset($options['page_background_color'])) {
     
    160171        }
    161172
    162         $output .= '<h4 class="transact_promo" id="transact_promo"></h4>' .
    163         '<div>';
    164 
     173        if ($this->should_display_promo()) {
     174            $output .= '<h4 class="transact_promo" id="transact_promo"></h4>';
     175
     176        }
     177
     178        $output .=  '<div>';
    165179        for ($i = 0; $i < count($buttons); $i++) {
    166180            $output .= '<div class="transact_button_col">' . $buttons[$i] . '</div>';
    167181        }
    168182
    169         $output .= '</div></div>';
     183        $output .= '</div>';
     184
     185        if ($is_donation || $this->should_display_call_to_action()) {
     186            $output .= '</div>';
     187        }
    170188
    171189        return $output;
     
    284302                        $token_text = __(self::TOKEN_TEXT, 'transact');
    285303                    }
    286    
     304
    287305                    $button_text = $this->options['transact_purchase_button_text'] . ' '.  $price . ' ' . $token_text;
    288306                } else {
  • transact/tags/4.3.0/frontend/controllers/transact-single-post.php

    r2306325 r2328310  
    459459        add_action( 'wp_body_open', array($this, 'add_gtm_body_include') );
    460460        add_action( 'wp_head', array($this, 'add_gtm_head_include') );
     461        add_action( 'wp_head', array($this, 'add_wp_nonce') );
    461462
    462463        /**
     
    492493                <!-- End Google Tag Manager (noscript) -->';
    493494        }
     495    }
     496    public function add_wp_nonce() {
     497        echo "<script>window.WP_REST_NONCE = '" . esc_html(wp_create_nonce( 'wp_rest' )) . "';</script>";
    494498    }
    495499
  • transact/tags/4.3.0/readme.txt

    r2306325 r2328310  
    8181== Changelog ==
    8282
     83= 4.3.0 =
     84* new short code options:  call_to_action and display_promo
     85* admin options for default button type or disable transact button.
     86* alow admin user to see premium without paying
     87
    8388= 4.2.4 =
    8489* Don't show purchase button if post has no premium blocks or premium content
     
    103108
    104109= 4.0.2 =
    105 * Fix for wordpress jetpack tiled-gallery+carousel compatibility 
     110* Fix for wordpress jetpack tiled-gallery+carousel compatibility
    106111
    107112= 4.0.1 =
  • transact/tags/4.3.0/transact-plugin.php

    r2306325 r2328310  
    33 * Plugin Name: transact.io
    44 * Description: Integrates transact.io services into WP
    5  * Version: 4.2.4
     5 * Version: 4.3.0
    66 * Author: transact.io
    77 * Author URI: https://transact.io
  • transact/trunk/README.md

    r2256774 r2328310  
    21212. Is possible to set up new texts for purchase and subscribe buttons, also choose between the 3 model buttons (as in the post settings)
    22223. You can choose to show "Only Purchase Button", "Only Subscribe button", "Purchase and Subscribe button".
    23 4. Shortcode is [transact_button]
     234. Shortcode is `[transact_button]`
    24245. If you do not set up any option, it will use default transact buttons.
    25 5. Options are 'button_text' 'subscribe_text', 'button_type'
    26 6. "Purchase and Subscribe button" = 1, "Only Purchase Button" = 2, "Only Subscribe button" = 3
    27 6. Example: [transact_button button_text="purchase me" subscribe_text="subscribe to the site" button_type="1"]
     256. Options are:
     26   -  `button_text` : Text to display on purchase button
     27   -  `subscribe_text` : Text to display on subscribe button
     28   -  `button_type`
     29       *  "Purchase and Subscribe button" = 1, "Only Purchase Button" = 2, "Only Subscribe button" = 3
     30   -  `call_to_action`
     31      * `0` = don't display call to action text
     32      * `1` = Display call to action text (default)
     33   -  `display_promo`
     34      * `0` = don't display call to transact promotion text
     35      * `1` = Display call to promotion text (free credit text) (default)
     367. Example:
     37   - `[transact_button button_text="purchase me" subscribe_text="subscribe to the site" button_type="1" call_to_action="1" display_promo="1"]`
    2838
    2939## Google Tag Manager integration
     
    3444### Events Emitted
    3545
    36 - `start-purchase` 
     46- `start-purchase`
    3747    - Emitted when purchase button is clicked
    3848    - Also exposes a `purchaseType` flag, set to either `purchase`, `donation`, or `subscription`.
  • transact/trunk/admin/controllers/transact-admin-settings-menu.php

    r2256774 r2328310  
    232232                'id' => 'transact_purchase_button_text',
    233233                'default_val' => 'cents') // Default value
     234        );
     235
     236        add_settings_field(
     237            'efault_purchase_type',
     238            'Default Post Purchase Type',
     239            array( $this, 'default_purchase_type_callback' ),
     240            'transact-settings',
     241            'xct_button_style',
     242            array(
     243                'id' => 'transact_default_purchase_type',
     244                'default_val' => 'subscribe_purchase') // Default value
    234245        );
    235246
     
    481492        ?>
    482493        <script>
    483             // Handles checkbox for subscription
     494            // Sets the real setting field
    484495            function setButtonFormatValue(val) {
    485496                jQuery('#display_cents_dollars').val(val);
     
    513524    }
    514525
     526    public function default_purchase_type_callback($args)
     527    {
     528        $purchase_type_options = array('subscribe_purchase', 'purchase_only', 'subscribe_only', 'disable_transact');
     529        $option_labels = array(
     530            'subscribe_purchase' => 'Display Purchase and Subscribe Button',
     531            'purchase_only' => 'Display Only Purchase Button',
     532            'subscribe_only' => 'Display Only Subscribe Button',
     533            'disable_transact' => 'Disable Transact by Default');
     534        $options = get_option('transact-settings');
     535        $selected_option = isset($options['default_purchase_type']) ? $options['default_purchase_type'] : 'subscribe_purchase';
     536        ?>
     537        <script>
     538            // Sets the real setting field
     539            function setPurchaseTypeValue(val) {
     540                jQuery('#default_purchase_type').val(val);
     541            }
     542        </script>
     543        <input
     544            id="default_purchase_type"
     545            type="hidden"
     546            name="transact-settings[default_purchase_type]"
     547            value="<?php echo esc_attr($selected_option); ?>"
     548            />
     549
     550        <?php
     551        for($i = 0; $i < count($purchase_type_options); $i++) {
     552            $i_option = $purchase_type_options[$i];
     553            $field_id = "default_purchase_type_" . $i_option;
     554            $is_checked = $i_option === $selected_option ? 'checked' : '';
     555
     556            ?>
     557                <input <?php echo esc_attr($is_checked); ?>
     558                    id="<?php echo esc_html($field_id); ?>"
     559                    type="radio"
     560                    onclick="setPurchaseTypeValue('<?php echo esc_attr($i_option); ?>')"
     561                    name="uf-default_purchase_type"
     562                    value="<?php echo esc_attr($i_option); ?>"
     563                />
     564                <label for="<?php echo esc_html($field_id); ?>"><?php echo esc_html($option_labels[$i_option]); ?></label>
     565                <br />
     566            <?php
     567        }
     568    }
     569
    515570    /**
    516571     * Individual settings callback to be created
     
    620675    protected function settings_user_validates($account_id, $secret_key)
    621676    {
    622 
    623677        $validate_url = (new ConfigParser())->getValidationUrl();
    624678        $response = (new TransactApi())->validates($validate_url, $account_id, $secret_key);
  • transact/trunk/admin/controllers/transact-admin-settings-post.php

    r2264141 r2328310  
    404404            $subscription_options = isset($options['subscription']) ? $options['subscription'] : 0;
    405405            if ($subscription_options) {
     406                if(!$value[4] && $options['default_purchase_type']) {
     407                    switch($options['default_purchase_type']) {
     408                        case 'subscribe_purchase':
     409                            $value[4] = self::PURCHASE_AND_SUBSCRIPTION;
     410                            break;
     411                        case 'purchase_only':
     412                            $value[4] = self::ONLY_PURCHASE;
     413                            break;
     414                        case 'subscribe_only':
     415                            $value[4] = self::ONLY_SUBSCRIBE;
     416                            break;
     417                        case 'disable_transact':
     418                            $value[4] = self::DISABLE;
     419                            break;
     420                    }
     421                }
     422               
    406423                $selected_purchased_and_subscription = ($value[4] == self::PURCHASE_AND_SUBSCRIPTION) ? 'selected' : '';
    407424                $selected_purchased = ($value[4] == self::ONLY_PURCHASE) ? 'selected' : '';
  • transact/trunk/admin/controllers/transact-shortcode.php

    r2266126 r2328310  
    4747            'subscribe_text' => '',
    4848            'button_type' => '1',
     49            'call_to_action' => '1',
     50            'display_promo' => '1',
    4951        ), $this->attributes );
    5052
     
    5456            $atts['button_text'],
    5557            $atts['subscribe_text'],
    56             $atts['button_type']
     58            $atts['button_type'],
     59            $atts['call_to_action'],
     60            $atts['display_promo']
    5761        );
    5862
  • transact/trunk/frontend/assets/transact_post.js

    r2306325 r2328310  
    5454                    tokenUrl += '/' + transact_params.affiliate_id;
    5555                }
    56                 jQuery.get(tokenUrl)
     56                ajaxGet(tokenUrl)
    5757                    .done(function(data) {
    5858                        loadingPurchase = false;
     
    9090                    subscribeTokenUrl += '/' + transact_params.affiliate_id;
    9191                }
    92                 jQuery.get(subscribeTokenUrl)
     92                ajaxGet(subscribeTokenUrl)
    9393                    .done(function(data) {
    9494                        loadingSubscribe = false;
     
    108108
    109109        transactApi.getCurrentPromo('en', function(arg, result) {
    110             var promoBlock = jQuery('#transact_promo');
    111             promoBlock.css('color', transact_params.theme.background_color)
    112             // this text comes from transact.io who we trust
    113             // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
    114             promoBlock.html(result.text);
     110            let promoBlock = jQuery('#transact_promo');
     111
     112            if (promoBlock && promoBlock.length) {
     113                promoBlock.css('color', transact_params.theme.background_color);
     114                // this text comes from transact.io who we trust
     115                // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
     116                promoBlock.html(result.text);
     117            }
    115118        });
    116119    });
     
    120123
    121124        var premiumUrl = transact_params.ajaxurl + 'premium/' + transact_params.post_id;
    122         jQuery.get(premiumUrl)
     125        ajaxGet(premiumUrl)
    123126            .done(function(data) {
    124127                if(data.is_premium) {
     
    130133                    // Get comments
    131134                    var commentsUrl = transact_params.ajaxurl + 'comments_template/' + transact_params.post_id;
    132                     jQuery.get(commentsUrl)
     135                    ajaxGet(commentsUrl)
    133136                        .done(function(data) {
    134137                            // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.append
     
    138141                            console.log('Could not fetch comments', data);
    139142                        });
    140                    
     143
    141144                    reloadKnownScripts();
    142145                } else {
     
    191194            donateUrl += '/' + transact_params.affiliate_id;
    192195        }
    193         jQuery.get(donateUrl)
     196        ajaxGet(donateUrl)
    194197            .done(function(data) {
    195198                jQuery('#button_purchase_donation_loading').css('display', 'none');
     
    426429        });
    427430    }
    428    
     431
    429432    function gtmEvent(name, addtlParams) {
    430433        if(window.dataLayer !== undefined) {
     
    442445        }
    443446    }
     447
     448    function ajaxGet(url) {
     449        // Set the nonce token so we can get the user object in wordpress
     450        return $.ajax({
     451            url: url,
     452            type: "GET",
     453            beforeSend: function(xhr){
     454                if(window.WP_REST_NONCE) {
     455                    xhr.setRequestHeader('X-WP-Nonce', window.WP_REST_NONCE);
     456                }
     457            }
     458         });
     459    }
    444460})();
  • transact/trunk/frontend/controllers/transact-api.php

    r2269448 r2328310  
    252252    public function is_premium()
    253253    {
     254        // Admins with edit post permissions can always view premium
     255        if(current_user_can( 'edit_posts' )) {
     256            return true;
     257        }
    254258        $cookie_manager = new CookieManager();
    255259        if ($cookie_manager->validate_cookie($this->post_id)) {
  • transact/trunk/frontend/controllers/transact-handle-buttons-shortcode.php

    r2266126 r2328310  
    2424    protected $is_single;
    2525
    26     public function __construct($post_id, $transact_api, $purchase_text, $subscribe_text, $button_type)
     26    public function __construct($post_id, $transact_api, $purchase_text,
     27        $subscribe_text, $button_type, $call_to_action, $display_promo)
    2728    {
    2829        parent::__construct($post_id, $transact_api);
     
    3132        $this->button_type = $button_type;
    3233        $this->is_single = (is_single() || get_post_type() === 'page');
     34        $this->call_to_action = $call_to_action;
     35        $this->display_promo = $display_promo;
    3336    }
    3437
     
    4649        } else {
    4750            return '';
     51        }
     52    }
     53
     54    public function should_display_call_to_action()
     55    {
     56
     57        if (empty($this->call_to_action)) {
     58            return FALSE;
     59        } else if ($this->call_to_action == "1") {
     60            return TRUE;
     61        } else {
     62            return FALSE;
     63        }
     64    }
     65
     66
     67    public function should_display_promo()
     68    {
     69
     70        if (!isset($this->display_promo)) {
     71            return TRUE;
     72        } else if ($this->display_promo == "0") {
     73            return FALSE;
     74        } else {
     75            return TRUE;
    4876        }
    4977    }
  • transact/trunk/frontend/controllers/transact-handle-buttons.php

    r2266126 r2328310  
    104104    }
    105105
     106    public function should_display_call_to_action()
     107    {
     108         //  with short code you can override this to false
     109        return TRUE;
     110    }
     111
     112    public function should_display_promo()
     113    {
     114       //  with short code you can override this to false
     115       return TRUE;
     116    }
    106117    /**
    107118     * Get button type from post options
     
    141152        if($is_donation) {
    142153            $output .= '<div class="transact-purchase_button" style="%s">';
    143         } else {
     154        } else if ($this->should_display_call_to_action()) {
    144155            $background_fade_color_style = '';
    145156            if(isset($options['page_background_color'])) {
     
    160171        }
    161172
    162         $output .= '<h4 class="transact_promo" id="transact_promo"></h4>' .
    163         '<div>';
    164 
     173        if ($this->should_display_promo()) {
     174            $output .= '<h4 class="transact_promo" id="transact_promo"></h4>';
     175
     176        }
     177
     178        $output .=  '<div>';
    165179        for ($i = 0; $i < count($buttons); $i++) {
    166180            $output .= '<div class="transact_button_col">' . $buttons[$i] . '</div>';
    167181        }
    168182
    169         $output .= '</div></div>';
     183        $output .= '</div>';
     184
     185        if ($is_donation || $this->should_display_call_to_action()) {
     186            $output .= '</div>';
     187        }
    170188
    171189        return $output;
     
    284302                        $token_text = __(self::TOKEN_TEXT, 'transact');
    285303                    }
    286    
     304
    287305                    $button_text = $this->options['transact_purchase_button_text'] . ' '.  $price . ' ' . $token_text;
    288306                } else {
  • transact/trunk/frontend/controllers/transact-single-post.php

    r2306325 r2328310  
    459459        add_action( 'wp_body_open', array($this, 'add_gtm_body_include') );
    460460        add_action( 'wp_head', array($this, 'add_gtm_head_include') );
     461        add_action( 'wp_head', array($this, 'add_wp_nonce') );
    461462
    462463        /**
     
    492493                <!-- End Google Tag Manager (noscript) -->';
    493494        }
     495    }
     496    public function add_wp_nonce() {
     497        echo "<script>window.WP_REST_NONCE = '" . esc_html(wp_create_nonce( 'wp_rest' )) . "';</script>";
    494498    }
    495499
  • transact/trunk/readme.txt

    r2306325 r2328310  
    8181== Changelog ==
    8282
     83= 4.3.0 =
     84* new short code options:  call_to_action and display_promo
     85* admin options for default button type or disable transact button.
     86* alow admin user to see premium without paying
     87
    8388= 4.2.4 =
    8489* Don't show purchase button if post has no premium blocks or premium content
     
    103108
    104109= 4.0.2 =
    105 * Fix for wordpress jetpack tiled-gallery+carousel compatibility 
     110* Fix for wordpress jetpack tiled-gallery+carousel compatibility
    106111
    107112= 4.0.1 =
  • transact/trunk/transact-plugin.php

    r2306325 r2328310  
    33 * Plugin Name: transact.io
    44 * Description: Integrates transact.io services into WP
    5  * Version: 4.2.4
     5 * Version: 4.3.0
    66 * Author: transact.io
    77 * Author URI: https://transact.io
Note: See TracChangeset for help on using the changeset viewer.