本文整理汇总了PHP中wp_stream_get_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_stream_get_meta函数的具体用法?PHP wp_stream_get_meta怎么用?PHP wp_stream_get_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_stream_get_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 object $record Stream record
*
* @return array Action links
*/
public static function action_links($links, $record)
{
if ('wordpress' === $record->context && 'updated' === $record->action) {
global $wp_version;
$version = wp_stream_get_meta($record, 'new_version', true);
if ($version === $wp_version) {
$links[__('About', 'stream')] = admin_url('about.php?updated');
}
$links[__('View Release Notes', 'stream')] = esc_url(sprintf('http://codex.wordpress.org/Version_%s', $version));
}
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 int $record Stream record
* @return array Action links
*/
public static function action_links($links, $record)
{
if (current_user_can('edit_theme_options')) {
$file_name = wp_stream_get_meta($record->ID, 'file', true);
$theme_slug = wp_stream_get_meta($record->ID, 'theme_slug', true);
if ('' !== $file_name && '' !== $theme_slug) {
$links[__('Edit File', 'stream')] = admin_url(sprintf('theme-editor.php?theme=%s&file=%s', $theme_slug, $file_name));
$links[__('Edit Theme', 'stream')] = admin_url(sprintf('themes.php?theme=%s', $theme_slug));
}
}
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 int $record Stream record
* @return array Action links
*/
public static function action_links($links, $record)
{
if ($sidebar = wp_stream_get_meta($record->ID, 'sidebar_id', true)) {
global $wp_registered_sidebars;
if (array_key_exists($sidebar, $wp_registered_sidebars)) {
$links[__('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;
}
示例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 int $record Stream record
* @return array Action links
*/
public static function action_links($links, $record)
{
$post = get_post($record->object_id);
if ($post && $post->post_status === wp_stream_get_meta($record->ID, 'new_status', true)) {
$post_type_name = self::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', 'default')] = $view_link;
}
if ($revision_id = wp_stream_get_meta($record->ID, 'revision_id', true)) {
$links[esc_html__('Revision', 'default')] = get_edit_post_link($revision_id);
}
}
}
return $links;
}
示例5: metabox_save
public function metabox_save($rule)
{
$reset_link = add_query_arg(array('action' => 'stream-notifications-reset-occ', 'id' => absint($rule->ID), 'wp_stream_nonce' => wp_create_nonce('reset-occ_' . absint($rule->ID))), admin_url('admin-ajax.php'));
?>
<div class="submitbox" id="submitpost">
<div id="minor-publishing">
<div id="misc-publishing-actions">
<div class="misc-pub-section misc-pub-post-status">
<label for="notification_visibility">
<input type="checkbox" name="visibility" id="notification_visibility" value="active" <?php
checked(!$rule->exists() || 'active' === $rule->visibility);
?>
>
<?php
esc_html_e('Active', 'stream-notifications');
?>
</label>
</div>
<?php
if ($rule->exists()) {
?>
<div class="misc-pub-section">
<?php
$occ = absint(wp_stream_get_meta($rule->ID, 'occurrences', true));
?>
<div class="occurrences">
<p>
<?php
echo sprintf(_n('This rule has occurred %1$s time.', 'This rule has occurred %1$s times.', $occ, 'stream-notifications'), sprintf('<strong>%d</strong>', $occ ? $occ : 0));
?>
</p>
<?php
if (0 !== $occ) {
?>
<p>
<a href="<?php
echo esc_url($reset_link);
?>
" class="button button-secondary reset-occ">
<?php
esc_html_e('Reset Count', 'stream-notifications');
?>
</a>
</p>
<?php
}
?>
</div>
</div>
<?php
}
?>
</div>
</div>
<div id="major-publishing-actions">
<?php
if ($rule->exists()) {
?>
<div id="delete-action">
<?php
$delete_link = add_query_arg(array('page' => WP_Stream_Notifications::NOTIFICATIONS_PAGE_SLUG, 'action' => 'delete', 'id' => absint($rule->ID), 'wp_stream_nonce' => wp_create_nonce('delete-record_' . absint($rule->ID))), is_network_admin() ? network_admin_url(WP_Stream_Admin::ADMIN_PARENT_PAGE) : admin_url(WP_Stream_Admin::ADMIN_PARENT_PAGE));
?>
<a class="submitdelete deletion" href="<?php
echo esc_url($delete_link);
?>
">
<?php
esc_html_e('Delete Permanently', 'stream-notifications');
?>
</a>
</div>
<?php
}
?>
<div id="publishing-action">
<span class="spinner"></span>
<input type="submit" name="publish" id="publish" class="button button-primary button-large" value="<?php
$rule->exists() ? esc_attr_e('Update', 'stream-notifications') : esc_attr_e('Save', 'stream-notifications');
?>
" accesskey="s">
</div>
<div class="clear"></div>
</div>
</div>
<?php
}
示例6: 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 object $record Stream record
*
* @return array Action links
*/
public static function action_links($links, $record)
{
$contexts = self::get_context_labels();
// Options
if ($option = wp_stream_get_meta($record, 'option', true)) {
$key = wp_stream_get_meta($record, 'option_key', true);
$links[__('Edit', 'default')] = add_query_arg(array('page' => $record->context), admin_url('admin.php')) . '#stream-highlight-' . esc_attr($key);
} elseif ('wpseo_files' === $record->context) {
$links[__('Edit', 'default')] = add_query_arg(array('page' => $record->context), admin_url('admin.php'));
} elseif ('wpseo_meta' === $record->context) {
$post = get_post($record->object_id);
if ($post) {
$post_type_name = WP_Stream_Connector_Posts::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', 'default')] = $view_link;
}
if ($revision_id = wp_stream_get_meta($record, 'revision_id', true)) {
$links[esc_html__('Revision', 'default')] = get_edit_post_link($revision_id);
}
}
}
}
return $links;
}
示例7: 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 object $record Stream record
*
* @return array Action links
*/
public static function action_links($links, $record)
{
// @todo provide proper action links
if ('jetpack' === $record->connector) {
if ('modules' === $record->context) {
$slug = wp_stream_get_meta($record, 'module_slug', true);
if (is_array($slug)) {
$slug = current($slug);
}
if (Jetpack::is_module_active($slug)) {
if (apply_filters('jetpack_module_configurable_' . $slug, false)) {
$links[__('Configure', 'stream')] = Jetpack::module_configuration_url($slug);
}
$links[__('Deactivate', 'stream')] = wp_nonce_url(add_query_arg(array('action' => 'deactivate', 'module' => $slug), Jetpack::admin_url()), 'jetpack_deactivate-' . sanitize_title($slug));
} else {
$links[__('Activate', 'stream')] = wp_nonce_url(add_query_arg(array('action' => 'activate', 'module' => $slug), Jetpack::admin_url()), 'jetpack_activate-' . sanitize_title($slug));
}
} elseif (Jetpack::is_module_active(str_replace('jetpack-', '', $record->context))) {
$slug = str_replace('jetpack-', '', $record->context);
// handling jetpack-comment anomaly
if (apply_filters('jetpack_module_configurable_' . $slug, false)) {
$links[__('Configure module', 'stream')] = Jetpack::module_configuration_url($slug);
}
}
}
return $links;
}
示例8: alert
private function alert($rules, $log)
{
foreach ($rules as $rule_id => $rule) {
// Update occurrences
wp_stream_update_meta($rule_id, 'occurrences', (int) wp_stream_get_meta($rule_id, 'occurrences', true) + 1);
foreach ($rule['alerts'] as $alert) {
if (!isset(WP_Stream_Notifications::$adapters[$alert['type']])) {
continue;
}
$adapter = new WP_Stream_Notifications::$adapters[$alert['type']]['class']();
$adapter->load($alert)->send($log);
}
}
}
示例9: 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 object $record Stream record
*
* @return array Action links
*/
public static function action_links($links, $record)
{
if (current_user_can('edit_theme_options')) {
$file_name = wp_stream_get_meta($record, 'file', true);
$file_path = wp_stream_get_meta($record, 'file_path', true);
if (!empty($file_name) && !empty($file_path)) {
$theme_slug = wp_stream_get_meta($record, 'theme_slug', true);
$plugin_slug = wp_stream_get_meta($record, 'plugin_slug', true);
$theme_exists = !empty($theme_slug) && file_exists($file_path);
$plugin_exists = !empty($plugin_slug) && file_exists($file_path);
if ($theme_exists) {
$links[__('Edit File', 'stream')] = add_query_arg(array('theme' => urlencode($theme_slug), 'file' => urlencode($file_name)), self_admin_url('theme-editor.php'));
$links[__('Theme Details', 'stream')] = add_query_arg(array('theme' => urlencode($theme_slug)), self_admin_url('themes.php'));
}
if ($plugin_exists) {
$links[__('Edit File', 'stream')] = add_query_arg(array('plugin' => urlencode($plugin_slug), 'file' => urlencode(str_ireplace(trailingslashit(WP_PLUGIN_DIR), '', $file_path))), self_admin_url('plugin-editor.php'));
}
}
}
return $links;
}
示例10: column_default
function column_default($item, $column_name)
{
switch ($column_name) {
case 'date':
$date_string = sprintf('<time datetime="%s" class="relative-time">%s</time>', $item->created, get_date_from_gmt($item->created, 'Y/m/d'));
$out = $this->column_link($date_string, 'date', date('Y/m/d', strtotime($item->created)));
$out .= '<br />';
$out .= get_date_from_gmt($item->created, 'h:i:s A');
break;
case 'summary':
$out = $item->summary;
if ($item->object_id) {
$out .= $this->column_link('<span class="dashicons dashicons-search stream-filter-object-id"></span>', array('object_id' => $item->object_id, 'context' => $item->context), null, __('View all records for this object', 'stream'));
}
$out .= $this->get_action_links($item);
break;
case 'author':
require_once WP_STREAM_INC_DIR . 'class-wp-stream-author.php';
$author_meta = wp_stream_get_meta($item->ID, 'author_meta', true);
$author = new WP_Stream_Author((int) $item->author, $author_meta);
$out = sprintf('<a href="%s">%s <span>%s</span></a>%s%s%s', $author->get_records_page_url(), $author->get_avatar_img(80), $author->get_display_name(), $author->is_deleted() ? sprintf('<br /><small class="deleted">%s</small>', esc_html__('Deleted User', 'stream')) : '', $author->get_role() ? sprintf('<br /><small>%s</small>', $author->get_role()) : '', $author->get_agent() ? sprintf('<br /><small>%s</small>', WP_Stream_Author::get_agent_label($author->get_agent())) : '');
break;
case 'connector':
case 'context':
case 'action':
$out = $this->column_link($this->get_term_title($item->{$column_name}, $column_name), $column_name, $item->{$column_name});
break;
case 'ip':
$out = $this->column_link($item->{$column_name}, 'ip', $item->{$column_name});
break;
case 'id':
$out = absint($item->ID);
break;
case 'blog_id':
$blog = $item->blog_id && is_multisite() ? get_blog_details($item->blog_id) : WP_Stream_Network::get_network_blog();
$out = sprintf('<a href="%s"><span>%s</span></a>', add_query_arg(array('blog_id' => $blog->blog_id), network_admin_url('admin.php?page=wp_stream')), esc_html($blog->blogname));
break;
default:
/**
* Registers new Columns to be inserted into the table. The cell contents of this column is set
* below with 'wp_stream_inster_column_default-'
*
* @param array $new_columns Array of new column titles to add
*/
$inserted_columns = apply_filters('wp_stream_register_column_defaults', $new_columns = array());
if (!empty($inserted_columns) && is_array($inserted_columns)) {
foreach ($inserted_columns as $column_title) {
/**
* If column title inserted via wp_stream_register_column_defaults ($column_title) exists
* among columns registered with get_columns ($column_name) and there is an action associated
* with this column, do the action
*
* Also, note that the action name must include the $column_title registered
* with wp_stream_register_column_defaults
*/
if ($column_title == $column_name && has_action('wp_stream_insert_column_default-' . $column_title)) {
/**
* This action allows for the addition of content under the specified column ($column_title)
*
* @param string $column_title Title of the column (set in wp_stream_register_column_defaults)
* @param obj $item Contents of the row
*/
$out = do_action('wp_stream_insert_column_default-' . $column_title, $item);
} else {
$out = $column_name;
}
}
} else {
$out = $column_name;
// xss ok
}
}
echo $out;
// xss ok
}
示例11: get_stream_meta
/**
* get_stream_meta()
*
* @deprecated 1.3.2
* @deprecated Use wp_stream_get_meta
* @see wp_stream_get_meta()
*/
function get_stream_meta($record_id, $key = '', $single = false)
{
_deprecated_function(__FUNCTION__, '1.3.2', 'wp_stream_get_meta()');
return wp_stream_get_meta($record_id, $key, $single);
}
示例12: 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 object $record Stream record
*
* @return array Action links
*/
public static function action_links($links, $record)
{
if (in_array($record->context, array('downloads'))) {
$links = WP_Stream_Connector_Posts::action_links($links, $record);
} elseif (in_array($record->context, array('discounts'))) {
$post_type_label = get_post_type_labels(get_post_type_object('edd_discount'))->singular_name;
$base = admin_url('edit.php?post_type=download&page=edd-discounts');
$links[sprintf(__('Edit %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'edit_discount', 'discount' => $record->object_id), $base);
if ('active' === get_post($record->object_id)->post_status) {
$links[sprintf(__('Deactivate %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'deactivate_discount', 'discount' => $record->object_id), $base);
} else {
$links[sprintf(__('Activate %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'activate_discount', 'discount' => $record->object_id), $base);
}
} elseif (in_array($record->context, array('download_category', 'download_tag'))) {
$tax_label = get_taxonomy_labels(get_taxonomy($record->context))->singular_name;
$links[sprintf(__('Edit %s', 'stream'), $tax_label)] = get_edit_term_link($record->object_id, wp_stream_get_meta($record, 'taxonomy', true));
} elseif ('api_keys' === $record->context) {
$user = new WP_User($record->object_id);
if (apply_filters('edd_api_log_requests', true)) {
$links[__('View API Log', 'stream')] = add_query_arg(array('view' => 'api_requests', 'post_type' => 'download', 'page' => 'edd-reports', 'tab' => 'logs', 's' => $user->user_email), 'edit.php');
}
$links[__('Revoke', 'stream')] = add_query_arg(array('post_type' => 'download', 'user_id' => $record->object_id, 'edd_action' => 'process_api_key', 'edd_api_process' => 'revoke'), 'edit.php');
$links[__('Reissue', 'stream')] = add_query_arg(array('post_type' => 'download', 'user_id' => $record->object_id, 'edd_action' => 'process_api_key', 'edd_api_process' => 'regenerate'), 'edit.php');
}
return $links;
}
示例13: 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 object $record Stream record
*
* @return array Action links
*/
public static function action_links($links, $record)
{
$context_labels = self::get_context_labels();
$rules = array('stream' => array('menu_slug' => 'wp_stream', 'submenu_slug' => WP_Stream_Admin::SETTINGS_PAGE_SLUG, 'url' => function ($rule, $record) {
$option_key = wp_stream_get_meta($record, 'option_key', true);
$url_tab = null;
if ('' !== $option_key) {
foreach (WP_Stream_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(__('Edit %s Settings', 'stream'), $context_labels[$record->context]);
$field_name = wp_stream_get_meta($record, 'option_key', true);
if ('' === $field_name) {
$field_name = wp_stream_get_meta($record, '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;
}
示例14: widget_row
/**
* Renders rows for Stream Activity Dashboard Widget
*
* @param obj Record to be inserted
* @param int Row number
* @return string Contents of new row
*/
public static function widget_row($item, $i = null)
{
require_once WP_STREAM_INC_DIR . 'class-wp-stream-author.php';
$author_meta = wp_stream_get_meta($item->ID, 'author_meta', true);
$author = new WP_Stream_Author((int) $item->author, $author_meta);
$time_author = sprintf(_x('%1$s ago by <a href="%2$s">%3$s</a>', '1: Time, 2: User profile URL, 3: User display name', 'stream'), human_time_diff(strtotime($item->created)), esc_url($author->get_records_page_url()), esc_html($author->get_display_name()));
if ($author->get_agent()) {
$time_author .= sprintf(' %s', WP_Stream_Author::get_agent_label($author->get_agent()));
}
$class = isset($i) && $i % 2 ? 'alternate' : '';
ob_start();
?>
<li class="<?php
echo esc_html($class);
?>
" data-id="<?php
echo esc_html($item->ID);
?>
">
<div class="record-avatar">
<a href="<?php
echo esc_url($author->get_records_page_url());
?>
">
<?php
echo $author->get_avatar_img(72);
// xss ok
?>
</a>
</div>
<span class="record-meta"><?php
echo $time_author;
// xss ok
?>
</span>
<br />
<?php
echo esc_html($item->summary);
?>
</li><?php
return ob_get_clean();
}
示例15: wp_stream_update_migrate_media_to_attachment_type
function wp_stream_update_migrate_media_to_attachment_type()
{
global $wpdb;
$sql = "SELECT r.ID id, r.object_id pid, c.meta_id mid\n\t\tFROM {$wpdb->stream} r\n\t\tJOIN {$wpdb->streamcontext} c\n\t\t\tON r.ID = c.record_id AND c.connector = 'media' AND c.context = 'media'\n\t";
$records = $wpdb->get_results($sql);
// db call ok
foreach ($records as $record) {
$post = get_post($record->pid);
$guid = isset($post->guid) ? $post->guid : null;
$url = $guid ? $guid : wp_stream_get_meta($record->id, 'url', true);
if (!empty($url)) {
$wpdb->update($wpdb->streamcontext, array('context' => WP_Stream_Connector_Media::get_attachment_type($url)), array('record_id' => $record->id), array('%s'), array('%d'));
}
}
}