File: /home/posscale/public_html/WP-POS/wp-content/themes/angle/functions/functions.php
<?php
/**
* Theme functions and definitions
*
* Set up the theme and provides some helper functions, which are used in the
* theme as custom template tags. Others are attached to action and filter
* hooks in WordPress to change core functionality.
*
* When using a child theme you can override certain functions (those wrapped
* in a function_exists() call) by defining them first in your child theme's
* functions.php file. The child theme's functions.php file is included before
* the parent theme's file, so the child theme functions would be used.
*/
if ( ! function_exists( 'angle_setup' ) ) :
/**
* Theme setup.
*
* Set up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support post thumbnails.
*/
function angle_setup() {
// This theme styles the visual editor to resemble the theme style.
add_editor_style( array( 'css/editor-style.css' ) );
add_image_size( 'featured', 1400, 550, true );
add_image_size( 'featured-small', 800 );
/* Portfolio item featured */
add_image_size( 'portfolio-thumb', 600, 400, true );
/* Main loop */
add_image_size( 'loop', option::get('thumb_width'), option::get('thumb_height'), true );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
// Register nav menus
register_nav_menus( array(
'primary' => __( 'Main Menu', 'wpzoom' )
) );
/**
* Theme Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 50,
'width' => 250,
'flex-height' => true,
'flex-width' => true
) );
angle_old_fonts();
}
endif;
add_action( 'after_setup_theme', 'angle_setup' );
/* Add support for Custom Background
==================================== */
add_theme_support( 'custom-background' );
/* Custom Excerpt Length
==================================== */
function new_excerpt_length( $length ) {
return (int) option::get( "excerpt_length" ) ? (int)option::get( "excerpt_length" ) : 50;
}
add_filter( 'excerpt_length', 'new_excerpt_length' );
/* Replaces the excerpt "more" text by a link
=========================================== */
function new_excerpt_more( $more ) {
global $post;
return ' […] <div class="clear"></div><a class="more_link clearfix" href="' . get_permalink( $post->ID ) . '" rel="nofollow">' . __( 'Read More →', 'wpzoom' ) . '</a>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
/* Enable Excerpts for Pages
==================================== */
add_action( 'init', 'wpzoom_excerpts_to_pages' );
function wpzoom_excerpts_to_pages() {
add_post_type_support( 'page', 'excerpt' );
}
/* Portfolio Module @ ZOOM Framewowk
================================== */
add_theme_support( 'zoom-portfolio' );
function inspiro_filter_portfolio( $query ) {
if ( $query->is_main_query() && $query->is_tax( 'portfolio' ) ) {
$query->set( 'posts_per_page', option::get( 'portfolio_posts' ) );
}
return $query;
}
add_action( 'pre_get_posts', 'inspiro_filter_portfolio' );
/* Filter to set posts per page as defined in portfolio options.
==================================== */
add_filter( 'pre_get_posts', 'su_portfolio_pre_get_posts' );
function su_portfolio_pre_get_posts( $query ) {
/* If is portfolio taxonomy, limit number of posts. */
if ( isset( $query->query['portfolio'] ) ) {
$query->set( 'posts_per_page', option::get('portfolio_posts') );
}
}
/* Maximum width for images in posts
=========================================== */
if ( ! isset( $content_width ) ) $content_width = 840;
/* Reset [gallery] shortcode styles
==================================== */
if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
add_filter( 'gallery_style', function ( $a ) {
return "<div class='gallery'>";
} );
} else {
add_filter( 'gallery_style', create_function( '$a', 'return "<div class=\'gallery\'>";' ) );
}
/* Add Support for Shortcodes in Excerpt
========================================== */
add_filter( 'the_excerpt', 'shortcode_unautop');
add_filter( 'the_excerpt', 'do_shortcode');
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
if ( ! function_exists( 'angle_get_google_font_uri' ) ) :
/**
* Build the HTTP request URL for Google Fonts.
*
* @return string The URL for including Google Fonts.
*/
function angle_get_google_font_uri() {
// Grab the font choices
$font_keys = zoom_customizer_get_font_familiy_ids(angle_customizer_data());
$fonts = array();
foreach ( $font_keys as $key => $default ) {
$fonts[] = get_theme_mod( $key, $default );
}
// De-dupe the fonts
$fonts = array_unique( $fonts );
$allowed_fonts = zoom_customizer_get_google_fonts();
$family = array();
// Validate each font and convert to URL format
foreach ( $fonts as $font ) {
$font = trim( $font );
// Verify that the font exists
if ( array_key_exists( $font, $allowed_fonts ) ) {
// Build the family name and variant string (e.g., "Open+Sans:regular,italic,700")
$family[] = urlencode( $font . ':' . join( ',', zoom_customizer_choose_google_font_variants( $font, $allowed_fonts[ $font ]['variants'] ) ) );
}
}
// Convert from array to string
if ( empty( $family ) ) {
return '';
} else {
$request = '//fonts.googleapis.com/css?family=' . implode( '|', $family );
}
// Load the font subset
$subset = get_theme_mod( 'font-subset', false );
if ( 'all' === $subset ) {
$subsets_available = zoom_customizer_get_google_font_subsets();
// Remove the all set
unset( $subsets_available['all'] );
// Build the array
$subsets = array_keys( $subsets_available );
} else {
$subsets = array(
'latin',
$subset,
);
}
// Append the subset string
if ( ! empty( $subsets ) ) {
$request .= urlencode( '&subset=' . join( ',', $subsets ) );
}
/**
* Filter the Google Fonts URL.
*
* @since 1.2.3.
*
* @param string $url The URL to retrieve the Google Fonts.
*/
return apply_filters( 'angle_get_google_font_uri', esc_url( $request ) );
}
endif;
/**
* generate home widgetized content that can be changed from customizer
*/
function angle_home_widgetized_callback(){
$widgets_areas = (int) get_theme_mod( 'home-widget-columns', zoom_customizer_get_default_option_value( 'home-widget-columns', angle_customizer_data() ) );
$has_active_sidebar = false;
if ( $widgets_areas > 0 ) {
$i = 1;
while ( $i <= $widgets_areas ) {
if ( is_active_sidebar( 'home-' . $i ) ) {
$has_active_sidebar = true;
break;
}
$i++;
}
}
if ( $has_active_sidebar ) { ?>
<div class="home_widgets cols-<?php echo $widgets_areas; ?>">
<h3 class="section-title"><?php echo get_theme_mod( 'home-widget-section-text', zoom_customizer_get_default_option_value( 'home-widget-section-text', angle_customizer_data() ) ); ?></h3>
<?php for ( $i = 1; $i <= $widgets_areas; $i ++ ) : ?>
<div class="home_column <?php echo ($i == $widgets_areas ? 'last' : ''); ?>">
<?php dynamic_sidebar( 'home-' . $i ) ?>
</div>
<?php endfor; ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
<?php
}
}
function angle_footer_widgetized_callback(){
$widgets_areas = (int) get_theme_mod( 'footer-widget-areas', zoom_customizer_get_default_option_value( 'footer-widget-areas', angle_customizer_data() ) );
$has_active_sidebar = false;
if ( $widgets_areas > 0 ) {
$i = 1;
while ( $i <= $widgets_areas ) {
if ( is_active_sidebar( 'footer_' . $i ) ) {
$has_active_sidebar = true;
break;
}
$i++;
}
}
?>
<?php if ( $has_active_sidebar ) : ?>
<div class="footer-widgets widgets widget-columns-<?php echo esc_attr( $widgets_areas ); ?>">
<div class="inner-wrap">
<?php for ( $i = 1; $i <= $widgets_areas; $i ++ ) : ?>
<div class="column">
<?php dynamic_sidebar( 'footer_' . $i ); ?>
</div><!-- .column -->
<?php endfor; ?>
</div>
<div class="clear"></div>
</div><!-- .footer-widgets -->
<?php endif; ?>
<?php
}
/**
* Show custom logo or blog title and description (backward compatibility)
*
*/
function angle_custom_logo()
{
//In future must remove it is for backward compatibility.
if(get_theme_mod('logo')){
set_theme_mod('custom_logo', zoom_get_attachment_id_from_url(get_theme_mod('logo')));
remove_theme_mod('logo');
}
has_custom_logo() ? the_zoom_custom_logo() : printf('<h1><a href="%s" title="%s">%s</a></h1>', home_url(), get_bloginfo('description'), get_bloginfo('name'));
}
function angle_old_fonts() {
if(get_theme_mod('font-family-site-title')){
set_theme_mod('title-font-family', get_theme_mod('font-family-site-title'));
remove_theme_mod('font-family-site-title');
}
if(get_theme_mod('font-family-site-tagline')){
set_theme_mod('description-font-family', get_theme_mod('font-family-site-tagline'));
remove_theme_mod('font-family-site-tagline');
}
if(get_theme_mod('font-family-nav')){
set_theme_mod('mainmenu-font-family', get_theme_mod('font-family-nav'));
remove_theme_mod('font-family-nav');
}
if(get_theme_mod('font-family-slider-title')){
set_theme_mod('slider-title-font-family', get_theme_mod('font-family-slider-title'));
remove_theme_mod('font-family-slider-title');
}
if(get_theme_mod('font-family-widgets')){
set_theme_mod('widget-title-font-family', get_theme_mod('font-family-widgets'));
remove_theme_mod('font-family-widgets');
}
if(get_theme_mod('font-family-post-title')){
set_theme_mod('blog-title-font-family', get_theme_mod('font-family-post-title'));
remove_theme_mod('font-family-post-title');
}
if(get_theme_mod('font-family-single-post-title')){
set_theme_mod('post-title-font-family', get_theme_mod('font-family-single-post-title'));
remove_theme_mod('font-family-single-post-title');
}
if(get_theme_mod('font-family-page-title')){
set_theme_mod('page-title-font-family', get_theme_mod('font-family-page-title'));
remove_theme_mod('font-family-page-title');
}
}
/* Enqueue scripts and styles for the front end.
=========================================== */
function angle_scripts() {
if ( '' !== $google_request = angle_get_google_font_uri() ) {
wp_enqueue_style( 'angle-google-fonts', $google_request, WPZOOM::$themeVersion );
}
// Load our main stylesheet.
wp_enqueue_style( 'angle-style', get_stylesheet_uri(), array(), WPZOOM::$themeVersion );
wp_enqueue_style( 'media-queries', get_template_directory_uri() . '/css/media-queries.css', array(), WPZOOM::$themeVersion );
wp_enqueue_style( 'angle-google-font-default', '//fonts.googleapis.com/css?family=Roboto:400,400i,500,500i,700,700i,900,900i&subset=cyrillic,greek,latin-ext' );
wp_enqueue_style( 'dashicons' );
wp_enqueue_script( 'mmenu', get_template_directory_uri() . '/js/jquery.mmenu.min.all.js', array( 'jquery' ), WPZOOM::$themeVersion, true );
wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/flexslider.min.js', array( 'jquery' ), WPZOOM::$themeVersion, true );
wp_enqueue_script( 'fitvids', get_template_directory_uri() . '/js/fitvids.min.js', array( 'jquery' ), WPZOOM::$themeVersion, true );
wp_enqueue_script( 'superfish', get_template_directory_uri() . '/js/superfish.min.js', array( 'jquery' ), WPZOOM::$themeVersion, true );
$themeJsOptions = option::getJsOptions();
// Enqueue Isotope when Portfolio Isotope template is used.
if ( is_page_template( 'portfolio/archive-isotope.php' ) ) {
wp_enqueue_script( 'isotope', get_template_directory_uri() . '/js/isotope.pkgd.min.js', array( ), WPZOOM::$themeVersion, true );
}
wp_enqueue_script( 'angle-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), WPZOOM::$themeVersion, true );
wp_localize_script( 'angle-script', 'zoomOptions', $themeJsOptions );
}
add_action( 'wp_enqueue_scripts', 'angle_scripts' );