Changeset 3376123
- Timestamp:
- 10/10/2025 08:28:12 AM (6 months ago)
- Location:
- sitewide-notice-wp
- Files:
-
- 3 edited
-
tags/2.4.1/readme.txt (modified) (1 diff)
-
tags/2.4/sitewide-notice-wp.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sitewide-notice-wp/tags/2.4.1/readme.txt
r3191366 r3376123 4 4 Tags: sitewide banner, site banner, banner, notice, sitewide notice, popup banner, simple banner, website banner, website notice, site notice, site message, website message bar, website bar message, message bar 5 5 Requires at least: 5.2 6 Tested up to: 6. 76 Tested up to: 6.8 7 7 Stable tag: 2.4.1 8 8 License: GPLv2 or later -
sitewide-notice-wp/tags/2.4/sitewide-notice-wp.php
r2857164 r3376123 1 1 <?php 2 2 /** 3 * Plugin Name: Sitewide Notice WP 4 * Description: Adds a simple message bar to the front-end of your website. 5 * Plugin URI: https://yoohooplugins.com 6 * Version: 2.4 7 * Author: Yoohoo Plugins 8 * Author URI: https://yoohooplugins.com 9 * License: GPL2 or later 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 * Text Domain: sitewide-notice-wp 3 * Plugin Name: Paid Memberships Pro - Variable Pricing Add On 4 * Plugin URI: https://www.paidmembershipspro.com/add-ons/variable-pricing-add-on/ 5 * Description: Allow customers to set their own price when checking out for your membership levels. 6 * Version: 0.4.6 7 * Author: Paid Memberships Pro 8 * Author URI: https://www.paidmembershipspro.com 9 * Text Domain: pmpro-variable-pricing 10 * Domain Path: /languages 11 */ 12 13 /* 14 The Plan 15 - Override level cost text on checkout to show text field to set price. 16 - Use that price when checking out. 17 - Price overrides the initial payment and any billing amount for the level. 18 - Leaves trial, billing cycle, and expiration stuff alone. 19 - Add "min price" and "max price" fields to edit level page. 20 - Set price is the "suggested price" 21 */ 22 23 define( 'PMPROVP_VERSION', '0.4.6' ); 24 25 /* 26 Load plugin textdomain. 27 */ 28 function pmprovp_load_textdomain() { 29 load_plugin_textdomain( 'pmpro-variable-pricing', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); 30 } 31 add_action( 'init', 'pmprovp_load_textdomain' ); 32 33 /** 34 * Get settings for a specified level. 35 */ 36 function pmprovp_get_settings( $level_id ) { 37 $defaults = array( 38 'variable_pricing' => 0, 39 'min_price' => '', 40 'max_price' => '', 41 'suggested_price' => '', 42 ); 43 44 $existing_settings = empty( $level_id ) ? array() : get_option( "pmprovp_{$level_id}", array() ); 45 46 return array_merge( $defaults, $existing_settings ); 47 } 48 49 /* 50 Min Price and Max Price Fields on the edit levels page 51 */ 52 // fields on edit page 53 function pmprovp_pmpro_membership_level_after_other_settings() { 54 global $pmpro_currency_symbol; 55 $level_id = intval( $_REQUEST['edit'] ); 56 if ( $level_id > 0 ) { 57 $vpfields = pmprovp_get_settings( $level_id ); 58 $variable_pricing = $vpfields['variable_pricing']; 59 $min_price = $vpfields['min_price']; 60 $max_price = $vpfields['max_price']; 61 $suggested_price = $vpfields['suggested_price']; 62 } else { 63 $variable_pricing = 0; 64 $min_price = ''; 65 $max_price = ''; 66 $suggested_price = ''; 67 } 68 ?> 69 <h3 class="topborder"><?php esc_html_e( 'Variable Pricing', 'pmpro-variable-pricing' ); ?></h3> 70 <p><?php esc_html_e( 'If variable pricing is enabled, users will be able to set their own price at checkout. That price will override any initial payment and billing amount values you set on this level. You can set the minimum, maxium, and suggested price for this level.', 'pmpro-variable-pricing' ); ?></p> 71 72 <table> 73 <tbody class="form-table"> 74 <tr> 75 <th scope="row" valign="top"><label for="pmprovp_variable_pricing"><?php _e( 'Enable:', 'pmpro-variable-pricing' ); ?></label></th> 76 <td> 77 <input type="checkbox" name="variable_pricing" id="pmprovp_variable_pricing" value="1" <?php checked( $variable_pricing, '1' ); ?> /> <label for="pmprovp_variable_pricing"><?php _e( 'Enable Variable Pricing', 'pmpro-variable-pricing' ); ?></label> 78 </td> 79 </tr> 80 <tr class="pmprovp_setting"> 81 <th scope="row" valign="top"><label for="pmprovp_min_price"><?php _e( 'Min Price:', 'pmpro-variable-pricing' ); ?></label></th> 82 <td> 83 <?php echo esc_html( $pmpro_currency_symbol ); ?><input type="text" name="min_price" id="pmprovp_min_price" value="<?php echo esc_attr( $min_price ); ?>" /> 84 </td> 85 </tr> 86 <tr class="pmprovp_setting"> 87 <th scope="row" valign="top"><label for="pmprovp_max_price"><?php esc_html_e( 'Max Price:', 'pmpro-variable-pricing' ); ?></label></th> 88 <td> 89 <?php echo esc_html( $pmpro_currency_symbol ); ?><input type="text" name="max_price" id="pmprovp_max_price" value="<?php echo esc_attr( $max_price ); ?>" /> 90 <?php esc_html_e( 'Leave this blank to allow any maximum amount.', 'pmpro-variable-pricing' ); ?> 91 </td> 92 </tr> 93 <tr class="pmprovp_setting"> 94 <th scope="row" valign="top"><label for="pmprovp_suggested_price"><?php esc_html_e( 'Suggested Price:', 'pmpro-variable-pricing' ); ?></label></th> 95 <td> 96 <?php echo esc_html( $pmpro_currency_symbol ); ?><input type="text" name="suggested_price" id="pmprovp_suggested_price" value="<?php echo esc_attr( $suggested_price ); ?>" /> 97 <?php esc_html_e( 'You may leave this blank.', 'pmpro-variable-pricing' ); ?> 98 </td> 99 </tr> 100 </tbody> 101 </table> 102 <script> 103 jQuery(document).ready(function(){ 104 function pmprovp_toggleSettings() { 105 var pmprovp_enabled = jQuery('#pmprovp_variable_pricing:checked').val(); 106 107 if(typeof pmprovp_enabled == 'undefined') { 108 //disabled 109 jQuery('tr.pmprovp_setting').hide(); 110 } else { 111 //enabled 112 jQuery('tr.pmprovp_setting').show(); 113 } 114 } 115 116 jQuery('#pmprovp_variable_pricing').change(function(){pmprovp_toggleSettings()}); 117 118 pmprovp_toggleSettings(); 119 }); 120 </script> 121 <?php 122 } 123 add_action( 'pmpro_membership_level_after_other_settings', 'pmprovp_pmpro_membership_level_after_other_settings' ); 124 125 // save level cost text when the level is saved/added 126 function pmprovp_pmpro_save_membership_level( $level_id ) { 127 $variable_pricing = isset( $_REQUEST['variable_pricing'] ) ? intval( $_REQUEST['variable_pricing'] ) : 0; 128 $min_price = preg_replace( '[^0-9\.]', '', $_REQUEST['min_price'] ); 129 $max_price = preg_replace( '[^0-9\.]', '', $_REQUEST['max_price'] ); 130 $suggested_price = preg_replace( '[^0-9\.]', '', $_REQUEST['suggested_price'] ); 131 132 update_option( 133 'pmprovp_' . $level_id, array( 134 'variable_pricing' => $variable_pricing, 135 'min_price' => $min_price, 136 'max_price' => $max_price, 137 'suggested_price' => $suggested_price, 138 ) 139 ); 140 } 141 add_action( 'pmpro_save_membership_level', 'pmprovp_pmpro_save_membership_level' ); 142 143 /* 144 Show form at checkout. 145 */ 146 // override level cost text on checkout page 147 function pmprovp_pmpro_level_cost_text( $text, $level ) { 148 global $pmpro_pages; 149 if ( is_page( $pmpro_pages['checkout'] ) && !did_action( 'pmpro_after_checkout' ) ) { 150 $vpfields = pmprovp_get_settings( $level->id ); 151 if ( ! empty( $vpfields ) && ! empty( $vpfields['variable_pricing'] ) ) { 152 $text = ''; 153 } 154 } 155 156 return $text; 157 } 158 add_filter( 'pmpro_level_cost_text', 'pmprovp_pmpro_level_cost_text', 10, 2 ); 159 160 161 /** 162 * Display Variable Price details column on Membership Levels Settings Page 12 163 * 13 * Sitewide Notice WP is free software: you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by 15 * the Free Software Foundation, either version 2 of the License, or 16 * any later version. 164 */ 165 function pmprovp_pmpro_membership_levels_table_extra_cols_header( $level ) { 166 ?> 167 <th><?php _e( 'Variable Pricing', 'pmpro-variable-pricing' ); ?></th> 168 <?php 169 } 170 add_action( 'pmpro_membership_levels_table_extra_cols_header', 'pmprovp_pmpro_membership_levels_table_extra_cols_header' ); 171 172 /** 173 * Display Variable Price level details on Membership Levels Settings Page 17 174 * 18 * Sitewide Notice WP is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with Sitewide Notice WP. If not, see http://www.gnu.org/licenses/gpl.html 25 * 26 **/ 27 28 defined( 'ABSPATH' ) or exit; 29 30 /** 31 * INCLUDES 32 */ 33 include 'sitewide-notice-settings.php'; //all admin code can be found in here. 34 35 class SiteWide_Notice_WP { 36 37 /** Refers to a single instance of this class. */ 38 private static $instance = null; 39 40 /** 41 * Creates or returns an instance of this class. 42 * 43 * @return Sitewide_Notice_WP A single instance of this class. 44 */ 45 public static function get_instance() { 46 if ( null == self::$instance ) { 47 self::$instance = new self; 48 self::$instance->hooks(); 49 } 50 return self::$instance; 51 } // end get_instance; 52 53 /** 54 * Initializes the plugin by setting localization, filters, and administration functions. 55 */ 56 private function __construct() { 57 58 } //end of construct 59 60 61 private static function hooks() { 62 global $pagenow; 63 64 //run this code regardless if the actual banner is activated or not. 65 add_action( 'init', array( 'SiteWide_Notice_WP', 'init' ) ); 66 67 $swnza_options = get_option( 'swnza_options' ); 68 69 if ( ( is_array( $swnza_options ) && $swnza_options['active'] ) && !is_admin() && ( $pagenow !== 'wp-login.php' ) ) { 70 add_action( 'wp_footer', array( 'SiteWide_Notice_WP', 'display_sitewide_notice_banner' ) ); 71 add_action( 'wp_enqueue_scripts', array( 'SiteWide_Notice_WP', 'enqueue_scripts' ) ); 72 } 73 } 74 75 public static function init() { 76 if( isset( $_REQUEST['remove_swnza_settings'] ) || !empty( $_REQUEST['remove_swnza_settings'] ) ) { 77 delete_option( 'swnza_options' ); 78 } 79 } 80 81 public static function enqueue_scripts() { 82 wp_enqueue_style( 'swnza_css', plugins_url( '/css/swnza.css', __FILE__ ) ); 83 wp_enqueue_script( 'swnza_css', plugins_url( '/js/jquery_cookie.js', __FILE__ ), array( 'jquery' ), '2.1.4', true ); 84 } 85 86 public static function display_sitewide_notice_banner() { 87 $swnza_options = get_option( 'swnza_options' ); 88 89 if( ( isset( $swnza_options[ 'hide_for_logged_in' ] ) && ! empty( $swnza_options['hide_for_logged_in'] ) ) && is_user_logged_in() ) { 90 return; 91 } 92 93 if( apply_filters( 'swnza_show_banner', true ) && $swnza_options[ 'active' ] ) { 94 95 // If show for PMPro members setting is enabled and user doesn't have membership level, return. 96 if( isset( $swnza_options['show_for_members'] ) && ! empty( $swnza_options['show_for_members'] ) && !pmpro_hasMembershipLevel() ) { 97 return; 98 } ?> 99 100 <?php if ( ! empty( $swnza_options['dismissible'] ) ) { ?> 101 <!-- SiteWide Notice WP Cookies --> 102 <script type="text/javascript"> 103 jQuery(document).ready(function($){ 104 if( Cookies.get('swnza_hide_banner_cookie') != 1 ) { 105 $('.swnza_banner').show(); 106 } 107 108 $('#swnza_close_button_link').click(function(){ 109 Cookies.set('swnza_hide_banner_cookie', 1, { expires: 1, path: '/' }); //expire the cookie after 24 hours. 110 $('.swnza_banner').hide(); 111 }); 112 }); 113 </script> 114 <?php }?> 115 116 117 118 <!-- SiteWide Notice WP Custom CSS --> 119 <style type="text/css"> 120 .swnza_banner{ 121 position:fixed; 122 min-height:50px; 123 height:auto; 124 width:100%; 125 background:<?php echo esc_attr( $swnza_options['background_color'] ); ?>; 126 padding-top:10px; 127 z-index:999; 128 display:block; 129 } 130 131 <?php if( isset( $swnza_options['show_on_top'] ) && ! empty( $swnza_options['show_on_top'] ) ) { ?> 132 .admin-bar .swnza_banner { margin-top:32px; } 133 .swnza_banner { top:0; } 134 .swnza_close_button { bottom:-10px; } 135 <?php } else { ?> 136 .swnza_banner{ bottom:0; } 137 .swnza_close_button { top:-10px;} 138 <?php } ?> 139 140 .swnza_banner p { 141 color: <?php echo esc_attr( $swnza_options['font_color'] ); ?>; 142 text-align:center; 143 z-index:1000; 144 font-size:20px; 145 display:block; 146 margin: 0; 147 } 148 149 <?php if ( ! empty( $swnza_options['dismissible'] ) ) { ?> 150 .swnza_close_button{ 151 display:block; 152 position:absolute; 153 right:5px; 154 width:20px; 155 height:20px; 156 background:url("<?php echo plugins_url( 'images/close-button.svg', __FILE__ ); ?>") no-repeat center center; 157 background-color:white; 158 border-radius:100px; 159 border: 1px solid #000; 160 } 161 162 .swnza_close_button:hover{ 163 cursor: pointer; 164 } 165 166 <?php } ?> 167 168 #swnza_banner_text{ 169 margin-top:0; 170 } 171 172 <?php if( $swnza_options[ 'show_on_mobile' ] != 1 ) { ?> 173 @media all and (max-width: 500px){ 174 .swnza_banner{ 175 display: none; 176 } 177 } 178 <?php } ?> 179 </style> 180 <?php } ?> 181 182 <div class="swnza_banner" id="swnza_banner_id" style="display:none;"> 183 <p id="swnza_banner_text"><?php echo htmlspecialchars_decode( stripslashes( apply_filters( 'swnza_banner_text', $swnza_options['message'] ) ) ); ?></p> 184 <a id="swnza_close_button_link" class="swnza_close_button"></a> 185 </div> 186 <?php } 187 } //end of class 188 189 Sitewide_Notice_WP::get_instance(); 175 */ 176 function pmprovp_pmpro_membership_levels_table_extra_cols_body( $level ) { ?> 177 <td> 178 <?php 179 // get variable pricing info 180 $vpfields = pmprovp_get_settings( $level->id ); 181 182 // No variable pricing? Show "--" and return. 183 if ( empty( $vpfields ) || empty( $vpfields['variable_pricing'] ) ) { 184 echo '--'; 185 return; 186 } 187 188 // Get the variable pricing data from the level. 189 $min_price = $vpfields['min_price']; 190 $max_price = $vpfields['max_price']; 191 $suggested_price = $vpfields['suggested_price']; 192 193 // Setup price text description based on price ranges. 194 if ( ! empty( $max_price ) && ! empty( $min_price ) ) { 195 $price_text_description = sprintf( 196 __( 'Between %1$s and %2$s.', 'pmpro-variable-pricing' ), 197 esc_html( pmpro_formatPrice( $vpfields['min_price'] ) ), 198 esc_html( pmpro_formatPrice( $vpfields['max_price'] ) ) 199 ); 200 } elseif( ! empty( $min_price ) && empty( $max_price ) ) { 201 $price_text_description = sprintf( 202 __( 'Minimum price of %s or higher.', 'pmpro-variable-pricing' ), 203 esc_html( pmpro_formatPrice( $vpfields['min_price'] ) ) 204 ); 205 } elseif( ! empty( $max_price ) && empty( $min_price ) ) { 206 $price_text_description = sprintf( 207 __( '%s or lower.', 'pmpro-variable-pricing' ), 208 esc_html( pmpro_formatPrice( $vpfields['max_price'] ) ) 209 ); 210 } else { 211 $price_text_description = __( 'Any', 'pmpro-variable-pricing' ); 212 } 213 214 // Show suggested price if specified. 215 if ( ! empty( $suggested_price ) ) { 216 $price_text_description .= '<br />'; 217 $price_text_description .= sprintf( 218 __( 'Suggested Price: %s.', 'pmpro-variable-pricing' ), 219 esc_html( pmpro_formatPrice( $vpfields['suggested_price'] ) ) 220 ); 221 } 222 223 // Display the price text and suggested price in the row. 224 echo $price_text_description; 225 ?> 226 </td> 227 <?php 228 } 229 add_action( 'pmpro_membership_levels_table_extra_cols_body', 'pmprovp_pmpro_membership_levels_table_extra_cols_body' ); 230 231 // show form 232 function pmprovp_pmpro_checkout_after_level_cost() { 233 global $pmpro_level, $gateway, $pmpro_review, $pmpro_currencies, $pmpro_currency, $pmpro_currency_symbol; 234 235 // get variable pricing info 236 $vpfields = pmprovp_get_settings( $pmpro_level->id ); 237 238 // no variable pricing? just return 239 if ( empty( $vpfields ) || empty( $vpfields['variable_pricing'] ) ) { 240 return; 241 } 242 243 // okay, now we're showing the form 244 $min_price = $vpfields['min_price']; 245 $max_price = $vpfields['max_price']; 246 $suggested_price = $vpfields['suggested_price']; 247 248 249 if ( isset( $_REQUEST['price'] ) ) { 250 $price = preg_replace( '[^0-9\.]', '', floatval( $_REQUEST['price'] ) ); 251 } else { 252 $price = $suggested_price; 253 } 254 255 // setup price text description based on price ranges 256 if ( ! empty( $max_price ) && ! empty( $min_price ) ) { 257 $price_text_description = sprintf( 258 __( 'Enter a price between %1$s and %2$s.', 'pmpro-variable-pricing' ), 259 esc_html( pmpro_formatPrice( $vpfields['min_price'] ) ), 260 esc_html( pmpro_formatPrice( $vpfields['max_price'] ) ) 261 ); 262 } elseif( ! empty( $min_price ) && empty( $max_price ) ) { 263 $price_text_description = sprintf( 264 __( 'Enter a minimum price of %s or higher.', 'pmpro-variable-pricing' ), 265 esc_html( pmpro_formatPrice( $vpfields['min_price'] ) ) 266 ); 267 } elseif( ! empty( $max_price ) && empty( $min_price ) ) { 268 $price_text_description = sprintf( 269 __( 'Enter a price of %s or lower.', 'pmpro-variable-pricing' ), 270 esc_html( pmpro_formatPrice( $vpfields['max_price'] ) ) 271 ); 272 } else { 273 $price_text_description = __( 'Enter a price for your membership', 'pmpro-variable-pricing' ); 274 } 275 276 /** 277 * @filter pmpropvp_checkout_price_description - Filter to modify the variable price description text 278 * @param string $price_text_description 279 */ 280 $price_text_description = apply_filters( 'pmpropvp_checkout_price_description', $price_text_description ); 281 282 if ( empty( $pmpro_currencies[$pmpro_currency]['position'] ) || $pmpro_currencies[$pmpro_currency]['position'] == 'left' ) { 283 $price_text = sprintf( 284 __( 'Your price: %s', 'pmpro-variable-pricing' ), 285 esc_html( $pmpro_currency_symbol ) 286 ); 287 } else { 288 $price_text = __( 'Your price:', 'pmpro-variable-pricing' ); 289 } 290 291 /** 292 * @filter pmprovp_checkout_price_input_label - Filter to modify the label for the Variable Price input box on the checkout page 293 * @param string $price_text 294 */ 295 $price_text = apply_filters( 'pmprovp_checkout_price_input_label', $price_text ); 296 297 ?> 298 <div class="pmprovp"> 299 <p class="pmprovp_price_text_description"><?php echo esc_html( $price_text_description ); ?></p> 300 <p class="pmprovp_price_input"><?php echo esc_html( $price_text ); ?> <input type="text" id="price" name="price" size="10" value="<?php esc_attr_e( $price ); ?>" style="width:auto;" <?php if( $pmpro_review ) { ?> readonly <?php } ?>/> <?php if ( !empty( $pmpro_currencies[$pmpro_currency]['position'] ) && $pmpro_currencies[$pmpro_currency]['position'] == 'right' ) { echo esc_html( $pmpro_currency_symbol ); } ?> 301 <span id="pmprovp-warning" class="pmpro_message pmpro_alert" style="display:none;"><small><?php echo esc_html( $price_text_description ); ?></small></span></p> 302 </div> <!-- end .pmprovp --> 303 <?php 304 } 305 add_action( 'pmpro_checkout_after_level_cost', 'pmprovp_pmpro_checkout_after_level_cost' ); 306 307 // set price 308 function pmprovp_pmpro_checkout_level( $level ) { 309 // Get variable pricing info. 310 $vpfields = pmprovp_get_settings( $level->id ); 311 312 // Make sure level has variable pricing. 313 if ( empty( $vpfields ) || empty( $vpfields['variable_pricing'] ) ) { 314 return $level; 315 } 316 317 if ( isset( $_REQUEST['price'] ) ) { 318 $price = preg_replace( '[^0-9\.\,]', '', floatval( $_REQUEST['price'] ) ); 319 } 320 321 if ( isset( $price ) ) { 322 $level->initial_payment = $price; 323 324 if ( $level->billing_amount > 0 ) { 325 $level->billing_amount = $price; 326 } 327 } 328 329 return $level; 330 } 331 add_filter( 'pmpro_checkout_level', 'pmprovp_pmpro_checkout_level' ); 332 333 /** 334 * Check if price is between min and max value. 335 * If no max value is set, set it to unlimited. 336 */ 337 function pmprovp_pmpro_registration_checks( $continue ) { 338 // only bother if we are continuing already 339 if ( $continue ) { 340 global $pmpro_currency_symbol, $pmpro_msg, $pmpro_msgt; 341 342 // was a price passed in? 343 if ( isset( $_REQUEST['price'] ) ) { 344 // get values 345 $level = pmpro_getLevelAtCheckout(); 346 $level_id = empty( $level->id ) ? null : intval( $level->id ); 347 $vpfields = pmprovp_get_settings( $level_id ); 348 349 // Bail if the Variable Pricing is not set for this level. 350 if( empty( $vpfields['variable_pricing'] ) ){ 351 return $continue; 352 } 353 354 // get price 355 $price = preg_replace( '[^0-9\.]', '', floatval( $_REQUEST['price'] ) ); 356 357 // check that the price falls between the min and max 358 if ( (double) $price < (double) $vpfields['min_price'] ) { 359 $pmpro_msg = sprintf( 360 __( 'The lowest accepted price is %1$s%2$s. Please enter a new amount.', 'pmpro-variable-pricing' ), 361 esc_html( $pmpro_currency_symbol ), 362 esc_html( $vpfields['min_price'] ) 363 ); 364 $pmpro_msgt = 'pmpro_error'; 365 $continue = false; 366 } elseif ( ! empty( $vpfields['max_price'] ) && ( (double) $price > (double) $vpfields['max_price'] ) ) { 367 $pmpro_msg = sprintf( 368 __( 'The highest accepted price is %1$s%2$s. Please enter a new amount.', 'pmpro-variable-pricing' ), 369 esc_html( $pmpro_currency_symbol ), 370 esc_html( $vpfields['max_price'] ) 371 ); 372 $pmpro_msgt = 'pmpro_error'; 373 $continue = false; 374 } 375 376 // all good! 377 } 378 } 379 380 return $continue; 381 } 382 add_filter( 'pmpro_registration_checks', 'pmprovp_pmpro_registration_checks' ); 383 384 // save fields in session for PayPal Express/etc 385 function pmprovp_pmpro_paypalexpress_session_vars() { 386 if ( ! empty( $_REQUEST['price'] ) ) { 387 $_SESSION['price'] = floatval( $_REQUEST['price'] ); 388 } else { 389 $_SESSION['price'] = ''; 390 } 391 } 392 add_action( 'pmpro_paypalexpress_session_vars', 'pmprovp_pmpro_paypalexpress_session_vars' ); 393 add_action( 'pmpro_before_send_to_twocheckout', 'pmprovp_pmpro_paypalexpress_session_vars', 10, 2 ); 394 395 // Load fields from session if available. 396 function pmprovp_init_load_session_vars() { 397 if(function_exists('pmpro_start_session')) { 398 pmpro_start_session(); 399 } 400 401 if ( empty( $_REQUEST['price'] ) && ! empty( $_SESSION['price'] ) ) { 402 $_REQUEST['price'] = floatval( $_SESSION['price'] ); 403 } 404 } 405 add_action( 'pmpro_checkout_preheader_before_get_level_at_checkout', 'pmprovp_init_load_session_vars', 5 ); 406 407 /** 408 * Register and set variables for JavaScript 409 */ 410 function pmprovp_load_scripts() { 411 412 global $gateway, $pmpro_level; 413 414 if ( empty( $pmpro_level ) ) { 415 return; 416 } 417 418 // get variable pricing info 419 $vpfields = pmprovp_get_settings( $pmpro_level->id ); 420 421 // no variable pricing? just return 422 if ( empty( $vpfields ) || empty( $vpfields['variable_pricing'] ) ) { 423 return; 424 } 425 426 // Bail if PMPro is not loaded. 427 if ( ! function_exists( 'pmpro_getGateway' ) ) { 428 return; 429 } 430 431 if ( empty( $gateway ) ) { 432 $gateway = get_option( 'pmpro_gateway' ); 433 } 434 435 wp_register_script( 'pmprovp', plugins_url( 'javascript/pmpro-variable-pricing.js', __FILE__ ), array( 'jquery' ), PMPROVP_VERSION, true ); 436 437 wp_localize_script( 438 'pmprovp', 'pmprovp', array( 439 'settings' => array( 440 'gateway' => pmpro_getGateway(), 441 'gateway_billing' => ( in_array( $gateway, array( 'paypalexpress', 'twocheckout' ) ) !== false ) ? 'false' : 'true', 442 ), 443 'pricing_billing' => ! pmpro_isLevelFree( $pmpro_level ) ? 'true' : 'false', 444 'vp_data' => wp_json_encode( $vpfields ) 445 ) 446 ); 447 } 448 add_action( 'wp_enqueue_scripts', 'pmprovp_load_scripts', 5 ); 449 450 /** 451 * Split register/localize and enqueue operation to simplify unhooking JS from plugin if needed 452 */ 453 function pmprovp_enqueue_scripts() { 454 455 global $pmpro_level; 456 457 if ( empty( $pmpro_level ) ) { 458 return; 459 } 460 461 // get variable pricing info 462 $vpfields = pmprovp_get_settings( $pmpro_level->id ); 463 464 // no variable pricing? just return 465 if ( empty( $vpfields ) || empty( $vpfields['variable_pricing'] ) ) { 466 return; 467 } 468 469 wp_enqueue_script( 'pmprovp' ); 470 } 471 add_action( 'wp_enqueue_scripts', 'pmprovp_enqueue_scripts', 15 ); 472 473 /* 474 Function to add links to the plugin row meta 475 */ 476 function pmprovp_plugin_row_meta( $links, $file ) { 477 if ( strpos( $file, 'pmpro-variable-pricing.php' ) !== false ) { 478 $new_links = array( 479 '<a href="' . esc_url( 'https://www.paidmembershipspro.com/add-ons/variable-pricing-add-on/' ) . '" title="' . esc_attr__( 'View Documentation', 'pmpro-variable-pricing' ) . '">' . esc_html__( 'Docs', 'pmpro-variable-pricing' ) . '</a>', 480 '<a href="' . esc_url( 'https://www.paidmembershipspro.com/support/' ) . '" title="' . esc_attr__( 'Visit Customer Support Forum', 'pmpro-variable-pricing' ). '">' . esc_html__( 'Support', 'pmpro-variable-pricing' ) . '</a>', 481 ); 482 $links = array_merge( $links, $new_links ); 483 } 484 return $links; 485 } 486 add_filter( 'plugin_row_meta', 'pmprovp_plugin_row_meta', 10, 2 ); -
sitewide-notice-wp/trunk/readme.txt
r3191366 r3376123 4 4 Tags: sitewide banner, site banner, banner, notice, sitewide notice, popup banner, simple banner, website banner, website notice, site notice, site message, website message bar, website bar message, message bar 5 5 Requires at least: 5.2 6 Tested up to: 6. 76 Tested up to: 6.8 7 7 Stable tag: 2.4.1 8 8 License: GPLv2 or later
Note: See TracChangeset
for help on using the changeset viewer.