public function taxonomy($taxonomy) { $this->taxonomy = $taxonomy; if (!is_array($this->taxonomy)) { $this->model = Yare::config("register.taxonomies.{$this->taxonomy}.model", 'Term'); } return $this; }
function add_to_twig($twig) { $filters = Yare::config('theme.filters'); foreach ($filters as $filter => $callback) { $twig->addFilter($filter, new \Twig_SimpleFilter($filter, $callback)); } $functions = Yare::config('theme.functions'); foreach ($functions as $function => $callback) { $twig->addFunction($function, new \Twig_SimpleFunction($function, $callback)); } return $twig; }
public function type($type = 'post') { if (func_num_args() > 1) { $this->post_type = func_get_args(); } else { $this->post_type = $type ?: 'post'; } if (!is_array($this->post_type)) { $this->model = Yare::config("register.post_types.{$this->post_type}.model", 'Post'); } return $this; }
function theme_page_templates($page_templates, $theme, $post) { foreach (Yare::config('register.page_templates', array()) as $value => $label) { $page_templates[$value] = $label; } return $page_templates; }
function remove_post_type_supports() { $default_supports = array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats'); $default_types = array('post', 'page', 'attachment', 'revision', 'nav_menu_item'); $post_types = Yare::config('register.post_types', array()); foreach ($post_types as $post_type => $args) { if (!in_array($post_type, $default_types) or !array_key_exists('supports', $args)) { return; } $supports = array_diff($default_supports, (array) $args['supports']); foreach ($supports as $support) { remove_post_type_support($post_type, $support); //remove_meta_box( 'commentstatusdiv', $post_type, 'nomral' ); remove_meta_box($support . 'div', $post_type, 'nomral'); } } }
<?php namespace Yare\ThemeSetup\ACF; use Yare\Yare; if (function_exists('acf_add_options_page')) { if (!class_exists('acf_pro_options_page')) { acf_include('pro/admin/options-page.php'); } foreach ((array) Yare::config('register.options_page') as $slug => $option) { if (is_numeric($slug)) { acf_add_options_page($option); continue; } $args = array('capability' => 'edit_posts', 'redirect' => false, 'menu_slug' => $slug); if (is_string($option)) { $args['page_title'] = $option; $args['menu_title'] = $option; acf_add_options_page($args); } elseif (is_array($option)) { if (isset($option['page_title'])) { $args = array_merge($args, $option); } elseif (isset($option['main_page'])) { if (!is_array($option['main_page'])) { $args['page_title'] = $option['main_page']; $args['menu_title'] = $option['main_page']; } else { $args = array_merge($args, $option['main_page']); } } }
function hooks() { foreach ((array) Yare::config('theme.hooks') as $key => $hooks) { if (!is_array($hooks)) { continue; } foreach ($hooks as $args) { $added = $key === 'remove' && is_numeric($args[1]) ? '_all_filters' : '_filter'; call_user_func_array($key . $added, $args); } } }
function script_loader_tag_init() { global $sw_script_tags; if (isset($sw_script_tags)) { return; } $sw_script_allow_attrs = array('async', 'defer'); $sw_script_tags = array(); foreach ((array) Yare::config('assets.scripts') as $handle => $args) { if (!is_array($args)) { continue; } foreach ($sw_script_allow_attrs as $key) { if (array_key_exists($key, $args)) { $attr = sprintf('%s="%s"', $key, $args[$key]); $sw_script_tags[$handle] = $attr; } } } }
/** * Get a config item from config files using "dot" notation. * * @param string $key * @param mixed $default * * @return mixed */ function wpsw_get_config($key, $default = null) { return Yare::config($key, $default); }
public function register_menu_pages() { $admin_menu = Yare::config('register.admin_menus', array()); foreach ((array) $admin_menu as $menu_slug => $menu_args) { //if (isset($menu_args['link'])) { // continue; //} if (isset($menu_args['parent_slug'])) { $args = array('parent_slug' => 'options-general.php', 'page_title' => '', 'menu_title' => '', 'capability' => 'manage_options', 'menu_slug' => '', 'function' => ''); if (isset($menu_args['view'])) { $sub_view = array_get($menu_args, 'view', 'Admin'); $function = str_replace('\\', '_', $sub_view); //$parent_slug = array_get($menu_args, 'parent_slug', ''); $menu_args['menu_slug'] = $menu_slug; $menu_args['function'] = array($this, $function); } if (isset($menu_args['link'])) { $this->highlight_files[$menu_args['link']] = $menu_args['parent_slug']; $menu_args['menu_slug'] = $menu_args['link']; } foreach ($args as $key => $value) { $args[$key] = array_get($menu_args, $key, $value); } pc($args, 'add_submenu_page'); call_user_func_array('add_submenu_page', $args); continue; } $args = array('page_title' => '', 'menu_title' => '', 'capability' => 'manage_options', 'menu_slug' => '', 'function' => '', 'icon_url' => '', 'position' => 6); if (isset($menu_args['view'])) { $view = array_get($menu_args, 'view', 'Admin'); $function = str_replace('\\', '_', $view); $menu_args['menu_slug'] = $menu_slug; $menu_args['function'] = array($this, $function); } if (isset($menu_args['link'])) { //$this->highlight_files[$menu_args['link']] = $menu_args['parent_slug']; $menu_args['menu_slug'] = $menu_args['link']; } foreach ($args as $key => $value) { $args[$key] = array_get($menu_args, $key, $value); } pc($args, 'add_menu_page'); call_user_func_array('add_menu_page', $args); if ($sub_menu = array_get($menu_args, 'sub_menu')) { foreach ($sub_menu as $sub_menu_slug => $sub_menu_args) { //if (isset($sub_menu_args['link'])) { // continue; //} $args = array('parent_slug' => $menu_slug, 'page_title' => '', 'menu_title' => '', 'capability' => 'manage_options', 'menu_slug' => '', 'function' => ''); if (isset($sub_menu_args['view'])) { $sub_view = array_get($sub_menu_args, 'view', 'Admin'); $function = str_replace('\\', '_', $sub_view); $sub_menu_args['menu_slug'] = $menu_slug . '-' . $sub_menu_slug; $sub_menu_args['function'] = array($this, $function); } if (isset($sub_menu_args['link'])) { remove_menu_page($sub_menu_args['link']); $this->highlight_files[$sub_menu_args['link']] = $menu_slug; $sub_menu_args['menu_slug'] = $sub_menu_args['link']; } foreach ($args as $key => $value) { $args[$key] = array_get($sub_menu_args, $key, $value); } pc($args, 'add_submenu_page'); call_user_func_array('add_submenu_page', $args); } } } }