>>> 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... $vers = aweaver_getopt( 'style_version' ); if ( ! $vers ) { $vers = '1'; } else { $vers = sprintf( "%d", $vers ); } $updir = wp_upload_dir(); $css_path = trailingslashit( $updir['baseurl'] ) . 'absolute-wvr-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_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' ); } // 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. // 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' => 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; // 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 ( Not a template file ) 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; } elseif ( ( $val = aweaver_getopt_default( 'content_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* #content */ $bg = $val; } elseif ( ( $val = aweaver_getopt_default( 'container_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* #container */ $bg = $val; } elseif ( ( $val = aweaver_getopt_default( 'wrapper_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* #wrapper */ $bg = $val; } elseif ( ( $val = aweaver_getopt_default( 'body_bgcolor', 'inherit' ) ) && $val != 'inherit' ) { /* Outside BG */ $bg = $val; } elseif ( ( $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' => 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' ), ), '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' => esc_html__( 'Wintery Fog', 'absolute-weaver' ), ), ) ); } 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' => '