Example #1
0
function gardenia_option_validate($input)
{
    $input['logo'] = esc_url_raw($input['logo']);
    $input['favicon'] = esc_url_raw($input['favicon']);
    $input['footertext'] = sanitize_text_field($input['footertext']);
    $input['email'] = sanitize_email($input['email']);
    $input['phone'] = wp_filter_nohtml_kses($input['phone']);
    $input['home-title'] = sanitize_text_field($input['home-title']);
    $input['home-content'] = sanitize_text_field($input['home-content']);
    $input['post-title'] = sanitize_text_field($input['post-title']);
    $input['post-content'] = sanitize_text_field($input['post-content']);
    $input['twitter'] = esc_url_raw($input['twitter']);
    $input['fburl'] = esc_url_raw($input['fburl']);
    $input['pinterest'] = esc_url_raw($input['pinterest']);
    $input['linkedin'] = esc_url_raw($input['linkedin']);
    $input['gplus'] = esc_url_raw($input['gplus']);
    $input['rss'] = esc_url_raw($input['rss']);
    for ($gardenia_i = 1; $gardenia_i <= 5; $gardenia_i++) {
        $input['slider-img-' . $gardenia_i] = esc_url_raw($input['slider-img-' . $gardenia_i]);
        $input['slidelink-' . $gardenia_i] = esc_url_raw($input['slidelink-' . $gardenia_i]);
    }
    for ($gardenia_section_i = 1; $gardenia_section_i <= 4; $gardenia_section_i++) {
        $input['home-icon-' . $gardenia_section_i] = esc_url_raw($input['home-icon-' . $gardenia_section_i]);
        $input['section-title-' . $gardenia_section_i] = sanitize_text_field($input['section-title-' . $gardenia_section_i]);
        $input['section-content-' . $gardenia_section_i] = sanitize_text_field($input['section-content-' . $gardenia_section_i]);
        $input['section-link-' . $gardenia_section_i] = esc_url_raw($input['section-link-' . $gardenia_section_i]);
    }
    return $input;
}
Example #2
0
/**
 * Validate/Sanitize options
 */
function kopa_validate_options($input)
{
    $args = kopa_get_options_args();
    foreach ($args as $index => $option) {
        $id = $option['id'];
        if (isset($input[$id])) {
            switch ($option['type']) {
                case 'text':
                    $input[$id] = sanitize_text_field($input[$id]);
                    break;
                case 'url':
                    $input[$id] = esc_url($input[$id]);
                    break;
                case 'email':
                    $input[$id] = sanitize_email($input[$id]);
                    break;
                case 'number':
                    $input[$id] = kopa_sanitize_number($input[$id]);
                    break;
                case 'abs_number':
                    $input[$id] = absint($input[$id]);
                    break;
                case 'textarea':
                    $input[$id] = kopa_sanitize_textarea($input[$id]);
                    break;
                case 'upload':
                    $input[$id] = kopa_sanitize_upload($input[$id]);
                default:
                    break;
            }
        }
    }
    return $input;
}
/**
 * Defines an array of options that will be used to generate the settings page and be saved in the database.
 * When creating the 'id' fields, make sure to use all lowercase and no spaces.
 *
 * If you are making your theme translatable, you should replace 'skt-full-width'
 * with the actual text domain for your theme.  Read more:
 * http://codex.wordpress.org/Function_Reference/load_theme_textdomain
 */
function optionsframework_options()
{
    $options = array();
    $imagepath = get_template_directory_uri() . '/images/';
    //Basic Settings
    $options[] = array('name' => __('Basic Settings', 'skt-full-width'), 'type' => 'heading');
    $options[] = array('name' => __('Logo', 'skt-full-width'), 'desc' => __('Upload your logo here', 'skt-full-width'), 'id' => 'logo', 'class' => '', 'std' => '', 'type' => 'upload');
    $options[] = array('name' => __('Copyright Text', 'skt-full-width'), 'desc' => __('Some Text regarding copyright of your site, you would like to display in the footer.', 'skt-full-width'), 'id' => 'footertext2', 'std' => 'Full Width 2014. All Rights Reserved', 'type' => 'text');
    $options[] = array('name' => __('Featured image as background', 'skt-full-width'), 'desc' => __('Do not use featured image as background image.', 'skt-full-width'), 'id' => 'featured_as_background', 'type' => 'checkbox', 'std' => '');
    $options[] = array('name' => __('Color Scheme', 'skt-full-width'), 'desc' => __('Select the color scheme for theme', 'skt-full-width'), 'id' => 'navigation_color', 'std' => '#7BB303', 'type' => 'color');
    $options[] = array('name' => __('Navigation Icon', 'skt-full-width'), 'desc' => __('Upload icon for navigation<br />(max image size 9px X 9px)', 'skt-full-width'), 'id' => 'navigation_icon', 'class' => '', 'std' => get_template_directory_uri() . "/images/nav-icon-hover.png", 'type' => 'upload');
    $options[] = array('name' => __('Pagination Gradient Color - Top', 'skt-full-width'), 'desc' => __('Select the top gradient color for pagination links', 'skt-full-width'), 'id' => 'pagin_grad_top_color', 'std' => '#89b219', 'type' => 'color');
    $options[] = array('name' => __('Pagination Gradient Color - Bottom', 'skt-full-width'), 'desc' => __('Select the bottom gradient color for pagination links', 'skt-full-width'), 'id' => 'pagin_grad_bottom_color', 'std' => '#3f8d03', 'type' => 'color');
    //Layout Settings
    $options[] = array('name' => __('Layout Settings', 'skt-full-width'), 'type' => 'heading');
    $options[] = array('name' => "Menu Layout", 'desc' => "Select Layout for Menu position. It applies on inner pages only.", 'id' => "sidebar-layout", 'std' => "left", 'type' => "images", 'options' => array('left' => $imagepath . '2cl.png', 'right' => $imagepath . '2cr.png'));
    $options[] = array('name' => __('Custom CSS', 'skt-full-width'), 'desc' => __('Some Custom Styling for your site. Place any css codes here instead of the style.css file.', 'skt-full-width'), 'id' => 'style2', 'std' => '', 'type' => 'textarea');
    //SLIDER SETTINGS
    $options[] = array('name' => __('Homepage Slider', 'skt-full-width'), 'type' => 'heading');
    $options[] = array('name' => __('Slider Effects', 'skt-full-width'), 'desc' => __('Add slider effects number eg: 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left.', 'skt-full-width'), 'id' => 'sliderefect', 'type' => 'text', 'std' => '1');
    $options[] = array('name' => __('Slider Image 1', 'skt-full-width'), 'desc' => __('First Slide', 'skt-full-width'), 'id' => 'slide1', 'class' => '', 'std' => get_template_directory_uri() . "/images/banner_bg.jpg", 'type' => 'upload');
    $options[] = array('desc' => __('Title', 'skt-full-width'), 'id' => 'slidetitle1', 'std' => 'Slider Image 1', 'type' => 'text');
    $options[] = array('desc' => __('Description or Tagline', 'skt-full-width'), 'id' => 'slidedesc1', 'std' => 'Small description for slide 1', 'type' => 'textarea');
    $options[] = array('desc' => __('Url', 'skt-full-width'), 'id' => 'slideurl1', 'std' => '#link1', 'type' => 'text', 'subtype' => 'url');
    $options[] = array('name' => __('Slider Image 2', 'skt-full-width'), 'desc' => __('Second Slide', 'skt-full-width'), 'class' => '', 'id' => 'slide2', 'std' => get_template_directory_uri() . "/images/banner-welcome.jpg", 'type' => 'upload');
    $options[] = array('desc' => __('Title', 'skt-full-width'), 'id' => 'slidetitle2', 'std' => 'Slider Image 2 ', 'type' => 'text');
    $options[] = array('desc' => __('Description or Tagline', 'skt-full-width'), 'id' => 'slidedesc2', 'std' => 'Small description for slide 2', 'type' => 'textarea');
    $options[] = array('desc' => __('Url', 'skt-full-width'), 'id' => 'slideurl2', 'std' => '#link2', 'type' => 'text', 'subtype' => 'url');
    $options[] = array('name' => __('Slider Image 3', 'skt-full-width'), 'desc' => __('Third Slide', 'skt-full-width'), 'id' => 'slide3', 'class' => '', 'std' => '', 'type' => 'upload');
    $options[] = array('desc' => __('Title', 'skt-full-width'), 'id' => 'slidetitle3', 'std' => '', 'type' => 'text');
    $options[] = array('desc' => __('Description or Tagline', 'skt-full-width'), 'id' => 'slidedesc3', 'std' => '', 'type' => 'textarea');
    $options[] = array('desc' => __('Url', 'skt-full-width'), 'id' => 'slideurl3', 'std' => '', 'type' => 'text', 'subtype' => 'url');
    $options[] = array('name' => __('Slider Image 4', 'skt-full-width'), 'desc' => __('Fourth Slide', 'skt-full-width'), 'id' => 'slide4', 'class' => '', 'std' => '', 'type' => 'upload');
    $options[] = array('desc' => __('Title', 'skt-full-width'), 'id' => 'slidetitle4', 'std' => '', 'type' => 'text');
    $options[] = array('desc' => __('Description or Tagline', 'skt-full-width'), 'id' => 'slidedesc4', 'std' => '', 'type' => 'textarea');
    $options[] = array('desc' => __('Url', 'skt-full-width'), 'id' => 'slideurl4', 'std' => '', 'type' => 'text', 'subtype' => 'url');
    $options[] = array('name' => __('Slider Image 5', 'skt-full-width'), 'desc' => __('Fifth Slide', 'skt-full-width'), 'id' => 'slide5', 'class' => '', 'std' => '', 'type' => 'upload');
    $options[] = array('desc' => __('Title', 'skt-full-width'), 'id' => 'slidetitle5', 'std' => '', 'type' => 'text');
    $options[] = array('desc' => __('Description or Tagline', 'skt-full-width'), 'id' => 'slidedesc5', 'std' => '', 'type' => 'textarea');
    $options[] = array('desc' => __('Url', 'skt-full-width'), 'id' => 'slideurl5', 'std' => '', 'type' => 'text', 'subtype' => 'url');
    //Social Settings
    $options[] = array('name' => __('Social Settings', 'skt-full-width'), 'type' => 'heading');
    $options[] = array('desc' => __('Please set the value of following fields, as per the instructions given along. If you do not want to use an icon, just leave it blank. If some icons are showing up, even when no value is set then make sure they are completely blank, and just save the options once. They will not be shown anymore.', 'skt-full-width'), 'type' => 'info');
    $options[] = array('name' => __('Facebook', 'skt-full-width'), 'desc' => __('Facebook Profile or Page URL i.e. http://facebook.com/username/ ', 'skt-full-width'), 'id' => 'facebook', 'std' => '#', 'class' => 'mini', 'type' => 'text', 'subtype' => 'url');
    $options[] = array('name' => __('Twitter', 'skt-full-width'), 'desc' => __('Twitter Username', 'skt-full-width'), 'id' => 'twitter', 'std' => '#', 'class' => 'mini', 'type' => 'text');
    $options[] = array('name' => __('Google Plus', 'skt-full-width'), 'desc' => __('Google Plus profile url, including "http://"', 'skt-full-width'), 'id' => 'google', 'std' => '#', 'class' => 'mini', 'type' => 'text', 'subtype' => 'url');
    $options[] = array('name' => __('Linkedin', 'skt-full-width'), 'desc' => __('Linkedin URL', 'skt-full-width'), 'id' => 'linkedin', 'std' => '#', 'class' => 'mini', 'type' => 'text', 'subtype' => 'url');
    // Contact Details
    $options[] = array('name' => __('Contact Details for footer', 'skt-full-width'), 'type' => 'heading');
    $options[] = array('desc' => __('Company Name', 'skt-full-width'), 'id' => 'contact1', 'std' => 'Full Width', 'type' => 'text');
    $options[] = array('desc' => __('Address 1', 'skt-full-width'), 'id' => 'contact2', 'std' => '123 Some Street', 'type' => 'text');
    $options[] = array('desc' => __('Address 2', 'skt-full-width'), 'id' => 'contact3', 'std' => 'California, USA', 'type' => 'text');
    $options[] = array('desc' => __('Phone', 'skt-full-width'), 'id' => 'contact4', 'std' => '100 2000 300', 'type' => 'text');
    $options[] = array('desc' => __('Email', 'skt-full-width'), 'id' => 'contact5', 'std' => sanitize_email('*****@*****.**'), 'type' => 'text', 'subtype' => 'email');
    // Support
    $options[] = array('name' => __('Our Themes', 'skt-full-width'), 'type' => 'heading');
    $options[] = array('desc' => __('SKT Full Width WordPress theme has been Designed and Created by SKT Themes.', 'skt-full-width'), 'type' => 'info');
    $options[] = array('desc' => '<a href="' . esc_url(SKT_THEME_URL) . '" target="_blank"><img src="' . get_template_directory_uri() . '/images/sktskill.jpg"></a><p><em><a target="_blank" href="' . esc_url(SKT_THEME_URL_DIRECT) . '">' . __('Buy PRO version for only $39 with more features.', 'skt-full-width') . '</a></em></p>', 'type' => 'info');
    return $options;
}
 /**
  * Check if we need to download a file and check validity.
  */
 public static function download_product()
 {
     $product_id = absint($_GET['download_file']);
     $product = wc_get_product($product_id);
     $data_store = WC_Data_Store::load('customer-download');
     if (!$product || !isset($_GET['key'], $_GET['order'])) {
         self::download_error(__('Invalid download link.', 'woocommerce'));
     }
     $download_ids = $data_store->get_downloads(array('user_email' => sanitize_email(str_replace(' ', '+', $_GET['email'])), 'order_key' => wc_clean($_GET['order']), 'product_id' => $product_id, 'download_id' => wc_clean(preg_replace('/\\s+/', ' ', $_GET['key'])), 'orderby' => 'downloads_remaining', 'order' => 'DESC', 'limit' => 1, 'return' => 'ids'));
     if (empty($download_ids)) {
         self::download_error(__('Invalid download link.', 'woocommerce'));
     }
     $download = new WC_Customer_Download(current($download_ids));
     self::check_order_is_valid($download);
     self::check_downloads_remaining($download);
     self::check_download_expiry($download);
     self::check_download_login_required($download);
     do_action('woocommerce_download_product', $download->get_user_email(), $download->get_order_key(), $download->get_product_id(), $download->get_user_id(), $download->get_download_id(), $download->get_order_id());
     $count = $download->get_download_count();
     $remaining = $download->get_downloads_remaining();
     $download->set_download_count($count++);
     $download->set_downloads_remaining($remaining--);
     $download->save();
     self::download($product->get_file_download_path($download->get_download_id()), $download->get_product_id());
 }
Example #5
0
function fu_add_new_user($fu = false)
{
    //echo "wtf?";
    require_once '../../../wp-includes/registration.php';
    global $blog_id;
    $email = sanitize_email($fu['email']);
    //$current_site = get_current_site();
    $pass = $fu['password'];
    $user_id = email_exists($email);
    //echo "hi";
    if (!$user_id) {
        $password = $pass ? $pass : generate_random_password();
        $user_id = wpmu_create_user($fu['username'], $password, $email);
        if (false == $user_id) {
            //echo "uh oh";
            wp_die(__('There was an error creating the user'));
        } else {
            //echo "sending mail";
            wp_new_user_notification($user_id, $password);
        }
        if (get_user_option('primary_blog', $user_id) == $blog_id) {
            update_user_option($user_id, 'primary_blog', $blog_id, true);
        }
    }
    $redirect = $fu['referer'] ? $fu['referer'] : get_bloginfo('url');
    wp_redirect($redirect);
}
Example #6
0
 /** 
  * Called via AJAX to submit the subscribe form. 
  *
  * @since 1.5.2
  * @return string The JSON encoded response.
  */
 public function submit()
 {
     $name = isset($_POST['name']) ? sanitize_text_field($_POST['name']) : false;
     $email = isset($_POST['email']) ? sanitize_email($_POST['email']) : false;
     $node_id = isset($_POST['node_id']) ? sanitize_text_field($_POST['node_id']) : false;
     $result = array('action' => false, 'error' => false, 'message' => false, 'url' => false);
     if ($email && $node_id) {
         $module = FLBuilderModel::get_module($node_id);
         $settings = $module->settings;
         // Subscribe.
         $instance = FLBuilderServices::get_service_instance($settings->service);
         $response = $instance->subscribe($settings, $email, $name);
         // Check for an error from the service.
         if ($response['error']) {
             $result['error'] = $response['error'];
         } else {
             $result['action'] = $settings->success_action;
             if ('message' == $settings->success_action) {
                 $result['message'] = $settings->success_message;
             } else {
                 $result['url'] = $settings->success_url;
             }
         }
     } else {
         $result['error'] = __('There was an error subscribing. Please try again.', 'fl-builder');
     }
     echo json_encode($result);
     die;
 }
/**
 * Sanitizes posted data from before saving an email
 * 
 * @access public
 * @param mixed $posted
 * @return int email id of saved email
 */
function edd_pup_sanitize_save($data)
{
    // Convert form data to array
    if (isset($data['form'])) {
        $form = $data['form'];
        $data = array();
        parse_str($form, $data);
    }
    // Sanitize our data
    $data['message'] = wp_kses_post($data['message']);
    $data['email-id'] = isset($data['email-id']) ? absint($data['email-id']) : 0;
    $data['recipients'] = absint($data['recipients']);
    $data['from_name'] = sanitize_text_field($data['from_name']);
    $data['from_email'] = sanitize_email($data['from_email']);
    $data['title'] = sanitize_text_field($data['title'], 'ID:' . $data['email-id'], 'save');
    $data['subject'] = sanitize_text_field($data['subject']);
    $data['bundle_1'] = sanitize_text_field($data['bundle_1']);
    $data['bundle_2'] = isset($data['bundle_2']) ? 1 : 0;
    // Sanitize products array and convert to ID => name format
    if (isset($data['products'])) {
        foreach ($data['products'] as $product) {
            $prodid = absint($product);
            $products[absint($prodid)] = get_the_title(absint($prodid));
        }
        $data['products'] = $products;
    }
    return edd_pup_save_email($data, $data['email-id']);
}
Example #8
0
 /**
  * Hooks into WordPress' save_post function
  */
 public function save_post($post_id)
 {
     if (!isset($_POST['advanced_options_nonce'])) {
         return $post_id;
     }
     $nonce = $_POST['advanced_options_nonce'];
     if (!wp_verify_nonce($nonce, 'advanced_options_data')) {
         return $post_id;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     foreach ($this->fields as $field) {
         if (isset($_POST[$field['id']])) {
             switch ($field['type']) {
                 case 'email':
                     $_POST[$field['id']] = sanitize_email($_POST[$field['id']]);
                     break;
                 case 'text':
                     $_POST[$field['id']] = sanitize_text_field($_POST[$field['id']]);
                     break;
             }
             update_post_meta($post_id, 'advanced_options_' . $field['id'], $_POST[$field['id']]);
         } else {
             if ($field['type'] === 'checkbox') {
                 update_post_meta($post_id, 'advanced_options_' . $field['id'], '0');
             }
         }
     }
 }
function sanitize_option($option, $value) {

	switch ($option) {
		case 'admin_email':
			$value = sanitize_email($value);
			break;

		case 'default_post_edit_rows':
		case 'mailserver_port':
		case 'comment_max_links':
			$value = abs((int) $value);
			break;

		case 'posts_per_page':
		case 'posts_per_rss':
			$value = (int) $value;
			if ( empty($value) ) $value = 1;
			if ( $value < -1 ) $value = abs($value);
			break;

		case 'default_ping_status':
		case 'default_comment_status':
			// Options that if not there have 0 value but need to be something like "closed"
			if ( $value == '0' || $value == '')
				$value = 'closed';
			break;

		case 'blogdescription':
		case 'blogname':
			if (current_user_can('unfiltered_html') == false)
				$value = wp_filter_post_kses( $value );
			break;

		case 'blog_charset':
			$value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value);
			break;

		case 'date_format':
		case 'time_format':
		case 'mailserver_url':
		case 'mailserver_login':
		case 'mailserver_pass':
		case 'ping_sites':
		case 'upload_path':
			$value = strip_tags($value);
			$value = wp_filter_kses($value);
			break;

		case 'gmt_offset':
			$value = preg_replace('/[^0-9:.-]/', '', $value);
			break;

		case 'siteurl':
		case 'home':
			$value = clean_url($value);
			break;
	}

	return $value;	
}
Example #10
0
/**
 * Sanitizes an email input
 *
 * @package lsx-theme
 * @subpackage sanitize
 *
 * @param string $email
 * @param obj $setting
 * @return string $default
 */
function lsx_sanitize_email($email, $setting)
{
    // Sanitize $input as a hex value without the hash prefix.
    $email = sanitize_email($email);
    // If $email is a valid email, return it; otherwise, return the default.
    return !is_null($email) ? $email : $setting->default;
}
Example #11
0
 /**
  * AJAX Register.
  *
  * @since 1.0.0
  */
 public function ajax_register()
 {
     // First check the nonce, if it fails the function will break
     check_ajax_referer('vr-ajax-register-nonce', 'vr-secure-register');
     // Nonce is checked, Get to work
     $info = array();
     $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['register_username']);
     $info['user_pass'] = sanitize_text_field($_POST['register_pwd']);
     $info['user_email'] = sanitize_email($_POST['register_email']);
     // Register the user
     $user_register = wp_insert_user($info);
     if (is_wp_error($user_register)) {
         $error = $user_register->get_error_codes();
         if (in_array('empty_user_login', $error)) {
             echo json_encode(array('success' => false, 'message' => __($user_register->get_error_message('empty_user_login'))));
         } elseif (in_array('existing_user_login', $error)) {
             echo json_encode(array('success' => false, 'message' => __('This username already exists.', 'VRC')));
         } elseif (in_array('existing_user_email', $error)) {
             echo json_encode(array('success' => false, 'message' => __('This email is already registered.', 'VRC')));
         }
     } else {
         /**
          * Object: VR_Member class.
          *
          * @since 1.0.0
          */
         $vr_member_object = new VR_Member();
         $vr_member_object->ajax_user_authenticate($info['user_login'], $info['user_pass'], __('Registration', 'VRC'));
     }
     die;
 }
Example #12
0
/**
 * Grant downloadable product access to the file identified by $download_id
 *
 * @access public
 * @param string $download_id file identifier
 * @param int $product_id product identifier
 * @param WC_Order $order the order
 * @return int|bool insert id or false on failure
 */
function wc_downloadable_file_permission($download_id, $product_id, $order)
{
    global $wpdb;
    if ($order->status == 'processing' && get_option('woocommerce_downloads_grant_access_after_payment') == 'no') {
        return false;
    }
    $user_email = sanitize_email($order->billing_email);
    $limit = trim(get_post_meta($product_id, '_download_limit', true));
    $expiry = trim(get_post_meta($product_id, '_download_expiry', true));
    $limit = empty($limit) ? '' : absint($limit);
    // Default value is NULL in the table schema
    $expiry = empty($expiry) ? null : absint($expiry);
    if ($expiry) {
        $order_completed_date = date_i18n("Y-m-d", strtotime($order->completed_date));
        $expiry = date_i18n("Y-m-d", strtotime($order_completed_date . ' + ' . $expiry . ' DAY'));
    }
    $data = apply_filters('woocommerce_downloadable_file_permission_data', array('download_id' => $download_id, 'product_id' => $product_id, 'user_id' => absint($order->user_id), 'user_email' => $user_email, 'order_id' => $order->id, 'order_key' => $order->order_key, 'downloads_remaining' => $limit, 'access_granted' => current_time('mysql'), 'download_count' => 0));
    $format = apply_filters('woocommerce_downloadable_file_permission_format', array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d'), $data);
    if (!is_null($expiry)) {
        $data['access_expires'] = $expiry;
        $format[] = '%s';
    }
    // Downloadable product - give access to the customer
    $result = $wpdb->insert($wpdb->prefix . 'woocommerce_downloadable_product_permissions', $data, $format);
    do_action('woocommerce_grant_product_download_access', $data);
    return $result ? $wpdb->insert_id : false;
}
Example #13
0
function koabase_get_socials_icon()
{
    $facebook_url = $twitter_url = $googleplus_url = $skype_link = $flickr_link = $youtube_url = $rss_link = $instagram_url = $pinterest_url = $email_link = '';
    if ($facebook_url != '') {
        $out .= '<a class="facebook" 	href="' . esc_url($facebook_url) . '" target="_blank"></a>';
    }
    if ($twitter_url != '') {
        $out .= '<a class="twitter" 	href="' . esc_url($twitter_url) . '" target="_blank"></a>';
    }
    if ($googleplus_url != '') {
        $out .= '<a class="googleplus" href="' . esc_url($googleplus_url) . '" target="_blank"></a>';
    }
    if ($skype_link != '') {
        $out .= '<a class="skype" 	href="skype:' . esc_attr($skype_link) . '?call"></a>';
    }
    if ($flickr_link != '') {
        $out .= '<a class="flickr" 	href="' . esc_url($flickr_link) . '" target="_blank"></a>';
    }
    if ($youtube_url != '') {
        $out .= '<a class="youtube" 	href="' . esc_url($youtube_url) . '" target="_blank"></a>';
    }
    if ($rss_link != '') {
        $out .= '<a class="rss" 		href="' . esc_url($rss_link) . '" target="_blank"></a>';
    }
    if ($instagram_url != '') {
        $out .= '<a class="instagram"	href="' . esc_url($instagram_url) . '" target="_blank"></a>';
    }
    if ($pinterest_url != '') {
        $out .= '<a class="pinterest"	href="' . esc_url($pinterest_url) . '" target="_blank"></a>';
    }
    if ($email_link != '') {
        $out .= '<a class="email" 	href="mailto:' . sanitize_email($email_link) . '"></a>';
    }
    echo '<div class="social-icon">' . $out . '</div>';
}
Example #14
0
/**
 * hermes_contact_form_send_email  called by ajax from client-validation.js
 * @return array the feedback array with the keys 
 *     - status: error|success
 *     - message: string
 */
function hermes_contact_form_send_email()
{
    $feedback = array('status' => 'error');
    // check if the CSRF token is valid
    if (!@isset($_POST['csrf_token']) || !wp_verify_nonce($_POST['csrf_token'], 'contact_form_token')) {
        $feedback['message'] = 'Wrong CSRF token.';
        die(json_encode($feedback));
    }
    if (!@isset($_POST['name']) || !@isset($_POST['email']) || !@isset($_POST['message'])) {
        $feedback['message'] = 'The form is incomplete.';
        die(json_encode($feedback));
    }
    // Sanitize
    $name = sanitize_text_field($_POST['name']);
    $email = sanitize_email($_POST['email']);
    $message = sanitize_text_field($_POST['message']);
    // Validations
    hermes_contact_form_validate_form($name, $email, $message);
    $headers = 'From: ' . $name . ' <' . $email . '>' . "\r\n";
    $to = "*****@*****.**";
    $subject = 'EML foundation website message';
    $message = '<p>' . $message . '</p><p>' . $name . '</p>';
    // Send the email
    if (wp_mail($to, $subject, $message, $headers)) {
        $feedback['status'] = 'success';
        $feedback['message'] = 'Message has been sent succesfully!';
    } else {
        $feedback['message'] = 'Impossible to send the message';
    }
    die(json_encode($feedback));
}
Example #15
0
function ajax_register()
{
    // First check the nonce, if it fails the function will break
    check_ajax_referer('ajax-register-nonce', 'security');
    // Nonce is checked, get the POST data and sign user on
    $info = array();
    $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['username']);
    $info['user_pass'] = sanitize_text_field($_POST['password']);
    $info['user_email'] = sanitize_email($_POST['email']);
    // Register the user
    $user_register = wp_insert_user($info);
    if (is_wp_error($user_register)) {
        $error = $user_register->get_error_codes();
        if (in_array('empty_user_login', $error)) {
            echo json_encode(array('loggedin' => false, 'message' => __($user_register->get_error_message('empty_user_login'))));
        } elseif (in_array('existing_user_login', $error)) {
            echo json_encode(array('loggedin' => false, 'message' => __('This username is already registered.')));
        } elseif (in_array('existing_user_email', $error)) {
            echo json_encode(array('loggedin' => false, 'message' => __('This email address is already registered.')));
        }
    } else {
        auth_user_login($info['nickname'], $info['user_pass'], 'Registration');
    }
    die;
}
function advent_options_validate($input)
{
    $input['logo'] = advent_image_validation(esc_url_raw($input['logo']));
    $input['favicon'] = advent_image_validation(esc_url_raw($input['favicon']));
    $input['footertext'] = sanitize_text_field($input['footertext']);
    $input['topheading'] = sanitize_text_field($input['topheading']);
    $input['headertop-logo'] = advent_image_validation(esc_url_raw($input['headertop-logo']));
    $input['headertop-img'] = advent_image_validation(esc_url_raw($input['headertop-img']));
    $input['headertop-bg'] = advent_image_validation(esc_url_raw($input['headertop-bg']));
    $input['home-title'] = sanitize_text_field($input['home-title']);
    $input['home-content'] = sanitize_text_field($input['home-content']);
    $input['howitwork'] = sanitize_text_field($input['howitwork']);
    $input['howitworktitle'] = sanitize_text_field($input['howitworktitle']);
    $input['howitworkdesc'] = sanitize_text_field($input['howitworkdesc']);
    $input['howitwork-img'] = advent_image_validation(esc_url_raw($input['howitwork-img']));
    $input['post-title'] = sanitize_text_field($input['post-title']);
    $input['email'] = sanitize_email($input['email']);
    $input['facebook'] = esc_url_raw($input['facebook']);
    $input['twitter'] = esc_url_raw($input['twitter']);
    $input['pinterest'] = esc_url_raw($input['pinterest']);
    for ($advent_section_i = 1; $advent_section_i <= 6; $advent_section_i++) {
        $input['section-title-' . $advent_section_i] = sanitize_text_field($input['section-title-' . $advent_section_i]);
        $input['section-content-' . $advent_section_i] = sanitize_text_field($input['section-content-' . $advent_section_i]);
    }
    return $input;
}
 /**
  * Constructor.
  *
  * @since 2.5.0
  *
  * @param string|array|int|WP_User $email_or_user Either a email address, user ID, WP_User object,
  *                                                or an array containing any combination of the above.
  * @param string $name Optional. If $email_or_user is a string, this is the recipient's name.
  */
 public function __construct($email_or_user, $name = '')
 {
     $name = sanitize_text_field($name);
     // User ID, email address or WP_User object.
     if (is_int($email_or_user) || is_string($email_or_user) && is_email($email_or_user) || is_object($email_or_user)) {
         // We already have a WP user.
         if (is_object($email_or_user)) {
             $this->user_object = $email_or_user;
             // Query for WP user by user ID.
         } elseif (is_int($email_or_user)) {
             $this->user_object = get_user_by('id', $email_or_user);
         }
         // Set email address.
         if (empty($this->user_object) && is_email($email_or_user)) {
             $address = $email_or_user;
         }
         // Array or miscellaneous string.
     } else {
         if (!is_array($email_or_user)) {
             $email_or_user = array($email_or_user => $name);
         }
         // Handle numeric arrays.
         if (is_int(key($email_or_user))) {
             $address = current($email_or_user);
         } else {
             $address = key($email_or_user);
             $name = current($email_or_user);
         }
     }
     // Set address if we have one.
     if (!empty($address)) {
         $this->address = sanitize_email($address);
     }
     // Still no user object; try to query user by email address.
     if (empty($this->user_object)) {
         $this->get_user('search-email');
     }
     // We have a user object; so set address and name from DB.
     if ($this->user_object) {
         // This is escaped with esc_html in bp_core_get_user_displayname()
         $wp_name = wp_specialchars_decode(bp_core_get_user_displayname($this->user_object->ID), ENT_QUOTES);
         $this->address = $this->user_object->user_email;
         $this->name = sanitize_text_field($wp_name);
     }
     // Custom name override.
     if ($name) {
         $this->name = $name;
     }
     /**
      * Fires inside __construct() method for BP_Email_Recipient class.
      *
      * @since 2.5.0
      *
      * @param string|array|int|WP_User $email_or_user Either a email address, user ID, WP_User object,
      *                                                or an array containing any combination of the above.
      * @param string $name If $email_or_user is a string, this is the recipient's name.
      * @param BP_Email_Recipient $this Current instance of the email type class.
      */
     do_action('bp_email_recipient', $email_or_user, $name, $this);
 }
 protected function send_reg_email()
 {
     global $wpdb;
     if (empty($this->member_info)) {
         return false;
     }
     $member_info = $this->member_info;
     $settings = BSettings::get_instance();
     $subject = $settings->get_value('reg-complete-mail-subject');
     $body = $settings->get_value('reg-complete-mail-body');
     $from_address = $settings->get_value('email-from');
     $login_link = $settings->get_value('login-page-url');
     $headers = 'From: ' . $from_address . "\r\n";
     $member_info['membership_level_name'] = BPermission::get_instance($member_info['membership_level'])->get('alias');
     $member_info['password'] = $member_info['plain_password'];
     $member_info['login_link'] = $login_link;
     $values = array_values($member_info);
     $keys = array_map('swpm_enclose_var', array_keys($member_info));
     $body = str_replace($keys, $values, $body);
     $email = sanitize_email(filter_input(INPUT_POST, 'email', FILTER_UNSAFE_RAW));
     wp_mail(trim($email), $subject, $body, $headers);
     if ($settings->get_value('enable-admin-notification-after-reg')) {
         $subject = "Notification of New Member Registration";
         $body = "A new member has registered. The following email was sent to the member." . "\n\n-------Member Email----------\n" . $body . "\n\n------End------\n";
         wp_mail($from_address, $subject, $body, $headers);
     }
     return true;
 }
Example #19
0
function deliver_mail()
{
    // if the submit button is clicked, send the email
    if (isset($_POST['cf-submitted']) && $_POST["cf-url"] == '') {
        // sanitize form values
        $name = sanitize_text_field($_POST["cf-name"]);
        $email = sanitize_email($_POST["cf-email"]);
        $subject = 'Website Contact and Prayer Request Form Submission';
        $message = esc_textarea($_POST["cf-message"]);
        // get the blog administrator's email address
        $to = get_field('main_campus_email', 'options');
        //$to = '*****@*****.**';
        $headers = "From: {$name} <{$email}>" . "\r\n";
        // If email has been process for sending, display a success message
        if (wp_mail($to, $subject, $message, $headers)) {
            echo '<div>';
            echo '<p class="success">Thanks for getting in touch with us. Your request has been submitted.</p>';
            echo '</div>';
        } else {
            echo '<div>';
            echo '<p class="error">We\'re terribly sorry, but it looks like an error occurred. Please make sure all fields are filled out and try submitting your request again.</p>';
            echo '</div>';
        }
    }
}
 public function customer_note_added($data)
 {
     global $wpdb;
     $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE id = %d", $data['order_id']));
     if ($post && $post->post_type == 'order_shipment') {
         $parent_id = $post->post_parent;
         $is_customer_note = intval(1);
         if (isset($_SERVER['HTTP_HOST'])) {
             $comment_author_email = sanitize_email(strtolower(__('WooCommerce', 'woocommerce')) . '@' . str_replace('www.', '', $_SERVER['HTTP_HOST']));
         } else {
             $comment_author_email = sanitize_email(strtolower(__('WooCommerce', 'woocommerce')) . '@noreply.com');
         }
         $comment_post_ID = $parent_id;
         $comment_author = __('WooCommerce', 'woocommerce');
         $comment_author_url = '';
         $comment_content = $data['customer_note'];
         $comment_agent = 'WooCommerce';
         $comment_type = 'order_note';
         $comment_parent = 0;
         $comment_approved = 1;
         $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_agent', 'comment_type', 'comment_parent', 'comment_approved');
         $comment_id = wp_insert_comment($commentdata);
         add_comment_meta($comment_id, 'is_customer_note', $is_customer_note);
     }
 }
Example #21
0
 /**
  * @since 1.0.0
  */
 public function form_handler()
 {
     if (!empty($_POST['stylify_button'])) {
         $status = $this->stylify->refresh();
         $message = is_wp_error($status) ? $status->get_error_message() : __('Colors updated.', 'Postmatic');
         $class = is_wp_error($status) ? 'error' : 'updated';
         Prompt_Core::$options->set('site_styles', $this->stylify->get_styles());
         $this->add_notice($message, $class);
         return;
     }
     if (!empty($_POST['reset_site_styles_button'])) {
         Prompt_Core::$options->set('site_styles', array());
         $this->stylify = new Prompt_Stylify(array());
         $this->add_notice(__('Colors set to defaults.', 'Postmatic'));
         return;
     }
     if (!empty($_POST['send_test_email_button'])) {
         $to_address = sanitize_email($_POST['test_email_address']);
         if (!is_email($to_address)) {
             $this->add_notice(__('Test email was <strong>not sent</strong> to an invalid address.', 'Postmatic'), 'error');
             return;
         }
         $html_template = new Prompt_Template('test-email.php');
         $footnote = __('This is a test email sent by Postmatic. It is solely for demonstrating the Postmatic template and is not replyable. Also, that is not latin. <a href="https://en.wikipedia.org/wiki/Lorem_ipsum">It is Lorem ipsum</a>.', 'Postmatic');
         $batch = new Prompt_Email_Batch(array('subject' => __('This is a test email. By Postmatic.', 'Postmatic'), 'html_content' => $html_template->render(), 'message_type' => Prompt_Enum_Message_Types::ADMIN, 'footnote_html' => $footnote, 'footnote_text' => $footnote));
         $batch->add_individual_message_values(array('to_address' => $to_address));
         if (!is_wp_error(Prompt_Factory::make_mailer($batch)->send())) {
             $this->add_notice(__('Test email <strong>sent</strong>.', 'Postmatic'));
             return;
         }
     }
     parent::form_handler();
 }
function SendForm()
{
    // if the submit button is clicked, send the information to the API
    if (isset($_POST['submit'])) {
        $api_url = "http://www.rdstation.com.br/api/1.2/conversions";
        // sanitize form values
        $form_data["token_rdstation"] = esc_attr(get_option('rd_station_token'));
        $form_data["identificador"] = esc_attr(get_option('identificador'));
        $form_data["email"] = sanitize_text_field($_POST["email"]);
        $form_data["nome"] = sanitize_text_field($_POST["nome"]);
        $form_data["empresa"] = sanitize_email($_POST["empresa"]);
        $form_data["cargo"] = esc_textarea($_POST["cargo"]);
        $form_data["telefone"] = sanitize_text_field($_POST["telefone"]);
        $form_data["celular"] = sanitize_email($_POST["celular"]);
        $form_data["website"] = sanitize_text_field($_POST["website"]);
        $form_data["twitter"] = esc_textarea($_POST["twitter"]);
        $args = array('headers' => array('Content-Type' => 'application/json'), 'body' => json_encode($form_data));
        //print_r($form_data);
        //die();
        $response = wp_remote_post($api_url, $args);
        if (is_wp_error($response)) {
            wp_die('Erro ao enviar o formulário');
            unset($form_data);
        } else {
            echo '<div id="message" class="updated" style="display: block;"><p>Obrigada por se registrar</p></div>';
        }
    }
}
Example #23
0
function http_call()
{
    // if the submit button is clicked, send the email
    if (isset($_POST['http-submitted'])) {
        // sanitize form values
        $name = sanitize_text_field($_POST["http-name"]);
        $email = sanitize_email($_POST["http-email"]);
        $application = sanitize_text_field($_POST["http-application"]);
        $password = $_POST["http-password"];
        //        $DispForm = False;
        // setup the http call
        /* UCD test site
        $url = 'https://rtpucd01-srv.tivlab.raleigh.ibm.com:8443/cli/application/';
        */
        /* vLaunch test site
        $url = 'https://vlaunch.rtp.raleigh.ibm.com/groups';
        */
        $url = 'https://rtpucd01-srv.tivlab.raleigh.ibm.com:8443/cli/application/';
        $args = array('headers' => array('Authorization' => 'Basic ' . base64_encode($name . ':' . $password)), 'sslverify' => false);
        $response = wp_remote_get($url, $args);
        print_r($response);
        $response_code = wp_remote_retrieve_response_code($response);
        print_r($response_code);
        // If http has been processed, display a success message
        if ($response_code == '200') {
            echo '<div>';
            echo '<p>http call successful, result is:</p>';
            echo '</div>';
            $body = wp_remote_retrieve_body($response);
            print_r($response_code);
        } else {
            echo 'An unexpected error occurred';
        }
    }
}
 /**
  * Function to sanitize email
  *
  * @access public
  * @since 1.1
  *
  * @param $coder_input
  * @return int || float
  *
  */
 function coder_sanitize_email($coder_email, $coder_setting)
 {
     // Sanitize $coder_email as a hex value without the hash prefix.
     $coder_email = sanitize_email($coder_email);
     // If $coder_email is a valid email, return it; otherwise, return the default.
     return !null($coder_email) ? $coder_email : $coder_setting->default;
 }
        /**
         * Front-end display of widget.
         * @see WP_Widget::widget()
         * @param array $args     Widget arguments.
         * @param array $instance Saved values from database.
         */
        public function widget($args, $instance)
        {
            extract($args);
            extract($instance);
            global $allowed_html_tags;
            $email = sanitize_email($email);
            $email = is_email($email);
            $title = apply_filters('widget_title', $title);
            echo $before_widget;
            ?>
            <?php 
            echo $title ? $before_title . $title . $after_title : false;
            ?>
            <section class="contact-option-single">
                <address>
                    <p><?php 
            echo $address ? wp_kses($address, $allowed_html_tags) : '';
            ?>
</p>
                </address>
                <ul class="contact-options">
                    <?php 
            echo $phone ? '<li class="phone"><span>' . __('Phone: ', 'majestic-widgets') . '</span>' . esc_attr($phone) . '</li>' : '';
            echo $fax ? '<li class="fax"><span>' . __('Fax: ', 'majestic-widgets') . '</span>' . esc_attr($fax) . '</li>' : '';
            echo $email ? '<li class="email"><span>' . __('Email: ', 'majestic-widgets') . '</span><a href="mailto:' . $email . '">' . $email . '</a></li>' : '';
            ?>
                </ul>
            </section>
            <?php 
            echo $after_widget;
        }
Example #26
0
function send_email()
{
    // Verify nonce
    if (!isset($_POST['reef_nonce']) || !wp_verify_nonce($_POST['reef_nonce'], 'reef_nonce')) {
        die('Permission denied');
    }
    $data = array();
    parse_str($_POST['data'], $data);
    $name = sanitize_text_field($data['fname']);
    $tel = sanitize_text_field($data['fphone']);
    $email = sanitize_email($data['femail']);
    $count = sanitize_text_field($data['fcount']);
    $to = '*****@*****.**';
    $subject = 'Резерв мест - ' . $count . ' шт';
    $subject = "=?utf-8?b?" . base64_encode($subject) . "?=";
    $message = "\r\nЗаявка отправленна с сайта " . $_SERVER['HTTP_REFERER'] . "\r\nEmail: " . $email . "\r\nИмя: " . $name . "\r\nТелефон: " . $tel . "\r\nКоличество персон: " . $count . "\r\n";
    $headers = 'Content-type: text/plain; charset="utf-8"';
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Date: " . date('D, d M Y h(idea)(worry) O') . "\r\n";
    mail($to, $subject, $message, $headers);
    ?>

    <div class="reserve-msg-wrapper">
        <div class="reserve-msg-container">
            <div class="reserve-msg-content popup-content">
                <div class="msg">
                    <p>Спасибо, ваш запрос отправлен!</p>
                    <ul class="fenti">
                        <li><?php 
    echo return_fenty(array('id' => 2));
    ?>
</li>
                        <li><?php 
    echo return_fenty(array('id' => 4));
    ?>
</li>
                        <li><?php 
    echo return_fenty(array('id' => 9));
    ?>
</li>
                        <li><?php 
    echo return_fenty(array('id' => 7));
    ?>
</li>
                    </ul>
                </div>
                <figure>
                    <img src="<?php 
    echo REEF_THEME_URL . 'assets/images/success_form_corr.jpg';
    ?>
" alt=""/>
                </figure>
            </div>
        </div>
    </div>


    <?php 
    exit;
}
Example #27
0
/**
 * Validate data and send mail.
 *
 * @see http://codex.wordpress.org/Function_Reference/wp_mail
 * @return {int} Status of message:
 * -2 => Invalid data
 * -1 => Failed to send
 *  1 => OK
 */
function sendMail()
{
    header("Content-Type: application/json");
    $response = array('status' => -2, 'errors' => array());
    if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['message'])) {
        echo json_encode($response);
        die;
    }
    $name = esc_attr($_POST['name']);
    $email = sanitize_email($_POST['email']);
    $message = esc_textarea($_POST['message']);
    if (!strlen($name)) {
        $response['errors']['name'] = "C'mon, what's your name?";
    }
    if (!is_email($email)) {
        $response['errors']['email'] = "Please, give us valid email.";
    }
    if (!strlen($message)) {
        $response['errors']['message'] = "No message, huh?";
    }
    if (empty($response['errors'])) {
        $to = get_bloginfo('admin_email');
        $subject = 'Contact from ' . get_bloginfo('name');
        $headers[] = "From: {$name} <{$email}>";
        $isSent = wp_mail($to, $subject, $message, $headers);
        $response['status'] = $isSent ? 1 : -1;
    }
    echo json_encode($response);
    die;
}
 /**
  * Prepare items to be displayed and setup pagination data
  */
 public function prepare_items()
 {
     $wpdb = Follow_Up_Emails::instance()->wpdb;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = array();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $per_page = 20;
     $page = empty($_GET['paged']) ? 1 : absint($_GET['paged']);
     $start = $per_page * $page - $per_page;
     $sql = "SELECT SQL_CALC_FOUND_ROWS *\n                FROM {$wpdb->prefix}followup_email_orders eo, {$wpdb->posts} p\n                WHERE 1=1\n                AND eo.is_sent = 0\n                AND p.ID = eo.email_id";
     if (!empty($_GET['_customer_user'])) {
         // filter by user id/user email
         $user = new WP_User($_GET['_customer_user']);
         $user_email = $user->billing_email;
         if (empty($user_email)) {
             $user_email = $user->user_email;
         }
         $sql .= " AND (\n                user_id = " . esc_sql(absint($user->ID)) . " OR\n                user_email = '" . esc_sql(sanitize_email($user_email)) . "'\n            )";
     }
     $sql .= " ORDER BY send_on DESC LIMIT {$start},{$per_page}";
     $this->items = $wpdb->get_results($sql, ARRAY_A);
     $total_items = $wpdb->get_var("SELECT FOUND_ROWS()");
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
 }
Example #29
0
function ajax_register()
{
    // First check the nonce, if it fails the function will break
    check_ajax_referer('ajax-register-nonce', 'security');
    // Nonce is checked, get the POST data and sign user on
    $info = array();
    $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['username']);
    $info['user_pass'] = sanitize_text_field($_POST['password']);
    $info['user_email'] = sanitize_email($_POST['email']);
    // Register the user
    $user_register = wp_insert_user($info);
    if (is_wp_error($user_register)) {
        $error = $user_register->get_error_codes();
        if (in_array('empty_user_login', $error)) {
            echo json_encode(array('loggedin' => false, 'message' => __('Xin lỗi, thông tin đăng nhập không hợp lệ.')));
        } else {
            if (in_array('existing_user_login', $error)) {
                echo json_encode(array('loggedin' => false, 'message' => __('Xin lỗi, tên đăng nhập này đã tồn tại.')));
            } else {
                if (in_array('existing_user_email', $error)) {
                    echo json_encode(array('loggedin' => false, 'message' => __('Xin lỗi, thư điện tử này đã tồn tại.')));
                }
            }
        }
        //        else echo json_encode(array('loggedin'=>false, 'message'=>__($user_register->get_error_messages($error))));
    } else {
        wp_insert_user($info);
        echo json_encode(array('loggedin' => true, 'message' => __('Đăng ký thành công.')));
    }
    die;
}
Example #30
0
function os_form_process()
{
    // Check nonce
    check_ajax_referer('contact_form_nonce', 'nonce');
    // Check Recaptcha
    if (!$_POST['g-recaptcha-response']) {
        die;
    }
    $url = 'https://www.google.com/recaptcha/api/siteverify';
    $data = array('secret' => '6LdyAhcTAAAAABSH9lEARxFK2OTW9eLpfc9p4NP-', 'response' => $_POST['g-recaptcha-response']);
    $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)));
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    // if Recaptcha FAILS
    if ($result === FALSE) {
        die;
    }
    // Build the data
    $subject = $_POST['contact_subject'];
    $name = sanitize_text_field($_POST['contact_name']);
    $company = sanitize_text_field($_POST['contact_company']);
    $email = sanitize_email($_POST['contact_email']);
    $message = esc_textarea($_POST['contact_message']);
    $to = get_option('admin_email');
    $body = "Name: " . $name . " <" . $email . ">\n";
    $body .= "Company: " . $company . "\n";
    $body .= "Subject: " . $subject . "\n\n";
    $body .= $message;
    // Send Mail notification
    $mail_sent = wp_mail($to, "New OS form submission — " . $name, $body);
    // Insert new post
    $new_post = wp_insert_post(array('post_title' => $name . ' — ' . $subject, 'post_content' => $body, 'post_status' => 'publish', 'post_type' => 'form_entry'));
    // Return JSON
    wp_send_json(array('to' => $to, 'subject' => "New OS form submission — " . $name, 'body' => $body, 'recaptcha' => true, 'result' => $result, 'mail_sent' => $mail_sent, 'new_post' => $new_post));
}