function testIsChildTheme() { $base = new RockharborThemeBase(); $this->assertFalse($base->isChildTheme()); $this->Base->setTestPaths(); $this->assertTrue($this->Base->isChildTheme()); }
/** * Adds new roles if they are missing. Also takes care of other access control * related filters. * * @return void */ public function init() { global $wp_roles; if (!$wp_roles->is_role('production')) { // to update the role, I had to run `remove_role()` first #YAWPH add_role('production', 'Production Staff', array('upload_files' => true, 'edit_posts' => false, 'delete_posts' => true, 'read' => true)); } $user = $this->theme->userMetaToData(get_current_user_id()); if (!empty($user['show_only_owned_posts'])) { add_filter('pre_get_posts', array($this, 'limitPostsToUser')); } }
/** * Creates an image tag * * ### Attr * - boolean $parent If true, will pull from parent theme, otherwise child theme * - ...rest Attributes for the img tag * * @param string $url The name of the image * @param array $attr Attributes and options * @return string Image code */ public function image($url, $attr = array()) { $_options = array('url' => false, 'parent' => false); $attr += $_options; $options = array_intersect_key($attr, $_options); $attr = array_diff_key($attr, $options); if (empty($url)) { return null; } $path = $options['parent'] ? $this->theme->info('base_url') : $this->theme->info('url'); if ($options['url']) { return $path . '/img/' . $url; } return '<img src="' . $path . '/img/' . $url . '"' . $this->parseAttributes($attr) . '/>'; }
/** * Adds plugin * * @param array $plugin_array * @return array */ public function addEditorPlugins($plugin_array) { $plugin_array['audioShortcode'] = $this->theme->info('base_url') . '/js/mceplugins/audio_plugin.js'; $plugin_array['videoShortcode'] = $this->theme->info('base_url') . '/js/mceplugins/video_plugin.js'; $plugin_array['columns'] = $this->theme->info('base_url') . '/js/mceplugins/columns_plugin.js'; return $plugin_array; }
/** * Shortcode to display this post type's posts within a page. #YAWPH * * The shortcode itself runs a loop within the current loop and restores the * original when it's done. This allows us to show the content of whatever page * shows the archives in addition to the archives. * * Passing attributes add to the query. * * ### Default query: * - `numberofposts` -1 Shows all posts * * @param array $attrs Shortcode attributes * @return string Post type's archives */ public function shortcode($attrs = array()) { global $wp_query, $wp_rewrite; $_old_query = $wp_query; $query = $this->archiveQuery; $query['post_type'] = $this->name; if (isset($attrs['campus'])) { switch_to_blog($attrs['campus']); } $wp_query = new WP_Query($query); $wp_query->query($query); // we have to gobble this up and return it so it doesn't just print everywhere ob_start(); // loop within loop while (have_posts()) { the_post(); get_template_part('content', $this->options['slug']); } $this->theme->set('wp_rewrite', $wp_rewrite); $this->theme->set('wp_query', $wp_query); echo $this->theme->render('pagination'); $return = ob_get_clean(); // back to the old query $wp_query = $_old_query; if (isset($attrs['campus'])) { restore_current_blog(); } return $return; }
/** * Adds plugin * * @param array $plugin_array * @return array */ public function addEditorPlugins($plugin_array) { $min = WP_DEBUG ? '' : '.min'; $plugin_array['audioShortcode'] = $this->theme->info('base_url')."/js/mceplugins/audio_plugin{$min}.js"; $plugin_array['videoShortcode'] = $this->theme->info('base_url')."/js/mceplugins/video_plugin{$min}.js"; $plugin_array['columns'] = $this->theme->info('base_url')."/js/mceplugins/columns_plugin{$min}.js"; return $plugin_array; }
/** * Renders the backend widget form * * @param array $data Database values provided in backend */ public function form($data) { $_defaults = array('title' => 'Widget'); $data = array_merge($_defaults, $data); // need to use methods in this class to generate fields $this->theme->set('widget', $this); $this->theme->set('data', $data); echo $this->theme->render('admin' . DS . 'widgets' . DS . $this->settings['base_id']); }
/** * Renders the template options meta box */ public function templateOptionsMetabox() { global $post; $this->theme->set('data', $this->theme->metaToData($post->ID)); echo $this->theme->render('admin' . DS . 'template_options_meta_box'); }
/** * Theme constructor */ public function __construct() { parent::__construct(); $this->_customShortcodes(); }