'no', // Off. 'user_id' => '0', // Current. 'date_format' => 'M jS, Y, g:i a T', 'round_to' => '', // Optional rounding. 'offset' => '0', // Optional time offset. 'timezone' => '', // Default timezone; i.e., GMT/UTC. 'future_format' => $mode ? '%%date%%' : ''._x('Access Expires:', 's2member-front', 's2member').' %%date%%', 'past_format' => $mode ? '%%date%%' : ''._x('Access Expired:', 's2member-front', 's2member').' %%date%%', 'next_format' => $mode ? '%%date%%' : ''._x('Next Payment:', 's2member-front', 's2member').' %%date%%', 'empty_format' => $mode ? (in_array($subscr_gateway, array('stripe', 'paypal', 'clickbank'), TRUE) ? _x('N/A', 's2member-front', 's2member') : _x('—', 's2member-front', 's2member')) : '', ), c_ws_plugin__s2member_utils_strings::trim_qts_deep($attr) ); foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; do_action('ws_plugin__s2member_before_sc_eot_details_after_shortcode_atts', get_defined_vars()); unset($__refs, $__v); // Allow variables to be modified by reference. //251223 Sanitize shortcode attributes foreach ($attr as $key => $value) { if (in_array($key, array('user_id', 'offset'), true)) { $attr[$key] = (int) $value; } elseif (in_array($key, array('debug', 'date_format', 'round_to', 'timezone'), true)) { $attr[$key] = sanitize_text_field($value); } elseif (in_array($key, array('future_format', 'past_format', 'next_format', 'empty_format'), true)) { $attr[$key] = wp_kses_post($value); } } // Collect and cache the EOT for this user. $prefix = 's2m_eot_'; // Transient prefix for this shortcode. $hash_vars = $user_id.$subscr_gateway.$subscr_id.$subscr_cid.$auto_eot_time; $transient = $prefix.md5('s2member_sc_eot_'.$mode.serialize($attr).$hash_vars); if(!is_array($eot = get_transient($transient))) { $eot = c_ws_plugin__s2member_utils_users::get_user_eot($user_id, true, $mode); set_transient($transient, $eot, DAY_IN_SECONDS / 2); } if($eot['time'] && (integer)$attr['offset']) $eot['time'] = $eot['time'] + (integer)$attr['offset']; // Initialize EOT details/output format. if($eot['type'] === 'fixed' && $eot['time'] && $eot['tense'] === 'past') $details = $attr['past_format']; else if($eot['type'] === 'fixed' && $eot['time'] && $eot['tense'] === 'future') $details = $attr['future_format']; else if($eot['type'] === 'next' && $eot['time'] && $eot['tense'] === 'future') $details = $attr['next_format']; else $details = $attr['empty_format']; // Initialize EOT details/output date format. $time = null; // Initialize the time calculation. if($eot['time']) // // Do we have a time to work with? { $time = new DateTime(date('Y-m-d H:i:s', $eot['time'])); if($attr['timezone'] && strtoupper($attr['timezone']) !== 'UTC') $time->setTimezone(new DateTimeZone($attr['timezone'])); if($attr['round_to']) $time->modify($attr['round_to']); } if($time && $attr['date_format'] === 'timestamp') $date = (string)$time->getTimestamp(); else if($time && $attr['date_format'] === 'default') $date = $time->format(get_option('date_format')); else if($time && $attr['date_format']) $date = $time->format($attr['date_format']); else if($time) // Default date/time format. $date = $time->format('M jS, Y, g:i a T'); else $date = ''; // Default date; i.e., nothing. $details = str_ireplace('%%date%%', esc_html($date), $details); // Check special considerations and the current mode. if($eot['type'] === 'fixed' && !$GLOBALS['WS_PLUGIN__']['s2member']['o']['auto_eot_system_enabled']) { $details = $attr['empty_format']; // EOTs are disabled on this site. $eot['debug'] = 's2Member\'s Auto-EOT System is disabled on this site.'; } else if($eot['type'] === 'fixed' && $mode === 'next') { $details = $attr['empty_format']; // Empty this. $eot['debug'] = 'No fixed EOT time was found for this user.'; } else if($eot['type'] === 'next' && $mode === 'fixed') { $details = $attr['empty_format']; // Empty this. $eot['debug'] = 'No more payments needed from this user.'; } // Wrapper and debug info... if($details) // Wrapper for CSS styling. $details = ''.$details.''; if(filter_var($attr['debug'], FILTER_VALIDATE_BOOLEAN)) $details .= '
'.esc_html($eot['debug'] ? $eot['debug'] : 'Unknown error.').'
'; // Return the details/output from this shortcode. return apply_filters('ws_plugin__s2member_sc_eot_details', $details, get_defined_vars()); } } }