<?php

namespace W3TC;

if (!defined('W3TC')) {
    die;
}
?>
<tr>
    <th colspan="2">
        <?php 
$key = 'stats.enabled';
$c = Dispatcher::config();
$value = $c->get($key);
$label = Util_Ui::config_label($key);
$name = Util_Ui::config_key_to_http_name($key);
Util_Ui::checkbox($key, $name, $value, $c->is_sealed('common.'), $label);
?>
    </th>
</tr>
<?php 
Ejemplo n.º 2
0
 /**
  * Prints configuration item UI based on description
  *   key => configuration key
  *   label => configuration key's as its introduced to the user
  *   value => it's value
  *   disabled => if disabled
  *
  *   control => checkbox | radiogroup | selectbox | textbox
  *   checkbox_label => text shown after the textbox
  *   radiogroup_values => array of possible values for radiogroup
  *   selectbox_values => array of possible values for dropdown
  *   selectbox_optgroups =>
  *   textbox_size =>
  *
  *   description => description shown to the user below
  */
 public static function config_item($a)
 {
     $c = Dispatcher::config();
     if (!isset($a['value']) || is_null($a['value'])) {
         $a['value'] = $c->get($a['key']);
         if (is_array($a['value'])) {
             $a['value'] = implode('\\n', $a['value']);
         }
     }
     if (isset($a['disabled']) && !is_null($a['disabled'])) {
         $disabled = $a['disabled'];
     } else {
         $disabled = $c->is_sealed($a['key']);
     }
     if (empty($a['label'])) {
         $a['label'] = Util_Ui::config_label($a['key']);
     }
     $action_key = $a['key'];
     if (is_array($action_key)) {
         $action_key = 'extension.' . $action_key[0] . '.' . $action_key[1];
     }
     $a = apply_filters('w3tc_ui_config_item_' . $action_key, $a);
     // convert to table_tr data
     $table_tr = array('id' => Util_Ui::config_key_to_http_name($a['key']), 'label' => $a['label']);
     if (isset($a['style'])) {
         $table_tr['style'] = $a['style'];
     }
     if ($a['control'] == 'checkbox') {
         $table_tr['label_class'] = 'w3tc_config_checkbox';
         $table_tr['checkbox'] = array('name' => Util_Ui::config_key_to_http_name($a['key']), 'value' => $a['value'], 'disabled' => $disabled, 'label' => $a['checkbox_label']);
     } else {
         if ($a['control'] == 'radiogroup') {
             $table_tr['radiogroup'] = array('name' => Util_Ui::config_key_to_http_name($a['key']), 'value' => $a['value'], 'disabled' => $disabled, 'values' => $a['radiogroup_values']);
         } else {
             if ($a['control'] == 'selectbox') {
                 $table_tr['selectbox'] = array('name' => Util_Ui::config_key_to_http_name($a['key']), 'value' => $a['value'], 'disabled' => $disabled, 'values' => $a['selectbox_values'], 'optgroups' => isset($a['selectbox_optgroups']) ? $a['selectbox_optgroups'] : null);
             } else {
                 if ($a['control'] == 'textbox') {
                     $table_tr['textbox'] = array('name' => Util_Ui::config_key_to_http_name($a['key']), 'value' => $a['value'], 'disabled' => $disabled, 'size' => isset($a['textbox_size']) ? $a['textbox_size'] : null);
                 } else {
                     if ($a['control'] == 'textarea') {
                         $table_tr['textarea'] = array('name' => Util_Ui::config_key_to_http_name($a['key']), 'value' => $a['value'], 'disabled' => $disabled);
                     }
                 }
             }
         }
     }
     if (isset($a['description'])) {
         $table_tr['description'] = $a['description'];
     }
     Util_Ui::table_tr($table_tr);
 }