Skip to content

Commit c01b5a5

Browse files
authored
ADDED - Default standard options for option fields
v2.5.5 - Changelog = ADDED - Default standard options for option fields
1 parent ea72ef8 commit c01b5a5

File tree

2 files changed

+364
-2
lines changed

2 files changed

+364
-2
lines changed

dilaz-metabox.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin URI: http://webdilaz.com/plugins/dilaz-metabox/
55
* Description: Create custom metaboxes for WordPress themes and plugins.
66
* Author: WebDilaz Team
7-
* Version: 2.5.4
7+
* Version: 2.5.5
88
* Author URI: http://webdilaz.com/
99
* License: GPL-2.0+
1010
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@@ -15,7 +15,7 @@
1515
||
1616
|| @package Dilaz Metabox
1717
|| @subpackage Metabox
18-
|| @version 2.5.4
18+
|| @version 2.5.5
1919
|| @since Dilaz Metabox 2.0
2020
|| @author WebDilaz Team, http://webdilaz.com
2121
|| @copyright Copyright (C) 2017, WebDilaz LTD
@@ -32,6 +32,11 @@
3232
*/
3333
require_once plugin_dir_path(__FILE__) .'inc/functions.php';
3434

35+
/**
36+
* DilazMetabox defaults
37+
*/
38+
require_once plugin_dir_path(__FILE__) .'inc/defaults.php';
39+
3540

3641
/**
3742
* DilazMetabox main class

inc/defaults.php

Lines changed: 357 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
<?php
2+
/*
3+
|| --------------------------------------------------------------------------------------------
4+
|| Metabox Defaults
5+
|| --------------------------------------------------------------------------------------------
6+
||
7+
|| @package Dilaz Metabox
8+
|| @subpackage Defaults
9+
|| @since Dilaz Metabox 2.5.5
10+
|| @author WebDilaz Team, http://webdilaz.com
11+
|| @copyright Copyright (C) 2019, WebDilaz LTD
12+
|| @link http://webdilaz.com/metabox
13+
|| @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
14+
||
15+
*/
16+
17+
defined('ABSPATH') || exit;
18+
19+
class DilazMetaboxDefaults {
20+
21+
function __construct() {
22+
23+
}
24+
25+
/**
26+
* Background defaults
27+
*
28+
* @since 2.5.5
29+
*
30+
* @return array
31+
*/
32+
public static function _bg() {
33+
34+
$bg_defaults = array(
35+
'image' => '',
36+
'repeat' => array(
37+
'' => '',
38+
'no-repeat' => __('No Repeat', 'dilaz-panel'),
39+
'repeat' => __('Repeat All', 'dilaz-panel'),
40+
'repeat-x' => __('Repeat Horizontally', 'dilaz-panel'),
41+
'repeat-y' => __('Repeat Vertically', 'dilaz-panel'),
42+
'inherit' => __('Inherit', 'dilaz-panel'),
43+
),
44+
'size' => array(
45+
'' => '',
46+
'cover' => __('Cover', 'dilaz-panel'),
47+
'contain' => __('Contain', 'dilaz-panel'),
48+
'inherit' => __('Inherit', 'dilaz-panel'),
49+
),
50+
'position' => array(
51+
'' => '',
52+
'top left' => __('Top Left', 'dilaz-panel'),
53+
'top center' => __('Top Center', 'dilaz-panel'),
54+
'top right' => __('Top Right', 'dilaz-panel'),
55+
'center left' => __('Center Left', 'dilaz-panel'),
56+
'center center' => __('Center Center', 'dilaz-panel'),
57+
'center right' => __('Center Right', 'dilaz-panel'),
58+
'bottom left' => __('Bottom Left', 'dilaz-panel'),
59+
'bottom center' => __('Bottom Center', 'dilaz-panel'),
60+
'bottom right' => __('Bottom Right', 'dilaz-panel')
61+
),
62+
'attachment' => array(
63+
'' => '',
64+
'fixed' => __('Fixed', 'dilaz-panel'),
65+
'scroll' => __('Scroll', 'dilaz-panel'),
66+
'inherit' => __('Inherit', 'dilaz-panel'),
67+
),
68+
'origin' => array(
69+
'' => '',
70+
'content-box' => __('Content Box', 'dilaz-panel'),
71+
'border-box' => __('Border Box', 'dilaz-panel'),
72+
'padding-box' => __('Padding Box', 'dilaz-panel'),
73+
),
74+
'color' => '',
75+
);
76+
77+
$bg_defaults = apply_filters('dilaz_mb_bg_defaults', $bg_defaults);
78+
79+
foreach ($bg_defaults as $k => $v) {
80+
$bg_defaults[$k] = is_array($v) ? array_map('sanitize_text_field', $v) : sanitize_text_field($bg_defaults[$k]);
81+
}
82+
83+
return $bg_defaults;
84+
}
85+
86+
87+
/**
88+
* Multicolor defaults
89+
*
90+
* @since 2.5.5
91+
*
92+
* @return array
93+
*/
94+
public static function _multicolor() {
95+
$multicolor_defaults = array();
96+
$multicolor_defaults = apply_filters('dilaz_mb_multicolor_defaults', $multicolor_defaults);
97+
$multicolor_defaults = array_map('sanitize_hex_color', $multicolor_defaults);
98+
return $multicolor_defaults;
99+
}
100+
101+
102+
/**
103+
* Get Google Fonts
104+
*
105+
* @since 2.5.5
106+
*
107+
* @return array
108+
*/
109+
public static function _getGoogleFonts() {
110+
111+
$g_fonts_array = array();
112+
$get_g_fonts = file_get_contents(dirname(__FILE__).'/google-fonts.json');
113+
if ($get_g_fonts !== false && !empty($get_g_fonts)) {
114+
$g_fonts_array = json_decode($get_g_fonts, true);
115+
foreach ((array)$g_fonts_array as $font => &$atts) {
116+
foreach ($atts['variants'] as $ke => &$val) {
117+
foreach ($val as $k => &$v) {
118+
if (isset($v['url']))
119+
unset($v['url']);
120+
}
121+
}
122+
}
123+
}
124+
125+
return apply_filters('dilaz_mb_get_google_fonts', $g_fonts_array);
126+
}
127+
128+
129+
/**
130+
* Google Fonts
131+
*
132+
* @since 2.5.5
133+
*
134+
* @return array
135+
*/
136+
public static function _googleFonts() {
137+
138+
$g_fonts = DilazMetaboxDefaults::_getGoogleFonts();
139+
$g_font_names = [];
140+
141+
foreach ((array)$g_fonts as $font_name => &$atts) {
142+
$g_font_names[$font_name] = $font_name;
143+
}
144+
145+
return apply_filters('dilaz_mb_google_fonts', $g_font_names);
146+
}
147+
148+
149+
/**
150+
* Font defaults
151+
*
152+
* @since 2.5.5
153+
*
154+
* @return array
155+
*/
156+
public static function _font() {
157+
$font_defaults = array(
158+
'family' => 'verdana',
159+
'subset' => '',
160+
'size' => 'normal',
161+
'size' => '14',
162+
'height' => '16',
163+
'style' => '',
164+
'case' => '',
165+
'color' => '#555'
166+
);
167+
$font_defaults = apply_filters('dilaz_mb_font_defaults', $font_defaults);
168+
$font_defaults = array_map('sanitize_text_field', $font_defaults);
169+
return $font_defaults;
170+
}
171+
172+
173+
/**
174+
* Font family defaults
175+
*
176+
* @since 2.5.5
177+
*
178+
* @return array
179+
*/
180+
public static function _font_family() {
181+
$font_family = wp_parse_args(DilazMetaboxDefaults::_googleFonts(), array(
182+
'' => '',
183+
'arial' => 'Arial',
184+
'verdana' => 'Verdana, Geneva',
185+
'trebuchet' => 'Trebuchet',
186+
'georgia' => 'Georgia',
187+
'times' => 'Times New Roman',
188+
'tahoma' => 'Tahoma, Geneva',
189+
'palatino' => 'Palatino',
190+
'helvetica' => 'Helvetica',
191+
));
192+
$font_family = apply_filters('dilaz_mb_font_family', $font_family);
193+
$font_family = array_map('sanitize_text_field', $font_family);
194+
return $font_family;
195+
}
196+
197+
198+
/**
199+
* Font subset defaults
200+
*
201+
* @since 2.5.5
202+
*
203+
* @return array
204+
*/
205+
public static function _font_subset() {
206+
$font_subset = array(
207+
'' => '',
208+
'arabic' => 'arabic',
209+
'bengali' => 'bengali',
210+
'cyrillic' => 'cyrillic',
211+
'cyrillic-ext' => 'cyrillic-ext',
212+
'devanagari' => 'devanagari',
213+
'greek' => 'greek',
214+
'greek-ext' => 'greek-ext',
215+
'gujarati' => 'gujarati',
216+
'gurmukhi' => 'gurmukhi',
217+
'hebrew' => 'hebrew',
218+
'kannada' => 'kannada',
219+
'khmer' => 'khmer',
220+
'latin' => 'latin',
221+
'latin-ext' => 'latin-ext',
222+
'malayalam' => 'malayalam',
223+
'myanmar' => 'myanmar',
224+
'oriya' => 'oriya',
225+
'sinhala' => 'sinhala',
226+
'tamil' => 'tamil',
227+
'telugu' => 'telugu',
228+
'thai' => 'thai',
229+
'vietnamese' => 'vietnamese',
230+
);
231+
$font_subset = apply_filters('dilaz_mb_font_subset', $font_subset);
232+
$font_subset = array_map('sanitize_text_field', $font_subset);
233+
return $font_subset;
234+
}
235+
236+
237+
/**
238+
* Font size defaults
239+
*
240+
* @since 2.5.5
241+
*
242+
* @return array
243+
*/
244+
public static function _font_sizes() {
245+
$font_sizes = range(6, 100);
246+
$font_sizes = apply_filters('dilaz_mb_font_sizes', $font_sizes);
247+
$font_sizes = array_map('absint', $font_sizes);
248+
return $font_sizes;
249+
}
250+
251+
252+
/**
253+
* Font height defaults
254+
*
255+
* @since 2.5.5
256+
*
257+
* @return array
258+
*/
259+
public static function _font_heights() {
260+
$font_heights = range(10, 70);
261+
$font_heights = apply_filters('dilaz_mb_font_heights', $font_heights);
262+
$font_heights = array_map('absint', $font_heights);
263+
return $font_heights;
264+
}
265+
266+
267+
/**
268+
* Font weight defaults
269+
*
270+
* @since 2.5.5
271+
*
272+
* @return array
273+
*/
274+
public static function _font_weights() {
275+
$font_weights = array(
276+
'' => '',
277+
'100' => 'Ultra-Light 100',
278+
'200' => 'Light 200',
279+
'300' => 'Book 300',
280+
'400' => 'Normal 400',
281+
'500' => 'Medium 500',
282+
'600' => 'Semi-Bold 600',
283+
'700' => 'Bold 700',
284+
'800' => 'Extra-Bold 800',
285+
'900' => 'Ultra-Bold 900',
286+
'normal' => 'Normal',
287+
'lighter' => 'Lighter',
288+
'bold' => 'Bold',
289+
'bolder' => 'Bolder',
290+
'inherit' => 'Inherit',
291+
'initial' => 'Initial'
292+
);
293+
$font_weights = apply_filters('dilaz_mb_font_weights', $font_weights);
294+
$font_weights = array_map('sanitize_text_field', $font_weights);
295+
return $font_weights;
296+
}
297+
298+
299+
/**
300+
* Font style defaults
301+
*
302+
* @since 2.5.5
303+
*
304+
* @return array
305+
*/
306+
public static function _font_styles() {
307+
$font_styles = array(
308+
'' => '',
309+
'normal' => 'Normal',
310+
'italic' => 'Italic',
311+
'oblique' => 'Oblique',
312+
'inherit' => 'Inherit',
313+
'initial' => 'Initial'
314+
);
315+
$font_styles = apply_filters('dilaz_mb_font_styles', $font_styles);
316+
$font_styles = array_map('sanitize_text_field', $font_styles);
317+
return $font_styles;
318+
}
319+
320+
321+
/**
322+
* Font case defaults
323+
*
324+
* @since 2.5.5
325+
*
326+
* @return array
327+
*/
328+
329+
public static function _font_cases() {
330+
$font_cases = array(
331+
'' => '',
332+
'none' => 'None',
333+
'uppercase' => 'Uppercase',
334+
'lowercase' => 'Lowercase',
335+
'capitalize' => 'Capitalize'
336+
);
337+
$font_cases = apply_filters('dilaz_mb_font_cases', $font_cases);
338+
$font_cases = array_map('sanitize_text_field', $font_cases);
339+
return $font_cases;
340+
}
341+
342+
343+
/**
344+
* Integer range defaults
345+
*
346+
* @since 2.5.5
347+
*
348+
* @return array
349+
*/
350+
public static function _int_range($min, $max) {
351+
$ints = range($min, $max);
352+
$ints = apply_filters('dilaz_mb_int_range', $ints);
353+
$ints = array_map('absint', $ints);
354+
return $ints;
355+
}
356+
357+
}

0 commit comments

Comments
 (0)