Пример #1
0
 function wallow_get_opt($opt)
 {
     global $wallow_opt;
     if (isset($wallow_opt[$opt])) {
         return apply_filters('wallow_option_' . $opt, $wallow_opt[$opt], $opt);
     }
     $defopt = wallow_get_coa($opt);
     if (!$defopt) {
         return null;
     }
     if ($defopt['req'] == '' || wallow_get_opt($defopt['req'])) {
         return $defopt['default'];
     } else {
         return null;
     }
 }
Пример #2
0
 function wallow_print_the_option($key, $is_top = true)
 {
     $val = wallow_get_coa($key);
     $type = $val['type'];
     $output = '';
     switch ($type) {
         case "chk":
             if ($is_top) {
                 $output .= '<span class="column-nam">' . $val['description'] . '</span>';
                 $output .= ' <input name="wallow_options[' . $key . ']" value="1" type="checkbox" class="ww_opt_p_checkbox" ' . checked(1, wallow_get_opt($key), false) . ' />';
                 if ($val['req'] != '') {
                     $req = wallow_get_coa($val['req']);
                     $output .= '<div class="column-req"><u>' . __('requires', 'wallow') . ': ' . $req['description'] . '</u></div>';
                 }
                 $output .= '<div class="column-des">' . $val['info'] . '</div>';
             } else {
                 $output .= '<input name="wallow_options[' . $key . ']" value="1" type="checkbox" class="ww_opt_p_checkbox" ' . checked(1, wallow_get_opt($key), false) . ' />';
                 $output .= ' <span class="wlw-sub-opt-nam">' . $val['description'] . '</span>';
                 if ($val['info'] != '') {
                     $output .= ' - <span class="wlw-sub-opt-des">' . $val['info'] . '</span>';
                 }
             }
             break;
         case "txt":
         case "int":
         case "url":
             if ($is_top) {
                 $output .= '<span class="column-nam">' . $val['description'] . '</span>';
                 $output .= ' <input name="wallow_options[' . $key . ']" value="' . esc_attr(wallow_get_opt($key)) . '" type="text" />';
                 if ($val['req'] != '') {
                     $req = wallow_get_coa($val['req']);
                     $output .= '<div class="column-req"><u>' . __('requires', 'wallow') . ': ' . $req['description'] . '</u></div>';
                 }
                 $output .= '<div class="column-des">' . $val['info'] . '</div>';
             } else {
                 $output .= '<span class="wlw-sub-opt-nam">' . $val['description'] . '</span> :';
                 $output .= ' <input name="wallow_options[' . $key . ']" value="' . esc_attr(wallow_get_opt($key)) . '" type="text" />';
                 if ($val['info'] != '') {
                     $output .= ' - <span class="wlw-sub-opt-des">' . $val['info'] . '</span>';
                 }
             }
             break;
         case "txtarea":
             if ($is_top) {
                 $output .= '<span class="column-nam">' . $val['description'] . '</span>';
                 $output .= ' <textarea name="wallow_options[' . $key . ']">' . esc_textarea(wallow_get_opt($key)) . '</textarea>';
                 if ($val['req'] != '') {
                     $req = wallow_get_coa($val['req']);
                     $output .= '<div class="column-req"><u>' . __('requires', 'wallow') . ': ' . $req['description'] . '</u></div>';
                 }
                 $output .= '<div class="column-des">' . $val['info'] . '</div>';
             } else {
                 $output .= '<!-- txtarea suboption not implemented -->';
             }
             break;
         case "sel":
             if ($is_top) {
                 $output .= '<span class="column-nam">' . $val['description'] . '</span>';
                 $output .= ' <select name="wallow_options[' . $key . ']">';
                 foreach ($val['options'] as $optionkey => $option) {
                     $output .= '<option value="' . $option . '" ' . selected(wallow_get_opt($key), $option, false) . '>' . $val['options_readable'][$optionkey] . '</option>';
                 }
                 $output .= '</select>';
                 if ($val['req'] != '') {
                     $req = wallow_get_coa($val['req']);
                     $output .= '<div class="column-req"><u>' . __('requires', 'wallow') . ': ' . $req['description'] . '</u></div>';
                 }
                 $output .= '<div class="column-des">' . $val['info'] . '</div>';
             } else {
                 $output .= '<span class="wlw-sub-opt-nam">' . $val['description'] . '</span> :';
                 $output .= ' <select name="wallow_options[' . $key . ']">';
                 foreach ($val['options'] as $optionkey => $option) {
                     $output .= '<option value="' . $option . '" ' . selected(wallow_get_opt($key), $option, false) . '>' . $val['options_readable'][$optionkey] . '</option>';
                 }
                 $output .= '</select>';
                 if ($val['info'] != '') {
                     $output .= ' - <span class="wlw-sub-opt-des">' . $val['info'] . '</span>';
                 }
             }
             break;
         case "opt":
             if ($is_top) {
                 $output .= '<span class="column-nam">' . $val['description'] . '</span>';
                 foreach ($val['options'] as $optionkey => $option) {
                     $output .= ' <label title="' . esc_attr($option) . '"><input type="radio" ' . checked(wallow_get_opt($key), $option, false) . ' value="' . $option . '" name="wallow_options[' . $key . ']"> <span>' . $val['options_readable'][$optionkey] . '</span></label>';
                 }
                 if ($val['req'] != '') {
                     $req = wallow_get_coa($val['req']);
                     $output .= '<div class="column-req"><u>' . __('requires', 'wallow') . ': ' . $req['description'] . '</u></div>';
                 }
                 $output .= '<div class="column-des">' . $val['info'] . '</div>';
             } else {
                 $output .= '<span class="wlw-sub-opt-nam">' . $val['description'] . '</span> :';
                 foreach ($val['options'] as $optionkey => $option) {
                     $output .= ' <label title="' . esc_attr($option) . '"><input type="radio" ' . checked(wallow_get_opt($key), $option, false) . ' value="' . $option . '" name="wallow_options[' . $key . ']"> <span>' . $val['options_readable'][$optionkey] . '</span></label>';
                 }
                 if ($val['info'] != '') {
                     $output .= ' - <span class="wlw-sub-opt-des">' . $val['info'] . '</span>';
                 }
             }
             break;
         case "col":
             if ($is_top) {
                 $output .= '<span class="column-nam">' . $val['description'] . '</span>';
                 $output .= ' <input class="wlw-color" id="wlw-color-' . $key . '" type="text" name="wallow_options[' . $key . ']" value="' . esc_attr(wallow_get_opt($key)) . '" data-default-color="' . $val['default'] . '" />';
                 $output .= '<span class="description hide-if-js">' . __('Default', 'wallow') . ': ' . $val['default'] . '</span>';
                 if ($val['req'] != '') {
                     $req = wallow_get_coa($val['req']);
                     $output .= '<div class="column-req"><u>' . __('requires', 'wallow') . ': ' . $req['description'] . '</u></div>';
                 }
                 $output .= '<div class="column-des">' . $val['info'] . '</div>';
             } else {
                 $output .= '<span class="wlw-sub-opt-nam">' . $val['description'] . '</span> :';
                 $output .= ' <input class="wlw-color" id="wlw-color-' . $key . '" type="text" name="wallow_options[' . $key . ']" value="' . esc_attr(wallow_get_opt($key)) . '" data-default-color="' . $val['default'] . '" />';
                 $output .= ' <span class="description hide-if-js">' . __('Default', 'wallow') . ': ' . $val['default'] . '</span>';
                 if ($val['info'] != '') {
                     $output .= ' - <span class="wlw-sub-opt-des">' . $val['info'] . '</span>';
                 }
             }
             break;
         default:
             $output .= '<!-- no default output -->';
     }
     $output = apply_filters('wallow_filter_print_the_option', $output, $key, $type, $is_top);
     echo $output;
 }