Skip to content

Instantly share code, notes, and snippets.

@aristath
Last active October 11, 2019 09:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aristath/7c6b6373cf166d890d42 to your computer and use it in GitHub Desktop.
Save aristath/7c6b6373cf166d890d42 to your computer and use it in GitHub Desktop.
<?php
class Maera_Timber_Conditionals extends TimberCore {
public $comments_open;
public $has_tag;
public $has_term;
public $in_category;
public $is_404;
public $is_admin;
public $is_archive;
public $is_attachment;
public $is_author;
public $is_category;
public $is_child_theme;
public $is_comments_popup;
public $is_date;
public $is_day;
public $is_feed;
public $is_front_page;
public $is_home;
public $is_month;
public $is_multi_author;
public $is_multisite;
public $is_main_site;
public $is_page;
public $is_page_template;
public $is_paged;
public $is_preview;
public $is_rtl;
public $is_search;
public $is_single;
public $is_singular;
public $is_sticky;
public $is_super_admin;
public $is_tag;
public $is_tax;
public $is_time;
public $is_trackback;
public $is_year;
public $pings_open;
public function __construct() {
$this->comments_open = $this->comments_open();
$this->has_tag = $this->has_tag();
$this->has_term = $this->has_term();
$this->in_category = $this->in_category();
$this->is_404 = $this->is_404();
$this->is_admin = $this->is_admin();
$this->is_archive = $this->is_archive();
$this->is_attachment = $this->is_attachment();
$this->is_author = $this->is_author();
$this->is_category = $this->is_category();
$this->is_child_theme = $this->is_child_theme();
$this->is_comments_popup = $this->is_comments_popup();
$this->is_date = $this->is_date();
$this->is_day = $this->is_day();
$this->is_feed = $this->is_feed();
$this->is_front_page = $this->is_front_page();
$this->is_home = $this->is_home();
$this->is_month = $this->is_month();
$this->is_multi_author = $this->is_multi_author();
$this->is_multisite = $this->is_multisite();
$this->is_main_site = $this->is_main_site();
$this->is_page = $this->is_page();
$this->is_page_template = $this->is_page_template();
$this->is_paged = $this->is_paged();
$this->is_preview = $this->is_preview();
$this->is_rtl = $this->is_rtl();
$this->is_search = $this->is_search();
$this->is_single = $this->is_single();
$this->is_singular = $this->is_singular();
$this->is_sticky = $this->is_sticky();
$this->is_super_admin = $this->is_super_admin();
$this->is_tag = $this->is_tag();
$this->is_tax = $this->is_tax();
$this->is_time = $this->is_time();
$this->is_trackback = $this->is_trackback();
$this->is_year = $this->is_year();
$this->pings_open = $this->pings_open();
}
public function comments_open( $post_id = 0 ) {
return comments_open( $post_id );
}
public function has_tag( $tag = '', $post = null ) {
return has_tag( $tag, $post );
}
public function has_term( $term = '', $taxonomy = '', $post = null ) {
return has_term( $term, $taxonomy, $post );
}
public function in_category( $category, $post = null ) {
return in_category( $category, $post );
}
public function is_404() {
return is_404();
}
public function is_admin() {
return is_admin();
}
public function is_archive() {
return is_archive();
}
public function is_attachment() {
return is_attachment();
}
public function is_author( $author ) {
return is_author( $author );
}
public function is_category( $category ) {
return is_category( $category );
}
public function is_child_theme() {
return is_child_theme();
}
public function is_comments_popup() {
return is_comments_popup();
}
public function is_date() {
return is_date();
}
public function is_day() {
return is_day();
}
public function is_feed( $feeds = '' ) {
return is_feed( $feeds );
}
public function is_front_page() {
return is_front_page();
}
public function is_home() {
return is_home();
}
public function is_month() {
return is_month();
}
public function is_multi_author() {
return is_multi_author();
}
public function is_multisite() {
return is_multisite();
}
public function is_main_site( $blog_id = null ) {
return is_main_site( $blog_id );
}
public function is_page( $page = '' ) {
return is_page( $page );
}
public function is_page_template( $template = '' ) {
return is_page_template( $template );
}
public function is_paged() {
return is_paged();
}
public function is_preview() {
return is_preview();
}
public function is_rtl() {
return is_rtl();
}
public function is_search() {
return is_search();
}
public function is_single( $post = '' ) {
return is_single( $post );
}
public function is_singular( $post_types = '' ) {
return is_singular( $post_types );
}
public function is_sticky( $post_id = 0 ) {
return is_sticky( $post_id );
}
public function is_super_admin( $user_id = false ) {
return is_super_admin( $user_id );
}
public function is_tag( $tag = '' ) {
return is_tag( $tag );
}
public function is_tax( $taxonomy = '', $term = '' ) {
return is_tax( $taxonomy, $term );
}
public function is_time() {
return is_time();
}
public function is_trackback() {
return is_trackback();
}
public function is_year() {
return is_year();
}
public function pings_open( $post_id = null ) {
return pings_open( $post_id );
}
}
$mara_wp_core_conditionals = new Maera_Timber_Conditionals();
@rodmar35
Copy link

Hi,

Thanks for this gist. Could you explain us or give an example how to implement it ?
Regards

@aristath
Copy link
Author

Hello @rodmar35

Could you explain us or give an example how to implement it ?

Honestly? No. It's been more than 4 years since I wrote this, I don't recall what it was for or why i wrote it.
Did you find this gist from a ticket somewhere so that i can get an idea and remember what it was all about?

@rodmar35
Copy link

Hi @aristath,

No problem :-) I've find it by google search.
Timber is a Wordpress "theme/library" for using twig in templating : https://timber.github.io
Your gist extend TimberCore.
I hope this will help you find the memory otherwise it does not matter I will try my side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment