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