>>> DO NOT EDIT THIS FILE <<<< * * Warning! DO NOT EDIT THIS FILE, or any other theme file! If you edit ANY theme * file, all your changes will be LOST when you update the theme to a newer version. * Instead, if you need to change theme functionality, CREATE A CHILD THEME! * * >>>> DO NOT EDIT THIS FILE <<<< * * Sets up the theme and provides some helper functions. Some helper functions * are used in the theme as custom template tags. Others are attached to action and * filter hooks in WordPress to change core functionality. * * The first function, aweaver_setup(), sets up the theme by registering support * for various features in WordPress, such as post thumbnails, navigation menus, and the like. * * This file formatted 4/8 on tabs * * >>>> DO NOT EDIT THIS FILE <<<< */ add_action( 'after_setup_theme', 'aweaver_setup' ); // run aweaver_setup() when the 'after_setup_theme' hook is run if ( ! function_exists( 'aweaver_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 post thumbnails. * * To override aweaver_setup() in a child theme, add your own aweaver_setup to your child theme's * functions.php file. * * @uses load_theme_textdomain() For translation/localization support. * @uses add_editor_style() To style the visual editor. * @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats. * @uses register_nav_menus() To add support for navigation menus. * @uses register_default_headers() To register the default custom header images provided with the theme. * @uses set_post_thumbnail_size() To set a custom post thumbnail size * @uses add_theme_support( 'custom-header', $aweaver_header ) for WP 3.4+ custom header * * */ function aweaver_setup() { if ( ! isset( $content_width ) ) $content_width = (int)(ABSOLUTE_WVR_THEME_WIDTH * .75); // 1100 * .75 - default for content with a sidebar /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. */ load_theme_textdomain('absolute-weaver' , get_template_directory() . '/languages' ); // now theme's translations as fallback // ******** add theme support possibilities ******** // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); // Let WordPress manage the document title. add_theme_support( 'title-tag' ); // Enable support for Post Thumbnails on posts and pages. add_theme_support( 'post-thumbnails' ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); // html5 for search // future: comment-form, comment-list, gallery, caption add_theme_support( 'html5', array( 'search-form' ) ); // Add support for responsive embedded content. add_theme_support( 'responsive-embeds' ); // gutenberg // Add support for a variety of post formats (not supported: chat) - NOT Absolute Weaver // now, need Absolute Weaver settings available for everything else aweaver_init_opts('functions'); // Now add all the support needed for the editor - both classic and block editor // Absolute Weaver provides its own block styles, so we don't want to include // add_theme_support( 'wp-block-styles' ); // because it pulls in wp-incudes/css/dist/block-library/theme.min.css // Add support for default block styles. add_theme_support( 'wp-block-styles' ); // Add support for full and wide align images. add_theme_support( 'align-wide' ); // Add support for editor styles. add_theme_support( 'editor-styles' ); if (aweaver_getopt('_hide_editor_style')) { // Enqueue editor styles - without theme editor styles add_editor_style( array ( 'editor-style.css', // classic editor 'assets/css/blocks-editor-base-style'.ABSOLUTE_WVR_MINIFY.'.css', // gutenberg ABSOLUTE_WVR_GOOGLE_FONTS_URL)); // from settings.php - in %7C format } else { aweaver_check_editor_style(); // see if we need an update... $updir = wp_upload_dir(); $css_path = trailingslashit($updir['baseurl']) . 'absolute-wvr-css/editor-early-style-awvr.css'; // Enqueue editor styles - without theme editor styles add_editor_style( array ( 'editor-style.css', // classic editor 'assets/css/blocks-editor-base-style'.ABSOLUTE_WVR_MINIFY.'.css', // gutenberg $css_path, ABSOLUTE_WVR_GOOGLE_FONTS_URL)); // from settings.php - in %7C format } //add_theme_support( 'responsive-embeds' ); aweaver_dark_theme_check(); // add Block Editor dark theme support if theme settings have dark bg $width = aweaver_getopt_default('theme_width_int',ABSOLUTE_WVR_THEME_WIDTH); $height = aweaver_getopt_default('header_image_height_int',188); // now that everything is responsive, we can just set this to an arbitrary height. // Enable support for custom logo. add_theme_support( 'custom-logo', array( 'height' => $height, 'width' => $width, 'flex-height' => true, ) ); $aweaver_header = array( 'default-image' => '%s/assets/images/headers/winter-fog.jpg', 'random-default' => true, 'width' => $width, 'height' => $height, 'flex-height' => true, 'flex-width' => true, 'default-text-color' => '', 'header-text' => false, 'uploads' => true, 'video' => true, 'wp-head-callback' => '', 'admin-head-callback' => 'aweaver_admin_header_style', 'admin-preview-callback' => '', ); global $content_width; $content_width = $width; // let the WP $content_width be the same as theme width, and let our responsive CSS make it work. if (function_exists('get_custom_header')) { add_theme_support( 'custom-header', $aweaver_header); add_theme_support( 'custom-background'); } // We'll be using post thumbnails for custom header images on posts and pages. // We want them to be the size of the header image that we just defined // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. // CHANGE NOTE: This call was removed from Absolute Weaver 1.1. The semantics of WP have changed // since this was first added and was causing the unnecessary auto-generation of a pretty large // file for each and every image added to the media library. // set_post_thumbnail_size( $aweaver_header['width'], $aweaver_header['height'], true ); // ... and thus ends the changeable header business. aweaver_register_header_images(); // Absolute Weaver supports two main nav menus register_nav_menus( array( 'primary' => __('Primary Navigation: if specified, used instead of Default menu', 'absolute-weaver' /*adm*/), 'header-mini' => __('Header Mini Menu: if specified, adds horizontal mini-menu to header', 'absolute-weaver' /*adm*/), ) ); } endif; // aweaver_setup //-- if ( ! function_exists('aweaver_init_opts')) : function aweaver_init_opts($who='') { // this sets either the current settings, or the default values. aweaver_clear_opt_cache('aweaver_init_opts'); // start with a clear cache $themename = aweaver_getopt('themename'); // load the theme from the db if there (aweaver_getopt loads the options if there) if ($themename === false) { require_once('includes/get-default-settings.php'); // load a set of defaults aweaver_get_default_settings(); } // Keep some info for max_input_vars detection. These have to be collected here because the // WP settings API clears $_POST after the after_setup_theme action $GLOBALS['ABSOLUTE_WVR_POSTS'] = count($_POST, COUNT_RECURSIVE); // count all elements $GLOBALS['ABSOLUTE_WVR_GETS'] = count($_GET, COUNT_RECURSIVE); $GLOBALS['ABSOLUTE_WVR_COOKIES'] = count($_COOKIE, COUNT_RECURSIVE); } endif; //-- if ( ! function_exists('aweaver_dark_theme_check')) : function aweaver_dark_theme_check() { $bg = ''; if ( ($val = aweaver_getopt_default('editor_bgcolor','inherit')) && $val != 'inherit') { /* alt bg color */ $bg = $val; } else if ( ($val = aweaver_getopt_default('content_bgcolor','inherit')) && $val != 'inherit') { /* #content */ $bg = $val; } else if ( ($val = aweaver_getopt_default('container_bgcolor','inherit') ) && $val != 'inherit') { /* #container */ $bg = $val; } else if (($val = aweaver_getopt_default('wrapper_bgcolor','inherit')) && $val != 'inherit') { /* #wrapper */ $bg = $val; } else if (($val = aweaver_getopt_default('body_bgcolor','inherit')) && $val != 'inherit') { /* Outside BG */ $bg = $val; } else if (($name = aweaver_getopt('themename')) && strpos($name,'Transparent Dark') !== false) { // fix in V3.0.5 $bg = '#222'; } // now decide if we need to add alternate styling for the editor icons $need_alt = $bg && $bg[0] != '#'; // always use alt styling for non-hex bg colors if ( !$need_alt ) { // Normalize a proper hex string with length 6 = but assume started as a #hex $hex = preg_replace("/[^0123456789abcdef]/", '',strtolower($bg)); if ( strlen( $hex ) == 3 ) $hex = preg_replace("/(.)(.)(.)/", '\1\1\2\2\3\3', $hex); if ( preg_match('/^[0123456789abcdef]{6}$/', $hex) ) { // have a valid hex string if ( hexdec($hex) < hexdec( '888888' ) ) // hex values less than #888888 are "dark" $need_alt = true; } } if ($need_alt ) { add_theme_support( 'dark-editor-style' ); } } endif; // dark theme check //-- /** */ if (! function_exists( 'aweaver_register_header_images')) : function aweaver_register_header_images() { // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers( array( 'maroon-bells' => array( 'url' => '%s/assets/images/headers/maroon-bells.jpg', 'thumbnail_url' => '%s/assets/images/headers/maroon-bells-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Maroon Bells', 'absolute-weaver' /*adm*/) ), 'beckwith-mtn' => array( 'url' => '%s/assets/images/headers/beckwith-mtn.jpg', 'thumbnail_url' => '%s/assets/images/headers/beckwith-mtn-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Colorado Autumn', 'absolute-weaver' /*adm*/) ), 'winter-fog' => array( 'url' => '%s/assets/images/headers/winter-fog.jpg', 'thumbnail_url' => '%s/assets/images/headers/winter-fog-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Wintery Fog', 'absolute-weaver' /*adm*/) ) ) ); } endif; //-- if ( ! function_exists( 'aweaver_admin_header_style' ) ) { /** * Styles the header image displayed on the Appearance > Header admin panel. */ function aweaver_admin_header_style() { ?> $name, 'id' => $id, 'description' => $desc, 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } } //-- // ================================ Absolute Weaver admin ================================ add_action('wp_head', 'aweaver_wp_head'); /** * Theme wphead generation * * @since Absolute Weaver 1.0 * */ function aweaver_wp_head() { // action definition require_once('includes/wphead.php'); aweaver_generate_wphead(); } //-- if (!function_exists('aweaver_enqueue_styles')) { /** * Enqueue theme stylesheets * * @since Absolute Weaver 1.0 * */ function aweaver_enqueue_styles() { // Add stylesheets $sheet = get_template_directory_uri() . '/assets/css/fonts'.ABSOLUTE_WVR_MINIFY.'.css'; wp_enqueue_style('aweaver-font-sheet',$sheet,array(),ABSOLUTE_WVR_VERSION,'all'); // Start with the "real" stylesheet (so child theme style.css can override) $sheet = get_template_directory_uri() . '/assets/css/'. ABSOLUTE_WVR_STYLE_FILE . ABSOLUTE_WVR_MINIFY.'.css'; wp_enqueue_style('aweaver-style-sheet',$sheet,array('aweaver-font-sheet'),ABSOLUTE_WVR_VERSION,'all'); // Only add style.css if a child theme if ( is_child_theme() ) { // don't bother with empty main style.css $sheet_dev = get_stylesheet_directory_uri() . '/style.css'; // get style.css $sheet = str_replace('.css', ABSOLUTE_WVR_MINIFY.'.css',$sheet_dev); // default sheet $sheet_file = get_stylesheet_directory() . '/style' . ABSOLUTE_WVR_MINIFY . '.css'; if (! @file_exists($sheet_file)) $sheet = $sheet_dev; // no style.min.css available (need this check for child themes) wp_enqueue_style( 'aweaver-root-style-sheet', $sheet, array('aweaver-style-sheet'), ABSOLUTE_WVR_VERSION, 'all'); } if ( !aweaver_use_inline_css( aweaver_get_css_filename() ) ) { // generate inline CSS $vers = aweaver_getopt('style_version'); if (!$vers) $vers = '1'; else $vers = sprintf("%d",$vers); $sheet = aweaver_get_css_url(); wp_enqueue_style('aweaver-gen-style-sheet',$sheet,array(),$vers,'all'); } } } //-- add_action('wp_enqueue_scripts', 'aweaver_enqueue_styles', 11 ); // styles in normal order add_action('wp_enqueue_scripts', 'aweaver_enqueue_scripts', 8 ); // early priority so load before most other scripts (added: 3.1.7) /** * Enqueue theme scripts * * @since Absolute Weaver 1.0 * */ function aweaver_enqueue_scripts() { // action definition //aweaver_enqueue_styles(); // add the styles // need to know the page template for some conditional script inclusion global $aweaver_cur_template; $aweaver_cur_template = (is_page()) ? get_page_template() : 'nonpage'; if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } //-- Absolute Weaver js lib - requires jQuery... // put this one in to enhance performance slightly for menu fix-up wp_enqueue_script('aweaverJSLib', get_template_directory_uri() . '/assets/js/weaverxjslib'.ABSOLUTE_WVR_MINIFY.'.js', array('jquery'), ABSOLUTE_WVR_VERSION); $useSM = aweaver_getopt('use_smartmenus') ? '1' : '0'; if ( $useSM ) wp_enqueue_script('aweaverSMLib', get_template_directory_uri() . '/assets/js/smartmenus/jquery.smartmenus'.ABSOLUTE_WVR_MINIFY.'.js', array('jquery'),ABSOLUTE_WVR_VERSION); $altsw = aweaver_getopt('mobile_alt_switch'); if ($useSM == '0' || $altsw < 10 ) $altsw = '767'; $altLabel = aweaver_getopt('mobile_alt_label'); global $post; if (!aweaver_get_cur_page_id() && is_object($post)) aweaver_set_cur_page_id( get_the_ID() ); // this must go before aweaver_get_video_render() call $local = array( 'useSmartMenus' => $useSM, 'menuAltswitch' => $altsw, 'mobileAltLabel' => $altLabel, 'primaryScroll' => aweaver_getopt('m_primary_fixedtop'), 'secondaryScroll' => 'none', // need to keep to make script work 'headerVideoClass' => aweaver_get_video_render() ); wp_localize_script('aweaverJSLib', 'wvrxOpts', $local ); wp_enqueue_script('aweaverJSLibEnd', get_template_directory_uri().'/assets/js/weaverxjslib-end'.ABSOLUTE_WVR_MINIFY.'.js',array('jquery'), ABSOLUTE_WVR_VERSION,true); } //-- // Load files required to make the theme work! require_once(get_template_directory() . '/settings.php'); // settings stay in theme root directory require_once(get_template_directory() . '/includes/lib-content.php'); // page/post display support require_once(get_template_directory() . '/includes/lib-runtime.php'); // standard runtime library require_once(get_template_directory() . '/includes/lib-layout.php'); // content layout support require_once(get_template_directory() . '/includes/filters.php'); // other filter and action definitions if (is_user_logged_in() ) { require_once(get_template_directory() . ABSOLUTE_WVR_ADMIN_DIR . '/load-admin-core.php'); // load admin files require_once(get_template_directory() . ABSOLUTE_WVR_ADMIN_DIR . '/wvrx-editor-style.php'); // the editor file generator require_once( trailingslashit( get_template_directory() ) . 'admin/customizer/trt-customize-pro/trt-customize-pro-top.php' ); } do_action('aweaver_load_admin'); // now load the tradtional admin from plugin if loaded, otherwise basic info do_action('aweaver_load_customizer'); // load the customizer based option inteface. // ============================== MORE WEAVER THEME ACTIONS =================== remove_filter( 'nav_menu_description', 'strip_tags' ); add_filter( 'wp_setup_nav_menu_item', 'aweaver_wp_setup_nav_menu_item' ); /** * Filter: Allow HTML descriptions in WordPress Menu * * @since Absolute Weaver pre-3.0 * */ function aweaver_wp_setup_nav_menu_item( $menu_item ) { $menu_item->description = apply_filters( 'nav_menu_description', $menu_item->post_content ); return $menu_item; } /** * Add theme support for infinite scroll * * @uses add_theme_support * @action after_setup_theme */ function aweaver_infinite_scroll_init() { add_theme_support( 'infinite-scroll', array( 'container' => 'content', 'type' => 'click', 'render' => 'aweaver_render_infinite_scroll', ) ); } add_action( 'after_setup_theme', 'aweaver_infinite_scroll_init' ); function aweaver_render_infinite_scroll() { $GLOBALS['aweaver_page_who'] = 'blog'; $num_cols = aweaver_getopt('blog_cols'); if (!$num_cols || $num_cols > 3) $num_cols = 1; $col = 0; /* Start the Loop */ aweaver_post_count_clear(); echo '
'; while ( have_posts() ) { the_post(); aweaver_post_count_bump(); switch ($num_cols) { case 1: get_template_part( 'templates/content', get_post_format() ); $sticky_one = false; break; case 2: $col++; echo ('
' . "\n"); get_template_part( 'templates/content', get_post_format() ); echo ("
\n"); $sticky_one = false; break; case 3: $col++; echo ('
' . "\n"); get_template_part( 'templates/content', get_post_format() ); echo ("
\n"); $sticky_one = false; break; default: get_template_part( 'templates/content', get_post_format() ); $sticky_one = false; } // end switch num cols } // end while have posts echo "
\n"; // fix 3.1.3 } function aweaver_infinite_scroll_settings($js_settings) { $js_settings['text'] = __('Load more posts…', 'absolute-weaver'); return $js_settings; } add_filter( 'infinite_scroll_js_settings', 'aweaver_infinite_scroll_settings'); if (!function_exists('aweaver_increase_max_srcset_image_width')) { /** * Increase the maximum image width to be included in a 'srcset' attribute. * * @param int $max_width The maximum image width to be included in the 'srcset'. Default '1600'. * @return int Filtered maximum image width. */ function aweaver_increase_max_srcset_image_width( $max_width ) { return ($max_width <= 1920) ? 1920 : $max_width; } add_filter( 'max_srcset_image_width', 'aweaver_increase_max_srcset_image_width' ); } // Checking if WooCommerce is active, load support if it is if ( class_exists( 'WooCommerce' ) ) { require_once('woocommerce_support.php'); } // THE END OF functions.php ?>