Media recommended images sizes notice
add_action( 'admin_init', 'receptar_image_size_notice' );
//Website sections
//DOCTYPE
add_action( 'wmhook_html_before', 'receptar_doctype', 10 );
//HEAD
add_action( 'wp_head', 'receptar_head', 1 );
//Body
add_action( 'wmhook_body_top', 'receptar_site_top', 10 );
add_action( 'wmhook_body_bottom', 'receptar_site_bottom', 100 );
//Header
add_action( 'wmhook_header_top', 'receptar_header_top', 10 );
add_action( 'wmhook_header', 'receptar_logo', 10, 0 );
add_action( 'wmhook_header', 'get_sidebar', 20 );
add_action( 'wmhook_header', 'receptar_header_widgets', 30 );
add_action( 'wmhook_header_bottom', 'receptar_header_bottom', 10 );
add_action( 'wmhook_secondary_content_top', 'receptar_logo', 10, 0 );
add_action( 'wmhook_secondary_controls_bottom', 'receptar_post_nav', 10 );
add_action( 'wmhook_secondary_controls_bottom', 'receptar_menu_social', 20 );
//Content
add_action( 'wmhook_content_top', 'receptar_content_top', 10 );
add_action( 'wmhook_entry_top', 'receptar_entry_top', 10 );
add_action( 'wmhook_entry_top', 'receptar_post_title', 20 );
add_action( 'wmhook_entry_top', 'receptar_breadcrumbs', 30 );
add_action( 'wmhook_entry_bottom', 'receptar_entry_bottom', 10 );
add_action( 'wmhook_comments_before', 'receptar_comments_before', 10 );
add_action( 'wmhook_comments_after', 'receptar_comments_after', 10 );
add_action( 'wmhook_content_bottom', 'receptar_content_bottom', 100 );
add_action( 'wmhook_postslist_before', 'receptar_breadcrumbs', 10 );
add_action( 'wmhook_postslist_before', 'receptar_breadcrumbs_off', 20 );
//Footer
add_action( 'wmhook_footer_top', 'receptar_footer_top', 100 );
add_action( 'wmhook_footer', 'receptar_footer', 100 );
add_action( 'wmhook_footer_bottom', 'receptar_footer_bottom', 100 );
/**
* Filters
*/
//Disable TGMPA - not needed
add_filter( 'wmhook_enable_plugins_integration', '__return_false' );
//Set up image sizes
add_filter( 'wmhook_receptar_setup_image_sizes', 'receptar_image_sizes' );
//Set required Google Fonts
add_filter( 'wmhook_receptar_google_fonts_url_fonts_setup', 'receptar_google_fonts' );
//BODY classes
add_filter( 'body_class', 'receptar_body_classes', 98 );
//Post classes
add_filter( 'post_class', 'receptar_post_classes', 98 );
//Navigation improvements
add_filter( 'walker_nav_menu_start_el', 'receptar_nav_item_process', 10, 4 );
//Excerpt modifications
add_filter( 'the_excerpt', 'receptar_remove_shortcodes', 10 );
add_filter( 'the_excerpt', 'receptar_excerpt', 20 );
add_filter( 'excerpt_length', 'receptar_excerpt_length', 10 );
add_filter( 'excerpt_more', 'receptar_excerpt_more', 10 );
add_filter( 'wmhook_receptar_excerpt_continue_reading', 'receptar_excerpt_continue_reading', 10 );
//Post thumbnail
add_filter( 'wmhook_entry_featured_image_size', 'receptar_post_thumbnail_size' );
add_filter( 'wmhook_entry_featured_image_fallback_url', 'receptar_entry_featured_image_fallback_url' );
//Comments form
add_filter( 'comment_form_default_fields', 'receptar_comments_form_placeholders' );
add_filter( 'comment_form_field_comment', 'receptar_comments_form_placeholders' );
/**
* 20) Global variables
*/
/**
* Max content width
*
* Required here, because we don't set it up in functions.php.
* The $content_width is calculated as golden ratio of the site container width.
*/
if ( ! isset( $content_width ) || ! $content_width ) {
global $content_width;
$content_width = 960;
}
/**
* 30) Theme setup
*/
/**
* Theme setup
*
* @since 1.0.0
* @version 1.6.0
*/
if ( ! function_exists( 'receptar_setup' ) ) {
function receptar_setup() {
//Helper variables
$image_sizes = array_filter( apply_filters( 'wmhook_receptar_setup_image_sizes', array() ) );
//WordPress visual editor CSS stylesheets
$version = esc_attr( trim( wp_get_theme()->get( 'Version' ) ) );
$visual_editor_css = array_filter( (array) apply_filters( 'wmhook_receptar_setup_visual_editor_css', array(
str_replace( ',', '%2C', receptar_google_fonts_url() ),
esc_url( add_query_arg( array( 'ver' => $version ), receptar_get_stylesheet_directory_uri( 'assets/fonts/genericons-neue/genericons-neue.css' ) ) ),
esc_url( add_query_arg( array( 'ver' => $version ), receptar_get_stylesheet_directory_uri( 'assets/css/starter.css' ) ) ),
esc_url( add_query_arg( array( 'ver' => $version ), receptar_get_stylesheet_directory_uri( 'assets/css/colors.css' ) ) ),
esc_url( add_query_arg( array( 'ver' => $version ), receptar_get_stylesheet_directory_uri( 'assets/css/editor-style.css' ) ) ),
) ) );
/**
* Localization
*
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
*/
//wp-content/languages/theme-name/it_IT.mo
load_theme_textdomain( 'receptar', trailingslashit( WP_LANG_DIR ) . 'themes/' . WM_THEME_SHORTNAME );
//wp-content/themes/child-theme-name/languages/it_IT.mo
load_theme_textdomain( 'receptar', get_stylesheet_directory() . '/languages' );
//wp-content/themes/theme-name/languages/it_IT.mo
load_theme_textdomain( 'receptar', get_template_directory() . '/languages' );
//Title tag
add_theme_support( 'title-tag' );
// Site logo
/**
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo' );
//Visual editor styles
add_editor_style( $visual_editor_css );
//Feed links
add_theme_support( 'automatic-feed-links' );
//Enable HTML5 markup
add_theme_support( 'html5', array(
'comment-list',
'comment-form',
'search-form',
'gallery',
'caption',
) );
//Custom menus
register_nav_menus( apply_filters( 'wmhook_receptar_setup_menus', array(
'primary' => esc_html__( 'Primary Menu', 'receptar' ),
'social' => esc_html__( 'Social Links Menu', 'receptar' ),
) ) );
//Custom header
add_theme_support( 'custom-header', apply_filters( 'wmhook_receptar_setup_custom_background_args', array(
'default-image' => receptar_get_stylesheet_directory_uri( 'assets/images/header.jpg' ),
'header-text' => false,
'width' => 1920,
'height' => 640, //Approx. 62% of desktop viewport height (16:9)
'flex-height' => false,
'flex-width' => true,
) ) );
//Custom background
add_theme_support( 'custom-background', apply_filters( 'wmhook_receptar_setup_custom_background_args', array(
'default-color' => 'f5f7f9',
) ) );
//Post types supports
add_post_type_support( 'attachment', 'custom-fields' );
//Thumbnails support
add_post_type_support( 'attachment:audio', 'thumbnail' );
add_post_type_support( 'attachment:video', 'thumbnail' );
add_theme_support( 'post-thumbnails', array( 'attachment:audio', 'attachment:video' ) );
add_theme_support( 'post-thumbnails' );
//Image sizes (x, y, crop)
if ( ! empty( $image_sizes ) ) {
foreach ( $image_sizes as $size => $setup ) {
if ( ! in_array( $size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
add_image_size(
$size,
$image_sizes[ $size ][0],
$image_sizes[ $size ][1],
$image_sizes[ $size ][2]
);
}
} // /foreach
}
}
} // /receptar_setup
/**
* Setup images
*/
/**
* Image sizes
*
* @example
*
* $image_sizes = array(
* 'image_size_id' => array(
* absint( width ),
* absint( height ),
* (bool) cropped?,
* (string) optional_theme_usage_explanation_text
* )
* );
*
* @since 1.0
* @version 1.3
*
* @param array $image_sizes
*/
if ( ! function_exists( 'receptar_image_sizes' ) ) {
function receptar_image_sizes( $image_sizes ) {
//Helper variables
global $content_width;
//Preparing output
/**
* image_size = array(
* width,
* height,
* cropped?,
* theme_usage //Optional
* )
*/
$image_sizes = array(
'thumbnail' => array(
480,
640,
true,
esc_html__( 'In posts list.', 'receptar' )
),
'medium' => array(
absint( $content_width * .62 ),
9999,
false
),
'large' => array(
absint( $content_width ),
9999,
false,
esc_html__( 'In single post page.', 'receptar' )
),
'receptar-banner' => array(
1920,
640, //Approx. 62% of desktop viewport height (16:9)
true,
esc_html__( 'In front (and blog) page banner.', 'receptar' )
),
'receptar-featured' => array(
absint( $content_width ),
absint( $content_width / 3 * 2 ),
true,
esc_html__( 'In single post page on mobile devices only.', 'receptar' )
),
);
//Output
return $image_sizes;
}
} // /receptar_image_sizes
/**
* Reset predefined image sizes to their original values
*
* @since 1.3.1
* @version 1.3.1
*/
if ( ! function_exists( 'receptar_image_sizes_reset' ) ) {
function receptar_image_sizes_reset() {
// Helper variables
$image_sizes = array( 'thumbnail', 'medium', 'large' );
$theme_old = get_option( 'theme_switched' );
$theme_mods = get_option( 'theme_mods_' . $theme_old );
$update_theme_mods = false;
// Processing
foreach ( $image_sizes as $size ) {
$values = (array) ( isset( $theme_mods[ '__image_size_' . $size ] ) ) ? ( $theme_mods[ '__image_size_' . $size ] ) : ( array() );
// Skip processing if we do not have the image height and crop value
if ( ! isset( $values[1] ) || ! isset( $values[2] ) ) {
continue;
}
// Old image width
if ( $values[0] ) {
update_option( $size . '_size_w', $values[0] );
}
// Old image height
if ( $values[1] ) {
update_option( $size . '_size_h', $values[1] );
}
// Old image crop
if ( $values[2] ) {
update_option( $size . '_crop', $values[2] );
}
// Remove the image settings from theme mods for future reset
unset( $theme_mods[ '__image_size_' . $size ] );
$update_theme_mods = true;
} // /foreach
if ( $update_theme_mods ) {
update_option( 'theme_mods_' . $theme_old, $theme_mods );
}
}
} // /receptar_image_sizes_reset
/**
* Register recommended image sizes notice
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_image_size_notice' ) ) {
function receptar_image_size_notice() {
add_settings_field(
//$id
'recommended-image-sizes',
//$title
'',
//$callback
'receptar_image_size_notice_html',
//$page
'media',
//$section
'default',
//$args
array()
);
register_setting(
//$option_group
'media',
//$option_name
'recommended-image-sizes',
//$sanitize_callback
'esc_attr'
);
}
} // /receptar_image_size_notice
/**
* Display recommended image sizes notice
*
* @since 1.0
* @version 1.3
*/
if ( ! function_exists( 'receptar_image_size_notice_html' ) ) {
function receptar_image_size_notice_html() {
//Helper variables
$default_image_size_names = array(
'thumbnail' => esc_html_x( 'Thumbnail size', 'WordPress predefined image size name.', 'receptar' ),
'medium' => esc_html_x( 'Medium size', 'WordPress predefined image size name.', 'receptar' ),
'large' => esc_html_x( 'Large size', 'WordPress predefined image size name.', 'receptar' ),
);
$image_sizes = array_filter( apply_filters( 'wmhook_receptar_setup_image_sizes', array() ) );
//Requirements check
if ( empty( $image_sizes ) ) {
return;
}
//Output
echo '';
echo '
';
do_action( 'wmhook_receptar_image_size_notice_html_top' );
echo '
' . esc_html__( 'Recommended image sizes', 'receptar' ) . '
'
. '
' . esc_html__( 'For the theme to work correctly, please, set these recommended image sizes:', 'receptar' ) . '
';
echo '
';
echo ''
. ''
. '' . esc_html__( 'Size name', 'receptar' ) . ' | '
. '' . esc_html__( 'Size parameters', 'receptar' ) . ' | '
. '' . esc_html__( 'Theme usage', 'receptar' ) . ' | '
. '
'
. '';
echo '';
foreach ( $image_sizes as $size => $setup ) {
$crop = ( $setup[2] ) ? ( esc_html__( 'cropped', 'receptar' ) ) : ( esc_html__( 'scaled', 'receptar' ) );
if ( isset( $default_image_size_names[ $size ] ) ) {
echo '' . esc_html( $default_image_size_names[ $size ] ) . ': | ';
} else {
echo '
---|
' . esc_html( $size ) . ' : | ';
}
echo '' . sprintf(
esc_html_x( '%1$d × %2$d, %3$s', '1: image width, 2: image height, 3: cropped or scaled?', 'receptar' ),
absint( $setup[0] ),
absint( $setup[1] ),
$crop
) . ' | '
. '' . ( ( isset( $setup[3] ) ) ? ( $setup[3] ) : ( '—' ) ) . ' | '
. '
';
} // /foreach
echo '';
echo '
';
do_action( 'wmhook_receptar_image_size_notice_html_bottom' );
echo '
';
}
} // /receptar_image_size_notice_html
/**
* Setup typography
*/
/**
* Google Fonts
*
* @since 1.0
* @version 1.0
*
* @param array $fonts_setup
*/
if ( ! function_exists( 'receptar_google_fonts' ) ) {
function receptar_google_fonts( $fonts_setup ) {
return array( 'Roboto', 'Roboto Condensed:400,300', 'Alegreya:400,700' );
}
} // /receptar_google_fonts
/**
* 40) Assets and design
*/
/**
* Registering theme styles and scripts
*
* @since 1.0
* @version 1.6.0
*/
if ( ! function_exists( 'receptar_register_assets' ) ) {
function receptar_register_assets() {
//Helper variables
$version = esc_attr( trim( wp_get_theme()->get( 'Version' ) ) );
/**
* Styles
*/
$register_styles = apply_filters( 'wmhook_receptar_register_assets_register_styles', array(
'genericons-neue' => array( receptar_get_stylesheet_directory_uri( 'assets/fonts/genericons-neue/genericons-neue.css' ) ),
'receptar-google-fonts' => array( receptar_google_fonts_url() ),
'receptar-starter' => array( receptar_get_stylesheet_directory_uri( 'assets/css/starter.css' ) ),
'receptar-stylesheet' => array( 'src' => get_stylesheet_uri(), 'deps' => array( 'genericons-neue', 'receptar-starter' ) ),
'receptar-colors' => array( receptar_get_stylesheet_directory_uri( 'assets/css/colors.css' ), 'deps' => array( 'receptar-stylesheet' ) ),
'receptar-slick' => array( receptar_get_stylesheet_directory_uri( 'assets/css/slick.css' ) ),
) );
foreach ( $register_styles as $handle => $atts ) {
$src = ( isset( $atts['src'] ) ) ? ( $atts['src'] ) : ( $atts[0] );
$deps = ( isset( $atts['deps'] ) ) ? ( $atts['deps'] ) : ( false );
$ver = ( isset( $atts['ver'] ) ) ? ( $atts['ver'] ) : ( $version );
$media = ( isset( $atts['media'] ) ) ? ( $atts['media'] ) : ( 'all' );
wp_register_style( $handle, $src, $deps, $ver, $media );
}
/**
* Scripts
*/
$register_scripts = apply_filters( 'wmhook_receptar_register_assets_register_scripts', array(
'receptar-slick' => array( receptar_get_stylesheet_directory_uri( 'assets/js/slick.min.js' ) ),
'receptar-scripts-global' => array( receptar_get_stylesheet_directory_uri( 'assets/js/scripts-global.js' ) ),
'receptar-skip-link-focus-fix' => array( receptar_get_stylesheet_directory_uri( 'assets/js/skip-link-focus-fix.js' ) ),
) );
foreach ( $register_scripts as $handle => $atts ) {
$src = ( isset( $atts['src'] ) ) ? ( $atts['src'] ) : ( $atts[0] );
$deps = ( isset( $atts['deps'] ) ) ? ( $atts['deps'] ) : ( array( 'jquery' ) );
$ver = ( isset( $atts['ver'] ) ) ? ( $atts['ver'] ) : ( $version );
$in_footer = ( isset( $atts['in_footer'] ) ) ? ( $atts['in_footer'] ) : ( true );
wp_register_script( $handle, $src, $deps, $ver, $in_footer );
}
}
} // /receptar_register_assets
/**
* Frontend HTML head assets enqueue
*
* @since 1.0
* @version 1.2.1
*/
if ( ! function_exists( 'receptar_enqueue_assets' ) ) {
function receptar_enqueue_assets() {
//Helper variables
$enqueue_styles = $enqueue_scripts = array();
$custom_styles = receptar_custom_styles();
$inline_styles_handle = ( wp_style_is( 'receptar-colors', 'registered' ) ) ? ( 'receptar-colors' ) : ( 'receptar-stylesheet' );
$inline_styles_handle = apply_filters( 'wmhook_receptar_enqueue_assets_inline_styles_handle', $inline_styles_handle );
/**
* Styles
*/
//Google Fonts
if ( receptar_google_fonts_url() ) {
$enqueue_styles[] = 'receptar-google-fonts';
}
//Banner slider
if (
( is_front_page() || is_home() )
&& receptar_has_banner_posts( 2 )
) {
$enqueue_styles[] = 'receptar-slick';
}
//Main
$enqueue_styles[] = 'receptar-stylesheet';
//Colors
if ( 'receptar-colors' === $inline_styles_handle ) {
$enqueue_styles[] = 'receptar-colors';
}
$enqueue_styles = apply_filters( 'wmhook_receptar_enqueue_assets_enqueue_styles', $enqueue_styles );
foreach ( $enqueue_styles as $handle ) {
wp_enqueue_style( $handle );
}
/**
* Styles - inline
*/
//Customizer setup custom styles
if ( $custom_styles ) {
wp_add_inline_style(
$inline_styles_handle,
"\r\n" . apply_filters( 'wmhook_esc_css', $custom_styles ) . "\r\n"
);
}
//Custom styles set in post/page 'custom-css' custom field
if (
is_singular()
&& $output = get_post_meta( get_the_ID(), 'custom_css', true )
) {
$output = apply_filters( 'wmhook_receptar_enqueue_assets_styles_inline_singular', "\r\n\r\n/* Custom singular styles */\r\n" . $output . "\r\n" );
wp_add_inline_style(
$inline_styles_handle,
apply_filters( 'wmhook_esc_css', $output ) . "\r\n"
);
}
/**
* Scripts
*/
//Banner slider
if (
( is_front_page() || is_home() )
&& receptar_has_banner_posts( 2 )
) {
$enqueue_scripts[] = 'receptar-slick';
}
//Global theme scripts
$enqueue_scripts[] = 'receptar-scripts-global';
//Skip link focus fix
$enqueue_scripts[] = 'receptar-skip-link-focus-fix';
$enqueue_scripts = apply_filters( 'wmhook_receptar_enqueue_assets_enqueue_scripts', $enqueue_scripts );
foreach ( $enqueue_scripts as $handle ) {
wp_enqueue_script( $handle );
}
}
} // /receptar_enqueue_assets
/**
* Enqueue comment-reply.js the right way
*
* @since 1.2.1
* @version 1.2.1
*/
if ( ! function_exists( 'receptar_comment_reply_js_enqueue' ) ) {
function receptar_comment_reply_js_enqueue() {
if ( get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
} // /receptar_comment_reply_js_enqueue
/**
* Customizer controls assets enqueue
*
* @since 1.0
* @version 1.6.0
*/
if ( ! function_exists( 'receptar_customizer_enqueue_assets' ) ) {
function receptar_customizer_enqueue_assets() {
//Styles
wp_enqueue_style(
'receptar-customizer',
get_template_directory_uri() . '/assets/css/customizer.css',
false,
esc_attr( trim( wp_get_theme()->get( 'Version' ) ) ),
'all'
);
}
} // /receptar_customizer_enqueue_assets
/**
* Customizer preview assets enqueue
*
* @since 1.0
* @version 1.6.0
*/
if ( ! function_exists( 'receptar_customizer_preview_enqueue_assets' ) ) {
function receptar_customizer_preview_enqueue_assets() {
//Scripts
wp_enqueue_script(
'receptar-customizer-preview',
receptar_get_stylesheet_directory_uri( 'assets/js/customizer-preview.js' ),
array( 'customize-preview' ),
esc_attr( trim( wp_get_theme()->get( 'Version' ) ) ),
true
);
}
} // /receptar_customizer_preview_enqueue_assets
/**
* HTML Body classes
*
* @since 1.0
* @version 1.5.0
*
* @param array $classes
*/
if ( ! function_exists( 'receptar_body_classes' ) ) {
function receptar_body_classes( $classes ) {
//Helper variables
$body_classes = array();
$i = 0;
//Preparing output
//Is not front page?
if ( ! is_front_page() ) {
$body_classes['not-front-page'] = ++$i;
}
//Singular?
if ( is_singular() ) {
$body_classes['is-singular'] = ++$i;
} else {
$body_classes['is-not-singular'] = ++$i;
}
// Privacy Policy page
if ( (int) get_option( 'wp_page_for_privacy_policy' ) === get_the_ID() ) {
$body_classes['page-privacy-policy'] = ++$i;
}
//Has featured image?
if ( is_singular() && has_post_thumbnail() ) {
$body_classes['has-post-thumbnail'] = ++$i;
}
//Is posts list?
if ( is_archive() || is_search() ) {
$body_classes['is-posts-list'] = ++$i;
}
//Featured posts
if (
class_exists( 'NS_Featured_Posts' )
&& (
is_home()
|| is_archive()
|| is_search()
)
) {
$body_classes['has-featured-posts'] = ++$i;
}
//Output
$body_classes = array_filter( (array) apply_filters( 'wmhook_receptar_body_classes_output', $body_classes ) );
$classes = array_merge( $classes, array_flip( $body_classes ) );
asort( $classes );
return $classes;
}
} // /receptar_body_classes
/**
* Post classes
*
* @since 1.0.0
* @version 1.4.0
*
* @param array $classes
*/
if ( ! function_exists( 'receptar_post_classes' ) ) {
function receptar_post_classes( $classes ) {
// Processing
// A generic class for easy styling
$classes[] = 'entry';
// Sticky post
/**
* On paginated posts list the sticky class is not
* being applied, so, we need to compensate.
*/
if ( is_sticky() ) {
$classes[] = 'is-sticky';
}
// Featured post
if (
class_exists( 'NS_Featured_Posts' )
&& get_post_meta( get_the_ID(), '_is_ns_featured_post', true )
) {
$classes[] = 'is-featured';
}
// Output
return $classes;
}
} // /receptar_post_classes
/**
* Singular view featured image
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_singular_featured_image' ) ) {
function receptar_singular_featured_image() {
//Requrements check
if (
( ! is_singular() && ! is_attachment() )
|| is_front_page()
) {
return;
}
//Helper variables
$output = array( apply_filters( 'wmhook_entry_featured_image_fallback_url', '' ) );
if (
is_singular()
&& has_post_thumbnail()
) {
$output = wp_get_attachment_image_src(
get_post_thumbnail_id( get_the_ID() ),
apply_filters( 'wmhook_receptar_enqueue_assets_styles_inline_featured_image_size', 'large' )
);
} else if ( is_attachment() ) {
$output = wp_get_attachment_image_src(
get_the_ID(),
apply_filters( 'wmhook_receptar_enqueue_assets_styles_inline_featured_image_size', 'large' )
);
}
//Preparing output
$output = "\r\n\r\n/* Singular featured image styles */\r\n.entry-media { background-image: url('" . $output[0] . "'); }\r\n";
$output = apply_filters( 'wmhook_receptar_singular_featured_image_output', $output );
//Output
wp_add_inline_style(
'receptar-stylesheet',
apply_filters( 'wmhook_esc_css', $output ) . "\r\n"
);
}
} // /receptar_singular_featured_image
/**
* 50) Site global markup
*/
/**
* Website DOCTYPE
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_doctype' ) ) {
function receptar_doctype() {
echo '';
}
} // /receptar_doctype
/**
* Website HEAD
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_head' ) ) {
function receptar_head() {
//Helper variables
$output = array();
//Preparing output
$output[10] = '';
$output[20] = '';
$output[30] = '';
$output[40] = '';
//Filter output array
$output = apply_filters( 'wmhook_receptar_head_output_array', $output );
//Output
echo apply_filters( 'wmhook_receptar_head_output', implode( "\r\n", $output ) . "\r\n" );
}
} // /receptar_head
/**
* Body top
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_site_top' ) ) {
function receptar_site_top() {
//Helper variables
$output = '' . "\r\n";
$output .= "\t" . '
' . "\r\n";
//Output
echo $output;
}
} // /receptar_site_top
/**
* Body bottom
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_site_bottom' ) ) {
function receptar_site_bottom() {
//Helper variables
$output = "\r\n\t" . '
';
$output .= "\r\n" . '
' . "\r\n\r\n";
//Output
echo $output;
}
} // /receptar_site_bottom
/**
* Header top
*
* @since 1.0.0
* @version 1.4.0
*/
if ( ! function_exists( 'receptar_header_top' ) ) {
function receptar_header_top() {
// Output
echo "\r\n\r\n" . '' . "\r\n\r\n";
//Output
echo $output;
}
} // /receptar_header_bottom
/**
* Display header widgets
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_header_widgets' ) ) {
function receptar_header_widgets() {
get_sidebar( 'header' );
}
} // /receptar_header_widgets
/**
* Social menu args.
*
* @since 1.6.1
* @version 1.6.1
*
* @param string $items_wrap
*/
function receptar_social_menu_args( $items_wrap = '' ) {
// Output
return (array) apply_filters( 'wmhook_receptar_social_menu_args', array(
'theme_location' => 'social',
'container' => 'div',
'container_id' => '',
'container_class' => 'social-links',
'menu_class' => 'social-links-items',
'depth' => 1,
'link_before' => '',
'link_after' => '',
'fallback_cb' => false,
'items_wrap' => (string) $items_wrap,
) );
} // /receptar_social_menu_args
/**
* Display social links
*
* @since 1.0
* @version 1.3
*/
if ( ! function_exists( 'receptar_menu_social' ) ) {
function receptar_menu_social() {
get_template_part( 'template-parts/menu', 'social' );
}
} // /receptar_menu_social
/**
* Social links supported icons
*
* @since 1.6.0
* @version 1.6.1
*/
function receptar_social_links_icons() {
// Output
return array(
'behance.net' => 'behance',
'bitbucket.org' => 'bitbucket',
'codepen.io' => 'codepen',
'deviantart.com' => 'deviantart',
'digg.com' => 'digg',
'docker.com' => 'dockerhub',
'dribbble.com' => 'dribbble',
'dropbox.com' => 'dropbox',
'facebook.com' => 'facebook',
'flickr.com' => 'flickr',
'foursquare.com' => 'foursquare',
'plus.google.com' => 'google-plus',
'github.com' => 'github',
'instagram.com' => 'instagram',
'linkedin.com' => 'linkedin',
'mailto:' => 'envelope',
'medium.com' => 'medium',
'paypal.com' => 'paypal',
'pscp.tv' => 'periscope',
'tel:' => 'phone',
'pinterest.com' => 'pinterest',
'getpocket.com' => 'get-pocket',
'reddit.com' => 'reddit',
'/feed' => 'rss',
'skype.com' => 'skype',
'skype:' => 'skype',
'slack.com' => 'slack',
'slideshare.net' => 'slideshare',
'snapchat.com' => 'snapchat',
'soundcloud.com' => 'soundcloud',
'spotify.com' => 'spotify',
'stackoverflow.com' => 'stack-overflow',
'stumbleupon.com' => 'stumbleupon',
'trello.com' => 'trello',
'tripadvisor.' => 'tripadvisor',
'tumblr.com' => 'tumblr',
'twitch.tv' => 'twitch',
'twitter.com' => 'twitter',
'vimeo.com' => 'vimeo',
'vine.co' => 'vine',
'vk.com' => 'vk',
'wordpress.org' => 'wordpress',
'wordpress.com' => 'wordpress',
'xing.com' => 'xing',
'yelp.com' => 'yelp',
'youtube.com' => 'youtube',
);
} // /receptar_social_links_icons
add_filter( 'wmhook_receptar_svg_get_social_icons', 'receptar_social_links_icons' );
/**
* Display SVG icons in social links menu
*
* @since 1.6.0
* @version 1.6.1
*
* @param string $item_output The menu item output.
* @param WP_Post $item Menu item object.
* @param int $depth Depth of the menu.
* @param array $args wp_nav_menu() arguments.
*/
function receptar_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
// Requirements check
if ( false === strpos( $item_output, '' ) ) {
return $item_output;
}
// Variables
$social_icons = Receptar_SVG::get_social_icons();
$social_icon = 'chain';
// Processing
foreach ( $social_icons as $url => $icon ) {
if ( false !== strpos( $item_output, $url ) ) {
$social_icon = $icon;
break;
}
}
$item_output = str_replace(
'',
'' . Receptar_SVG::get( array(
'icon' => esc_attr( $social_icon ),
'base' => 'social-icon',
) ),
$item_output
);
// Output
return $item_output;
} // /receptar_nav_menu_social_icons
add_filter( 'walker_nav_menu_start_el', 'receptar_nav_menu_social_icons', 10, 4 );
/**
* Display social links in Navigation Menu widget
*
* @subpackage Widgets
*
* @since 1.6.0
* @version 1.6.1
*
* @param array $nav_menu_args Array of parameters for `wp_nav_menu()` function.
* @param string $nav_menu Menu slug assigned in the widget.
* @param array $args Widget parameters.
*/
function receptar_social_widget( $nav_menu_args, $nav_menu, $args ) {
// Variables
$locations = get_nav_menu_locations();
$locations['social'] = ( isset( $locations['social'] ) ) ? ( $locations['social'] ) : ( false );
// Requirements check
if (
! isset( $nav_menu->term_id )
|| (
false === stripos( $nav_menu->name, '[soc]' )
&& $locations['social'] !== $nav_menu->term_id
)
) {
return $nav_menu_args;
}
// Processing
$menu_args = receptar_social_menu_args();
$nav_menu_args['container_class'] = 'social-links';
$nav_menu_args['menu_class'] = 'social-links-items';
$nav_menu_args['depth'] = $menu_args['depth'];
$nav_menu_args['link_before'] = $menu_args['link_before'];
$nav_menu_args['link_after'] = $menu_args['link_after'];
$nav_menu_args['items_wrap'] = $menu_args['items_wrap'];
// Output
return $nav_menu_args;
} // /receptar_social_widget
add_filter( 'widget_nav_menu_args', 'receptar_social_widget', 10, 3 );
/**
* Navigation item improvements
*
* @since 1.0
* @version 1.0
*
* @param string $item_output
* @param object $item
* @param int $depth
* @param array $args
*/
if ( ! function_exists( 'receptar_nav_item_process' ) ) {
function receptar_nav_item_process( $item_output, $item, $depth, $args ) {
//Preparing output
//Display item description
if (
'primary' == $args->theme_location
&& trim( $item->description )
) {
$item_output = str_replace( $args->link_after . '', '' . $args->link_after . '', $item_output );
}
//Output
return $item_output;
}
} // /receptar_nav_item_process
/**
* Post/page heading (title)
*
* @since 1.0.0
* @version 1.4.0
*
* @param array $args Heading setup arguments
*/
if ( ! function_exists( 'receptar_post_title' ) ) {
function receptar_post_title( $args = array() ) {
// Helper variables
global $post;
// Requirements check
if (
! ( $title = get_the_title() )
|| apply_filters( 'wmhook_receptar_post_title_disable', false )
) {
return;
}
$output = $meta = '';
$args = wp_parse_args( $args, apply_filters( 'wmhook_receptar_post_title_defaults', array(
'class' => 'entry-title',
'class_container' => 'entry-header',
'link' => esc_url( get_permalink() ),
'output' => '<{tag} class="{class}">{title}{tag}>{meta}',
'tag' => 'h1',
'title' => '' . $title . '',
) ) );
// Processing
// Singular title (no link applied)
if (
is_single()
|| ( is_page() && 'page' === get_post_type() ) //not to display the below stuff on posts list on static front page
) {
if ( $suffix = receptar_paginated_suffix( 'small' ) ) {
$args['title'] .= $suffix;
} else {
$args['title'] = $title;
}
if ( ( $helper = get_edit_post_link( get_the_ID() ) ) && is_page() ) {
$args['title'] .= ' false ) ) ) ) . '">' . esc_html_x( 'Edit', 'Edit post link.', 'receptar' ) . '';
}
}
// Post meta
if ( is_single() ) {
$meta = receptar_post_meta( array(
'class' => 'entry-category',
'meta' => array( 'category' ),
) );
}
// Filter processed $args
$args = apply_filters( 'wmhook_receptar_post_title_args', $args );
// Generating output HTML
$replacements = apply_filters( 'wmhook_receptar_post_title_replacements', array(
'{class}' => esc_attr( $args['class'] ),
'{class_container}' => esc_attr( $args['class_container'] ),
'{meta}' => $meta,
'{tag}' => esc_attr( $args['tag'] ),
'{title}' => do_shortcode( $args['title'] ),
), $args );
$output = strtr( $args['output'], $replacements );
// Output
echo apply_filters( 'wmhook_receptar_post_title_output', $output, $args );
}
} // /receptar_post_title
/**
* Content top
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_content_top' ) ) {
function receptar_content_top() {
//Helper variables
$output = "\r\n\r\n" . '';
$output .= "\r\n\t" . '
';
$output .= "\r\n\t\t" . '' . "\r\n\r\n";
//Output
echo $output;
}
} // /receptar_content_top
/**
* Content bottom
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_content_bottom' ) ) {
function receptar_content_bottom() {
//Helper variables
$output = "\r\n\r\n\t\t" . '';
$output .= "\r\n\t" . '
';
$output .= "\r\n" . '
' . "\r\n\r\n";
//Output
echo $output;
}
} // /receptar_content_bottom
/**
* Breadcrumbs
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_breadcrumbs' ) ) {
function receptar_breadcrumbs() {
if (
function_exists( 'bcn_display' )
&& ! is_front_page()
&& ( is_singular() || is_archive() || is_search() )
&& apply_filters( 'wmhook_receptar_breadcrumbs_enabled', true )
) {
echo '';
}
}
} // /receptar_breadcrumbs
/**
* Remove breadcrumbs in posts list items
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_breadcrumbs_off' ) ) {
function receptar_breadcrumbs_off() {
add_filter( 'wmhook_receptar_breadcrumbs_enabled', '__return_false' );
}
} // /receptar_breadcrumbs_off
/**
* Entry top
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_entry_top' ) ) {
function receptar_entry_top() {
//Post content inner wrapper
if (
! is_single( get_the_ID() )
&& ! is_page()
) {
echo '';
}
}
} // /receptar_entry_top
/**
* Entry bottom
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_entry_bottom' ) ) {
function receptar_entry_bottom() {
//Post meta
if ( in_array( get_post_type(), apply_filters( 'wmhook_receptar_entry_bottom_meta_post_types', array( 'post' ) ) ) ) {
if ( is_single() ) {
echo receptar_post_meta( apply_filters( 'wmhook_receptar_entry_bottom_meta', array(
'class' => 'entry-meta entry-meta-bottom',
'meta' => array( 'edit', 'date', 'likes', 'author', 'tags' ),
) ) );
}
}
//Comments
comments_template( '', true );
//Post content inner wrapper end
if (
! is_single( get_the_ID() )
&& ! is_page()
) {
echo '
';
}
}
} // /receptar_entry_bottom
/**
* Comments section wrapper
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_comments_before' ) ) {
function receptar_comments_before() {
echo '';
}
} // /receptar_comments_after
/**
* Post thumbnail (featured image) display size
*
* @since 1.0
* @version 1.3.5
*
* @param string $image_size
*/
if ( ! function_exists( 'receptar_post_thumbnail_size' ) ) {
function receptar_post_thumbnail_size( $image_size ) {
//Preparing output
if (
is_single( get_the_ID() )
|| is_page( get_the_ID() )
) {
$image_size = 'receptar-featured';
} else {
$image_size = 'thumbnail';
}
//Output
return $image_size;
}
} // /receptar_post_thumbnail_size
/**
* Excerpt
*
* Displays the excerpt properly.
* If the post is password protected, display a message.
* If the post has more tag, display the content appropriately.
*
* @since 1.0
* @version 1.6.0
*
* @param string $excerpt
*/
if ( ! function_exists( 'receptar_excerpt' ) ) {
function receptar_excerpt( $excerpt ) {
//Requirements check
if ( post_password_required() ) {
if ( ! is_single() ) {
return esc_html__( 'This content is password protected.', 'receptar' ) . ' ' . esc_html__( 'Enter the password to view it.', 'receptar' ) . '';
}
return;
}
//Preparing output
if (
! is_single()
&& receptar_has_more_tag()
) {
/**
* Post has more tag
*/
if ( has_excerpt() ) {
$excerpt = '' . get_the_excerpt() . '
';
}
$excerpt = apply_filters( 'the_content', $excerpt . get_the_content( '' ) );
} else {
/**
* Default excerpt for posts without more tag
*/
$excerpt = strtr( $excerpt, apply_filters( 'wmhook_receptar_excerpt_replacements', array( ' '
' . sprintf( esc_html__( 'Continue reading%s…', 'receptar' ), ' "' . get_the_title() . '"' ) . '';
}
} // /receptar_excerpt_continue_reading
/**
* Previous and next post links
*
* Since WordPress 4.1 you can use the_post_navigation() and/or get_the_post_navigation().
* However, you are modifying markup by applying custom classes, so stick with this
* cusotm function for now.
*
* @todo Transfer to WordPress 4.1+ core functionality.
*
* @since 1.0
* @version 1.3.4
*/
if ( ! function_exists( 'receptar_post_nav' ) ) {
function receptar_post_nav() {
//Requirements check
if ( ! is_singular() || is_page() ) {
return;
}
//Helper variables
$output = $prev_class = $next_class = '';
$previous = ( is_attachment() ) ? ( get_post( get_post()->post_parent ) ) : ( get_adjacent_post( false, '', true ) );
$next = get_adjacent_post( false, '', false );
//Requirements check
if (
( ! $next && ! $previous )
|| ( is_attachment() && 'attachment' == $previous->post_type )
) {
return;
}
$links_count = absint( (bool) $next ) + absint( (bool) $previous );
//Preparing output
if ( $previous && has_post_thumbnail( $previous->ID ) ) {
$prev_class = " has-post-thumbnail";
}
if ( $next && has_post_thumbnail( $next->ID ) ) {
$next_class = " has-post-thumbnail";
}
if ( is_attachment() ) {
$output .= get_previous_post_link(
'
%link
',
wp_kses(
__( 'Published In: %title', 'receptar' ),
array( 'span' => array( 'class' => array() ) )
)
);
} else {
$output .= get_next_post_link(
'%link
',
wp_kses(
__( 'Next: %title', 'receptar' ),
array( 'span' => array( 'class' => array() ) )
)
);
$output .= get_previous_post_link(
'%link
',
wp_kses(
__( 'Previous: %title', 'receptar' ),
array( 'span' => array( 'class' => array() ) )
)
);
}
if ( $output ) {
$output = '';
}
//Output
echo apply_filters( 'wmhook_receptar_post_nav_output', $output );
}
} // /receptar_post_nav
/**
* Pagination
*
* @since 1.0
* @version 1.1
*/
if ( ! function_exists( 'receptar_pagination' ) ) {
function receptar_pagination() {
//Requirements check
if ( class_exists( 'The_Neverending_Home_Page' ) ) {
//Don't display pagination if Jetpack Infinite Scroll in use
return;
}
//Helper variables
global $wp_query, $wp_rewrite;
$output = '';
$pagination = array(
'prev_text' => '«',
'next_text' => '»',
);
//Preparing output
if ( $output = paginate_links( $pagination ) ) {
$output = '';
}
//Output
echo $output;
}
} // /receptar_pagination
/**
* Footer
*
* Theme author credits:
* =====================
* It is completely optional, but if you like this WordPress theme,
* I would appreciate it if you keep the credit link in the footer.
*
* @since 1.0.0
* @version 1.4.0
*/
if ( ! function_exists( 'receptar_footer' ) ) {
function receptar_footer() {
// Output
get_template_part( 'template-parts/footer/site', 'info' );
}
} // /receptar_footer
/**
* Footer top
*
* @since 1.0.0
* @version 1.4.0
*/
if ( ! function_exists( 'receptar_footer_top' ) ) {
function receptar_footer_top() {
// Output
echo "\r\n\r\n" . '' . "\r\n\r\n";
//Output
echo $output;
}
} // /receptar_footer_bottom
/**
* Website footer custom scripts
*
* Outputs custom scripts set in post/page 'custom-js' custom field.
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_footer_custom_scripts' ) ) {
function receptar_footer_custom_scripts() {
//Requirements check
if (
! is_singular()
|| ! ( $output = get_post_meta( get_the_ID(), 'custom_js', true ) )
) {
return;
}
//Helper variables
$output = "\r\n\r\n\r\n\r\n";
//Output
echo apply_filters( 'wmhook_receptar_footer_custom_scripts_output', $output );
}
} // /receptar_footer_custom_scripts
/**
* 100) Other functions
*/
/**
* Register predefined widget areas (sidebars)
*
* @since 1.0
* @version 1.3
*/
if ( ! function_exists( 'receptar_register_widget_areas' ) ) {
function receptar_register_widget_areas() {
//Secondary
register_sidebar( array(
'id' => 'sidebar',
'name' => esc_html__( 'Sidebar', 'receptar' ),
'description' => esc_html__( 'Displayed in hidden sidebar on left below the primary navigation.', 'receptar' ),
'before_widget' => '',
'before_title' => ''
) );
//Header
register_sidebar( array(
'id' => 'header',
'name' => esc_html__( 'Header Widgets', 'receptar' ),
'description' => esc_html__( 'Display widgets in the site header.', 'receptar' ),
'before_widget' => '',
'before_title' => ''
) );
}
} // /receptar_register_widget_areas
/**
* Ignore sticky posts in main loop
*
* @since 1.0
* @version 1.0
*
* @param obj $query
*/
if ( ! function_exists( 'receptar_posts_query_ignore_sticky_posts' ) ) {
function receptar_posts_query_ignore_sticky_posts( $query ) {
if ( $query->is_main_query() ) {
$query->set( 'ignore_sticky_posts', 1 );
}
}
} // /receptar_posts_query_ignore_sticky_posts
/**
* Include Visual Editor addons
*
* @since 1.0
* @version 1.0
*/
if ( ! function_exists( 'receptar_visual_editor' ) ) {
function receptar_visual_editor() {
if ( is_admin() || isset( $_GET['fl_builder'] ) ) {
locate_template( WM_INC_DIR . 'lib/visual-editor.php', true );
}
}
} // /receptar_visual_editor
/**
* Adding additional formats to TinyMCE editor
*
* @since 1.0
* @version 1.3
*
* @param array $formats
*/
if ( ! function_exists( 'receptar_visual_editor_custom_mce_format' ) ) {
function receptar_visual_editor_custom_mce_format( $formats ) {
//Preparing output
$formats[] = array(
'title' => esc_html__( 'Dropcaps', 'receptar' ),
'items' => array(
array(
'title' => esc_html__( 'Dropcap text', 'receptar' ),
'selector' => 'p',
'classes' => 'dropcap-text',
),
),
);
//Return
return $formats;
}
} // /receptar_visual_editor_custom_mce_format
/**
* Default featured image URL
*
* @since 1.0
* @version 1.6.0
*/
if ( ! function_exists( 'receptar_entry_featured_image_fallback_url' ) ) {
function receptar_entry_featured_image_fallback_url() {
//Helper variables
$output = trailingslashit( get_stylesheet_directory_uri() ) . 'assets/images/featured.jpg';
$header_image_data = (array) get_custom_header();
//Preparing output
if (
! empty( $header_image_data )
&& isset( $header_image_data['attachment_id'] )
&& $header_image_data['attachment_id']
) {
$image_size = ( is_singular() ) ? ( 'full' ) : ( 'thumbnail' ); //Using 'full' because this is a banner-cropped image already.
$output = wp_get_attachment_image_src(
absint( $header_image_data['attachment_id'] ),
apply_filters( 'wmhook_receptar_enqueue_assets_styles_inline_featured_image_size', $image_size )
);
$output = $output[0];
}
//Output
return esc_url( $output );
}
} // /receptar_entry_featured_image_fallback_url
/**
* Add form field placeholders to comments form
*
* @since 1.0
* @version 1.5.0
*
* @param mixed $fields
*/
if ( ! function_exists( 'receptar_comments_form_placeholders' ) ) {
function receptar_comments_form_placeholders( $fields ) {
//Processing
if ( is_string( $fields ) ) {
// Comment
$fields = str_replace(
'