Example #1
0
function wppb_userdata_add_yim($userdata, $global_request)
{
    if (isset($global_request['yim'])) {
        $userdata['yim'] = sanitize_text_field(trim($global_request['yim']));
    }
    return $userdata;
}
 /**
  * Columns shortcode
  *
  * @param array $atts
  * @param string $content
  * @return string
  */
 function wolf_columns_shortcode($atts, $content = null)
 {
     // if ( class_exists( 'Vc_Manager' ) && function_exists( 'vc_map_get_attributes' ) ) {
     // 	$atts = vc_map_get_attributes( 'wolf_column', $atts );
     // }
     extract(shortcode_atts(array('col' => 'col-6', 'class' => '', 'first' => '', 'last' => '', 'inline_style' => ''), $atts));
     $col = esc_attr($col);
     $first = esc_attr($first);
     $last = esc_attr($last);
     $col = esc_attr($col);
     $inline_style = sanitize_text_field($inline_style);
     $output = '';
     $style = '';
     $class = $class ? "{$class} " : '';
     // add space
     if ($inline_style) {
         $style .= $inline_style;
     }
     $style = $style ? " style='{$style}'" : '';
     if ($first) {
         $class = 'first';
     } elseif ($last) {
         $class = 'last';
     }
     if ($class == 'first') {
         $output .= '<div class="clear"></div>';
     }
     $output .= '<div class="' . $col . ' ' . $class . '"' . $style . '>' . do_shortcode($content) . '</div>';
     if ($class == 'last') {
         $output .= '<div class="clear"></div>';
     }
     return $output;
 }
Example #3
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;
}
 public function ask_form_name_field($args)
 {
     if (!is_user_logged_in() && ap_opt('allow_anonymous')) {
         $args['fields'][] = array('name' => 'name', 'label' => __('Name', 'ap'), 'type' => 'text', 'placeholder' => __('Enter your name to display', 'ap'), 'value' => sanitize_text_field(@$_POST['name']), 'order' => 12);
     }
     return $args;
 }
Example #5
0
 /**
  * Construct
  */
 function __construct($args = array(), $hook_prefs = NULL, $type = 'mycred_default')
 {
     if (!empty($args)) {
         foreach ($args as $key => $value) {
             $this->{$key} = $value;
         }
     }
     // Grab myCRED Settings
     $this->core = mycred($type);
     if (!empty($type)) {
         $this->core->cred_id = sanitize_text_field($type);
         $this->mycred_type = $this->core->cred_id;
     }
     if ($this->mycred_type != 'mycred_default') {
         $this->is_main_type = false;
     }
     // Grab settings
     if ($hook_prefs !== NULL) {
         // Assign prefs if set
         if (isset($hook_prefs[$this->id])) {
             $this->prefs = $hook_prefs[$this->id];
         }
         // Defaults must be set
         if (!isset($this->defaults)) {
             $this->defaults = array();
         }
     }
     // Apply default settings if needed
     if (!empty($this->defaults)) {
         $this->prefs = mycred_apply_defaults($this->defaults, $this->prefs);
     }
 }
Example #6
0
 /**
  * Update widget instance.
  *
  * @since 1.0.0
  *
  * @param array $new_instance New settings for this instance as input by the user via
  *                            {@see WP_Widget::form()}.
  * @param array $old_instance Old settings for this instance.
  * @return array Settings to save or bool false to cancel saving.
  */
 function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $new_instance = wp_parse_args((array) $new_instance, array('title' => ''));
     $instance['title'] = sanitize_text_field($new_instance['title']);
     return $instance;
 }
Example #7
0
 function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = sanitize_text_field($new_instance['title']);
     $instance['adsenseCode'] = wp_filter_post_kses(addslashes($new_instance['adsenseCode']));
     return $instance;
 }
 function wpuxss_eml_taxonomies_validate($input)
 {
     if (!$input) {
         $input = array();
     }
     foreach ($input as $taxonomy => $params) {
         $sanitized_taxonomy = sanitize_key($taxonomy);
         if ($sanitized_taxonomy !== $taxonomy) {
             $input[$sanitized_taxonomy] = $input[$taxonomy];
             unset($input[$taxonomy]);
             $taxonomy = $sanitized_taxonomy;
         }
         $input[$taxonomy]['hierarchical'] = isset($params['hierarchical']) ? 1 : 0;
         $input[$taxonomy]['sort'] = isset($params['sort']) ? 1 : 0;
         $input[$taxonomy]['show_admin_column'] = isset($params['show_admin_column']) ? 1 : 0;
         $input[$taxonomy]['show_in_nav_menus'] = isset($params['show_in_nav_menus']) ? 1 : 0;
         $input[$taxonomy]['assigned'] = isset($params['assigned']) ? 1 : 0;
         $input[$taxonomy]['admin_filter'] = isset($params['admin_filter']) ? 1 : 0;
         $input[$taxonomy]['media_uploader_filter'] = isset($params['media_uploader_filter']) ? 1 : 0;
         $input[$taxonomy]['media_popup_taxonomy_edit'] = isset($params['media_popup_taxonomy_edit']) ? 1 : 0;
         $input[$taxonomy]['rewrite']['with_front'] = isset($params['rewrite']['with_front']) ? 1 : 0;
         $input[$taxonomy]['rewrite']['slug'] = isset($params['rewrite']['slug']) ? wpuxss_eml_sanitize_slug($params['rewrite']['slug'], $taxonomy) : '';
         if (isset($params['labels'])) {
             $default_labels = array('menu_name' => $params['labels']['name'], 'all_items' => 'All ' . $params['labels']['name'], 'edit_item' => 'Edit ' . $params['labels']['singular_name'], 'view_item' => 'View ' . $params['labels']['singular_name'], 'update_item' => 'Update ' . $params['labels']['singular_name'], 'add_new_item' => 'Add New ' . $params['labels']['singular_name'], 'new_item_name' => 'New ' . $params['labels']['singular_name'] . ' Name', 'parent_item' => 'Parent ' . $params['labels']['singular_name'], 'search_items' => 'Search ' . $params['labels']['name']);
             foreach ($params['labels'] as $label => $value) {
                 $input[$taxonomy]['labels'][$label] = sanitize_text_field($value);
                 if (empty($value) && isset($default_labels[$label])) {
                     $input[$taxonomy]['labels'][$label] = sanitize_text_field($default_labels[$label]);
                 }
             }
         }
     }
     return $input;
 }
function rcl_update_grouppost_meta($post_id, $postdata, $action)
{
    if ($postdata['post_type'] != 'post-group') {
        return false;
    }
    if (isset($_POST['term_id'])) {
        $term_id = intval(base64_decode($_POST['term_id']));
    }
    if (isset($term_id)) {
        wp_set_object_terms($post_id, (int) $term_id, 'groups');
    }
    $gr_tag = sanitize_text_field($_POST['group-tag']);
    if ($gr_tag) {
        if (!$term_id) {
            $groups = get_the_terms($post_id, 'groups');
            foreach ($groups as $group) {
                if ($group->parent != 0) {
                    continue;
                }
                $group_id = $group->term_id;
            }
        } else {
            $group_id = $term_id;
        }
        $term = term_exists($gr_tag, 'groups', $group_id);
        if (!$term) {
            $term = wp_insert_term($gr_tag, 'groups', array('description' => '', 'slug' => '', 'parent' => $group_id));
        }
        wp_set_object_terms($post_id, array((int) $term['term_id'], (int) $group_id), 'groups');
    }
}
 /**
  *	Process network options
  */
 function process_network_settings()
 {
     if (current_user_can('manage_network')) {
         $opts = array('recaptcha_publickey' => 'trim', 'recaptcha_privatekey' => 'trim', 'recaptcha_enable_comments' => 'intval', 'recaptcha_enable_signup' => 'intval', 'recaptcha_enable_login' => 'intval', 'recaptcha_enable_lostpw' => 'intval', 'recaptcha_enable_wc_order' => 'intval', 'recaptcha_disable_for_known_users' => 'intval', 'recaptcha_noscript' => 'intval', 'recaptcha_comment_use_42_filter' => 'intval');
         if (array_intersect(array_keys($_POST), array_keys($opts))) {
             check_admin_referer('recaptcha-network-settings');
         }
         $updated = false;
         foreach ($opts as $option_name => $sanitize_cb) {
             if (isset($_POST[$option_name])) {
                 $option_value = sanitize_text_field($_POST[$option_name]);
                 if (is_callable($sanitize_cb)) {
                     $option_value = call_user_func($sanitize_cb, $_POST[$option_name]);
                 }
                 update_site_option($option_name, $option_value);
                 $updated = true;
             }
         }
         if ($updated) {
             $redirect = $this->remove_new_apikey_url(add_query_arg(array('updated' => 'true')));
             wp_redirect($redirect);
         }
     } else {
         wp_die('Cheating, uh?');
     }
     // expecting api keys,
 }
 /**
  *
  * 	Process the infoz
  *	@since 1.0
  */
 function user_info()
 {
     if (isset($_POST['action'])) {
         // bail out if this user isnt logged in
         if (!is_user_logged_in()) {
             return;
         }
         if (!wp_verify_nonce($_POST['nonce'], 'process-user-info')) {
             return;
         }
         $user_id = get_current_user_id();
         if ($_POST['action'] == 'process_user_info') {
             $gender = isset($_POST['gender']) ? sanitize_text_field($_POST['gender']) : false;
             $age = isset($_POST['age']) ? sanitize_text_field($_POST['age']) : false;
             $education = isset($_POST['education']) ? sanitize_text_field($_POST['education']) : false;
             $employment = isset($_POST['employment']) ? sanitize_text_field($_POST['employment']) : false;
             $data = array('gender' => $gender, 'age' => $age, 'education' => $education, 'employment' => $employment);
             update_user_meta($user_id, 'user_info', $data);
             update_user_meta($user_id, 'user_info_completed', 1);
             do_action('user_info_updated', $user_id, $data);
             wp_send_json_success();
         } else {
             wp_send_json_error();
         }
     } else {
         wp_send_json_error();
     }
 }
 function fes_edd_save_meta_box_data($post_id)
 {
     /*
      * We need to verify this came from our screen and with proper authorization,
      * because the save_post action can be triggered at other times.
      */
     // Check if our nonce is set.
     if (!isset($_POST['fes_edd_meta_box_nonce'])) {
         return;
     }
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($_POST['fes_edd_meta_box_nonce'], 'fes_edd_meta_box')) {
         return;
     }
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     /* OK, it's safe for us to save the data now. */
     // Make sure that it is set.
     if (!isset($_POST['fes_edd_initial_message'])) {
         return;
     }
     // Sanitize user input.
     $my_data = sanitize_text_field($_POST['fes_edd_initial_message']);
     // Update the meta field in the database.
     update_post_meta($post_id, '_fes_edd_initial_message', $my_data);
 }
Example #13
0
 /**
  * Check if ANY Newsletter Sign-Up form has been submitted.
  */
 public function submit()
 {
     $opts = $this->options['form'];
     $errors = array();
     $email = isset($_POST['nsu_email']) ? sanitize_text_field($_POST['nsu_email']) : '';
     $name = isset($_POST['nsu_name']) ? sanitize_text_field($_POST['nsu_name']) : '';
     // has the honeypot been filled?
     if (!empty($_POST['nsu_robocop'])) {
         return false;
     }
     // if name is required, check it it was given
     if ($this->options['mailinglist']['subscribe_with_name'] == 1 && $opts['name_required'] == 1 && empty($name)) {
         $errors['name-field'] = $opts['text_empty_name'];
     }
     // validate email
     if (empty($email)) {
         $errors['email-field'] = $opts['text_empty_email'];
     } elseif (!is_string($email) || !is_email($email)) {
         $errors['email-field'] = $opts['text_invalid_email'];
     }
     // store errors as property
     $this->validation_errors = $errors;
     // send request to service if no errors occured
     if (count($this->validation_errors) == 0) {
         NSU::instance()->send_post_data($email, $name, 'form');
         return true;
     }
     return false;
 }
Example #14
0
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = sanitize_text_field($new_instance['title']);
     $instance['page_id'] = sanitize_text_field($new_instance['page_id']);
     return $instance;
 }
 /**
  * Process this field after being posted
  * @return array on success, WP_ERROR on failure
  */
 public function get_cart_item_data()
 {
     $cart_item_data = array();
     foreach ($this->addon['options'] as $key => $option) {
         $option_key = empty($option['label']) ? $key : sanitize_title($option['label']);
         $posted = isset($this->value[$option_key]) ? $this->value[$option_key] : '';
         if ($posted === '') {
             continue;
         }
         $label = $this->get_option_label($option);
         $price = $this->get_option_price($option);
         switch ($this->addon['type']) {
             case "custom_price":
                 $price = floatval(sanitize_text_field($posted));
                 if ($price >= 0) {
                     $cart_item_data[] = array('name' => $label, 'value' => $price, 'price' => $price, 'display' => strip_tags(woocommerce_price($price)));
                 }
                 break;
             case "input_multiplier":
                 $posted = absint($posted);
                 $cart_item_data[] = array('name' => $label, 'value' => $posted, 'price' => $posted * $price);
                 break;
             default:
                 $cart_item_data[] = array('name' => $label, 'value' => wp_kses_post($posted), 'price' => $price);
                 break;
         }
     }
     return $cart_item_data;
 }
Example #16
0
function wpsc_ajax_sales_quarterly()
{
    $lastdate = sanitize_text_field($_POST['add_start']);
    $date = preg_split('/-/', $lastdate);
    if (!isset($date[0])) {
        $date[0] = 0;
    }
    if (!isset($date[1])) {
        $date[1] = 0;
    }
    if (!isset($date[2])) {
        $date[2] = 0;
    }
    $lastquart = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
    if ($lastquart != get_option('wpsc_last_quarter')) {
        update_option('wpsc_last_date', $lastdate);
        update_option('wpsc_fourth_quart', $lastquart);
        $thirdquart = mktime(0, 0, 0, $date[1] - 3, $date[2], $date[0]);
        update_option('wpsc_third_quart', $thirdquart);
        $secondquart = mktime(0, 0, 0, $date[1] - 6, $date[2], $date[0]);
        update_option('wpsc_second_quart', $secondquart);
        $firstquart = mktime(0, 0, 0, $date[1] - 9, $date[2], $date[0]);
        update_option('wpsc_first_quart', $firstquart);
        $finalquart = mktime(0, 0, 0, $date[1], $date[2], $date[0] - 1);
        update_option('wpsc_final_quart', $finalquart);
    }
}
 public function reply_private_message()
 {
     global $wpdb, $xoouserultra;
     require_once ABSPATH . 'wp-includes/formatting.php';
     $logged_user_id = get_current_user_id();
     $message_id = sanitize_text_field($_POST["message_id"]);
     //$uu_message =   sanitize_text_field($_POST["uu_message"]);
     $uu_message = implode("\n", array_map('sanitize_text_field', explode("\n", $_POST["uu_message"])));
     $message = $this->get_one($message_id, $logged_user_id);
     $uu_subject = __("Reply: ", 'xoousers') . " " . $message->subject;
     //check if reply equal to sender
     $receiver_id = $message->sender;
     if ($receiver_id == $logged_user_id) {
         $receiver_id = $message->recipient;
     }
     //get receiver
     $receiver = get_user_by('id', $receiver_id);
     $sender = get_user_by('id', $logged_user_id);
     //store in the db
     if ($receiver->ID > 0) {
         $new_message = array('id' => NULL, 'subject' => $uu_subject, 'content' => $uu_message, 'sender' => $logged_user_id, 'recipient' => $receiver_id, 'parent' => $message->id, 'date' => date('Y-m-d H:i:s'), 'readed' => 0, 'deleted' => 0);
         // insert into database
         $wpdb->insert($wpdb->prefix . 'users_ultra_pm', $new_message, array('%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'));
         $xoouserultra->messaging->send_private_message_user($receiver, $sender->display_name, $uu_subject, $_POST["uu_message"]);
     }
     echo "<div class='uupublic-ultra-success'>" . __(" Reply sent ", 'xoousers') . "</div>";
     die;
 }
/**
 * Main tab handler
 *
 * @param noting.
 * @return nothing.
 *
 * Note that wp_iframe() will add the css for the "media" page when the  callback 
 * function begins with "media".
 **/
function media_upload_pac_pickapictab()
{
    // Two things can happen here, either we need to show the first page after the search button has been hit
    // or we need to display the paginated results for previous searches.
    if (isset($_POST['pac_pickapic_search_term']) && isset($_POST['pac_pickapic_results_per_page']) || isset($_GET['pac_pickapic_search_term']) && isset($_GET['pac_pickapic_results_per_page']) && isset($_GET['paged']) && !isset($_POST['pac_pickapic_choose'])) {
        // Displays the search results
        $search_term = sanitize_text_field($_REQUEST['pac_pickapic_search_term'], '');
        $results = absint($_REQUEST['pac_pickapic_results_per_page']);
        $paged = 0;
        if (isset($_REQUEST['paged'])) {
            $paged = absint($_REQUEST['paged']);
        }
        wp_iframe('media_pac_pickapic_search_results', $search_term, $results, $paged);
        return;
    } else {
        if (isset($_POST['pac_pickapic_choose'])) {
            // A picture has been selected so we must download it from flickr and show it to the user.
            //TODO: Implement better error handling
            check_admin_referer('pac_pickapic_nonce', 'pac_pickapic_nonce_field');
            //Show the selected image using get_media_item
            wp_iframe('media_pac_pickapic_final_form');
            return;
        } else {
            if (isset($_POST['send'])) {
                // Check the final form arguments generated by get_media_item() function
                // and if they are ok the image will be inserted to the editor
                media_upload_form_handler();
            }
        }
    }
    wp_iframe('media_pac_pickapic_search');
}
 function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = sanitize_text_field($new_instance['title']);
     $instance['adsenseCode'] = current_user_can('unfiltered_html') ? $new_instance['adsenseCode'] : stripslashes(wp_filter_post_kses(addslashes($new_instance['adsenseCode'])));
     return $instance;
 }
 /**
  * Add a notice message to be displayed.
  *
  * @param string $message
  * @param string $type
  * @param int $user_id
  * @static
  * @access public
  */
 public static function message($message, $type, $user_id = null)
 {
     if (empty($user_id)) {
         $user_id = get_current_user_id();
     }
     self::add_user_meta($user_id, self::KEY, array('message' => sanitize_text_field($message), 'type' => sanitize_text_field($type)));
 }
Example #21
0
    public function widget($args, $instance)
    {
        $title = apply_filters('widget_title', $instance['title']);
        echo $args['before_widget'];
        if (!empty($title)) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        ?>
			<form id="ap-search-form" class="ap-search-form" action="<?php 
        echo ap_get_link_to('search');
        ?>
" method="GET">
				<div class="ap-qaf-inner">
					<input class="form-control" type="text" name="ap_s" id="ap-quick-ask-input" placeholder="<?php 
        _e('Search questions & answers', 'ap');
        ?>
" value="<?php 
        echo sanitize_text_field(get_query_var('ap_s'));
        ?>
" autocomplete="off" />
					<button type="submit" ><?php 
        _e('Search', 'ap');
        ?>
</button>
				</div>
			</form>
		<?php 
        echo $args['after_widget'];
    }
 /**
  * Hook into the query parsing to detect oEmbed requests.
  *
  * If an oEmbed request is made, trigger the output.
  *
  * @codeCoverageIgnore
  *
  * @param WP_Query $wp_query The WP_Query instance (passed by reference).
  */
 public function parse_query($wp_query)
 {
     // Check for required params.
     if (false === $wp_query->get('oembed', false)) {
         return;
     }
     if (false === $wp_query->get('url', false)) {
         status_header(400);
         echo 'URL parameter missing';
         exit;
     }
     /**
      * Check for the allowed query vars and set defaults.
      *
      * @see WP_REST_oEmbed_Controller::register_routes()
      */
     $url = esc_url_raw(get_query_var('url'));
     $format = sanitize_text_field(get_query_var('format', 'json'));
     /**
      * Filter the maxwidth oEmbed parameter.
      *
      * @param int $maxwidth Maximum allowed width. Defaults to 600.
      *
      * @return int
      */
     $maxwidth = apply_filters('oembed_default_width', 600);
     $maxwidth = get_query_var('maxwidth', $maxwidth);
     $callback = get_query_var('_jsonp', false);
     $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback);
     echo $this->dispatch($request);
     exit;
 }
Example #23
0
function csmm_ajax_support()
{
    // We are going to store the response in the $response() array
    $response = array('code' => 'error', 'response' => __('Please fill in both the fields to create your support ticket.', 'signals'));
    // Filtering and sanitizing the support issue
    if (!empty($_POST['signals_support_email']) && !empty($_POST['signals_support_issue'])) {
        $admin_email = sanitize_text_field($_POST['signals_support_email']);
        $issue = $_POST['signals_support_issue'];
        $subject = '[Maintenance Mode Ticket] by ' . $admin_email;
        $body = "Email: {$admin_email} \r\nIssue: {$issue}";
        $headers = 'From: ' . $admin_email . "\r\n" . 'Reply-To: ' . $admin_email;
        // Sending the mail to the support email
        if (true === wp_mail('*****@*****.**', $subject, $body, $headers)) {
            // Sending the success response
            $response = array('code' => 'success', 'response' => __('We have received your support ticket. We will get back to you shortly!', 'signals'));
        } else {
            // Sending the failure response
            $response = array('code' => 'error', 'response' => __('There was an error creating the support ticket. You can try again later or send us an email directly to <strong>support@69signals.com</strong>', 'signals'));
        }
    }
    // Sending proper headers and sending the response back in the JSON format
    header("Content-Type: application/json");
    echo json_encode($response);
    // Exiting the AJAX function. This is always required
    exit;
}
Example #24
0
 function save_meta_box_data($post_id)
 {
     if (!isset($_POST['portfolio_meta_box_nonce'])) {
         return;
     }
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($_POST['portfolio_meta_box_nonce'], 'portfolio_meta_box')) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (isset($_POST['post_type']) && 'portfolio' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
     }
     if (!isset($_POST['publishing_year'])) {
         return;
     }
     $my_data = sanitize_text_field($_POST['publishing_year']);
     update_post_meta($post_id, 'publishing_year', $my_data);
 }
 /**
  * @inheritdoc
  *
  * @param array $arguments
  */
 public function process_call($arguments)
 {
     $am = $this->get_am();
     $am->ajax_begin(array('nonce' => $am->get_action_js_name(Types_Ajax::CALLBACK_SETTINGS_ACTION)));
     $setting = sanitize_text_field(wpcf_getpost('setting'));
     $setting_value = wpcf_getpost('setting_value');
     if (!is_array($setting_value)) {
         parse_str($setting_value, $setting_value);
         $setting_value = array_pop($setting_value);
     }
     $sanitized_value = array();
     foreach ($setting_value as $key => $value) {
         $sanitized_key = sanitize_title($key);
         $sanitized_value[$sanitized_key] = sanitize_text_field($value);
     }
     // use toolset settings if available
     if (class_exists('Toolset_Settings') && method_exists('Toolset_Settings', 'get_instance')) {
         $toolset_settings = Toolset_Settings::get_instance();
         if (method_exists($toolset_settings, 'save')) {
             $toolset_settings[$setting] = $sanitized_value;
             $toolset_settings->save();
             $am->ajax_finish('success', true);
         }
     } else {
         update_option($setting, $sanitized_value);
         $am->ajax_finish('success', true);
     }
     // default toolset setting error will be used
     // todo throw specific error
     $am->ajax_finish(array('error'), false);
 }
 /**
  * Save metabox data.
  *
  * @param  int $post_id Current post type ID.
  *
  * @return void
  */
 public function save($post_id)
 {
     // Verify nonce.
     if (!isset($_POST['wcboleto_metabox_nonce']) || !wp_verify_nonce($_POST['wcboleto_metabox_nonce'], basename(__FILE__))) {
         return $post_id;
     }
     // Verify if this is an auto save routine.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // Check permissions.
     if ('shop_order' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } elseif (!current_user_can('edit_post', $post_id)) {
         return $post_id;
     }
     if (isset($_POST['wcboleto_expiration_date']) && !empty($_POST['wcboleto_expiration_date'])) {
         // Gets boleto data.
         $boleto_data = get_post_meta($post_id, 'wc_boleto_data', true);
         $boleto_data['data_vencimento'] = sanitize_text_field($_POST['wcboleto_expiration_date']);
         // Update boleto data.
         update_post_meta($post_id, 'wc_boleto_data', $boleto_data);
         // Gets order data.
         $order = new WC_Order($post_id);
         // Add order note.
         $order->add_order_note(sprintf(__('Expiration date updated to: %s', 'wcboleto'), $boleto_data['data_vencimento']));
         // Send email notification.
         $this->email_notification($order, $boleto_data['data_vencimento']);
     }
 }
 public function save_site_options_push($site_id)
 {
     global $settings_manager;
     /**
      * If this isn't a save action, bail.
      */
     if (!isset($_POST['site_url'])) {
         return false;
     }
     /**
      * Grab and sanitize save values.
      */
     $site_url = isset($_POST['site_url']) ? sanitize_text_field($_POST['site_url']) : '';
     $username = isset($_POST['site_username']) ? sanitize_text_field($_POST['site_username']) : '';
     $password = isset($_POST['site_password']) ? sanitize_text_field($_POST['site_password']) : '';
     // Remove training `/xmlrpc.php` from site_url if present.
     $site_url = str_replace('/xmlrpc.php', '', $site_url);
     //
     update_post_meta($site_id, 'syn_site_url', esc_url_raw($site_url));
     update_post_meta($site_id, 'syn_site_username', $username);
     update_post_meta($site_id, 'syn_site_password', $settings_manager->syndicate_encrypt($password));
     if (!filter_var($_POST['site_url'], FILTER_VALIDATE_URL)) {
         add_filter('redirect_post_location', create_function('$location', 'return add_query_arg( "message", 301, $location );'));
         return false;
     }
     return true;
 }
Example #28
0
 public function parseDescription()
 {
     $descr = '';
     $results = $this->xpathScalar(".//article[@id='produktbeschreibung']/p");
     $descr = sanitize_text_field($results);
     return $descr;
 }
Example #29
0
 public function store_commission_data($data, $query_mode, $api_object)
 {
     if ('store-commissions' != $query_mode) {
         return $data;
     }
     $user_id = $api_object->get_user();
     if (!user_can($user_id, 'view_shop_reports')) {
         return $data;
     }
     $data = array('commissions' => array());
     $paged = $api_object->get_paged();
     $status = isset($_REQUEST['status']) ? sanitize_text_field($_REQUEST['status']) : 'unpaid';
     $commission_args = array('post_type' => 'edd_commission', 'post_status' => 'publish', 'posts_per_page' => $api_object->per_page(), 'paged' => $paged);
     if ($status) {
         $commission_args['tax_query'] = array(array('taxonomy' => 'edd_commission_status', 'terms' => $status, 'field' => 'slug'));
     }
     $commissions = get_posts($commission_args);
     if ($commissions) {
         foreach ($commissions as $commission) {
             $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
             $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
             $renewal = (bool) get_post_meta($commission->ID, '_edd_commission_is_renewal', true);
             $data['commissions'][] = array('amount' => edd_sanitize_amount($commission_meta['amount']), 'rate' => $commission_meta['rate'], 'currency' => $commission_meta['currency'], 'item' => get_the_title($download_id), 'status' => eddc_get_commission_status($commission->ID), 'date' => $commission->post_date, 'renewal' => $renewal ? 1 : 0);
         }
         wp_reset_postdata();
     }
     $data['total_unpaid'] = eddc_get_unpaid_totals();
     return $data;
 }
 public function feedback_submit()
 {
     if (isset($_POST['post_id']) && !empty($_POST['post_id']) && isset($_POST['feedback']) && !empty($_POST['feedback'])) {
         $post_id = $_POST['post_id'];
         $nonce = $_POST['am2WritingHelperNonce'];
         $reviewers_hash = $_POST['am2_sharedraft'];
         $allow = false;
         $reviews = get_post_meta($post_id, 'am2_review_feedback', true);
         $invites = get_post_meta($post_id, 'am2_review_emails', true);
         if (!is_array($reviews)) {
             $reviews = array();
         }
         if (is_array($invites)) {
             $allow = array_key_exists($reviewers_hash, $invites);
         }
         // check to see if the submitted nonce matches with the
         // generated nonce we created earlier
         if (!wp_verify_nonce($nonce, 'am2-writing-helper-nonce')) {
             exit('Busted!');
         } else {
             if ($allow) {
                 $reviews[$reviewers_hash][] = sanitize_text_field($_POST['feedback']);
                 update_post_meta($post_id, 'am2_review_feedback', $reviews);
                 exit;
             } else {
                 echo json_encode('not allowed');
                 exit;
             }
         }
     }
     exit;
 }