Plugin Directory

Changeset 2346213


Ignore:
Timestamp:
07/24/2020 06:26:56 PM (6 years ago)
Author:
transact
Message:

version 5.1.0 configure text fade

Location:
transact
Files:
5 edited
17 copied

Legend:

Unmodified
Added
Removed
  • transact/tags/5.1.0/admin/controllers/transact-admin-settings-menu.php

    r2344350 r2346213  
    161161
    162162        add_settings_field(
    163             'page_background_color',
     163            'text_fade_color',
    164164            'Page Fade Color',
    165165            array( $this, 'color_input_callback' ),
     
    167167            'xct_button_style',
    168168            array('page_background_color') // Default value
     169        );
     170
     171        add_settings_field(
     172            'text_fade_amount',
     173            'Preview Text Fade Amount',
     174            array( $this, 'text_fade_callback' ),
     175            'transact-settings',
     176            'xct_button_style',
     177            array(
     178                'id' => 'text_fade_amount',
     179                'default_val' => 'regular') // Default value
    169180        );
    170181
     
    235246
    236247        add_settings_field(
    237             'efault_purchase_type',
     248            'default_purchase_type',
    238249            'Default Post Purchase Type',
    239250            array( $this, 'default_purchase_type_callback' ),
     
    440451    }
    441452
     453    public function text_fade_callback() {
     454        $purchase_type_options = array('regular', 'less', 'disable');
     455        $option_labels = array(
     456            'regular' => 'Regular fade amount',
     457            'less' => 'Less fade',
     458            'disable' => 'Disable fade');
     459        $options = get_option('transact-settings');
     460        $selected_option = isset($options['text_fade_amount']) ? $options['text_fade_amount'] : 'regular';
     461        ?>
     462        <script>
     463            // Sets the real setting field
     464            function setTextFadeValue(val) {
     465                jQuery('#text_fade_amount').val(val);
     466            }
     467        </script>
     468        <input
     469            id="text_fade_amount"
     470            type="hidden"
     471            name="transact-settings[text_fade_amount]"
     472            value="<?php echo esc_attr($selected_option); ?>"
     473            />
     474
     475        <?php
     476        for($i = 0; $i < count($purchase_type_options); $i++) {
     477            $i_option = $purchase_type_options[$i];
     478            $field_id = "text_fade_amount_" . $i_option;
     479            $is_checked = $i_option === $selected_option ? 'checked' : '';
     480
     481            ?>
     482                <input <?php echo esc_attr($is_checked); ?>
     483                    id="<?php echo esc_html($field_id); ?>"
     484                    type="radio"
     485                    onclick="setTextFadeValue('<?php echo esc_attr($i_option); ?>')"
     486                    name="uf-text_fade_amount"
     487                    value="<?php echo esc_attr($i_option); ?>"
     488                />
     489                <label for="<?php echo esc_html($field_id); ?>"><?php echo esc_html($option_labels[$i_option]); ?></label>
     490                <br />
     491            <?php
     492        }
     493    }
     494
    442495    public function button_text_callback($args) {
    443496
  • transact/tags/5.1.0/frontend/assets/style.css

    r2344350 r2346213  
    33  position: relative;
    44  margin-top: -125px;
    5   padding-top: 125px;
    65  z-index: 1;
    76  text-align: center;
     
    109  display: block;
    1110}
    12 .transact-purchase_button.transact-fade {
    13   background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 130px, rgba(255, 255, 255, 1));
     11.transact-purchase_button .transact-fade {
     12  padding-top: 125px;
     13  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 125px, rgba(255, 255, 255, 1));
     14}
     15.transact-purchase_button .transact-fade.fade-less {
     16  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 180px, rgba(255, 255, 255, 1));
     17}
     18.transact-purchase_button .transact-fade.fade-disable {
     19  background: transparent !important;
    1420}
    1521.transact-purchase_button
  • transact/tags/5.1.0/frontend/controllers/transact-handle-buttons.php

    r2344350 r2346213  
    148148     */
    149149    protected function wrap_buttons($options, $transact_api, $buttons, $is_donation) {
    150         $output = '';
    151 
    152         if($is_donation) {
    153             $output .= '<div class="transact-purchase_button" style="%s">';
    154         } else if ($this->should_display_call_to_action()) {
     150        $output = '<div class="transact-purchase_button">';
     151        $has_overlay = false;
     152
     153        if(!$is_donation && $this->should_display_call_to_action()) {
     154            $has_overlay = true;
     155
     156            $background_gradient_start = 130;
     157            $background_fade_amount_class = '';
     158            if(isset($options['text_fade_amount'])) {
     159                $background_fade_amount_class = ' fade-' . $options['text_fade_amount'];
     160                if($options['text_fade_amount'] === 'less') {
     161                    $background_gradient_start = 180;
     162                }
     163            }
     164
    155165            $background_fade_color_style = '';
    156166            if(isset($options['page_background_color'])) {
    157167                list($r, $g, $b) = sscanf($options['page_background_color'], "#%02x%02x%02x");
    158                 $background_fade_color_style = "background:linear-gradient(to bottom, rgba($r,$g,$b,0), rgba($r,$g,$b,1) 130px, rgba($r,$g,$b,1))";
     168                $background_fade_color_style = "background:linear-gradient(to bottom, rgba($r,$g,$b,0), rgba($r,$g,$b,1) " .
     169                    $background_gradient_start .
     170                    "px, rgba($r,$g,$b,1))";
    159171            }
    160172
     
    165177
    166178            $output .= sprintf(
    167                 '<div class="transact-purchase_button transact-fade" style="%s">' .
     179                '<div class="transact-fade%s" style="%s">' .
    168180                '<h3 class="transact-cta">' . $cta_text . '</h3>',
     181                $background_fade_amount_class,
    169182                $background_fade_color_style
    170183            );
     
    183196        $output .= '</div>';
    184197
    185         if ($is_donation || $this->should_display_call_to_action()) {
     198        if ($has_overlay) {
    186199            $output .= '</div>';
    187200        }
     201        $output .= '</div>';
    188202
    189203        return $output;
  • transact/tags/5.1.0/readme.txt

    r2344350 r2346213  
    55Requires at least: 5.0
    66Requires PHP: 5.6
    7 Tested up to: 5.3.2
    8 Stable tag: 4.4.0
     7Tested up to: 5.4.2
     8Stable tag: 5.1.0
    99License: APACHE-2.0
    1010License URI: https://www.apache.org/licenses/LICENSE-2.0
     
    8282
    8383
     84= 5.1.0 =
     85* Configurable text fade on paid content.
     86
    8487= 5.0.0 =
    8588* Create a user for each transact user.
  • transact/tags/5.1.0/transact-plugin.php

    r2344350 r2346213  
    33 * Plugin Name: transact.io
    44 * Description: Integrates transact.io services into WP
    5  * Version: 5.0.0
     5 * Version: 5.1.0
    66 * Author: transact.io
    77 * Author URI: https://transact.io
  • transact/trunk/admin/controllers/transact-admin-settings-menu.php

    r2344350 r2346213  
    161161
    162162        add_settings_field(
    163             'page_background_color',
     163            'text_fade_color',
    164164            'Page Fade Color',
    165165            array( $this, 'color_input_callback' ),
     
    167167            'xct_button_style',
    168168            array('page_background_color') // Default value
     169        );
     170
     171        add_settings_field(
     172            'text_fade_amount',
     173            'Preview Text Fade Amount',
     174            array( $this, 'text_fade_callback' ),
     175            'transact-settings',
     176            'xct_button_style',
     177            array(
     178                'id' => 'text_fade_amount',
     179                'default_val' => 'regular') // Default value
    169180        );
    170181
     
    235246
    236247        add_settings_field(
    237             'efault_purchase_type',
     248            'default_purchase_type',
    238249            'Default Post Purchase Type',
    239250            array( $this, 'default_purchase_type_callback' ),
     
    440451    }
    441452
     453    public function text_fade_callback() {
     454        $purchase_type_options = array('regular', 'less', 'disable');
     455        $option_labels = array(
     456            'regular' => 'Regular fade amount',
     457            'less' => 'Less fade',
     458            'disable' => 'Disable fade');
     459        $options = get_option('transact-settings');
     460        $selected_option = isset($options['text_fade_amount']) ? $options['text_fade_amount'] : 'regular';
     461        ?>
     462        <script>
     463            // Sets the real setting field
     464            function setTextFadeValue(val) {
     465                jQuery('#text_fade_amount').val(val);
     466            }
     467        </script>
     468        <input
     469            id="text_fade_amount"
     470            type="hidden"
     471            name="transact-settings[text_fade_amount]"
     472            value="<?php echo esc_attr($selected_option); ?>"
     473            />
     474
     475        <?php
     476        for($i = 0; $i < count($purchase_type_options); $i++) {
     477            $i_option = $purchase_type_options[$i];
     478            $field_id = "text_fade_amount_" . $i_option;
     479            $is_checked = $i_option === $selected_option ? 'checked' : '';
     480
     481            ?>
     482                <input <?php echo esc_attr($is_checked); ?>
     483                    id="<?php echo esc_html($field_id); ?>"
     484                    type="radio"
     485                    onclick="setTextFadeValue('<?php echo esc_attr($i_option); ?>')"
     486                    name="uf-text_fade_amount"
     487                    value="<?php echo esc_attr($i_option); ?>"
     488                />
     489                <label for="<?php echo esc_html($field_id); ?>"><?php echo esc_html($option_labels[$i_option]); ?></label>
     490                <br />
     491            <?php
     492        }
     493    }
     494
    442495    public function button_text_callback($args) {
    443496
  • transact/trunk/frontend/assets/style.css

    r2344350 r2346213  
    33  position: relative;
    44  margin-top: -125px;
    5   padding-top: 125px;
    65  z-index: 1;
    76  text-align: center;
     
    109  display: block;
    1110}
    12 .transact-purchase_button.transact-fade {
    13   background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 130px, rgba(255, 255, 255, 1));
     11.transact-purchase_button .transact-fade {
     12  padding-top: 125px;
     13  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 125px, rgba(255, 255, 255, 1));
     14}
     15.transact-purchase_button .transact-fade.fade-less {
     16  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 180px, rgba(255, 255, 255, 1));
     17}
     18.transact-purchase_button .transact-fade.fade-disable {
     19  background: transparent !important;
    1420}
    1521.transact-purchase_button
  • transact/trunk/frontend/controllers/transact-handle-buttons.php

    r2344350 r2346213  
    148148     */
    149149    protected function wrap_buttons($options, $transact_api, $buttons, $is_donation) {
    150         $output = '';
    151 
    152         if($is_donation) {
    153             $output .= '<div class="transact-purchase_button" style="%s">';
    154         } else if ($this->should_display_call_to_action()) {
     150        $output = '<div class="transact-purchase_button">';
     151        $has_overlay = false;
     152
     153        if(!$is_donation && $this->should_display_call_to_action()) {
     154            $has_overlay = true;
     155
     156            $background_gradient_start = 130;
     157            $background_fade_amount_class = '';
     158            if(isset($options['text_fade_amount'])) {
     159                $background_fade_amount_class = ' fade-' . $options['text_fade_amount'];
     160                if($options['text_fade_amount'] === 'less') {
     161                    $background_gradient_start = 180;
     162                }
     163            }
     164
    155165            $background_fade_color_style = '';
    156166            if(isset($options['page_background_color'])) {
    157167                list($r, $g, $b) = sscanf($options['page_background_color'], "#%02x%02x%02x");
    158                 $background_fade_color_style = "background:linear-gradient(to bottom, rgba($r,$g,$b,0), rgba($r,$g,$b,1) 130px, rgba($r,$g,$b,1))";
     168                $background_fade_color_style = "background:linear-gradient(to bottom, rgba($r,$g,$b,0), rgba($r,$g,$b,1) " .
     169                    $background_gradient_start .
     170                    "px, rgba($r,$g,$b,1))";
    159171            }
    160172
     
    165177
    166178            $output .= sprintf(
    167                 '<div class="transact-purchase_button transact-fade" style="%s">' .
     179                '<div class="transact-fade%s" style="%s">' .
    168180                '<h3 class="transact-cta">' . $cta_text . '</h3>',
     181                $background_fade_amount_class,
    169182                $background_fade_color_style
    170183            );
     
    183196        $output .= '</div>';
    184197
    185         if ($is_donation || $this->should_display_call_to_action()) {
     198        if ($has_overlay) {
    186199            $output .= '</div>';
    187200        }
     201        $output .= '</div>';
    188202
    189203        return $output;
  • transact/trunk/readme.txt

    r2344350 r2346213  
    55Requires at least: 5.0
    66Requires PHP: 5.6
    7 Tested up to: 5.3.2
    8 Stable tag: 4.4.0
     7Tested up to: 5.4.2
     8Stable tag: 5.1.0
    99License: APACHE-2.0
    1010License URI: https://www.apache.org/licenses/LICENSE-2.0
     
    8282
    8383
     84= 5.1.0 =
     85* Configurable text fade on paid content.
     86
    8487= 5.0.0 =
    8588* Create a user for each transact user.
  • transact/trunk/transact-plugin.php

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