如何在此处使用此代码创建a:2:{i:57;s:8:"situação";i:61;s:8:"condição";}
?
当我携带并且我将该类别放在帖子中时,他带有组和属性。 他是一个基于类别,属性和组的利润和损失的电子表格。 目标并创建一个“短代码”,以便在搜索表单中加载,其中表单创建一个新帖子并使用值发送到数据库,以便这个模式!
//make text input field
记住生成此代码的是escolhidoa选项
<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>
以下完整代码:
DateFormat serverFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
try {
Date timestamp = serverFormatter.parse("2017-05-06T20:50:59.000Z");
SimpleDateFormat localFormat = new SimpleDateFormat("h:mm a");
localFormat.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
print (localFormat.format(timestamp));
} catch (ParseException e) {
e.printStackTrace();
}
注意:谷歌翻译
谢谢你
答案 0 :(得分:0)
您最好参考官方documentation
创建一个短代码:
// [bartag foo="foo-value"]
function bartag_func( $atts ) {
$a = shortcode_atts( array(
'foo' => 'something',
'bar' => 'something else',
), $atts );
return "foo = {$a['foo']}";
}
add_shortcode( 'bartag', 'bartag_func' );
&#13;