コード例 #1
0
ファイル: shortcodes.php プロジェクト: aragonc/3clicks
 protected function capture_attribute(G1_Shortcode_Attribute $attribute)
 {
     $out = '';
     $name = $attribute->get_label();
     if (empty($name)) {
         $name = $attribute->get_id();
     }
     $out .= sprintf('<div class="g1-name">%s</div>', $name);
     $out .= '<div class="g1-description">';
     $hint = $attribute->get_hint();
     if (strlen($hint) > 0) {
         $out .= sprintf('<div class="g1-hint">%s</div>', $attribute->get_hint());
     }
     $help = $attribute->get_help();
     if (strlen($help) > 0) {
         $out .= sprintf('<div class="g1-help">%s</div>', $attribute->get_help());
     }
     if ($attribute->get_form_control() === 'Choice') {
         if ($attribute->get_id() === 'icon') {
             $out .= sprintf('<div class="g1-options-label">%s:</div>', __('Available Options', 'g1_theme'));
             $out .= sprintf('<div>All icons available on <a href="%s">Font Awesome</a> site</div>', 'http://fortawesome.github.io/Font-Awesome/icons/');
         } else {
             $choices = $attribute->get_attr_by_name('choices');
             if (!empty($choices)) {
                 $out .= sprintf('<div class="g1-options-label">%s:</div>', __('Available Options', 'g1_theme'));
                 $out .= '<ul class="g1-options">';
                 foreach ($choices as $key => $value) {
                     if (strtolower($key) !== strtolower($value)) {
                         $out .= sprintf('<li><span>%s</span> - %s</li>', $key, $value);
                     } else {
                         $out .= sprintf('<li><span>%s</span></li>', $key);
                     }
                 }
                 $out .= '</ul>';
             }
         }
     }
     $out .= '</div>';
     $out = sprintf('<li class="g1-sc-doc__attribute">%s</li>', $out);
     return $out;
 }
コード例 #2
0
ファイル: form-controls.php プロジェクト: aragonc/3clicks
 /**
  * @param G1_Shortcode_Attribute $attribute
  * @return G1_Form_Control
  */
 public static function create_form_control_from_attribute(G1_Shortcode_Attribute $attribute)
 {
     $attributeArgs = array('label' => $attribute->get_label(), 'name' => $attribute->get_id(), 'hint' => $attribute->get_hint(), 'help' => $attribute->get_help());
     switch ($attribute->get_form_control()) {
         case 'Choice':
             $attributeArgs['choices'] = $attribute->get_attr_by_name('choices');
             break;
         case 'Multichoice_Text':
             $attributeArgs['elements'] = $attribute->get_attr_by_name('elements');
             break;
     }
     $attributeArgs = apply_filters('g1_create_form_control_from_attribute', $attributeArgs);
     $control = self::create($attribute->get_id(), $attributeArgs, $attribute->get_form_control());
     $control->set_value($attribute->get_value());
     return $control;
 }