IM-BASE IM-BASE

お問い合わせ

inc Directory Guide

A developer guide to the PHP feature modules stored in the IM Base inc directory and the boundaries around them.

Overview

The inc directory contains IM Base theme feature modules and reusable PHP classes. Its current modules cover navigation markup, helper functions, asset loading, layout behavior, post-list handling, SEO, sitemaps, shortcodes, the Table of Contents, and the News post type. The directory also includes enqueue-custom.php for creator-defined asset registration.

functions.php is an ordered module loader. It loads administrative files, core files, the inc modules, and the News custom post type with require_once; feature implementation remains in the respective modules rather than in functions.php itself.

  • class-imb-global-nav-walker.php
  • custom-functions.php
  • enqueue.php
  • enqueue-custom.php
  • enqueue-singular-css.php
  • layout.php
  • post-list-layout.php
  • seo.php
  • shortcodes.php
  • sitemap.php
  • table-of-contents.php
  • custom-post-types/news.php

How inc Is Loaded

functions.php loads the theme’s PHP files in four groups. The Admin group loads theme settings and the layout, SEO, and Table of Contents meta-box modules. The Core group loads core/setup.php and core/cleanup.php. The Theme Functions group then loads the reusable helpers, navigation Walker, shortcodes, asset and layout modules, SEO, sitemap, and Table of Contents modules. The Custom Post Types group loads the News post type module.

This sequence loads the files; it does not describe all of their runtime work. core/setup.php registers theme support, loads the theme text domain, and registers the Global and Footer navigation locations through the after_setup_theme hook. The modules under inc contain feature logic, helpers, hooks, filters, and reusable classes, while functions.php remains responsible for loading them in order.

require_once get_theme_file_path('/inc/custom-functions.php');
require_once get_theme_file_path('/inc/shortcodes.php');
require_once get_theme_file_path('/inc/enqueue.php');

File Responsibilities

The navigation markup is generated by class-imb-global-nav-walker.php through IMB_Global_Nav_Walker, which extends Walker_Nav_Menu. custom-functions.php provides reusable helpers for retrieving site images and business information. enqueue.php loads the theme’s standard front-end CSS and JavaScript with wp_enqueue_style() and wp_enqueue_script() on wp_enqueue_scripts; enqueue-custom.php loads creator-defined assets at the same hook with priority 20, and enqueue-singular-css.php loads an optional stylesheet for singular content at priority 30.

layout.php resolves layout settings and provides column, header, scroll-offset, mobile-control, body-class, and sidebar helpers. It adds scroll-offset and custom layout CSS on wp_enqueue_scripts and adds layout classes through body_class. post-list-layout.php provides archive-list titles, descriptions, settings, and rendering through the template-parts/post-list template. seo.php supplies theme meta tags, Open Graph data, canonical handling, and structured data, using wp_head and wp hooks while checking for SEO plugins. sitemap.php customizes the WordPress XML sitemap through filters for post types, taxonomies, post-query arguments, and sitemap providers.

shortcodes.php registers the site_logo, organization, local_business, breadcrumb, news_list, sns_links, and share shortcodes on init, and can capture template-part output for shortcode rendering. table-of-contents.php manages TOC settings, heading extraction and processing, list rendering, the imb_toc shortcode, content filtering through the_content, and the footer drawer through wp_footer. custom-post-types/news.php registers the News post type on init, adds its external-link meta box through add_meta_boxes, and saves the external URL with save_post for that post type.

  • Navigation markup: class-imb-global-nav-walker.php
  • Reusable image and Business Information helpers: custom-functions.php
  • Standard, creator-defined, and singular asset loading: enqueue.php, enqueue-custom.php, and enqueue-singular-css.php
  • Layout and archive-list helpers: layout.php and post-list-layout.php
  • Metadata, structured data, and XML sitemap policy: seo.php and sitemap.php
  • Reusable shortcodes and template-part capture: shortcodes.php
  • Table of Contents processing and output: table-of-contents.php
  • News post type and external-link metadata: custom-post-types/news.php

Common Customization Paths

For standard front-end CSS and JavaScript loading, use inc/enqueue.php. Creator-defined files are handled in inc/enqueue-custom.php; CSS files belong in assets/css/ and JavaScript files in assets/js/, with file names supplied without extensions. For an optional stylesheet tied to the current singular content slug, use inc/enqueue-singular-css.php and the corresponding file under assets/css/singular/. Layout columns, sidebar behavior, layout settings, body classes, scroll offset CSS, and custom layout CSS are provided by inc/layout.php.

Use inc/shortcodes.php for shortcode registration and rendering, including site logos, Business Information values, breadcrumbs, News lists, social links, sharing, and template-part output. XML sitemap customization belongs in inc/sitemap.php. Site images and shared Business Information retrieval are provided by inc/custom-functions.php; News registration and its external URL field are in inc/custom-post-types/news.php. Archive post-list titles, descriptions, settings, and rendering helpers are in inc/post-list-layout.php, while theme metadata and structured data are handled by inc/seo.php. TOC settings, heading extraction, rendering, the

shortcode, content filtering, and the mobile drawer are in inc/table-of-contents.php. Global navigation item markup is generated by inc/class-imb-global-nav-walker.php.

  • Standard CSS and JavaScript loading: inc/enqueue.php
  • Creator-defined asset registration: inc/enqueue-custom.php
  • Slug-specific CSS loading: inc/enqueue-singular-css.php
  • Columns, sidebar, and layout CSS variables: inc/layout.php
  • Shortcode registration and rendering: inc/shortcodes.php
  • XML sitemap scope: inc/sitemap.php
  • Business Information and site image retrieval: inc/custom-functions.php
  • News post type and external URL field: inc/custom-post-types/news.php
  • Archive list headings, descriptions, settings, and rendering helper: inc/post-list-layout.php
  • Meta tags and structured data: inc/seo.php
  • TOC extraction, rendering, shortcode, content filter, and drawer: inc/table-of-contents.php
  • Global navigation item markup: inc/class-imb-global-nav-walker.php

Separation of Responsibilities

core/setup.php handles theme setup and WordPress Core integration, including loading the text domain, declaring theme support, and registering navigation locations. functions.php is the ordered loader for the theme’s Admin, Core, Theme Functions, and Custom Post Type modules; feature implementations belong in the files it loads rather than in functions.php itself.

The inc directory contains PHP feature logic, helpers, hooks, filters, and reusable classes, including navigation, shortcodes, layouts, SEO, sitemaps, and the table of contents. Reusable presentation markup belongs in template-parts, which templates or helpers can call. The assets directory contains browser-facing resources: SCSS sources, compiled CSS, JavaScript, images, and icons.

  • core/setup.php: theme support, text domain loading, and navigation location registration.
  • functions.php: ordered module loading only.
  • inc/: PHP feature logic, helpers, hooks, filters, and reusable classes.
  • template-parts/: reusable presentation templates called by templates or helpers.
  • assets/: SCSS, generated CSS, JavaScript, images, and other browser-facing files.

Adding New PHP Features

For a distinct PHP responsibility, first use the relevant WordPress Core API, hook, template function, or data structure. Add a focused module under inc when a custom implementation is needed, and use the imb_ prefix for its PHP identifiers. Keep the module’s responsibility narrow and predictable.

Load the module from functions.php with require_once and get_theme_file_path, maintaining the existing ordered module-loading pattern. Register the module’s actions and filters in that module rather than turning functions.php into an implementation file. When the feature requires substantial presentation markup, keep that markup in template-parts and have the feature logic or templates call the reusable presentation template.

require_once get_theme_file_path('/inc/sitemap.php');
function imb_filter_sitemap_post_types($post_types)
{
    $allowed_post_types = ['page', 'post', 'news'];

    return array_intersect_key($post_types, array_flip($allowed_post_types));
}
add_filter('wp_sitemaps_post_types', 'imb_filter_sitemap_post_types');