| 1 |
<?php |
| 2 |
// @codingStandardsIgnoreFile |
| 3 |
/** |
| 4 |
* s2Member's Return Page template handler. |
| 5 |
* |
| 6 |
* Copyright: © 2009-2011 |
| 7 |
* {@link http://websharks-inc.com/ WebSharks, Inc.} |
| 8 |
* (coded in the USA) |
| 9 |
* |
| 10 |
* Released under the terms of the GNU General Public License. |
| 11 |
* You should have received a copy of the GNU General Public License, |
| 12 |
* along with this software. In the main directory, see: /licensing/ |
| 13 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 14 |
* |
| 15 |
* @package s2Member\Return_Templates |
| 16 |
* @since 110720 |
| 17 |
*/ |
| 18 |
if(!defined('WPINC')) // MUST have WordPress. |
| 19 |
exit ('Do not access this file directly.'); |
| 20 |
|
| 21 |
if(!class_exists('c_ws_plugin__s2member_return_templates')) |
| 22 |
{ |
| 23 |
/** |
| 24 |
* s2Member's Return Page template handler. |
| 25 |
* |
| 26 |
* @package s2Member\Return_Templates |
| 27 |
* @since 110720 |
| 28 |
*/ |
| 29 |
class c_ws_plugin__s2member_return_templates |
| 30 |
{ |
| 31 |
/** |
| 32 |
* Handles Return templates w/ response message. |
| 33 |
* |
| 34 |
* @package s2Member\Return_Templates |
| 35 |
* @since 110720 |
| 36 |
* |
| 37 |
* @param string $template Optional A Subscr. Gateway code should be used as the template name, or `default` is a multipurpose template. Defaults to `default`. Used in template selection. |
| 38 |
* @param string $response Optional. Response message to fill template with, using the Replacement Code `%%response%%` inside the template file. Defaults to: `Thank you. Please click the link below.`. |
| 39 |
* @param string $continue_html Optional. The HTML value of the continuation link presented within the template using Replacement Code `%%continue%%`. Defaults to: `Continue`. |
| 40 |
* @param string $continue_link Optional. The HREF value for the continuation link presented within the template using Replacement Code `%%continue%%`. Defaults to: ``home_url ('/', 'http')``. |
| 41 |
* |
| 42 |
* @return string The full HTML code of the template. All Replacement Codes inside the template file will have already been filled by this routine. |
| 43 |
*/ |
| 44 |
public static function return_template($template = '', $response = '', $continue_html = '', $continue_link = '') |
| 45 |
{ |
| 46 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 47 |
do_action('ws_plugin__s2member_before_return_template', get_defined_vars()); |
| 48 |
unset($__refs, $__v); // Housekeeping. |
| 49 |
|
| 50 |
$template = ($template) ? $template : 'default'; |
| 51 |
$continue_link = ($continue_link) ? $continue_link : home_url('/', 'http'); |
| 52 |
$continue_html = ($continue_html) ? $continue_html : _x('Continue', 's2member-front', 's2member'); |
| 53 |
$response = ($response) ? $response : _x('Thank you. Please click the link below.', 's2member-front', 's2member'); |
| 54 |
|
| 55 |
$custom_template = (is_file(TEMPLATEPATH.'/'.$template.'-return.php')) ? TEMPLATEPATH.'/'.$template.'-return.php' : ''; |
| 56 |
$custom_template = (is_file(get_stylesheet_directory().'/'.$template.'-return.php')) ? get_stylesheet_directory().'/'.$template.'-return.php' : $custom_template; |
| 57 |
$custom_template = (is_file(WP_CONTENT_DIR.'/'.$template.'-return.php')) ? WP_CONTENT_DIR.'/'.$template.'-return.php' : $custom_template; |
| 58 |
|
| 59 |
$custom_template = (!$custom_template && is_file(TEMPLATEPATH.'/default-return.php')) ? TEMPLATEPATH.'/default-return.php' : $custom_template; |
| 60 |
$custom_template = (!$custom_template && is_file(get_stylesheet_directory().'/default-return.php')) ? get_stylesheet_directory().'/default-return.php' : $custom_template; |
| 61 |
$custom_template = (!$custom_template && is_file(WP_CONTENT_DIR.'/default-return.php')) ? WP_CONTENT_DIR.'/default-return.php' : $custom_template; |
| 62 |
|
| 63 |
$specific_template = ($custom_template) ? $custom_template : ((is_file($_default_specific_template = dirname(dirname(__FILE__)).'/templates/returns/'.$template.'-return.php')) ? $_default_specific_template : ''); |
| 64 |
|
| 65 |
$code = trim(file_get_contents((($specific_template) ? $specific_template : ($_default_template = dirname(dirname(__FILE__)).'/templates/returns/default-return.php')))); |
| 66 |
$code = trim(((!$custom_template || !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) ? c_ws_plugin__s2member_utilities::evl($code) : $code)); |
| 67 |
|
| 68 |
$doctype_html_head = c_ws_plugin__s2member_utils_html::doctype_html_head(get_bloginfo('name'), 'ws_plugin__s2member_during_return_template_head_'.(($specific_template) ? basename($specific_template) : 'default-return.php')); |
| 69 |
$code = preg_replace('/%%doctype_html_head%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(apply_filters('ws_plugin__s2member_return_template_doctype_html_head', $doctype_html_head, get_defined_vars())), $code); |
| 70 |
|
| 71 |
$code = preg_replace('/%%header%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(apply_filters('ws_plugin__s2member_return_template_header', sprintf(_x('[ %s ] <strong><em>says…</em></strong>', 's2member-front', 's2member'), esc_html($_SERVER['HTTP_HOST'])), get_defined_vars())), $code); |
| 72 |
|
| 73 |
$code = preg_replace('/%%response%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(apply_filters('ws_plugin__s2member_return_template_response', $response, get_defined_vars())), $code); |
| 74 |
$code = preg_replace('/%%continue%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(apply_filters('ws_plugin__s2member_return_template_continue', '<a href="'.esc_attr($continue_link).'">'.$continue_html.'</a>', get_defined_vars())), $code); |
| 75 |
$code = preg_replace('/%%support%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(apply_filters('ws_plugin__s2member_return_template_support', sprintf(_x('If you need assistance, please <a href="%s" target="_blank">contact support</a>.', 's2member-front', 's2member'), esc_attr($GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_support_link'])), get_defined_vars())), $code); |
| 76 |
$code = preg_replace('/%%tracking%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(apply_filters('ws_plugin__s2member_return_template_tracking', c_ws_plugin__s2member_tracking_codes::generate_all_tracking_codes(), get_defined_vars())), $code); |
| 77 |
|
| 78 |
return apply_filters('ws_plugin__s2member_return_template', $code, get_defined_vars()); |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
|