} } } return $template; } /** * Fetch site list. * * @since 1.0.0 */ public static function get_sites() { $output = array(); $qargs = array('post_type' => 'dbsite', 'no_found_rows' => true, 'posts_per_page' => -1); $all_posts = get_posts($qargs); if ($all_posts) { foreach ($all_posts as $p) { $item = array(); $item['ID'] = $p->ID; $item['title'] = apply_filters('the_title', $p->post_title); $item['slug'] = $p->post_name; $item['site_url'] = get_post_meta($p->ID, 'demo_bar_site_url', true); $item['download_url'] = get_post_meta($p->ID, 'demo_bar_download_url', true); $output[$p->ID] = $item; } } return $output; } } DemoBar_Switcher::init();
language_attributes(); ?> > <head> <meta charset="<?php bloginfo('charset'); ?> "> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> <?php wp_head(); ?> </head> <?php $current_demo = ''; $sites = DemoBar_Switcher::get_sites(); $site_param = isset($_REQUEST['demo']) ? sanitize_key($_REQUEST['demo']) : ''; $valid_key = false; if (!empty($sites)) { $valid_key = demobar_array_find_by_key($sites, 'slug', $site_param); if (false === $valid_key) { $first_element = reset($sites); $valid_key = $first_element['ID']; } } if (false !== $valid_key) { $current_demo = $valid_key; } ?> <body> <div id="db-switcher">