-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponsive-fonts.php
761 lines (684 loc) · 43.6 KB
/
responsive-fonts.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
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
<?php
/*
Plugin Name: Responsive Fonts
Description: This is a plugin that will give the average wordpress user the ability to customize the size of their font responsively, changing the size on mobile, tablet and desktop in one simple place.
Version: 1.0.0
Author: Donte Henley
Author URI: https://www.dontehenley.com
License: GPLv2 or later
Text Domain: responsive-fonts
*/
if (!defined('ABSPATH')) die ('No direct access allowed');
//Setting up options in customizer
function responsive_fonts_customize_register( $wp_customize ) {
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'responsive_fonts__options',
array(
'title' => __( 'Responsive Fonts', 'responsiveFonts' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Set font size responsively according to screen size.', 'responsiveFonts'), //Descriptive tooltip
)
);
$wp_customize->add_setting( 'default_body_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_default_body_font',
array(
'label' => __( 'Body Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'default_body_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 10, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'desktop_body_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_desktop_body_font',
array(
'label' => __( 'Desktop Body Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'desktop_body_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 11, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'tablet_body_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_tablet_body_font',
array(
'label' => __( 'Tablet Body Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'tablet_body_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 12, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'mobile_body_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_mobile_body_font',
array(
'label' => __( 'Mobile Body Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'mobile_body_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 13, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'responsive_fonts__options',
array(
'title' => __( 'Responsive Fonts', 'responsiveFonts' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Set font size responsively according to screen size.', 'responsiveFonts'), //Descriptive tooltip
)
);
$wp_customize->add_setting( 'default_h1_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_default_h1_font',
array(
'label' => __( 'H1 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'default_h1_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 14, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'desktop_h1_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_desktop_h1_font',
array(
'label' => __( 'Desktop H1 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'desktop_h1_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 15, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'tablet_h1_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_tablet_h1_font',
array(
'label' => __( 'Tablet H1 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'tablet_h1_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 16, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'mobile_h1_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_mobile_h1_font',
array(
'label' => __( 'Mobile H1 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'mobile_h1_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 17, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'responsive_fonts__options',
array(
'title' => __( 'Responsive Fonts', 'responsiveFonts' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Set font size responsively according to screen size.', 'responsiveFonts'), //Descriptive tooltip
)
);
$wp_customize->add_setting( 'default_h2_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_default_h2_font',
array(
'label' => __( 'H2 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'default_h2_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 18, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'desktop_h2_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_desktop_h2_font',
array(
'label' => __( 'Desktop H2 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'desktop_h2_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 19, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'tablet_h2_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_tablet_h2_font',
array(
'label' => __( 'Tablet H2 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'tablet_h2_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 20, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'mobile_h2_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_mobile_h2_font',
array(
'label' => __( 'Mobile H2 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'mobile_h2_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 21, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'responsive_fonts__options',
array(
'title' => __( 'Responsive Fonts', 'responsiveFonts' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Set font size responsively according to screen size.', 'responsiveFonts'), //Descriptive tooltip
)
);
$wp_customize->add_setting( 'default_h3_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_default_h3_font',
array(
'label' => __( 'H3 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'default_h3_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 22, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'desktop_h3_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_desktop_h3_font',
array(
'label' => __( 'Desktop H3 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'desktop_h3_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 23, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'tablet_h3_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_tablet_h3_font',
array(
'label' => __( 'Tablet H3 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'tablet_h3_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 24, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'mobile_h3_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_mobile_h3_font',
array(
'label' => __( 'Mobile H3 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'mobile_h3_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 25, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'responsive_fonts__options',
array(
'title' => __( 'Responsive Fonts', 'responsiveFonts' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Set font size responsively according to screen size.', 'responsiveFonts'), //Descriptive tooltip
)
);
$wp_customize->add_setting( 'default_h4_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_default_h4_font',
array(
'label' => __( 'H4 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'default_h4_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 26, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'desktop_h4_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_desktop_h4_font',
array(
'label' => __( 'Desktop H4 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'desktop_h4_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 27, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'tablet_h4_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_tablet_h4_font',
array(
'label' => __( 'Tablet H4 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'tablet_h4_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 28, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'mobile_h4_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_mobile_h4_font',
array(
'label' => __( 'Mobile H4 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'mobile_h4_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 29, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'responsive_fonts__options',
array(
'title' => __( 'Responsive Fonts', 'responsiveFonts' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Set font size responsively according to screen size.', 'responsiveFonts'), //Descriptive tooltip
)
);
$wp_customize->add_setting( 'default_h5_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_default_h5_font',
array(
'label' => __( 'H5 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'default_h5_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 30, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'desktop_h5_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_desktop_h5_font',
array(
'label' => __( 'Desktop H4 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'desktop_h5_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 31, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'tablet_h5_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_tablet_h5_font',
array(
'label' => __( 'Tablet H5 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'tablet_h5_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 32, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'mobile_h5_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_mobile_h5_font',
array(
'label' => __( 'Mobile H4 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'mobile_h5_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 33, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'responsive_fonts__options',
array(
'title' => __( 'Responsive Fonts', 'responsiveFonts' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Set font size responsively according to screen size.', 'responsiveFonts'), //Descriptive tooltip
)
);
$wp_customize->add_setting( 'default_h6_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_default_h6_font',
array(
'label' => __( 'H6 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'default_h6_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 34, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'desktop_h6_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_desktop_h6_font',
array(
'label' => __( 'Desktop H6 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'desktop_h6_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 35, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'tablet_h6_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_tablet_h6_font',
array(
'label' => __( 'Tablet H6 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'tablet_h6_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 36, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
$wp_customize->add_setting( 'mobile_h6_font', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
//'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'responsiveFonts_mobile_h6_font',
array(
'label' => __( 'Mobile H6 Font Size', 'responsiveFonts' ), //Admin-visible name of the control
'settings' => 'mobile_h6_font', //Which setting to load and manipulate (serialized is okay)
'priority' => 37, //Determines the order this control appears in for the specified section
'section' => 'responsive_fonts__options', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
)
) );
}
add_action( 'customize_register', 'responsive_fonts_customize_register' );
/*
* Code to output CSS
*/
function responsiveFonts_customize_css()
{
$mobile_max = "576px";
$tablet_min = "700px";
$tablet_max = "1219.99px";
$desktop = "1220px";
?>
<style type="text/css">
:root{
--RFdefaultBodyFontSize: <?php echo get_theme_mod('default_body_font'); ?>;
--RFdefaultH1FontSize: <?php echo get_theme_mod('default_h1_font'); ?>;
--RFdefaultH2FontSize: <?php echo get_theme_mod('default_h2_font'); ?>;
--RFdefaultH3FontSize: <?php echo get_theme_mod('default_h3_font'); ?>;
--RFdefaultH4FontSize: <?php echo get_theme_mod('default_h4_font'); ?>;
--RFdefaultH5FontSize: <?php echo get_theme_mod('default_h5_font'); ?>;
--RFdefaultH6FontSize: <?php echo get_theme_mod('default_h6_font'); ?>;
--RFdesktopBodyFontSize: <?php echo get_theme_mod('desktop_body_font'); ?>;
--RFdesktopH1FontSize: <?php echo get_theme_mod('desktop_h1_font'); ?>;
--RFdesktopH2FontSize: <?php echo get_theme_mod('desktop_h2_font'); ?>;
--RFdesktopH3FontSize: <?php echo get_theme_mod('desktop_h3_font'); ?>;
--RFdesktopH4FontSize: <?php echo get_theme_mod('desktop_h4_font'); ?>;
--RFdesktopH5FontSize: <?php echo get_theme_mod('desktop_h5_font'); ?>;
--RFdesktopH6FontSize: <?php echo get_theme_mod('desktop_h6_font'); ?>;
--RFtabletBodyFontSize: <?php echo get_theme_mod('tablet_body_font'); ?>;
--RFtabletH1FontSize: <?php echo get_theme_mod('tablet_h1_font'); ?>;
--RFtabletH2FontSize: <?php echo get_theme_mod('tablet_h2_font'); ?>;
--RFtabletH3FontSize: <?php echo get_theme_mod('tablet_h3_font'); ?>;
--RFtabletH4FontSize: <?php echo get_theme_mod('tablet_h4_font'); ?>;
--RFtabletH5FontSize: <?php echo get_theme_mod('tablet_h5_font'); ?>;
--RFtabletH6FontSize: <?php echo get_theme_mod('tablet_h6_font'); ?>;
--RFmobileFontSize: <?php echo get_theme_mod('mobile_body_font'); ?>;
--RFmobileH1FontSize: <?php echo get_theme_mod('mobile_h1_font'); ?>;
--RFmobileH2FontSize: <?php echo get_theme_mod('mobile_h2_font'); ?>;
--RFmobileH3FontSize: <?php echo get_theme_mod('mobile_h3_font'); ?>;
--RFmobileH4FontSize: <?php echo get_theme_mod('mobile_h4_font'); ?>;
--RFmobileH5FontSize: <?php echo get_theme_mod('mobile_h5_font'); ?>;
--RFmobileH6FontSize: <?php echo get_theme_mod('mobile_h6_font'); ?>;
}
body p { font-size: var(--RFdefaultBodyFontSize); }
h1 { font-size: var(--RFdefaultH1FontSize); }
h2 { font-size: var(--RFdefaultH2FontSize); }
h3 { font-size: var(--RFdefaultH3FontSize); }
h4 { font-size: var(--RFdefaultH4FontSize); }
h5 { font-size: var(--RFdefaultH5FontSize); }
h6 { font-size: var(--RFdefaultH6FontSize); }
@media screen and (max-width: <?php echo $mobile_max; ?>) {
body p { font-size: var(--RFmobileBodyFontSize); }
h1 { font-size: var(--RFmobileH1FontSize); }
h2 { font-size: var(--RFmobileH2FontSize); }
h3 { font-size: var(--RFmobileH3FontSize); }
h4 { font-size: var(--RFmobileH4FontSize); }
h5 { font-size: var(--RFmobileH5FontSize); }
h6 { font-size: var(--RFmobileH6FontSize); }
}
@media screen and (min-width: <?php echo $tablet_min; ?>) and (max-width: <?php echo $tablet_max; ?>) {
body p { font-size: var(--RFtabletBodyFontSize); }
h1 { font-size: var(--RFtabletH1FontSize); }
h2 { font-size: var(--RFtabletH2FontSize); }
h3 { font-size: var(--RFtabletH3FontSize); }
h4 { font-size: var(--RFtabletH4FontSize); }
h5 { font-size: var(--RFtabletH5FontSize); }
h6 { font-size: var(--RFtabletH6FontSize); }
}
@media screen and (min-width: <?php echo $desktop; ?>) {
body p { font-size: var(--RFdesktopBodyFontSize); }
h1 { font-size: var(--RFdesktopH1FontSize); }
h2 { font-size: var(--RFdesktopH2FontSize); }
h3 { font-size: var(--RFdesktopH3FontSize); }
h4 { font-size: var(--RFdesktopH4FontSize); }
h5 { font-size: var(--RFdesktopH5FontSize); }
h6 { font-size: var(--RFdesktopH6FontSize); }
}
</style>
<?php
}
add_action( 'wp_head', 'responsiveFonts_customize_css');
$theme_version = wp_get_theme()->get( 'Version' );
// Add main customizer js file.
wp_enqueue_script( 'responsive-font', plugin_dir_url( __FILE__ ) . 'js/customize.js', array( 'jquery' ), $theme_version, false );
/*
* Code to output JS
function responsiveFonts_customize_js()
{
?>
<script>
( function( $, api, _ ) {
// Add listener for the "default body font" control.
api( 'default_body_font', function( value ) {
value.bind( function( to ) {
// Add background color to header and footer wrappers.
$( 'body:not(.overlay-header)#site-header, body p' ).css( 'font-size', to );
} );
} );
})
</script>
<?php
}
add_action( 'wp_footer', 'responsiveFonts_customize_js');
*/