>>> 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. * * The first function, absolute_weaver_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', 'absolute_weaver_setup' ); // run absolute_weaver_setup() when the 'after_setup_theme' hook is run if ( ! function_exists( 'absolute_weaver_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 absolute_weaver_setup() in a child theme, add your own absolute_weaver_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', $absolute_weaver_header ) for WP 3.4+ custom header * * */ function absolute_weaver_setup() { if ( ! isset( $GLOBALS['content_width'] ) ) { $GLOBALS['content_width'] = ( int ) ( ABSOLUTE_WEAVER_THEME_WIDTH * .75 ); } /* * 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 absolute_weaver_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-includes/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 ( absolute_weaver_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_WEAVER_MINIFY . '.css', // gutenberg ABSOLUTE_WEAVER_GOOGLE_FONTS_URL, ) ); // from settings.php - in %7C format } else { absolute_weaver_check_editor_style(); // see if we need an update... $vers = absolute_weaver_getopt( 'style_version' ); if ( ! $vers ) { $vers = '1'; } else { $vers = sprintf( "%d", $vers ); } $updir = wp_upload_dir( null, true, true ); // force cache update to avoid bug after moving hosts $css_path = trailingslashit( $updir['baseurl'] ) . 'absolute-weaver-css/editor-early-style-awvr.css?vers=' . $vers; // Enqueue editor styles - without theme editor styles add_editor_style( array( 'editor-style.css', // classic editor 'assets/css/blocks-editor-base-style' . ABSOLUTE_WEAVER_MINIFY . '.css', // gutenberg $css_path, ABSOLUTE_WEAVER_GOOGLE_FONTS_URL, ) ); } absolute_weaver_dark_theme_check(); // add Block Editor dark theme support if theme settings have dark bg $width = absolute_weaver_getopt_default( 'theme_width_int', ABSOLUTE_WEAVER_THEME_WIDTH ); $height = absolute_weaver_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, ) ); $absolute_weaver_header_args = array( 'default-image' => '%s/assets/images/headers/Maroon-Bells.jpg', 'random-default' => true, 'width' => $width, 'height' => $height, 'flex-height' => true, 'flex-width' => true, 'default-text-color' => '', 'header-text' => false, 'uploads' => true, 'video' => false, 'wp-head-callback' => '', 'admin-head-callback' => 'absolute_weaver_admin_header_style', 'admin-preview-callback' => '', ); $GLOBALS['content_width'] = $width; // let the WP $content_width be the same as theme width, and let our responsive CSS make it work. add_theme_support( 'custom-header', $absolute_weaver_header_args ); add_theme_support( 'custom-background' ); // Report all errors except E_NOTICE error_reporting( E_ALL & ~E_WARNING ); // 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. absolute_weaver_register_header_images(); // Absolute Weaver supports two main nav menus register_nav_menus( array( 'primary' => esc_html__( 'Primary Navigation: if specified, used instead of Default menu', 'absolute-weaver' ), 'header-mini' => esc_html__( 'Header Mini Menu: if specified, adds horizontal mini-menu to header', 'absolute-weaver'), ) ); } endif; // absolute_weaver_setup //-- if ( ! function_exists( 'absolute_weaver_init_opts' ) ) : function absolute_weaver_init_opts( $who = '' ) { // this sets either the current settings, or the default values. absolute_weaver_clear_opt_cache( 'absolute_weaver_init_opts' ); // start with a clear cache $themename = absolute_weaver_getopt( 'themename' ); // load the theme from the db if there ( absolute_weaver_getopt loads the options if there ) if ( $themename === false ) { require_once( get_template_directory() . '/inc/get-default-settings.php' ); // load a set of defaults ( Not a template file ) absolute_weaver_get_default_settings(); } if ( ABSOLUTE_WEAVER_SMARTMENUS_DEFAULT ) absolute_weaver_setopt( 'use_smartmenus', true ); } endif; //-- if ( ! function_exists( 'absolute_weaver_dark_theme_check' ) ) : function absolute_weaver_dark_theme_check() { $bg = ''; if ( ( $val = absolute_weaver_getopt_default( 'editor_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* alt bg color */ $bg = $val; } elseif ( ( $val = absolute_weaver_getopt_default( 'content_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* #content */ $bg = $val; } elseif ( ( $val = absolute_weaver_getopt_default( 'container_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* #container */ $bg = $val; } elseif ( ( $val = absolute_weaver_getopt_default( 'wrapper_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* #wrapper */ $bg = $val; } elseif ( ( $val = absolute_weaver_getopt_default( 'body_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* Outside BG */ $bg = $val; } elseif ( ( $name = absolute_weaver_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( 'absolute_weaver_register_header_images' ) ) : function absolute_weaver_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' => esc_html__( 'Maroon Bells', 'absolute-weaver' ), ), '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' => esc_html__( 'Colorado Autumn', 'absolute-weaver' ), ), 'arctic-aurora' => array( 'url' => '%s/assets/images/headers/grand-mesa.jpg', 'thumbnail_url' => '%s/assets/images/headers/grand-mesa-thumbnail.jpg', /* translators: header image description */ 'description' => esc_html__( 'Grand Mesa', 'absolute-weaver' ), ), ) ); } endif; //-- if ( ! function_exists( 'absolute_weaver_admin_header_style' ) ) { /** * Styles the header image displayed on the Appearance > Header admin panel. */ function absolute_weaver_admin_header_style() { ?> $name, 'id' => $id, 'description' => $desc, 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } } //-- // ================================ Absolute Weaver admin ================================ add_action( 'wp_head', 'absolute_weaver_wp_head_action' ); /** * Theme wphead generation * * @since Absolute Weaver 1.0 * */ function absolute_weaver_wp_head_action() { // action definition require_once( get_template_directory() . '/inc/wphead.php' ); // ( Not a template file ) absolute_weaver_generate_wphead(); } //-- if ( ! function_exists( 'absolute_weaver_enqueue_styles_action' ) ) { /** * Enqueue theme stylesheets * * @since Absolute Weaver 1.0 * */ function absolute_weaver_enqueue_styles_action() { // Add stylesheets do_action( 'absolute_weaver_g_fonts', 'absolute_weaver_g_fonts' ); // enqueue Google Fonts $sheet = get_template_directory_uri() . '/assets/css/fonts' . ABSOLUTE_WEAVER_MINIFY . '.css'; wp_enqueue_style( 'absolute-weaver-font-sheet', $sheet, array(), ABSOLUTE_WEAVER_VERSION, 'all' ); // Start with the "real" stylesheet ( so child theme style.css can override ) $sheet = get_template_directory_uri() . '/assets/css/' . ABSOLUTE_WEAVER_STYLE_FILE . ABSOLUTE_WEAVER_MINIFY . '.css'; wp_enqueue_style( 'absolute-weaver-style-sheet', $sheet, array( 'absolute-weaver-font-sheet' ), ABSOLUTE_WEAVER_VERSION, 'all' ); // Now add generated style rules $generated_style = '/* Absolute Weaver Generated Style */' . absolute_weaver_get_generated_style(); wp_add_inline_style('absolute-weaver-style-sheet', $generated_style); // Only add style.css if a child theme if ( is_child_theme() ) { // don't bother with empty main style.css $sheet = get_stylesheet_directory_uri() . '/style.css'; // get style.css wp_enqueue_style( 'absolute-weaver-root-style-sheet', $sheet, array( 'absolute-weaver-style-sheet' ), ABSOLUTE_WEAVER_VERSION, 'all' ); } } } //-- add_action( 'wp_enqueue_scripts', 'absolute_weaver_enqueue_styles_action', 11 ); // styles in normal order add_action( 'wp_enqueue_scripts', 'absolute_weaver_enqueue_scripts_action', 8 ); // early priority so load before most other scripts ( added: 3.1.7 ) /** * Enqueue theme scripts * * @since Absolute Weaver 1.0 * */ function absolute_weaver_enqueue_scripts_action() { // action definition //absolute_weaver_enqueue_styles(); // add the styles 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( 'absolute-weaver-JSLib', get_template_directory_uri() . '/assets/js/aweaver-jslib' . ABSOLUTE_WEAVER_MINIFY . '.js', array( 'jquery' ), ABSOLUTE_WEAVER_VERSION ); $useSM = absolute_weaver_getopt( 'use_smartmenus' ) ? '1' : '0'; if ( $useSM ) { wp_enqueue_script( 'jquery.smartmenus', get_template_directory_uri() . '/assets/js/smartmenus/jquery.smartmenus' . ABSOLUTE_WEAVER_MINIFY . '.js', array( 'jquery' ), ABSOLUTE_WEAVER_VERSION ); } $altsw = absolute_weaver_getopt( 'mobile_alt_switch' ); if ( $useSM == '0' || $altsw < 10 ) { $altsw = '767'; } $altLabel = absolute_weaver_getopt( 'mobile_alt_label' ); global $post; if ( ! absolute_weaver_get_cur_page_id() && is_object( $post ) ) { absolute_weaver_set_cur_page_id( get_the_ID() ); } if ( $useSM ) { wp_enqueue_script( 'aweaver-smartmenus', get_template_directory_uri() . '/assets/js/aweaver-smartmenus' . ABSOLUTE_WEAVER_MINIFY . '.js', '', ABSOLUTE_WEAVER_VERSION, true ); // must load at end. } $local = array( 'useSmartMenus' => $useSM, 'menuAltswitch' => $altsw, 'mobileAltLabel' => $altLabel, 'primaryScroll' => absolute_weaver_getopt( 'm_primary_fixedtop' ), 'secondaryScroll' => 'none', // need to keep to make script work ); wp_localize_script( 'absolute-weaver-JSLib', 'AbsoluteWeaverOpts', $local ); wp_enqueue_script( 'absolute-weaver-JSLibEnd', get_template_directory_uri() . '/assets/js/aweaver-jslib-end' . ABSOLUTE_WEAVER_MINIFY . '.js', array( 'jquery' ), ABSOLUTE_WEAVER_VERSION, true ); } //-- // Load files required to make the theme work! require_once( get_template_directory() . '/settings.php' ); // settings stay in theme root directory ( Not a template file ) require_once( get_template_directory() . '/inc/lib-content.php' ); // page/post display support ( Not a template file ) require_once( get_template_directory() . '/inc/lib-runtime.php' ); // standard runtime library ( Not a template file ) require_once( get_template_directory() . '/inc/lib-layout.php' ); // content layout support ( Not a template file ) require_once( get_template_directory() . '/inc/filters.php' ); // other filter and action definitions ( Not a template file ) if ( is_user_logged_in() && (current_user_can( 'edit_themes' ) || current_user_can( 'manage_options' ) ) ) { require_once( get_template_directory() . ABSOLUTE_WEAVER_ADMIN_DIR . '/admin-core/load-admin-core.php' ); // load admin files ( Not a template file ) require_once( get_template_directory() . ABSOLUTE_WEAVER_ADMIN_DIR . '/admin-core/aweaver-editor-style.php' ); // the editor file generator ( Not a template file ) } do_action( 'absolute_weaver_load_admin' ); // now load the traditional admin from plugin if loaded, otherwise basic info do_action( 'absolute_weaver_load_customizer' ); // load the customizer based option interface. // ============================== MORE WEAVER THEME ACTIONS =================== add_filter( 'wp_setup_nav_menu_item', 'absolute_weaver_wp_setup_nav_menu_item_filter' ); /** * Filter: Allow HTML descriptions in WordPress Menu */ function absolute_weaver_wp_setup_nav_menu_item_filter( $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 absolute_weaver_infinite_scroll_action() { add_theme_support( 'infinite-scroll', array( 'container' => 'content', 'type' => 'click', 'render' => 'absolute_weaver_render_infinite_scroll_cb', ) ); } add_action( 'after_setup_theme', 'absolute_weaver_infinite_scroll_init_action' ); function absolute_weaver_render_infinite_scroll_cb() { $GLOBALS['absolute_weaver_page_who'] = 'blog'; $num_cols = absolute_weaver_getopt( 'blog_cols' ); if ( ! $num_cols || $num_cols > 3 ) { $num_cols = 1; } $col = 0; /* Start the Loop */ absolute_weaver_post_count_clear(); echo '
'; while ( have_posts() ) { the_post(); absolute_weaver_post_count_bump(); switch ( $num_cols ) { case 1: get_template_part( 'template-parts/content', get_post_format() ); $sticky_one = false; break; case 2: $col ++; echo( '
' . "\n" ); get_template_part( 'template-parts/content', get_post_format() ); echo( "
\n" ); $sticky_one = false; break; case 3: $col ++; echo( '
' . "\n" ); get_template_part( 'template-parts/content', get_post_format() ); echo( "
\n" ); $sticky_one = false; break; default: get_template_part( 'template-parts/content', get_post_format() ); $sticky_one = false; } // end switch num cols } // end while have posts echo "
\n"; // fix 3.1.3 } function absolute_weaver_infinite_scroll_settings_filter( $js_settings ) { $js_settings['text'] = esc_html__( 'Load more posts…', 'absolute-weaver' ); return $js_settings; } add_filter( 'infinite_scroll_js_settings', 'absolute_weaver_infinite_scroll_settings_filter' ); if ( ! function_exists( 'absolute_weaver_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 absolute_weaver_increase_max_srcset_image_width( $max_width ) { return ( $max_width <= 1920 ) ? 1920 : $max_width; } add_filter( 'max_srcset_image_width', 'absolute_weaver_increase_max_srcset_image_width' ); } // Checking if WooCommerce is active, load support if it is if ( class_exists( 'WooCommerce' ) ) { require_once( get_template_directory() . '/woocommerce-support.php' ); // ( Not a template file ) } // THE END OF functions.php ?>