PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / trunk
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF vtrunk
2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / libs / factory / forms / controls / font.php
robin-image-optimizer / libs / factory / forms / controls Last commit date
customs 5 months ago holders 5 months ago checkbox.php 5 months ago color-and-opacity.php 5 months ago color.php 5 months ago datepicker-range.php 5 months ago dropdown-and-colors.php 5 months ago dropdown.php 5 months ago font.php 5 months ago google-font.php 5 months ago gradient.php 5 months ago hidden.php 5 months ago index.php 5 months ago integer.php 5 months ago list.php 5 months ago multiple-textbox.php 5 months ago paddings-editor.php 5 months ago pattern.php 5 months ago radio-colors.php 5 months ago radio.php 5 months ago textarea.php 5 months ago textbox.php 5 months ago url.php 5 months ago wp-editor.php 5 months ago
font.php
261 lines
1 <?php
2
3 /**
4 * Dropdown List Control
5 *
6 * Main options:
7 * name => a name of the control
8 * value => a value to show in the control
9 * default => a default value of the control if the "value" option is not specified
10 * items => a callback to return items or an array of items to select
11 *
12 * @package core
13 * @since 1.0.0
14 */
15 // Exit if accessed directly
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 if ( ! class_exists( 'Wbcr_FactoryForms600_FontControl' ) ) {
21
22 class Wbcr_FactoryForms600_FontControl extends Wbcr_FactoryForms600_ComplexControl {
23
24 public $type = 'font';
25
26 public function __construct( $options, $form, $provider = null ) {
27 parent::__construct( $options, $form, $provider );
28
29 $option_font_size = [
30 'name' => $this->options['name'] . '__size',
31 'units' => $this->options['units'],
32 'default' => isset( $this->options['default'] )
33 ? $this->options['default']['size']
34 : null,
35 ];
36
37 $option_font_family = [
38 'name' => $this->options['name'] . '__family',
39 'data' => $this->getFonts(),
40 'default' => isset( $this->options['default'] )
41 ? $this->options['default']['family']
42 : null,
43 ];
44
45 $optionFontColor = [
46 'name' => $this->options['name'] . '__color',
47 'default' => isset( $this->options['default'] )
48 ? $this->options['default']['color']
49 : null,
50 'pickerTarget' => '.factory-control-' . $this->options['name'] . ' .factory-picker-target',
51 ];
52
53 $this->size = new Wbcr_FactoryForms600_IntegerControl( $option_font_size, $form, $provider );
54 $this->family = new Wbcr_FactoryForms600_DropdownControl( $option_font_family, $form, $provider );
55 $this->color = new Wbcr_FactoryForms600_ColorControl( $optionFontColor, $form, $provider );
56
57 $this->innerControls = [ $this->family, $this->size, $this->color ];
58 }
59
60 public function getFonts() {
61
62 $fonts = $this->getDefaultFonts();
63
64 $fonts = apply_filters( 'wbcr_factory_forms_600_fonts', $fonts );
65 $fonts = apply_filters( 'wbcr_factory_forms_600_fonts-' . $this->options['name'], $fonts );
66
67 return $fonts;
68 }
69
70 public function getDefaultFonts() {
71
72 $fonts = [
73
74 [ 'inherit', '(' . __( 'Use default website font', 'robin-image-optimizer' ) . ')' ],
75 [
76 'group',
77 __( 'Sans Serif:', 'robin-image-optimizer' ),
78 [
79 [ 'Arial, "Helvetica Neue", Helvetica, sans-serif', 'Arial' ],
80 [ '"Arial Black", "Arial Bold", Gadget, sans-serif', 'Arial Black' ],
81 [ '"Arial Narrow", Arial, sans-serif', 'Arial Narrow' ],
82 [
83 '"Arial Rounded MT Bold", "Helvetica Rounded", Arial, sans-serif',
84 'Arial Rounded MT Bold',
85 ],
86 [
87 '"Avant Garde", Avantgarde, "Century Gothic", CenturyGothic, "AppleGothic", sans-serif',
88 'Avant Garde',
89 ],
90 [ 'Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif', 'Calibri' ],
91 [ 'Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif', 'Candara' ],
92 [ '"Century Gothic", CenturyGothic, AppleGothic, sans-serif', 'Century Gothic' ],
93 [
94 '"Franklin Gothic Medium", "Franklin Gothic", "ITC Franklin Gothic", Arial, sans-serif',
95 'Franklin Gothic Medium',
96 ],
97 [ 'Futura, "Trebuchet MS", Arial, sans-serif', 'Futura' ],
98 [ 'Geneva, Tahoma, Verdana, sans-serif', 'Geneva' ],
99 [ '"Gill Sans", "Gill Sans MT", Calibri, sans-serif', 'Gill Sans' ],
100 [ '"Helvetica Neue", Helvetica, Arial, sans-serif', 'Helvetica' ],
101 [
102 'Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", sans serif',
103 'Impact',
104 ],
105 [
106 '"Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif',
107 'Lucida Grande',
108 ],
109 [ 'Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif', 'Optima' ],
110 [
111 '"Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif',
112 'Segoe UI',
113 ],
114 [
115 'Montserrat, "Segoe UI", "Helvetica Neue", Arial, sans-serif',
116 'Montserrat',
117 ],
118 [ 'Tahoma, Verdana, Segoe, sans-serif', 'Tahoma' ],
119 [
120 '"Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, sans-serif',
121 'Trebuchet MS',
122 ],
123 [ 'Verdana, Geneva, sans-serif', 'Verdana' ],
124 ],
125 ],
126 [
127 'group',
128 __( 'Serif:', 'robin-image-optimizer' ),
129 [
130 [
131 'Baskerville, "Baskerville Old Face", "Hoefler Text", Garamond, "Times New Roman", serif',
132 'Baskerville',
133 ],
134 [ '"Big Caslon", "Book Antiqua", "Palatino Linotype", Georgia, serif', 'Big Caslon' ],
135 [
136 '"Bodoni MT", Didot, "Didot LT STD", "Hoefler Text", Garamond, "Times New Roman", serif',
137 'Bodoni MT',
138 ],
139 [
140 '"Book Antiqua", Palatino, "Palatino Linotype", "Palatino LT STD", Georgia, serif',
141 'Book Antiqua',
142 ],
143 [
144 '"Calisto MT", "Bookman Old Style", Bookman, "Goudy Old Style", Garamond, "Hoefler Text", "Bitstream Charter", Georgia, serif',
145 'Calisto MT',
146 ],
147 [ 'Cambria, Georgia, serif', 'Cambria' ],
148 [ 'Didot, "Didot LT STD", "Hoefler Text", Garamond, "Times New Roman", serif', 'Didot' ],
149 [
150 'Garamond, Baskerville, "Baskerville Old Face", "Hoefler Text", "Times New Roman", serif',
151 'Garamond',
152 ],
153 [ 'Georgia, Times, "Times New Roman", serif', 'Georgia' ],
154 [
155 '"Goudy Old Style", Garamond, "Big Caslon", "Times New Roman", serif',
156 'Goudy Old Style',
157 ],
158 [
159 '"Hoefler Text", "Baskerville old face", Garamond, "Times New Roman", serif',
160 'Hoefler Text',
161 ],
162 [ '"Lucida Bright", Georgia, serif', 'Lucida Bright' ],
163 [
164 'Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif',
165 'Palatino',
166 ],
167 [
168 'Perpetua, Baskerville, "Big Caslon", "Palatino Linotype", Palatino, "URW Palladio L", "Nimbus Roman No9 L", serif',
169 'Perpetua',
170 ],
171 [
172 'Rockwell, "Courier Bold", Courier, Georgia, Times, "Times New Roman", serif',
173 'Rockwell',
174 ],
175 [ '"Rockwell Extra Bold", "Rockwell Bold", monospace', 'Rockwell Extra Bold' ],
176 [
177 'TimesNewRoman, "Times New Roman", Times, Baskerville, Georgia, serif',
178 'Times New Roman',
179 ],
180 ],
181 ],
182 [
183 'group',
184 __( 'Monospaced:', 'robin-image-optimizer' ),
185 [
186 [ '"Andale Mono", AndaleMono, monospace', 'Andale Mono' ],
187 [ 'Consolas, monaco, monospace', 'Consolas' ],
188 [
189 '"Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace',
190 'Courier New',
191 ],
192 [
193 '"Lucida Console", "Lucida Sans Typewriter", Monaco, "Bitstream Vera Sans Mono", monospace',
194 'Lucida Console',
195 ],
196 [
197 '"Lucida Sans Typewriter", "Lucida Console", Monaco, "Bitstream Vera Sans Mono", monospace',
198 'Lucida Sans Typewriter',
199 ],
200 [ 'Monaco, Consolas, "Lucida Console", monospace', 'Monaco' ],
201 ],
202 ],
203
204 ];
205
206 return $fonts;
207 }
208
209 /**
210 * Removes \" in the font family value.
211 *
212 * @since 3.1.0
213 * @return mixed[]
214 */
215 public function getValuesToSave() {
216 $values = parent::getValuesToSave();
217
218 $family_key = sanitize_key( $this->options['name'] ) . '__family';
219 $values[ $family_key ] = sanitize_text_field( $values[ $family_key ] );
220
221 return $values;
222 }
223
224 public function beforeControlsHtml() {
225 }
226
227 public function afterControlsHtml() {
228 }
229
230 /**
231 * Shows the html markup of the control.
232 *
233 * @since 1.0.0
234 * @return void
235 */
236 public function html() {
237 ?>
238 <div <?php $this->attrs(); ?>>
239 <div class="factory-control-row">
240 <?php $this->beforeControlsHtml(); ?>
241
242 <div class="factory-family-wrap">
243 <?php $this->family->html(); ?>
244 </div>
245 <div class="factory-size-wrap">
246 <?php $this->size->html(); ?>
247 </div>
248 <div class="factory-color-wrap">
249 <?php $this->color->html(); ?>
250 </div>
251
252 <?php $this->afterControlsHtml(); ?>
253 </div>
254 <div class="factory-picker-target"></div>
255 </div>
256 <?php
257 }
258 }
259 }
260
261