function dk_speakout_sendmail() { // set WPML language global $sitepress; $lang = isset($_POST['lang']) ? $_POST['lang'] : ''; if (isset($sitepress)) { $sitepress->switch_lang($lang, true); } include_once 'class.signature.php'; include_once 'class.petition.php'; include_once 'class.mail.php'; include_once 'class.wpml.php'; $the_signature = new dk_speakout_Signature(); $the_petition = new dk_speakout_Petition(); $wpml = new dk_speakout_WPML(); $options = get_option('dk_speakout_options'); // clean posted signature fields $the_signature->poppulate_from_post(); // get petition data $the_petition->retrieve($the_signature->petitions_id); $wpml->translate_petition($the_petition); $options = $wpml->translate_options($options); // check if submitted email address is already in use for this petition if ($the_signature->has_unique_email($the_signature->email, $the_signature->petitions_id)) { // handle custom petition messages $original_message = str_replace("\r", '', $the_petition->petition_message); if ($the_petition->is_editable && $the_signature->submitted_message != $original_message) { $the_signature->custom_message = trim($the_signature->submitted_message); } // does petition require email confirmation? if ($the_petition->requires_confirmation) { $the_signature->is_confirmed = 0; $the_signature->create_confirmation_code(); dk_speakout_Mail::send_confirmation($the_petition, $the_signature, $options); } else { if ($the_petition->sends_email) { dk_speakout_Mail::send_petition($the_petition, $the_signature); } } // add signature to database $the_signature->create($the_signature->petitions_id); // display success message $success_message = $options['success_message']; $success_message = str_replace('%first_name%', $the_signature->first_name, $success_message); $success_message = str_replace('%last_name%', $the_signature->last_name, $success_message); $json_response = array('status' => 'success', 'message' => $success_message); $json_response = json_encode($json_response); echo $json_response; } else { $json_response = array('status' => 'error', 'message' => $options['already_signed_message']); $json_response = json_encode($json_response); echo $json_response; } // end AJAX processing die; }
/** * Displays the Email Petitions table page */ function dk_speakout_petitions_page() { // check security: ensure user has authority if (!current_user_can('publish_posts')) { wp_die('Insufficient privileges: You need to be an editor to do that.'); } include_once 'class.speakout.php'; include_once 'class.petition.php'; include_once 'class.wpml.php'; $the_petitions = new dk_speakout_Petition(); $wpml = new dk_speakout_WPML(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; $options = get_option('dk_speakout_options'); // set variables for paged record display and limit values in db query // request values may be submitted either by html links (pagination.php) or by javascript (admin.js) $paged = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : '1'; $total_pages = isset($_REQUEST['total_pages']) ? $_REQUEST['total_pages'] : '1'; $current_page = dk_speakout_SpeakOut::current_paged($paged, $total_pages); $query_limit = $options['petitions_rows']; $query_start = $current_page * $query_limit - $query_limit; // link URL for "Add New" button in header $addnew_url = esc_url(site_url() . '/wp-admin/admin.php?page=dk_speakout_addnew'); switch ($action) { case 'delete': // security: ensure user has intention check_admin_referer('dk_speakout-delete_petition' . $id); // delete the petition and its signatures $the_petitions->delete($id); $wpml->unregister_petition($id); // get petitions $petitions = $the_petitions->all($query_start, $query_limit); // set up page display variables $page_title = __('Email Petitions', 'dk_speakout'); $count = $the_petitions->count(); $message_update = __('Petition deleted.', 'dk_speakout'); break; default: // get petitions $petitions = $the_petitions->all($query_start, $query_limit); // set up page display variables $page_title = __('Email Petitions', 'dk_speakout'); $count = $the_petitions->count(); $message_update = ''; } // display the Petitions table include_once 'petitions.view.php'; }
function dk_speakout_install() { global $wpdb, $db_petitions, $db_signatures, $dk_speakout_version; dk_speakout_translate(); $sql_create_tables = "\r\n\t\tCREATE TABLE `{$db_petitions}` (\r\n\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n\t\t\t`title` TEXT CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`target_email` VARCHAR(300) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`email_subject` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`greeting` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`petition_message` LONGTEXT CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`address_fields` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`expires` CHAR(1) BINARY NOT NULL,\r\n\t\t\t`expiration_date` DATETIME NOT NULL,\r\n\t\t\t`created_date` DATETIME NOT NULL,\r\n\t\t\t`goal` INT(11) NOT NULL,\r\n\t\t\t`sends_email` CHAR(1) BINARY NOT NULL,\r\n\t\t\t`twitter_message` VARCHAR(120) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`requires_confirmation` CHAR(1) BINARY NOT NULL,\r\n\t\t\t`return_url` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`displays_custom_field` CHAR(1) BINARY NOT NULL,\r\n\t\t\t`custom_field_label` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`displays_optin` CHAR(1) BINARY NOT NULL,\r\n\t\t\t`optin_label` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`is_editable` CHAR(1) BINARY NOT NULL,\r\n\t\t\tUNIQUE KEY (`id`)\r\n\t\t);\r\n\t\tCREATE TABLE `{$db_signatures}` (\r\n\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n\t\t\t`petitions_id` BIGINT(20) NOT NULL,\r\n\t\t\t`first_name` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`last_name` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`email` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`street_address` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`city` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`state` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`postcode` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`country` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`custom_field` VARCHAR(400) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`optin` CHAR(1) BINARY NOT NULL,\r\n\t\t\t`date` DATETIME NOT NULL,\r\n\t\t\t`confirmation_code` VARCHAR(32) NOT NULL,\r\n\t\t\t`is_confirmed` CHAR(1) BINARY NOT NULL,\r\n\t\t\t`custom_message` LONGTEXT CHARACTER SET utf8 NOT NULL,\r\n\t\t\t`language` VARCHAR(10) CHARACTER SET utf8 NOT NULL,\r\n\t\t\tUNIQUE KEY (`id`)\r\n\t\t);"; // create database tables require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql_create_tables); // set default options $options = array("petitions_rows" => "20", "signatures_rows" => "50", "petition_theme" => "default", "button_text" => __("Sign Now", "dk_speakout"), "expiration_message" => __("This petition is now closed.", "dk_speakout"), "success_message" => "<strong>" . __("Thank you", "dk_speakout") . ", %first_name%.</strong>\r\n<p>" . __("Your signature has been added.", "dk_speakout") . "</p>", "already_signed_message" => __("This petition has already been signed using your email address.", "dk_speakout"), "share_message" => __("Share this with your friends:", "dk_speakout"), "confirm_subject" => __("Please confirm your email address", "dk_speakout"), "confirm_message" => __("Hello", "dk_speakout") . " %first_name%\r\n\r\n" . __("Thank you for singing our petition", "dk_speakout") . ". " . __("Please confirm your email address by clicking the link below:", "dk_speakout") . "\r\n%confirmation_link%\r\n\r\n" . get_bloginfo("name"), "confirm_email" => get_bloginfo("name") . " <" . get_bloginfo("admin_email") . ">", "optin_default" => "unchecked", "display_count" => "1", "signaturelist_theme" => "default", "signaturelist_header" => __("Latest Signatures", "dk_speakout"), "signaturelist_rows" => "50", "signaturelist_columns" => serialize(array("sig_date")), "widget_theme" => "default", "csv_signatures" => "all", "signaturelist_privacy" => "enabled"); // add plugin options to wp_options table add_option('dk_speakout_options', $options); add_option('dk_speakout_version', $dk_speakout_version); // register options for translation in WPML include_once 'class.wpml.php'; $wpml = new dk_speakout_WPML(); $wpml->register_options($options); }
function widget($args, $instance) { global $dk_speakout_version; include_once 'class.speakout.php'; include_once 'class.petition.php'; include_once 'class.wpml.php'; $options = get_option('dk_speakout_options'); $petition = new dk_speakout_Petition(); $wpml = new dk_speakout_WPML(); extract($args); // get widget data $instance = $wpml->translate_widget($instance); $title = apply_filters('widget_title', $instance['title']); $call_to_action = empty($instance['call_to_action']) ? ' ' : $instance['call_to_action']; $petition->id = empty($instance['petition_id']) ? 1 : absint($instance['petition_id']); $get_petition = $petition->retrieve($petition->id); $wpml->translate_petition($petition); $options = $wpml->translate_options($options); // set up variables for widget display $userdata = dk_speakout_SpeakOut::userinfo(); $expired = $petition->expires == '1' && current_time('timestamp') >= strtotime($petition->expiration_date) ? 1 : 0; $greeting = $petition->greeting != '' && $petition->sends_email == 1 ? '<p><span class="dk-speakout-widget-greeting">' . $petition->greeting . '</span></p>' : ''; $optin_default = $options['optin_default'] == 'checked' ? 'checked' : ''; // get language value from URL if available (for WPML) $wpml_lang = ''; if (defined('ICL_LANGUAGE_CODE')) { $wpml_lang = ICL_LANGUAGE_CODE; } // check if petition exists... // if a petition has been deleted, but its widget still exists, don't try to display the form if ($get_petition) { // compose the petition widget and pop-up form $petition_widget = ' <!-- SpeakOut! Email Petitions ' . $dk_speakout_version . ' --> <div class="dk-speakout-widget-wrap"> <h3>' . stripslashes(esc_html($title)) . '</h3> <p>' . stripslashes(esc_html($call_to_action)) . '</p> <div class="dk-speakout-widget-button-wrap"> <a rel="dk-speakout-widget-popup-wrap-' . $petition->id . '" class="dk-speakout-widget-button"><span>' . $options['button_text'] . '</span></a> </div>'; if ($options['display_count'] == 1) { $petition_widget .= ' <div class="dk-speakout-widget-progress-wrap"> <div class="dk-speakout-widget-signature-count"> <span>' . number_format($petition->signatures) . '</span> ' . _n('signature', 'signatures', $petition->signatures, 'dk_speakout') . ' </div> ' . dk_speakout_SpeakOut::progress_bar($petition->goal, $petition->signatures, 150) . ' </div>'; } $petition_widget .= ' </div> <div id="dk-speakout-widget-windowshade"></div> <div id="dk-speakout-widget-popup-wrap-' . $petition->id . '" class="dk-speakout-widget-popup-wrap"> <h3>' . stripslashes(esc_html($petition->title)) . '</h3> '; // <div class="dk-speakout-widget-close"></div> if ($petition->is_editable == 1) { $petition_widget .= ' <div class="dk-speakout-widget-message-wrap"> <p class="dk-speakout-greeting">' . $petition->greeting . '</p> <textarea name="dk-speakout-widget-message" id="dk-speakout-widget-message-' . $petition->id . '" class="dk-speakout-widget-message">' . stripslashes(esc_textarea($petition->petition_message)) . '</textarea> <p class="dk-speakout-caps">[' . __('signature', 'dk-speakout') . ']</p> </div>'; } else { $petition_widget .= ' <div class="dk-speakout-widget-message-wrap"> <div class="dk-speakout-widget-message"> <p class="dk-speakout-greeting">' . $petition->greeting . '</p> ' . stripslashes(wpautop($petition->petition_message)) . ' <p class="dk-speakout-caps">[' . __('signature', 'dk-speakout') . ']</p> </div> </div>'; } $petition_widget .= ' <div class="dk-speakout-widget-form-wrap"> <div class="dk-speakout-widget-response"></div> <form class="dk-speakout-widget-form"> <input type="hidden" id="dk-speakout-widget-posttitle-' . $petition->id . '" value="' . esc_attr(urlencode(stripslashes($petition->title))) . '" /> <input type="hidden" id="dk-speakout-widget-shareurl-' . $petition->id . '" value="' . esc_attr(urlencode(stripslashes($instance['sharing_url']))) . '" /> <input type="hidden" id="dk-speakout-widget-tweet-' . $petition->id . '" value="' . dk_speakout_SpeakOut::twitter_encode($petition->twitter_message) . '" /> <input type="hidden" id="dk-speakout-widget-lang-' . $petition->id . '" value="' . $wpml_lang . '" />'; if ($expired) { $petition_widget .= ' <p><strong>' . $options['expiration_message'] . '</strong></p> <p>' . __('End date', 'dk_speakout') . ': ' . date('M d, Y', strtotime($petition->expiration_date)) . '</p> <p>' . __('Signatures collected', 'dk_speakout') . ': ' . $petition->signatures . '</p>'; if ($petition->goal != 0) { $petition_widget .= ' <p><div class="dk-speakout-expired-goal"><span>' . __('Signature goal', 'dk_speakout') . ':</span> ' . $petition->goal . '</div></p>'; } } else { $petition_widget .= ' <div class="dk-speakout-widget-full"> <label for="dk-speakout-widget-first-name-' . $petition->id . '" class="required">' . __('First Name', 'dk_speakout') . '</label> <input name="dk-speakout-widget-first-name" id="dk-speakout-widget-first-name-' . $petition->id . '" value="' . $userdata['firstname'] . '" type="text" /> </div> <div class="dk-speakout-widget-full"> <label for="dk-speakout-widget-last-name-' . $petition->id . '" class="required">' . __('Last Name', 'dk_speakout') . '</label> <input name="dk-speakout-widget-last-name" id="dk-speakout-widget-last-name-' . $petition->id . '" value="' . $userdata['lastname'] . '" type="text" /> </div> <div class="dk-speakout-widget-full"> <label for="dk-speakout-widget-email-' . $petition->id . '" class="required">' . __('Email', 'dk_speakout') . '</label> <input name="dk-speakout-widget-email" id="dk-speakout-widget-email-' . $petition->id . '" value="' . $userdata['email'] . '" type="text" /> </div>'; if ($petition->requires_confirmation) { $petition_widget .= ' <div class="dk-speakout-widget-full"> <label for="dk-speakout-widget-email-confirm-' . $petition->id . '" class="required">' . __('Confirm Email', 'dk_speakout') . '</label> <input name="dk-speakout-widget-email-confirm" id="dk-speakout-widget-email-confirm-' . $petition->id . '" value="" type="text" /> </div>'; } if (in_array('street', $petition->address_fields)) { $petition_widget .= ' <div class="dk-speakout-widget-full"> <label for="dk-speakout-widget-street-' . $petition->id . '">' . __('Street', 'dk_speakout') . '</label> <input name="dk-speakout-widget-street" id="dk-speakout-widget-street-' . $petition->id . '" maxlength="200" type="text" /> </div>'; } if (in_array('city', $petition->address_fields)) { $petition_widget .= ' <div class="dk-speakout-widget-half"> <label for="dk-speakout-widget-city-' . $petition->id . '">' . __('City', 'dk_speakout') . '</label> <input name="dk-speakout-widget-city" id="dk-speakout-widget-city-' . $petition->id . '" maxlength="200" type="text"> </div>'; } if (in_array('state', $petition->address_fields)) { $petition_widget .= ' <div class="dk-speakout-widget-half"> <label for="dk-speakout-widget-state-' . $petition->id . '">' . __('State / Province', 'dk_speakout') . '</label> <input name="dk-speakout-widget-state" id="dk-speakout-widget-state-' . $petition->id . '" maxlength="200" type="text" list="dk-speakout-states" /> <datalist id="dk-speakout-states"> <option value="Alabama"><option value="Alaska"><option value="Alberta"><option value="Arizona"><option value="Arkansas"><option value="British Columbia"><option value="California"><option value="Colorado"><option value="Connecticut"><option value="Washington DC"><option value="Delaware"><option value="Florida"><option value="Georgia"><option value="Hawaii"><option value="Idaho"><option value="Illinois"><option value="Indiana"><option value="Iowa"><option value="Kansas"><option value="Kentucky"><option value="Labrador"><option value="Louisiana"><option value="Maine"><option value="Manitoba"><option value="Maryland"><option value="Massachusetts"><option value="Michigan"><option value="Minnesota"><option value="Mississippi"><option value="Missouri"><option value="Montana"><option value="Nebraska"><option value="Nevada"><option value="New Brunswick"><option value="Newfoundland"><option value="New Hampshire"><option value="New Jersey"><option value="New Mexico"><option value="New York"><option value="North Carolina"><option value="North Dakota"><option value="North West Territory"><option value="Nova Scotia"><option value="Nunavut"><option value="Ohio"><option value="Oklahoma"><option value="Ontario"><option value="Oregon"><option value="Pennsylvania"><option value="Prince Edward Island"><option value="Quebec"><option value="Rhode Island"><option value="Saskatchewan"><option value="South Carolina"><option value="South Dakota"><option value="Tennessee"><option value="Texas"><option value="Utah"><option value="Vermont"><option value="Virginia"><option value="Washington"><option value="West Virginia"><option value="Wisconsin"><option value="Wyoming"><option value="Yukon"> </datalist> </div>'; } if (in_array('postcode', $petition->address_fields)) { $petition_widget .= ' <div class="dk-speakout-widget-half"> <label for="dk-speakout-widget-postcode-' . $petition->id . '">' . __('Post Code', 'dk_speakout') . '</label> <input name="dk-speakout-widget-postcode" id="dk-speakout-widget-postcode-' . $petition->id . '" maxlength="200" type="text"> </div>'; } if (in_array('country', $petition->address_fields)) { $petition_widget .= ' <div class="dk-speakout-widget-half"> <label for="dk-speakout-widget-country-' . $petition->id . '">' . __('Country', 'dk_speakout') . '</label> <input name="dk-speakout-widget-country" id="dk-speakout-widget-country-' . $petition->id . '" maxlength="200" type="text" list="dk-speakout-widget-countries" /> <datalist id="dk-speakout-widget-countries"> <option value="Afghanistan"><option value="Albania"><option value="Algeria"><option value="American Samoa"><option value="Andorra"><option value="Angola"><option value="Anguilla"><option value="Antarctica"><option value="Antigua and Barbuda"><option value="Argentina"><option value="Armenia"><option value="Aruba"><option value="Australia"><option value="Austria"><option value="Azerbaijan"><option value="Bahrain"><option value="Bangladesh"><option value="Barbados"><option value="Belarus"><option value="Belgium"><option value="Belize"><option value="Benin"><option value="Bermuda"><option value="Bhutan"><option value="Bolivia"><option value="Bosnia and Herzegovina"><option value="Botswana"><option value="Bouvet Island"><option value="Brazil"><option value="British Indian Ocean Territory"><option value="British Virgin Islands"><option value="Brunei"><option value="Bulgaria"><option value="Burkina Faso"><option value="Burundi"><option value="Côte d\'Ivoire"><option value="Cambodia"><option value="Cameroon"><option value="Canada"><option value="Cape Verde"><option value="Cayman Islands"><option value="Central African Republic"><option value="Chad"><option value="Chile"><option value="China"><option value="Christmas Island"><option value="Cocos (Keeling) Islands"><option value="Colombia"><option value="Comoros"><option value="Congo"><option value="Cook Islands"><option value="Costa Rica"><option value="Croatia"><option value="Cuba"><option value="Cyprus"><option value="Czech Republic"><option value="Democratic Republic of the Congo"><option value="Denmark"><option value="Djibouti"><option value="Dominica"><option value="Dominican Republic"><option value="East Timor"><option value="Ecuador"><option value="Egypt"><option value="El Salvador"><option value="Equatorial Guinea"><option value="Eritrea"><option value="Estonia"><option value="Ethiopia"><option value="Faeroe Islands"><option value="Falkland Islands"><option value="Fiji"><option value="Finland"><option value="Former Yugoslav Republic of Macedonia"><option value="France"><option value="French Guiana"><option value="French Polynesia"><option value="French Southern Territories"><option value="Gabon"><option value="Georgia"><option value="Germany"><option value="Ghana"><option value="Gibraltar"><option value="Greece"><option value="Greenland"><option value="Grenada"><option value="Guadeloupe"><option value="Guam"><option value="Guatemala"><option value="Guinea"><option value="Guinea-Bissau"><option value="Guyana"><option value="Haiti"><option value="Heard Island and McDonald Islands"><option value="Honduras"><option value="Hong Kong"><option value="Hungary"><option value="Iceland"><option value="India"><option value="Indonesia"><option value="Iran"><option value="Iraq"><option value="Ireland"><option value="Israel"><option value="Italy"><option value="Jamaica"><option value="Japan"><option value="Jordan"><option value="Kazakhstan"><option value="Kenya"><option value="Kiribati"><option value="Kuwait"><option value="Kyrgyzstan"><option value="Laos"><option value="Latvia"><option value="Lebanon"><option value="Lesotho"><option value="Liberia"><option value="Libya"><option value="Liechtenstein"><option value="Lithuania"><option value="Luxembourg"><option value="Macau"><option value="Madagascar"><option value="Malawi"><option value="Malaysia"><option value="Maldives"><option value="Mali"><option value="Malta"><option value="Marshall Islands"><option value="Martinique"><option value="Mauritania"><option value="Mauritius"><option value="Mayotte"><option value="Mexico"><option value="Micronesia"><option value="Moldova"><option value="Monaco"><option value="Mongolia"><option value="Montserrat"><option value="Morocco"><option value="Mozambique"><option value="Myanmar"><option value="Namibia"><option value="Nauru"><option value="Nepal"><option value="Netherlands"><option value="Netherlands Antilles"><option value="New Caledonia"><option value="New Zealand"><option value="Nicaragua"><option value="Niger"><option value="Nigeria"><option value="Niue"><option value="Norfolk Island"><option value="North Korea"><option value="Northern Marianas"><option value="Norway"><option value="Oman"><option value="Pakistan"><option value="Palau"><option value="Panama"><option value="Papua New Guinea"><option value="Paraguay"><option value="Peru"><option value="Philippines"><option value="Pitcairn Islands"><option value="Poland"><option value="Portugal"><option value="Puerto Rico"><option value="Qatar"><option value="Réunion"><option value="Romania"><option value="Russia"><option value="Rwanda"><option value="São Tomé and Príncipe"><option value="Saint Helena"><option value="Saint Kitts and Nevis"><option value="Saint Lucia"><option value="Saint Pierre and Miquelon"><option value="Saint Vincent and the Grenadines"><option value="Samoa"><option value="San Marino"><option value="Saudi Arabia"><option value="Senegal"><option value="Seychelles"><option value="Sierra Leone"><option value="Singapore"><option value="Slovakia"><option value="Slovenia"><option value="Solomon Islands"><option value="Somalia"><option value="South Africa"><option value="South Georgia and the South Sandwich Islands"><option value="South Korea"><option value="Spain"><option value="Sri Lanka"><option value="Sudan"><option value="Suriname"><option value="Svalbard and Jan Mayen"><option value="Swaziland"><option value="Sweden"><option value="Switzerland"><option value="Syria"><option value="Taiwan"><option value="Tajikistan"><option value="Tanzania"><option value="Thailand"><option value="The Bahamas"><option value="The Gambia"><option value="Togo"><option value="Tokelau"><option value="Tonga"><option value="Trinidad and Tobago"><option value="Tunisia"><option value="Turkey"><option value="Turkmenistan"><option value="Turks and Caicos Islands"><option value="Tuvalu"><option value="US Virgin Islands"><option value="Uganda"><option value="Ukraine"><option value="United Arab Emirates"><option value="United Kingdom"><option value="United States"><option value="United States Minor Outlying Islands"><option value="Uruguay"><option value="Uzbekistan"><option value="Vanuatu"><option value="Vatican City"><option value="Venezuela"><option value="Vietnam"><option value="Wallis and Futuna"><option value="Western Sahara"><option value="Yemen"><option value="Yugoslavia"><option value="Zambia"><option value="Zimbabwe"> </datalist> </div>'; } if ($petition->displays_custom_field == 1) { $petition_widget .= ' <div class="dk-speakout-widget-full"> <label for="dk-speakout-widget-custom-field-' . $petition->id . '">' . stripslashes(esc_html($petition->custom_field_label)) . '</label> <input name="dk-speakout-widget-custom-field" id="dk-speakout-widget-custom-field-' . $petition->id . '" maxlength="400" type="text"> </div>'; } if ($petition->displays_optin == 1) { $optin_default = $options['optin_default'] == 'checked' ? ' checked="checked"' : ''; $petition_widget .= ' <div class="dk-speakout-widget-optin-wrap"> <input type="checkbox" name="dk-speakout-widget-optin" id="dk-speakout-widget-optin-' . $petition->id . '"' . $optin_default . ' /> <label for="dk-speakout-widget-optin-' . $petition->id . '">' . stripslashes(esc_html($petition->optin_label)) . '</label> </div>'; } $petition_widget .= ' <div class="dk-speakout-widget-submit-wrap"> <div id="dk-speakout-widget-ajaxloader-' . $petition->id . '" class="dk-speakout-widget-ajaxloader" style="visibility: hidden;"> </div> <a name="' . $petition->id . '" class="dk-speakout-widget-submit"><span>' . stripslashes(esc_html(__($options['button_text'], 'dk_speakout'))) . '</span></a> </div> </form> <div class="dk-speakout-widget-share"> <p><strong>' . stripslashes(esc_html(__($options['share_message'], 'dk_speakout'))) . '</strong></p> <p> <a class="dk-speakout-widget-facebook" href="#" title="Facebook"><span></span></a> <a class="dk-speakout-widget-twitter" href="#" title="Twitter"><span></span></a> </p> <div class="dk-speakout-clear"></div> </div> </div> </div>'; } echo $petition_widget; } }
function dk_speakout_addnew_page() { // check security: ensure user has authority if (!current_user_can('publish_posts')) { wp_die('Insufficient privileges: You need to be an editor to do that.'); } include_once 'class.petition.php'; include_once 'class.wpml.php'; $petition = new dk_speakout_Petition(); $wpml = new dk_speakout_WPML(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $petition->id = isset($_REQUEST['id']) ? absint($_REQUEST['id']) : ''; switch ($action) { // add a new petition to database // then display form for editing the new petition case 'create': // security: ensure user has intention check_admin_referer('dk_speakout-create_petition'); $petition->poppulate_from_post(); $petition->create(); $wpml->register_petition($petition); // set up page display variables $page_title = __('Edit Email Petition', 'dk_speakout'); $nonce = 'dk_speakout-update_petition' . $petition->id; $action = 'update'; $x_date = $petition->get_expiration_date_components(); $button_text = __('Update Petition', 'dk_speakout'); // construct update message box content $emailpetition_shortcode = '[emailpetition id="' . $petition->id . '"]'; $signaturelist_shortcode = '[signaturelist id="' . $petition->id . '"]'; $start_tag = '<strong>'; $end_tag = '</strong>'; $message_text = __('Petition created. Use %1$s %2$s %3$s to display in a page or post. Use %1$s %4$s %3$s to display the signatures list.', 'dk_speakout'); $message_update = sprintf($message_text, $start_tag, $emailpetition_shortcode, $end_tag, $signaturelist_shortcode); break; // 'edit' is only called from text links on the Email Petitions page // displays existing petition for alteration and submits with 'update' action // 'edit' is only called from text links on the Email Petitions page // displays existing petition for alteration and submits with 'update' action case 'edit': // security: ensure user has intention check_admin_referer('dk_speakout-edit_petition' . $petition->id); $petition->retrieve($petition->id); // set up page display variables $page_title = __('Edit Email Petition', 'dk_speakout'); $nonce = 'dk_speakout-update_petition' . $petition->id; $action = 'update'; $x_date = $petition->get_expiration_date_components(); $button_text = __('Update Petition', 'dk_speakout'); $message_update = ''; break; // alter an existing petition // alter an existing petition case 'update': // security: ensure user has intention check_admin_referer('dk_speakout-update_petition' . $petition->id); $petition->poppulate_from_post(); $petition->update($petition->id); $wpml->register_petition($petition); // set up page display variables $page_title = __('Edit New Email Petition', 'dk_speakout'); $nonce = 'dk_speakout-update_petition' . $petition->id; $action = 'update'; $x_date = $petition->get_expiration_date_components(); $button_text = __('Update Petition', 'dk_speakout'); $message_update = __('Petition updated.'); break; // show blank form for adding a new petition // show blank form for adding a new petition default: // set up page display variables $page_title = __('Add New Email Petition', 'dk_speakout'); $nonce = 'dk_speakout-create_petition'; $action = 'create'; $x_date = $petition->get_expiration_date_components(); $button_text = __('Create Petition', 'dk_speakout'); $message_update = ''; $petition->optin_label = __('Add me to your mailing list', 'dk_speakout'); } if ($petition->return_url == '') { $petition->return_url = home_url(); error_log($petition->return_url); } // display the form include_once 'addnew.view.php'; }
/** * Displays the confirmation page */ function dk_speakout_confirm_email() { // set WPML language global $sitepress; $lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : ''; if (isset($sitepress)) { $sitepress->switch_lang($lang, true); } include_once 'class.signature.php'; include_once 'class.petition.php'; include_once 'class.mail.php'; include_once 'class.wpml.php'; $the_signature = new dk_speakout_Signature(); $the_petition = new dk_speakout_Petition(); $wpml = new dk_speakout_WPML(); // get the confirmation code from url $confirmation_code = $_REQUEST['dkspeakoutconfirm']; // try to confirm the signature $try_confirm = $the_signature->confirm($confirmation_code); // if our attempt to confirm the signature was successful if ($try_confirm) { // retrieve the signature data $the_signature->retrieve_confirmed($confirmation_code); // retrieve the petition data $the_petition->retrieve($the_signature->petitions_id); $wpml->translate_petition($the_petition); // send the petition email if ($the_petition->sends_email) { dk_speakout_Mail::send_petition($the_petition, $the_signature); } // set up the status message $message = __('Thank you. Your signature has been added to the petition.', 'dk_speakout'); } else { // has the signature already been confirmed? if ($the_signature->check_confirmation($confirmation_code)) { $message = __('Your signature has already been confirmed.', 'dk_speakout'); } else { // the confirmation code is fubar or an admin has already deleted the signature $message = __('The confirmation code you provided is invalid.', 'dk_speakout'); } } // display the confirmation page $confirmation_page = ' <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=' . get_bloginfo("charset") . '" /> <meta http-equiv="refresh" content="10;' . $the_petition->return_url . '"> <title>' . get_bloginfo("name") . '</title> <style type="text/css"> body { background: #666; font-family: arial, sans-serif; font-size: 14px; } #confirmation { background: #fff url(' . plugins_url("speakout/images/mail-stripes.png") . ') repeat top left; border: 1px solid #fff; width: 515px; margin: 200px auto 0 auto; box-shadow: 0px 3px 5px #333; } #confirmation-content { background: #fff url(' . plugins_url("speakout/images/postmark.png") . ') no-repeat top right; margin: 10px; padding: 40px 0 20px 100px; } </style> </head> <body> <div id="confirmation"> <div id="confirmation-content"> <h2>' . __("Email Confirmation", "dk_speakout") . '</h2> <p>' . $message . '</p> <p>' . __("You will be redirected momentarily.", "dk_speakout") . '</p> <p><a href="' . home_url() . '">' . get_bloginfo("name") . ' »</a></p> </div> </div> </body> </html> '; echo $confirmation_page; // stop page rendering here // without this, the home page will display below the confirmation message die; }