loading...

Theme Setup

WordPress is highly configurable. There are multiple settings that can be modified or refined, enabled or disabled. By default WordPress enables a subset of features. Some of these can be turned off and others turned on. Some are specific to the Admin UI customizer.

For more information see: https://developer.wordpress.org/reference/functions/add_theme_support/.

Bootstrap

The iPress theme has a number of configurable constant values that can be changed depending on what you decide the overall theme name to be called. These are in the bootstrap.php file of the child & standalone themes.

As of yet WordPress can not use a variable as a language definition, which is more of a PHP limitation. See the languages section for more details.

Configuration

The sections below will take you through the options available for theme setup. The Custom Hooks section in the configuration file is where these hooks should be placed.

Content Width:

Required default content width for image manipulation. Requires integer value. Default, 1200.


// Set content width for image manipulation
add_filter( 'ipress_content_width', function() {
  return 960;
} );
    

Post Thumbnails:

By default post thumbnails support is active. This is initially only enabled for the ‘post’ post-type. Additional post-types can be added as a parameter. Requires an array value.


// Set thumbnail post types, default post
add_filter( 'ipress_post_thumbnails_post_types', function() { 
  return [ 'post', 'course' ];
);
    

Post Thumbnails Size:

The default post thumbnail size can be manipulated by setting the width, height, and crop values. Requires an array value.


// Set thumbnail default size: width, height, crop
add_filter( 'ipress_post_thumbnail_size', function() { 
  return [
    50, 50, [ 'center', 'center' ]
  ];
);
    

Core Image Sizes:

The default WordPress creates a set of image sizes from an imported large image: ‘large’, ‘medium’, ‘medium_large’, ‘thumbnail’. This can be changed. Use with caution. Requires an array value.


// Core image sizes overrides
add_filter( 'ipress_image_size_default, function() { 
  return [
    'large',
    'medium',
    'thumbnail'
  ];
);
    

Add Image Sizes:

Add a custom image size. This adds to the image sizes set internally by WordPress and externally by plugins. Creates images of a set size when full size images are imported. Requires an array: name, width, height, crop. Height & crop are optional. See definitions above.


// Add custom image size, override at lower priority
add_filter( 'ipress_add_image_size', function() {
 return [
    'ipress_small' => [ 200, 150, true ],
    'ipress_square' => [ 500, 500 ]
  ];
} );
    

Use big images:

Turn off big image support, from WP 5.3. Requires a boolean, false


// Turn off big image support, override at lower priority
add_filter('ipress_big_image_size', '__return_false' );
    

Set Navigation menus:

Register default menu locations, override at lower priority. Requires an array: name, description.


// Register default menu locations, override at lower priority
add_filter( 'ipress_nav_menus', function() {
  return [
    'primary' => __( 'Primary Menu', 'ipress' ),
    'footer-nav-1' => __( 'Footer column navigation 1', 'ipress' ),
    'footer-nav-2' => __( 'Footer column navigation 2', 'ipress' ),
    'footer-nav-3' => __( 'Footer column navigation 3', 'ipress' ),
    'footer-nav-4' => __( 'Footer column navigation 4', 'ipress' )
  ];
} );
    

Enable HTML5 support:

Enable support for HTML5 markup. Requires an array. Valid options: ‘search-form’, ‘comment-form’, ‘comment-list’, ‘gallery’, ‘caption’, ‘widgets’, script’, ‘style’, ‘editor-styles’, ‘align-wide’. Defaults to: ‘search-form’, ‘comment-form’, ‘comment-list’, ‘gallery’, ‘caption’, ‘script’, ‘style’, ‘widgets’.


// Enable support for HTML5 markup, override at lower priority
add_filter( 'ipress_html5', function() {
  return [ 'search-form', 'comment-form', 'comment-list', 'gallery' ];
} );
    

Enable post-format support:

Add post-format support. Requires an array. Valid options: ‘aside’, ‘image’, ‘video’, ‘quote’, ‘link’, ‘gallery’, ‘status’, ‘audio’, ‘chat’. Default, none.


// Enable support for post-formats, override at lower priority
add_filter( 'ipress_post_formats', function() {
  return [ 'aside', 'image', 'gallery' ];
} );
    

Enable theme support:

Custom plugin & feature support, e.g. Guttenberg wide image alignment, embeds & block styles. Requires an array. See https://developer.wordpress.org/reference/functions/add_theme_support/ for more details.


// Enable theme support, override at lower priority
add_filter( 'ipress_theme_support', function() {
  return [ 'align-wide', 'responsive-embeds' ];
} );
    

Disable theme support:

Remove enabled custom plugin & feature support, e.g. Guttenberg wide image alignment, embeds & block styles. Requires an array. See https://developer.wordpress.org/reference/functions/remove_theme_support/ for more details.


// Disable theme support, override at lower priority
add_filter( 'ipress_remove_theme_support', function() {
  return [ 'align-wide', 'responsive-embeds' ];
} );
    

Custom title tag support:

Theme support for Title tag is enabled by default. This property also adds specific features to the title tag. Legacy functionality. Probably not needed in light of the many powerful and ubiquitous SEO plugins that do the same thing via a dedicated admin UI. Default, false/off.


// Custom title tag features, override at lower priority
add_filter( 'ipress_custom_title_tag', '__return_true' );

// Set title separator
add_filter( 'ipress_document_title_separator', function() {
  return '-';
} );

// Append or prepend?
add_filter( 'ipress_home_doctitle_append', '__return_true' );

// Set doctitle separator
add_filter( 'ipress_doctitle_separator', function() {
  return '|';
} );
    

Customizer

The WordPress customizer is a modern method for real-time modification of theme pages. There are a number of optional sections to the customizer that can be enabled & disabled as needed. The sections below will take you through the options available for theme customizer setup. The Custom Hooks section in the configuration file is where these hooks should be placed.

Custom Logo Support:

Enable support for custom logo within customizer and theme. See https://developer.wordpress.org/themes/functionality/custom-logo/. This is enabled by default. Additional parameters can be set to modify the default logo dimensions.


// Set custom logo parameters
add_filter( 'ipress_custom_logo_args', function() {
  return [
    'width' => 360,
    'height' => 200
  ];
} );
    

Custom Header Support:

Enable support for custom header within customizer and theme. See https://developer.wordpress.org/themes/functionality/custom-header/. This is not enabled by default. Additional parameters can be set to modify the default header image & dimensions.


// Enable custom header
add_filter( 'ipress_custom_header', '__return_true' );

// Set custom header default image, requires custom header to be active
add_filter( 'ipress_custom_header_default_image', function() {
  return $image_url;
} );

// Set custom header parameters, required custom header to be active
add_filter( 'ipress_custom_header_args', function() {
  return [
    'header-text' => true,
    'width' => 1740,
    'height' => 360
  ];
} );

// Force custom header uploads, requires custom headers to be active
add_filter( 'ipress_custom_header_uploads', '__return_true' );

// Filterable default header settings, requires custom headers to be active
add_filter( 'ipress_default_headers', '__return_true' );

// Set custom header parameters, required custom header to be active
add_filter( 'ipress_default_header_args', function() {
  'ipress_default_header_args', [
    'default-image' => [
    'url'           => '%s/assets/images/header.jpg',
    'thumbnail_url' => '%s/assets/images/header.jpg',
    'description'   => __( 'Default Header Image', 'ipress' ),
  ]
} );
    

Custom Background Support:

Enable support for custom background within customizer and theme. See https://developer.wordpress.org/themes/functionality/custom-background/. This is not enabled by default. Additional parameters can be set to modify the default background image & dimensions.


// Enable custom background
add_filter( 'ipress_custom_background', '__return_true' );

// Set custom background default image, requires custom background to be active
add_filter( 'ipress_custom_background_default_image', function() {
  return $image_url;
} );

// Set custom background default color, requires custom background to be active
add_filter( 'ipress_custom_background_default_color', function() {
  return '#eee';
} );

// Set custom background parameters, required custom background to be active
add_filter( 'ipress_custom_background_args', function() {
  return [
    'default-image' => esc_url_raw( $image_url ),
    'default-color' => '#aaa'
  ];
} );
    

Selective refresh:

Add theme support for selective refresh for widgets, default true


// Disable selective refresh
add_filter( 'ipress_custom_selective_refresh', '__return_false' );
    

Header partials:

Dynamic refresh for header partials, default true. Requires selective refresh to be active.


// Disable header partials
add_filter( 'ipress_customize_header_partials', '__return_false' );
    

Register control types:

Register external customizer control types for dynamic JS access. Requires array.


// Register control type
add_filter( 'ipress_customize_register_control_type, function() {
  return [];
} );
    

Register control section:

Register external customizer control sectiom for dynamic JS access. Requires array.


// Register control sectiom
add_filter( 'ipress_customize_register_control_section, function() {
  return [];
} );
    

Customizer custom JS settings:

Register external customizer control section for dynamic JS access. Use with extreme caution.


// Enable customizer JS sections, requires boolean
add_filter( 'ipress_custom_js, '__return_true' );
    

Editor

Adds callback for custom TinyMCE editor stylesheets. Allows theme developers to link a custom stylesheet file to the TinyMCE visual editor.

Editor styles:

Enable customisable editor styles & theme support? Default, true.


// Enable editor styles support, requires boolean
add_filter( 'ipress_editor_styles', '__return_true' );

// Register editor font sizes, requires editor styles to be active
add_filter( 'ipress_editor_font_sizes', function() {
  return [
    [
      'name' => __( 'Large', 'ipress' ),
      'size' => 28,
      'slug' => 'large'
    ],
    [
      'name' => __( 'Big', 'ipress' ),
      'size' => 32,
      'slug' => 'big'
    ],
  ];
} );

// Register editor font styles, requires editor styles to be active
add_filter( 'ipress_editor_styles_url', function() {
  return esc_url_raw( $url );
} );
    

Body

The body_class function is normally placed inside the html tag. WordPress injects specific classes based on post & page type, and available functionality. The iPress theme can modify this class sequence prior to display

Body class:

Modify the available classes injected into the page body tag.


// Modify body classes, always return the existing classes value
add_filter( 'ipress_body_class', function( $classes ) {
	
  // Front Page
  if ( is_front_page() ) {
    $classes[] = 'is-front-page';
  }

  // 404 page
  if ( is_404() ) {
    $classes[] = 'is-page-404';
  }

  // Case Studies
  if ( is_singular( 'case_studies' ) ) {
    $parent_id = get_page_by_path( 'case-studies' )->ID;
    $parent_name = 'case-studies';
    $classes[] = 'case-study-single';
    $classes[] = 'parent_id-' . $parent_id;
    $classes[] = 'parent_name-' . $parent_name; 
  }

  return $classes;
} );
    

Scroll back to top