コード例 #1
0
 function __construct($field = array(), $value = '', $parent)
 {
     if (!isset($field['options'])) {
         $field['options'] = array(1 => __("Show", 'ct_theme'), 0 => __("Hide", 'ct_theme'));
     }
     //no way - default values on plugin init do not allow this
     /*if(!isset($field['std'])){
     			$field['std'] = 1;
     		}*/
     parent::__construct($field, $value, $parent);
 }
コード例 #2
0
ファイル: field_background.php プロジェクト: jenng/nicucare
 function render()
 {
     $class = isset($this->field['class']) ? $this->field['class'] : '';
     $values = $this->background_values('value');
     $bgoptions = $this->background_values('bgoptions');
     $this->field['options']['recur'] = $values['recur'];
     // Assign Select box values
     $this->field['options']['attach'] = $values['attach'];
     $this->field['options']['position'] = $values['position'];
     $chkbox_array = array('none', 'scale', 'custom');
     // Checkboxes array
     echo '<div class="background">';
     // Set Initial value
     if (empty($this->value)) {
         $this->value = array();
         $this->value['background'] = Null;
         $this->value['patterncolor'] = Null;
         $this->value['patternrecur'] = Null;
         $this->value['patternattach'] = Null;
         $this->value['patternposition'] = Null;
         $this->value['bgdefault'] = Null;
         $this->value['color'] = Null;
     }
     $hidden_array1 = array('class' => "bgdefault", 'id' => $this->field['id'] . '][background');
     // Standard BG Value
     $hidden_field1 = new NHP_Options_hidden($hidden_array1, $this->value['bgdefault'], $this->parent);
     $hidden_field1->render();
     $hidden_array2 = array('class' => "field-id", 'id' => "field-id");
     $hidden_field2 = new NHP_Options_hidden($hidden_array2, $this->field['id'], $this->parent);
     // Field Id
     $hidden_field2->render();
     foreach ($chkbox_array as $chkbox) {
         if (!isset($this->value[$chkbox])) {
             $this->value[$chkbox] = 0;
         }
         if ($chkbox == 'custom') {
             $label = 'Custom Background';
             $class = 'bg-hide-below';
         } else {
             $label = 'Background ' . ucfirst($chkbox);
         }
         $chkbox_array = array('id' => $this->field['id'] . '][' . $chkbox, 'desc' => $label, 'class' => $class);
         $chkbox_field = new NHP_Options_checkbox($chkbox_array, $this->value[$chkbox], $this->parent);
         // Call Chk Box
         $chkbox_field->render();
     }
     echo '<br/>';
     echo '<div class="basic-option">';
     foreach ($this->field['defaults'] as $k => $v) {
         $hidden_pattern_values = '<input type="hidden" id="' . $this->field['id'] . '-defaults-' . $k . '" value="';
         if (isset($v['color'])) {
             $temp = $v['color'] . '/';
         } else {
             $temp = '' . '/';
         }
         if (isset($v['recur'])) {
             $temp .= $v['recur'] . '/';
         } else {
             $temp .= '' . '/';
         }
         if (isset($v['attach'])) {
             $temp .= $v['attach'] . '/';
         } else {
             $temp .= '' . '/';
         }
         if (isset($v['position'])) {
             $temp .= $v['position'] . '/';
         } else {
             $temp .= '' . '/';
         }
         if (isset($v['opacity'])) {
             $temp .= $v['opacity'] . '/';
         } else {
             $temp .= '' . '/';
         }
         if (isset($v['scheme'])) {
             $temp .= $v['scheme'];
         } else {
             $temp .= '';
         }
         $hidden_pattern_values .= $temp;
         $hidden_pattern_values .= '">';
         echo $hidden_pattern_values;
     }
     $img_select_array = array('id' => $this->field['id'] . '][bgdefault', 'options' => $this->field['defaults'], 'label' => 'Pattern');
     $img_select_field = new NHP_Options_img_select($img_select_array, $this->value['bgdefault'], $this->parent);
     // Call image select box
     $img_select_field->enqueue();
     $img_select_field->render();
     echo '</div>';
     // "Basic options"
     echo '<div class="advance-option">';
     $select_array = array('id' => $this->field['id'] . '][bgpattern', 'label' => 'Custom Pattern');
     $upload_field = new NHP_Options_upload($select_array, $this->value['bgpattern'], $this->parent);
     // Call Chk Box
     $upload_field->render();
     echo '</div>';
     // Advance Option
     $color_picker = new NHP_Options_color(array('id' => $this->field['id'] . '][color', 'label' => 'Background Color'), $this->value['color'], $this->parent);
     // Call Color Box
     $color_picker->enqueue();
     $color_picker->render();
     echo '<div id="' . $this->field['id'] . 'bgoptions" class="bgoptions-wrapper">';
     $i = 0;
     foreach ($this->field['options'] as $key => $option) {
         // if(!isset($this->value['pattern'.$key])){ $this->value['pattern'.$key] = null; }
         if (!isset($this->value['pattern' . $key])) {
             $this->value['pattern' . $key] = null;
         }
         $select_array = array('options' => $this->field['options'][$key], 'id' => $this->field['id'] . '][' . $key, 'label' => $bgoptions[$i]);
         if (!isset($this->value[$key])) {
             $this->value[$key] = null;
         }
         $select_field = new NHP_Options_select($select_array, $this->value[$key], $this->parent);
         // Call Chk Box
         $select_field->render();
         $i++;
     }
     echo '</div>';
     // bg options
     if (!isset($this->value['opacity'])) {
         $this->value['opacity'] = -1;
     }
     $slider_array = array('id' => $this->field['id']);
     $slider_field = new NHP_Options_slider($slider_array, $this->value['opacity'], $this->parent);
     // Call Chk Box
     $slider_field->enqueue();
     $slider_field->render();
     echo isset($this->field['desc']) && !empty($this->field['desc']) ? ' <p class="description">' . $this->field['desc'] . '</p>' : '';
     echo '</div>';
     // Advance Options
 }
コード例 #3
0
ファイル: field_typo.php プロジェクト: jenng/nicucare
 function render()
 {
     $values = $this->typo_values('value');
     //Get The Value of Element's Value from function typo_values
     $label = $this->typo_values('fontoptions');
     //Get The Value of Element's Value from function typo_values
     $class = isset($this->field['class']) ? $this->field['class'] : 'regular-text';
     echo '<div class="typo" >';
     $hidden_array = array('class' => "hidden-id", 'id' => 'hidden-id');
     $hidden_field1 = new NHP_Options_hidden($hidden_array, $this->field['id'], $this->parent);
     // Field ID
     $hidden_field1->render();
     $hidden_array1 = array('class' => "hidden-url", 'id' => 'hidden-url');
     $hidden_field2 = new NHP_Options_hidden($hidden_array1, NHP_OPTIONS_URL . 'fields/typo/preview.php', $this->parent);
     // Url
     $hidden_field2->render();
     if (isset($this->field['group'])) {
         $hidden_array2 = array('class' => "heading-group", 'id' => 'heading-group');
         $hidden_field3 = new NHP_Options_hidden($hidden_array2, $this->field['group'], $this->parent);
         // Show Apply All Heading Button
         $hidden_field3->render();
     }
     // Set Initial values
     if (!isset($this->value['color'])) {
         $this->value['color'] = '#000000';
     }
     if (!empty($this->value['family'])) {
         // Update the options the font family of typography
         $fonts = get_option('be_themes_selected_fonts');
         if (empty($fonts)) {
             $fonts[0] = $this->value['family'];
         } elseif (!in_array($this->value['family'], $fonts)) {
             array_push($fonts, $this->value['family']);
         }
         update_option('be_themes_selected_fonts', $fonts);
     }
     //Show Font Family
     $select_array = array('options' => $this->google_fonts, 'id' => $this->field['id'] . '][family', 'label' => 'Font Family');
     $select_field = new NHP_Options_select($select_array, $this->value['family'], $this->parent);
     // Call Chk Box
     $select_field->render();
     $keys = array_slice(array_keys($values), 1, 7);
     // Show Select boxes
     $i = 0;
     foreach ($keys as $key) {
         $this->field['options'][$key] = $values[$key];
         $select_array = array('options' => $this->field['options'][$key], 'id' => $this->field['id'] . '][' . $key, 'label' => $label[$i]);
         $select_field = new NHP_Options_select($select_array, $this->value[$key], $this->parent);
         // Call Chk Box
         $select_field->render();
         $i++;
     }
     // Show Color Picker
     $color_picker = new NHP_Options_color(array('id' => $this->field['id'] . '][color', 'label' => 'Font Color'), $this->value['color'], $this->parent);
     // Call Color Box
     $color_picker->enqueue();
     $color_picker->render();
     // Show Group apply button if required
     if (isset($this->field['group_head']) && $this->field['group_head'] == $this->field['group']) {
         echo '<input type="button" name="" class="preset-heading button-primary" value="Apply to all Headings" id="' . $this->field['group'] . '" />';
     }
     echo isset($this->field['desc']) && !empty($this->field['desc']) ? ' <span class="description">' . $this->field['desc'] . '</span>' : '';
     echo '</div>';
     // Field Type Wrapper
 }