/** * Get template part (for templates like the shop-loop). * * @access public * @param mixed $slug * @param string $name (default: '') * @since 1.0.0 */ function documentate_get_template_part($slug, $name = '') { $template_path = documentate_get_template_path(); $template = ''; // Look in yourtheme/slug-name.php and yourtheme/documentate/slug-name.php if ($name && !DOCUMENTATE_TEMPLATE_DEBUG_MODE) { $template = locate_template(array("{$slug}-{$name}.php", $template_path . "{$slug}-{$name}.php")); } // Get default slug-name.php if (!$template && $name && file_exists(Docu()->plugin_path() . "/templates/{$slug}-{$name}.php")) { $template = Docu()->plugin_path() . "/templates/{$slug}-{$name}.php"; } // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/documentate/slug.php if (!$template && !DOCUMENTATE_TEMPLATE_DEBUG_MODE) { $template = locate_template(array("{$slug}.php", $template_path . "{$slug}.php")); } // Allow 3rd party plugin filter template file from their plugin if (!$template && DOCUMENTATE_TEMPLATE_DEBUG_MODE || $template) { $template = apply_filters('documentate_get_template_part', $template, $slug, $name); } if ($template) { load_template($template, false); } }
/** * Locate a template and return the path for inclusion. * * This is the load order: * * yourtheme / $template_path / $template_name * yourtheme / $template_name * $default_path / $template_name * * @access public * @param string $template_name * @param string $template_path (default: '') * @param string $default_path (default: '') * @return string */ function documentate_locate_template($template_name, $template_path = '', $default_path = '') { if (!$template_path) { $template_path = documentate_get_template_path(); } if (!$default_path) { $default_path = Docu()->plugin_path() . '/templates/'; } // Look within passed path within the theme - this is priority $template = locate_template(array(trailingslashit($template_path) . $template_name, $template_name)); // Get default template if (!$template || DOCUMENTATE_TEMPLATE_DEBUG_MODE) { $template = $default_path . $template_name; } // Return what we found return apply_filters('documentate_locate_template', $template, $template_name, $template_path); }