-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
140 lines (113 loc) · 3.54 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
use {=namespaceSlug=}\postTypes\MainPostTypeProvider;
use {=namespaceSlug=}\core\ThemeOptions;
use {=namespaceSlug=}\core\Menus;
use {=namespaceSlug=}\core\PartialFinder;
use {=namespaceSlug=}\core\RestApiCustomRoutes;
use {=namespaceSlug=}\core\RewriteRules;
use {=namespaceSlug=}\core\WordpressDefaults;
use {=namespaceSlug=}\core\ThemeUpdateChecker;
use {=namespaceSlug=}\core\AcfDefaults;
use {=namespaceSlug=}\core\RoleManagement;
use {=namespaceSlug=}\blocks\MainBlockProvider;
use {=namespaceSlug=}\providers\AdvancedImagesProvider;
define( 'INCLUDE_PATH', get_template_directory() . '/inc/' );
define( 'TEMPLATE_PATH', get_template_directory() . '/' );
define( 'INCLUDE_URL', get_template_directory_uri() );
define( 'FS_METHOD', 'direct' );
if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
add_action( 'admin_notices', function () {
?>
<div class="notice notice-error">
<h2>Missing <i>vendor/autoloader.php</i></h2>
<p>
<strong>
You are missing composer autoload. Please run <i>composer install</i> in root of your project.
</strong>
</p>
</div>
<?php
} );
return;
}
/**
* If this command fails try to run "composer dump" in the theme root directory
*/
require_once __DIR__ . '/vendor/autoload.php';
if ( class_exists( '{=namespaceSlug=}\core\ThemeUpdateChecker' ) ) {
//Initialize the update checker.
$example_update_checker = new ThemeUpdateChecker(
'{=folderName=}', //Theme folder name, AKA "slug".
'{=liveServerPath=}?identifier={=projectIdentifier=}&type=manifest' //URL of the metadata file.
);
add_action( 'load-themes.php', function () use ( $example_update_checker ) {
$example_update_checker->check_for_updates();
} );
}
$main_post_type_provider = new MainPostTypeProvider();
$main_post_type_provider->register();
$theme_options = new ThemeOptions();
$theme_options->register();
$rest_api_custom_routes = new RestApiCustomRoutes();
$rest_api_custom_routes->register();
$menus = new Menus();
$menus->register();
$wordpress_defaults = new WordpressDefaults();
$wordpress_defaults->init();
$role_management = new RoleManagement();
$role_management->init();
$rewrite_rules = new RewriteRules();
$rewrite_rules->register();
$acf_defaults = new AcfDefaults();
$acf_defaults->init();
// initializing main gutenberg block provider
$main_block_provider = new MainBlockProvider();
$main_block_provider->init();
// Must use AdvancedImagesPlugin v3.3.1+
$advanced_images_provider = new AdvancedImagesProvider();
$advanced_images_provider->register_image_sizes();
/**
* Pretty dump
*
* @param $obj
*/
function dump( $obj ) {
echo "<pre class='debug'>";
var_dump( $obj );
echo "</pre>";
}
/**
* Base url convertion method.
*
* @param $url
*
* @return string
*/
function bu( $url ) {
$clean = trim( $url );
return INCLUDE_URL . "/static/" . $clean;
}
function au( $url ) {
$clean = trim( $url );
return get_template_directory() . "/static/" . $clean;
}
function get_partial( $partial, $data = null, $return = false, $folder = PartialFinder::PARTIAL_FOLDER ) {
return PartialFinder::get_instance()->get_partial( $partial, $data, $return, $folder );
}
/**
* Get icon method.
*
* @param $name
*
* @return string
*/
function get_icon( $name ) {
return get_partial( 'icons/icon-' . $name, [], true, 'static' );
}
function bf_content( int $id = null ) {
global $post;
if ( empty( $id ) ) {
$id = $post->ID;
}
return apply_filters( 'the_content', get_post_field( 'post_content', $id ) );
}