public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['banner_image'] = hocwp_get_value_by_key($new_instance, 'banner_image');
     $instance['banner_url'] = hocwp_get_value_by_key($new_instance, 'banner_url');
     $instance['nofollow'] = hocwp_checkbox_post_data_value($new_instance, 'nofollow');
     return $instance;
 }
Пример #2
0
function hocwp_option_user_login_update($input)
{
    $users_can_register = hocwp_checkbox_post_data_value($input, 'users_can_register');
    if ((bool) $users_can_register) {
        update_option('users_can_register', 1);
    } else {
        update_option('users_can_register', 0);
    }
    unset($users_can_register);
}
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['page_name'] = hocwp_get_value_by_key($new_instance, 'page_name');
     $instance['href'] = hocwp_get_value_by_key($new_instance, 'href');
     $instance['width'] = hocwp_get_value_by_key($new_instance, 'width', $this->args['width']);
     $instance['height'] = hocwp_get_value_by_key($new_instance, 'height', $this->args['height']);
     $instance['button_text'] = hocwp_get_value_by_key($new_instance, 'button_text', $this->args['button_text']);
     $instance['position'] = hocwp_get_value_by_key($new_instance, 'position', $this->args['position']);
     $instance['hide_cover'] = hocwp_checkbox_post_data_value($new_instance, 'hide_cover');
     $instance['show_facepile'] = hocwp_checkbox_post_data_value($new_instance, 'show_facepile');
     $instance['hide_cta'] = hocwp_checkbox_post_data_value($new_instance, 'hide_cta');
     $instance['small_header'] = hocwp_checkbox_post_data_value($new_instance, 'small_header');
     $instance['adapt_container_width'] = hocwp_checkbox_post_data_value($new_instance, 'adapt_container_width');
     $instance['fixed'] = hocwp_checkbox_post_data_value($new_instance, 'fixed');
     $instance['only_link'] = hocwp_checkbox_post_data_value($new_instance, 'only_link');
     return $instance;
 }
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['fields'] = $this->get_value_fields($new_instance);
     $all_fields = explode(',', $instance['fields']);
     foreach ($all_fields as $field_name) {
         $field = hocwp_get_value_by_key($this->args['fields'], $field_name);
         if (hocwp_array_has_value($field)) {
             foreach ($field as $key => $data) {
                 $real_name = 'subscribe_' . $field_name . '_' . $key;
                 $instance[$real_name] = $this->get_value_field($new_instance, $field_name, $key);
             }
         }
     }
     $instance['button_text'] = hocwp_get_value_by_key($new_instance, 'button_text', hocwp_get_value_by_key($this->args, 'button_text'));
     $instance['description'] = hocwp_get_value_by_key($new_instance, 'description', hocwp_get_value_by_key($this->args, 'description'));
     $instance['desc_position'] = hocwp_get_value_by_key($new_instance, 'desc_position', $this->args['desc_position']);
     $instance['captcha'] = hocwp_checkbox_post_data_value($new_instance, 'captcha');
     $instance['captcha_label'] = hocwp_get_value_by_key($new_instance, 'captcha_label', hocwp_get_value_by_key($this->args, 'captcha_label'));
     $instance['captcha_placeholder'] = hocwp_get_value_by_key($new_instance, 'captcha_placeholder', hocwp_get_value_by_key($this->args, 'captcha_placeholder'));
     $instance['register'] = hocwp_checkbox_post_data_value($new_instance, 'register');
     return $instance;
 }
 public function update($new_instance, $old_instance)
 {
     hocwp_delete_transient('hocwp_top_commenters');
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['number'] = hocwp_get_value_by_key($new_instance, 'number', hocwp_get_value_by_key($this->args, 'number'));
     $instance['time'] = hocwp_get_value_by_key($new_instance, 'time', hocwp_get_value_by_key($this->args, 'time'));
     $instance['exclude_users'] = hocwp_get_value_by_key($new_instance, 'exclude_users');
     $instance['show_count'] = hocwp_checkbox_post_data_value($new_instance, 'show_count');
     $instance['link_author_name'] = hocwp_checkbox_post_data_value($new_instance, 'link_author_name');
     $instance['none_text'] = hocwp_get_value_by_key($new_instance, 'none_text', hocwp_get_value_by_key($this->args, 'none_text'));
     return $instance;
 }
Пример #6
0
function hocwp_shop_save_product_meta($post_id)
{
    if (!hocwp_can_save_post($post_id)) {
        return;
    }
    if (!hocwp_is_shop_site() || hocwp_wc_installed()) {
        return;
    }
    if (isset($_POST['sku'])) {
        update_post_meta($post_id, 'sku', $_POST['sku']);
    }
    $regular_price = hocwp_get_method_value('regular_price');
    $sale_price = hocwp_get_method_value('sale_price');
    $prices = hocwp_sanitize_product_price($regular_price, $sale_price, $post_id);
    update_post_meta($post_id, 'regular_price', $prices['regular_price']);
    update_post_meta($post_id, 'sale_price', $prices['sale_price']);
    update_post_meta($post_id, 'price', $prices['price']);
    if (isset($_POST['short_description'])) {
        update_post_meta($post_id, 'short_description', $_POST['short_description']);
    }
    $out_of_stock = hocwp_checkbox_post_data_value($_POST, 'out_of_stock');
    update_post_meta($post_id, 'out_of_stock', $out_of_stock);
    if (isset($_POST['gallery'])) {
        update_post_meta($post_id, 'gallery', $_POST['gallery']);
    }
}
 public function sanitize($input)
 {
     $fields = $this->get_fields();
     if (hocwp_array_has_value($fields)) {
         foreach ($fields as $field) {
             $data_type = hocwp_get_value_by_key($field, 'data_type');
             if ('checkbox' == $data_type) {
                 $name = hocwp_get_value_by_key($field, 'name');
                 if (!empty($name)) {
                     $input[$name] = hocwp_checkbox_post_data_value($input, $name);
                 }
             }
         }
     }
     if ($this->get_parse_options()) {
         $old = (array) get_option($this->get_option_name());
         $input = (array) $input;
         $input = wp_parse_args($input, $old);
     }
     $input = apply_filters('hocwp_sanitize_option_' . $this->get_option_name_no_prefix(), $input);
     do_action('hocwp_sanitize_' . $this->get_option_name_no_prefix() . '_option', $input);
     $input = apply_filters('validate_options', $input);
     return apply_filters('hocwp_validate_options', $input);
 }
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['page_name'] = hocwp_get_value_by_key($new_instance, 'page_name');
     $instance['href'] = hocwp_get_value_by_key($new_instance, 'href');
     $tabs = hocwp_get_value_by_key($new_instance, 'tabs');
     $tabs = explode(',', $tabs);
     $tabs = array_map('trim', $tabs);
     $instance['tabs'] = $tabs;
     $instance['width'] = hocwp_get_value_by_key($new_instance, 'width', $this->args['width']);
     $instance['height'] = hocwp_get_value_by_key($new_instance, 'height', $this->args['height']);
     $instance['hide_cover'] = hocwp_checkbox_post_data_value($new_instance, 'hide_cover');
     $instance['show_facepile'] = hocwp_checkbox_post_data_value($new_instance, 'show_facepile');
     $instance['show_posts'] = hocwp_checkbox_post_data_value($new_instance, 'show_posts');
     $instance['hide_cta'] = hocwp_checkbox_post_data_value($new_instance, 'hide_cta');
     $instance['small_header'] = hocwp_checkbox_post_data_value($new_instance, 'small_header');
     $adapt_container_width = hocwp_checkbox_post_data_value($new_instance, 'adapt_container_width');
     $instance['adapt_container_width'] = $adapt_container_width;
     return $instance;
 }
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['taxonomy'] = hocwp_get_value_by_key($new_instance, 'taxonomy', json_encode($this->args['taxonomy']));
     $instance['number'] = hocwp_get_value_by_key($new_instance, 'number', $this->args['number']);
     $instance['order'] = hocwp_get_value_by_key($new_instance, 'order', $this->args['order']);
     $instance['orderby'] = hocwp_get_value_by_key($new_instance, 'orderby', $this->args['orderby']);
     $instance['full_width_item'] = hocwp_get_value_by_key($new_instance, 'full_width_item', $this->args['full_width_item']);
     $instance['count_format'] = hocwp_get_value_by_key($new_instance, 'count_format', $this->args['count_format']);
     $width = hocwp_get_value_by_key($new_instance, 'thumbnail_size_width', $this->args['thumbnail_size'][0]);
     $height = hocwp_get_value_by_key($new_instance, 'thumbnail_size_height', $this->args['thumbnail_size'][1]);
     $instance['thumbnail_size'] = array($width, $height);
     $instance['hide_thumbnail'] = hocwp_checkbox_post_data_value($new_instance, 'hide_thumbnail');
     $instance['show_count'] = hocwp_checkbox_post_data_value($new_instance, 'show_count');
     $instance['only_thumbnail'] = hocwp_checkbox_post_data_value($new_instance, 'only_thumbnail');
     $instance['different_name'] = hocwp_checkbox_post_data_value($new_instance, 'different_name');
     $instance['in_current_post'] = hocwp_checkbox_post_data_value($new_instance, 'in_current_post');
     $instance['hide_empty'] = hocwp_checkbox_post_data_value($new_instance, 'hide_empty');
     $instance['only_parent'] = hocwp_checkbox_post_data_value($new_instance, 'only_parent');
     $instance['child_of_current'] = hocwp_checkbox_post_data_value($new_instance, 'child_of_current');
     $instance['child_of_parent'] = hocwp_checkbox_post_data_value($new_instance, 'child_of_parent');
     $instance['parent_as_title'] = hocwp_checkbox_post_data_value($new_instance, 'parent_as_title');
     return $instance;
 }
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['icon'] = hocwp_get_value_by_key($new_instance, 'icon');
     $instance['icon_hover'] = hocwp_get_value_by_key($new_instance, 'icon_hover');
     $instance['icon_html'] = hocwp_get_value_by_key($new_instance, 'icon_html');
     $instance['link'] = esc_url(hocwp_get_value_by_key($new_instance, 'link'));
     $instance['title_link'] = hocwp_checkbox_post_data_value($new_instance, 'title_link');
     $instance['text'] = hocwp_get_value_by_key($new_instance, 'text');
     return $instance;
 }
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['post_type'] = hocwp_get_value_by_key($new_instance, 'post_type', json_encode($this->args['post_type']));
     $instance['number'] = hocwp_get_value_by_key($new_instance, 'number', $this->args['number']);
     $instance['by'] = hocwp_get_value_by_key($new_instance, 'by', $this->args['by']);
     $instance['category'] = hocwp_get_value_by_key($new_instance, 'category', json_encode($this->args['category']));
     $instance['full_width_post'] = hocwp_get_value_by_key($new_instance, 'full_width_post', $this->args['full_width_post']);
     $width = hocwp_get_value_by_key($new_instance, 'thumbnail_size_width', $this->args['thumbnail_size'][0]);
     $height = hocwp_get_value_by_key($new_instance, 'thumbnail_size_height', $this->args['thumbnail_size'][1]);
     $instance['thumbnail_size'] = array($width, $height);
     $instance['slider'] = hocwp_checkbox_post_data_value($new_instance, 'slider');
     $instance['title_length'] = hocwp_get_value_by_key($new_instance, 'title_length', $this->args['title_length']);
     $instance['excerpt_length'] = hocwp_get_value_by_key($new_instance, 'excerpt_length', $this->args['excerpt_length']);
     $instance['hide_thumbnail'] = hocwp_checkbox_post_data_value($new_instance, 'hide_thumbnail');
     $instance['widget_title_link_category'] = hocwp_checkbox_post_data_value($new_instance, 'widget_title_link_category');
     $instance['category_as_widget_title'] = hocwp_checkbox_post_data_value($new_instance, 'category_as_widget_title');
     return $instance;
 }