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