/wp-content/themes/ravens-egg-2022/inc/theme-support.php
PHP | 367 lines | 87 code | 51 blank | 229 comment | 5 complexity | 5d6b16aa48f8fda0f67d8b509cd586bb MD5 | raw file
- <?php
- /**
- * Theme support
- *
- * @package WordPress
- * @subpackage Ravens_Egg_2022
- * @since 1.0
- * @version 1.0
- */
- namespace ravensegg2022;
- if ( ! function_exists( 'ravensegg_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.
- *
- * @return void
- * @since Ravens_Egg_2022 1.0
- *
- */
- function ravensegg_setup() {
- /*
- * Make theme available for translation.
- * Translations can be filed in the /languages/ directory.
- */
- // load_theme_textdomain( 'ravens-egg-2022', get_template_directory() . '/languages' );
- // Add default posts and comments RSS feed links to head.
- add_theme_support( 'automatic-feed-links' );
- /*
- * Let WordPress manage the document title.
- * This theme does not use a hard-coded <title> tag in the document head,
- * WordPress will 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' );
- set_post_thumbnail_size( 1920, 1240 );
- register_nav_menus(
- array(
- 'primary' => esc_html__( 'The Main Menu', 'ravens-egg-2022' ), // main nav in header
- 'secondary' => __( 'Secondary menu', 'ravens-egg-2022' ),
- 'top' => __( 'Top menu', 'ravens-egg-2022' ),
- 'footer' => __( 'Footer menu', 'ravens-egg-2022' )
- )
- );
- /*
- * Switch default core markup for search form, comment form, and comments
- * to output valid HTML5.
- */
- add_theme_support(
- 'html5',
- array(
- 'comment-form',
- 'comment-list',
- 'gallery',
- 'caption',
- 'style',
- 'script',
- 'navigation-widgets',
- )
- );
- // Add support for responsive embedded content.
- add_theme_support( 'responsive-embeds' );
- // Add theme support for selective refresh for widgets.
- add_theme_support( 'customize-selective-refresh-widgets' );
- // Add support for full and wide align images.
- add_theme_support( 'align-wide' );
- // Add support for editor styles.
- add_theme_support( 'editor-styles' );
- // Add support for Block Styles. Displays default block styles from editor also on front end.
- // add_theme_support( 'wp-block-styles' );
- // Custom background color.
- // add_theme_support(
- // 'custom-background',
- // array(
- // 'default-color' => 'ffffff',
- // )
- // );
- /*
- * Add support for core custom logo.
- *
- * @link https://codex.wordpress.org/Theme_Logo
- */
- // $logo_width = 300;
- // $logo_height = 100;
- //
- // add_theme_support(
- // 'custom-logo',
- // array(
- // 'height' => $logo_height,
- // 'width' => $logo_width,
- // 'flex-width' => true,
- // 'flex-height' => true,
- // 'unlink-homepage-logo' => true,
- // )
- // );
- /**
- * Add post-formats support.
- */
- // add_theme_support(
- // 'post-formats',
- // array(
- // 'link',
- // 'aside',
- // 'gallery',
- // 'image',
- // 'quote',
- // 'status',
- // 'video',
- // 'audio',
- // 'chat',
- // )
- // );
- // Editor color palette.
- // $teal = '#00637a';
- // $aqua = '#77d1e6';
- // $warmGrayLight = '#ebe7e0';
- // $choco = '#615742';
- // $orange = '#f26a13';
- //
- // add_theme_support(
- // 'editor-color-palette',
- // array(
- // array(
- // 'name' => esc_html__( 'Teal', 'ravens-egg-2022' ),
- // 'slug' => 'teal',
- // 'color' => $teal,
- // ),
- // array(
- // 'name' => esc_html__( 'Aqua', 'ravens-egg-2022' ),
- // 'slug' => 'aqua',
- // 'color' => $aqua,
- // ),
- // array(
- // 'name' => esc_html__( 'Warm Gray Light', 'ravens-egg-2022' ),
- // 'slug' => 'warm-gray-light',
- // 'color' => $warmGrayLight,
- // ),
- // array(
- // 'name' => esc_html__( 'Choco', 'ravens-egg-2022' ),
- // 'slug' => 'choco',
- // 'color' => $choco,
- // ),
- // array(
- // 'name' => esc_html__( 'Orange', 'ravens-egg-2022' ),
- // 'slug' => 'orange',
- // 'color' => $orange,
- // ),
- // )
- // );
- // Disables custom colors
- // add_theme_support( 'disable-custom-colors' );
- // Disables custom gradients
- // add_theme_support( 'disable-custom-gradients' );
- // To completely disable gradients, leave preset array empty.
- // add_theme_support( 'editor-gradient-presets', array() );
- // Adds gradient preset(s).
- // add_theme_support( 'editor-gradient-presets', array(
- // array(
- // 'name' => esc_attr__( 'Gray Wash', 'ravens-egg-2022' ),
- // 'gradient' => 'linear-gradient(to right, rgba(128, 128, 128, 1), rgba(192, 192, 192, 1))',
- // 'slug' => 'gray-wash',
- // )
- // ) );
- // Add custom editor font sizes.
- // add_theme_support( 'editor-font-sizes',
- // array(
- // array(
- // 'name' => esc_html__( 'Small', 'ravens-egg-2022' ),
- // 'shortName' => esc_html_x( 'S', 'ravens-egg-2022' ),
- // 'size' => 14,
- // 'slug' => 'small'
- // ),
- // array(
- // 'name' => esc_html__( 'Normal', 'ravens-egg-2022' ),
- // 'shortName' => esc_html_x( 'N', 'ravens-egg-2022' ),
- // 'size' => 16,
- // 'slug' => 'normal'
- // ),
- // array(
- // 'name' => esc_html__( 'Large', 'ravens-egg-2022' ),
- // 'shortName' => esc_html_x( 'M', 'ravens-egg-2022' ),
- // 'size' => 20,
- // 'slug' => 'medium'
- // ),
- // array(
- // 'name' => esc_html__( 'Larger', 'ravens-egg-2022' ),
- // 'shortName' => esc_html_x( 'L', 'ravens-egg-2022' ),
- // 'size' => 23,
- // 'slug' => 'large'
- // ),
- // array(
- // 'name' => esc_html__( 'Huge', 'ravens-egg-2022' ),
- // 'shortName' => esc_html_x( 'XL', 'ravens-egg-2022' ),
- // 'size' => 26,
- // 'slug' => 'huge'
- // )
- // ) );
- // Disables custom font sizes
- // add_theme_support( 'disable-custom-font-sizes' );
- // Add support for custom line height controls.
- // add_theme_support( 'custom-line-height' );
- // Add support for experimental link color control.
- // add_theme_support( 'experimental-link-color' );
- // Add support for experimental cover block spacing.
- // add_theme_support( 'custom-spacing' );
- }
- }
- add_action( 'after_setup_theme', 'ravensegg2022\ravensegg_setup' );
- // Add editor styles with cache busting hash.
- function add_editor_styles() {
- add_editor_style( get_asset_path( 'editor.css' ) );
- }
- add_action( 'init', 'ravensegg2022\add_editor_styles' );
- /**
- * Sets active sidebars and widgetized areas.
- *
- * @return void
- */
- function register_sidebars() {
- $my_sidebars = array(
- array(
- 'name' => 'Sidebar 1',
- 'id' => 'sidebar1',
- 'description' => 'The first (primary) sidebar',
- ),
- array(
- 'name' => 'Sidebar 2',
- 'id' => 'sidebar2',
- 'description' => 'The second (secondary) sidebar',
- ),
- array(
- 'name' => 'Subfooter Widget',
- 'id' => 'subfooter',
- 'description' => 'Subfooter widget, non-sidebar',
- ),
- );
- $defaults = array(
- 'name' => 'Default Sidebar',
- 'id' => 'sidebar-default',
- 'description' => 'This is the default sidebar',
- 'class' => '',
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>'
- );
- foreach ( $my_sidebars as $sidebar ) {
- $args = wp_parse_args( $sidebar, $defaults );
- register_sidebar( $args );
- }
- }
- add_action( 'widgets_init', 'RavensEgg2022\register_sidebars' );
- /**
- * Disables core update notification emails unless update failed.
- *
- * @param $send
- * @param $type
- * @param $core_update
- * @param $result
- *
- * @return false
- */
- function auto_core_update_send_email( $send, $type, $core_update, $result ) {
- if ( ! empty( $type ) && $type == 'success' ) {
- // don't send email
- return false;
- }
- // use default settings
- return $send;
- }
- add_filter( 'auto_core_update_send_email', 'ravensegg2022\auto_core_update_send_email', 10, 4 );
- // Disables auto-update email notifications for plugins.
- add_filter( 'auto_plugin_update_send_email', '__return_false' );
- // Disables auto-update email notifications for themes.
- add_filter( 'auto_theme_update_send_email', '__return_false' );
- /**
- * Sets custom thumbnail sizes. Full size is limited by Imsanity plugin to 1920 x 1080.
- * Colorbox restrains lightboxed images to 90% of screen width and height
- */
- //add_image_size( 'xlarge', 1024, 768, false );
- // add_image_size( 'slideshow', 1200, 675, true );
- //add_image_size( 'ravensegg2022-thumb-300', 300, 100, true );
- /**
- * Disables full screen editor by default.
- */
- function disable_editor_fullscreen_by_default() {
- $script = "window.onload = function() { const isFullscreenMode = wp.data.select( 'core/edit-post' ).isFeatureActive( 'fullscreenMode' ); if ( isFullscreenMode ) { wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fullscreenMode' ); } }";
- wp_add_inline_script( 'wp-blocks', $script );
- }
- add_action( 'enqueue_block_editor_assets', 'ravensegg2022\disable_editor_fullscreen_by_default' );
- /**
- * Display unlimited post types per page and sort by random.
- *
- * @param $query
- */
- // function alter_posttype_query( $query ) {
- // /* only proceed on the front end */
- // if ( is_admin() ) {
- // return;
- // }
- // /* only on the posttype post archive for the main query */
- // if ( $query->is_post_type_archive( 'posttype' ) && $query->is_main_query() ) {
- // $query->set( 'posts_per_page', - 1 );
- // // $query->set( 'orderby', 'post_title' );
- // $query->set( 'order', 'ASC' );
- // $query->set( 'orderby', 'rand' );
- // }
- // }
- // add_action( 'pre_get_posts', 'ravensegg2022\alter_posttype_query' );