delete_transient() public static method

Hooks in the "save_post" action.
public static delete_transient ( )
Esempio n. 1
0
 /**
  * Fires during init, looks for a semicolon_action.
  */
 public static function inline_controls_handler()
 {
     if (empty($_GET['semicolon_action']) || !is_user_logged_in()) {
         return;
     }
     $action = strtolower($_GET['semicolon_action']);
     if (!in_array($action, array('toggle_featured'))) {
         return;
     }
     // Powered by Jetpack's Featured Content.
     if ('toggle_featured' == $action) {
         if (empty($_GET['semicolon_post_id'])) {
             return;
         }
         $post_id = absint($_GET['semicolon_post_id']);
         $post = get_post($post_id);
         if (!current_user_can('edit_post', $post->ID)) {
             return;
         }
         // Only if the featured content tag has been set.
         $term_id = self::get_jetpack_featured_content_term_id();
         if (!$term_id) {
             return;
         }
         // Toggle the featured content tag.
         if (self::is_featured($post->ID)) {
             wp_remove_object_terms($post->ID, $term_id, 'post_tag');
         } else {
             wp_set_object_terms($post->ID, $term_id, 'post_tag', true);
         }
         if (method_exists('Featured_Content', 'delete_transient')) {
             Featured_Content::delete_transient();
         }
         $redirect_url = remove_query_arg(array('semicolon_action', 'semicolon_post_id'));
         $redirect_url .= sprintf('#semicolon-post-%d', $post->ID);
         wp_safe_redirect(esc_url_raw($redirect_url));
     }
 }