function test_filter_c2c_admin_post_navigation_orderby()
 {
     add_filter('c2c_admin_post_navigation_orderby', array($this, 'c2c_admin_post_navigation_orderby'), 10, 2);
     $posts = $this->create_posts();
     // Change post dates so post ordering by date is 3, 0, 2, 4, 1
     $new_post_dates = array('2015-06-13 12:30:00', '2015-03-13 12:30:00', '2015-05-13 12:30:00', '2015-07-13 12:30:00', '2015-04-13 12:30:00');
     foreach ($new_post_dates as $i => $date) {
         $post = get_post($posts[$i]);
         $post->post_date = $date;
         wp_update_post($post);
     }
     $next_post = c2c_AdminPostNavigation::next_post();
     $this->assertEquals($posts[0], $next_post->ID);
     $previous_post = c2c_AdminPostNavigation::previous_post();
     $this->assertEquals($posts[4], $previous_post->ID);
 }
 /**
  * Register meta box.
  *
  * By default, the navigation is present for all post types. Filter
  * 'c2c_admin_post_navigation_post_types' to limit its use.
  *
  * @param string  $post_type The post type.
  * @param string  $type      The mode for the meta box (normal, advanced, or side).
  * @param WP_Post $post      The post.
  */
 public static function do_meta_box($post_type, $type, $post)
 {
     $post_types = apply_filters('c2c_admin_post_navigation_post_types', get_post_types());
     if (!in_array($post_type, $post_types)) {
         return;
     }
     $post_statuses = (array) apply_filters('c2c_admin_post_navigation_post_statuses', self::$post_statuses, $post_type, $post);
     if ($post_statuses) {
         foreach ($post_statuses as $i => $v) {
             $GLOBALS['wpdb']->escape_by_ref($v);
             $post_statuses[$i] = $v;
         }
         self::$post_statuses_sql = "'" . implode("', '", $post_statuses) . "'";
     }
     if (in_array($post->post_status, $post_statuses)) {
         add_meta_box('adminpostnav', sprintf(__('%s Navigation', 'admin-post-navigation'), ucfirst($post_type)), array(__CLASS__, 'add_meta_box'), $post_type, 'side', 'core');
     }
 }
 /**
  * Register meta box
  *
  * By default, the navigation is present for all post types.  Filter
  * 'c2c_admin_post_navigation_post_types' to limit its use.
  *
  * @param string $post_type The post type
  * @param string $type The mode for the meta box (normal, advanced, or side)
  * @param WP_Post $post The post
  * @return void
  */
 public static function do_meta_box($post_type, $type, $post)
 {
     $post_types = apply_filters('c2c_admin_post_navigation_post_types', get_post_types());
     if (!in_array($post_type, $post_types)) {
         return;
     }
     $post_statuses = apply_filters('c2c_admin_post_navigation_post_statuses', self::$post_statuses, $post_type, $post);
     self::$post_statuses_sql = "'" . implode("', '", array_map('esc_sql', $post_statuses)) . "'";
     $label = self::_get_post_type_label($post_type);
     if (in_array($post->post_status, $post_statuses)) {
         add_meta_box('adminpostnav', sprintf(__('%s Navigation', 'admin-post-navigation'), ucfirst($post_type)), array(__CLASS__, 'add_meta_box'), $post_type, 'side', 'core');
     }
 }