/** * 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']) : GS_Featured_Content::set_custom_field($new_instance); GS_Featured_Content::delete_transient('gsfc_extra_' . $new_instance['custom_field']); if ($new_instance['custom_field'] != $old_instance['custom_field']) { GS_Featured_Content::delete_transient('gsfc_extra_' . $old_instance['custom_field']); } GS_Featured_Content::delete_transient('gsfc_main_' . $new_instance['custom_field']); if ($new_instance['custom_field'] != $old_instance['custom_field']) { GS_Featured_Content::delete_transient('gsfc_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('gsfc_update', $new_instance, $old_instance); }
/** * Do Action * * @param array $instance The settings for the particular instance of the widget. */ public function do_action($instance) { //* Bail if empty show param if (empty($instance['show_icon'])) { return; } $link = $instance['link_icon_field'] && get_post_meta(get_the_ID(), $instance['link_icon_field'], true) ? get_post_meta(get_the_ID(), $instance['link_icon_field'], true) : get_permalink(); $icon = sprintf('<%1$s class="%2$s"></%1$s>', $instance['icon_tag'], $instance['icon']); $icon = $instance['link_icon'] == 1 ? sprintf('<a href="%s" title="%s" class="%s">%s</a>', $link, the_title_attribute('echo=0'), $align, $icon) : $icon; echo 'icon'; GS_Featured_Content::maybe_echo($instance, 'gsfc_before_post_content', 'icon_position', 'before-title', $icon); GS_Featured_Content::maybe_echo($instance, 'gsfc_post_content', 'icon_position', 'after-title', $icon); GS_Featured_Content::maybe_echo($instance, 'gsfc_after_post_content', 'icon_position', 'after-content', $icon); }