Changeset 2328310
- Timestamp:
- 06/21/2020 08:00:10 PM (6 years ago)
- Location:
- transact
- Files:
-
- 13 edited
- 12 copied
-
tags/4.3.0 (copied) (copied from transact/trunk)
-
tags/4.3.0/README.md (modified) (2 diffs)
-
tags/4.3.0/admin/controllers/transact-admin-settings-menu.php (modified) (4 diffs)
-
tags/4.3.0/admin/controllers/transact-admin-settings-post.php (copied) (copied from transact/trunk/admin/controllers/transact-admin-settings-post.php) (1 diff)
-
tags/4.3.0/admin/controllers/transact-shortcode.php (copied) (copied from transact/trunk/admin/controllers/transact-shortcode.php) (2 diffs)
-
tags/4.3.0/frontend/assets/style.css (copied) (copied from transact/trunk/frontend/assets/style.css)
-
tags/4.3.0/frontend/assets/transact_post.js (copied) (copied from transact/trunk/frontend/assets/transact_post.js) (9 diffs)
-
tags/4.3.0/frontend/controllers/transact-api.php (copied) (copied from transact/trunk/frontend/controllers/transact-api.php) (1 diff)
-
tags/4.3.0/frontend/controllers/transact-handle-buttons-shortcode.php (copied) (copied from transact/trunk/frontend/controllers/transact-handle-buttons-shortcode.php) (3 diffs)
-
tags/4.3.0/frontend/controllers/transact-handle-buttons.php (copied) (copied from transact/trunk/frontend/controllers/transact-handle-buttons.php) (4 diffs)
-
tags/4.3.0/frontend/controllers/transact-single-post.php (copied) (copied from transact/trunk/frontend/controllers/transact-single-post.php) (2 diffs)
-
tags/4.3.0/readme.txt (copied) (copied from transact/trunk/readme.txt) (2 diffs)
-
tags/4.3.0/transact-plugin.php (copied) (copied from transact/trunk/transact-plugin.php) (1 diff)
-
tags/4.3.0/vendors/transact-io-php/transact-io.php (copied) (copied from transact/trunk/vendors/transact-io-php/transact-io.php)
-
trunk/README.md (modified) (2 diffs)
-
trunk/admin/controllers/transact-admin-settings-menu.php (modified) (4 diffs)
-
trunk/admin/controllers/transact-admin-settings-post.php (modified) (1 diff)
-
trunk/admin/controllers/transact-shortcode.php (modified) (2 diffs)
-
trunk/frontend/assets/transact_post.js (modified) (9 diffs)
-
trunk/frontend/controllers/transact-api.php (modified) (1 diff)
-
trunk/frontend/controllers/transact-handle-buttons-shortcode.php (modified) (3 diffs)
-
trunk/frontend/controllers/transact-handle-buttons.php (modified) (4 diffs)
-
trunk/frontend/controllers/transact-single-post.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/transact-plugin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
transact/tags/4.3.0/README.md
r2256774 r2328310 21 21 2. Is possible to set up new texts for purchase and subscribe buttons, also choose between the 3 model buttons (as in the post settings) 22 22 3. You can choose to show "Only Purchase Button", "Only Subscribe button", "Purchase and Subscribe button". 23 4. Shortcode is [transact_button]23 4. Shortcode is `[transact_button]` 24 24 5. 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"] 25 6. 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) 36 7. Example: 37 - `[transact_button button_text="purchase me" subscribe_text="subscribe to the site" button_type="1" call_to_action="1" display_promo="1"]` 28 38 29 39 ## Google Tag Manager integration … … 34 44 ### Events Emitted 35 45 36 - `start-purchase` 46 - `start-purchase` 37 47 - Emitted when purchase button is clicked 38 48 - 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 232 232 'id' => 'transact_purchase_button_text', 233 233 '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 234 245 ); 235 246 … … 481 492 ?> 482 493 <script> 483 // Handles checkbox for subscription494 // Sets the real setting field 484 495 function setButtonFormatValue(val) { 485 496 jQuery('#display_cents_dollars').val(val); … … 513 524 } 514 525 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 515 570 /** 516 571 * Individual settings callback to be created … … 620 675 protected function settings_user_validates($account_id, $secret_key) 621 676 { 622 623 677 $validate_url = (new ConfigParser())->getValidationUrl(); 624 678 $response = (new TransactApi())->validates($validate_url, $account_id, $secret_key); -
transact/tags/4.3.0/admin/controllers/transact-admin-settings-post.php
r2264141 r2328310 404 404 $subscription_options = isset($options['subscription']) ? $options['subscription'] : 0; 405 405 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 406 423 $selected_purchased_and_subscription = ($value[4] == self::PURCHASE_AND_SUBSCRIPTION) ? 'selected' : ''; 407 424 $selected_purchased = ($value[4] == self::ONLY_PURCHASE) ? 'selected' : ''; -
transact/tags/4.3.0/admin/controllers/transact-shortcode.php
r2266126 r2328310 47 47 'subscribe_text' => '', 48 48 'button_type' => '1', 49 'call_to_action' => '1', 50 'display_promo' => '1', 49 51 ), $this->attributes ); 50 52 … … 54 56 $atts['button_text'], 55 57 $atts['subscribe_text'], 56 $atts['button_type'] 58 $atts['button_type'], 59 $atts['call_to_action'], 60 $atts['display_promo'] 57 61 ); 58 62 -
transact/tags/4.3.0/frontend/assets/transact_post.js
r2306325 r2328310 54 54 tokenUrl += '/' + transact_params.affiliate_id; 55 55 } 56 jQuery.get(tokenUrl)56 ajaxGet(tokenUrl) 57 57 .done(function(data) { 58 58 loadingPurchase = false; … … 90 90 subscribeTokenUrl += '/' + transact_params.affiliate_id; 91 91 } 92 jQuery.get(subscribeTokenUrl)92 ajaxGet(subscribeTokenUrl) 93 93 .done(function(data) { 94 94 loadingSubscribe = false; … … 108 108 109 109 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 } 115 118 }); 116 119 }); … … 120 123 121 124 var premiumUrl = transact_params.ajaxurl + 'premium/' + transact_params.post_id; 122 jQuery.get(premiumUrl)125 ajaxGet(premiumUrl) 123 126 .done(function(data) { 124 127 if(data.is_premium) { … … 130 133 // Get comments 131 134 var commentsUrl = transact_params.ajaxurl + 'comments_template/' + transact_params.post_id; 132 jQuery.get(commentsUrl)135 ajaxGet(commentsUrl) 133 136 .done(function(data) { 134 137 // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.append … … 138 141 console.log('Could not fetch comments', data); 139 142 }); 140 143 141 144 reloadKnownScripts(); 142 145 } else { … … 191 194 donateUrl += '/' + transact_params.affiliate_id; 192 195 } 193 jQuery.get(donateUrl)196 ajaxGet(donateUrl) 194 197 .done(function(data) { 195 198 jQuery('#button_purchase_donation_loading').css('display', 'none'); … … 426 429 }); 427 430 } 428 431 429 432 function gtmEvent(name, addtlParams) { 430 433 if(window.dataLayer !== undefined) { … … 442 445 } 443 446 } 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 } 444 460 })(); -
transact/tags/4.3.0/frontend/controllers/transact-api.php
r2269448 r2328310 252 252 public function is_premium() 253 253 { 254 // Admins with edit post permissions can always view premium 255 if(current_user_can( 'edit_posts' )) { 256 return true; 257 } 254 258 $cookie_manager = new CookieManager(); 255 259 if ($cookie_manager->validate_cookie($this->post_id)) { -
transact/tags/4.3.0/frontend/controllers/transact-handle-buttons-shortcode.php
r2266126 r2328310 24 24 protected $is_single; 25 25 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) 27 28 { 28 29 parent::__construct($post_id, $transact_api); … … 31 32 $this->button_type = $button_type; 32 33 $this->is_single = (is_single() || get_post_type() === 'page'); 34 $this->call_to_action = $call_to_action; 35 $this->display_promo = $display_promo; 33 36 } 34 37 … … 46 49 } else { 47 50 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; 48 76 } 49 77 } -
transact/tags/4.3.0/frontend/controllers/transact-handle-buttons.php
r2266126 r2328310 104 104 } 105 105 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 } 106 117 /** 107 118 * Get button type from post options … … 141 152 if($is_donation) { 142 153 $output .= '<div class="transact-purchase_button" style="%s">'; 143 } else {154 } else if ($this->should_display_call_to_action()) { 144 155 $background_fade_color_style = ''; 145 156 if(isset($options['page_background_color'])) { … … 160 171 } 161 172 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>'; 165 179 for ($i = 0; $i < count($buttons); $i++) { 166 180 $output .= '<div class="transact_button_col">' . $buttons[$i] . '</div>'; 167 181 } 168 182 169 $output .= '</div></div>'; 183 $output .= '</div>'; 184 185 if ($is_donation || $this->should_display_call_to_action()) { 186 $output .= '</div>'; 187 } 170 188 171 189 return $output; … … 284 302 $token_text = __(self::TOKEN_TEXT, 'transact'); 285 303 } 286 304 287 305 $button_text = $this->options['transact_purchase_button_text'] . ' '. $price . ' ' . $token_text; 288 306 } else { -
transact/tags/4.3.0/frontend/controllers/transact-single-post.php
r2306325 r2328310 459 459 add_action( 'wp_body_open', array($this, 'add_gtm_body_include') ); 460 460 add_action( 'wp_head', array($this, 'add_gtm_head_include') ); 461 add_action( 'wp_head', array($this, 'add_wp_nonce') ); 461 462 462 463 /** … … 492 493 <!-- End Google Tag Manager (noscript) -->'; 493 494 } 495 } 496 public function add_wp_nonce() { 497 echo "<script>window.WP_REST_NONCE = '" . esc_html(wp_create_nonce( 'wp_rest' )) . "';</script>"; 494 498 } 495 499 -
transact/tags/4.3.0/readme.txt
r2306325 r2328310 81 81 == Changelog == 82 82 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 83 88 = 4.2.4 = 84 89 * Don't show purchase button if post has no premium blocks or premium content … … 103 108 104 109 = 4.0.2 = 105 * Fix for wordpress jetpack tiled-gallery+carousel compatibility 110 * Fix for wordpress jetpack tiled-gallery+carousel compatibility 106 111 107 112 = 4.0.1 = -
transact/tags/4.3.0/transact-plugin.php
r2306325 r2328310 3 3 * Plugin Name: transact.io 4 4 * Description: Integrates transact.io services into WP 5 * Version: 4. 2.45 * Version: 4.3.0 6 6 * Author: transact.io 7 7 * Author URI: https://transact.io -
transact/trunk/README.md
r2256774 r2328310 21 21 2. Is possible to set up new texts for purchase and subscribe buttons, also choose between the 3 model buttons (as in the post settings) 22 22 3. You can choose to show "Only Purchase Button", "Only Subscribe button", "Purchase and Subscribe button". 23 4. Shortcode is [transact_button]23 4. Shortcode is `[transact_button]` 24 24 5. 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"] 25 6. 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) 36 7. Example: 37 - `[transact_button button_text="purchase me" subscribe_text="subscribe to the site" button_type="1" call_to_action="1" display_promo="1"]` 28 38 29 39 ## Google Tag Manager integration … … 34 44 ### Events Emitted 35 45 36 - `start-purchase` 46 - `start-purchase` 37 47 - Emitted when purchase button is clicked 38 48 - Also exposes a `purchaseType` flag, set to either `purchase`, `donation`, or `subscription`. -
transact/trunk/admin/controllers/transact-admin-settings-menu.php
r2256774 r2328310 232 232 'id' => 'transact_purchase_button_text', 233 233 '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 234 245 ); 235 246 … … 481 492 ?> 482 493 <script> 483 // Handles checkbox for subscription494 // Sets the real setting field 484 495 function setButtonFormatValue(val) { 485 496 jQuery('#display_cents_dollars').val(val); … … 513 524 } 514 525 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 515 570 /** 516 571 * Individual settings callback to be created … … 620 675 protected function settings_user_validates($account_id, $secret_key) 621 676 { 622 623 677 $validate_url = (new ConfigParser())->getValidationUrl(); 624 678 $response = (new TransactApi())->validates($validate_url, $account_id, $secret_key); -
transact/trunk/admin/controllers/transact-admin-settings-post.php
r2264141 r2328310 404 404 $subscription_options = isset($options['subscription']) ? $options['subscription'] : 0; 405 405 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 406 423 $selected_purchased_and_subscription = ($value[4] == self::PURCHASE_AND_SUBSCRIPTION) ? 'selected' : ''; 407 424 $selected_purchased = ($value[4] == self::ONLY_PURCHASE) ? 'selected' : ''; -
transact/trunk/admin/controllers/transact-shortcode.php
r2266126 r2328310 47 47 'subscribe_text' => '', 48 48 'button_type' => '1', 49 'call_to_action' => '1', 50 'display_promo' => '1', 49 51 ), $this->attributes ); 50 52 … … 54 56 $atts['button_text'], 55 57 $atts['subscribe_text'], 56 $atts['button_type'] 58 $atts['button_type'], 59 $atts['call_to_action'], 60 $atts['display_promo'] 57 61 ); 58 62 -
transact/trunk/frontend/assets/transact_post.js
r2306325 r2328310 54 54 tokenUrl += '/' + transact_params.affiliate_id; 55 55 } 56 jQuery.get(tokenUrl)56 ajaxGet(tokenUrl) 57 57 .done(function(data) { 58 58 loadingPurchase = false; … … 90 90 subscribeTokenUrl += '/' + transact_params.affiliate_id; 91 91 } 92 jQuery.get(subscribeTokenUrl)92 ajaxGet(subscribeTokenUrl) 93 93 .done(function(data) { 94 94 loadingSubscribe = false; … … 108 108 109 109 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 } 115 118 }); 116 119 }); … … 120 123 121 124 var premiumUrl = transact_params.ajaxurl + 'premium/' + transact_params.post_id; 122 jQuery.get(premiumUrl)125 ajaxGet(premiumUrl) 123 126 .done(function(data) { 124 127 if(data.is_premium) { … … 130 133 // Get comments 131 134 var commentsUrl = transact_params.ajaxurl + 'comments_template/' + transact_params.post_id; 132 jQuery.get(commentsUrl)135 ajaxGet(commentsUrl) 133 136 .done(function(data) { 134 137 // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.append … … 138 141 console.log('Could not fetch comments', data); 139 142 }); 140 143 141 144 reloadKnownScripts(); 142 145 } else { … … 191 194 donateUrl += '/' + transact_params.affiliate_id; 192 195 } 193 jQuery.get(donateUrl)196 ajaxGet(donateUrl) 194 197 .done(function(data) { 195 198 jQuery('#button_purchase_donation_loading').css('display', 'none'); … … 426 429 }); 427 430 } 428 431 429 432 function gtmEvent(name, addtlParams) { 430 433 if(window.dataLayer !== undefined) { … … 442 445 } 443 446 } 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 } 444 460 })(); -
transact/trunk/frontend/controllers/transact-api.php
r2269448 r2328310 252 252 public function is_premium() 253 253 { 254 // Admins with edit post permissions can always view premium 255 if(current_user_can( 'edit_posts' )) { 256 return true; 257 } 254 258 $cookie_manager = new CookieManager(); 255 259 if ($cookie_manager->validate_cookie($this->post_id)) { -
transact/trunk/frontend/controllers/transact-handle-buttons-shortcode.php
r2266126 r2328310 24 24 protected $is_single; 25 25 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) 27 28 { 28 29 parent::__construct($post_id, $transact_api); … … 31 32 $this->button_type = $button_type; 32 33 $this->is_single = (is_single() || get_post_type() === 'page'); 34 $this->call_to_action = $call_to_action; 35 $this->display_promo = $display_promo; 33 36 } 34 37 … … 46 49 } else { 47 50 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; 48 76 } 49 77 } -
transact/trunk/frontend/controllers/transact-handle-buttons.php
r2266126 r2328310 104 104 } 105 105 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 } 106 117 /** 107 118 * Get button type from post options … … 141 152 if($is_donation) { 142 153 $output .= '<div class="transact-purchase_button" style="%s">'; 143 } else {154 } else if ($this->should_display_call_to_action()) { 144 155 $background_fade_color_style = ''; 145 156 if(isset($options['page_background_color'])) { … … 160 171 } 161 172 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>'; 165 179 for ($i = 0; $i < count($buttons); $i++) { 166 180 $output .= '<div class="transact_button_col">' . $buttons[$i] . '</div>'; 167 181 } 168 182 169 $output .= '</div></div>'; 183 $output .= '</div>'; 184 185 if ($is_donation || $this->should_display_call_to_action()) { 186 $output .= '</div>'; 187 } 170 188 171 189 return $output; … … 284 302 $token_text = __(self::TOKEN_TEXT, 'transact'); 285 303 } 286 304 287 305 $button_text = $this->options['transact_purchase_button_text'] . ' '. $price . ' ' . $token_text; 288 306 } else { -
transact/trunk/frontend/controllers/transact-single-post.php
r2306325 r2328310 459 459 add_action( 'wp_body_open', array($this, 'add_gtm_body_include') ); 460 460 add_action( 'wp_head', array($this, 'add_gtm_head_include') ); 461 add_action( 'wp_head', array($this, 'add_wp_nonce') ); 461 462 462 463 /** … … 492 493 <!-- End Google Tag Manager (noscript) -->'; 493 494 } 495 } 496 public function add_wp_nonce() { 497 echo "<script>window.WP_REST_NONCE = '" . esc_html(wp_create_nonce( 'wp_rest' )) . "';</script>"; 494 498 } 495 499 -
transact/trunk/readme.txt
r2306325 r2328310 81 81 == Changelog == 82 82 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 83 88 = 4.2.4 = 84 89 * Don't show purchase button if post has no premium blocks or premium content … … 103 108 104 109 = 4.0.2 = 105 * Fix for wordpress jetpack tiled-gallery+carousel compatibility 110 * Fix for wordpress jetpack tiled-gallery+carousel compatibility 106 111 107 112 = 4.0.1 = -
transact/trunk/transact-plugin.php
r2306325 r2328310 3 3 * Plugin Name: transact.io 4 4 * Description: Integrates transact.io services into WP 5 * Version: 4. 2.45 * Version: 4.3.0 6 6 * Author: transact.io 7 7 * Author URI: https://transact.io
Note: See TracChangeset
for help on using the changeset viewer.