/** * locate_template * * locate a template file by looking in the following places, in the following order: * <assumed full absolute server path> * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ * <server path up to>/wp-content/uploads/espresso/templates/ * <server path up to>/wp-content/plugins/<EE4 folder>/templates/<current EE theme>/ * <server path up to>/wp-content/plugins/<EE4 folder>/<relative path> * as soon as the template is found in one of these locations, it will be returned or loaded * * @param array|string $templates array of template file names including extension (or just a single string) * @param array $template_args an array of arguments to be extracted for use in the template * @param boolean $load whether to pass the located template path on to the EEH_Template::display_template() method or simply return it * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will generate a custom template or not. * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. * @return mixed */ public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { // first use WP locate_template to check for template in the current theme folder $template_path = locate_template($templates); if ($check_if_custom && !empty($template_path)) { return TRUE; } // not in the theme if (empty($template_path)) { // not even a template to look for ? if (empty($templates)) { // get post_type $post_type = EE_Registry::instance()->REQ->get('post_type'); // get array of EE Custom Post Types $EE_CPTs = EE_Register_CPTs::get_CPTs(); // build template name based on request if (isset($EE_CPTs[$post_type])) { $archive_or_single = is_archive() ? 'archive' : ''; $archive_or_single = is_single() ? 'single' : $archive_or_single; $templates = $archive_or_single . '-' . $post_type . '.php'; } } // currently active EE template theme $current_theme = EE_Config::get_current_theme(); // array of paths to folders that may contain templates $template_folder_paths = array(EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, EVENT_ESPRESSO_TEMPLATE_DIR); //add core plugin folders for checking only if we're not $check_if_custom if (!$check_if_custom) { $core_paths = array(EE_PUBLIC . $current_theme, EE_TEMPLATES . $current_theme, EE_PLUGIN_DIR_PATH); $template_folder_paths = array_merge($template_folder_paths, $core_paths); } // now filter that array $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); // array to hold all possible template paths $full_template_paths = array(); // loop through $templates foreach ((array) $templates as $template) { // while looping through all template folder paths foreach ((array) $template_folder_paths as $template_folder_path) { // build up our template locations array by combining our template folder paths with our templates $full_template_paths[] = rtrim($template_folder_path, DS) . DS . $template; } // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first array_unshift($full_template_paths, $template); } // filter final array of full template paths $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths); // now loop through our final array of template location paths and check each location foreach ((array) $full_template_paths as $full_template_path) { if (is_readable($full_template_path)) { $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); break; } } } // if we got it and you want to see it... if ($template_path && $load && !$check_if_custom) { if ($return_string) { return EEH_Template::display_template($template_path, $template_args, TRUE); } else { EEH_Template::display_template($template_path, $template_args, FALSE); } } return $check_if_custom && !empty($template_path) ? TRUE : $template_path; }
/** * event_list_template_filters * * @access public * @return void */ public function event_list_template_filters() { $args = array('form_url' => get_post_type_archive_link('espresso_events'), 'elf_month' => EED_Events_Archive_Filters::_display_month(), 'elf_category' => EED_Events_Archive_Filters::_event_category_slug(), 'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(), 'elf_type' => self::$_type); EEH_Template::display_template(EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-filters.php', $args); }
/** * locate_template * * locate a template file by looking in the following places, in the following order: * <server path up to>/wp-content/themes/<current active WordPress theme>/ * <assumed full absolute server path> * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ * <server path up to>/wp-content/uploads/espresso/templates/ * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ * <server path up to>/wp-content/plugins/<EE4 folder>/ * as soon as the template is found in one of these locations, it will be returned or loaded * * Example: * You are using the WordPress Twenty Sixteen theme, * and you want to customize the "some-event.template.php" template, * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. * Assuming WP is installed on your server in the "/home/public_html/" folder, * EEH_Template::locate_template() will look at the following paths in order until the template is found: * * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php * /relative/path/to/some-event.template.php * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php * * Had you passed an absolute path to your template that was in some other location, * ie: "/absolute/path/to/some-event.template.php" * then the search would have been : * * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php * /absolute/path/to/some-event.template.php * * and stopped there upon finding it in the second location * * @param array|string $templates array of template file names including extension (or just a single string) * @param array $template_args an array of arguments to be extracted for use in the template * @param boolean $load whether to pass the located template path on to the EEH_Template::display_template() method or simply return it * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will generate a custom template or not. * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. * @return mixed */ public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { // first use WP locate_template to check for template in the current theme folder $template_path = locate_template($templates); if ($check_if_custom && !empty($template_path)) { return TRUE; } // not in the theme if (empty($template_path)) { // not even a template to look for ? if (empty($templates)) { // get post_type $post_type = EE_Registry::instance()->REQ->get('post_type'); // get array of EE Custom Post Types $EE_CPTs = EE_Register_CPTs::get_CPTs(); // build template name based on request if (isset($EE_CPTs[$post_type])) { $archive_or_single = is_archive() ? 'archive' : ''; $archive_or_single = is_single() ? 'single' : $archive_or_single; $templates = $archive_or_single . '-' . $post_type . '.php'; } } // currently active EE template theme $current_theme = EE_Config::get_current_theme(); // array of paths to folders that may contain templates $template_folder_paths = array(EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, EVENT_ESPRESSO_TEMPLATE_DIR); //add core plugin folders for checking only if we're not $check_if_custom if (!$check_if_custom) { $core_paths = array(EE_PUBLIC . $current_theme, EE_TEMPLATES . $current_theme, EE_PLUGIN_DIR_PATH); $template_folder_paths = array_merge($template_folder_paths, $core_paths); } // now filter that array $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); $templates = is_array($templates) ? $templates : array($templates); $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); // array to hold all possible template paths $full_template_paths = array(); EE_Registry::instance()->load_helper('File'); // loop through $templates foreach ($templates as $template) { // normalize directory separators $template = EEH_File::standardise_directory_separators($template); $file_name = basename($template); $template_path_minus_file_name = substr($template, 0, strlen($file_name) * -1); // while looping through all template folder paths foreach ($template_folder_paths as $template_folder_path) { // normalize directory separators $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); // determine if any common base path exists between the two paths $common_base_path = EEH_Template::_find_common_base_path(array($template_folder_path, $template_path_minus_file_name)); if ($common_base_path !== '') { // both paths have a common base, so just tack the filename onto our search path $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; } else { // no common base path, so let's just concatenate $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; } // build up our template locations array by adding our resolved paths $full_template_paths[] = $resolved_path; } // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first array_unshift($full_template_paths, $template); // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); } // filter final array of full template paths $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); // now loop through our final array of template location paths and check each location foreach ((array) $full_template_paths as $full_template_path) { if (is_readable($full_template_path)) { $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); break; } } } // if we got it and you want to see it... if ($template_path && $load && !$check_if_custom) { if ($return_string) { return EEH_Template::display_template($template_path, $template_args, TRUE); } else { EEH_Template::display_template($template_path, $template_args, FALSE); } } return $check_if_custom && !empty($template_path) ? TRUE : $template_path; }
/** * wp_enqueue_scripts * * @access public * @return void */ public function wp_enqueue_scripts() { // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); if (apply_filters('FHEE_load_css', TRUE)) { $this->Registry->CFG->template_settings->enable_default_style = TRUE; //Load the ThemeRoller styles if enabled if (isset($this->Registry->CFG->template_settings->enable_default_style) && $this->Registry->CFG->template_settings->enable_default_style) { //Load custom style sheet if available if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION); wp_enqueue_style('espresso_custom_css'); } if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')) { wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); } else { wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); } wp_enqueue_style('espresso_default'); if (is_readable(get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css')) { wp_register_style('espresso_style', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', array('dashicons', 'espresso_default')); } else { wp_register_style('espresso_style', EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', array('dashicons', 'espresso_default')); } } } // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); if (apply_filters('FHEE_load_js', TRUE)) { wp_enqueue_script('jquery'); //let's make sure that all required scripts have been setup if (function_exists('wp_script_is') && !wp_script_is('jquery')) { $msg = sprintf(__('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso'), '<em><br />', '</em>'); EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); } // load core js wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); wp_enqueue_script('espresso_core'); wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); } //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); if (apply_filters('FHEE_load_qtip', FALSE)) { EEH_Qtip_Loader::instance()->register_and_enqueue(); } //accounting.js library // @link http://josscrowcroft.github.io/accounting.js/ if (apply_filters('FHEE_load_accounting_js', FALSE)) { $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE); wp_enqueue_script('ee-accounting'); $currency_config = array('currency' => array('symbol' => $this->Registry->CFG->currency->sign, 'format' => array('pos' => $this->Registry->CFG->currency->sign_b4 ? '%s%v' : '%v%s', 'neg' => $this->Registry->CFG->currency->sign_b4 ? '- %s%v' : '- %v%s', 'zero' => $this->Registry->CFG->currency->sign_b4 ? '%s--' : '--%s'), 'decimal' => $this->Registry->CFG->currency->dec_mrk, 'thousand' => $this->Registry->CFG->currency->thsnds, 'precision' => $this->Registry->CFG->currency->dec_plc), 'number' => array('precision' => 0, 'thousand' => $this->Registry->CFG->currency->thsnds, 'decimal' => $this->Registry->CFG->currency->dec_mrk)); wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); } if (!function_exists('wp_head')) { $msg = sprintf(__('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), '<em><br />', '</em>'); EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); } if (!function_exists('wp_footer')) { $msg = sprintf(__('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), '<em><br />', '</em>'); EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); } }
/** * class constructor - can ONLY be instantiated by EE_Front_Controller * * @override default exception handling * @access public * @return \EED_Module */ public final function __construct() { $this->theme = EE_Config::get_current_theme(); $module_name = $this->module_name(); EE_Registry::instance()->modules->{$module_name} = $this; }