-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathilldy-main.php
More file actions
393 lines (316 loc) · 13.3 KB
/
Copy pathilldy-main.php
File metadata and controls
393 lines (316 loc) · 13.3 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<?php
if ( ! defined( 'WPINC' ) ) {
die;
}
// Include Illdy Companion Helper
require_once plugin_dir_path( __FILE__ ) . 'inc/class-illdy-companion-helper.php';
// Include Illdy Companion Importer
require_once plugin_dir_path( __FILE__ ) . 'inc/class-illdy-companion-import-data.php';
// The importer's admin page. Loaded after the importer itself, which it calls into.
require_once plugin_dir_path( __FILE__ ) . 'inc/class-illdy-companion-importer-page.php';
/**
* Plugin companion widgets
*/
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-illdy-widget-recent-posts.php';
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-illdy-widget-skill.php';
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-illdy-widget-project.php';
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-illdy-widget-service.php';
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-illdy-widget-counter.php';
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-illdy-widget-person.php';
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-illdy-widget-parallax.php';
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-illdy-widget-testimonial.php';
if ( ! function_exists( 'illdy_companion_admin_scripts' ) ) {
/**
* Function to enqueue admin resources - CSS/JS
*/
function illdy_companion_admin_scripts( $hook_suffix ) {
/*
* These used to load on every single admin screen, roughly 50 KB of CSS and JS
* on pages that never reference any of it. Only the widgets screen needs them
* now — it hosts the icon picker and the media control. The Customizer is served
* by illdy_companion_customizer_scripts() below, and the demo importer page
* loads its own script from Illdy_Companion_Importer_Page.
*/
if ( 'widgets.php' !== $hook_suffix ) {
return;
}
wp_enqueue_style( 'illdy-companion-admin-css', ILLDY_COMPANION_ASSETS_DIR . 'css/admin.css', array(), ILLDY_COMPANION );
wp_enqueue_style( 'font-awesome', ILLDY_COMPANION_ASSETS_DIR . 'css/font-awesome.min.css', array(), '4.5.0', 'all' );
wp_enqueue_style( 'illdy-companion-iconpicker-css', ILLDY_COMPANION_ASSETS_DIR . 'css/jquery.fonticonpicker.css', array(), ILLDY_COMPANION );
wp_enqueue_style( 'illdy-companion-iconpicker-theme-css', ILLDY_COMPANION_ASSETS_DIR . 'css/jquery.fonticonpicker.grey.min.css', array(), ILLDY_COMPANION );
wp_enqueue_script( 'illdy-companion-iconpicker-js', ILLDY_COMPANION_ASSETS_DIR . 'js/iconpicker.min.js', array( 'jquery' ), ILLDY_COMPANION, true );
wp_enqueue_script( 'illdy-widget-text-editor', ILLDY_COMPANION_ASSETS_DIR . 'js/widget-text-editor.js', array( 'jquery' ), ILLDY_COMPANION, true );
}
add_action( 'admin_enqueue_scripts', 'illdy_companion_admin_scripts' );
}
if ( ! function_exists( 'illdy_companion_customizer_scripts' ) ) {
/**
* Function to enqueue admin resources - CSS/JS
*/
function illdy_companion_customizer_scripts() {
wp_enqueue_style( 'illdy-companion-iconpicker-css', ILLDY_COMPANION_ASSETS_DIR . 'css/jquery.fonticonpicker.css', array(), ILLDY_COMPANION );
wp_enqueue_style( 'font-awesome', ILLDY_COMPANION_ASSETS_DIR . 'css/font-awesome.min.css', array(), '4.5.0', 'all' );
wp_enqueue_script( 'illdy-companion-iconpicker-js', ILLDY_COMPANION_ASSETS_DIR . 'js/iconpicker.min.js', array( 'jquery' ), ILLDY_COMPANION, true );
wp_enqueue_style( 'illdy-companion-iconpicker-theme-css', ILLDY_COMPANION_ASSETS_DIR . 'css/jquery.fonticonpicker.grey.min.css', array(), ILLDY_COMPANION );
/*
* admin.js is gone. Both of its handlers bound to welcome-screen markup — the
* "Advanced" toggle and the import button — and it read a nonce off the
* welcomeScreen object the theme localised. None of that exists any more; the
* importer page ships its own script.
*/
}
add_action( 'customize_controls_enqueue_scripts', 'illdy_companion_customizer_scripts' );
}
if ( ! function_exists( 'illdy_companion_customize_register' ) ) {
/**
* Function that adds back the customizer sections we were asked to remove from the theme
*
* @param $wp_customize
*/
function illdy_companion_customize_register( $wp_customize ) {
// Set prefix
$prefix = 'illdy';
if ( ! $wp_customize->get_setting( $prefix . '_services_general_entry' ) ) {
$wp_customize->add_setting(
$prefix . '_services_general_entry', array(
'sanitize_callback' => 'wp_kses_post',
'default' => __( 'In order to help you grow your business, our carefully selected experts can advise you in in the following areas:', 'illdy-companion' ),
'transport' => 'postMessage',
)
);
if ( class_exists( 'Illdy_Control_Text_Editor' ) ) {
$wp_customize->add_control(
new Illdy_Control_Text_Editor(
$wp_customize, $prefix . '_services_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'section' => $prefix . '_panel_services',
'priority' => 3,
'type' => 'illdy-text-editor',
)
)
);
} else {
$wp_customize->add_control(
$prefix . '_services_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'description' => __( 'Add the content for this section.', 'illdy-companion' ),
'section' => $prefix . '_panel_services',
'priority' => 3,
'type' => 'textarea',
)
);
}
}
if ( ! $wp_customize->get_setting( $prefix . '_team_general_entry' ) ) {
$wp_customize->add_setting(
$prefix . '_team_general_entry', array(
'sanitize_callback' => 'wp_kses_post',
'default' => __( 'Meet the people that are going to take your business to the next level.', 'illdy-companion' ),
'transport' => 'postMessage',
)
);
if ( class_exists( 'Illdy_Control_Text_Editor' ) ) {
$wp_customize->add_control(
new Illdy_Control_Text_Editor(
$wp_customize, $prefix . '_team_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'section' => $prefix . '_panel_team',
'priority' => 3,
'type' => 'illdy-text-editor',
)
)
);
} else {
$wp_customize->add_control(
$prefix . '_team_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'description' => __( 'Add the content for this section.', 'illdy-companion' ),
'section' => $prefix . '_panel_team',
'priority' => 3,
'type' => 'textarea',
)
);
}
}
if ( ! $wp_customize->get_setting( $prefix . '_about_general_entry' ) ) {
$wp_customize->add_setting(
$prefix . '_about_general_entry', array(
'sanitize_callback' => 'wp_kses_post',
'default' => __( 'It is an amazing one-page theme with great features that offers an incredible experience. It is easy to install, make changes, adapt for your business. A modern design with clean lines and styling for a wide variety of content, exactly how a business design should be. You can add as many images as you want to the main header area and turn them into slider.', 'illdy-companion' ),
'transport' => 'postMessage',
)
);
if ( class_exists( 'Illdy_Control_Text_Editor' ) ) {
$wp_customize->add_control(
new Illdy_Control_Text_Editor(
$wp_customize, $prefix . '_about_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'section' => $prefix . '_panel_about',
'priority' => 3,
'type' => 'illdy-text-editor',
)
)
);
} else {
$wp_customize->add_control(
$prefix . '_about_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'description' => __( 'Add the content for this section.', 'illdy-companion' ),
'section' => $prefix . '_panel_about',
'priority' => 3,
'type' => 'textarea',
)
);
}
}
if ( ! $wp_customize->get_setting( $prefix . '_jumbotron_general_entry' ) ) {
$wp_customize->add_setting(
$prefix . '_jumbotron_general_entry', array(
'sanitize_callback' => 'wp_kses_post',
'default' => __( 'lldy is a great one-page theme, perfect for developers and designers but also for someone who just wants a new website for his business. Try it now!', 'illdy-companion' ),
'transport' => 'postMessage',
)
);
if ( class_exists( 'Illdy_Control_Text_Editor' ) ) {
$wp_customize->add_control(
new Illdy_Control_Text_Editor(
$wp_customize, $prefix . '_jumbotron_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'section' => $prefix . '_jumbotron_general',
'priority' => 5,
'type' => 'illdy-text-editor',
)
)
);
} else {
$wp_customize->add_control(
$prefix . '_jumbotron_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'description' => __( 'The content added in this field will show below title.', 'illdy-companion' ),
'section' => $prefix . '_jumbotron_general',
'priority' => 5,
'type' => 'textarea',
)
);
}
}
if ( ! $wp_customize->get_setting( $prefix . '_latest_news_general_entry' ) ) {
$wp_customize->add_setting(
$prefix . '_latest_news_general_entry', array(
'sanitize_callback' => 'wp_kses_post',
'default' => __( 'If you are interested in the latest articles in the industry, take a sneak peek at our blog. You have nothing to loose!', 'illdy-companion' ),
'transport' => 'postMessage',
)
);
if ( class_exists( 'Illdy_Control_Text_Editor' ) ) {
$wp_customize->add_control(
new Illdy_Control_Text_Editor(
$wp_customize, $prefix . '_latest_news_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'section' => $prefix . '_latest_news_general',
'priority' => 3,
'type' => 'illdy-text-editor',
)
)
);
} else {
$wp_customize->add_control(
$prefix . '_latest_news_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'description' => __( 'Add the content for this section.', 'illdy-companion' ),
'section' => $prefix . '_latest_news_general',
'priority' => 3,
'type' => 'textarea',
)
);
}
}
if ( ! $wp_customize->get_setting( $prefix . '_projects_general_entry' ) ) {
$wp_customize->add_setting(
$prefix . '_projects_general_entry', array(
'sanitize_callback' => 'wp_kses_post',
'default' => __( 'You\'ll love our work. Check it out!', 'illdy-companion' ),
'transport' => 'postMessage',
)
);
if ( class_exists( 'Illdy_Control_Text_Editor' ) ) {
$wp_customize->add_control(
new Illdy_Control_Text_Editor(
$wp_customize, $prefix . '_projects_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'section' => $prefix . '_panel_projects',
'priority' => 3,
'type' => 'illdy-text-editor',
)
)
);
} else {
$wp_customize->add_control(
$prefix . '_projects_general_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'description' => __( 'Add the content for this section.', 'illdy-companion' ),
'section' => $prefix . '_panel_projects',
'priority' => 3,
'type' => 'textarea',
)
);
}
}
if ( ! $wp_customize->get_setting( $prefix . '_contact_us_entry' ) ) {
$wp_customize->add_setting(
$prefix . '_contact_us_entry', array(
'sanitize_callback' => 'wp_kses_post',
'default' => __( 'And we will get in touch as soon as possible.', 'illdy-companion' ),
'transport' => 'postMessage',
)
);
if ( class_exists( 'Illdy_Control_Text_Editor' ) ) {
$wp_customize->add_control(
new Illdy_Control_Text_Editor(
$wp_customize, $prefix . '_contact_us_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'section' => $prefix . '_contact_us',
'priority' => 3,
'type' => 'illdy-text-editor',
)
)
);
} else {
$wp_customize->add_control(
$prefix . '_contact_us_entry', array(
'label' => __( 'Entry', 'illdy-companion' ),
'description' => __( 'Add the content for this section.', 'illdy-companion' ),
'section' => $prefix . '_contact_us',
'priority' => 3,
'type' => 'textarea',
)
);
}
}
}
// hook our function
add_action( 'customize_register', 'illdy_companion_customize_register', 20 );
} // End if().
/**
* Resolves an attachment id to its full-size URL for the widget media pickers.
*
* Previously this ran for any authenticated user with no nonce and no capability
* check, letting a subscriber walk attachment ids and read back the URL of any
* upload on the site, including media attached to private or draft posts.
*/
function illdy_get_attachment_image() {
if ( ! current_user_can( 'upload_files' ) ) {
wp_send_json_error( 'forbidden', 403 );
}
check_ajax_referer( 'illdy_get_attachment_media', 'nonce' );
$id = isset( $_POST['attachment_id'] ) ? absint( wp_unslash( $_POST['attachment_id'] ) ) : 0;
if ( ! $id ) {
wp_die( '', '', array( 'response' => 400 ) );
}
$src = wp_get_attachment_image_src( $id, 'full', false );
if ( ! empty( $src[0] ) ) {
echo esc_url( $src[0] );
}
wp_die();
}
add_action( 'wp_ajax_illdy_get_attachment_media', 'illdy_get_attachment_image' );