| 1 | <?php //phpcs:ignore |
|---|
| 2 | /** |
|---|
| 3 | * Theme functions and definitions. |
|---|
| 4 | * |
|---|
| 5 | * @package BlogHash |
|---|
| 6 | * @author Peregrine Themes |
|---|
| 7 | * @since 1.0.0 |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | /** |
|---|
| 11 | * Main Bloghash class. |
|---|
| 12 | * |
|---|
| 13 | * @since 1.0.0 |
|---|
| 14 | */ |
|---|
| 15 | final class Bloghash { |
|---|
| 16 | |
|---|
| 17 | /** |
|---|
| 18 | * Theme options |
|---|
| 19 | * |
|---|
| 20 | * @since 1.0.0 |
|---|
| 21 | * @var object |
|---|
| 22 | */ |
|---|
| 23 | public $options; |
|---|
| 24 | |
|---|
| 25 | /** |
|---|
| 26 | * Theme fonts |
|---|
| 27 | * |
|---|
| 28 | * @since 1.0.0 |
|---|
| 29 | * @var object |
|---|
| 30 | */ |
|---|
| 31 | public $fonts; |
|---|
| 32 | |
|---|
| 33 | /** |
|---|
| 34 | * Theme icons |
|---|
| 35 | * |
|---|
| 36 | * @since 1.0.0 |
|---|
| 37 | * @var object |
|---|
| 38 | */ |
|---|
| 39 | public $icons; |
|---|
| 40 | |
|---|
| 41 | /** |
|---|
| 42 | * Theme customizer |
|---|
| 43 | * |
|---|
| 44 | * @since 1.0.0 |
|---|
| 45 | * @var object |
|---|
| 46 | */ |
|---|
| 47 | public $customizer; |
|---|
| 48 | |
|---|
| 49 | /** |
|---|
| 50 | * Theme admin |
|---|
| 51 | * |
|---|
| 52 | * @since 1.0.0 |
|---|
| 53 | * @var object |
|---|
| 54 | */ |
|---|
| 55 | public $admin; |
|---|
| 56 | |
|---|
| 57 | /** |
|---|
| 58 | * Singleton instance of the class. |
|---|
| 59 | * |
|---|
| 60 | * @since 1.0.0 |
|---|
| 61 | * @var object |
|---|
| 62 | */ |
|---|
| 63 | private static $instance; |
|---|
| 64 | /** |
|---|
| 65 | * Theme version. |
|---|
| 66 | * |
|---|
| 67 | * @since 1.0.0 |
|---|
| 68 | * @var string |
|---|
| 69 | */ |
|---|
| 70 | public $version = '1.0.12'; |
|---|
| 71 | /** |
|---|
| 72 | * Main Bloghash Instance. |
|---|
| 73 | * |
|---|
| 74 | * Insures that only one instance of Bloghash exists in memory at any one |
|---|
| 75 | * time. Also prevents needing to define globals all over the place. |
|---|
| 76 | * |
|---|
| 77 | * @since 1.0.0 |
|---|
| 78 | * @return Bloghash |
|---|
| 79 | */ |
|---|
| 80 | public static function instance() { |
|---|
| 81 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Bloghash ) ) { |
|---|
| 82 | self::$instance = new Bloghash(); |
|---|
| 83 | self::$instance->constants(); |
|---|
| 84 | self::$instance->includes(); |
|---|
| 85 | self::$instance->objects(); |
|---|
| 86 | // Hook now that all of the Bloghash stuff is loaded. |
|---|
| 87 | do_action( 'bloghash_loaded' ); |
|---|
| 88 | } |
|---|
| 89 | return self::$instance; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | /** |
|---|
| 93 | * Setup constants. |
|---|
| 94 | * |
|---|
| 95 | * @since 1.0.0 |
|---|
| 96 | * @return void |
|---|
| 97 | */ |
|---|
| 98 | private function constants() { |
|---|
| 99 | if ( ! defined( 'BLOGHASH_THEME_VERSION' ) ) { |
|---|
| 100 | define( 'BLOGHASH_THEME_VERSION', $this->version ); |
|---|
| 101 | } |
|---|
| 102 | if ( ! defined( 'BLOGHASH_THEME_URI' ) ) { |
|---|
| 103 | define( 'BLOGHASH_THEME_URI', get_parent_theme_file_uri() ); |
|---|
| 104 | } |
|---|
| 105 | if ( ! defined( 'BLOGHASH_THEME_PATH' ) ) { |
|---|
| 106 | define( 'BLOGHASH_THEME_PATH', get_parent_theme_file_path() ); |
|---|
| 107 | } |
|---|
| 108 | } |
|---|
| 109 | /** |
|---|
| 110 | * Include files. |
|---|
| 111 | * |
|---|
| 112 | * @since 1.0.0 |
|---|
| 113 | * @return void |
|---|
| 114 | */ |
|---|
| 115 | public function includes() { |
|---|
| 116 | require_once BLOGHASH_THEME_PATH . '/inc/common.php'; |
|---|
| 117 | require_once BLOGHASH_THEME_PATH . '/inc/helpers.php'; |
|---|
| 118 | require_once BLOGHASH_THEME_PATH . '/inc/widgets.php'; |
|---|
| 119 | require_once BLOGHASH_THEME_PATH . '/inc/template-tags.php'; |
|---|
| 120 | require_once BLOGHASH_THEME_PATH . '/inc/template-parts.php'; |
|---|
| 121 | require_once BLOGHASH_THEME_PATH . '/inc/icon-functions.php'; |
|---|
| 122 | require_once BLOGHASH_THEME_PATH . '/inc/breadcrumbs.php'; |
|---|
| 123 | require_once BLOGHASH_THEME_PATH . '/inc/class-bloghash-dynamic-styles.php'; |
|---|
| 124 | // Core. |
|---|
| 125 | require_once BLOGHASH_THEME_PATH . '/inc/core/class-bloghash-options.php'; |
|---|
| 126 | require_once BLOGHASH_THEME_PATH . '/inc/core/class-bloghash-enqueue-scripts.php'; |
|---|
| 127 | require_once BLOGHASH_THEME_PATH . '/inc/core/class-bloghash-fonts.php'; |
|---|
| 128 | require_once BLOGHASH_THEME_PATH . '/inc/core/class-bloghash-theme-setup.php'; |
|---|
| 129 | // Compatibility. |
|---|
| 130 | require_once BLOGHASH_THEME_PATH . '/inc/compatibility/woocommerce/class-bloghash-woocommerce.php'; |
|---|
| 131 | require_once BLOGHASH_THEME_PATH . '/inc/compatibility/socialsnap/class-bloghash-socialsnap.php'; |
|---|
| 132 | require_once BLOGHASH_THEME_PATH . '/inc/compatibility/class-bloghash-wpforms.php'; |
|---|
| 133 | require_once BLOGHASH_THEME_PATH . '/inc/compatibility/class-bloghash-jetpack.php'; |
|---|
| 134 | require_once BLOGHASH_THEME_PATH . '/inc/compatibility/class-bloghash-beaver-themer.php'; |
|---|
| 135 | require_once BLOGHASH_THEME_PATH . '/inc/compatibility/class-bloghash-elementor.php'; |
|---|
| 136 | require_once BLOGHASH_THEME_PATH . '/inc/compatibility/class-bloghash-elementor-pro.php'; |
|---|
| 137 | require_once BLOGHASH_THEME_PATH . '/inc/compatibility/class-bloghash-hfe.php'; |
|---|
| 138 | |
|---|
| 139 | if ( is_admin() ) { |
|---|
| 140 | require_once BLOGHASH_THEME_PATH . '/inc/utilities/class-bloghash-plugin-utilities.php'; |
|---|
| 141 | require_once BLOGHASH_THEME_PATH . '/inc/admin/class-bloghash-admin.php'; |
|---|
| 142 | |
|---|
| 143 | } |
|---|
| 144 | new Bloghash_Enqueue_Scripts(); |
|---|
| 145 | // Customizer. |
|---|
| 146 | require_once BLOGHASH_THEME_PATH . '/inc/customizer/class-bloghash-customizer.php'; |
|---|
| 147 | require_once BLOGHASH_THEME_PATH . '/inc/customizer/customizer-callbacks.php'; |
|---|
| 148 | require_once BLOGHASH_THEME_PATH . '/inc/customizer/class-bloghash-section-ordering.php'; |
|---|
| 149 | } |
|---|
| 150 | /** |
|---|
| 151 | * Setup objects to be used throughout the theme. |
|---|
| 152 | * |
|---|
| 153 | * @since 1.0.0 |
|---|
| 154 | * @return void |
|---|
| 155 | */ |
|---|
| 156 | public function objects() { |
|---|
| 157 | |
|---|
| 158 | bloghash()->options = new Bloghash_Options(); |
|---|
| 159 | bloghash()->fonts = new Bloghash_Fonts(); |
|---|
| 160 | bloghash()->icons = new Bloghash_Icons(); |
|---|
| 161 | bloghash()->customizer = new Bloghash_Customizer(); |
|---|
| 162 | if ( is_admin() ) { |
|---|
| 163 | bloghash()->admin = new Bloghash_Admin(); |
|---|
| 164 | } |
|---|
| 165 | } |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | /** |
|---|
| 169 | * The function which returns the one Bloghash instance. |
|---|
| 170 | * |
|---|
| 171 | * Use this function like you would a global variable, except without needing |
|---|
| 172 | * to declare the global. |
|---|
| 173 | * |
|---|
| 174 | * Example: <?php $bloghash = bloghash(); ?> |
|---|
| 175 | * |
|---|
| 176 | * @since 1.0.0 |
|---|
| 177 | * @return object |
|---|
| 178 | */ |
|---|
| 179 | function bloghash() { |
|---|
| 180 | return Bloghash::instance(); |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | bloghash(); |
|---|
| 184 | |
|---|