예제 #1
0
 /**
  * Widget Update method
  */
 function update($new_instance, $old_instance)
 {
     foreach ($new_instance as $name => $value) {
         // special handling for text inputs
         if (in_array($name, IntelliWidgetStrings::get_fields('text'))) {
             if (current_user_can('unfiltered_html')) {
                 $old_instance[$name] = $value;
             } else {
                 // raw html parser/cleaner-upper: see WP docs re: KSES
                 $old_instance[$name] = stripslashes(wp_filter_post_kses(addslashes($value)));
             }
         } elseif (0 === strpos($name, 'iw') || in_array($name, array('pagesearch', 'termsearch', 'profiles_only'))) {
             unset($old_instance[$name]);
         } else {
             $old_instance[$name] = $this->filter_sanitize_input($value);
         }
         // handle multi selects that may not be passed or may just be empty
         if ('page_multi' == $name && empty($new_instance['page'])) {
             $old_instance['page'] = array();
         }
         if ('terms_multi' == $name && empty($new_instance['terms'])) {
             $old_instance['terms'] = array();
         }
     }
     foreach (IntelliWidgetStrings::get_fields('checkbox') as $name) {
         $old_instance[$name] = isset($new_instance[$name]);
     }
     //$iwq = new IntelliWidgetQuery(); // do not use for now ( 2.3.4 )
     //$old_instance[ 'querystr' ] = $iwq->iw_query( $old_instance );
     return $old_instance;
 }
예제 #2
0
파일: Admin.php 프로젝트: joecooper3/2015
 function save_data($id)
 {
     // reset the data array
     $post_data = array();
     $prefix = 'intelliwidget_';
     // since we can now save a single meta box via ajax post,
     // we need to manipulate the existing boxmap
     $box_map = $this->iw()->get_box_map($id, $this->objecttype);
     // allow customization of input fields
     /***
      * Here is some perlesque string handling. Using grep gives us a subset of relevant data fields
      * quickly. We then iterate through the fields, parsing out the actual data field name and the 
      * box_id from the input key.
      */
     foreach (preg_grep('#^' . $prefix . '#', array_keys($_POST)) as $field) {
         // find the box id and field name in the post key with a perl regex
         preg_match('#^' . $prefix . '(preview|\\d+)_(\\d+)_([\\w\\-]+)$#', $field, $matches);
         if (count($matches)) {
             if (!($id == $matches[1]) || !($box_id = $matches[2])) {
                 continue;
             }
             $name = $matches[3];
         } else {
             continue;
         }
         // organize this into a 2-dimensional array for later
         // raw html parser/cleaner-upper: see WP docs re: KSES
         if (in_array($name, IntelliWidgetStrings::get_fields('text'))) {
             if (current_user_can('unfiltered_html')) {
                 $post_data[$box_id][$name] = $_POST[$field];
             } else {
                 $post_data[$box_id][$name] = stripslashes(wp_filter_post_kses(addslashes($_POST[$field])));
             }
         } else {
             $post_data[$box_id][$name] = $this->filter_sanitize_input($_POST[$field]);
         }
     }
     // track meta boxes updated
     $boxcounter = 0;
     // additional processing for each box data segment
     foreach ($post_data as $box_id => $new_instance) {
         // get current values
         $old_instance = $this->iw()->get_meta($id, '_intelliwidget_data_', $this->objecttype, $box_id);
         foreach ($new_instance as $name => $value) {
             $old_instance[$name] = $value;
             // make sure at least one post type exists
             if ('post_types' == $name && empty($new_instance[$name])) {
                 $old_instance['post_types'] = array('post');
             }
             if ('replace_widget' == $name) {
                 $box_map[$box_id] = $new_instance['replace_widget'];
             }
             // handle multi selects that may not be passed or may just be empty
             if ('page_multi' == $name && empty($new_instance['page'])) {
                 $old_instance['page'] = array();
             }
             if ('terms_multi' == $name && empty($new_instance['terms'])) {
                 $old_instance['terms'] = array();
             }
         }
         // special handling for checkboxes:
         foreach (IntelliWidgetStrings::get_fields('checkbox') as $name) {
             $old_instance[$name] = isset($new_instance[$name]);
         }
         if (isset($old_instance['custom_text'])) {
             $old_instance['custom_text'] = base64_encode($old_instance['custom_text']);
         }
         // update query cache // do not use for now (2.3.4)
         // $iwq = new IntelliWidgetQuery();
         // $old_instance[ 'querystr' ] = $iwq->iw_query( $old_instance );
         // save new data
         $this->update_meta($id, '_intelliwidget_data_', $old_instance, $box_id);
         // increment box counter
         $boxcounter++;
     }
     if ($boxcounter) {
         // if we have updates, save new map
         $this->update_meta($id, '_intelliwidget_', $box_map, 'map');
     }
 }
예제 #3
0
 function post_save_cdf_data($post_id)
 {
     // reset the data array
     $prefix = 'intelliwidget_';
     foreach (IntelliWidgetStrings::get_fields('custom') as $cfield) {
         $cdfield = $prefix . $cfield;
         if (array_key_exists($cdfield, $_POST)) {
             if (empty($_POST[$cdfield]) || '' == $_POST[$cdfield]) {
                 $this->delete_meta($post_id, $cdfield);
             } else {
                 $newdata = $_POST[$cdfield];
                 if (!current_user_can('unfiltered_html')) {
                     $newdata = stripslashes(wp_filter_post_kses(addslashes($newdata)));
                 }
                 $this->update_meta($post_id, $cdfield, $newdata);
             }
         }
     }
 }
예제 #4
0
// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
/**
 * class-intelliwidget-form.php - Outputs widget form
 *
 * @package IntelliWidget
 * @subpackage includes
 * @author Jason C Fleming
 * @copyright 2014-2015 Lilaea Media LLC
 * @access public
 */
$custom_data = get_post_custom($post->ID);
$fields = array();
foreach (IntelliWidgetStrings::get_fields('custom') as $field) {
    $key = 'intelliwidget_' . $field;
    $fields[$key] = empty($custom_data[$key]) ? '' : $custom_data[$key][0];
}
?>

<p>
  <label title="<?php 
echo $this->get_tip('event_date');
?>
" for="intelliwidget_event_date"> <?php 
echo $this->get_label('event_date');
?>
: <a href="#edit_timestamp" id="intelliwidget_event_date-edit" class="intelliwidget-edit-timestamp hide-if-no-js">
    <?php 
_e('Edit', 'intelliwidget');