public static function gen_field($key, $args = array(), $settk = '', $r = false) { // Get option key $vars = Skeleteon_Generic::get_plug_vars(); $settk = empty($settk) ? $vars['plug_opt'] : sanitize_key($settk); // Get stored values from options option. $stored_vals = get_option($settk); //var_dump($stored_vals); $stored_val = null; // Skeleteon_Generic::vd($stored_vals,true,'svals'); // Default values for input $defaults = (require $vars['plug_dir'] . 'skeleteon/inc/input_defaults.php'); // Convert classes to arrays if strings are given // var_dump($args['class']); /*if( ! is_array( $args['wrap_cl'] ) ) { $args['wrap_cl'] = explode(' ',$args['wrap_cl']); if( ! is_array( $args['wrap_cl'] ) ) array($args['wrap_cl']); array_unique($args['wrap_cl']); }*/ foreach ($args as $ak => $av) { if (is_array($av) && array_key_exists($ak, $defaults)) { $args[$ak] = wp_parse_args($av, $defaults[$ak]); } } $args = wp_parse_args($args, $defaults); $args['name'] ? $name = $settk . '[' . $args['name'] . ']' : ($name = $settk . '[' . $key . ']'); $value = $args['std']; if (!is_array($value)) { $value = stripslashes($value); } // the things that need to be array $arr_args = array('class', 'label_cl', 'wrap_cl', 'validate'); foreach ($arr_args as $arr_arg) { if (!is_array($args[$arr_arg])) { $args[$arr_arg] = explode(' ', $args[$arr_arg]); if (!is_array($args[$arr_arg])) { array($args[$arr_arg]); } array_unique($args[$arr_arg]); } } if (!empty($args['descr']['lbl_cl'])) { if (!is_array($args['descr']['lbl_cl'])) { $args['descr']['lbl_cl'] = explode(' ', $args['descr']['lbl_cl']); if (!is_array($args['descr']['lbl_cl'])) { array($args['descr']['lbl_cl']); } array_unique($args['descr']['lbl_cl']); } } $args['wrap_cl'][] = 'wrap-' . $args['type']; /* if( ! is_array( $args['label_cl'] ) ) { $args['label_cl'] = explode(' ',$args['label_cl']); if( ! is_array( $args['label_cl'] ) ) array($args['label_cl']); array_unique($args['label_cl']); } if ( is_string( $args['class'] ) ) $args['class'] = array( $args['class'] ); if ( is_string( $args['label_cl'] ) ) $args['label_cl'] = array( $args['label_cl'] ); if ( is_string( $args['wrap_cl'] ) ) $args['wrap_cl'] = array( $args['wrap_cl'] );*/ // if($args['type'] == 'checkbox' && empty($value) || $args['type'] == 'checkbox_onoff' && empty($value) ) $value = '0'; // Stored values if ($stored_vals && array_key_exists($key, $stored_vals)) { $stored_val = $stored_vals[$key]; } if (isset($stored_val)) { $value = $stored_val; } $descr = $args['descr']; // Add input classes // if( $args['type'] ); $args['class'][] = 'input-' . $args['type']; // Add validate classes if ($args['required']) { $args['class'][] = 'vldt-req'; $required = ' <span class="rq" title="' . esc_attr__('Required', $vars['lang_slug']) . '">*</span>'; } else { $required = ''; } if (!empty($args['validate'])) { foreach ($args['validate'] as $validate) { $args['class'][] = 'vldt-' . $validate; } } // if ( $args['required'] ) if ( $args['class'] ) implode( ' ', $args['class'] ); $args['maxlength'] = $args['maxlength'] ? 'maxlength="' . absint($args['maxlength']) . '"' : ''; if (!empty($descr['txt'])) { $descr['lbl'] ? $descl = 'dwlbl ' : ($descl = ' '); $descr_html = '<input id="' . esc_attr($key) . '_cboxt" type="checkbox" '; if ($descr['coll']) { $descr_html .= 'checked="checked" '; } $descr_html .= 'class="cbox_toggle_i" role="button"><label class="cbox_toggle descr_lbl ' . $descl . esc_attr(implode(' ', $descr['lbl_cl'])) . '" for="' . esc_attr($key) . '_cboxt">'; if ($descr['lbl']) { $descr_html .= '<span class="label label-success cbt_s">+ ' . esc_attr($descr['lbl']) . '</span><span class="label label-info cbt_h">— ' . esc_attr($descr['lbl']) . '</span>'; } else { $descr_html .= '<span class="label label-info cbt_s">i</span><span class="label label-default cbt_h">i</span>'; } $descr_html .= '</label>'; $descr_html .= '<div class="cbt_cont well inpdescr">' . $descr['txt'] . '</div>'; } // Custom attribute handling $custom_attributes = array(); if (!empty($args['custom_attributes']) && is_array($args['custom_attributes'])) { foreach ($args['custom_attributes'] as $attribute => $attribute_value) { $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"'; } } $inp_before = wp_kses_post($args['before']); if ($args['wrap']) { $inp_before .= '<div class="' . esc_attr(implode(' ', $args['wrap_cl'])) . '" id="wrap_' . esc_attr($key) . '">'; } if ($args['abbr']) { $inp_before .= '<abbr title="' . esc_attr($args['abbr']) . '">'; } if ($args['label']) { $inp_before .= '<label for="' . esc_attr($key) . '" class="' . trim('main-lbl ' . esc_attr(implode(' ', $args['label_cl']))) . '">' . $args['label'] . $required . ' : </label>'; } if ($args['abbr']) { $inp_before .= '</abbr>'; } if ($args['wrapinp']) { $inp_before .= '<span class="inpwrap">'; } $inp_after = ''; if ($args['wrapinp']) { $inp_after .= '</span>'; } if (!empty($descr['txt'])) { $inp_after .= $descr_html; } if ($args['wrap']) { $inp_after .= '</div>'; } $inp_after .= wp_kses_post($args['after']); // var_dump($args); switch ($args['type']) { case "text": case "colorpicker": // if ( $args['type'] == 'colorpicker' ) $args['class'][] = 'wp-color-picker-field'; $field = $inp_before; $field .= '<input type="text" class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($name) . '" id="' . esc_attr($key) . '" placeholder="' . esc_attr($args['placeholder']) . '" ' . $args['maxlength'] . ' value="' . esc_attr($value) . '" ' . implode(' ', $custom_attributes) . ' />'; $field .= $inp_after; break; case "textarea": $field = $inp_before; $field .= '<textarea name="' . esc_attr($name) . '" class="input-text ' . esc_attr(implode(' ', $args['class'])) . '" id="' . esc_attr($key) . '" placeholder="' . esc_attr($args['placeholder']) . '"' . (empty($args['custom_attributes']['rows']) ? ' rows="2"' : '') . (empty($args['custom_attributes']['cols']) ? ' cols="20"' : '') . implode(' ', $custom_attributes) . '>' . esc_textarea($value) . '</textarea>'; $field .= $inp_after; break; case "checkbox": // Regular checkbox if (!$args['misc']) { $field = $inp_before; $field .= '<input type="' . esc_attr($args['type']) . '" class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($name) . '" id="' . esc_attr($key) . '" '; // eopfw_endswith('[]',$name) !empty($value) ? $field .= checked($value, $value, false) . ' />' : ($field .= checked($value, 1, false) . ' />'); $field .= $inp_after; } else { if ($args['misc']['onoff']) { $field = '<div class="cbox_wrapper form-group wrap-checkbox">'; $field .= '<label class="onoff_name" for="' . esc_attr($key) . '">' . $args['label'] . ' : </label>'; $field .= '<div class="onoffswitch">'; $field .= '<input id="' . esc_attr($key) . '" class="input-onoff onoffswitch-checkbox ' . esc_attr(implode(' ', $args['class'])) . '" type="checkbox" name="' . esc_attr($name) . '" '; !empty($value) ? $field .= checked($value, $value, false) . ' />' : ($field .= checked($value, 1, false) . ' />'); $field .= '<label class="explain onoffswitch-label" for="' . esc_attr($key) . '" title="' . esc_attr($descr['txt']) . '"><div class="onoffswitch-inner"><div class="onoffswitch-active"><div class="onoffswitch-switch">' . __('ON') . '</div></div><div class="onoffswitch-inactive"><div class="onoffswitch-switch">' . __('OFF') . '</div></div></div></label></div>'; $field .= '</div>'; } } break; case "select": $field = $inp_before; $field .= '<select class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($name) . '" id="' . esc_attr($key) . '"' . implode(' ', $custom_attributes) . '>'; foreach ($args['options'] as $k => $opttxt) { $field .= '<option' . selected($value, $k, false) . ' value="' . esc_attr($k) . '">' . esc_html($opttxt) . '</option>'; } $field .= '</select>'; $field .= $inp_after; break; case "radio": $field = $inp_before; foreach ($args['options'] as $k => $optxt) { $field .= '<input type="radio" class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($name) . '" id="' . esc_attr($key . '_' . $k) . '" value="' . esc_attr($k) . '" '; $field .= checked($value, $k, false) . ' />'; $field .= '<label for="' . esc_attr($key . '_' . $k) . '" class="' . implode(' ', $args['label_cl']) . '">' . $optxt . '</label>'; } $field .= $inp_after; break; case "upload": $field = $inp_before; $field .= self::gen_uploader($settk, $key, $value, null, '', $vars['lang_slug']); $field .= $inp_after; break; case "images": $field = $inp_before; // var_dump($args); $field .= '<input id="' . esc_attr($key) . '_imgs_cboxt" type="checkbox" '; $field .= 'class="cbox_toggle_i" role="button"><label class="cbox_toggle" for="' . esc_attr($key) . '_imgs_cboxt">'; $field .= '<span class="label label-success cbt_s">+ Show Images</span><span class="label label-default cbt_h">— Hide Images</span>'; $field .= '</label>'; $field .= '<div class="row imagesrow well cbt_cont togglebox">'; foreach ($args['options'] as $k => $imgsrc) { list($w, $h) = getimagesize($imgsrc); $irat = $w / $h; $rcl = $irat > 1 ? 'horz' : 'vert'; if ($irat > 2) { $rcl .= ' h2x'; } elseif ($irat > 3) { $rcl .= ' h3x'; } $selected = $value != '' && $value == $k ? ' selected' : ''; $field .= '<div class="radio-img-wrap ' . $rcl . $selected . ' col-xs-6 col-md-4 col-lg-3">'; $field .= '<span class="radio-imglbl">' . esc_html($k) . '</span>'; $field .= '<input type="radio" class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($name) . '" id="' . esc_attr($key . '_' . $k) . '" value="' . esc_attr($k) . '" '; $field .= checked($value, $k, false) . ' />'; $field .= '<img src="' . esc_url($imgsrc) . '" alt="' . $k . '" title="' . $k . '" class="radio-img img-responsive" />'; $field .= '</div>'; } $field .= '</div>'; $field .= $inp_after; break; case "multicheck": $field = $inp_before; foreach ($args['options'] as $k => $ctxt) { $is_checked = in_array($k, $value); // $val = $value[$k]; $field .= '<input type="checkbox" class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($name . '[' . $k . ']') . '" id="' . esc_attr($key . '_' . $k) . '" ' . checked($is_checked, true, false) . '/>'; $field .= '<label for="' . esc_attr($key . '_' . $k) . '" class="' . implode(' ', $args['label_cl']) . '">' . $ctxt . '</label>'; } $field .= $inp_after; break; case "multiselect": $field = $inp_before; $field .= '<select multiple="multiple" class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($name) . '[]" id="' . esc_attr($key) . '"' . implode(' ', $custom_attributes) . '>'; foreach ($args['options'] as $k => $opttxt) { $is_selected = in_array($k, $value); $field .= '<option ' . selected($is_selected, true, false) . ' value="' . esc_attr($k) . '">' . esc_html($opttxt) . '</option>'; } $field .= '</select>'; $field .= $inp_after; break; case 'typography': $field = $inp_before; unset($font_face, $font_style, $font_size, $font_color, $font_subset); $os_font_faces = (require_once $vars['plug_dir'] . 'skeleteon/xtra/os_fonts.php'); // If we have a proper Google Fonts transient in place $gf_trans_name = $vars['reg_transients']['google_fonts']; $gfjson_trans = get_transient($gf_trans_name); if ($gfjson_trans && is_array($gfjson_trans) && !empty($gfjson_trans)) { $google_font_faces = $gfjson_trans; } else { // _eo-review: Merge local file & google api requested json data process into 1 step as $gf_json_src ? $google_font_faces_rebuilt = array(); // For google fonts we should have a prefetched json file already. $gfjson_file = $vars['plug_dir'] . 'skeleteon/xtra/gfjsondump.txt'; if (file_exists($gfjson_file)) { $gfjson_file_uri = $vars['plug_uri'] . 'skeleteon/xtra/gfjsondump.txt'; $gf_json = wp_remote_fopen($gfjson_file_uri); $gf_json_data = json_decode($gf_json, true); // var_dump($gf_json_data); //$google_font_faces = $gf_json_data['items']; // Get rid of unnecessary data, key the items, and save as transient for convenience. foreach ($gf_json_data['items'] as $gfitem) { $lite_item = array('family' => $gfitem['family'], 'category' => $gfitem['category'], 'variants' => $gfitem['variants'], 'subsets' => $gfitem['subsets']); // _eo-review: should we sanitize the family name to save as key ? $google_font_faces_rebuilt[$gfitem['family']] = $lite_item; } } else { $gwf_api_key = 'AIzaSyAMO-3ly3H7EJ801RbtRAQ2bkTqyVtGLoE'; $gf_json_uri = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $gwf_api_key; $gf_json = wp_remote_fopen($gf_json_uri); $has_error = array_key_exists('error', $gf_json_data); if (!$has_error) { $gf_json_data = json_decode($gf_json, true); //$google_font_faces = $gf_json_data['items']; foreach ($gf_json_data['items'] as $gfitem) { $lite_item = array('family' => $gfitem['family'], 'category' => $gfitem['category'], 'variants' => $gfitem['variants'], 'subsets' => $gfitem['subsets']); // _eo-review: should we sanitize the family name to save as key ? $google_font_faces_rebuilt[$gfitem['family']] = $lite_item; } } else { $err_reason = $gf_json_data["error"]["errors"][0]["reason"]; $curruri = Skeleteon_Generic::curruri(); $redir_uri = add_query_arg(array('ske_error' => $err_reason, 'ske_errid' => 'gwf_err'), $curruri); Skeleteon_Generic::redir($redir_uri, NULL, array('ske_error' => '')); $google_font_faces_rebuilt = array('Open Sans' => array('family' => 'Open Sans', 'category' => 'sans-serif', 'variants' => array("300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic", "800", "800italic"), 'subsets' => array("latin-ext", "cyrillic-ext", "latin", "greek-ext", "cyrillic", "greek", "vietnamese")), 'Roboto' => array('family' => 'Roboto', 'category' => 'sans-serif', 'variants' => array("100", "100italic", "300", "300italic", "regular", "italic", "500", "500italic", "700", "700italic", "900", "900italic"), 'subsets' => array("latin-ext", "cyrillic-ext", "latin", "greek-ext", "cyrillic", "greek", "vietnamese"))); } } $google_font_faces = $google_font_faces_rebuilt; // save google font faces as transient for convenience and performance. A week should suffice. alt: 7 * DAY_IN_SECONDS set_transient($gf_trans_name, $google_font_faces_rebuilt, 7 * 86400); } $font_source_names = array('os_fonts' => 'Stock OS Fonts', 'gwf_fonts' => 'Google Fonts'); $subset_names = array("greek-ext" => 'Greek Extended', "cyrillic" => 'Cyrillic', 'vietnamese' => 'Vietnamese', 'greek' => 'Greek', 'latin-ext' => 'Latin Extended', 'cyrillic-ext' => 'Cyrillic Extended', 'latin' => 'Latin', 'arabic' => 'Arabic', 'devanagari' => 'Devanagari', 'hebrew' => 'Hebrew', 'khmer' => 'Khmer', 'tamil' => 'Tamil', 'telugu' => 'Telugu', 'thai' => 'Thai'); $combined_font_faces = array('os_fonts' => $os_font_faces, 'gwf_fonts' => $google_font_faces); /* $gfjson_trans = get_transient('ske_gwf_trans'); if( ! $gfjson_trans ) { $gfjson_file = $vars['plug_uri'] . 'skeleteon/xtra/gfjsondump.txt'; //$gfjson = wp_remote_fopen($gfjson_file); // $gwf_api_key = 'AIzaSyAMO-3ly3H7EJ801RbtRAQ2bkTqyVtGLoE'; // https://www.googleapis.com/webfonts/v1/webfonts?key=YOUR-API-KEY // $gf_json_uri = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $gwf_api_key; $gf_json = wp_remote_fopen($gf_json_src); $gf_json_data = json_decode($gf_json,true); $has_error = array_key_exists('error',$gf_json_data); if( $has_error ) { $err_reason = $gf_json_data["error"]["errors"][0]["reason"]; $curruri = Skeleteon_Generic::curruri(); // var_dump($curruri); $redir_uri = add_query_arg(array('ske_error' => $err_reason,'ske_errid' => 'gwf_err'), $curruri); // var_dump($redir_uri); // $redir_uri = $curruri . '&ske_error='.$err_reason . '&ske_errid=gwf_err'; Skeleteon_Generic::redir( $redir_uri, NULL, array('ske_error'=>'') ); } }*/ // var_dump($gf_json_data); // require $vars['plug_dir'] . 'skeleteon/xtra/gfdump.php'; // var_dump($def_gf_array); // array_merge( self::combined_font_faces(); $def_font_styles = array('normal' => __('Normal', $vars['lang_slug']), 'italic' => __('Italic', $vars['lang_slug']), 'bold' => __('Bold', $vars['lang_slug']), 'bold-italic' => __('Bold Italic', $vars['lang_slug'])); $sizes = range(9, 71); $font_sizes = array_map('absint', $sizes); $font_styles = array('normal' => __('Normal', $vars['lang_slug']), 'italic' => __('Italic', $vars['lang_slug']), 'bold' => __('Bold', $vars['lang_slug']), 'bold italic' => __('Bold Italic', $vars['lang_slug'])); $typography_defaults = array('face' => '', 'style' => 'normal', 'subset' => 'Latin', 'size' => '14px', 'color' => ''); $typography_stored = wp_parse_args($value, $typography_defaults); // var_dump($fonts_all); // $all_fonts_sources[$all_font["font_src_slug"]] = $all_font["font_src_name"]; $typography_options = array('faces' => $combined_font_faces, 'subsets' => '', 'variants' => array("regular" => "Regular"), 'sizes' => $font_sizes, 'styles' => $font_styles, 'color' => true); if (isset($value['options'])) { $typography_options = wp_parse_args($value['options'], $typography_options); } /* $font_source = '<select class="ske-typo-source" name="' . esc_attr( $name . '[source]' ) . '" id="' . esc_attr( $key ) . '-source' . '">'; $sources = $typography_options['sources']; foreach ( $sources as $key => $source ) { // $font_source .= '<option value="' . esc_attr( $key ) . '" ' . selected( $typography_stored['source'], $key, false ) . '>' . esc_html( $source ) . '</option>'; $font_source .= '<option'. selected( $typography_stored['source'], $key, false ) .' value="' . esc_attr( $key ) . '">' . esc_html( $source ) . '</option>'; } $font_source .= '</select>';*/ // Font Face // $font_sources = $typography_options['sources']; $all_faces = $typography_options['faces']; // Keep the select as is if it's the stored font, else modify the id and hide // ($stored_s $font_face = '<select class="ske-typo-face" name="' . esc_attr($name . '[face]') . '" id="' . esc_attr($key) . '_face' . '">'; $font_face .= '<option value="">' . __(' — Font Face —', $vars['lang_slug']) . '</option>'; foreach ($all_faces as $font_src_k => $font_faces) { $fontsrcname = $font_source_names[$font_src_k]; $disabled = ''; $font_face .= '<optgroup label="' . $fontsrcname . '".' . $disabled . '>'; foreach ($font_faces as $face) { // var_dump($typography_stored['face'], $face['family']); $fflabel = array_key_exists('label', $face) ? $face['label'] : $face['family']; $font_face .= '<option value="' . wp_kses_normalize_entities($face['family']) . '" ' . selected($typography_stored['face'], $face['family'], false) . '>' . esc_html($fflabel) . '</option>'; } $font_face .= '</optgroup>'; } // $font_face .= '<select class="of-typography of-typography-face '.$k.' '.$hiddclas.'" name="'. $hidd. esc_attr( $option_name . '[' . $value['id'] . '][face]' ) . '" id="'. $hidd. esc_attr( $value['id'] . '_face' ) . '">'; /* foreach ( $all_faces[$k] as $face ) { $fflabel = (array_key_exists('label',$face) ) ? $face['label'] : $face['family']; $font_face .= '<option value="' . wp_kses_normalize_entities( $face['family'] ) . '" ' . selected( $typography_stored['face'], $key, false ) . '>' . esc_html( $fflabel ) . '</option>'; }*/ $font_face .= '</select>'; // var_dump($faces); // Font Styles // if this is a google font face, get specific styles for the font. $is_google_font = $typography_stored['face'] && array_key_exists($typography_stored['face'], $google_font_faces); $styles = $is_google_font ? $google_font_faces[$typography_stored['face']]['variants'] : $typography_options['styles']; // $styles = ( $typography_stored['face'] && array_key_exists($typography_stored['face'],$google_font_faces) ) ? $google_font_faces[$typography_stored['face']]['variants'] : $typography_options['styles']; // var_dump($google_font_faces); // var_dump( in_array($typography_stored['face'],$google_font_faces) ); //var_dump(array_search('Roboto',$google_font_faces) ); // Display styles only for standart fonts, google has variants. $font_style = '<select class="ske-typo-style" name="' . esc_attr($name . '[style]') . '" id="' . esc_attr($key) . '_style' . '">'; $font_style .= '<option value="">' . __(' — Style —', $vars['lang_slug']) . '</option>'; // $font_style = '<select class="of-typography of-typography-style'.$hiddclas.'" name="'.$option_name.'['.$value['id'].'][style]" id="'. $value['id'].'_style">'; foreach ($styles as $style) { $font_style .= '<option value="' . esc_attr($style) . '" ' . selected($typography_stored['style'], $style, false) . '>' . esc_html($style) . '</option>'; } $font_style .= '</select>'; // Font subset if ($is_google_font) { // $subsets = $google_font_faces[$typography_stored['face']]['subsets']; $facesubsets = $google_font_faces[$typography_stored['face']]['subsets']; $font_subset = '<select multiple="multiple" class="ske-typo-subset" name="' . esc_attr($name . '[subset][]') . '" id="' . esc_attr($key) . '_subset' . '">'; $font_subset .= '<option value="">' . __(' — Subset —', $vars['lang_slug']) . '</option>'; foreach ($facesubsets as $subset) { $is_selected = !empty($typography_stored['subset']) && is_array($typography_stored['subset']) && in_array($subset, $typography_stored['subset']); // var_dump(in_array($subset,$typography_stored['subset'])); // var_dump(selected( $is_selected, true, false )); $font_subset .= '<option value="' . esc_attr($subset) . '" ' . selected($is_selected, true, false) . '>' . esc_html($subset_names[$subset]) . '</option>'; } $font_subset .= '</select>'; } /* if ( $typography_options['variants'] ) { $ftg = $typography_stored['face']; // var_dump( $value['id'],$typography_stored['variant'] ); $tsrcs = $typography_stored['source']; ( $tsrcs == "os_font") ? $hiddclas = ' hidv' : $hiddclas = ''; if($typography_stored['face'] && $tsrcs != "os_font") { $variants = eo_get_gwf_variant($ftg); } else { $variants = $typography_options['variants']; } // Display styles only for standart fonts, google has variants. $font_variant = '<select class="of-typography of-typography-variant'.$hiddclas.'" name="'.$option_name.'['.$value['id'].'][variant]" id="'. $value['id'].'_variant">'; // get the variant for the selected font if there's a stored val foreach ( $variants as $variant ) { $font_variant .= '<option value="' . esc_attr( $variant ) . '" ' . selected( $typography_stored['variant'], $variant, false ) . '>'. $variant .'</option>'; } $font_variant .= '</select>'; }*/ // Font Size if ($typography_options['sizes']) { $font_size = '<select class="ske-typo-size" name="' . esc_attr($name . '[size]') . '" id="' . esc_attr($key) . '_size' . '">'; $font_size .= '<option value="">' . __(' — Size —', $vars['lang_slug']) . '</option>'; // $font_size = '<select class="of-typography of-typography-size" name="' . esc_attr( $option_name . '[' . $value['id'] . '][size]' ) . '" id="' . esc_attr( $value['id'] . '_size' ) . '">'; $sizes = $typography_options['sizes']; foreach ($sizes as $i) { $size = $i . 'px'; $font_size .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $font_size .= '</select>'; } // Font Color if ($typography_options['color']) { //var_dump($typography_stored); $default_color = ''; if (isset($value['std']['color'])) { if ($val != $value['std']['color']) { $default_color = ' data-default-color="' . $value['std']['color'] . '" '; } } $font_color = '<input type="text" class="ske-typo-color input-colorpicker" name="' . esc_attr($name . '[color]') . '" id="' . esc_attr($key) . '_color" placeholder="' . esc_attr($args['placeholder']) . '" ' . $args['maxlength'] . ' value="' . esc_attr($typography_stored['color']) . '"' . $default_color . ' />'; // $font_color = '<input name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" class="of-color of-typography-color type="text" value="' . esc_attr( $typography_stored['color'] ) . '"' . $default_color .' />'; } // Allow modification/injection of typography fields $typography_fields = compact('font_face', 'font_style', 'font_size', 'font_color', 'font_subset'); // var_dump($typography_fields); $typography_fields = apply_filters('ske_typography_fields', $typography_fields, $typography_stored, $settk, $value); //var_dump($typography_fields); $field .= implode('', $typography_fields); $field .= $inp_after; break; // break; /* foreach ($args['options'] as $key => $option) { $selected = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-'. $option; $name = $option_name . '[' . $value['id'] . '][' . $option .']'; if ( isset($val) && is_array($val) ) { if( array_key_exists( $key, $val)) { if($val[$key]) { $selected = ' selected="selected" '; } } } $field .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $label ) . '</option>'; }*/ $field .= '</select>'; $field .= $inp_after; break; case 'editor': $field = $inp_before; $default_editor_settings = array('textarea_name' => $name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress,wplink')); $editor_settings = array(); if (isset($args['options'])) { $editor_settings = $args['options']; } $editor_settings = array_merge($default_editor_settings, $editor_settings); $field .= wp_editor($value, $key, $editor_settings); $field .= $inp_after; break; case 'password': $field = $inp_before; $field .= '<input type="password" class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($name) . '" id="' . esc_attr($key) . '" placeholder="' . esc_attr($args['placeholder']) . '" ' . $args['maxlength'] . ' value="' . esc_attr($value) . '" ' . implode(' ', $custom_attributes) . ' />'; $field .= $inp_after; break; /* // Image Selectors case "images": // $name = $option_name .'['. $value['id'] .']'; foreach ( $value['options'] as $key => $option ) { $selected = ''; if ( $val != '' && ($val == $key) ) { $selected = ' of-radio-img-selected'; } $output .= '<input type="radio" id="' . esc_attr( $value['id'] .'_'. $key) . '" class="of-radio-img-radio" value="' . esc_attr( $key ) . '" name="' . esc_attr( $name ) . '" '. checked( $val, $key, false ) .' />'; $output .= '<div class="of-radio-img-label">' . esc_html( $key ) . '</div>'; $output .= '<img src="' . esc_url( $option ) . '" alt="' . $option .'" class="of-radio-img-img' . $selected .'" onclick="document.getElementById(\''. esc_attr($value['id'] .'_'. $key) .'\').checked=true;" />'; } break;*/ /* // Image Selectors case "images": // $name = $option_name .'['. $value['id'] .']'; foreach ( $value['options'] as $key => $option ) { $selected = ''; if ( $val != '' && ($val == $key) ) { $selected = ' of-radio-img-selected'; } $output .= '<input type="radio" id="' . esc_attr( $value['id'] .'_'. $key) . '" class="of-radio-img-radio" value="' . esc_attr( $key ) . '" name="' . esc_attr( $name ) . '" '. checked( $val, $key, false ) .' />'; $output .= '<div class="of-radio-img-label">' . esc_html( $key ) . '</div>'; $output .= '<img src="' . esc_url( $option ) . '" alt="' . $option .'" class="of-radio-img-img' . $selected .'" onclick="document.getElementById(\''. esc_attr($value['id'] .'_'. $key) .'\').checked=true;" />'; } break;*/ case "gr_start": $field = $inp_before; $field .= wp_kses_post($args['after']); break; case "gr_end": $field = wp_kses_post($args['before']); $field = $inp_after; break; case "togglebox_start": $field = wp_kses_post($args['before']); if (!isset($key)) { $key = 'cbt_' . uniqid(); } $field .= '<input id="' . esc_attr($key) . '_cboxt" type="checkbox" '; if (!empty($value)) { $field .= 'checked="checked" '; } $field .= 'class="cbox_toggle_i" role="button"><label class="cbox_toggle ' . esc_attr(implode(' ', $args['label_cl'])) . '" for="' . esc_attr($key) . '_cboxt">'; if ($args['label']) { $field .= '<span class="label label-success cbt_s">+ Show {' . esc_attr($args['label']) . '}</span><span class="label label-default cbt_h">— Hide {' . esc_attr($args['label']) . '}</span>'; } else { $field .= '<span class="label label-info cbt_s">i</span><span class="label label-default cbt_h">i</span>'; } $field .= '</label>'; $field .= '<div class="cbt_cont togglebox">'; $field .= wp_kses_post($args['after']); break; case "togglebox_end": case "closediv": $field = wp_kses_post($args['before']); $field .= '</div>'; $field .= wp_kses_post($args['after']); break; case "hr": $field = wp_kses_post($args['before']); $field .= '<hr class="' . esc_attr(implode(' ', $args['class'])) . '" />'; $field .= wp_kses_post($args['after']); break; case "free_html": $field = $inp_before; $field .= $value; $field .= $inp_after; break; default: $field = apply_filters('skeleteon_form_field_' . $args['type'], '', $key, $args, $value); break; } // make sure we have unique ids just in case if ($r) { return $field; } else { echo $field; } }
public static function reset_metaboxes($page) { // TODO: look into possibility of resetting the if (!isset($_GET['ske_action']) || !isset($_GET['page'])) { return; } if (isset($_GET['ske_action']) && $_GET['ske_action'] != 'reset_mboxes') { return; } //meta-box-order_honey-thick_page_honey_thick_settings global $wpdb, $current_user; $cuid = $current_user->ID; /* $x = plugin_basename( __FILE__ ); list($prefx) = explode('/',$x); $cuid = $current_user->ID; $pageid = $prefx .'_page_' . $_GET['page']; // var_dump($prefx,$page,$cuid);*/ $query = $wpdb->prepare("\n\t\t\t\tDELETE\n\t\t\t\tFROM {$wpdb->usermeta}\n\t\t\t\tWHERE meta_key LIKE %s\n\t\t\t\tAND user_id = %d\n\t\t\t\t", 'meta-box-order_' . $page->id, $cuid); $run = $wpdb->query($query); if (!$run) { return false; } else { Skeleteon_Generic::add_trans_msg('mboxreset', '<i class="fa fa-check-square-o"></i> ' . __('Metaboxes reset', self::$vars['lang_slug']), 'success', array('ske_show_msg' => 'mboxreset')); $curruri = Skeleteon_Generic::curruri(); wp_redirect(add_query_arg('ske_show_msg', 'mboxreset', $curruri)); } }