本文整理汇总了PHP中PodsForm::dependencies方法的典型用法代码示例。如果您正苦于以下问题:PHP PodsForm::dependencies方法的具体用法?PHP PodsForm::dependencies怎么用?PHP PodsForm::dependencies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PodsForm
的用法示例。
在下文中一共展示了PodsForm::dependencies方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: meta_post
/**
* @param $post
* @param $metabox
*/
public function meta_post($post, $metabox)
{
wp_enqueue_style('pods-form');
wp_enqueue_script('pods');
$hidden_fields = array();
?>
<table class="form-table pods-metabox pods-admin pods-dependency">
<?php
$id = null;
if (is_object($post) && false === strpos($_SERVER['REQUEST_URI'], '/post-new.php?')) {
$id = $post->ID;
}
$pod = pods($metabox['args']['group']['pod']['name'], $id, true);
foreach ($metabox['args']['group']['fields'] as $field) {
if (false === PodsForm::permission($field['type'], $field['name'], $field['options'], $metabox['args']['group']['fields'], $pod, $id)) {
if (pods_var('hidden', $field['options'], false, null, true)) {
$field['type'] = 'hidden';
} else {
continue;
}
} elseif (!pods_has_permissions($field['options']) && pods_var('hidden', $field['options'], false, null, true)) {
$field['type'] = 'hidden';
}
$value = '';
if (!empty($pod)) {
pods_no_conflict_on('post');
$value = $pod->field(array('name' => $field['name'], 'in_form' => true));
pods_no_conflict_off('post');
} elseif (!empty($id)) {
$value = get_post_meta($id, $field['name'], true);
}
if ('hidden' == $field['type']) {
$hidden_fields[] = array('field' => $field, 'value' => $value);
} else {
$depends = PodsForm::dependencies($field, 'pods-meta-');
?>
<tr class="form-field pods-field <?php
echo 'pods-form-ui-row-type-' . $field['type'] . ' pods-form-ui-row-name-' . Podsform::clean($field['name'], true);
?>
<?php
echo $depends;
?>
">
<th scope="row" valign="top"><?php
echo PodsForm::label('pods_meta_' . $field['name'], $field['label'], $field['help'], $field);
?>
</th>
<td>
<?php
// Remove any extra ? help icons
if (isset($field['help'])) {
unset($field['help']);
}
?>
<?php
echo PodsForm::field('pods_meta_' . $field['name'], $value, $field['type'], $field, $pod, $id);
?>
<?php
echo PodsForm::comment('pods_meta_' . $field['name'], $field['description'], $field);
?>
</td>
</tr>
<?php
}
}
?>
</table>
<?php
foreach ($hidden_fields as $hidden_field) {
$field = $hidden_field['field'];
echo PodsForm::field('pods_meta_' . $field['name'], $hidden_field['value'], 'hidden');
}
?>
<input type="hidden" name="pods_metasave" value="1" />
<script type="text/javascript">
jQuery( function ( $ ) {
$( document ).Pods( 'dependency', true );
} );
</script>
<?php
}
示例2: meta_post
/**
* @param $post
* @param $metabox
*/
public function meta_post($post, $metabox)
{
wp_enqueue_style('pods-form');
wp_enqueue_script('pods');
$pod_type = 'post';
if ('attachment' == $post->post_type) {
$pod_type = 'media';
}
do_action('pods_meta_' . __FUNCTION__, $post);
$hidden_fields = array();
?>
<table class="form-table pods-metabox pods-admin pods-dependency">
<?php
echo PodsForm::field('pods_meta', wp_create_nonce('pods_meta_' . $pod_type), 'hidden');
?>
<?php
$id = null;
if (is_object($post) && false === strpos($_SERVER['REQUEST_URI'], '/post-new.php')) {
$id = $post->ID;
}
if (empty(self::$current_pod_data) || !is_object(self::$current_pod) || self::$current_pod->pod != $metabox['args']['group']['pod']['name']) {
self::$current_pod = pods($metabox['args']['group']['pod']['name'], $id, true);
} elseif (self::$current_pod->id() != $id) {
self::$current_pod->fetch($id);
}
$pod = self::$current_pod;
foreach ($metabox['args']['group']['fields'] as $field) {
if (false === PodsForm::permission($field['type'], $field['name'], $field['options'], $metabox['args']['group']['fields'], $pod, $id)) {
if (pods_var('hidden', $field['options'], false)) {
$field['type'] = 'hidden';
} else {
continue;
}
} elseif (!pods_has_permissions($field['options']) && pods_var('hidden', $field['options'], false)) {
$field['type'] = 'hidden';
}
$value = '';
if (!empty($pod)) {
pods_no_conflict_on('post');
$value = $pod->field(array('name' => $field['name'], 'in_form' => true));
pods_no_conflict_off('post');
} elseif (!empty($id)) {
$value = get_post_meta($id, $field['name'], true);
}
if ('hidden' == $field['type']) {
$hidden_fields[] = array('field' => $field, 'value' => $value);
} else {
$depends = PodsForm::dependencies($field, 'pods-meta-');
do_action('pods_meta_' . __FUNCTION__ . '_' . $field['name'], $post, $field, $pod);
?>
<tr class="form-field pods-field pods-field-input <?php
echo esc_attr('pods-form-ui-row-type-' . $field['type'] . ' pods-form-ui-row-name-' . PodsForm::clean($field['name'], true));
?>
<?php
echo esc_attr($depends);
?>
">
<th scope="row" valign="top"><?php
echo PodsForm::label('pods_meta_' . $field['name'], $field['label'], $field['help'], $field);
?>
</th>
<td>
<?php
// Remove any extra ? help icons
if (isset($field['help'])) {
unset($field['help']);
}
?>
<div class="pods-submittable-fields">
<?php
echo PodsForm::field('pods_meta_' . $field['name'], $value, $field['type'], $field, $pod, $id);
?>
<?php
echo PodsForm::comment('pods_meta_' . $field['name'], $field['description'], $field);
?>
</div>
</td>
</tr>
<?php
do_action('pods_meta_' . __FUNCTION__ . '_' . $field['name'] . '_post', $post, $field, $pod);
}
}
?>
</table>
<?php
do_action('pods_meta_' . __FUNCTION__ . '_post', $post);
foreach ($hidden_fields as $hidden_field) {
$field = $hidden_field['field'];
echo PodsForm::field('pods_meta_' . $field['name'], $hidden_field['value'], 'hidden');
}
?>
<script type="text/javascript">
jQuery( function ( $ ) {
//.........这里部分代码省略.........
示例3: foreach
">
<th class="pods-field-option-group-label">
<?php
echo $field_option['label'];
?>
</th>
<td class="pods-pick-values pods-pick-checkbox">
<ul>
<?php
foreach ($field_option['group'] as $field_group_name => $field_group_option) {
$field_group_option = PodsForm::field_setup($field_group_option, null, $field_group_option['type']);
if ('boolean' != $field_group_option['type']) {
continue;
}
$field_group_option['boolean_yes_label'] = $field_group_option['label'];
$depends_option = PodsForm::dependencies($field_group_option);
$value = pods_var_raw($field_group_name, $settings, $field_group_option['default']);
?>
<li class="<?php
echo $depends_option;
?>
">
<?php
echo PodsForm::field('pods_setting_' . $field_group_name, $value, $field_group_option['type'], $field_group_option);
?>
</li>
<?php
}
?>
</ul>
</td>
示例4: foreach
<p class="pods-field-option-group-label">
<?php
echo $field_option['label'];
?>
</p>
<div class="pods-pick-values pods-pick-checkbox">
<ul>
<?php
foreach ($field_option['group'] as $field_group_name => $field_group_option) {
$field_group_option = (array) $field_group_option;
if ('boolean' != $field_group_option['type']) {
continue;
}
$field_group_option['boolean_yes_label'] = $field_group_option['label'];
$depends_option = PodsForm::dependencies($field_group_option, !isset($pods_tab_form) ? 'field-data-' : '');
$row_name = $field_group_name;
if (!isset($pods_tab_form)) {
$row_name = 'field_data[' . $pods_i . '][' . $field_group_name . ']';
}
$value = $field_group_option['default'];
if (isset($field_group_option['value']) && 0 < strlen($field_group_option['value'])) {
$value = $field_group_option['value'];
} else {
$value = pods_var_raw($field_group_name, $field, $value);
}
?>
<li class="<?php
echo esc_attr($depends_option);
?>
">
示例5: foreach
<?php
foreach ($fields as $field) {
if ('hidden' != $field['type']) {
continue;
}
echo PodsForm::field('pods_field_' . $field['name'], $pod->field(array('name' => $field['name'], 'in_form' => true)), 'hidden');
}
?>
<table class="form-table pods-manage-field">
<?php
$depends_on = false;
foreach ($fields as $field) {
if ('hidden' == $field['type']) {
continue;
}
$depends = PodsForm::dependencies($field);
if ((!empty($depends_on) || !empty($depends)) && $depends_on != $depends) {
if (!empty($depends_on)) {
?>
</tbody>
<?php
}
if (!empty($depends)) {
?>
<tbody class="pods-field-option-container <?php
echo $depends;
?>
">
<?php
}
}