| 1 |
<?php |
| 2 |
/** |
| 3 |
* s2Member's Return Page template handler. |
| 4 |
* |
| 5 |
* Copyright: © 2009-2011 |
| 6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.} |
| 7 |
* ( coded in the USA ) |
| 8 |
* |
| 9 |
* Released under the terms of the GNU General Public License. |
| 10 |
* You should have received a copy of the GNU General Public License, |
| 11 |
* along with this software. In the main directory, see: /licensing/ |
| 12 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 13 |
* |
| 14 |
* @package s2Member\Return_Templates |
| 15 |
* @since 110720 |
| 16 |
*/ |
| 17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"])) |
| 18 |
exit ("Do not access this file directly."); |
| 19 |
/**/ |
| 20 |
if (!class_exists ("c_ws_plugin__s2member_return_templates")) |
| 21 |
{ |
| 22 |
/** |
| 23 |
* s2Member's Return Page template handler. |
| 24 |
* |
| 25 |
* @package s2Member\Return_Templates |
| 26 |
* @since 110720 |
| 27 |
*/ |
| 28 |
class c_ws_plugin__s2member_return_templates |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Handles Return templates w/ response message. |
| 32 |
* |
| 33 |
* @package s2Member\Return_Templates |
| 34 |
* @since 110720 |
| 35 |
* |
| 36 |
* @param str $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. |
| 37 |
* @param str $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.`. |
| 38 |
* @param str $continue_html Optional. The HTML value of the continuation link presented within the template using Replacement Code `%%continue%%`. Defaults to: `Continue`. |
| 39 |
* @param str $continue_link Optional. The HREF value for the continuation link presented within the template using Replacement Code `%%continue%%`. Defaults to: ``home_url ("/")``. |
| 40 |
* @return str The full HTML code of the template. All Replacement Codes inside the template file will have already been filled by this routine. |
| 41 |
*/ |
| 42 |
public static function return_template ($template = FALSE, $response = FALSE, $continue_html = FALSE, $continue_link = FALSE) |
| 43 |
{ |
| 44 |
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 45 |
do_action ("ws_plugin__s2member_before_return_template", get_defined_vars ()); |
| 46 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 47 |
/**/ |
| 48 |
$template = ($template) ? $template : "default"; |
| 49 |
$continue_html = ($continue_html) ? $continue_html : "Continue"; |
| 50 |
$continue_link = ($continue_link) ? $continue_link : home_url ("/"); |
| 51 |
$response = ($response) ? $response : "Thank you. Please click the link below."; |
| 52 |
/**/ |
| 53 |
$custom_template = (file_exists (TEMPLATEPATH . "/" . $template . "-return.html")) ? TEMPLATEPATH . "/" . $template . "-return.html" : false; |
| 54 |
$custom_template = (file_exists (TEMPLATEPATH . "/" . $template . "-return.php")) ? TEMPLATEPATH . "/" . $template . "-return.php" : $custom_template; |
| 55 |
$custom_template = (file_exists (WP_CONTENT_DIR . "/" . $template . "-return.html")) ? WP_CONTENT_DIR . "/" . $template . "-return.html" : $custom_template; |
| 56 |
$custom_template = (file_exists (WP_CONTENT_DIR . "/" . $template . "-return.php")) ? WP_CONTENT_DIR . "/" . $template . "-return.php" : $custom_template; |
| 57 |
/**/ |
| 58 |
$custom_template = (!$custom_template && file_exists (TEMPLATEPATH . "/default-return.html")) ? TEMPLATEPATH . "/default-return.html" : $custom_template; |
| 59 |
$custom_template = (!$custom_template && file_exists (TEMPLATEPATH . "/default-return.php")) ? TEMPLATEPATH . "/default-return.php" : $custom_template; |
| 60 |
$custom_template = (!$custom_template && file_exists (WP_CONTENT_DIR . "/default-return.html")) ? WP_CONTENT_DIR . "/default-return.html" : $custom_template; |
| 61 |
$custom_template = (!$custom_template && file_exists (WP_CONTENT_DIR . "/default-return.php")) ? WP_CONTENT_DIR . "/default-return.php" : $custom_template; |
| 62 |
/**/ |
| 63 |
$specific_template = ($custom_template) ? $custom_template : ((file_exists ($specific_template = dirname (dirname (__FILE__)) . "/templates/returns/" . $template . "-return.html")) ? $specific_template : false); |
| 64 |
/**/ |
| 65 |
$code = trim (file_get_contents ((($specific_template) ? $specific_template : dirname (dirname (__FILE__)) . "/templates/returns/default-return.html"))); |
| 66 |
$code = (!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.html")); |
| 69 |
$code = preg_replace ("/%%doctype_html_head%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (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_ds (apply_filters ("ws_plugin__s2member_return_template_header", '[ ' . esc_html ($_SERVER["HTTP_HOST"]) . ' ] <strong><em>says…</em></strong>', get_defined_vars ())), $code); |
| 72 |
/**/ |
| 73 |
$code = preg_replace ("/%%response%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (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_ds (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_ds (apply_filters ("ws_plugin__s2member_return_template_support", 'If you need assistance, please <a href="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_support_link"]) . '" target="_blank">contact support</a>.', get_defined_vars ())), $code); |
| 76 |
$code = preg_replace ("/%%tracking%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (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 |
?> |