Ejemplo n.º 1
0
 /**
  * Update a particular instance.
  *
  * This function should check that $new_instance is set correctly.
  * The newly calculated value of $instance should be returned.
  * If "false" is returned, the instance won't be saved/updated.
  *
  * @since 0.1.8
  *
  * @param array $new_instance New settings for this instance as input by the user via form()
  * @param array $old_instance Old settings for this instance
  * @return array Settings to save or bool false to cancel saving
  */
 public function update($new_instance, $old_instance)
 {
     $new_instance['excerpt_cutoff'] = '...' == $new_instance['excerpt_cutoff'] ? '…' : $new_instance['excerpt_cutoff'];
     $new_instance['title_cutoff'] = '...' == $new_instance['title_cutoff'] ? '…' : $new_instance['title_cutoff'];
     $new_instance['title'] = strip_tags($new_instance['title']);
     $new_instance['more_text'] = strip_tags($new_instance['more_text']);
     $new_instance['post_info'] = wp_kses_post($new_instance['post_info']);
     $new_instance['custom_field'] = $new_instance['custom_field'] ? sanitize_title_with_dashes($new_instance['custom_field']) : ThemeMix_Featured_Content::set_custom_field($new_instance);
     ThemeMix_Featured_Content::delete_transient('thememix_featured_content_extra_' . $new_instance['custom_field']);
     if ($new_instance['custom_field'] != $old_instance['custom_field']) {
         ThemeMix_Featured_Content::delete_transient('thememix_featured_content_extra_' . $old_instance['custom_field']);
     }
     ThemeMix_Featured_Content::delete_transient('thememix_featured_content_main_' . $new_instance['custom_field']);
     if ($new_instance['custom_field'] != $old_instance['custom_field']) {
         ThemeMix_Featured_Content::delete_transient('thememix_featured_content_main_' . $old_instance['custom_field']);
     }
     // Fix potential issues
     $new_instance['page_id'] = 'page' !== $new_instance['post_type'] ? '' : absint($new_instance['page_id']);
     $new_instance['include_exclude'] = 'page' !== $new_instance['post_type'] ? $new_instance['include_exclude'] : '';
     $new_instance['link_title_field'] = $new_instance['link_title'] ? $new_instance['link_title_field'] : '';
     return apply_filters('thememix_featured_content_update', $new_instance, $old_instance);
 }