| 1 |
<?php |
| 2 |
// @codingStandardsIgnoreFile |
| 3 |
/** |
| 4 |
* Tracking Codes. |
| 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\Tracking |
| 16 |
* @since 3.5 |
| 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_tracking_codes")) |
| 22 |
{ |
| 23 |
/** |
| 24 |
* Tracking Codes. |
| 25 |
* |
| 26 |
* @package s2Member\Tracking |
| 27 |
* @since 3.5 |
| 28 |
*/ |
| 29 |
class c_ws_plugin__s2member_tracking_codes |
| 30 |
{ |
| 31 |
/** |
| 32 |
* Displays Signup Tracking Codes. |
| 33 |
* |
| 34 |
* These are stored inside s2Member's Transient Queue by the IPN processor. |
| 35 |
* |
| 36 |
* Tracking Codes are only displayed/processed one time. |
| 37 |
* s2Member will display Tracking Codes in (1) of these 4 locations: |
| 38 |
* |
| 39 |
* o On the Return URL / Thank-You Page, after returning from your Payment Gateway. |
| 40 |
* o Otherwise, on the Registration Form, after returning from your Payment Gateway. |
| 41 |
* o Otherwise, if possible, on the Login Form *(in the footer)* after Registration is completed. |
| 42 |
* o Otherwise, in the footer of your WordPress theme, as soon as possible; or after the Customer's very first login. |
| 43 |
* |
| 44 |
* @package s2Member\Tracking |
| 45 |
* @since 3.5 |
| 46 |
* |
| 47 |
* @attaches-to ``add_action("login_footer");`` |
| 48 |
* @attaches-to ``add_action("wp_footer");`` |
| 49 |
* @also-called-by {@link s2Member\Tracking\c_ws_plugin__s2member_tracking_codes::generate_all_tracking_codes()} |
| 50 |
*/ |
| 51 |
public static function display_signup_tracking_codes() |
| 52 |
{ |
| 53 |
do_action("ws_plugin__s2member_before_display_signup_tracking_codes", get_defined_vars()); |
| 54 |
|
| 55 |
if((!empty($_COOKIE["s2member_tracking"]) && ($subscr_or_txn_id = c_ws_plugin__s2member_utils_encryption::decrypt($_COOKIE["s2member_tracking"]))) || (($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies) && ($subscr_or_txn_id = $subscr_id))) |
| 56 |
{ |
| 57 |
if(($code = get_transient($transient = "s2m_".md5("s2member_transient_signup_tracking_codes_".$subscr_or_txn_id)))) |
| 58 |
{ |
| 59 |
delete_transient($transient); // Only display this ONE time. Delete transient immediately. |
| 60 |
|
| 61 |
echo '<img src="'.esc_attr(home_url("/?s2member_delete_tracking_cookie=1")).'" alt="." style="width:1px; height:1px; border:0;" />'."\n"; |
| 62 |
|
| 63 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 64 |
do_action("ws_plugin__s2member_during_display_signup_tracking_codes", get_defined_vars()); |
| 65 |
unset($__refs, $__v); |
| 66 |
|
| 67 |
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) |
| 68 |
echo do_shortcode($code)."\n"; // No PHP here. |
| 69 |
|
| 70 |
else // Otherwise, safe to allow PHP code. |
| 71 |
echo do_shortcode(c_ws_plugin__s2member_utilities::evl($code)); |
| 72 |
} |
| 73 |
} |
| 74 |
do_action("ws_plugin__s2member_after_display_signup_tracking_codes", get_defined_vars()); |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Displays Modification Tracking Codes. |
| 79 |
* |
| 80 |
* These are stored inside s2Member's Transient Queue by the IPN processor. |
| 81 |
* |
| 82 |
* Tracking Codes are only displayed/processed one time. |
| 83 |
* s2Member will display Tracking Codes in (1) of these 3 locations: |
| 84 |
* |
| 85 |
* o On the Return URL / Thank-You Page, after returning from your Payment Gateway. |
| 86 |
* o Otherwise, if possible, on the Login Form *(in the footer)* after returning from your Payment Gateway. |
| 87 |
* o Otherwise, in the footer of your WordPress theme, as soon as possible; or after the Customer's next login. |
| 88 |
* |
| 89 |
* @package s2Member\Tracking |
| 90 |
* @since 110815 |
| 91 |
* |
| 92 |
* @attaches-to ``add_action("login_footer");`` |
| 93 |
* @attaches-to ``add_action("wp_footer");`` |
| 94 |
* @also-called-by {@link s2Member\Tracking\c_ws_plugin__s2member_tracking_codes::generate_all_tracking_codes()} |
| 95 |
*/ |
| 96 |
public static function display_modification_tracking_codes() |
| 97 |
{ |
| 98 |
do_action("ws_plugin__s2member_before_display_modification_tracking_codes", get_defined_vars()); |
| 99 |
|
| 100 |
if((!empty($_COOKIE["s2member_tracking"]) && ($subscr_or_txn_id = c_ws_plugin__s2member_utils_encryption::decrypt($_COOKIE["s2member_tracking"]))) || (($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies) && ($subscr_or_txn_id = $subscr_id))) |
| 101 |
{ |
| 102 |
if(($code = get_transient($transient = "s2m_".md5("s2member_transient_modification_tracking_codes_".$subscr_or_txn_id)))) |
| 103 |
{ |
| 104 |
delete_transient($transient); // Only display this ONE time. Delete transient immediately. |
| 105 |
|
| 106 |
echo '<img src="'.esc_attr(home_url("/?s2member_delete_tracking_cookie=1")).'" alt="." style="width:1px; height:1px; border:0;" />'."\n"; |
| 107 |
|
| 108 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 109 |
do_action("ws_plugin__s2member_during_display_modification_tracking_codes", get_defined_vars()); |
| 110 |
unset($__refs, $__v); |
| 111 |
|
| 112 |
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) |
| 113 |
echo do_shortcode($code)."\n"; // No PHP here. |
| 114 |
|
| 115 |
else // Otherwise, safe to allow PHP code. |
| 116 |
echo do_shortcode(c_ws_plugin__s2member_utilities::evl($code)); |
| 117 |
} |
| 118 |
} |
| 119 |
do_action("ws_plugin__s2member_after_display_modification_tracking_codes", get_defined_vars()); |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* Displays Capability Tracking Codes. |
| 124 |
* |
| 125 |
* These are stored inside s2Member's Transient Queue by the IPN processor. |
| 126 |
* |
| 127 |
* Tracking Codes are only displayed/processed one time. |
| 128 |
* s2Member will display Tracking Codes in (1) of these 3 locations: |
| 129 |
* |
| 130 |
* o On the Return URL / Thank-You Page, after returning from your Payment Gateway. |
| 131 |
* o Otherwise, if possible, on the Login Form *(in the footer)* after returning from your Payment Gateway. |
| 132 |
* o Otherwise, in the footer of your WordPress theme, as soon as possible; or after the Customer's next login. |
| 133 |
* |
| 134 |
* @package s2Member\Tracking |
| 135 |
* @since 110815 |
| 136 |
* |
| 137 |
* @attaches-to ``add_action("login_footer");`` |
| 138 |
* @attaches-to ``add_action("wp_footer");`` |
| 139 |
* @also-called-by {@link s2Member\Tracking\c_ws_plugin__s2member_tracking_codes::generate_all_tracking_codes()} |
| 140 |
*/ |
| 141 |
public static function display_ccap_tracking_codes() |
| 142 |
{ |
| 143 |
do_action("ws_plugin__s2member_before_display_ccap_tracking_codes", get_defined_vars()); |
| 144 |
|
| 145 |
if((!empty($_COOKIE["s2member_tracking"]) && ($subscr_or_txn_id = c_ws_plugin__s2member_utils_encryption::decrypt($_COOKIE["s2member_tracking"]))) || (($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies) && ($subscr_or_txn_id = $subscr_id))) |
| 146 |
{ |
| 147 |
if(($code = get_transient($transient = "s2m_".md5("s2member_transient_ccap_tracking_codes_".$subscr_or_txn_id)))) |
| 148 |
{ |
| 149 |
delete_transient($transient); // Only display this ONE time. Delete transient immediately. |
| 150 |
|
| 151 |
echo '<img src="'.esc_attr(home_url("/?s2member_delete_tracking_cookie=1")).'" alt="." style="width:1px; height:1px; border:0;" />'."\n"; |
| 152 |
|
| 153 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 154 |
do_action("ws_plugin__s2member_during_display_ccap_tracking_codes", get_defined_vars()); |
| 155 |
unset($__refs, $__v); |
| 156 |
|
| 157 |
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) |
| 158 |
echo do_shortcode($code)."\n"; // No PHP here. |
| 159 |
|
| 160 |
else // Otherwise, safe to allow PHP code. |
| 161 |
echo do_shortcode(c_ws_plugin__s2member_utilities::evl($code)); |
| 162 |
} |
| 163 |
} |
| 164 |
do_action("ws_plugin__s2member_after_display_ccap_tracking_codes", get_defined_vars()); |
| 165 |
} |
| 166 |
|
| 167 |
/** |
| 168 |
* Displays Specific Post/Page Tracking Codes. |
| 169 |
* |
| 170 |
* These are stored inside s2Member's Transient Queue, by BOTH the IPN & Return-Data processors. |
| 171 |
* |
| 172 |
* Specific Post/Page Tracking Codes are only displayed/processed one time. |
| 173 |
* s2Member will display Tracking Codes in the footer of your theme. |
| 174 |
* |
| 175 |
* @package s2Member\Tracking |
| 176 |
* @since 3.5 |
| 177 |
* |
| 178 |
* @attaches-to ``add_action("login_footer");`` |
| 179 |
* @attaches-to ``add_action("wp_footer");`` |
| 180 |
* @also-called-by {@link s2Member\Tracking\c_ws_plugin__s2member_tracking_codes::generate_all_tracking_codes()} |
| 181 |
* |
| 182 |
* @return null After displaying possible Tracking Code(s). |
| 183 |
*/ |
| 184 |
public static function display_sp_tracking_codes() |
| 185 |
{ |
| 186 |
do_action("ws_plugin__s2member_before_display_sp_tracking_codes", get_defined_vars()); |
| 187 |
|
| 188 |
if(!empty($_COOKIE["s2member_sp_tracking"]) && ($txn_id = c_ws_plugin__s2member_utils_encryption::decrypt($_COOKIE["s2member_sp_tracking"]))) |
| 189 |
{ |
| 190 |
if(($code = get_transient($transient = "s2m_".md5("s2member_transient_sp_tracking_codes_".$txn_id)))) |
| 191 |
{ |
| 192 |
delete_transient($transient); // Only display this ONE time. Delete transient immediately. |
| 193 |
|
| 194 |
echo '<img src="'.esc_attr(home_url("/?s2member_delete_sp_tracking_cookie=1")).'" alt="." style="width:1px; height:1px; border:0;" />'."\n"; |
| 195 |
|
| 196 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 197 |
do_action("ws_plugin__s2member_during_display_sp_tracking_codes", get_defined_vars()); |
| 198 |
unset($__refs, $__v); |
| 199 |
|
| 200 |
if(is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) |
| 201 |
echo $code."\n"; // No PHP here. |
| 202 |
|
| 203 |
else // Otherwise, it's safe to allow PHP code. |
| 204 |
eval("?>".$code); |
| 205 |
} |
| 206 |
} |
| 207 |
do_action("ws_plugin__s2member_after_display_sp_tracking_codes", get_defined_vars()); |
| 208 |
} |
| 209 |
|
| 210 |
/** |
| 211 |
* Generates/returns all Tracking Codes integrated with s2Member. |
| 212 |
* |
| 213 |
* This method may be used in areas where s2Member needs to build tracking codes in a more dynamic way. |
| 214 |
* |
| 215 |
* @package s2Member\Tracking |
| 216 |
* @since 110720 |
| 217 |
* |
| 218 |
* @return string HTML output for all Tracking Codes integrated with s2Member. |
| 219 |
*/ |
| 220 |
public static function generate_all_tracking_codes() |
| 221 |
{ |
| 222 |
ob_start(); // Begin output buffering so we can "return". |
| 223 |
|
| 224 |
c_ws_plugin__s2member_tracking_codes::display_signup_tracking_codes(); |
| 225 |
c_ws_plugin__s2member_tracking_codes::display_modification_tracking_codes(); |
| 226 |
c_ws_plugin__s2member_tracking_codes::display_ccap_tracking_codes(); |
| 227 |
c_ws_plugin__s2member_tracking_codes::display_sp_tracking_codes(); |
| 228 |
|
| 229 |
return apply_filters("ws_plugin__s2member_generate_all_tracking_codes", ob_get_clean(), get_defined_vars()); |
| 230 |
} |
| 231 |
} |
| 232 |
} |
| 233 |
|