Current File : /home/n742ef5/public_html/tk4tax/wp-content/themes/accesspress_parallax_pro/functions.php |
<?php
/**
* accesspress_parallax functions and definitions
*
* @package accesspress_parallax
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if (!isset($content_width)) {
$content_width = 640; /* pixels */
}
if (!function_exists('accesspress_parallax_setup')) :
/**
* Sets 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 for post thumbnails.
*/
function accesspress_parallax_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on accesspress_parallax, use a find and replace
* to change 'accesspress_parallax' to the name of your theme in all the template files
*/
load_theme_textdomain('accesspress_parallax', get_template_directory() . '/languages');
// Add default posts and comments RSS feed links to head.
add_theme_support('automatic-feed-links');
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support('post-thumbnails');
add_image_size('blog-header', 900, 300, array('center', 'center')); //blog Image
add_image_size('portfolio-thumbnail', 560, 450, array('center', 'center')); //Portfolio Image
add_image_size('medium-thumbnail', 540, 350, array('center', 'center')); //Portfolio Image
add_image_size('team-thumbnail', 380, 380, array('top', 'center')); //Portfolio Image
add_image_size('portfolio-long', 373, 560, array('top', 'center')); //Portfolio Image
add_image_size('testimonial-thumbnial', 445, 445, true);
// This theme uses wp_nav_menu() in one location.
register_nav_menus(array(
'primary' => __('Primary Menu', 'accesspress_parallax'),
'topmenu' => __('Header Menu', 'accesspress_parallax'),
));
/*
* 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'
));
// Adding WooCommerce Support
add_theme_support('woocommerce');
}
endif; // accesspress_parallax_setup
add_action('after_setup_theme', 'accesspress_parallax_setup');
/** Define `of_get_option` function **/
if( ! function_exists( 'of_get_option' ) ) {
function of_get_option( $option, $default = false ) {
$options = get_option( 'accesspress_parallax_pro' );
$return_option = isset($options[$option]) ? $options[$option] : $default;
return $return_option;
}
}
/**
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
function accesspress_parallax_widgets_init() {
register_sidebar(array(
'name' => __('Sidebar Left', 'accesspress_parallax'),
'id' => 'sidebar-left',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title"><span>',
'after_title' => '</span></h4>',
));
register_sidebar(array(
'name' => __('Sidebar Right', 'accesspress_parallax'),
'id' => 'sidebar-right',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title"><span>',
'after_title' => '</span></h4>',
));
register_sidebar(array(
'name' => __('Sidebar Shop', 'accesspress_parallax'),
'id' => 'sidebar-shop',
'description' => __('Sidebar for WooCommerce Page', 'accesspress_parallax'),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title"><span>',
'after_title' => '</span></h4>',
));
register_sidebar(array(
'name' => __('Footer One', 'accesspress_parallax'),
'id' => 'footer-1',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
));
register_sidebar(array(
'name' => __('Footer Two', 'accesspress_parallax'),
'id' => 'footer-2',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
));
register_sidebar(array(
'name' => __('Footer Three', 'accesspress_parallax'),
'id' => 'footer-3',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
));
register_sidebar(array(
'name' => __('Footer Four', 'accesspress_parallax'),
'id' => 'footer-4',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
));
}
add_action('widgets_init', 'accesspress_parallax_widgets_init');
/**
* Enqueue scripts and styles.
*/
function accesspress_parallax_scripts() {
$map_latitude = of_get_option('map_latitude', '');
$map_longitude = of_get_option('map_longitude', '');
$map_apikey = of_get_option('map_api', '');
$query_args = array(
'family' => 'PT+Sans:400|Oxygen:400',
);
wp_enqueue_style('google-fonts', add_query_arg($query_args, "//fonts.googleapis.com/css"));
wp_enqueue_style('accesspress_parallax-combined-style', get_template_directory_uri() . '/css/ap-combined-style.css');
wp_enqueue_style('accesspress_parallax-style', get_stylesheet_uri());
wp_enqueue_style('accesspress_parallax-responsive', get_template_directory_uri() . '/css/responsive.css');
wp_enqueue_script('accesspress_parallax-plugins', get_template_directory_uri() . '/js/plugins.js', array('jquery'), '1', true);
if(of_get_option('enable_googlemap', 1) == '1' && !empty($map_latitude) && !empty($map_longitude) && (is_front_page() || is_page_template('contact-page.php') || is_page_template('home-page.php'))):
wp_enqueue_script('accesspress_parallax-googlemap', '//maps.googleapis.com/maps/api/js?key='.$map_apikey, array(), '3.0', false);
endif;
if (of_get_option('enable_animation', 1) == '1' && is_front_page()):
wp_enqueue_script('accesspress_parallax-wow', get_template_directory_uri() . '/js/wow.min.js', array('jquery'), '1.0', true);
endif;
wp_register_script('accesspress_parallax-custom', get_template_directory_uri() . '/js/custom.js', array('jquery'), '1.0', true);
wp_localize_script( 'accesspress_parallax-custom', 'parallax_pro_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php') ) );
wp_enqueue_script( 'accesspress_parallax-custom' );
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
}
add_action('wp_enqueue_scripts', 'accesspress_parallax_scripts');
/**
* Loads dynamic style files
*/
require get_template_directory() . '/css/style.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/accesspress-functions.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Load Google Fonts.
*/
require get_template_directory() . '/inc/accesspress-google-fonts.php';
/**
* Load Shortcodes
*/
require get_template_directory() . '/inc/accesspress-shortcodes.php';
/**
* Load Widgets
*/
require get_template_directory() . '/inc/accesspress-widgets.php';
/**
* Load Custom Post types
*/
require get_template_directory() . '/inc/accesspress-posts-types.php';
/**
* Load Custom Meta Box
*/
require get_template_directory() . '/inc/accesspress-metabox.php';
/**
* Import
*/
require get_template_directory() . '/welcome/welcome-config.php';
/**
* WooCommerce Function
*/
require get_template_directory() . '/woocommerce/woocommerce-function.php';
/**
* Options Framework
*/
require get_template_directory() . '/inc/options-framework/options-framework.php';
if( ! function_exists( 'of_get_typo_option' ) ) {
function of_get_typo_option( $option, $default = false ) {
$options = get_option( 'accesspress_parallax_prot' );
$return_option = isset( $options[$option] ) ? $options[$option] : $default;
return $return_option;
}
}
/**
* Migrate Old Typography Options
*/
if( ! function_exists('accesspress_parallax_pro_migrate_typo') ) {
function accesspress_parallax_pro_migrate_typo() {
$options = get_option( 'accesspress_parallax_pro' );
$typography = array();
$default_typos = array(
'line_height' => '',
'text_transform' => 'none',
'decoration' => 'none',
);
$options['hm_section_title_typography'] = array(
'face' => 'Roboto',
'style' => '300',
'decoration' => 'none',
'text_transform' => 'uppercase',
'size' => '32',
'line_height' => '1.2',
);
$typography_flag = get_option('accesspress_parallax_pro_typo_flag', 0);
if( isset( $options['menu_typography'] ) ) {
$typography['menu_typography'] = array_merge( $default_typos, $options['menu_typography'] );
$typography['menu_typography']['text_transform'] = $options['menu_text_transform'];
$typography['menu_typography']['size'] = str_replace( 'px', '', $options['menu_typography']['size'] );
}
if( isset( $options['topheader_typography'] ) ) {
$typography['topheader_typography'] = array_merge( $default_typos, $options['topheader_typography'] );
$typography['topheader_typography']['size'] = str_replace( 'px', '', $options['topheader_typography']['size'] );
}
if( isset( $options['body_typography'] ) ) {
$typography['body_typography'] = array_merge( $default_typos, $options['body_typography'] );
$typography['body_typography']['size'] = str_replace( 'px', '', $options['body_typography']['size'] );
}
if( isset( $options['h1_typography'] ) ) {
$typography['h1_typography'] = array_merge( $default_typos, $options['h1_typography'] );
$typography['h1_typography']['text_transform'] = $options['h1_text_transform'];
$typography['h1_typography']['size'] = str_replace( 'px', '', $options['h1_typography']['size'] );
}
if( isset( $options['h2_typography'] ) ) {
$typography['h2_typography'] = array_merge( $default_typos, $options['h2_typography'] );
$typography['h2_typography']['text_transform'] = $options['h2_text_transform'];
$typography['h2_typography']['size'] = str_replace( 'px', '', $options['h2_typography']['size'] );
}
if( isset( $options['h3_typography'] ) ) {
$typography['h3_typography'] = array_merge( $default_typos, $options['h3_typography'] );
$typography['h3_typography']['text_transform'] = $options['h3_text_transform'];
$typography['h3_typography']['size'] = str_replace( 'px', '', $options['h3_typography']['size'] );
}
if( isset( $options['h4_typography'] ) ) {
$typography['h4_typography'] = array_merge( $default_typos, $options['h4_typography'] );
$typography['h4_typography']['text_transform'] = $options['h4_text_transform'];
$typography['h4_typography']['size'] = str_replace( 'px', '', $options['h4_typography']['size'] );
}
if( isset( $options['h5_typography'] ) ) {
$typography['h5_typography'] = array_merge( $default_typos, $options['h5_typography'] );
$typography['h5_typography']['text_transform'] = $options['h5_text_transform'];
$typography['h5_typography']['size'] = str_replace( 'px', '', $options['h5_typography']['size'] );
}
if( isset( $options['h6_typography'] ) ) {
$typography['h6_typography'] = array_merge( $default_typos, $options['h6_typography'] );
$typography['h6_typography']['text_transform'] = $options['h6_text_transform'];
$typography['h6_typography']['size'] = str_replace( 'px', '', $options['h6_typography']['size'] );
}
if( isset( $options['widgettitle_typography'] ) ) {
$typography['widgettitle_typography'] = array_merge( $default_typos, $options['widgettitle_typography'] );
$typography['widgettitle_typography']['text_transform'] = $options['widget_title_text_transform'];
$typography['widgettitle_typography']['size'] = str_replace( 'px', '', $options['widgettitle_typography']['size'] );
}
if( isset( $options['footertitle_typography'] ) ) {
$typography['footertitle_typography'] = array_merge( $default_typos, $options['footertitle_typography'] );
$typography['footertitle_typography']['text_transform'] = $options['footer_title_text_transform'];
$typography['footertitle_typography']['size'] = str_replace( 'px', '', $options['footertitle_typography']['size'] );
}
if( !empty( $typography ) && !$typography_flag ) {
update_option( 'accesspress_parallax_prot', $typography );
update_option( 'accesspress_parallax_pro_typo_flag', 1 );
}
}
}
if( !function_exists('accesspress_parallax_pro_migrate_plx_sections') ) {
function accesspress_parallax_pro_migrate_plx_sections() {
$options = get_option( 'accesspress_parallax_pro' );
$accesspress_parallax_pro_plx_sections_flag = get_option( 'accesspress_parallax_pro_plx_sections_flag', 0 );
$plx_sections = isset( $options['parallax_section'] ) ? json_encode( $options['parallax_section'] ) : '';
if( !empty( $plx_sections ) && !$accesspress_parallax_pro_plx_sections_flag ) {
update_option( 'accesspress_parallax_pro_parallax_sections', $plx_sections );
update_option( 'accesspress_parallax_pro_plx_sections_flag', 1 );
}
}
}
if( !function_exists( 'accesspress_parallax_pro_modify_exclude_blog_category' ) ) {
function accesspress_parallax_pro_modify_exclude_blog_category() {
$options = get_option( 'accesspress_parallax_pro' );
$accesspress_parallax_pro_exblgcat_flag = get_option( 'accesspress_parallax_pro_exblgcat_flag', 0 );
if( !$accesspress_parallax_pro_exblgcat_flag ) {
$modified_valued = '';
$exclude_category = $options['exclude_from_blog'];
if( is_array( $exclude_category ) ) {
foreach( $exclude_category as $key => $value ) {
if( $value ) {
$modified_valued .= $key . ',';
}
}
}
$options['exclude_from_blog'] = $modified_valued;
update_option( 'accesspress_parallax_pro', $options );
update_option( 'accesspress_parallax_pro_exblgcat_flag', 1 );
}
}
}
if( !function_exists( 'accesspress_parallax_pro_partner_logo' ) ) {
function accesspress_parallax_pro_partner_logo() {
$options = get_option( 'accesspress_parallax_pro' );
$accesspress_parallax_pro_partner_logo_flag = get_option( 'accesspress_parallax_pro_partner_logo_flag', 0 );
if( !$accesspress_parallax_pro_partner_logo_flag ) {
$partner_logo = isset( $options['partner_logo'] ) ? json_encode( $options['partner_logo'] ) : '';
update_option( 'accesspress_parallax_pro_partner_logos', $partner_logo );
update_option( 'accesspress_parallax_pro_partner_logo_flag', 1 );
}
}
}
/** Migrating & Modifying old options **/
accesspress_parallax_pro_migrate_typo();
accesspress_parallax_pro_migrate_plx_sections();
accesspress_parallax_pro_modify_exclude_blog_category();
accesspress_parallax_pro_partner_logo();