Documente Academic
Documente Profesional
Documente Cultură
php
/**
* Custom functions that act independently of the theme templates
*
* Eventually, some of the functionality here could be replaced by core features.
*
* @package ThemeGrill
* @subpackage Suffice
* @since Suffice 1.0.0
*/
/**
* Before hook for content loop
*/
function suffice_custom_before_content_loop() {
/**
* Add the row div as required
* 1. If post style is grid
* 2. If in search page and post style is grid
*/
if ( ( ! is_search() && ( 'post-style-grid' ===
suffice_get_option( 'suffice_blog_post_style', 'post-style-classic' ) ) ) ||
( is_search() && ( 'post-style-grid' ===
suffice_get_option( 'suffice_search_result_style', 'post-style-classic' ) ) ) ) {
echo '<div class="row">';
}
}
add_action( 'suffice_before_content_loop', 'suffice_custom_before_content_loop' );
/**
* After hook for content loop
*/
function suffice_custom_after_content_loop() {
/**
* Add the closing row div as required
* 1. If post style is grid
* 2. If in search page and post style is grid
*/
if ( ( ! is_search() && ( 'post-style-grid' ===
suffice_get_option( 'suffice_blog_post_style', 'post-style-classic' ) ) ) ||
( is_search() && ( 'post-style-grid' ===
suffice_get_option( 'suffice_search_result_style', 'post-style-classic' ) ) ) ) {
echo '</div> <!-- .row -->';
}
}
add_action( 'suffice_after_content_loop', 'suffice_custom_after_content_loop' );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function suffice_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="',
esc_url( get_bloginfo( 'pingback_url' ) ), '">';
}
}
add_action( 'wp_head', 'suffice_pingback_header' );
/**
* Adds the breadcrumb
*/
function suffice_add_breadcrumb() {
if ( ( ! is_front_page() ) && ( ! is_page_template( 'page-templates/page-
builder.php' ) ) && ( true == suffice_get_option( 'suffice_show_pagetitle_bar',
true ) ) ) {
// hide on bbpress.
if ( function_exists( 'is_bbpress' ) ) {
if ( ! is_bbpress() ) {
suffice_breadcrumbs();
}
} else {
suffice_breadcrumbs();
}
}
}
add_action( 'suffice_after_header', 'suffice_add_breadcrumb', 5 );
if ( ! function_exists( 'suffice_breadcrumbs' ) ) {
/**
* Shows breadcrumb
*/
function suffice_breadcrumbs() {
if ( ! function_exists( 'suffice_breadcrumbs_trail' ) ) {
/**
* Breadcrumb Trail
*
* @since 1.0.0
*
* @global array $post global post variable
* @global array $wp_query global query variable
*/
function suffice_breadcrumbs_trail() {
if ( function_exists( 'yoast_breadcrumb' ) ) {
yoast_breadcrumb('
<p id="yoast-breadcrumbs">','</p>
');
return false;
}
if ( suffice_is_woocommerce_active() ) {
woocommerce_breadcrumb();
return false;
}
// Settings.
$separator = '>';
$home_title = esc_html__( 'Home', 'suffice' );
// Home page.
echo '<li class="trail-item trail-begin"><a class="trail-home"
href="' . esc_html( get_home_url() ) . '" title="' . esc_attr( $home_title ) .
'"><span>' . esc_attr( $home_title ) . '</span></a></li>';
} elseif ( is_single() ) {
if ( ! empty( $category ) ) {
} else {
echo '<li class="trail-item"><span>' .
esc_html( get_the_title() ) . '</span></li>';
}
} elseif ( is_category() ) {
// Category page.
echo '<li class="trail-item"><span>' . single_cat_title( '',
false ) . '</span></li>';
} elseif ( is_page() ) {
// Standard page.
if ( $post->post_parent ) {
// If child page, get parents.
$anc = get_post_ancestors( $post->ID );
// Current page.
echo '<li class="trail-item"><span>' .
esc_html( get_the_title() ) . '</span></li>';
} else {
// Just display current page if not parents.
echo '<li class="trail-item"><span>' .
esc_html( get_the_title() ) . '</span></li>';
}
} elseif ( is_tag() ) {
// Tag page.
// Get tag information.
$term_id = get_query_var( 'tag_id' );
$taxonomy = 'post_tag';
$args = 'include=' . $term_id;
$terms = get_terms( $taxonomy, $args );
$get_term_id = $terms[0]->term_id;
$get_term_slug = $terms[0]->slug;
$get_term_name = $terms[0]->name;
} elseif ( is_day() ) {
// Day archive.
// Year link.
echo '<li class="trail-item"><a class="item-year" href="' .
esc_url( get_year_link( get_the_time( __( 'Y', 'suffice' ) ) ) ) . '" title="' .
esc_attr( get_the_time( __( 'Y', 'suffice' ) ) ) . '"><span>' .
esc_html( get_the_time( __( 'Y', 'suffice' ) ) ) . '</span></a></li>';
// Month link.
echo '<li class="trail-item"><a class="item-month" href="' .
esc_url( get_month_link( get_the_time( __( 'Y', 'suffice' ) ),
get_the_time( __( 'M', 'suffice' ) ) ) ) . '" title="' .
esc_attr( get_the_time( __( 'M', 'suffice' ) ) ) . '"><span>' .
esc_html( get_the_time( __( 'M', 'suffice' ) ) ) . '</span></a></li>';
// Day display.
echo '<li class="trail-item"><span>' .
esc_html( get_the_time( __( 'jS', 'suffice' ) ) . get_the_time( __( 'M',
'suffice' ) ) ) . '</span></li>';
} elseif ( is_month() ) {
// Month Archive.
// Year link.
echo '<li class="trail-item"><a class="item-year" href="' .
esc_url( get_year_link( get_the_time( __( 'Y', 'suffice' ) ) ) ) . '" title="' .
esc_attr( get_the_time( __( 'Y', 'suffice' ) ) ) . '"><span>' .
esc_html( get_the_time( __( 'Y', 'suffice' ) ) ) . '</span></a></li>';
// Month link.
echo '<li class="trail-item"><span>' .
esc_html( get_the_time( __( 'M', 'suffice' ) ) ) . '</span></li>';
} elseif ( is_year() ) {
} elseif ( is_author() ) {
// Auhor archive.
// Get the author information.
global $author;
$userdata = get_userdata( $author );
} elseif ( is_search() ) {
// Search results page.
echo '<li class="trail-item"><span>' . esc_html__( 'Search
results for: ', 'suffice' ) . esc_html( get_search_query() ) . '</span></li>';
} elseif ( is_404() ) {
// 404 page.
echo '<li class="trail-item"><span>' . esc_html__( '404 Error',
'suffice' ) . '</span></li>';
}
echo '</ul>';
}
}
if ( ! function_exists( 'suffice_page_title' ) ) {
/**
* Title for page
*
* @since 1.0.0
*/
function suffice_page_title() {
if ( is_archive() ) {
$suffice_header_title = get_the_archive_title();
} elseif ( is_404() ) {
$suffice_header_title = esc_html__( 'Page NOT Found',
'suffice' );
} elseif ( is_search() ) {
$suffice_header_title = sprintf( esc_html__( 'Search Results
for: %s', 'suffice' ), esc_html( get_search_query() ) );
} elseif ( is_singular() ) {
$suffice_header_title = get_the_title();
} elseif ( is_home() ) {
$queried_id = get_option( 'page_for_posts' );
$suffice_header_title = get_the_title( $queried_id );
} else {
$suffice_header_title = '';
}
if ( ! function_exists( 'suffice_top_header_left_content' ) ) {
/**
* Header top left content
*
* Displays content in left section of Top Header.
*
* @since 1.0.0
*/
function suffice_top_header_left_content() {
$header_top_left_content =
suffice_get_option( 'suffice_header_content_left', 'contact-info' );
if ( ! function_exists( 'suffice_top_header_right_content' ) ) {
/**
* Header top right content
*
* Displays content in right section of Top Header.
*
* @since 1.0.0
*/
function suffice_top_header_right_content() {
$header_top_right_content =
suffice_get_option( 'suffice_header_content_right', 'social-icon' );
/**
* Displays the footer copyright text information
*/
function suffice_footer_copyright_text() {
$site_link = '<a href="' . esc_url( home_url( '/' ) ) . '" title="' .
esc_attr( get_bloginfo( 'name', 'display' ) ) . '" ><span>' . get_bloginfo( 'name',
'display' ) . '</span></a>';
$tg_link = '<a
href="'.esc_url( 'https://themegrill.com/themes/suffice' ).'" target="_blank"
title="'.esc_attr__( 'ThemeGrill', 'suffice' ).'"
rel="author"><span>'.__( 'ThemeGrill', 'suffice') .'</span></a>';
if ( ! function_exists( 'suffice_excerpt_length' ) ) {
/**
* Change the excerpt length
*/
function suffice_excerpt_length( $length ) {
return 40;
}
}
add_filter( 'excerpt_length', 'suffice_excerpt_length' );
if ( ! function_exists( 'suffice_continue_reading' ) ) {
/**
* Returns a "Continue Reading" link for excerpts
*/
function suffice_continue_reading() {
return '';
}
}
add_filter( 'excerpt_more', 'suffice_continue_reading' );
// SiteOrigin Pagebuilder
array(
'name' => 'SiteOrigin Pagebuilder',
'slug' => 'siteorigin-panels',
'required' => false,
),
// Suffice Toolkit
array(
'name' => 'Suffice Toolkit', // The plugin name.
'slug' => 'suffice-toolkit', // The plugin slug
(typically the folder name).
'required' => false,
),
);
/*
* Array of configuration settings. Amend each line as needed.
*
* TGMPA will start providing localized text strings soon. If you already
have translations of our standard
* strings available, please help us make TGMPA even better by giving us
access to these translations or by
* sending in a pull-request with .po file(s) with the translations.
*
* Only uncomment the strings in the config array if you want to customize
the strings.
*/
$config = array(
'id' => 'suffice', // Unique ID for hashing
notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to
bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'has_notices' => true, // Show admin notices or
not.
'dismissable' => true, // If false, a user cannot
dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is
false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate
plugins after installation or not.
'message' => '', // Message to output right
before the plugins table.
);
/**
* Compare user's current version of plugin.
*/
if ( ! function_exists( 'suffice_plugin_version_compare' ) ) {
function suffice_plugin_version_compare( $plugin_slug, $version_to_compare )
{
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$installed_plugins = get_plugins();