tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// add custom image size for theme
add_image_size( 'anza_blog_grid', 360, 360, true ); //360 pixels wide and 360 pixels in height
add_image_size( 'anza_blog_sidebar', 730, 9999 );
add_image_size( 'anza_blog_full', 1110, 9999 );
add_image_size( 'anza_recent_thumb', 65, 65, true );
add_image_size( 'anza_work_thumb', 380, 285, true );
add_image_size( 'anza_testi_thumb', 60, 60, true );
add_image_size( 'anza_about_img', 555, 9999 );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'anza-lite' ),
) );
/*
* 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',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'anza_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
}
endif;
add_action( 'after_setup_theme', 'anza_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function anza_content_width() {
$GLOBALS['content_width'] = apply_filters( 'anza_content_width', 640 );
}
add_action( 'after_setup_theme', 'anza_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function anza_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'anza-lite' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'anza-lite' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Anza Sidebar Blog', 'anza-lite' ),
'id' => 'sidebar-5',
'description' => esc_html__( 'Add widgets here.', 'anza-lite' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'anza_widgets_init' );
/**
* Anza Google Fonts
*/
function anza_google_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Lora, translate this to 'off'. Do not translate
* into your own language.
*/
$roboto = _x( 'on', 'Roboto font: on or off', 'anza-lite' );
/* Translators: If there are characters in your language that are not
* supported by Open Sans, translate this to 'off'. Do not translate
* into your own language.
*/
$noto_sans = _x( 'on', 'Noto Sans font: on or off', 'anza-lite' );
if ( 'off' !== $roboto || 'off' !== $noto_sans ) {
$font_families = array();
if ( 'off' !== $roboto ) {
$font_families[] = 'Roboto:300,400,500,700,900';
}
if ( 'off' !== $noto_sans ) {
$font_families[] = 'Noto Sans:400,700';
}
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return esc_url_raw( $fonts_url );
}
/**
* Setup anza Styles and Scripts
*/
function anza_scripts() {
global $redux_demo;
if (is_admin()) return; // don't dequeue on the backend
/*Load anza CSS*/
wp_enqueue_style( 'anza-style', get_stylesheet_uri() );
wp_enqueue_style( 'anza-google-fonts', anza_google_fonts_url(), array(), null );
wp_enqueue_style( 'bootstrap', esc_url( get_template_directory_uri() ).'/css/bootstrap.min.css' );
wp_enqueue_style( 'linear-fonts', esc_url( get_template_directory_uri() ).'/fonts/linear-fonts.css' );
wp_enqueue_style( 'font-awesome', esc_url( get_template_directory_uri() ).'/fonts/font-awesome.css' );
wp_enqueue_style( 'owl-carousel', esc_url( get_template_directory_uri() ).'/css/owl.carousel.css' );
wp_enqueue_style( 'owl-theme', esc_url( get_template_directory_uri() ).'/css/owl.theme.css' );
wp_enqueue_style( 'magnific-popup', esc_url( get_template_directory_uri() ).'/css/magnific-popup.css' );
wp_enqueue_style( 'animate', esc_url( get_template_directory_uri() ).'/css/animate.min.css' );
wp_enqueue_style( 'effects', esc_url( get_template_directory_uri() ).'/css/effects.css' );
wp_enqueue_style( 'style-main', esc_url( get_template_directory_uri() ).'/css/style.css' );
wp_enqueue_style( 'responsive', esc_url( get_template_directory_uri() ).'/css/responsive.css' );
wp_enqueue_style( 'isotope', esc_url( get_template_directory_uri() ).'/css/isotope.css' );
/*Load anza Scripts*/
wp_enqueue_script( 'bootstrap', esc_url( get_template_directory_uri() ) . '/js/bootstrap.min.js', array(), '', true );
// Load the html5 shiv.
wp_enqueue_script( 'html5shiv"', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', array(), '3.7.2' );
wp_script_add_data( 'html5shiv', 'conditional', 'lt IE 9' );
// Load the html5 html5respond.
wp_enqueue_script( 'html5respond"', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', array(), '1.4.2' );
wp_script_add_data( 'html5respond', 'conditional', 'lt IE 9' );
wp_enqueue_script( 'bootstrap-hover-dropdown', esc_url( get_template_directory_uri() ) . '/js/bootstrap-hover-dropdown.js', array(), '', true );
wp_enqueue_script( 'owl-carousel', esc_url( get_template_directory_uri() ) . '/js/owl.carousel.min.js', array(), '', true );
wp_enqueue_script( 'magnific-popup', esc_url( get_template_directory_uri() ) . '/js/jquery.magnific-popup.min.js', array(), '', true );
wp_enqueue_script( 'parallax', esc_url( get_template_directory_uri() ) . '/js/jarallax.js', array(), '', true );
// wp_enqueue_script( 'parallax', esc_url( get_template_directory_uri() ) . '/js/parallax.min.js', array(), '', true );
wp_enqueue_script( 'waypoints', esc_url( get_template_directory_uri() ) . '/js/jquery.waypoints.min.js', array(), '', true );
wp_enqueue_script( 'counterup', esc_url( get_template_directory_uri() ) . '/js/jquery.counterup.min.js', array(), '', true );
wp_enqueue_script( 'wow', esc_url( get_template_directory_uri() ) . '/js/wow.min.js', array(), '', true );
wp_enqueue_script( 'google-maps', esc_url('https://maps.googleapis.com/maps/api/js?key=AIzaSyCZ-Mg4yuMqEgPXx_q0xYQvZxO-Z3dYJHM'), array(), '', true );
wp_enqueue_script( 'gmap3', esc_url( get_template_directory_uri()) . '/js/gmap3.min.js', array(), '', true );
wp_enqueue_script( 'form-contact', esc_url( get_template_directory_uri() ) . '/js/form-contact.js', array(), '', true );
wp_enqueue_script( 'isotope-main', esc_url( get_template_directory_uri() ) . '/js/jquery.isotope.min.js', array(), '', true );
wp_enqueue_script( 'isotope-callback', esc_url( get_template_directory_uri() ) . '/js/isotope.js', array(), '', true );
wp_enqueue_script( 'scripts-main', esc_url( get_template_directory_uri() ) . '/js/scripts.js', array(), '', true );
wp_enqueue_script( 'validate', esc_url( get_template_directory_uri() ) . '/js/jquery.validate.min.js', array(), '', true );
wp_enqueue_script( 'newsletter', esc_url( get_template_directory_uri() ) . '/js/newsletter.js', array(), '', true );
wp_enqueue_script( 'anza-navigation', esc_url( get_template_directory_uri() ) . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'anza-skip-link-focus-fix', esc_url( get_template_directory_uri() ) . '/js/skip-link-focus-fix.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'anza_scripts', 100 );
function anza_admin_style() {
wp_register_style( 'admin_css', esc_url( get_template_directory_uri() ) . '/css/admin.css', false, '1.0.0' );
wp_enqueue_style( 'admin_css' );
//Get user id
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$args = array('post_type' =>'cta','fields'>'ids');
$count = count(get_posts($args));
if($count>0){
$page = remove_submenu_page( 'edit.php?post_type=cta', 'post-new.php?post_type=cta' );
if (isset($_GET['post_type']) && $_GET['post_type'] == 'cta') {
$custom_css = ".wrap h1.wp-heading-inline, a.page-title-action { display:none !important; }";
wp_add_inline_style( 'admin_css', $custom_css );
}
}
}
add_action( 'admin_enqueue_scripts', 'anza_admin_style' );
add_filter( 'the_password_form', 'anza_password_form' );
function anza_password_form($content) {
$before = array('This content is password protected. To view it please enter your password below:','Password:','Submit');
$after = array('Enter your password to view this post:','Password:','submit');
$content = str_replace($before,$after,$content);
return $content;
}
/** remove redux menu under the tools **/
add_action( 'admin_menu', 'anza_remove_redux_menu',12 );
function anza_remove_redux_menu() {
remove_submenu_page('tools.php','redux-about');
}
function anza_disable_plugin_updates( $value ) {
if(isset($value->response['redux-framework/redux-framework.php'])) {
unset( $value->response['redux-framework/redux-framework.php'] );
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'anza_disable_plugin_updates' );
function anza_excerpt_length( $length ) {
return 30;
}
add_filter( 'excerpt_length', 'anza_excerpt_length', 999 );
function anza_excerpt_more( $more ) {
return '...';
}
add_filter('excerpt_more', 'anza_excerpt_more');
function anza_template_url() {
global $redux_demo;
$anza_path = 'var templateUrl = "'.esc_url( get_template_directory_uri() ).'"'."\n\r";
if(isset($redux_demo['contact_map_lang']))
$anza_path .= 'var lang = "'.$redux_demo['contact_map_lang'].'"'."\n\r";
if(isset($redux_demo['contact_map_lat']))
$anza_path .= 'var lat = "'.$redux_demo['contact_map_lat'].'"'."\n\r";
wp_enqueue_script( 'anza-path', get_template_directory_uri().'/js/loadmore.js', array(), '1.0', false );
wp_add_inline_script( 'anza-path', $anza_path );
}
add_action( 'wp_enqueue_scripts', 'anza_template_url' );
function anza_posts_per_page_limit( $query ) {
global $redux_demo;
if( !is_admin() && $query->is_main_query() && is_post_type_archive( 'projects' ) ) {
$query->set( 'posts_per_page', $redux_demo['works_display_limit'] );
}
}
add_action( 'pre_get_posts', 'anza_posts_per_page_limit' );
function anza_one_click_import_files() {
return array(
array(
'import_file_name' => 'Demo Import',
'import_file_url' => 'http://anza.codetides.com/anza-wp-framework-images/demo-file.xml',
'import_widget_file_url' => 'http://anza.codetides.com/anza-wp-framework-images/widgets.wie',
'import_customizer_file_url' => 'http://anza.codetides.com/anza-wp-framework-images/customizer.dat',
'import_redux' => array(
array(
'file_url' => 'http://anza.codetides.com/anza-wp-framework-images/redux.json',
'option_name' => 'redux_demo',
),
),
'import_preview_image_url' => 'http://anza.codetides.com/anza-wp-framework-images/screenshot.png',
'import_notice' => esc_html__( 'After you import this demo, you dont need to do anything special. All will set up! have a good day.', 'anza-lite' ),
),
);
}
add_filter( 'pt-ocdi/import_files', 'anza_one_click_import_files' );
add_action('switch_theme','anza_disable_plugins');
function anza_disable_plugins(){
$plugins_url = plugins_url();
$plugin_path = $plugins_url.'/anza-custom-post-types/index.php';
if ( is_plugin_active($plugin_path) ) {
deactivate_plugins($plugin_path);
}
}