Changeset 3633440 for subscription-system/trunk/subscription-system.php
- Timestamp:
- 08/03/2026 08:36:32 PM (3 months ago)
- File:
-
- 1 edited
-
subscription-system/trunk/subscription-system.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
subscription-system/trunk/subscription-system.php
r3598150 r3633440 17 17 * Plugin URI: https://mediahubster.in/subscription-system 18 18 * Description: A comprehensive subscription management system for WordPress. 19 * Version: 1.0. 1819 * Version: 1.0.20 20 20 * Author: Joe Youngblood 21 21 * Author URI: https://mediahubster.in … … 97 97 98 98 // Define plugin constants 99 define('SUBS_SYS_VERSION', '1.0. 18');99 define('SUBS_SYS_VERSION', '1.0.20'); 100 100 define('SUBS_SYS_PLUGIN_DIR', plugin_dir_path(__FILE__)); 101 101 define('SUBS_SYS_PLUGIN_URL', plugin_dir_url(__FILE__)); 102 102 define('SUBS_SYS_PLUGIN_BASENAME', plugin_basename(__FILE__)); 103 104 /** 105 * Valid cooldown units for the subscribe modal re-show delay. 106 * 107 * @return string[] 108 */ 109 function subs_sys_get_modal_cooldown_units() { 110 return array( 'minutes', 'days', 'weeks', 'months' ); 111 } 112 113 /** 114 * Convert modal cooldown settings to milliseconds for frontend use. 115 * 116 * @param int|null $value Cooldown amount. 117 * @param string|null $unit Cooldown unit. 118 * @return int 119 */ 120 function subs_sys_get_modal_cooldown_ms( $value = null, $unit = null ) { 121 $value = null !== $value ? absint( $value ) : absint( get_option( 'subs_modal_auto_open_cooldown', 60 ) ); 122 $unit = null !== $unit ? sanitize_key( $unit ) : sanitize_key( get_option( 'subs_modal_auto_open_cooldown_unit', 'minutes' ) ); 123 124 if ( $value <= 0 ) { 125 return 0; 126 } 127 128 $seconds_per_unit = array( 129 'minutes' => MINUTE_IN_SECONDS, 130 'days' => DAY_IN_SECONDS, 131 'weeks' => WEEK_IN_SECONDS, 132 'months' => 30 * DAY_IN_SECONDS, 133 ); 134 135 if ( ! isset( $seconds_per_unit[ $unit ] ) ) { 136 $unit = 'minutes'; 137 } 138 139 return $value * $seconds_per_unit[ $unit ] * 1000; 140 } 141 142 /** 143 * Human-readable label for the modal cooldown period. 144 * 145 * @param int|null $value Cooldown amount. 146 * @param string|null $unit Cooldown unit. 147 * @return string 148 */ 149 function subs_sys_get_modal_cooldown_label( $value = null, $unit = null ) { 150 $value = null !== $value ? absint( $value ) : absint( get_option( 'subs_modal_auto_open_cooldown', 60 ) ); 151 $unit = null !== $unit ? sanitize_key( $unit ) : sanitize_key( get_option( 'subs_modal_auto_open_cooldown_unit', 'minutes' ) ); 152 153 if ( $value <= 0 ) { 154 return ''; 155 } 156 157 switch ( $unit ) { 158 case 'days': 159 /* translators: %d: number of days */ 160 return sprintf( _n( '%d day', '%d days', $value, 'subscription-system' ), $value ); 161 case 'weeks': 162 /* translators: %d: number of weeks */ 163 return sprintf( _n( '%d week', '%d weeks', $value, 'subscription-system' ), $value ); 164 case 'months': 165 /* translators: %d: number of months */ 166 return sprintf( _n( '%d month', '%d months', $value, 'subscription-system' ), $value ); 167 default: 168 /* translators: %d: number of minutes */ 169 return sprintf( _n( '%d minute', '%d minutes', $value, 'subscription-system' ), $value ); 170 } 171 } 103 172 104 173 /** … … 141 210 'ajax_url' => admin_url( 'admin-ajax.php' ), 142 211 'nonce' => wp_create_nonce( 'interest_subscription_nonce' ), 143 'auto_open' => (int) get_option( 'subs_modal_auto_open', 0 ), 144 'auto_open_delay' => absint( get_option( 'subs_modal_auto_open_delay', 3 ) ), 145 'hide_fields_logged_in' => (int) get_option( 'subs_modal_hide_fields_logged_in', 1 ), 146 'is_logged_in' => $is_logged_in ? 1 : 0, 147 'i18n' => array( 212 'auto_open' => (int) get_option( 'subs_modal_auto_open', 0 ), 213 'auto_open_delay' => absint( get_option( 'subs_modal_auto_open_delay', 3 ) ), 214 'auto_open_cooldown' => absint( get_option( 'subs_modal_auto_open_cooldown', 60 ) ), 215 'auto_open_cooldown_unit' => sanitize_key( get_option( 'subs_modal_auto_open_cooldown_unit', 'minutes' ) ), 216 'auto_open_cooldown_ms' => subs_sys_get_modal_cooldown_ms(), 217 'auto_open_cooldown_label' => subs_sys_get_modal_cooldown_label(), 218 'hide_fields_logged_in' => (int) get_option( 'subs_modal_hide_fields_logged_in', 1 ), 219 'is_logged_in' => $is_logged_in ? 1 : 0, 220 'i18n' => array( 148 221 'processing' => __( 'Processing...', 'subscription-system' ), 149 222 'submit' => __( 'Subscribe', 'subscription-system' ),
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)