1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function epl_load_core_templates( $template ) {
global $epl_settings;
$template_path = epl_get_content_path();
if ( isset( $epl_settings['epl_feeling_lucky'] ) && 'on' === $epl_settings['epl_feeling_lucky'] ) {
return $template;
}
$post_tpl = '';
if ( is_epl_post_single() ) {
$common_tpl = apply_filters( 'epl_common_single_template', 'single-listing.php' );
$post_tpl = 'single-' . str_replace( '_', '-', get_post_type() ) . '.php';
$find[] = $post_tpl;
$find[] = epl_template_path() . $post_tpl;
$find[] = $common_tpl;
$find[] = epl_template_path() . $common_tpl;
} elseif ( epl_is_search() ) {
$common_tpl = apply_filters( 'epl_common_search_template', 'archive-listing.php' );
$post_tpl = 'archive-listing.php';
if ( isset( $_GET['post_type'] ) ) {
if ( is_array( $_GET['post_type'] ) ) {
$post_tpl = 'search-listing.php';
} else {
$post_tpl = 'search-' . sanitize_title( wp_unslash( $_GET['post_type'] ) ) . '.php';
}
}
$find[] = $post_tpl;
$find[] = epl_template_path() . $post_tpl;
$find[] = 'search-listing.php';
$find[] = epl_template_path() . 'search-listing.php';
$find[] = $common_tpl;
$find[] = epl_template_path() . $common_tpl;
$find = array_unique( $find );
} elseif ( is_epl_post_archive() ) {
$common_tpl = apply_filters( 'epl_common_archive_template', 'archive-listing.php' );
$post_tpl = 'archive-' . str_replace( '_', '-', get_post_type() ) . '.php';
$find[] = $post_tpl;
$find[] = epl_template_path() . $post_tpl;
$find[] = $common_tpl;
$find[] = epl_template_path() . $common_tpl;
} elseif ( is_tax( 'location' ) || is_tax( 'tax_feature' ) || is_tax( 'tax_business_listing' ) ) {
$term = get_queried_object();
$common_tpl = apply_filters( 'epl_common_taxonomy_template', 'archive-listing.php' );
$post_tpl = 'taxonomy-' . $term->taxonomy . '.php';
$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = epl_template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = 'taxonomy-' . $term->taxonomy . '.php';
$find[] = epl_template_path() . 'taxonomy-' . $term->taxonomy . '.php';
$find[] = $common_tpl;
$find[] = $post_tpl;
$find[] = epl_template_path() . $common_tpl;
}
if ( $post_tpl ) {
$template = locate_template( array_unique( $find ) );
if ( ! $template ) {
$template = $template_path . $common_tpl;
if ( ! file_exists( $template ) ) {
$template = EPL_PATH_TEMPLATES_CONTENT . $common_tpl;
}
}
}
return $template;
}
add_filter( 'template_include', 'epl_load_core_templates' );
function epl_render_single_post() {
if ( epl_is_builder_framework_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES_ITHEMES;
} elseif ( epl_is_genesis_framework_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES_GENESIS;
} elseif ( epl_is_divi_framework_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES . 'divi/';
} elseif ( epl_is_twenty_twenty_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES . 'twentytwenty/';
} elseif ( epl_is_avada_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES . 'avada/';
} elseif ( file_exists( EPL_PATH_TEMPLATES_POST_TYPES . epl_get_active_theme() ) ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES . trailingslashit( epl_get_active_theme() );
} else {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES_DEFAULT;
}
$common_tpl = 'single-listing.php';
$template = $template_path . $common_tpl;
include $template;
}
add_action( 'epl_render_single_post', 'epl_render_single_post' );
function epl_render_archive_post() {
if ( epl_is_builder_framework_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES_ITHEMES;
} elseif ( epl_is_genesis_framework_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES_GENESIS;
} elseif ( epl_is_divi_framework_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES . 'divi/';
} elseif ( epl_is_twenty_twenty_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES . 'twentytwenty/';
} elseif ( epl_is_avada_theme() ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES . 'avada/';
} elseif ( file_exists( EPL_PATH_TEMPLATES_POST_TYPES . epl_get_active_theme() ) ) {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES . trailingslashit( epl_get_active_theme() );
} else {
$template_path = EPL_PATH_TEMPLATES_POST_TYPES_DEFAULT;
}
$common_tpl = 'archive-listing.php';
$template = $template_path . $common_tpl;
include $template;
}
add_action( 'epl_render_archive_post', 'epl_render_archive_post' );
function epl_active_theme_name_twentysixteen( $class ) {
if ( epl_get_active_theme() === 'twentysixteen' && ! is_single() ) {
$class = $class . ' content-area';
}
return $class;
}
add_filter( 'epl_active_theme_name', 'epl_active_theme_name_twentysixteen' );