| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * MultiSport functions and definitions |
|---|
| 4 | * |
|---|
| 5 | * Set up the theme and provides some helper functions, which are used in the |
|---|
| 6 | * theme as custom template tags. Others are attached to action and filter |
|---|
| 7 | * hooks in WordPress to change core functionality. |
|---|
| 8 | * |
|---|
| 9 | * When using a child theme you can override certain functions (those wrapped |
|---|
| 10 | * in a function_exists() call) by defining them first in your child theme's |
|---|
| 11 | * functions.php file. The child theme's functions.php file is included before |
|---|
| 12 | * the parent theme's file, so the child theme functions would be used. |
|---|
| 13 | * |
|---|
| 14 | */ |
|---|
| 15 | |
|---|
| 16 | require_once( trailingslashit( get_template_directory() ) . 'inc/customize-pro/class-customize.php' ); |
|---|
| 17 | |
|---|
| 18 | if ( ! function_exists( 'multisport_setup' ) ) : |
|---|
| 19 | /** |
|---|
| 20 | * MultiSport setup. |
|---|
| 21 | * |
|---|
| 22 | * Set up theme defaults and registers support for various WordPress features. |
|---|
| 23 | * |
|---|
| 24 | * Note that this function is hooked into the after_setup_theme hook, which |
|---|
| 25 | * runs before the init hook. The init hook is too late for some features, such |
|---|
| 26 | * as indicating support post thumbnails. |
|---|
| 27 | * |
|---|
| 28 | */ |
|---|
| 29 | function multisport_setup() { |
|---|
| 30 | |
|---|
| 31 | /* |
|---|
| 32 | * Make theme available for translation. |
|---|
| 33 | * |
|---|
| 34 | * Translations can be filed in the /languages/ directory |
|---|
| 35 | * |
|---|
| 36 | * If you're building a theme based on MultiSport, use a find and replace |
|---|
| 37 | * to change 'multisport' to the name of your theme in all the template files. |
|---|
| 38 | */ |
|---|
| 39 | load_theme_textdomain( 'multisport', get_template_directory() . '/languages' ); |
|---|
| 40 | |
|---|
| 41 | // Add default posts and comments RSS feed links to head. |
|---|
| 42 | add_theme_support( 'automatic-feed-links' ); |
|---|
| 43 | |
|---|
| 44 | /* |
|---|
| 45 | * Let WordPress manage the document title. |
|---|
| 46 | * By adding theme support, we declare that this theme does not use a |
|---|
| 47 | * hard-coded <title> tag in the document head, and expect WordPress to |
|---|
| 48 | * provide it for us. |
|---|
| 49 | */ |
|---|
| 50 | add_theme_support( 'title-tag' ); |
|---|
| 51 | |
|---|
| 52 | /* |
|---|
| 53 | * Enable support for Post Thumbnails on posts and pages. |
|---|
| 54 | */ |
|---|
| 55 | add_theme_support( 'post-thumbnails' ); |
|---|
| 56 | |
|---|
| 57 | add_image_size( 'multisport-thumbnail-avatar', 100, 100, true ); |
|---|
| 58 | |
|---|
| 59 | /* |
|---|
| 60 | * Switch default core markup for search form, comment form, and comments |
|---|
| 61 | * to output valid HTML5. |
|---|
| 62 | */ |
|---|
| 63 | add_theme_support( 'html5', array( |
|---|
| 64 | 'comment-form', |
|---|
| 65 | 'comment-list', |
|---|
| 66 | 'gallery', |
|---|
| 67 | 'caption', |
|---|
| 68 | ) ); |
|---|
| 69 | |
|---|
| 70 | /* |
|---|
| 71 | * This theme styles the visual editor to resemble the theme style, |
|---|
| 72 | * specifically font, colors, and column width. |
|---|
| 73 | */ |
|---|
| 74 | add_editor_style( array( 'assets/css/editor-style.css', |
|---|
| 75 | get_template_directory_uri() . '/assets/css/font-awesome.css', |
|---|
| 76 | multisport_fonts_url() |
|---|
| 77 | ) ); |
|---|
| 78 | |
|---|
| 79 | /* |
|---|
| 80 | * Set Custom Background |
|---|
| 81 | */ |
|---|
| 82 | add_theme_support( 'custom-background', array ('default-color' => '#ffffff') ); |
|---|
| 83 | |
|---|
| 84 | // Set the default content width. |
|---|
| 85 | $GLOBALS['content_width'] = 900; |
|---|
| 86 | |
|---|
| 87 | // This theme uses wp_nav_menu() in header menu |
|---|
| 88 | register_nav_menus( array( |
|---|
| 89 | 'primary' => __( 'Primary Menu', 'multisport' ), |
|---|
| 90 | ) ); |
|---|
| 91 | |
|---|
| 92 | $defaults = array( |
|---|
| 93 | 'flex-height' => false, |
|---|
| 94 | 'flex-width' => false, |
|---|
| 95 | 'header-text' => array( 'site-title', 'site-description' ), |
|---|
| 96 | ); |
|---|
| 97 | add_theme_support( 'custom-logo', $defaults ); |
|---|
| 98 | } |
|---|
| 99 | endif; // multisport_setup |
|---|
| 100 | add_action( 'after_setup_theme', 'multisport_setup' ); |
|---|
| 101 | |
|---|
| 102 | if ( ! function_exists( 'multisport_fonts_url' ) ) : |
|---|
| 103 | /** |
|---|
| 104 | * Load google font url used in the MultiSport theme |
|---|
| 105 | */ |
|---|
| 106 | function multisport_fonts_url() { |
|---|
| 107 | |
|---|
| 108 | $fonts_url = ''; |
|---|
| 109 | |
|---|
| 110 | /* Translators: If there are characters in your language that are not |
|---|
| 111 | * supported by Questrial, translate this to 'off'. Do not translate |
|---|
| 112 | * into your own language. |
|---|
| 113 | */ |
|---|
| 114 | $questrial = _x( 'on', 'Questrial font: on or off', 'multisport' ); |
|---|
| 115 | |
|---|
| 116 | if ( 'off' !== $questrial ) { |
|---|
| 117 | $font_families = array(); |
|---|
| 118 | |
|---|
| 119 | $font_families[] = 'Questrial'; |
|---|
| 120 | |
|---|
| 121 | $query_args = array( |
|---|
| 122 | 'family' => urlencode( implode( '|', $font_families ) ), |
|---|
| 123 | 'subset' => urlencode( 'latin,latin-ext' ), |
|---|
| 124 | ); |
|---|
| 125 | |
|---|
| 126 | $fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' ); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | return $fonts_url; |
|---|
| 130 | } |
|---|
| 131 | endif; // multisport_fonts_url |
|---|
| 132 | |
|---|
| 133 | if ( ! function_exists( 'multisport_load_scripts' ) ) : |
|---|
| 134 | /** |
|---|
| 135 | * the main function to load scripts in the MultiSport theme |
|---|
| 136 | * if you add a new load of script, style, etc. you can use that function |
|---|
| 137 | * instead of adding a new wp_enqueue_scripts action for it. |
|---|
| 138 | */ |
|---|
| 139 | function multisport_load_scripts() { |
|---|
| 140 | |
|---|
| 141 | // load main stylesheet. |
|---|
| 142 | wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.css', array( ) ); |
|---|
| 143 | wp_enqueue_style( 'multisport-style', get_stylesheet_uri(), array() ); |
|---|
| 144 | |
|---|
| 145 | wp_enqueue_style( 'multisport-fonts', multisport_fonts_url(), array(), null ); |
|---|
| 146 | |
|---|
| 147 | if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
|---|
| 148 | wp_enqueue_script( 'comment-reply' ); |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | // Load Utilities JS Script |
|---|
| 152 | wp_enqueue_script( 'multisport-utilities', get_template_directory_uri() . '/assets/js/utilities.js', array( 'jquery' ) ); |
|---|
| 153 | } |
|---|
| 154 | endif; // multisport_load_scripts |
|---|
| 155 | add_action( 'wp_enqueue_scripts', 'multisport_load_scripts' ); |
|---|
| 156 | |
|---|
| 157 | if ( ! function_exists( 'multisport_widgets_init' ) ) : |
|---|
| 158 | /** |
|---|
| 159 | * widgets-init action handler. Used to register widgets and register widget areas |
|---|
| 160 | */ |
|---|
| 161 | function multisport_widgets_init() { |
|---|
| 162 | |
|---|
| 163 | // Register Sidebar Widget. |
|---|
| 164 | register_sidebar( array ( |
|---|
| 165 | 'name' => __( 'Sidebar Widget Area', 'multisport'), |
|---|
| 166 | 'id' => 'sidebar-widget-area', |
|---|
| 167 | 'description' => __( 'The sidebar widget area', 'multisport'), |
|---|
| 168 | 'before_widget' => '', |
|---|
| 169 | 'after_widget' => '', |
|---|
| 170 | 'before_title' => '<div class="sidebar-before-title"></div><h3 class="sidebar-title">', |
|---|
| 171 | 'after_title' => '</h3><div class="sidebar-after-title"></div>', |
|---|
| 172 | ) ); |
|---|
| 173 | |
|---|
| 174 | // Register Footer Column #1 |
|---|
| 175 | register_sidebar( array ( |
|---|
| 176 | 'name' => __( 'Footer Column #1', 'multisport' ), |
|---|
| 177 | 'id' => 'footer-column-1-widget-area', |
|---|
| 178 | 'description' => __( 'The Footer Column #1 widget area', 'multisport' ), |
|---|
| 179 | 'before_widget' => '', |
|---|
| 180 | 'after_widget' => '', |
|---|
| 181 | 'before_title' => '<h2 class="footer-title">', |
|---|
| 182 | 'after_title' => '</h2><div class="footer-after-title"></div>', |
|---|
| 183 | ) ); |
|---|
| 184 | |
|---|
| 185 | // Register Footer Column #2 |
|---|
| 186 | register_sidebar( array ( |
|---|
| 187 | 'name' => __( 'Footer Column #2', 'multisport' ), |
|---|
| 188 | 'id' => 'footer-column-2-widget-area', |
|---|
| 189 | 'description' => __( 'The Footer Column #2 widget area', 'multisport' ), |
|---|
| 190 | 'before_widget' => '', |
|---|
| 191 | 'after_widget' => '', |
|---|
| 192 | 'before_title' => '<h2 class="footer-title">', |
|---|
| 193 | 'after_title' => '</h2><div class="footer-after-title"></div>', |
|---|
| 194 | ) ); |
|---|
| 195 | |
|---|
| 196 | // Register Footer Column #3 |
|---|
| 197 | register_sidebar( array ( |
|---|
| 198 | 'name' => __( 'Footer Column #3', 'multisport' ), |
|---|
| 199 | 'id' => 'footer-column-3-widget-area', |
|---|
| 200 | 'description' => __( 'The Footer Column #3 widget area', 'multisport' ), |
|---|
| 201 | 'before_widget' => '', |
|---|
| 202 | 'after_widget' => '', |
|---|
| 203 | 'before_title' => '<h2 class="footer-title">', |
|---|
| 204 | 'after_title' => '</h2><div class="footer-after-title"></div>', |
|---|
| 205 | ) ); |
|---|
| 206 | } |
|---|
| 207 | endif; // multisport_widgets_init |
|---|
| 208 | add_action( 'widgets_init', 'multisport_widgets_init' ); |
|---|
| 209 | |
|---|
| 210 | if ( ! function_exists( 'multisport_show_copyright_text' ) ) : |
|---|
| 211 | /** |
|---|
| 212 | * Displays the copyright text. |
|---|
| 213 | */ |
|---|
| 214 | function multisport_show_copyright_text() { |
|---|
| 215 | |
|---|
| 216 | $footerText = get_theme_mod('multisport_footer_copyright', null); |
|---|
| 217 | |
|---|
| 218 | if ( !empty( $footerText ) ) { |
|---|
| 219 | |
|---|
| 220 | echo esc_html( $footerText ) . ' | '; |
|---|
| 221 | } |
|---|
| 222 | } |
|---|
| 223 | endif; // multisport_show_copyright_text |
|---|
| 224 | |
|---|
| 225 | /** |
|---|
| 226 | * Implement the Custom Header feature. |
|---|
| 227 | */ |
|---|
| 228 | require get_template_directory() . '/inc/custom-header.php'; |
|---|
| 229 | |
|---|
| 230 | /** |
|---|
| 231 | * Customizer additions. |
|---|
| 232 | */ |
|---|
| 233 | require get_template_directory() . '/inc/customizer.php'; |
|---|
| 234 | |
|---|