| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: MailChimp |
| 4 |
Plugin URI: http://www.mailchimp.com/plugins/mailchimp-wordpress-plugin/ |
| 5 |
Description: The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list. |
| 6 |
Version: 1.2.8 |
| 7 |
Author: MailChimp and Crowd Favorite |
| 8 |
Author URI: http://mailchimp.com/api/ |
| 9 |
*/ |
| 10 |
/* Copyright 2008-2012 MailChimp.com (email : api@mailchimp.com) |
| 11 |
|
| 12 |
This program is free software; you can redistribute it and/or modify |
| 13 |
it under the terms of the GNU General Public License as published by |
| 14 |
the Free Software Foundation; either version 2 of the License, or |
| 15 |
(at your option) any later version. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, |
| 18 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
GNU General Public License for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License |
| 23 |
along with this program; if not, write to the Free Software |
| 24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
*/ |
| 26 |
|
| 27 |
// Version constant for easy CSS refreshes |
| 28 |
define('MCSF_VER', '1.2.8'); |
| 29 |
|
| 30 |
// What's our permission (capability) threshold |
| 31 |
define('MCSF_CAP_THRESHOLD', 'manage_options'); |
| 32 |
|
| 33 |
// Define our location constants, both MCSF_DIR and MCSF_URL |
| 34 |
mailchimpSF_where_am_i(); |
| 35 |
|
| 36 |
// Get our MailChimp API class in scope |
| 37 |
if (!class_exists('mailchimpSF_MCAPI')) { |
| 38 |
require_once('miniMCAPI.class.php'); |
| 39 |
} |
| 40 |
|
| 41 |
// includes the widget code so it can be easily called either normally or via ajax |
| 42 |
include_once('mailchimp_widget.php'); |
| 43 |
|
| 44 |
// includes the backwards compatibility functions |
| 45 |
include_once('mailchimp_compat.php'); |
| 46 |
|
| 47 |
/** |
| 48 |
* Do the following plugin setup steps here |
| 49 |
* |
| 50 |
* Internationalization |
| 51 |
* Resource (JS & CSS) enqueuing |
| 52 |
* |
| 53 |
* @return void |
| 54 |
*/ |
| 55 |
function mailchimpSF_plugin_init() { |
| 56 |
// Internationalize the plugin |
| 57 |
$textdomain = 'mailchimp_i18n'; |
| 58 |
$locale = apply_filters( 'plugin_locale', get_locale(), $textdomain); |
| 59 |
load_textdomain('mailchimp_i18n', MCSF_LANG_DIR.$textdomain.'-'.$locale.'.mo'); |
| 60 |
|
| 61 |
// Bring in our appropriate JS and CSS resources |
| 62 |
mailchimpSF_load_resources(); |
| 63 |
} |
| 64 |
add_action( 'init', 'mailchimpSF_plugin_init' ); |
| 65 |
|
| 66 |
|
| 67 |
/** |
| 68 |
* Add the settings link to the MailChimp plugin row |
| 69 |
* |
| 70 |
* @param array $links - Links for the plugin |
| 71 |
* @return array - Links |
| 72 |
*/ |
| 73 |
function mailchimpSD_plugin_action_links($links) { |
| 74 |
$settings_page = add_query_arg(array('page' => 'mailchimpSF_options'), admin_url('options-general.php')); |
| 75 |
$settings_link = '<a href="'.esc_url($settings_page).'">'.__('Settings', 'mailchimp_i18n' ).'</a>'; |
| 76 |
array_unshift($links, $settings_link); |
| 77 |
return $links; |
| 78 |
} |
| 79 |
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'mailchimpSD_plugin_action_links', 10, 1); |
| 80 |
|
| 81 |
/** |
| 82 |
* Loads the appropriate JS and CSS resources depending on |
| 83 |
* settings and context (admin or not) |
| 84 |
* |
| 85 |
* @return void |
| 86 |
*/ |
| 87 |
function mailchimpSF_load_resources() { |
| 88 |
// JS |
| 89 |
if (get_option('mc_use_javascript') == 'on') { |
| 90 |
if (!is_admin()) { |
| 91 |
wp_enqueue_script('jquery_scrollto', MCSF_URL.'js/scrollTo.js', array('jquery'), MCSF_VER); |
| 92 |
wp_enqueue_script('mailchimpSF_main_js', MCSF_URL.'js/mailchimp.js', array('jquery', 'jquery-form'), MCSF_VER); |
| 93 |
// some javascript to get ajax version submitting to the proper location |
| 94 |
global $wp_scripts; |
| 95 |
$wp_scripts->localize('mailchimpSF_main_js', 'mailchimpSF', array( |
| 96 |
'ajax_url' => trailingslashit(home_url()), |
| 97 |
)); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
if (get_option('mc_use_datepicker') == 'on' && !is_admin()) { |
| 102 |
// Datepicker theme |
| 103 |
wp_enqueue_style('flick', MCSF_URL.'/css/flick/flick.css'); |
| 104 |
// Datepicker JS |
| 105 |
wp_enqueue_script('datepicker', MCSF_URL.'/js/datepicker.js', array('jquery','jquery-ui-core')); |
| 106 |
} |
| 107 |
|
| 108 |
wp_enqueue_style('mailchimpSF_main_css', home_url('?mcsf_action=main_css&ver='.MCSF_VER)); |
| 109 |
wp_enqueue_style('mailchimpSF_ie_css', MCSF_URL.'css/ie.css'); |
| 110 |
global $wp_styles; |
| 111 |
$wp_styles->add_data( 'mailchimpSF_ie_css', 'conditional', 'IE' ); |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
/** |
| 116 |
* Loads resources for the MailChimp admin page |
| 117 |
* |
| 118 |
* @return void |
| 119 |
*/ |
| 120 |
function mc_admin_page_load_resources() { |
| 121 |
wp_enqueue_style('mailchimpSF_admin_css', MCSF_URL.'css/admin.css'); |
| 122 |
} |
| 123 |
add_action('load-settings_page_mailchimpSF_options', 'mc_admin_page_load_resources'); |
| 124 |
|
| 125 |
|
| 126 |
/** |
| 127 |
* Loads jQuery Datepicker for the date-pick class |
| 128 |
**/ |
| 129 |
function mc_datepicker_load() { |
| 130 |
?> |
| 131 |
<script type="text/javascript"> |
| 132 |
jQuery(function($) { |
| 133 |
$('.date-pick').datepicker({ |
| 134 |
autoFocusNextInput: true, |
| 135 |
constrainInput: false, |
| 136 |
changeMonth: true, |
| 137 |
changeYear: true, |
| 138 |
beforeShow: function(input, inst) { $('#ui-datepicker-div').addClass('show'); }, |
| 139 |
dateFormat: 'yy/mm/dd', |
| 140 |
}); |
| 141 |
|
| 142 |
d = new Date(); |
| 143 |
$('.birthdate-pick').datepicker({ |
| 144 |
autoFocusNextInput: true, |
| 145 |
constrainInput: false, |
| 146 |
changeMonth: true, |
| 147 |
changeYear: false, |
| 148 |
minDate: new Date(d.getFullYear(), 1-1, 1), |
| 149 |
maxDate: new Date(d.getFullYear(), 12-1, 31), |
| 150 |
beforeShow: function(input, inst) { $('#ui-datepicker-div').removeClass('show'); }, |
| 151 |
dateFormat: 'mm/dd', |
| 152 |
}); |
| 153 |
|
| 154 |
|
| 155 |
}); |
| 156 |
</script> |
| 157 |
<?php |
| 158 |
} |
| 159 |
if (get_option('mc_use_datepicker') == 'on' && !is_admin()) { |
| 160 |
add_action('wp_head', 'mc_datepicker_load'); |
| 161 |
} |
| 162 |
|
| 163 |
/** |
| 164 |
* Handles requests that as light-weight a load as possible. |
| 165 |
* typically, JS or CSS |
| 166 |
**/ |
| 167 |
function mailchimpSF_early_request_handler() { |
| 168 |
if (isset($_GET['mcsf_action'])) { |
| 169 |
switch ($_GET['mcsf_action']) { |
| 170 |
case 'main_css': |
| 171 |
header("Content-type: text/css"); |
| 172 |
mailchimpSF_main_css(); |
| 173 |
exit; |
| 174 |
} |
| 175 |
} |
| 176 |
} |
| 177 |
add_action('init', 'mailchimpSF_early_request_handler', 0); |
| 178 |
|
| 179 |
/** |
| 180 |
* Outputs the front-end CSS. This checks several options, so it |
| 181 |
* was best to put it in a Request-handled script, as opposed to |
| 182 |
* a static file. |
| 183 |
*/ |
| 184 |
function mailchimpSF_main_css() { |
| 185 |
?> |
| 186 |
.mc_error_msg { |
| 187 |
color: red; |
| 188 |
} |
| 189 |
.mc_success_msg { |
| 190 |
color: green; |
| 191 |
} |
| 192 |
.mc_merge_var{ |
| 193 |
padding:0; |
| 194 |
margin:0; |
| 195 |
} |
| 196 |
<?php |
| 197 |
// If we're utilizing custom styles |
| 198 |
if (get_option('mc_custom_style')=='on'){ |
| 199 |
?> |
| 200 |
#mc_signup_form { |
| 201 |
padding:5px; |
| 202 |
border-width: <?php echo get_option('mc_form_border_width'); ?>px; |
| 203 |
border-style: <?php echo (get_option('mc_form_border_width')==0) ? 'none' : 'solid'; ?>; |
| 204 |
border-color: #<?php echo get_option('mc_form_border_color'); ?>; |
| 205 |
color: #<?php echo get_option('mc_form_text_color'); ?>; |
| 206 |
background-color: #<?php echo get_option('mc_form_background'); ?>; |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
.mc_custom_border_hdr { |
| 211 |
border-width: <?php echo get_option('mc_header_border_width'); ?>px; |
| 212 |
border-style: <?php echo (get_option('mc_header_border_width')==0) ? 'none' : 'solid'; ?>; |
| 213 |
border-color: #<?php echo get_option('mc_header_border_color'); ?>; |
| 214 |
color: #<?php echo get_option('mc_header_text_color'); ?>; |
| 215 |
background-color: #<?php echo get_option('mc_header_background'); ?>; |
| 216 |
font-size: 1.2em; |
| 217 |
padding:5px 10px; |
| 218 |
width: 100%; |
| 219 |
} |
| 220 |
<?php |
| 221 |
} |
| 222 |
?> |
| 223 |
#mc_signup_container {} |
| 224 |
#mc_signup_form {} |
| 225 |
#mc_signup_form .mc_var_label {} |
| 226 |
#mc_signup_form .mc_input {} |
| 227 |
#mc-indicates-required { |
| 228 |
width:100%; |
| 229 |
} |
| 230 |
#mc_display_rewards {} |
| 231 |
.mc_interests_header { |
| 232 |
font-weight:bold; |
| 233 |
} |
| 234 |
div.mc_interest{ |
| 235 |
width:100%; |
| 236 |
} |
| 237 |
#mc_signup_form input.mc_interest {} |
| 238 |
#mc_signup_form select {} |
| 239 |
#mc_signup_form label.mc_interest_label { |
| 240 |
display:inline; |
| 241 |
} |
| 242 |
.mc_signup_submit { |
| 243 |
text-align:center; |
| 244 |
} |
| 245 |
ul.mc_list { |
| 246 |
list-style-type: none; |
| 247 |
} |
| 248 |
ul.mc_list li { |
| 249 |
font-size: 12px; |
| 250 |
} |
| 251 |
.ui-datepicker-year { |
| 252 |
display: none; |
| 253 |
} |
| 254 |
#ui-datepicker-div.show .ui-datepicker-year { |
| 255 |
display: inline; |
| 256 |
padding-left: 3px |
| 257 |
} |
| 258 |
<?php |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
/** |
| 263 |
* Add our settings page to the admin menu |
| 264 |
* |
| 265 |
* @return void |
| 266 |
*/ |
| 267 |
function mailchimpSF_add_pages(){ |
| 268 |
// Add settings page for users who can edit plugins |
| 269 |
add_options_page( __( 'MailChimp Setup', 'mailchimp_i18n' ), __( 'MailChimp Setup', 'mailchimp_i18n' ), MCSF_CAP_THRESHOLD, 'mailchimpSF_options', 'mailchimpSF_setup_page'); |
| 270 |
} |
| 271 |
add_action('admin_menu', 'mailchimpSF_add_pages'); |
| 272 |
|
| 273 |
function mailchimpSF_request_handler() { |
| 274 |
if (isset($_POST['mcsf_action'])) { |
| 275 |
switch ($_POST['mcsf_action']) { |
| 276 |
case 'logout': |
| 277 |
// Check capability & Verify nonce |
| 278 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'mc_logout')) { |
| 279 |
wp_die('Cheatin’ huh?'); |
| 280 |
} |
| 281 |
|
| 282 |
// erase API Key |
| 283 |
update_option('mc_apikey', ''); |
| 284 |
break; |
| 285 |
case 'update_mc_apikey': |
| 286 |
// Check capability & Verify nonce |
| 287 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_mc_api_key')) { |
| 288 |
wp_die('Cheatin’ huh?'); |
| 289 |
} |
| 290 |
|
| 291 |
mailchimpSF_set_api_key(strip_tags(stripslashes($_POST['mc_apikey']))); |
| 292 |
break; |
| 293 |
case 'reset_list': |
| 294 |
// Check capability & Verify nonce |
| 295 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'reset_mailchimp_list')) { |
| 296 |
wp_die('Cheatin’ huh?'); |
| 297 |
} |
| 298 |
|
| 299 |
mailchimpSF_reset_list_settings(); |
| 300 |
break; |
| 301 |
case 'change_form_settings': |
| 302 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_general_form_settings')) { |
| 303 |
wp_die('Cheatin’ huh?'); |
| 304 |
} |
| 305 |
|
| 306 |
// Update the form settings |
| 307 |
mailchimpSF_save_general_form_settings(); |
| 308 |
break; |
| 309 |
case 'mc_submit_signup_form': |
| 310 |
// Validate nonce |
| 311 |
if (!wp_verify_nonce($_POST['_mc_submit_signup_form_nonce'], 'mc_submit_signup_form')) { |
| 312 |
wp_die('Cheatin’ huh?'); |
| 313 |
} |
| 314 |
|
| 315 |
// Attempt the signup |
| 316 |
mailchimpSF_signup_submit(); |
| 317 |
|
| 318 |
// Do a different action for html vs. js |
| 319 |
switch ($_POST['mc_submit_type']) { |
| 320 |
case 'html': |
| 321 |
/* Allow to fall through. The widget will pick up the |
| 322 |
* global message left over from the signup_submit function */ |
| 323 |
break; |
| 324 |
case 'js': |
| 325 |
if (!headers_sent()){ //just in case... |
| 326 |
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT', true, 200); |
| 327 |
} |
| 328 |
echo mailchimpSF_global_msg(); // Don't esc_html this, b/c we've already escaped it |
| 329 |
exit; |
| 330 |
} |
| 331 |
} |
| 332 |
} |
| 333 |
} |
| 334 |
add_action('init', 'mailchimpSF_request_handler'); |
| 335 |
|
| 336 |
/** |
| 337 |
* Upgrades data if it needs to. Checks on admin_init |
| 338 |
* |
| 339 |
* @return void |
| 340 |
*/ |
| 341 |
function mailchimpSF_upgrade() { |
| 342 |
// See if we need an upgrade |
| 343 |
if (mailchimpSF_needs_upgrade()) { |
| 344 |
// remove password option if it's set (0.5) |
| 345 |
// Update interest group data |
| 346 |
mailchimpSF_do_upgrade(); |
| 347 |
} |
| 348 |
} |
| 349 |
add_action('admin_init', 'mailchimpSF_upgrade'); |
| 350 |
|
| 351 |
/** |
| 352 |
* Checks to see if we're storing a password, if so, we need |
| 353 |
* to upgrade to the API key |
| 354 |
* |
| 355 |
* @return bool |
| 356 |
**/ |
| 357 |
function mailchimpSF_needs_upgrade() { |
| 358 |
$igs = get_option('mc_interest_groups'); |
| 359 |
|
| 360 |
if ($igs !== false // we have an option |
| 361 |
&& ( |
| 362 |
empty($igs) || // it can be an empty array (no interest groups) |
| 363 |
(is_array($igs) && isset($igs[0]['id'])) // OR it should be a populated array that's well-formed |
| 364 |
)) { |
| 365 |
return false; // no need to upgrade |
| 366 |
} |
| 367 |
else { |
| 368 |
return true; // yeah, let's do it |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
/** |
| 373 |
* 1.2.4 -> 1.2.5 - Update to support multiple interest groups |
| 374 |
* MCAPIv1.2 -> MCAPIv1.3 - update interest groups |
| 375 |
* 2011-02-09 - old password upgrade code deleted as 0.5 is way old |
| 376 |
*/ |
| 377 |
function mailchimpSF_do_upgrade() { |
| 378 |
//left in just for good measure |
| 379 |
delete_option('mc_password'); |
| 380 |
$api = new mailchimpSF_MCAPI(get_option('mc_apikey')); |
| 381 |
$igs = $api->listInterestGroupings(get_option('mc_list_id')); |
| 382 |
|
| 383 |
// If we don't have any interest groups store an empty array, not (bool) false |
| 384 |
$igs = !$igs ? array() : $igs; |
| 385 |
|
| 386 |
update_option('mc_interest_groups', $igs); |
| 387 |
} |
| 388 |
|
| 389 |
/** |
| 390 |
* Sets the API Key to whatever value was passed to this func |
| 391 |
* |
| 392 |
* @return array of vars |
| 393 |
**/ |
| 394 |
function mailchimpSF_set_api_key($api_key = '') { |
| 395 |
$delete_setup = false; |
| 396 |
$api = new mailchimpSF_MCAPI($api_key); |
| 397 |
$api->ping(); |
| 398 |
if (empty($api->errorCode)) { |
| 399 |
$msg = "<p class='success_msg'>".esc_html(__("Success! We were able to verify your API Key! Let's continue, shall we?", 'mailchimp_i18n'))."</p>"; |
| 400 |
update_option('mc_apikey', $api_key); |
| 401 |
$req = $api->getAccountDetails(); |
| 402 |
update_option('mc_username', $req['username']); |
| 403 |
update_option('mc_user_id', $req['user_id']); |
| 404 |
$cur_list_id = get_option('mc_list_id'); |
| 405 |
if (!empty($cur_list_id)) { |
| 406 |
//we *could* support paging, but few users have that many lists (and shouldn't) |
| 407 |
$lists = $api->lists(array(),0,100); |
| 408 |
$lists = $lists['data']; |
| 409 |
//but don't delete if the list still exists... |
| 410 |
$delete_setup = true; |
| 411 |
foreach($lists as $list) { |
| 412 |
if ($list['id'] == $cur_list_id) { |
| 413 |
$list_id = isset($_POST['mc_list_id']) ? $_POST['mc_list_id'] : ''; |
| 414 |
$delete_setup = false; |
| 415 |
} |
| 416 |
} |
| 417 |
} |
| 418 |
} else { |
| 419 |
$msg = "<p class='error_msg'>".esc_html(__('Uh-oh, we were unable to verify your API Key. Please check them and try again!', 'mailchimp_i18n'))."<br/>"; |
| 420 |
$msg .= __('The server said:', 'mailchimp_i18n')."<em>".esc_html($api->errorMessage)."</em></p>"; |
| 421 |
$username = get_option('mc_username'); |
| 422 |
if (empty($username)) { |
| 423 |
$delete_setup = true; |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
// Set a global message |
| 428 |
mailchimpSF_global_msg($msg); |
| 429 |
|
| 430 |
// If we need to delete our setup, do it |
| 431 |
if ($delete_setup){ |
| 432 |
mailchimpSF_delete_setup(); |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
/** |
| 437 |
* Deletes all mailchimp options |
| 438 |
**/ |
| 439 |
function mailchimpSF_delete_setup() { |
| 440 |
delete_option('mc_user_id'); |
| 441 |
delete_option('mc_rewards'); |
| 442 |
delete_option('mc_use_javascript'); |
| 443 |
delete_option('mc_use_datepicker'); |
| 444 |
delete_option('mc_use_unsub_link'); |
| 445 |
delete_option('mc_list_id'); |
| 446 |
delete_option('mc_list_name'); |
| 447 |
$igs = get_option('mc_interest_groups'); |
| 448 |
if (is_array($igs)) { |
| 449 |
foreach ($igs as $ig) { |
| 450 |
$opt = 'mc_show_interest_groups_'.$ig['id']; |
| 451 |
delete_option($opt); |
| 452 |
} |
| 453 |
} |
| 454 |
delete_option('mc_interest_groups'); |
| 455 |
$mv = get_option('mc_merge_vars'); |
| 456 |
if (is_array($mv)){ |
| 457 |
foreach($mv as $var){ |
| 458 |
$opt = 'mc_mv_'.$var['tag']; |
| 459 |
delete_option($opt); |
| 460 |
} |
| 461 |
} |
| 462 |
delete_option('mc_merge_vars'); |
| 463 |
} |
| 464 |
|
| 465 |
/** |
| 466 |
* Resets the list settings, there's only one list |
| 467 |
* that can have settings at a time, so no list_id |
| 468 |
* parameter is necessary. |
| 469 |
**/ |
| 470 |
function mailchimpSF_reset_list_settings() { |
| 471 |
|
| 472 |
delete_option('mc_list_id'); |
| 473 |
delete_option('mc_list_name'); |
| 474 |
delete_option('mc_merge_vars'); |
| 475 |
delete_option('mc_interest_groups'); |
| 476 |
|
| 477 |
delete_option('mc_use_javascript'); |
| 478 |
delete_option('mc_use_unsub_link'); |
| 479 |
delete_option('mc_use_datepicker'); |
| 480 |
|
| 481 |
delete_option('mc_header_content'); |
| 482 |
delete_option('mc_subheader_content'); |
| 483 |
delete_option('mc_submit_text'); |
| 484 |
|
| 485 |
delete_option('mc_custom_style'); |
| 486 |
|
| 487 |
delete_option('mc_header_border_width'); |
| 488 |
delete_option('mc_header_border_color'); |
| 489 |
delete_option('mc_header_background'); |
| 490 |
delete_option('mc_header_text_color'); |
| 491 |
|
| 492 |
delete_option('mc_form_border_width'); |
| 493 |
delete_option('mc_form_border_color'); |
| 494 |
delete_option('mc_form_background'); |
| 495 |
delete_option('mc_form_text_color'); |
| 496 |
|
| 497 |
$msg = '<p class="success_msg">'.esc_html(__('Successfully Reset your List selection... Now you get to pick again!', 'mailchimp_i18n')).'</p>'; |
| 498 |
mailchimpSF_global_msg($msg); |
| 499 |
} |
| 500 |
|
| 501 |
/** |
| 502 |
* Gets or sets a global message based on parameter passed to it |
| 503 |
* |
| 504 |
* @return string/bool depending on get/set |
| 505 |
**/ |
| 506 |
function mailchimpSF_global_msg($msg = null) { |
| 507 |
global $mcsf_msgs; |
| 508 |
|
| 509 |
// Make sure we're formed properly |
| 510 |
if (!is_array($mcsf_msgs)) { |
| 511 |
$mcsf_msgs = array(); |
| 512 |
} |
| 513 |
|
| 514 |
// See if we're getting |
| 515 |
if (is_null($msg)) { |
| 516 |
return implode('', $mcsf_msgs); |
| 517 |
} |
| 518 |
|
| 519 |
// Must be setting |
| 520 |
$mcsf_msgs[] = $msg; |
| 521 |
return true; |
| 522 |
} |
| 523 |
|
| 524 |
/** |
| 525 |
* Sets the default options for the option form |
| 526 |
**/ |
| 527 |
function mailchimpSF_set_form_defaults($list_name = '') { |
| 528 |
update_option('mc_header_content',__( 'Sign up for', 'mailchimp_i18n' ).' '.$list_name); |
| 529 |
update_option('mc_submit_text',__( 'Subscribe', 'mailchimp_i18n' )); |
| 530 |
|
| 531 |
update_option('mc_use_datepicker', 'on'); |
| 532 |
update_option('mc_custom_style','on'); |
| 533 |
update_option('mc_use_javascript','on'); |
| 534 |
update_option('mc_use_unsub_link','off'); |
| 535 |
update_option('mc_header_border_width','1'); |
| 536 |
update_option('mc_header_border_color','E3E3E3'); |
| 537 |
update_option('mc_header_background','FFFFFF'); |
| 538 |
update_option('mc_header_text_color','CC6600'); |
| 539 |
|
| 540 |
update_option('mc_form_border_width','1'); |
| 541 |
update_option('mc_form_border_color','C4D3EA'); |
| 542 |
update_option('mc_form_background','EEF3F8'); |
| 543 |
update_option('mc_form_text_color','555555'); |
| 544 |
} |
| 545 |
|
| 546 |
/** |
| 547 |
* Saves the General Form settings on the options page |
| 548 |
* |
| 549 |
* @return void |
| 550 |
**/ |
| 551 |
function mailchimpSF_save_general_form_settings() { |
| 552 |
if (isset($_POST['mc_rewards'])){ |
| 553 |
update_option('mc_rewards', 'on'); |
| 554 |
$msg = '<p class="success_msg">'.__('Monkey Rewards turned On!', 'mailchimp_i18n').'</p>'; |
| 555 |
mailchimpSF_global_msg($msg); |
| 556 |
} else if (get_option('mc_rewards')!='off') { |
| 557 |
update_option('mc_rewards', 'off'); |
| 558 |
$msg = '<p class="success_msg">'.__('Monkey Rewards turned Off!', 'mailchimp_i18n').'</p>'; |
| 559 |
mailchimpSF_global_msg($msg); |
| 560 |
} |
| 561 |
if (isset($_POST['mc_use_javascript'])){ |
| 562 |
update_option('mc_use_javascript', 'on'); |
| 563 |
$msg = '<p class="success_msg">'.__('Fancy Javascript submission turned On!', 'mailchimp_i18n').'</p>'; |
| 564 |
mailchimpSF_global_msg($msg); |
| 565 |
} else if (get_option('mc_use_javascript')!='off') { |
| 566 |
update_option('mc_use_javascript', 'off'); |
| 567 |
$msg = '<p class="success_msg">'.__('Fancy Javascript submission turned Off!', 'mailchimp_i18n').'</p>'; |
| 568 |
mailchimpSF_global_msg($msg); |
| 569 |
} |
| 570 |
|
| 571 |
if (isset($_POST['mc_use_datepicker'])){ |
| 572 |
update_option('mc_use_datepicker', 'on'); |
| 573 |
$msg = '<p class="success_msg">'.__('Datepicker turned On!', 'mailchimp_i18n').'</p>'; |
| 574 |
mailchimpSF_global_msg($msg); |
| 575 |
} else if (get_option('mc_use_datepicker')!='off') { |
| 576 |
update_option('mc_use_datepicker', 'off'); |
| 577 |
$msg = '<p class="success_msg">'.__('Datepicker turned Off!', 'mailchimp_i18n').'</p>'; |
| 578 |
mailchimpSF_global_msg($msg); |
| 579 |
} |
| 580 |
|
| 581 |
if (isset($_POST['mc_use_unsub_link'])){ |
| 582 |
update_option('mc_use_unsub_link', 'on'); |
| 583 |
$msg = '<p class="success_msg">'.__('Unsubscribe link turned On!', 'mailchimp_i18n').'</p>'; |
| 584 |
mailchimpSF_global_msg($msg); |
| 585 |
} else if (get_option('mc_use_unsub_link')!='off') { |
| 586 |
update_option('mc_use_unsub_link', 'off'); |
| 587 |
$msg = '<p class="success_msg">'.__('Unsubscribe link turned Off!', 'mailchimp_i18n').'</p>'; |
| 588 |
mailchimpSF_global_msg($msg); |
| 589 |
} |
| 590 |
|
| 591 |
$content = stripslashes($_POST['mc_header_content']); |
| 592 |
$content = str_replace("\r\n","<br/>", $content); |
| 593 |
update_option('mc_header_content', $content ); |
| 594 |
|
| 595 |
$content = stripslashes($_POST['mc_subheader_content']); |
| 596 |
$content = str_replace("\r\n","<br/>", $content); |
| 597 |
update_option('mc_subheader_content', $content ); |
| 598 |
|
| 599 |
|
| 600 |
$submit_text = stripslashes($_POST['mc_submit_text']); |
| 601 |
$submit_text = str_replace("\r\n","", $submit_text); |
| 602 |
update_option('mc_submit_text', $submit_text); |
| 603 |
|
| 604 |
// Set Custom Style option |
| 605 |
update_option('mc_custom_style', isset($_POST['mc_custom_style']) ? 'on' : 'off'); |
| 606 |
|
| 607 |
//we told them not to put these things we are replacing in, but let's just make sure they are listening... |
| 608 |
update_option('mc_header_border_width',str_replace('px','',$_POST['mc_header_border_width']) ); |
| 609 |
update_option('mc_header_border_color', str_replace('#','',$_POST['mc_header_border_color'])); |
| 610 |
update_option('mc_header_background',str_replace('#','',$_POST['mc_header_background'])); |
| 611 |
update_option('mc_header_text_color', str_replace('#','',$_POST['mc_header_text_color'])); |
| 612 |
|
| 613 |
update_option('mc_form_border_width',str_replace('px','',$_POST['mc_form_border_width']) ); |
| 614 |
update_option('mc_form_border_color', str_replace('#','',$_POST['mc_form_border_color'])); |
| 615 |
update_option('mc_form_background',str_replace('#','',$_POST['mc_form_background'])); |
| 616 |
update_option('mc_form_text_color', str_replace('#','',$_POST['mc_form_text_color'])); |
| 617 |
|
| 618 |
$igs = get_option('mc_interest_groups'); |
| 619 |
if (is_array($igs)) { |
| 620 |
foreach($igs as $var){ |
| 621 |
$opt = 'mc_show_interest_groups_'.$var['id']; |
| 622 |
if (isset($_POST[$opt])){ |
| 623 |
update_option($opt,'on'); |
| 624 |
} else { |
| 625 |
update_option($opt,'off'); |
| 626 |
} |
| 627 |
} |
| 628 |
} |
| 629 |
|
| 630 |
$mv = get_option('mc_merge_vars'); |
| 631 |
if (is_array($mv)) { |
| 632 |
foreach($mv as $var){ |
| 633 |
$opt = 'mc_mv_'.$var['tag']; |
| 634 |
if (isset($_POST[$opt]) || $var['req']=='Y'){ |
| 635 |
update_option($opt,'on'); |
| 636 |
} else { |
| 637 |
update_option($opt,'off'); |
| 638 |
} |
| 639 |
} |
| 640 |
} |
| 641 |
$msg = '<p class="success_msg">'.esc_html(__('Successfully Updated your List Subscribe Form Settings!', 'mailchimp_i18n')).'</p>'; |
| 642 |
mailchimpSF_global_msg($msg); |
| 643 |
} |
| 644 |
|
| 645 |
/** |
| 646 |
* Sees if the user changed the list, and updates options accordingly |
| 647 |
**/ |
| 648 |
function mailchimpSF_change_list_if_necessary($api_key) { |
| 649 |
// Simple permission check before going through all this |
| 650 |
if (!current_user_can(MCSF_CAP_THRESHOLD)) { return; } |
| 651 |
|
| 652 |
$api = new mailchimpSF_MCAPI($api_key); |
| 653 |
//we *could* support paging, but few users have that many lists (and shouldn't) |
| 654 |
$lists = $api->lists(array(),0,100); |
| 655 |
$lists = $lists['data']; |
| 656 |
|
| 657 |
if (is_array($lists) && !empty($lists) && isset($_POST['mc_list_id'])) { |
| 658 |
|
| 659 |
/* If our incoming list ID (the one chosen in the select dropdown) |
| 660 |
is in our array of lists, the set it to be the active list */ |
| 661 |
foreach($lists as $key => $list) { |
| 662 |
if ($list['id'] == $_POST['mc_list_id']) { |
| 663 |
$list_id = $_POST['mc_list_id']; |
| 664 |
$list_name = $list['name']; |
| 665 |
$list_key = $key; |
| 666 |
} |
| 667 |
} |
| 668 |
|
| 669 |
$orig_list = get_option('mc_list_id'); |
| 670 |
if ($list_id != '') { |
| 671 |
update_option('mc_list_id', $list_id); |
| 672 |
update_option('mc_list_name', $list_name); |
| 673 |
update_option('mc_email_type_option', $lists[$list_key]['email_type_option']); |
| 674 |
|
| 675 |
|
| 676 |
// See if the user changed the list |
| 677 |
if ($orig_list != $list_id){ |
| 678 |
// The user changed the list, Reset the Form Defaults |
| 679 |
mailchimpSF_set_form_defaults($list_name); |
| 680 |
} |
| 681 |
// email_type_option |
| 682 |
|
| 683 |
// Grab the merge vars and interest groups |
| 684 |
$mv = $api->listMergeVars($list_id); |
| 685 |
$igs = $api->listInterestGroupings($list_id); |
| 686 |
|
| 687 |
update_option('mc_merge_vars', $mv); |
| 688 |
foreach($mv as $var){ |
| 689 |
$opt = 'mc_mv_'.$var['tag']; |
| 690 |
//turn them all on by default |
| 691 |
if ($orig_list != $list_id) { |
| 692 |
update_option($opt, 'on' ); |
| 693 |
} |
| 694 |
} |
| 695 |
update_option('mc_interest_groups', $igs); |
| 696 |
if (is_array($igs)) { |
| 697 |
foreach ($igs as $var){ |
| 698 |
$opt = 'mc_show_interest_groups_'.$var['id']; |
| 699 |
//turn them all on by default |
| 700 |
if ($orig_list != $list_id) { |
| 701 |
update_option($opt, 'on' ); |
| 702 |
} |
| 703 |
} |
| 704 |
} |
| 705 |
$igs_text = ' '; |
| 706 |
if (is_array($igs)) { |
| 707 |
$igs_text .= sprintf(__('and %s Sets of Interest Groups', 'mailchimp_i18n'), count($igs)); |
| 708 |
} |
| 709 |
|
| 710 |
$msg = '<p class="success_msg">'. |
| 711 |
sprintf( |
| 712 |
__('Success! Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n').$igs_text, |
| 713 |
count($mv) |
| 714 |
).' '. |
| 715 |
__('from your list').' "'.$list_name.'"<br/><br/>'. |
| 716 |
__('Now you should either Turn On the MailChimp Widget or change your options below, then turn it on.', 'mailchimp_i18n').'</p>'; |
| 717 |
mailchimpSF_global_msg($msg); |
| 718 |
} |
| 719 |
} |
| 720 |
} |
| 721 |
|
| 722 |
/** |
| 723 |
* Outputs the Settings/Options page |
| 724 |
*/ |
| 725 |
function mailchimpSF_setup_page() { |
| 726 |
?> |
| 727 |
<div class="wrap"> |
| 728 |
|
| 729 |
<h2><?php esc_html_e('MailChimp List Setup', 'mailchimp_i18n');?> </h2> |
| 730 |
|
| 731 |
<?php |
| 732 |
|
| 733 |
$user = get_option('mc_username'); |
| 734 |
$api_key = get_option('mc_apikey'); |
| 735 |
|
| 736 |
// If we have an API Key, see if we need to change the lists and its options |
| 737 |
if (!empty($api_key)){ |
| 738 |
mailchimpSF_change_list_if_necessary($api_key); |
| 739 |
} |
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
// Display our success/error message(s) if have them |
| 744 |
if (mailchimpSF_global_msg() != ''){ |
| 745 |
// Message has already been html escaped, so we don't want to 2x escape it here |
| 746 |
?> |
| 747 |
<div id="mc_message" class=""><?php echo mailchimpSF_global_msg(); ?></div> |
| 748 |
<?php |
| 749 |
} |
| 750 |
|
| 751 |
|
| 752 |
// If we don't have an API Key, do a login form |
| 753 |
if (get_option('mc_apikey') == '') { |
| 754 |
?> |
| 755 |
<div> |
| 756 |
<form method="post" action="options-general.php?page=mailchimpSF_options"> |
| 757 |
<h3><?php esc_html_e('Login Info', 'mailchimp_i18n');?></h3> |
| 758 |
<?php esc_html_e('To start using the MailChimp plugin, we first need to login and get your API Key. Please enter your MailChimp API Key below.', 'mailchimp_i18n'); ?> |
| 759 |
|
| 760 |
<br/> |
| 761 |
|
| 762 |
<?php |
| 763 |
echo sprintf( |
| 764 |
'%1$s <a href="http://www.mailchimp.com/signup/" target="_blank">%2$s</a>', |
| 765 |
esc_html(__("Don't have a MailChimp account?", 'mailchimp_i18n')), |
| 766 |
esc_html(__('Try one for Free!', 'mailchimp_i18n')) |
| 767 |
); |
| 768 |
?> |
| 769 |
|
| 770 |
<br/> |
| 771 |
|
| 772 |
<table class="form-table"> |
| 773 |
<tr valign="top"> |
| 774 |
<th scope="row"><?php esc_html_e('API Key', 'mailchimp_i18n'); ?>:</th> |
| 775 |
<td> |
| 776 |
<input name="mc_apikey" type="text" id="mc_apikey" class="code" value="<?php echo esc_attr($api_key); ?>" size="32" /> |
| 777 |
<br/> |
| 778 |
<a href="http://admin.mailchimp.com/account/api-key-popup" target="_blank">get your API Key here</a> |
| 779 |
</td> |
| 780 |
</tr> |
| 781 |
</table> |
| 782 |
|
| 783 |
<input type="hidden" name="mcsf_action" value="update_mc_apikey"/> |
| 784 |
<input type="submit" name="Submit" value="<?php esc_attr_e('Save & Check', 'mailchimp_i18n');?>" class="button" /> |
| 785 |
<?php wp_nonce_field('update_mc_api_key', '_mcsf_nonce_action'); ?> |
| 786 |
</form> |
| 787 |
</div> |
| 788 |
|
| 789 |
<?php |
| 790 |
if (get_option('mc_username')!=''){ |
| 791 |
?> |
| 792 |
<strong><?php esc_html_e('Notes', 'mailchimp_i18n'); ?>:</strong> |
| 793 |
<ul> |
| 794 |
<li><em><?php esc_html_e('Changing your settings at MailChimp.com may cause this to stop working.', 'mailchimp_i18n'); ?></em></li> |
| 795 |
<li><em><?php esc_html_e('If you change your login to a different account, the info you have setup below will be erased.', 'mailchimp_i18n'); ?></em></li> |
| 796 |
<li><em><?php esc_html_e('If any of that happens, no biggie - just reconfigure your login and the items below...', 'mailchimp_i18n'); ?></em></li> |
| 797 |
</ul> |
| 798 |
<br/> |
| 799 |
<?php |
| 800 |
} |
| 801 |
} // End of login form |
| 802 |
|
| 803 |
// Start logout form |
| 804 |
else { |
| 805 |
?> |
| 806 |
<table style="min-width:400px;"> |
| 807 |
<tr> |
| 808 |
<td><h3><?php esc_html_e('Logged in as', 'mailchimp_i18n');?>: <?php echo esc_html(get_option('mc_username')); ?></h3> |
| 809 |
</td> |
| 810 |
<td> |
| 811 |
<form method="post" action="options-general.php?page=mailchimpSF_options"> |
| 812 |
<input type="hidden" name="mcsf_action" value="logout"/> |
| 813 |
<input type="submit" name="Submit" value="<?php esc_attr_e('Logout', 'mailchimp_i18n');?>" class="button" /> |
| 814 |
<?php wp_nonce_field('mc_logout', '_mcsf_nonce_action'); ?> |
| 815 |
</form> |
| 816 |
</td> |
| 817 |
</tr> |
| 818 |
</table> |
| 819 |
<?php |
| 820 |
} // End Logout form |
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
//Just get out if nothing else matters... |
| 825 |
if (get_option('mc_apikey') == '') return; |
| 826 |
|
| 827 |
if (get_option('mc_apikey')!=''){ |
| 828 |
?> |
| 829 |
<h3><?php esc_html_e('Your Lists', 'mailchimp_i18n'); ?></h3> |
| 830 |
|
| 831 |
<div> |
| 832 |
|
| 833 |
<p><?php esc_html_e('Please select the List you wish to create a Signup Form for.', 'mailchimp_i18n'); ?></p> |
| 834 |
|
| 835 |
<form method="post" action="options-general.php?page=mailchimpSF_options"> |
| 836 |
<?php |
| 837 |
$api = new mailchimpSF_MCAPI(get_option('mc_apikey')); |
| 838 |
//we *could* support paging, but few users have that many lists (and shouldn't) |
| 839 |
$lists = $api->lists(array(),0,100); |
| 840 |
$lists = $lists['data']; |
| 841 |
|
| 842 |
if (count($lists) == 0) { |
| 843 |
?> |
| 844 |
<span class='error_msg'> |
| 845 |
<?php |
| 846 |
echo sprintf( |
| 847 |
esc_html(__("Uh-oh, you don't have any lists defined! Please visit %s, login, and setup a list before using this tool!", 'mailchimp_i18n')), |
| 848 |
"<a href='http://www.mailchimp.com/'>MailChimp</a>" |
| 849 |
); |
| 850 |
?> |
| 851 |
</span> |
| 852 |
<?php |
| 853 |
} |
| 854 |
else { |
| 855 |
?> |
| 856 |
<table style="min-width:400px"> |
| 857 |
<tr> |
| 858 |
<td> |
| 859 |
<select name="mc_list_id" style="min-width:200px;"> |
| 860 |
<option value=""> — <?php esc_html_e('Select A List','mailchimp_i18n'); ?> — </option> |
| 861 |
<?php |
| 862 |
foreach ($lists as $list) { |
| 863 |
$option = get_option('mc_list_id'); |
| 864 |
?> |
| 865 |
<option value="<?php echo esc_attr($list['id']); ?>"<?php selected($list['id'], $option); ?>><?php echo esc_html($list['name']); ?></option> |
| 866 |
<?php |
| 867 |
} |
| 868 |
?> |
| 869 |
</select> |
| 870 |
</td> |
| 871 |
<td> |
| 872 |
<input type="hidden" name="mcsf_action" value="update_mc_list_id" /> |
| 873 |
<input type="submit" name="Submit" value="<?php esc_attr_e('Update List', 'mailchimp_i18n'); ?>" class="button" /> |
| 874 |
</td> |
| 875 |
</tr> |
| 876 |
<tr> |
| 877 |
<td colspan="2"> |
| 878 |
<strong><?php esc_html_e('Note:', 'mailchimp_i18n'); ?></strong> <em><?php esc_html_e('Updating your list will not cause settings below to be lost. Changing to a new list will.', 'mailchimp_i18n'); ?></em> |
| 879 |
</td> |
| 880 |
</tr> |
| 881 |
</table> |
| 882 |
<?php |
| 883 |
} //end select list |
| 884 |
?> |
| 885 |
</form> |
| 886 |
</div> |
| 887 |
|
| 888 |
<br/> |
| 889 |
|
| 890 |
<?php |
| 891 |
} |
| 892 |
else { |
| 893 |
//display the selected list... |
| 894 |
?> |
| 895 |
|
| 896 |
<p class="submit"> |
| 897 |
<form method="post" action="options-general.php?page=mailchimpSF_options"> |
| 898 |
<input type="hidden" name="mcsf_action" value="reset_list" /> |
| 899 |
<input type="submit" name="reset_list" value="<?php esc_attr_e('Reset List Options and Select again', 'mailchimp_i18n'); ?>" class="button" /> |
| 900 |
<?php wp_nonce_field('reset_mailchimp_list', '_mcsf_nonce_action'); ?> |
| 901 |
</form> |
| 902 |
</p> |
| 903 |
<h3><?php esc_html_e('Subscribe Form Widget Settings for this List', 'mailchimp_i18n'); ?>:</h3> |
| 904 |
<h4><?php esc_html_e('Selected MailChimp List', 'mailchimp_i18n'); ?>: <?php echo esc_html(get_option('mc_list_name')); ?></h4> |
| 905 |
<?php |
| 906 |
} |
| 907 |
//Just get out if nothing else matters... |
| 908 |
if (get_option('mc_list_id') == '') return; |
| 909 |
|
| 910 |
|
| 911 |
// The main Settings form |
| 912 |
?> |
| 913 |
|
| 914 |
<div> |
| 915 |
<form method="post" action="options-general.php?page=mailchimpSF_options"> |
| 916 |
<div style="width:600px;"> |
| 917 |
<input type="hidden" name="mcsf_action" value="change_form_settings"> |
| 918 |
<?php wp_nonce_field('update_general_form_settings', '_mcsf_nonce_action'); ?> |
| 919 |
<input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" /> |
| 920 |
<table class="widefat"> |
| 921 |
<tr valign="top"> |
| 922 |
<th scope="row"><?php esc_html_e('Monkey Rewards', 'mailchimp_i18n'); ?>:</th> |
| 923 |
<td><input name="mc_rewards" type="checkbox"<?php if (get_option('mc_rewards')=='on' || get_option('mc_rewards')=='' ) { echo ' checked="checked"'; } ?> id="mc_rewards" class="code" /> |
| 924 |
<em><label for="mc_rewards"><?php esc_html_e('turning this on will place a "powered by MailChimp" link in your form that will earn you credits with us. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em> |
| 925 |
</td> |
| 926 |
</tr> |
| 927 |
<tr valign="top"> |
| 928 |
<th scope="row"><?php esc_html_e('Use Javascript Support?', 'mailchimp_i18n'); ?>:</th> |
| 929 |
<td><input name="mc_use_javascript" type="checkbox" <?php checked(get_option('mc_use_javascript'), 'on'); ?> id="mc_use_javascript" class="code" /> |
| 930 |
<em><label for="mc_use_javascript"><?php esc_html_e('turning this on will use fancy javascript submission and should degrade gracefully for users not using javascript. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em> |
| 931 |
</td> |
| 932 |
</tr> |
| 933 |
<tr valign="top"> |
| 934 |
<th scope="row"><?php esc_html_e('Use Javascript Datepicker?', 'mailchimp_i18n'); ?>:</th> |
| 935 |
<td><input name="mc_use_datepicker" type="checkbox" <?php checked(get_option('mc_use_datepicker'), 'on'); ?> id="mc_use_datepicker" class="code" /> |
| 936 |
<em><label for="mc_use_datepicker"><?php esc_html_e('turning this on will use the jQuery UI Datepicker for dates.', 'mailchimp_i18n'); ?></label></em> |
| 937 |
</td> |
| 938 |
</tr> |
| 939 |
<tr valign="top"> |
| 940 |
<th scope="row"><?php esc_html_e('Include Unsubscribe link?', 'mailchimp_i18n'); ?>:</th> |
| 941 |
<td><input name="mc_use_unsub_link" type="checkbox"<?php checked(get_option('mc_use_unsub_link'), 'on'); ?> id="mc_use_unsub_link" class="code" /> |
| 942 |
<em><label for="mc_use_unsub_link"><?php esc_html_e('turning this on will add a link to your host unsubscribe form', 'mailchimp_i18n'); ?></label></em> |
| 943 |
</td> |
| 944 |
</tr> |
| 945 |
<tr valign="top"> |
| 946 |
<th scope="row"><?php esc_html_e('Header content', 'mailchimp_i18n'); ?>:</th> |
| 947 |
<td> |
| 948 |
<textarea name="mc_header_content" rows="2" cols="50"><?php echo esc_html(get_option('mc_header_content')); ?></textarea><br/> |
| 949 |
<em><?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?></em> |
| 950 |
</td> |
| 951 |
</tr> |
| 952 |
|
| 953 |
<tr valign="top"> |
| 954 |
<th scope="row"><?php esc_html_e('Sub-header content', 'mailchimp_i18n'); ?>:</th> |
| 955 |
<td> |
| 956 |
<textarea name="mc_subheader_content" rows="2" cols="50"><?php echo esc_html(get_option('mc_subheader_content')); ?></textarea><br/> |
| 957 |
<em><?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?></em>. |
| 958 |
<?php esc_html_e('This will be displayed under the heading and above the form.', 'mailchimp_i18n'); ?> |
| 959 |
</td> |
| 960 |
</tr> |
| 961 |
|
| 962 |
|
| 963 |
<tr valign="top"> |
| 964 |
<th scope="row"><?php esc_html_e('Submit Button text', 'mailchimp_i18n'); ?>:</th> |
| 965 |
<td> |
| 966 |
<input type="text" name="mc_submit_text" size="30" value="<?php echo esc_attr(get_option('mc_submit_text')); ?>"/> |
| 967 |
</td> |
| 968 |
</tr> |
| 969 |
|
| 970 |
<tr valign="top"> |
| 971 |
<th scope="row"><?php esc_html_e('Custom Styling', 'mailchimp_i18n'); ?>:</th> |
| 972 |
<td> |
| 973 |
<table class="widefat"> |
| 974 |
|
| 975 |
<tr><th><label for="mc_custom_style"><?php esc_html_e('Turned On?', 'mailchimp_i18n'); ?></label></th><td><input type="checkbox" name="mc_custom_style" id="mc_custom_style"<?php checked(get_option('mc_custom_style'), 'on'); ?> /></td></tr> |
| 976 |
<tr><th colspan="2"><?php esc_html_e('Header Settings (only applies if there are no HTML tags in the Header Content area above)', 'mailchimp_i18n'); ?>:</th></tr> |
| 977 |
<tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?>:</th><td><input type="text" name="mc_header_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_header_border_width')); ?>"/> px<br/> |
| 978 |
<em><?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em> |
| 979 |
</td></tr> |
| 980 |
<tr><th><?php esc_html_e('Border Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_header_border_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_header_border_color')); ?>"/><br/> |
| 981 |
<em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em> |
| 982 |
</td></tr> |
| 983 |
<tr><th><?php esc_html_e('Text Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_header_text_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_header_text_color')); ?>"/><br/> |
| 984 |
<em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em> |
| 985 |
</td></tr> |
| 986 |
<tr><th><?php esc_html_e('Background Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_header_background" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_header_background')); ?>"/><br/> |
| 987 |
<em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em> |
| 988 |
</td></tr> |
| 989 |
|
| 990 |
<tr><th colspan="2"><?php esc_html_e('Form Settings', 'mailchimp_i18n'); ?>:</th></tr> |
| 991 |
<tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?>:</th><td><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_form_border_width')); ?>"/> px<br/> |
| 992 |
<em><?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em> |
| 993 |
</td></tr> |
| 994 |
<tr><th><?php esc_html_e('Border Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_form_border_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_border_color')); ?>"/><br/> |
| 995 |
<em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em> |
| 996 |
</td></tr> |
| 997 |
<tr><th><?php esc_html_e('Text Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_form_text_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_text_color')); ?>"/><br/> |
| 998 |
<em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em> |
| 999 |
</td></tr> |
| 1000 |
<tr><th><?php esc_html_e('Background Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_form_background" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_background')); ?>"/><br/> |
| 1001 |
<em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em> |
| 1002 |
</td></tr> |
| 1003 |
</table> |
| 1004 |
</td> |
| 1005 |
</tr> |
| 1006 |
</table> |
| 1007 |
</div> |
| 1008 |
<input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" /> |
| 1009 |
|
| 1010 |
<?php |
| 1011 |
// Merge Variables Table |
| 1012 |
?> |
| 1013 |
<div style="width:400px;"> |
| 1014 |
|
| 1015 |
<h4><?php esc_html_e('Merge Variables Included', 'mailchimp_i18n'); ?></h4> |
| 1016 |
|
| 1017 |
<?php |
| 1018 |
$mv = get_option('mc_merge_vars'); |
| 1019 |
|
| 1020 |
if (count($mv) == 0 || !is_array($mv)){ |
| 1021 |
?> |
| 1022 |
<em><?php esc_html_e('No Merge Variables found.', 'mailchimp_i18n'); ?></em> |
| 1023 |
<?php |
| 1024 |
} else { |
| 1025 |
?> |
| 1026 |
|
| 1027 |
<table class='widefat'> |
| 1028 |
<tr valign="top"> |
| 1029 |
<th><?php esc_html_e('Name', 'mailchimp_i18n');?></th> |
| 1030 |
<th><?php esc_html_e('Tag', 'mailchimp_i18n');?></th> |
| 1031 |
<th><?php esc_html_e('Required?', 'mailchimp_i18n');?></th> |
| 1032 |
<th><?php esc_html_e('Include?', 'mailchimp_i18n');?></th> |
| 1033 |
</tr> |
| 1034 |
<?php |
| 1035 |
foreach($mv as $var){ |
| 1036 |
?> |
| 1037 |
<tr valign="top"> |
| 1038 |
<td><?php echo esc_html($var['name']); ?></td> |
| 1039 |
<td><?php echo esc_html($var['tag']); ?></td> |
| 1040 |
<td><?php echo esc_html(($var['req'] == 1) ? 'Y' : 'N'); ?></td> |
| 1041 |
<td> |
| 1042 |
<?php |
| 1043 |
if (!$var['req']){ |
| 1044 |
$opt = 'mc_mv_'.$var['tag']; |
| 1045 |
?> |
| 1046 |
<input name="<?php echo esc_attr($opt); ?>" type="checkbox" id="<?php echo esc_attr($opt); ?>" class="code"<?php checked(get_option($opt), 'on'); ?> /> |
| 1047 |
<?php |
| 1048 |
} else { |
| 1049 |
?> |
| 1050 |
— |
| 1051 |
<?php |
| 1052 |
} |
| 1053 |
?> |
| 1054 |
</td> |
| 1055 |
</tr> |
| 1056 |
<?php |
| 1057 |
} |
| 1058 |
?> |
| 1059 |
</table> |
| 1060 |
<?php |
| 1061 |
} |
| 1062 |
|
| 1063 |
?> |
| 1064 |
|
| 1065 |
<h4><?php esc_html_e('Interest Groups', 'mailchimp_i18n'); ?></h4> |
| 1066 |
|
| 1067 |
<?php |
| 1068 |
// Interest Groups Table |
| 1069 |
$igs = get_option('mc_interest_groups'); |
| 1070 |
if (is_array($igs) && !isset($igs['id'])) { |
| 1071 |
// Determines whether or not to continue processing. Only false if there was an error. |
| 1072 |
$continue = true; |
| 1073 |
foreach ($igs as $ig) { |
| 1074 |
if ($continue) { |
| 1075 |
if (!is_array($ig) || empty($ig) || $ig == 'N' ) { |
| 1076 |
?> |
| 1077 |
<em><?php esc_html_e('No Interest Groups Setup for this List', 'mailchimp_i18n'); ?></em> |
| 1078 |
<?php |
| 1079 |
$continue = false; |
| 1080 |
} |
| 1081 |
else { |
| 1082 |
?> |
| 1083 |
<table class='widefat'> |
| 1084 |
<tr valign="top"> |
| 1085 |
<th width="75px"> |
| 1086 |
<label for="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>"><?php esc_html_e('Show?', 'mailchimp_i18n'); ?></label> |
| 1087 |
</th> |
| 1088 |
<th> |
| 1089 |
<input name="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>" id="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>" type="checkbox" class="code"<?php checked('on', get_option('mc_show_interest_groups_'.$ig['id'])); ?> /> |
| 1090 |
</th> |
| 1091 |
</tr> |
| 1092 |
<tr valign="top"> |
| 1093 |
<th><?php esc_html_e('Name', 'mailchimp_i18n'); ?>:</th> |
| 1094 |
<th><?php echo esc_html($ig['name']); ?></th> |
| 1095 |
</tr> |
| 1096 |
<tr valign="top"> |
| 1097 |
<th><?php esc_html_e('Input Type', 'mailchimp_i18n'); ?>:</th> |
| 1098 |
<td><?php echo esc_html($ig['form_field']); ?></td> |
| 1099 |
</tr> |
| 1100 |
<tr valign="top"> |
| 1101 |
<th><?php esc_html_e('Options', 'mailchimp_i18n'); ?>:</th> |
| 1102 |
<td> |
| 1103 |
<ul> |
| 1104 |
<?php |
| 1105 |
foreach($ig['groups'] as $interest){ |
| 1106 |
?> |
| 1107 |
<li><?php echo esc_html($interest['name']); ?></li> |
| 1108 |
<?php |
| 1109 |
} |
| 1110 |
?> |
| 1111 |
</ul> |
| 1112 |
</td> |
| 1113 |
</tr> |
| 1114 |
</table> |
| 1115 |
<?php |
| 1116 |
} |
| 1117 |
} |
| 1118 |
} |
| 1119 |
} |
| 1120 |
else { |
| 1121 |
?> |
| 1122 |
<em><?php esc_html_e('Error retrieving interest groups. Please re-import the list.', 'mailchimp_i18n'); ?></em> |
| 1123 |
<?php |
| 1124 |
} |
| 1125 |
|
| 1126 |
?> |
| 1127 |
<p class="submit"> |
| 1128 |
<input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" /> |
| 1129 |
</p> |
| 1130 |
</div> |
| 1131 |
</form> |
| 1132 |
</div> |
| 1133 |
</div><!--wrap--> |
| 1134 |
<?php |
| 1135 |
}//mailchimpSF_setup_page() |
| 1136 |
|
| 1137 |
|
| 1138 |
function mailchimpSF_register_widgets() { |
| 1139 |
register_widget('mailchimpSF_Widget'); |
| 1140 |
} |
| 1141 |
add_action('widgets_init', 'mailchimpSF_register_widgets'); |
| 1142 |
|
| 1143 |
function mailchimpSF_shortcode($atts){ |
| 1144 |
ob_start(); |
| 1145 |
mailchimpSF_signup_form(); |
| 1146 |
return ob_get_clean(); |
| 1147 |
} |
| 1148 |
add_shortcode('mailchimpsf_form', 'mailchimpSF_shortcode'); |
| 1149 |
|
| 1150 |
/** |
| 1151 |
* Attempts to signup a user, per the $_POST args. |
| 1152 |
* |
| 1153 |
* This sets a global message, that is then used in the widget |
| 1154 |
* output to retrieve and display that message. |
| 1155 |
* |
| 1156 |
* @return bool |
| 1157 |
*/ |
| 1158 |
function mailchimpSF_signup_submit() { |
| 1159 |
$mv = get_option('mc_merge_vars', array()); |
| 1160 |
$mv_tag_keys = array(); |
| 1161 |
|
| 1162 |
$igs = get_option('mc_interest_groups', array()); |
| 1163 |
|
| 1164 |
$success = true; |
| 1165 |
$listId = get_option('mc_list_id'); |
| 1166 |
$email = isset($_POST['mc_mv_EMAIL']) ? strip_tags(stripslashes($_POST['mc_mv_EMAIL'])) : ''; |
| 1167 |
$merge = $errs = array(); // Set up some vars |
| 1168 |
|
| 1169 |
// Loop through our Merge Vars, and if they're empty, but required, then print an error, and mark as failed |
| 1170 |
foreach($mv as $var) { |
| 1171 |
$opt = 'mc_mv_'.$var['tag']; |
| 1172 |
|
| 1173 |
$opt_val = isset($_POST[$opt]) ? $_POST[$opt] : ''; |
| 1174 |
|
| 1175 |
if (is_array($opt_val) && isset($opt_val['area'])) { |
| 1176 |
$opt_val = implode('-', $opt_val); |
| 1177 |
} |
| 1178 |
else if (is_array($opt_val)) { |
| 1179 |
$opt_val = implode($opt_val); |
| 1180 |
} |
| 1181 |
|
| 1182 |
if ($var['req'] == 'Y' && trim($opt_val) == '') { |
| 1183 |
$success = false; |
| 1184 |
$errs[] = sprintf(__("You must fill in %s.", 'mailchimp_i18n'), esc_html($var['name'])); |
| 1185 |
} |
| 1186 |
else { |
| 1187 |
if ($var['tag'] != 'EMAIL') { |
| 1188 |
$merge[$var['tag']] = $opt_val; |
| 1189 |
} |
| 1190 |
} |
| 1191 |
|
| 1192 |
// We also want to create an array where the keys are the tags for easier validation later |
| 1193 |
$mv_tag_keys[$var['tag']] = $var; |
| 1194 |
|
| 1195 |
} |
| 1196 |
|
| 1197 |
// Head back to the beginning of the merge vars array |
| 1198 |
reset($mv); |
| 1199 |
|
| 1200 |
// Ensure we have an array |
| 1201 |
$igs = !is_array($igs) ? array() : $igs; |
| 1202 |
$groups = ''; |
| 1203 |
foreach ($igs as $ig) { |
| 1204 |
if (get_option('mc_show_interest_groups_'.$ig['id']) == 'on') { |
| 1205 |
$groupings = array(); |
| 1206 |
switch ($ig['form_field']) { |
| 1207 |
case 'select': |
| 1208 |
case 'dropdown': |
| 1209 |
case 'radio': |
| 1210 |
if (isset($_POST['group'][$ig['id']])) { |
| 1211 |
$groupings = array( |
| 1212 |
'id' => $ig['id'], |
| 1213 |
'groups' => str_replace(',', '\,', $_POST['group'][$ig['id']]), |
| 1214 |
); |
| 1215 |
} |
| 1216 |
break; |
| 1217 |
case 'checkboxes': |
| 1218 |
case 'checkbox': |
| 1219 |
if (isset($_POST['group'][$ig['id']])) { |
| 1220 |
foreach ($_POST['group'][$ig['id']] as $i => $value) { |
| 1221 |
$groups .= str_replace(',', '\,', $value).','; |
| 1222 |
|
| 1223 |
} |
| 1224 |
$groupings = array( |
| 1225 |
'id' => $ig['id'], |
| 1226 |
'groups' => $groups, |
| 1227 |
); |
| 1228 |
} |
| 1229 |
break; |
| 1230 |
default: |
| 1231 |
// Nothing |
| 1232 |
break; |
| 1233 |
} |
| 1234 |
if (!isset($merge['GROUPINGS']) || !is_array($merge['GROUPINGS'])) { |
| 1235 |
$merge['GROUPINGS'] = array(); |
| 1236 |
} |
| 1237 |
if (!empty($groupings)) { |
| 1238 |
$merge['GROUPINGS'][] = $groupings; |
| 1239 |
} |
| 1240 |
} |
| 1241 |
} |
| 1242 |
|
| 1243 |
// If we're good |
| 1244 |
if ($success) { |
| 1245 |
// Clear out empty merge vars |
| 1246 |
foreach ($merge as $k => $v) { |
| 1247 |
if (is_array($v) && empty($v)) { |
| 1248 |
unset($merge[$k]); |
| 1249 |
} |
| 1250 |
else if (!is_array($v) && trim($v) === '') { |
| 1251 |
unset($merge[$k]); |
| 1252 |
} |
| 1253 |
} |
| 1254 |
|
| 1255 |
// If we have an empty $merge, then assign empty string. |
| 1256 |
if (count($merge) == 0 || $merge == '') { |
| 1257 |
$merge = ''; |
| 1258 |
} |
| 1259 |
|
| 1260 |
if (isset($_POST['email_type']) && in_array($_POST['email_type'], array('text', 'html', 'mobile'))) { |
| 1261 |
$email_type = $_POST['email_type']; |
| 1262 |
} |
| 1263 |
else { |
| 1264 |
$email_type = 'html'; |
| 1265 |
} |
| 1266 |
|
| 1267 |
// Custom validation based on type |
| 1268 |
if (is_array($merge) && !empty($merge)) { |
| 1269 |
foreach ($merge as $merge_key => $merge_value) { |
| 1270 |
if ($merge_key !== 'GROUPINGS') { |
| 1271 |
switch ($mv_tag_keys[$merge_key]['field_type']) { |
| 1272 |
case 'phone': |
| 1273 |
$phone = $merge_value; |
| 1274 |
if (!empty($phone)) { |
| 1275 |
if (!preg_match('/[0-9]{0,3}-[0-9]{0,3}-[0-9]{0,4}/', $phone)) { |
| 1276 |
$errs[] = sprintf(__("%s must consist of only numbers", 'mailchimp_i18n'), esc_html($mv_tag_keys[$merge_key]['name'])); |
| 1277 |
$success = false; |
| 1278 |
} |
| 1279 |
} |
| 1280 |
break; |
| 1281 |
|
| 1282 |
default: |
| 1283 |
break; |
| 1284 |
} |
| 1285 |
} |
| 1286 |
} |
| 1287 |
} |
| 1288 |
if ($success) { |
| 1289 |
$api = new mailchimpSF_MCAPI(get_option('mc_apikey')); |
| 1290 |
$retval = $api->listSubscribe( $listId, $email, $merge, $email_type); |
| 1291 |
if (!$retval) { |
| 1292 |
switch($api->errorCode) { |
| 1293 |
case '105' : |
| 1294 |
$errs[] = __("Please try again later", 'mailchimp_i18n').'.'; |
| 1295 |
break; |
| 1296 |
case '214' : |
| 1297 |
$errs[] = __("That email address is already subscribed to the list", 'mailchimp_i18n').'.'; |
| 1298 |
break; |
| 1299 |
case '250' : |
| 1300 |
list($field, $rest) = explode(' ', $api->errorMessage, 2); |
| 1301 |
$errs[] = sprintf(__("You must fill in %s.", 'mailchimp_i18n'), esc_html($mv_tag_keys[$field]['name'])); |
| 1302 |
break; |
| 1303 |
case '254' : |
| 1304 |
list($i1, $i2, $i3, $field, $rest) = explode(' ',$api->errorMessage,5); |
| 1305 |
$errs[] = sprintf(__("%s has invalid content.", 'mailchimp_i18n'), esc_html($mv_tag_keys[$field]['name'])); |
| 1306 |
break; |
| 1307 |
case '270' : |
| 1308 |
$errs[] = __("An invalid Interest Group was selected", 'mailchimp_i18n').'.'; |
| 1309 |
break; |
| 1310 |
case '502' : |
| 1311 |
$errs[] = __("That email address is invalid", 'mailchimp_i18n').'.'; |
| 1312 |
break; |
| 1313 |
default: |
| 1314 |
$errs[] = $api->errorCode.":".$api->errorMessage; |
| 1315 |
break; |
| 1316 |
} |
| 1317 |
$success = false; |
| 1318 |
} |
| 1319 |
} |
| 1320 |
} |
| 1321 |
|
| 1322 |
// If we have errors, then show them |
| 1323 |
if (count($errs) > 0) { |
| 1324 |
$msg = '<span class="mc_error_msg">'; |
| 1325 |
foreach($errs as $error){ |
| 1326 |
$msg .= '» '.esc_html($error).'<br />'; |
| 1327 |
} |
| 1328 |
$msg .= '</span>'; |
| 1329 |
} |
| 1330 |
else { |
| 1331 |
$msg = "<strong class='mc_success_msg'>".esc_html(__("Success, you've been signed up! Please look for our confirmation email!", 'mailchimp_i18n'))."</strong>"; |
| 1332 |
} |
| 1333 |
|
| 1334 |
// Set our global message |
| 1335 |
mailchimpSF_global_msg($msg); |
| 1336 |
|
| 1337 |
return $success; |
| 1338 |
} |
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
/********************** |
| 1343 |
* Utility Functions * |
| 1344 |
**********************/ |
| 1345 |
/** |
| 1346 |
* Utility function to allow placement of plugin in plugins, mu-plugins, child or parent theme's plugins folders |
| 1347 |
* |
| 1348 |
* This function must be ran _very early_ in the load process, as it sets up important constants for the rest of the plugin |
| 1349 |
*/ |
| 1350 |
function mailchimpSF_where_am_i() { |
| 1351 |
$locations = array( |
| 1352 |
'plugins' => array( |
| 1353 |
'dir' => WP_PLUGIN_DIR, |
| 1354 |
'url' => plugins_url() |
| 1355 |
), |
| 1356 |
'mu_plugins' => array( |
| 1357 |
'dir' => WPMU_PLUGIN_DIR, |
| 1358 |
'url' => plugins_url(), |
| 1359 |
), |
| 1360 |
'template' => array( |
| 1361 |
'dir' => trailingslashit(get_template_directory()).'plugins/', |
| 1362 |
'url' => trailingslashit(get_template_directory_uri()).'plugins/', |
| 1363 |
), |
| 1364 |
'stylesheet' => array( |
| 1365 |
'dir' => trailingslashit(get_stylesheet_directory()).'plugins/', |
| 1366 |
'url' => trailingslashit(get_stylesheet_directory_uri()).'plugins/', |
| 1367 |
), |
| 1368 |
); |
| 1369 |
|
| 1370 |
// Set defaults |
| 1371 |
$mscf_dir = trailingslashit(WP_PLUGIN_DIR).'mailchimp/'; |
| 1372 |
$mscf_url = trailingslashit(WP_PLUGIN_URL).'mailchimp/'; |
| 1373 |
|
| 1374 |
// Try our hands at finding the real location |
| 1375 |
foreach ($locations as $key => $loc) { |
| 1376 |
$dir = trailingslashit($loc['dir']).'mailchimp/'; |
| 1377 |
$url = trailingslashit($loc['url']).'mailchimp/'; |
| 1378 |
if (is_file($dir.basename(__FILE__))) { |
| 1379 |
$mscf_dir = $dir; |
| 1380 |
$mscf_url = $url; |
| 1381 |
break; |
| 1382 |
} |
| 1383 |
} |
| 1384 |
|
| 1385 |
// Define our complete filesystem path |
| 1386 |
define('MCSF_DIR', $mscf_dir); |
| 1387 |
|
| 1388 |
/* Lang location needs to be relative *from* ABSPATH, |
| 1389 |
so strip it out of our language dir location */ |
| 1390 |
define('MCSF_LANG_DIR', trailingslashit(MCSF_DIR).'po/'); |
| 1391 |
|
| 1392 |
// Define our complete URL to the plugin folder |
| 1393 |
define('MCSF_URL', $mscf_url); |
| 1394 |
} |
| 1395 |
|
| 1396 |
|
| 1397 |
?> |
| 1398 |
|