function gdlr_save_post_meta_option($post_id)
 {
     if (get_post_type() == 'post' && isset($_POST['post-option'])) {
         $post_option = gdlr_preventslashes(gdlr_stripslashes($_POST['post-option']));
         $post_option = json_decode(gdlr_decode_preventslashes($post_option), true);
         if (!empty($post_option['rating'])) {
             update_post_meta($post_id, 'gdlr-post-rating', floatval($post_option['rating']) * 100);
         } else {
             delete_post_meta($post_id, 'gdlr-post-rating');
         }
     }
 }
 function save_taxonomy_meta($term_id)
 {
     $term = get_term_by('id', $term_id, $this->setting['taxonomy']);
     if (isset($_POST['term_meta'])) {
         $term_meta = get_option($this->setting['slug']);
         $cat_keys = array_keys($_POST['term_meta']);
         foreach ($cat_keys as $key) {
             if (isset($_POST['term_meta'][$key])) {
                 $term_meta[$term->slug][$key] = gdlr_stripslashes($_POST['term_meta'][$key]);
             }
         }
         // Save the option array.
         update_option($this->setting['slug'], $term_meta);
     }
 }
 function gdlr_save_admin_panel()
 {
     if (!check_ajax_referer(THEME_SHORT_NAME . '-create-nonce', 'security', false)) {
         die(json_encode(array('status' => 'failed', 'message' => '<span class="head">' . __('Invalid Nonce', 'gdlr_translate') . '</span> ' . __('Please refresh the page and try this again.', 'gdlr_translate'))));
     }
     if (isset($_POST['option'])) {
         parse_str(gdlr_stripslashes($_POST['option']), $option);
         $option = gdlr_stripslashes($option);
         $old_option = get_option($this->setting['save_option']);
         if ($old_option == $option || update_option($this->setting['save_option'], $option)) {
             $ret = array('status' => 'success', 'message' => '<span class="head">' . __('Save Options Complete', 'gdlr_translate') . '</span> ');
         } else {
             $ret = array('status' => 'failed', 'message' => '<span class="head">' . __('Save Options Failed', 'gdlr_translate') . '</span> ' . __('Please refresh the page and try this again.', 'gdlr_translate'));
         }
     } else {
         $ret = array('status' => 'failed', 'message' => '<span class="head">' . __('Cannot Retrieve Options', 'gdlr_translate') . '</span> ' . __('Please refresh the page and try this again.', 'gdlr_translate'));
     }
     do_action('gdlr_save_' + $this->setting['menu_slug'], $this->option);
     die(json_encode($ret));
 }
예제 #4
0
 function save_page_option($post_id)
 {
     if (empty($_POST[$this->setting['option_name']]) || empty($post_id)) {
         return;
     }
     if (!in_array(get_post_type($post_id), $this->setting['post_type'])) {
         return;
     }
     if (isset($_POST[$this->setting['option_name']])) {
         update_post_meta($post_id, $this->setting['option_name'], gdlr_preventslashes($_POST[$this->setting['option_name']]));
     }
     $post_option = gdlr_preventslashes(gdlr_stripslashes($_POST['post-option']));
     $post_option = json_decode(gdlr_decode_preventslashes($post_option), true);
     // for custom_field attribute
     foreach ($this->option as $option_section) {
         foreach ($option_section['options'] as $option_slug => $option) {
             if (!empty($option['custom_field'])) {
                 if ($option['type'] == 'multi-combobox') {
                     update_post_meta($post_id, $option['custom_field'], json_encode($post_option[$option_slug]));
                 } else {
                     update_post_meta($post_id, $option['custom_field'], $post_option[$option_slug]);
                 }
             }
         }
     }
     // for custom meta filter
     $custom_meta = apply_filters('gdlr_custom_page_option_meta', array(), $post_option);
     if (!empty($custom_meta)) {
         foreach ($custom_meta as $meta) {
             if (!empty($meta['key']) && !empty($meta['value'])) {
                 update_post_meta($post_id, $meta['key'], $meta['value']);
             }
         }
     }
 }
예제 #5
0
 function save_page_option($post_id)
 {
     if (empty($_POST[$this->setting['option_name']]) || empty($post_id)) {
         return;
     }
     if (isset($_POST[$this->setting['option_name']])) {
         update_post_meta($post_id, $this->setting['option_name'], gdlr_preventslashes($_POST[$this->setting['option_name']]));
     }
     $post_option = gdlr_preventslashes(gdlr_stripslashes($_POST['post-option']));
     $post_option = json_decode(gdlr_decode_preventslashes($post_option), true);
     $custom_meta = apply_filters('gdlr_custom_page_option_meta', array(), $post_option);
     if (!empty($custom_meta)) {
         foreach ($custom_meta as $meta) {
             if (!empty($meta['key']) && !empty($meta['value'])) {
                 update_post_meta($post_id, $meta['key'], $meta['value']);
             }
         }
     }
 }
 function gdlr_print_tinymce_editor()
 {
     wp_editor(gdlr_stripslashes($_POST['content']), $_POST['id'], array('textarea_name' => $_POST['name']));
     die;
 }
 function gdlr_remove_sidebar()
 {
     if (!check_ajax_referer(THEME_SHORT_NAME . '-create-nonce', 'security', false)) {
         die(json_encode(array('status' => 'failed', 'message' => '<span class="head">' . __('Invalid Nonce', 'gdlr_translate') . '</span> ' . __('Please refresh the page and try this again.', 'gdlr_translate'))));
     }
     if (isset($_POST['sidebar_name'])) {
         $current_sidebar = gdlr_stripslashes(trim(strip_tags($_POST['sidebar_name'])));
         $key = array_search($current_sidebar, $this->sidebars);
         unset($this->sidebars[$key]);
         if (update_option($this->option_name, $this->sidebars)) {
             $ret = array('status' => 'success');
         } else {
             $ret = array('status' => 'failed', 'message' => '<span class="head">' . __('Save Failed', 'gdlr_translate') . '</span> ' . __('Please try again.', 'gdlr_translate'));
         }
     } else {
         $ret = array('status' => 'failed', 'message' => '<span class="head">' . __('Cannot Retrieve Sidebar Name', 'gdlr_translate') . '</span> ' . __('Please try again.', 'gdlr_translate'));
     }
     die(json_encode($ret));
 }
예제 #8
0
 function gdlr_save_cause_meta_option($post_id)
 {
     if (get_post_type() == 'cause' && isset($_POST['post-option'])) {
         $post_option = gdlr_preventslashes(gdlr_stripslashes($_POST['post-option']));
         $event_option = json_decode(gdlr_decode_preventslashes($post_option), true);
         if (!empty($event_option['current-funding'])) {
             update_post_meta($post_id, 'gdlr-current-funding', $event_option['current-funding']);
         }
         if (!empty($event_option['goal-of-donation'])) {
             $goal = floatval($event_option['goal-of-donation']);
             $current = floatval($event_option['current-funding']);
             $percent = intval($current / $goal * 100);
             update_post_meta($post_id, 'gdlr-donation-percent', $percent);
         }
     }
 }