Пример #1
0
 public static function get_url()
 {
     static $cache = null;
     if ($cache === null) {
         $cache = esc_url(theme_cache::get_permalink(theme_cache::get_page_by_path(self::$page_slug)->ID));
     }
     return $cache;
 }
Пример #2
0
 public static function page_create()
 {
     if (!theme_cache::current_user_can('manage_options')) {
         return false;
     }
     $page_slugs = array(self::$page_slug => array('post_content' => '[no-content]', 'post_name' => 'account', 'post_title' => ___('Account'), 'page_template' => 'page-' . self::$page_slug . '.php'));
     $defaults = array('post_content' => '[post_content]', 'post_name' => null, 'post_title' => null, 'post_status' => 'publish', 'post_type' => 'page', 'comment_status' => 'closed');
     foreach ($page_slugs as $k => $v) {
         theme_cache::get_page_by_path($k) || wp_insert_post(array_merge($defaults, $v));
     }
 }
Пример #3
0
 public static function get_tabs($key = null)
 {
     static $base_url = null, $tabs = null;
     if ($base_url === null) {
         $base_url = theme_cache::get_permalink(theme_cache::get_page_by_path(self::$page_slug)->ID);
     }
     if ($tabs === null) {
         $tabs = ['recommend' => ['tx' => ___('Recommend'), 'icon' => 'star', 'url' => esc_url(add_query_arg(['tab' => 'recommend'], $base_url))], 'popular' => ['tx' => ___('Popular'), 'icon' => 'bar-chart', 'url' => esc_url(add_query_arg(['tab' => 'popular'], $base_url)), 'filters' => ['day' => ['tx' => ___('Daily popular'), 'url' => esc_url(add_query_arg(['tab' => 'popular', 'filter' => 'day'], $base_url))], 'week' => ['tx' => ___('Weekly popular'), 'url' => add_query_arg(['tab' => 'popular', 'filter' => 'week'], $base_url)], 'month' => ['tx' => ___('Monthly popular'), 'url' => esc_url(add_query_arg(['tab' => 'popular', 'filter' => 'month'], $base_url))]]], 'latest' => ['tx' => ___('Latest'), 'icon' => 'refresh', 'url' => esc_url(add_query_arg(['tab' => 'latest'], $base_url))], 'users' => ['tx' => ___('Users'), 'icon' => 'users', 'url' => esc_url(add_query_arg(['tab' => 'users'], $base_url)), 'filter' => ['me' => ['tx' => ___('Me'), 'url' => esc_url(add_query_arg(['tab' => 'user', 'filter' => 'me'], $base_url))]]]];
     }
     /** end types */
     if ($key) {
         return isset($tabs[$key]) ? $tabs[$key] : false;
     }
     return $tabs;
 }