function __construct($args = array()) { if (!function_exists('my_t_define_constants')) { die('Theme constants not defined.'); } parent::__construct(); // default self::$assets_path = MY_BASEPATH . DS . 'assets'; self::$assets_url = MY_BASEURL . '/' . 'assets'; self::$widgets_path = MY_BASEPATH . DS . 'widgets'; self::$feeds_path = MY_BASEPATH . DS . 'feeds'; self::$admin_path = MY_BASEPATH . DS . 'admin-pages'; self::$builds_path = MY_BASEPATH . DS . 'builds'; self::$tools_path = MY_BASEPATH . DS . 'tools'; // custom overrides + dynamic property declarations // this allows use to save some space foreach ($args as $key => $value) { if (property_exists($this, $key) or $this->is_switch_var($key)) { $this->{$key} = $value; } } $this->assets = new MY_Theme_Assets(array('handle' => self::$assets_path, 'url' => self::$assets_url)); $this->check_dependencies(); $this->check_phpversion(); $this->check_activation(); $this->add_wp_hooks(); if (MY_ISADMIN) { add_action('admin_menu', array($this, 'add_admin_pages'), 1); // add first b/c we're important } // TODO - do admin $this->save_plugins_list(); // outsource data sanitizing // wp-post/query interface, request var handling $this->template = new StdClass(); }
function __get($name) { switch (TRUE) { case WPHF::has_prefix($name, self::$conditional_tag): // _log($name); switch (TRUE) { case in_array($name, self::$conditional_tag_by_admin): return $this->author->ID == self::$id_admin; break; case in_array($name, self::$conditional_tag_last_post): return $this->wp_query->current_post + 1 == $this->wp_query->post_count; break; case in_array($name, self::$conditional_tag_post_profile): return TRUE; break; case in_array($name, self::$conditional_tag_post_project): return TRUE; break; case in_array($name, self::$conditional_tag_post_event): // TODO - return TRUE; break; case in_array($name, self::$conditional_tag_post_news): return TRUE; break; case in_array($name, self::$conditional_tag_post_job): return TRUE; break; } break; case in_array($name, self::$boolean_tag): switch (TRUE) { case in_array($name, self::$conditional_tag_by_admin): return $_COOKIE['wp-postpass_' . COOKIEHASH] == $this->post->post_password; break; } break; case in_array($name, self::$post_tag_ids_people): // custom result $result = WPHF::element('post_tag_ids_people', $this->cache, array()); if (empty($result)) { $people = query_posts(array('cat' => $this->cat_id_people)); $people_names = array(); foreach ($people as $person) { $people_names[] = sprintf(self::$tag_slug_pattern, $person->post_name); } foreach ($this->tags as $tag) { if (in_array($tag->slug, $people_names)) { $result[] = $tag->term_id; } } $this->cache['post_tag_ids_people'] = $result; } return $result; break; } // #end custom template vars return parent::__get($name); }