-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
195 lines (182 loc) · 4.64 KB
/
example.php
File metadata and controls
195 lines (182 loc) · 4.64 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
/**
* Created by PhpStorm.
* User: fisso
* Date: 26/12/2018
* Time: 17:29
*/
use ItalyStrap\Asset;
//add_filter( 'italystrap_config_enqueue_style', function ( array $style ) {
//
// $min = '.min';
//
// /**
// * Avoid caching script
// *
// * @var int
// */
// $ver = null;
//
// $suffix = '.min';
//
// $dev_dir = '';
//
// if ( WP_DEBUG ) {
//
// $ver = rand( 0, 100000 );
// // $suffix = '';
// // $dev_dir = 'src/'; // Sistemare il path corretto per i font
//
// }
//
// /**
// * Only for
// * @link http://www.bootstrapcdn.com/alpha/
// */
// $style[] = array(
// 'handle' => 'bootstrap',
// 'file' => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/css/bootstrap.min.css',
// 'deps' => null,
// 'version' => $ver,
// 'media' => null,
// /**
// * With external file you have to preregister the style
// */
// 'pre_register' => true,
// /**
// * If you want to load only with WP_DEBUG true.
// */
// 'load_on' => WP_DEBUG, // bool
// );
//
// $style[] = array(
// 'handle' => CURRENT_TEMPLATE_SLUG,
// 'file' =>
// file_exists( STYLESHEETPATH . '/css/' . $dev_dir . CURRENT_TEMPLATE_SLUG . '.css' )
// ? STYLESHEETURL . '/css/' . $dev_dir . CURRENT_TEMPLATE_SLUG . '.css'
// : STYLESHEETURL . '/css/' . $dev_dir . 'custom.css',
// // 'deps' => array( 'bootstrap' ),
// 'version' => $ver,
// 'media' => null,
// // 'load_on' => 'is_single',
// );
//
// return $style;
//
//}, 10, 1 );
//
//add_filter( 'italystrap_config_enqueue_script', function ( array $script ) {
//
// $script[] = array(
// 'handle' => 'livereload', // Required
// 'file' => '//localhost:35729/livereload.js', // Required
// 'in_footer' => true,
// 'load_on' => WP_DEBUG,
// );
//
// $script[] = array(
// 'handle' => 'jquery',
// 'file' => 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js',
// 'deps' => false,
// 'version' => $ver,
// 'in_footer' => true,
// 'deregister' => true, // This will deregister previous registered jQuery.
// 'pre_register' => true, // And this will register the new jQuery.
// );
//
// $script[] = array(
// 'handle' => CURRENT_TEMPLATE_SLUG,
// 'file' => file_exists( STYLESHEETPATH . '/js/' . CURRENT_TEMPLATE_SLUG . $min . '.js' ) ? STYLESHEETURL . '/js/' . CURRENT_TEMPLATE_SLUG . $min . '.js' : STYLESHEETURL . '/js/custom' . $min . '.js',
// 'deps' => array( 'jquery' ),
// 'version' => $ver,
// 'in_footer' => true,
// );
//
// $script[] = array(
// /**
// * You can call a preregistered script.
// */
// 'handle' => 'comment-reply',
// 'load_on' => 'ItalyStrap\Core\is_comment_reply',
// );
//
// return $script;
//}, 10, 1 );
/**
*
*/
function load_assets() {
// d( current_filter() );
$min = '.min';
/**
* Avoid caching script
*
* @var int
*/
$ver = null;
$suffix = '.min';
$dev_dir = '';
if ( SCRIPT_DEBUG ) {
// $ver = filemtime( 'full/path/of/the/file' );
// $ver = filemtime($file);
// $suffix = '';
// $dev_dir = 'src/'; // Sistemare il path corretto per i font
}
$config = [
'script' => [
// [
// 'handle' => 'jquery',
// 'file' => '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js',
// 'deps' => false,
// 'version' => $ver,
// 'in_footer' => true,
// 'pre_register' => true,
// 'deregister' => true, // This will deregister previous registered jQuery.
// ],
[
'handle' => 'handle',
'file' => '/js/custom' . $min . '.js',
'deps' => ['jquery'],
'version' => $ver,
'in_footer' => true,
/**
* For now the localize object is set only if the script is not deregister
* and if is appendend to the config array of the script to load.
*/
'localize' => [
'object_name' => 'pluginParams',
'params' => [
'ajaxurl' => admin_url( '/admin-ajax.php' ),
'ajaxnonce' => wp_create_nonce( 'ajaxnonce' ),
// 'api_endpoint' => site_url( '/wp-json/rest/v1/' ),
],
],
],
[
'handle' => 'comment-reply',
'load_on' => true,
],
],
'style' => [
[
'handle' => 'example_handle',
// 'file' => __DIR__ . 'custom.css',
'file' => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css',
// 'version' => $ver,
'media' => null,
],
[
'handle' => 'handle',
'file' => 'custom.css',
'version' => $ver,
'media' => null,
],
],
];
// $loader = ( new Asset\Loader() )->run( $config );
//
// add_action( 'wp_enqueue_scripts', [ $loader, 'add_assets' ], 10, 1 );
// add_action( 'admin_enqueue_scripts', [ $loader, 'add_assets' ], 10, 1 );
// add_action( 'login_enqueue_scripts', [ $loader, 'add_assets' ], 10, 1 );
}
add_action( 'after_setup_theme', 'load_assets' );