Blog Posts" widget used in an area before it
locate_template( $templates, true, false );
endif;
}
endif;
/**
* A function for loading a custom widget template. This works similar to the WordPress `get_*()` template functions.
* It's purpose is for loading a widget display template. This function looks for widget templates within the
* `widget` sub-folder or the root theme folder.
*
* @since 1.0.0
* @access public
* @param string $name
* @return void
*/
function hybridextend_get_widget( $name = '' ) {
include( hybridextend_locate_widget( $name ) );
}
/**
* A function for locating a custom widget template. This works similar to the WordPress `get_*()` template functions.
* It's purpose is for loading a widget display template. This function looks for widget templates within the
* `widget` sub-folder or the root theme folder.
*
* @since 1.0.0
* @access public
* @param string $name
* @return void
*/
if ( !function_exists( 'hybridextend_locate_widget' ) ) :
function hybridextend_locate_widget( $name = '' ) {
$templates = array();
if ( '' !== $name ) {
$templates[] = "widget-{$name}.php";
$templates[] = "widget/{$name}.php";
$templates[] = "template-parts/widget-{$name}.php";
}
$templates[] = 'widget.php';
$templates[] = 'widget/widget.php';
$templates[] = 'template-parts/widget.php';
$templates = apply_filters( 'hybridextend_widget_template_hierarchy', $templates, $name );
return locate_template( $templates, false );
}
endif;
/**
* This function is an extension of 'get_template_part' in a way that it allows $load option to
* be passed to 'locate_template' (something that WordPress doesnt support currently)
*
* @link https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/general-template.php#L134
*
* @since 2.2.2
* @access public
* @param string $slug The slug name for the generic template.
* @param string $name The name of the specialised template.
* @param bool $load If true the template file will be loaded if it is found.
* @return void
*/
if ( !function_exists( 'hybridextend_get_template_part' ) ) :
function hybridextend_get_template_part( $slug, $name = null, $load = true ) {
do_action( "get_template_part_{$slug}", $slug, $name );
$templates = array();
$name = (string) $name;
if ( '' !== $name ) {
$templates[] = "{$slug}-{$name}.php";
$templates[] = "template-parts/{$slug}-{$name}.php";
}
$templates[] = "{$slug}.php";
$templates[] = "template-parts/{$slug}.php";
$templates = apply_filters( 'hybridextend_get_template_hierarchy', $slug, $name );
/* Load / Return the template */
if ( $load )
locate_template( $templates, true, false );
else
return locate_template( $templates );
}
endif;
/* == template-general == */
/**
* Displays a link to theme on WordPress.org.
*
* @since 1.1.4
* @access public
* @param string $link
* @param string $anchor
* @return void
*/
function hybridextend_wp_theme_link( $link = '', $anchor = '' ) {
echo hybridextend_get_wp_theme_link( $link, $anchor );
}
/**
* Returns a link to theme on WordPress.org.
*
* @since 1.1.4
* @access public
* @param string $link
* @param string $anchor
* @return string
*/
function hybridextend_get_wp_theme_link( $link = '', $anchor = '' ) {
/* Get Theme */
global $hybridextend_theme;
$name = $hybridextend_theme->display( 'Name', false, true );
$slug = preg_replace( "/[\s-]+/", " ", strtolower( hybridextend_trim( $name ) ) );
$slug = str_replace( " ", "-", $slug );
$link = ( empty( $link ) ) ? 'https://wordpress.org/themes/' . $slug : $link;
$anchor = ( empty( $anchor ) ) ? $name : $anchor;
$title = sprintf( __( '%s WordPress Theme', 'hybrid-core' ), $name );
return sprintf( '%s', esc_url( $link ), esc_attr( $title ), esc_html( $anchor ) );
}
/**
* Returns a link to the theme URI.
*
* @since 1.0.0
* @access public
* @param string $link
* @param string $anchor
* @return string
*/
function hybridextend_get_theme_link( $link = '', $anchor = '' ) {
/* Get Theme */
global $hybridextend_theme;
$name = ( is_child_theme() && is_object( $hybridextend_theme->parent() ) ) ? $hybridextend_theme->parent()->get( 'Name' ) : $hybridextend_theme->get( 'Name' );
$link = ( empty( $link ) ) ? ( ( is_child_theme() && is_object( $hybridextend_theme->parent() ) ) ? $hybridextend_theme->parent()->get( 'ThemeURI' ) : $hybridextend_theme->get( 'ThemeURI' ) ) : $link;
$anchor = ( empty( $anchor ) ) ? $name : $anchor;
$title = sprintf( __( '%s WordPress Theme', 'hybrid-core' ), $name );
return sprintf( '%s', esc_url( $link ), esc_attr( $title ), esc_html( $anchor ) );
}
/**
* Filter the WordPress archive title after Hybrid has worked its magic
*
* @deprecated since 2.9.0 -> modified hybrid core function
*
* @since 2.1.5
* @access public
* @param string $title
* @return string
*/
function hybridextend_loop_title( $title ) {
$title_suffix = '';
/* If the current page is a paged page. */
if ( ( ( $page = get_query_var( 'paged' ) ) || ( $page = get_query_var( 'page' ) ) ) && $page > 1 ) {
$paged = number_format_i18n( absint( $page ) );
$title_suffix = ' ' . sprintf( __( '(Page %s)', 'hybrid-core' ), $paged ) . '';
$title_suffix = apply_filters( 'hybridextend_title_suffix', $title_suffix, $paged );
}
return $title . $title_suffix;
}
// add_filter( 'hybrid_archive_title', 'hybridextend_loop_title', 1, 3 );