function initalize_theme() { $pages = array(OP_SN, OP_SN . '-setup-wizard'); $reinit_theme = $reinit_page_theme = false; $disable_theme = false; if (isset($_GET['page'])) { if ($_GET['page'] == OP_SN || $_GET['page'] == OP_SN . '-setup-wizard') { $cur = op_get_option('theme', 'dir'); if (isset($_GET['theme_switch']) && $_GET['theme_switch'] != $cur && ($conf = op_load_theme_config($_GET['theme_switch'])) !== false) { $theme = array('name' => $conf['name'], 'screenshot' => $conf['screenshot'], 'screenshot_thumbnail' => $conf['screenshot_thumbnail'], 'description' => $conf['description'], 'dir' => $_GET['theme_switch']); op_update_option('theme', $theme); $reinit_theme = true; } } elseif ($_GET['page'] == OP_SN . '-page-builder') { $disable_theme = true; } } elseif (defined('DOING_AJAX')) { $action = ''; if (!($action = op_get('action'))) { $action = op_post('action'); } $chk = OP_SN . '-live-editor'; if (is_string($action) && substr($action, 0, strlen($chk)) == $chk) { $disable_theme = true; } } if ($disable_theme === false) { op_init_theme(); define('OP_REINIT_THEME', $reinit_theme); if ($reinit_theme) { define('OP_SHOW_THEME_MSG', $cur !== false); do_action(OP_SN . '-reinit_theme'); } } }
function op_template_include($template, $use_template = true) { /* * Assuring that we don't run this method twice (once on the template_include and once on the index_template hook) */ static $passed; if (isset($passed) && true === $passed && !empty($template)) { return $template; } $passed = true; if (op_get_option('blog_enabled') != 'Y' || op_get_option('installed') != 'Y') { global $post; if (!empty($post) && 'page' != $post->post_type) { return OP_DIR . 'index.php'; } } if ($use_template) { if ($id = get_queried_object_id()) { $status = get_post_status($id); if ($status == 'publish' || (current_user_can('edit_posts') || current_user_can('edit_pages'))) { if (get_post_meta($id, '_' . OP_SN . '_pagebuilder', true) == 'Y') { op_init_page($id); if (op_page_option('launch_funnel', 'enabled') == 'Y' && ($launch_info = op_page_option('launch_suite_info'))) { require_once OP_FUNC . 'launch.php'; } $theme = op_page_option('theme'); $file = OP_PAGES . $theme['type'] . '/' . $theme['dir'] . '/template.php'; if (file_exists($file)) { return apply_filters('op_check_page_availability', $file); } } else { op_init_theme(); if ($tpl = get_post_meta($id, '_op_page_template', true)) { if (file_exists(OP_THEME_DIR . $tpl . '.php')) { return OP_THEME_DIR . $tpl . '.php'; } } } } else { op_init_theme(); } } else { op_init_theme(); } } $checks = array('is_404' => '404', 'is_search' => 'search', 'is_front_page' => 'front_page', 'is_home' => 'home', 'is_single' => 'single', 'is_page' => 'page', 'is_category' => 'category', 'is_tag' => 'tag', 'is_author' => 'author', 'is_archive' => 'archive', 'is_paged' => 'paged'); $checks = apply_filters('op_template_include_checks', $checks); foreach ($checks as $check => $type) { if ($check()) { $files = apply_filters('op_template_include-' . $type, array($type)); foreach ($files as $file) { if (file_exists(OP_THEME_DIR . $file . '.php')) { return OP_THEME_DIR . $file . '.php'; } } } } if (defined('OP_THEME_DIR')) { return OP_THEME_DIR . 'index.php'; } else { return OP_DIR . 'index.php'; } }