Make WordPress Themes


Ignore:
Timestamp:
09/29/2026 06:06:44 AM (6 weeks ago)
Author:
themedropbox
Message:

New version of Stackwise - 1.2.0

Location:
stackwise/1.2.0
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stackwise/1.2.0/functions.php

    r321264 r351334  
    1010
    1111if ( ! defined( 'ABSPATH' ) ) {
    12     exit; // Exit if accessed directly.
     12        exit; // Exit if accessed directly.
    1313}
    1414
    … …  
    1616 * Define theme constants
    1717 */
    18 define( 'STACKWISE_VERSION', '1.1.0' );
     18define( 'STACKWISE_VERSION', '1.2.0' );
    1919define( 'STACKWISE_DIR', get_template_directory() );
    2020define( 'STACKWISE_URI', get_template_directory_uri() );
    … …  
    2424 */
    2525function stackwise_setup() {
    26     /*
    27     * Make theme available for translation.
    28     * Translations can be filed in the /languages/ directory.
    29     */
    30     load_theme_textdomain( 'stackwise', STACKWISE_DIR . '/languages' );
    31 
    32     // Add default posts and comments RSS feed links to head.
    33     add_theme_support( 'automatic-feed-links' );
    34 
    35     /*
    36     * Let WordPress manage the document title.
    37     */
    38     add_theme_support( 'title-tag' );
    39 
    40     /*
    41     * Enable support for Post Thumbnails on posts and pages.
    42     */
    43     add_theme_support( 'post-thumbnails' );
    44 
    45     // Set default thumbnail size
    46     set_post_thumbnail_size( 1200, 750, true );
    47 
    48     // Add custom image sizes
    49     add_image_size( 'stackwise-project', 800, 500, true );
    50     add_image_size( 'stackwise-blog', 600, 400, true );
    51 
    52     // Register navigation menus
    53     register_nav_menus(
    54         array(
    55             'primary' => esc_html__( 'Primary Menu', 'stackwise' ),
    56             'footer'  => esc_html__( 'Footer Menu', 'stackwise' ),
    57         )
    58     );
    59 
    60     /*
    61     * Switch default core markup for search form, comment form, and comments
    62     * to output valid HTML5.
    63     */
    64     add_theme_support(
    65         'html5',
    66         array(
    67             'search-form',
    68             'comment-form',
    69             'comment-list',
    70             'gallery',
    71             'caption',
    72             'style',
    73             'script',
    74         )
    75     );
    76 
    77     // Set up the WordPress core custom background feature.
    78     add_theme_support(
    79         'custom-background',
    80         apply_filters(
    81             'stackwise_custom_background_args',
    82             array(
    83                 'default-color' => '0d1117',
    84                 'default-image' => '',
    85             )
    86         )
    87     );
    88 
    89     // Add theme support for selective refresh for widgets.
    90     add_theme_support( 'customize-selective-refresh-widgets' );
    91 
    92     // Add support for custom logo.
    93     add_theme_support(
    94         'custom-logo',
    95         array(
    96             'height'      => 80,
    97             'width'       => 200,
    98             'flex-width'  => true,
    99             'flex-height' => true,
    100         )
    101     );
    102 
    103     // Add support for Block Styles.
    104     add_theme_support( 'wp-block-styles' );
    105 
    106     // Add support for full and wide align images.
    107     add_theme_support( 'align-wide' );
    108 
    109     // Add support for editor styles.
    110     add_theme_support( 'editor-styles' );
    111 
    112     // Enqueue editor styles.
    113     add_editor_style( 'assets/css/editor-style.css' );
    114 
    115     // Add support for responsive embedded content.
    116     add_theme_support( 'responsive-embeds' );
    117 
    118     // Add support for custom line height controls.
    119     add_theme_support( 'custom-line-height' );
    120 
    121     // Add support for experimental link color control.
    122     add_theme_support( 'link-color' );
    123 
    124     // Add support for custom units.
    125     add_theme_support( 'custom-units' );
    126 
    127     // Add support for custom spacing.
    128     add_theme_support( 'custom-spacing' );
    129 
    130     // Remove core block patterns.
    131     remove_theme_support( 'core-block-patterns' );
    132 
    133     // Add support for appearance tools.
    134     add_theme_support( 'appearance-tools' );
    135 
    136     // Add support for custom header image.
    137     add_theme_support(
    138         'custom-header',
    139         apply_filters(
    140             'stackwise_custom_header_args',
    141             array(
    142                 'default-image'      => '',
    143                 'default-text-color' => 'e6edf3',
    144                 'width'              => 1200,
    145                 'height'             => 400,
    146                 'flex-height'        => true,
    147                 'flex-width'         => true,
    148             )
    149         )
    150     );
    151 
    152     /**
    153     * Add support for Starter Content
    154     */
    155     add_theme_support(
    156         'starter-content',
    157         stackwise_get_starter_content()
    158     );
     26        /*
     27        * Make theme available for translation.
     28        * Translations can be filed in the /languages/ directory.
     29        */
     30        load_theme_textdomain( 'stackwise', STACKWISE_DIR . '/languages' );
     31
     32        // Add default posts and comments RSS feed links to head.
     33        add_theme_support( 'automatic-feed-links' );
     34
     35        /*
     36        * Let WordPress manage the document title.
     37        */
     38        add_theme_support( 'title-tag' );
     39
     40        /*
     41        * Enable support for Post Thumbnails on posts and pages.
     42        */
     43        add_theme_support( 'post-thumbnails' );
     44
     45        // Set default thumbnail size.
     46        set_post_thumbnail_size( 1200, 750, true );
     47
     48        // Add custom image sizes.
     49        add_image_size( 'stackwise-project', 800, 500, true );
     50        add_image_size( 'stackwise-blog', 600, 400, true );
     51
     52        // Register navigation menus.
     53        register_nav_menus(
     54                array(
     55                        'primary' => esc_html__( 'Primary Menu', 'stackwise' ),
     56                        'footer'  => esc_html__( 'Footer Menu', 'stackwise' ),
     57                )
     58        );
     59
     60        /*
     61        * Switch default core markup for search form, comment form, and comments
     62        * to output valid HTML5.
     63        */
     64        add_theme_support(
     65                'html5',
     66                array(
     67                        'search-form',
     68                        'comment-form',
     69                        'comment-list',
     70                        'gallery',
     71                        'caption',
     72                        'style',
     73                        'script',
     74                )
     75        );
     76
     77        // Set up the WordPress core custom background feature.
     78        add_theme_support(
     79                'custom-background',
     80                apply_filters(
     81                        'stackwise_custom_background_args',
     82                        array(
     83                                'default-color' => '0d1117',
     84                                'default-image' => '',
     85                        )
     86                )
     87        );
     88
     89        // Add theme support for selective refresh for widgets.
     90        add_theme_support( 'customize-selective-refresh-widgets' );
     91
     92        // Add support for custom logo.
     93        add_theme_support(
     94                'custom-logo',
     95                array(
     96                        'height'      => 80,
     97                        'width'       => 200,
     98                        'flex-width'  => true,
     99                        'flex-height' => true,
     100                )
     101        );
     102
     103        // Add support for Block Styles.
     104        add_theme_support( 'wp-block-styles' );
     105
     106        // Add support for full and wide align images.
     107        add_theme_support( 'align-wide' );
     108
     109        // Add support for editor styles.
     110        add_theme_support( 'editor-styles' );
     111
     112        // Enqueue editor styles.
     113        add_editor_style( 'assets/css/editor-style.css' );
     114
     115        // Add support for responsive embedded content.
     116        add_theme_support( 'responsive-embeds' );
     117
     118        // Add support for custom line height controls.
     119        add_theme_support( 'custom-line-height' );
     120
     121        // Add support for experimental link color control.
     122        add_theme_support( 'link-color' );
     123
     124        // Add support for custom units.
     125        add_theme_support( 'custom-units' );
     126
     127        // Add support for custom spacing.
     128        add_theme_support( 'custom-spacing' );
     129
     130        // Remove core block patterns.
     131        remove_theme_support( 'core-block-patterns' );
     132
     133        // Add support for appearance tools.
     134        add_theme_support( 'appearance-tools' );
     135
     136        // Add support for custom header image.
     137        add_theme_support(
     138                'custom-header',
     139                apply_filters(
     140                        'stackwise_custom_header_args',
     141                        array(
     142                                'default-image' => '',
     143                                'header-text'   => false,
     144                                'width'         => 1200,
     145                                'height'        => 900,
     146                                'flex-height'   => true,
     147                                'flex-width'    => true,
     148                        )
     149                )
     150        );
     151
     152        /**
     153        * Add support for Starter Content
     154        */
     155        add_theme_support(
     156                'starter-content',
     157                stackwise_get_starter_content()
     158        );
    159159}
    160160add_action( 'after_setup_theme', 'stackwise_setup' );
    … …  
    166166 */
    167167function stackwise_content_width() {
    168     $GLOBALS['content_width'] = apply_filters( 'stackwise_content_width', 1200 );
     168        $GLOBALS['content_width'] = apply_filters( 'stackwise_content_width', 1200 );
    169169}
    170170add_action( 'after_setup_theme', 'stackwise_content_width', 0 );
    … …  
    174174 */
    175175function stackwise_widgets_init() {
    176     register_sidebar(
    177         array(
    178             'name'          => esc_html__( 'Sidebar', 'stackwise' ),
    179             'id'            => 'sidebar-1',
    180             'description'   => esc_html__( 'Add widgets here.', 'stackwise' ),
    181             'before_widget' => '<section id="%1$s" class="widget %2$s">',
    182             'after_widget'  => '</section>',
    183             'before_title'  => '<h3 class="widget-title">',
    184             'after_title'   => '</h3>',
    185         )
    186     );
    187 
    188     register_sidebar(
    189         array(
    190             'name'          => esc_html__( 'Footer Widget Area', 'stackwise' ),
    191             'id'            => 'footer-1',
    192             'description'   => esc_html__( 'Add footer widgets here.', 'stackwise' ),
    193             'before_widget' => '<div id="%1$s" class="widget %2$s">',
    194             'after_widget'  => '</div>',
    195             'before_title'  => '<h4 class="widget-title">',
    196             'after_title'   => '</h4>',
    197         )
    198     );
     176        register_sidebar(
     177                array(
     178                        'name'          => esc_html__( 'Footer Widget Area', 'stackwise' ),
     179                        'id'            => 'footer-1',
     180                        'description'   => esc_html__( 'Add footer widgets here.', 'stackwise' ),
     181                        'before_widget' => '<div id="%1$s" class="widget %2$s">',
     182                        'after_widget'  => '</div>',
     183                        'before_title'  => '<h4 class="widget-title">',
     184                        'after_title'   => '</h4>',
     185                )
     186        );
    199187}
    200188add_action( 'widgets_init', 'stackwise_widgets_init' );
    … …  
    204192 */
    205193function stackwise_scripts() {
    206     // Enqueue Google Fonts
    207     wp_enqueue_style(
    208         'stackwise-google-fonts',
    209         stackwise_google_fonts_url(),
    210         array(),
    211         null
    212     );
    213 
    214     // Main stylesheet
    215     wp_enqueue_style(
    216         'stackwise-style',
    217         get_stylesheet_uri(),
    218         array(),
    219         STACKWISE_VERSION
    220     );
    221 
    222     // Add inline styles from customizer
    223     wp_add_inline_style( 'stackwise-style', stackwise_get_customizer_css() );
    224 
    225     // Navigation script
    226     wp_enqueue_script(
    227         'stackwise-navigation',
    228         STACKWISE_URI . '/assets/js/navigation.js',
    229         array(),
    230         STACKWISE_VERSION,
    231         true
    232     );
    233 
    234     // Theme toggle script
    235     wp_enqueue_script(
    236         'stackwise-theme-toggle',
    237         STACKWISE_URI . '/assets/js/theme-toggle.js',
    238         array(),
    239         STACKWISE_VERSION,
    240         true
    241     );
    242 
    243     // Typing effect (only on front page)
    244     if ( is_front_page() ) {
    245         wp_enqueue_script(
    246             'stackwise-typing-effect',
    247             STACKWISE_URI . '/assets/js/typing-effect.js',
    248             array(),
    249             STACKWISE_VERSION,
    250             true
    251         );
    252 
    253         // Pass data to typing effect script
    254         wp_localize_script(
    255             'stackwise-typing-effect',
    256             'stackwiseTyping',
    257             array(
    258                 'strings' => stackwise_get_typing_strings(),
    259             )
    260         );
    261     }
    262 
    263     // Comment reply script
    264     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    265         wp_enqueue_script( 'comment-reply' );
    266     }
     194        // Enqueue Google Fonts.
     195        wp_enqueue_style(
     196                'stackwise-google-fonts',
     197                stackwise_google_fonts_url(),
     198                array(),
     199                STACKWISE_VERSION
     200        );
     201
     202        // Main stylesheet.
     203        wp_enqueue_style(
     204                'stackwise-style',
     205                get_stylesheet_uri(),
     206                array(),
     207                STACKWISE_VERSION
     208        );
     209
     210        // Add inline styles from customizer.
     211        wp_add_inline_style( 'stackwise-style', stackwise_get_customizer_css() );
     212
     213        // Navigation script.
     214        wp_enqueue_script(
     215                'stackwise-navigation',
     216                STACKWISE_URI . '/assets/js/navigation.js',
     217                array(),
     218                STACKWISE_VERSION,
     219                true
     220        );
     221
     222        // Theme toggle script.
     223        wp_enqueue_script(
     224                'stackwise-theme-toggle',
     225                STACKWISE_URI . '/assets/js/theme-toggle.js',
     226                array(),
     227                STACKWISE_VERSION,
     228                true
     229        );
     230
     231        // Typing effect (only on front page).
     232        if ( is_front_page() ) {
     233                wp_enqueue_script(
     234                        'stackwise-typing-effect',
     235                        STACKWISE_URI . '/assets/js/typing-effect.js',
     236                        array(),
     237                        STACKWISE_VERSION,
     238                        true
     239                );
     240
     241                // Pass data to typing effect script.
     242                wp_localize_script(
     243                        'stackwise-typing-effect',
     244                        'stackwiseTyping',
     245                        array(
     246                                'strings' => stackwise_get_typing_strings(),
     247                        )
     248                );
     249        }
     250
     251        // Comment reply script.
     252        if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
     253                wp_enqueue_script( 'comment-reply' );
     254        }
    267255}
    268256add_action( 'wp_enqueue_scripts', 'stackwise_scripts' );
    … …  
    274262 */
    275263function stackwise_google_fonts_url() {
    276     $fonts_url = '';
    277     $fonts     = array();
    278     $subsets   = 'latin,latin-ext';
    279 
    280     // Inter font
    281     $fonts[] = 'Inter:wght@400;500;600;700';
    282 
    283     // JetBrains Mono font
    284     $fonts[] = 'JetBrains+Mono:wght@400;500;600;700';
    285 
    286     if ( $fonts ) {
    287         $fonts_url = 'https://fonts.googleapis.com/css2?family=' . implode( '&family=', $fonts ) . '&display=swap';
    288     }
    289 
    290     return esc_url_raw( $fonts_url );
     264        $fonts_url = '';
     265        $fonts     = array();
     266        $subsets   = 'latin,latin-ext';
     267
     268        // Inter font.
     269        $fonts[] = 'Inter:wght@400;500;600;700';
     270
     271        // JetBrains Mono font.
     272        $fonts[] = 'JetBrains+Mono:wght@400;500;600;700';
     273
     274        if ( $fonts ) {
     275                $fonts_url = 'https://fonts.googleapis.com/css2?family=' . implode( '&family=', $fonts ) . '&display=swap';
     276        }
     277
     278        return esc_url_raw( $fonts_url );
    291279}
    292280
    … …  
    297285 */
    298286function stackwise_get_typing_strings() {
    299     $strings = get_theme_mod( 'stackwise_hero_typing_text', "Full Stack Developer\nFrontend Engineer\nBackend Developer\nUI/UX Enthusiast" );
    300     return array_map( 'trim', explode( "\n", $strings ) );
     287        $strings = get_theme_mod( 'stackwise_hero_typing_text', "Full Stack Developer\nFrontend Engineer\nBackend Developer\nUI/UX Enthusiast" );
     288        return array_map( 'trim', explode( "\n", $strings ) );
    301289}
    302290
    … …  
    307295 */
    308296function stackwise_get_customizer_css() {
    309     $css = '';
    310 
    311     // Accent color
    312     $accent_color = get_theme_mod( 'stackwise_accent_color', '#58a6ff' );
    313     if ( $accent_color !== '#58a6ff' ) {
    314         $css .= ':root { --sw-color-accent: ' . esc_attr( $accent_color ) . '; }';
    315     }
    316 
    317     return $css;
    318 }
    319 
    320 /**
    321  * Get starter content
    322  *
    323  * @return array Starter content array
     297        $css = '';
     298
     299        // Accent color.
     300        $accent_color = get_theme_mod( 'stackwise_accent_color', '#58a6ff' );
     301        if ( '#58a6ff' !== $accent_color ) {
     302                $css .= ':root { --sw-color-accent: ' . esc_attr( $accent_color ) . '; }';
     303        }
     304
     305        return $css;
     306}
     307
     308/**
     309 * Starter content for new sites.
     310 *
     311 * Shown in the Customizer preview on a fresh site and created only when the
     312 * user publishes the Customizer. It sets up the pages, front page sections,
     313 * menus and footer widgets so the theme looks complete from the start.
     314 *
     315 * @return array Starter content definition.
    324316 */
    325317function stackwise_get_starter_content() {
    326     return array(
    327         'posts'     => array(
    328             'home'    => array(
    329                 'post_type'    => 'page',
    330                 'post_title'   => esc_html_x( 'Home', 'Theme starter content', 'stackwise' ),
    331                 'post_content' => '',
    332             ),
    333             'about'   => array(
    334                 'post_type'    => 'page',
    335                 'post_title'   => esc_html_x( 'About', 'Theme starter content', 'stackwise' ),
    336                 'post_content' => esc_html_x( 'This is the about page. Tell visitors about yourself and your background.', 'Theme starter content', 'stackwise' ),
    337             ),
    338             'contact' => array(
    339                 'post_type'    => 'page',
    340                 'post_title'   => esc_html_x( 'Contact', 'Theme starter content', 'stackwise' ),
    341                 'post_content' => esc_html_x( 'Get in touch! Add your contact form shortcode here.', 'Theme starter content', 'stackwise' ),
    342             ),
    343             'blog'    => array(
    344                 'post_type'    => 'page',
    345                 'post_title'   => esc_html_x( 'Blog', 'Theme starter content', 'stackwise' ),
    346                 'post_content' => '',
    347             ),
    348             'project-one' => array(
    349                 'post_type'    => 'post',
    350                 'post_title'   => esc_html_x( 'E-Commerce Platform', 'Theme starter content', 'stackwise' ),
    351                 'post_content' => esc_html_x( 'A full-featured e-commerce platform built with React and Node.js.', 'Theme starter content', 'stackwise' ),
    352             ),
    353             'project-two' => array(
    354                 'post_type'    => 'post',
    355                 'post_title'   => esc_html_x( 'Task Management App', 'Theme starter content', 'stackwise' ),
    356                 'post_content' => esc_html_x( 'A collaborative task management application with real-time updates.', 'Theme starter content', 'stackwise' ),
    357             ),
    358         ),
    359         'nav_menus' => array(
    360             'primary' => array(
    361                 'name'  => esc_html__( 'Primary Menu', 'stackwise' ),
    362                 'items' => array(
    363                     'page_home'    => array(
    364                         'type'  => 'post_type',
    365                         'object'    => 'page',
    366                         'object_id' => '{{home}}',
    367                         'title'     => esc_html_x( 'Home', 'Theme starter content', 'stackwise' ),
    368                     ),
    369                     'page_about'   => array(
    370                         'type'      => 'post_type',
    371                         'object'    => 'page',
    372                         'object_id' => '{{about}}',
    373                         'title'     => esc_html_x( 'About', 'Theme starter content', 'stackwise' ),
    374                     ),
    375                     'page_blog'    => array(
    376                         'type'      => 'post_type',
    377                         'object'    => 'page',
    378                         'object_id' => '{{blog}}',
    379                         'title'     => esc_html_x( 'Blog', 'Theme starter content', 'stackwise' ),
    380                     ),
    381                     'page_contact' => array(
    382                         'type'      => 'post_type',
    383                         'object'    => 'page',
    384                         'object_id' => '{{contact}}',
    385                         'title'     => esc_html_x( 'Contact', 'Theme starter content', 'stackwise' ),
    386                     ),
    387                 ),
    388             ),
    389         ),
    390         'options'   => array(
    391             'show_on_front'  => 'page',
    392             'page_on_front'  => '{{home}}',
    393             'page_for_posts' => '{{blog}}',
    394         ),
    395     );
     318        $paragraph = static function ( $text ) {
     319                return '<!-- wp:paragraph --><p>' . esc_html( $text ) . '</p><!-- /wp:paragraph -->';
     320        };
     321
     322        return array(
     323                'posts'      => array(
     324                        'home'     => array(
     325                                'post_type'    => 'page',
     326                                'post_title'   => _x( 'Home', 'Theme starter content', 'stackwise' ),
     327                                'post_content' => '',
     328                        ),
     329                        'about'    => array(
     330                                'post_type'    => 'page',
     331                                'post_title'   => _x( 'About Me', 'Theme starter content', 'stackwise' ),
     332                                'post_content' => $paragraph( _x( 'I am a developer who builds fast, accessible websites. Use this page to tell visitors who you are, what you work on and what you care about.', 'Theme starter content', 'stackwise' ) )
     333                                        . $paragraph( _x( 'Add a featured image to this page to show a photo next to this text on the front page.', 'Theme starter content', 'stackwise' ) ),
     334                        ),
     335                        'services' => array(
     336                                'post_type'    => 'page',
     337                                'post_title'   => _x( 'What I Do', 'Theme starter content', 'stackwise' ),
     338                                'post_content' => stackwise_pattern_skills_columns(),
     339                        ),
     340                        'blog'     => array(
     341                                'post_type'  => 'page',
     342                                'post_title' => _x( 'Blog', 'Theme starter content', 'stackwise' ),
     343                        ),
     344                        'contact'  => array(
     345                                'post_type'    => 'page',
     346                                'post_title'   => _x( 'Contact', 'Theme starter content', 'stackwise' ),
     347                                'template'     => 'template-contact.php',
     348                                'post_content' => $paragraph( _x( 'Have a project in mind or just want to say hello? Add a contact form block from your form plugin here, and set your email address and location in Appearance > Customize > Theme Options.', 'Theme starter content', 'stackwise' ) ),
     349                        ),
     350                ),
     351                'options'    => array(
     352                        'show_on_front'  => 'page',
     353                        'page_on_front'  => '{{home}}',
     354                        'page_for_posts' => '{{blog}}',
     355                ),
     356                'theme_mods' => array(
     357                        'stackwise_fp_about_page'    => '{{about}}',
     358                        'stackwise_fp_services_page' => '{{services}}',
     359                        'stackwise_fp_contact_page'  => '{{contact}}',
     360                ),
     361                'widgets'    => array(
     362                        'footer-1' => array(
     363                                'text_about',
     364                                'recent-posts',
     365                        ),
     366                ),
     367                'nav_menus'  => array(
     368                        'primary' => array(
     369                                'name'  => __( 'Primary Menu', 'stackwise' ),
     370                                'items' => array(
     371                                        'link_home',
     372                                        'link_about'   => array(
     373                                                'type'  => 'custom',
     374                                                'title' => _x( 'About', 'Theme starter content', 'stackwise' ),
     375                                                'url'   => home_url( '/#about' ),
     376                                        ),
     377                                        'page_blog',
     378                                        'link_contact' => array(
     379                                                'type'  => 'custom',
     380                                                'title' => _x( 'Contact', 'Theme starter content', 'stackwise' ),
     381                                                'url'   => home_url( '/#contact' ),
     382                                        ),
     383                                ),
     384                        ),
     385                        'footer'  => array(
     386                                'name'  => __( 'Footer Menu', 'stackwise' ),
     387                                'items' => array(
     388                                        'page_about' => array(
     389                                                'type'      => 'post_type',
     390                                                'object'    => 'page',
     391                                                'object_id' => '{{about}}',
     392                                        ),
     393                                        'page_blog',
     394                                        'page_contact',
     395                                ),
     396                        ),
     397                ),
     398        );
    396399}
    397400
    … …  
    400403 */
    401404
    402 // Custom template tags
     405// Custom template tags.
    403406require STACKWISE_DIR . '/inc/template-tags.php';
    404407
    405 // Template functions
     408// Template functions.
    406409require STACKWISE_DIR . '/inc/template-functions.php';
    407410
    408 // Customizer additions
     411// Customizer additions.
    409412require STACKWISE_DIR . '/inc/customizer.php';
    410413
    411 // Block patterns
     414// Block patterns.
    412415require STACKWISE_DIR . '/inc/block-patterns.php';
    413416
    … …  
    419422 */
    420423function stackwise_body_classes( $classes ) {
    421     // Add a class if there is a custom header
    422     if ( has_header_image() ) {
    423         $classes[] = 'has-header-image';
    424     }
    425 
    426     // Add class for front page
    427     if ( is_front_page() && ! is_home() ) {
    428         $classes[] = 'is-front-page';
    429     }
    430 
    431     // Add class for singular views
    432     if ( is_singular() ) {
    433         $classes[] = 'is-singular';
    434     }
    435 
    436     // Add class based on sidebar
    437     if ( ! is_active_sidebar( 'sidebar-1' ) ) {
    438         $classes[] = 'no-sidebar';
    439     }
    440 
    441     return $classes;
     424        // Add a class if there is a custom header.
     425        if ( has_header_image() ) {
     426                $classes[] = 'has-header-image';
     427        }
     428
     429        // Add class for front page.
     430        if ( is_front_page() && ! is_home() ) {
     431                $classes[] = 'is-front-page';
     432        }
     433
     434        // Add class for singular views.
     435        if ( is_singular() ) {
     436                $classes[] = 'is-singular';
     437        }
     438
     439        return $classes;
    442440}
    443441add_filter( 'body_class', 'stackwise_body_classes' );
    … …  
    447445 */
    448446function stackwise_pingback_header() {
    449     if ( is_singular() && pings_open() ) {
    450         printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
    451     }
     447        if ( is_singular() && pings_open() ) {
     448                printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
     449        }
    452450}
    453451add_action( 'wp_head', 'stackwise_pingback_header' );
    … …  
    461459 */
    462460function stackwise_resource_hints( $urls, $relation_type ) {
    463     if ( 'preconnect' === $relation_type ) {
    464         $urls[] = array(
    465             'href' => 'https://fonts.googleapis.com',
    466         );
    467         $urls[] = array(
    468             'href' => 'https://fonts.gstatic.com',
    469             'crossorigin',
    470         );
    471     }
    472 
    473     return $urls;
     461        if ( 'preconnect' === $relation_type ) {
     462                $urls[] = array(
     463                        'href' => 'https://fonts.googleapis.com',
     464                );
     465                $urls[] = array(
     466                        'href' => 'https://fonts.gstatic.com',
     467                        'crossorigin',
     468                );
     469        }
     470
     471        return $urls;
    474472}
    475473add_filter( 'wp_resource_hints', 'stackwise_resource_hints', 10, 2 );
    … …  
    482480 */
    483481function stackwise_excerpt_length( $length ) {
    484     if ( is_admin() ) {
    485         return $length;
    486     }
    487     return 20;
     482        if ( is_admin() ) {
     483                return $length;
     484        }
     485        return 20;
    488486}
    489487add_filter( 'excerpt_length', 'stackwise_excerpt_length' );
    … …  
    496494 */
    497495function stackwise_excerpt_more( $more ) {
    498     if ( is_admin() ) {
    499         return $more;
    500     }
    501     return '&hellip;';
     496        if ( is_admin() ) {
     497                return $more;
     498        }
     499        return '&hellip;';
    502500}
    503501add_filter( 'excerpt_more', 'stackwise_excerpt_more' );
    504502
    505503/**
    506  * Get project category for posts
    507  *
    508  * @return WP_Term|false Project category term or false.
    509  */
    510 function stackwise_get_project_category() {
    511     $category_slug = get_theme_mod( 'stackwise_project_category', 'portfolio' );
    512     $category = get_term_by( 'slug', $category_slug, 'category' );
    513     return $category;
    514 }
    515 
    516 /**
    517  * Check if post is a project
    518  *
    519  * @param int|WP_Post $post Post ID or post object.
    520  * @return bool True if post is a project.
    521  */
    522 function stackwise_is_project( $post = null ) {
    523     $post = get_post( $post );
    524     if ( ! $post ) {
    525         return false;
    526     }
    527 
    528     $project_category = stackwise_get_project_category();
    529     if ( ! $project_category ) {
    530         return false;
    531     }
    532 
    533     return has_category( $project_category->term_id, $post );
    534 }
    535 
    536 /**
    537504 * Enqueue block editor assets
    538505 */
    539506function stackwise_block_editor_assets() {
    540     wp_enqueue_style(
    541         'stackwise-editor-style',
    542         STACKWISE_URI . '/assets/css/editor-style.css',
    543         array(),
    544         STACKWISE_VERSION
    545     );
     507        wp_enqueue_style(
     508                'stackwise-editor-style',
     509                STACKWISE_URI . '/assets/css/editor-style.css',
     510                array(),
     511                STACKWISE_VERSION
     512        );
    546513}
    547514add_action( 'enqueue_block_editor_assets', 'stackwise_block_editor_assets' );
Note: See TracChangeset for help on using the changeset viewer.