Пример #1
0
 function test_delete_should_delete_original_entry()
 {
     $entry = $this->insert_entry();
     $update_entry = WPCOM_Liveblog_Entry::delete($this->build_entry_args(array('entry_id' => $entry->get_id())));
     $query = new WPCOM_Liveblog_Entry_Query($entry->get_post_id(), 'liveblog');
     $this->assertNull($query->get_by_id($entry->get_id()));
 }
Пример #2
0
 function test_remove_replaced_entries_should_not_remove_entries_replacing_non_existing_entries()
 {
     $entries = array();
     $entries[0] = new WPCOM_Liveblog_Entry((object) array('comment_ID' => 1));
     $entries[1] = new WPCOM_Liveblog_Entry((object) array('comment_ID' => 1000));
     $entries[1]->replaces = 999;
     $filtered_entries = WPCOM_Liveblog_Entry_Query::remove_replaced_entries($entries);
     $this->assertEquals(array(1, 1000), $this->get_ids_from_entries($filtered_entries));
 }
 /**
  * Builds the box to display key entries
  *
  * @param $atts
  * @return mixed
  */
 public static function shortcode($atts)
 {
     global $post;
     if (!is_single()) {
         return;
     }
     // Define the default shortcode attributes.
     $atts = shortcode_atts(array('title' => 'Key Events'), $atts);
     // The args to pass into the entry query.
     $args = array('meta_key' => self::meta_key, 'meta_value' => self::meta_value);
     $limit = get_post_meta($post->ID, self::meta_key_limit, true);
     if (isset($limit)) {
         $args['number'] = $limit;
     }
     // Build the entry query.
     $entry_query = new WPCOM_Liveblog_Entry_Query($post->ID, WPCOM_Liveblog::key);
     // Execute the entry query with the previously defined args.
     $entries = (array) $entry_query->get_all($args);
     // Grab the template to use.
     $template = self::get_current_template($post->ID);
     // Only run the shortcode on an archived or enabled post.
     if (WPCOM_Liveblog::get_liveblog_state($post->ID)) {
         // Render the actual template.
         return WPCOM_Liveblog::get_template_part('liveblog-key-events.php', array('entries' => $entries, 'title' => $atts['title'], 'template' => $template[0], 'wrap' => $template[1], 'class' => $template[2]));
     }
 }