Wie erstelle ich hier einen shortcode
mit diesem Code?Wie erstelle ich einen Shortcode mit diesem Code?
Wenn ich trage und ich die Kategorie in die Post stelle, trägt er die Gruppen und Attribute. Er ist eine Tabelle mit Gewinnen und Verlusten basierend auf Kategorie, Attributen und Gruppen. Das Ziel und erstellen Sie einen 'shortcode' in einem Suchformular geladen werden, wo das Formular erstellt einen neuen Beitrag und senden an die Datenbank mit einem Wert, so dass dieses Muster!
a:2:{i:57;s:8:"situação";i:61;s:8:"condição";}
diesen Code zu generieren Erinnerung war escolhidoa Option
//make text input field
Dieser vollständige Code unten:
<div id="real-tb-attributes" class="real-tab-content">
<?php $cats = get_product_cats($post->ID);
if ($cats) {
$cat = $cats[62];
$cat_id = $cat->term_id;
} ?>
<?php if ($cat) {
// get cat groups
$groups = get_real_cat_groups($cat_id);
$groups_data = get_real_groups_data();
$attrs_data = get_real_attributes_data();
if (real_is_array($groups)) {
$count = 0; ?>
<ul class="real-data-pils">
<?php foreach ($groups as $group) { ?>
<li data-pil="#real-pil-<?php echo $group; ?>"<?php if ($count == 0) echo ' class="active"'; ?>><?php echo $groups_data[$group]['name']; ?></li>
<?php $count++;
} ?>
</ul>
<div class="real-pil-container">
<?php $count = 0;
foreach ($groups as $group) {
$group_data = $groups_data[$group];
$group_values = get_real_product_attributes($post->ID, $group); ?>
<div id="real-pil-<?php echo $group; ?>" class="real-pil-content<?php if ($count == 0) echo ' active'; ?>">
<?php if ($group_data['attrs']) { ?>
<div class="real-group-inputs">
<ul class="real-input-filelds">
<?php if (real_is_array($group_data['attrs'])) {
foreach ($group_data['attrs'] as $attr_id) {
$attr = $attrs_data[$attr_id];
$attr_val = (isset($group_values[$attr_id])) ? $group_values[$attr_id] : ''; ?>
<li>
<div class="real-col-1">
<label for="attr-input-<?php echo $attr_id; ?>"><?php echo $attr['name']; ?></label>
</div>
<div class="real-col-5">
<?php // switch the input types
switch ($attr['meta']['type']) {
case 'text' :
// make text input field
echo '<input type="text" id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-text-input" value="' .$attr_val .'" />';
break;
case 'check' :
// make checkbox input field
echo '<input type="hidden" name="real-attr[' .$group .'][' .$attr_id .']" value="No" />';
echo '<input type="checkbox" id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-checkbox" value="Yes"' .(($attr_val == 'Yes') ? ' checked="checked"' : '') .' />';
break;
case 'date' :
// make date input field
echo '<input type="text" id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-date-input real-text-input" value="' .$attr_val .'" />';
break;
case 'textarea' :
// make textarea input field
echo '<textarea id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-textarea" rows="4">' .$attr_val .'</textarea>';
break;
case 'select' :
// make select box
echo '<div class="real-select-label"><select id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-select-box">';
foreach ($attr['meta']['options'] as $option) {
echo '<option value="' .$option .'"' .(($option == $attr_val) ? ' selected="selected"' : '') .'>' .$option .'</option>';
}
echo '</select></div>';
break;
case 'mselect' :
// make multi select box
$attr_val = (array) $attr_val;
echo '<select id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" size="' .count($attr['meta']['options']) .'" class="real-select-box" multiple>';
foreach ($attr['meta']['options'] as $option) {
echo '<option value="' .$option .'"' .((in_array($option, $attr_val)) ? ' selected="selected"' : '') .'>' .$option .'</option>';
}
echo '</select>';
break;
} ?>
</div>
</li>
<?php }
} ?>
</ul>
</div>
<?php } ?>
</div>
<?php $count++;
} ?>
</div>
<?php } else { ?>
<p><?php _e('No Groups found for this category, you may add groups by editing category.', 'real-text'); ?></p>
<?php }
} else { ?>
<p><?php _e('Please select a Category to continue.', 'real-text'); ?></p>
<?php } ?>
</div>
Hinweis: Google Übersetzer
Ich danke
Hallo, könnten Sie bitte erklären, was Sie tun wollen und was falsch ist? Beispiele sind auch willkommen – Chris
bearbeitet besser sehen, ob Sie mir jetzt helfen können –
Das ist eine unlesbare Wand des Codes. Maschinelle Übersetzung macht die Sache nur noch schlimmer ... Weißt du, wie man eine Shortcode macht? Tipp: Shortcodes "echo" nichts, Sie müssen eine HTML-Zeichenfolge zurückgeben. – brasofilo