本文整理汇总了PHP中Record::get_meta方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::get_meta方法的具体用法?PHP Record::get_meta怎么用?PHP Record::get_meta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::get_meta方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_links
/**
* Add action links to Stream drop row in admin list screen
*
* @filter wp_stream_action_links_{connector}
*
* @param array $links Previous links registered
* @param Record $record Stream record
*
* @return array Action links
*/
public function action_links($links, $record)
{
// Options
if ($option = $record->get_meta('option', true)) {
$key = $record->get_meta('option_key', true);
$links[esc_html__('Edit', 'stream')] = add_query_arg(array('page' => $record->context), admin_url('admin.php')) . '#stream-highlight-' . esc_attr($key);
} elseif ('wpseo_files' === $record->context) {
$links[esc_html__('Edit', 'stream')] = add_query_arg(array('page' => $record->context), admin_url('admin.php'));
} elseif ('wpseo_meta' === $record->context) {
$post = get_post($record->object_id);
if ($post) {
$posts_connector = new Connector_Posts();
$post_type_name = $posts_connector->get_post_type_name(get_post_type($post->ID));
if ('trash' === $post->post_status) {
$untrash = wp_nonce_url(add_query_arg(array('action' => 'untrash', 'post' => $post->ID), admin_url('post.php')), sprintf('untrash-post_%d', $post->ID));
$delete = wp_nonce_url(add_query_arg(array('action' => 'delete', 'post' => $post->ID), admin_url('post.php')), sprintf('delete-post_%d', $post->ID));
$links[sprintf(esc_html_x('Restore %s', 'Post type singular name', 'stream'), $post_type_name)] = $untrash;
$links[sprintf(esc_html_x('Delete %s Permenantly', 'Post type singular name', 'stream'), $post_type_name)] = $delete;
} else {
$links[sprintf(esc_html_x('Edit %s', 'Post type singular name', 'stream'), $post_type_name)] = get_edit_post_link($post->ID);
if ($view_link = get_permalink($post->ID)) {
$links[esc_html__('View', 'stream')] = $view_link;
}
if ($revision_id = $record->get_meta('revision_id', true)) {
$links[esc_html__('Revision', 'stream')] = get_edit_post_link($revision_id);
}
}
}
}
return $links;
}
示例2: action_links
/**
* Add action links to Stream drop row in admin list screen
*
* @filter wp_stream_action_links_{connector}
*
* @param array $links Previous links registered
* @param Record $record Stream record
*
* @return array Action links
*/
public function action_links($links, $record)
{
if ($sidebar = $record->get_meta('sidebar_id', true)) {
global $wp_registered_sidebars;
if (array_key_exists($sidebar, $wp_registered_sidebars)) {
$links[esc_html__('Edit Widget Area', 'stream')] = admin_url('widgets.php#' . $sidebar);
// xss ok (@todo fix WPCS rule)
}
// @todo Also old_sidebar_id and new_sidebar_id
// @todo Add Edit Widget link
}
return $links;
}
示例3: action_links
/**
* Add action links to Stream drop row in admin list screen
*
* @filter wp_stream_action_links_{connector}
*
* @param array $links Previous links registered
* @param Record $record Stream record
*
* @return array Action links
*/
public function action_links($links, $record)
{
$post = get_post($record->object_id);
if ($post && $post->post_status === $record->get_meta('new_status', true)) {
$post_type_name = $this->get_post_type_name(get_post_type($post->ID));
if ('trash' === $post->post_status) {
$untrash = wp_nonce_url(add_query_arg(array('action' => 'untrash', 'post' => $post->ID), admin_url('post.php')), sprintf('untrash-post_%d', $post->ID));
$delete = wp_nonce_url(add_query_arg(array('action' => 'delete', 'post' => $post->ID), admin_url('post.php')), sprintf('delete-post_%d', $post->ID));
$links[sprintf(esc_html_x('Restore %s', 'Post type singular name', 'stream'), $post_type_name)] = $untrash;
$links[sprintf(esc_html_x('Delete %s Permenantly', 'Post type singular name', 'stream'), $post_type_name)] = $delete;
} else {
$links[sprintf(esc_html_x('Edit %s', 'Post type singular name', 'stream'), $post_type_name)] = get_edit_post_link($post->ID);
if ($view_link = get_permalink($post->ID)) {
$links[esc_html__('View', 'stream')] = $view_link;
}
$revision_id = absint($record->get_meta('revision_id', true));
$revision_id = $this->get_adjacent_post_revision($revision_id, false);
if ($revision_id) {
$links[esc_html__('Revision', 'stream')] = get_edit_post_link($revision_id);
}
}
}
return $links;
}
示例4: action_links
/**
* Add action links to Stream drop row in admin list screen
*
* @filter wp_stream_action_links_{connector}
*
* @param array $links Previous links registered
* @param Record $record Stream record
*
* @return array Action links
*/
public function action_links($links, $record)
{
if (in_array($record->context, $this->post_types) && get_post($record->object_id)) {
if ($link = get_edit_post_link($record->object_id)) {
$posts_connector = new Connector_Posts();
$post_type_name = $posts_connector->get_post_type_name(get_post_type($record->object_id));
$links[sprintf(esc_html_x('Edit %s', 'Post type singular name', 'stream'), $post_type_name)] = $link;
}
if (post_type_exists(get_post_type($record->object_id)) && ($link = get_permalink($record->object_id))) {
$links[esc_html__('View', 'stream')] = $link;
}
}
$context_labels = $this->get_context_labels();
$option_key = $record->get_meta('option', true);
$option_page = $record->get_meta('page', true);
$option_tab = $record->get_meta('tab', true);
$option_section = $record->get_meta('section', true);
if ($option_key && $option_tab) {
$text = sprintf(esc_html__('Edit WooCommerce %s', 'stream'), $context_labels[$record->context]);
$url = add_query_arg(array('page' => $option_page, 'tab' => $option_tab, 'section' => $option_section), admin_url('admin.php'));
$links[$text] = $url . '#wp-stream-highlight:' . $option_key;
}
return $links;
}
示例5: action_links
/**
* Add action links to Stream drop row in admin list screen
*
* @filter wp_stream_action_links_{connector}
*
* @param array $links Previous links registered
* @param Record $record Stream record
*
* @return array Action links
*/
public function action_links($links, $record)
{
$context_labels = $this->get_context_labels();
$plugin = wp_stream_get_instance();
$rules = array('stream' => array('menu_slug' => 'wp_stream', 'submenu_slug' => $plugin->admin->settings_page_slug, 'url' => function ($rule, $record) use($plugin) {
$option_key = $record->get_meta('option_key', true);
$url_tab = null;
if ('' !== $option_key) {
foreach ($plugin->settings->get_fields() as $tab_name => $tab_properties) {
foreach ($tab_properties['fields'] as $field) {
$field_key = sprintf('%s_%s', $tab_name, $field['name']);
if ($field_key === $option_key) {
$url_tab = $tab_name;
break 2;
}
}
}
}
return add_query_arg(array('page' => $rule['submenu_slug'], 'tab' => $url_tab), admin_url('admin.php'));
}, 'applicable' => function ($submenu, $record) {
return $record->context === 'wp_stream';
}), 'background_header' => array('menu_slug' => 'themes.php', 'submenu_slug' => function ($record) {
return str_replace('_', '-', $record->context);
}, 'url' => function ($rule, $record) {
return add_query_arg('page', $rule['submenu_slug']($record), admin_url($rule['menu_slug']));
}, 'applicable' => function ($submenu, $record) {
return in_array($record->context, array('custom_header', 'custom_background'));
}), 'general' => array('menu_slug' => 'options-general.php', 'submenu_slug' => function ($record) {
return sprintf('options-%s.php', $record->context);
}, 'url' => function ($rule, $record) {
return admin_url($rule['submenu_slug']($record));
}, 'applicable' => function ($submenu, $record) {
return !empty($submenu['options-general.php']);
}), 'network' => array('menu_slug' => 'settings.php', 'submenu_slug' => function ($record) {
return 'settings.php';
}, 'url' => function ($rule, $record) {
return network_admin_url($rule['menu_slug']);
}, 'applicable' => function ($submenu, $record) {
if (!$record->blog_id) {
return !empty($submenu['settings.php']);
}
return false;
}));
if ('settings' !== $record->context && in_array($record->context, array_keys($context_labels))) {
global $submenu;
$applicable_rules = array_filter($rules, function ($rule) use($submenu, $record) {
return call_user_func($rule['applicable'], $submenu, $record);
});
if (!empty($applicable_rules)) {
// The first applicable rule wins
$rule = array_shift($applicable_rules);
$menu_slug = $rule['menu_slug'];
$submenu_slug = is_object($rule['submenu_slug']) && $rule['submenu_slug'] instanceof Closure ? $rule['submenu_slug']($record) : $rule['submenu_slug'];
$url = $rule['url']($rule, $record);
if (isset($submenu[$menu_slug])) {
$found_submenus = wp_list_filter($submenu[$menu_slug], array(2 => $submenu_slug));
}
if (!empty($found_submenus)) {
$target_submenu = array_pop($found_submenus);
list($menu_title, $capability) = $target_submenu;
if (current_user_can($capability)) {
$url = apply_filters('wp_stream_action_link_url', $url, $record);
$text = sprintf(esc_html__('Edit %s Settings', 'stream'), $context_labels[$record->context]);
$field_name = $record->get_meta('option_key', true);
if ('' === $field_name) {
$field_name = $record->get_meta('option', true);
}
if ('' !== $field_name) {
$url = sprintf('%s#%s%s', rtrim(preg_replace('/#.*/', '', $url), '/'), self::HIGHLIGHT_FIELD_URL_HASH_PREFIX, $field_name);
}
$links[$text] = $url;
}
}
}
}
return $links;
}