-
-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.x Cleanup todo in code #2757
2.x Cleanup todo in code #2757
Changes from all commits
e650418
a68cd59
c010fa2
dd2f3a7
efab9da
7620017
98a7954
9812196
7a71a26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,6 @@ protected function fetch_meta($field_name = '', $args = [], $apply_filters = tru | |
$args | ||
); | ||
|
||
// @todo Remove when deprecated filters will be gone | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove all |
||
if ($object_type !== 'term') { | ||
/** | ||
* Filters the value for a post meta field before it is fetched from the database. | ||
|
@@ -236,7 +235,6 @@ protected function fetch_meta($field_name = '', $args = [], $apply_filters = tru | |
$args | ||
); | ||
|
||
// @todo Remove when deprecated filters will be gone | ||
if ($object_type === 'term') { | ||
/** | ||
* Filters the value for a term meta field. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,6 @@ protected function from_user_object($obj): CoreInterface | |
)); | ||
} | ||
|
||
// @todo return a UserCollection instance? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not at the moment. We discussed somewhere that user collections or collections for other types of content are not needed at the moment (#1689). We can add it if we really need it. |
||
protected function from_wp_user_query(WP_User_Query $query): iterable | ||
{ | ||
return array_map([$this, 'build'], $query->get_results()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,7 +198,7 @@ public function render($file, $data = null, $expires = false, $cache_mode = self | |
/** | ||
* Filters … | ||
* | ||
* @todo Add summary | ||
* @todo Add summary | ||
* | ||
* @deprecated 2.0.0, use `timber/output` | ||
*/ | ||
|
@@ -587,7 +587,6 @@ public function clear_cache_twig() | |
$twig = $this->get_twig(); | ||
|
||
// Get the configured cache location. | ||
// @todo What if this is a custom caching implementation? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will pop up as an issue in case it becomes a problem. |
||
$cache_location = $twig->getCache(true); | ||
|
||
// Cache not activated. | ||
|
@@ -596,7 +595,6 @@ public function clear_cache_twig() | |
} | ||
|
||
if (is_string($cache_location) && is_dir($cache_location)) { | ||
// @todo What if not all files could be deleted? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be improved when we introduce better and streamlined error handling, see #2210. |
||
self::rrmdir($cache_location); | ||
return true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,6 @@ | |
* </div> | ||
* </article> | ||
* ``` | ||
* @todo implement JsonSerializable? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Serialization can be added if needed. It’s documented in https://timber.github.io/docs/v2/guides/posts/#serialization. |
||
*/ | ||
class Post extends CoreEntity implements DatedInterface, Setupable | ||
{ | ||
|
@@ -165,7 +164,7 @@ class Post extends CoreEntity implements DatedInterface, Setupable | |
public $slug; | ||
|
||
/** | ||
* @var string Stores the PostType object for the Post | ||
* @var string Stores the PostType object for the post. | ||
*/ | ||
protected $__type; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ public function current() | |
*/ | ||
$wp_post = parent::current(); | ||
// Lazily instantiate a Timber\Post instance exactly once. | ||
// @todo maybe improve performance by caching the instantiated post. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Performance and caching is an area where we could improve in a lot of places. In case we want to improve post performance, we’ll find the right place to do it. |
||
$post = $factory->from($wp_post); | ||
$post->setup(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,11 +195,6 @@ public static function handle_preview($data, $post) | |
$data['post_title'] = $preview->post_title; | ||
$data['post_excerpt'] = $preview->post_excerpt; | ||
|
||
// @todo I think we can safely delete this? | ||
// It was included in the old PostCollection method but not defined anywhere, | ||
// so I think it was always just falling into a magic __call() and doing nothing. | ||
// $post->import_custom($preview_id); | ||
|
||
add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3); | ||
} | ||
|
||
|
@@ -318,7 +313,6 @@ public static function get_attachment($query = false, $options = []) | |
{ | ||
$post = static::get_post($query, $options); | ||
|
||
// @todo make this determination at the Factory level. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might improve this in the future. For the moment, it seems to work. |
||
// No need to instantiate a Post we're not going to use. | ||
return ($post instanceof Attachment) ? $post : null; | ||
} | ||
|
@@ -344,7 +338,6 @@ public static function get_image($query = false, $options = []) | |
{ | ||
$post = static::get_post($query, $options); | ||
|
||
// @todo make this determination at the Factory level. | ||
// No need to instantiate a Post we're not going to use. | ||
return ($post instanceof Image) ? $post : null; | ||
} | ||
|
@@ -457,9 +450,6 @@ public static function get_posts($query = false, $options = []) | |
); | ||
} | ||
|
||
/** | ||
* @todo Are there any more default options to support? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We’ll figure them out if needed. |
||
*/ | ||
$options = wp_parse_args($options, [ | ||
'merge_default' => false, | ||
]); | ||
|
@@ -863,7 +853,7 @@ public static function get_term_by(string $field, $value, string $taxonomy = '') | |
public static function get_users(array $query = [], array $options = []): iterable | ||
{ | ||
$factory = new UserFactory(); | ||
// TODO return a Collection type? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #1689. |
||
|
||
return $factory->from($query); | ||
} | ||
|
||
|
@@ -903,11 +893,6 @@ public static function get_users(array $query = [], array $options = []): iterab | |
*/ | ||
public static function get_user($user = null) | ||
{ | ||
/* | ||
* TODO in the interest of time, I'm implementing this logic here. If there's | ||
* a better place to do this or something that already implements this, let me know | ||
* and I'll switch over to that. | ||
*/ | ||
$user = $user ?: get_current_user_id(); | ||
|
||
$factory = new UserFactory(); | ||
|
@@ -1074,7 +1059,7 @@ public static function get_pages_menu(array $args = []) | |
public static function get_comments($query = [], array $options = []): iterable | ||
{ | ||
$factory = new CommentFactory(); | ||
// TODO return a Collection type? | ||
|
||
return $factory->from($query); | ||
} | ||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file didn’t really do anything. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,25 +178,20 @@ public function testNextCategory() | |
|
||
public function testNextCustomTax() | ||
{ | ||
$v = get_bloginfo('version'); | ||
if (version_compare($v, '3.8', '<')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don’t need to support WordPress < 3.8. |
||
$this->markTestSkipped('Custom taxonomy prev/next not supported until 3.8'); | ||
} else { | ||
register_taxonomy('pizza', 'post'); | ||
$posts = []; | ||
for ($i = 0; $i < 4; $i++) { | ||
$j = $i + 1; | ||
$posts[] = $this->factory->post->create([ | ||
'post_date' => '2014-02-0' . $j . ' 12:00:00', | ||
]); | ||
} | ||
wp_set_object_terms($posts[0], 'Cheese', 'pizza', false); | ||
wp_set_object_terms($posts[2], 'Cheese', 'pizza', false); | ||
wp_set_object_terms($posts[3], 'Mushroom', 'pizza', false); | ||
$firstPost = Timber::get_post($posts[0]); | ||
$nextPost = Timber::get_post($posts[2]); | ||
$this->assertEquals($firstPost->next('pizza')->ID, $nextPost->ID); | ||
register_taxonomy('pizza', 'post'); | ||
$posts = []; | ||
for ($i = 0; $i < 4; $i++) { | ||
$j = $i + 1; | ||
$posts[] = $this->factory->post->create([ | ||
'post_date' => '2014-02-0' . $j . ' 12:00:00', | ||
]); | ||
} | ||
wp_set_object_terms($posts[0], 'Cheese', 'pizza', false); | ||
wp_set_object_terms($posts[2], 'Cheese', 'pizza', false); | ||
wp_set_object_terms($posts[3], 'Mushroom', 'pizza', false); | ||
$firstPost = Timber::get_post($posts[0]); | ||
$nextPost = Timber::get_post($posts[2]); | ||
$this->assertEquals($firstPost->next('pizza')->ID, $nextPost->ID); | ||
} | ||
|
||
public function testPrev() | ||
|
@@ -215,25 +210,20 @@ public function testPrev() | |
|
||
public function testPrevCustomTax() | ||
{ | ||
$v = get_bloginfo('version'); | ||
if (version_compare($v, '3.8', '<')) { | ||
$this->markTestSkipped('Custom taxonomy prev/next not supported until 3.8'); | ||
} else { | ||
register_taxonomy('pizza', 'post'); | ||
$posts = []; | ||
for ($i = 0; $i < 3; $i++) { | ||
$j = $i + 1; | ||
$posts[] = $this->factory->post->create([ | ||
'post_date' => '2014-02-0' . $j . ' 12:00:00', | ||
'post_title' => "Pizza $j is so good!", | ||
]); | ||
} | ||
$cat = wp_insert_term('Cheese', 'pizza'); | ||
self::set_object_terms($posts[0], $cat, 'pizza', false); | ||
self::set_object_terms($posts[2], $cat, 'pizza', false); | ||
$lastPost = Timber::get_post($posts[2]); | ||
$this->assertEquals($posts[0], $lastPost->prev('pizza')->ID); | ||
register_taxonomy('pizza', 'post'); | ||
$posts = []; | ||
for ($i = 0; $i < 3; $i++) { | ||
$j = $i + 1; | ||
$posts[] = $this->factory->post->create([ | ||
'post_date' => '2014-02-0' . $j . ' 12:00:00', | ||
'post_title' => "Pizza $j is so good!", | ||
]); | ||
} | ||
$cat = wp_insert_term('Cheese', 'pizza'); | ||
self::set_object_terms($posts[0], $cat, 'pizza', false); | ||
self::set_object_terms($posts[2], $cat, 'pizza', false); | ||
$lastPost = Timber::get_post($posts[2]); | ||
$this->assertEquals($posts[0], $lastPost->prev('pizza')->ID); | ||
} | ||
|
||
public function testPrevCategory() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,20 +68,22 @@ public function testFrontPageAsPage() | |
|
||
public function testStaticPostPage() | ||
{ | ||
$this->markTestSkipped('@todo Undefined offset: 0 - do we need merge_default for this?'); | ||
$this->clearPosts(); | ||
$page_id = $this->factory->post->create([ | ||
'post_title' => 'Gobbles', | ||
'post_type' => 'page', | ||
]); | ||
update_option('page_for_posts', $page_id); | ||
$this->go_to(home_url('/?p=' . $page_id)); | ||
$children = $this->factory->post->create_many(10, [ | ||
$posts = $this->factory->post->create_many(10, [ | ||
'post_title' => 'Timmy', | ||
]); | ||
|
||
update_option('show_on_front', 'page'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line was missing to get the test working. |
||
update_option('page_for_posts', $page_id); | ||
$this->go_to(get_permalink($page_id)); | ||
|
||
$posts = Timber::get_posts(); | ||
$first_post = $posts[0]; | ||
$this->assertEquals('Timmy', $first_post->title()); | ||
|
||
$this->assertEquals('Timmy', $posts[0]->title()); | ||
} | ||
|
||
public function testOtherPostOnStaticPostPage() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an issue in the future, it will pop up as an issue.