本文整理汇总了PHP中clean_bookmark_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP clean_bookmark_cache函数的具体用法?PHP clean_bookmark_cache怎么用?PHP clean_bookmark_cache使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clean_bookmark_cache函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_delete_user
/**
* Remove user and optionally reassign posts and links to another user.
*
* If the $reassign parameter is not assigned to a User ID, then all posts will
* be deleted of that user. The action 'delete_user' that is passed the User ID
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
*
* @since 2.0.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
* @return bool True when finished.
*/
function wp_delete_user($id, $reassign = null)
{
global $wpdb;
if (!is_numeric($id)) {
return false;
}
$id = (int) $id;
$user = new WP_User($id);
if (!$user->exists()) {
return false;
}
// Normalize $reassign to null or a user ID. 'novalue' was an older default.
if ('novalue' === $reassign) {
$reassign = null;
} elseif (null !== $reassign) {
$reassign = (int) $reassign;
}
/**
* Fires immediately before a user is deleted from the database.
*
* @since 2.0.0
*
* @param int $id ID of the user to delete.
* @param int|null $reassign ID of the user to reassign posts and links to.
* Default null, for no reassignment.
*/
do_action('delete_user', $id, $reassign);
if (null === $reassign) {
$post_types_to_delete = array();
foreach (get_post_types(array(), 'objects') as $post_type) {
if ($post_type->delete_with_user) {
$post_types_to_delete[] = $post_type->name;
} elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
$post_types_to_delete[] = $post_type->name;
}
}
/**
* Filter the list of post types to delete with a user.
*
* @since 3.4.0
*
* @param array $post_types_to_delete Post types to delete.
* @param int $id User ID.
*/
$post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
$post_types_to_delete = implode("', '", $post_types_to_delete);
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_type IN ('{$post_types_to_delete}')", $id));
if ($post_ids) {
foreach ($post_ids as $post_id) {
wp_delete_post($post_id);
}
}
// Clean links
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
if ($link_ids) {
foreach ($link_ids as $link_id) {
wp_delete_link($link_id);
}
}
} else {
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
$wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
if (!empty($post_ids)) {
foreach ($post_ids as $post_id) {
clean_post_cache($post_id);
}
}
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
$wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
if (!empty($link_ids)) {
foreach ($link_ids as $link_id) {
clean_bookmark_cache($link_id);
}
}
}
// FINALLY, delete user
if (is_multisite()) {
remove_user_from_blog($id, get_current_blog_id());
} else {
$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
foreach ($meta as $mid) {
delete_metadata_by_mid('user', $mid);
}
$wpdb->delete($wpdb->users, array('ID' => $id));
//.........这里部分代码省略.........
示例2: link_library_insert_link
function link_library_insert_link($linkdata, $wp_error = false, $addlinknoaddress = false)
{
global $wpdb;
$defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0);
$linkdata = wp_parse_args($linkdata, $defaults);
$linkdata = sanitize_bookmark($linkdata, 'db');
extract(stripslashes_deep($linkdata), EXTR_SKIP);
$update = false;
if (!empty($link_id)) {
$update = true;
}
if (isset($link_name) && trim($link_name) == '') {
if (isset($link_url) && trim($link_url) != '') {
$link_name = $link_url;
} else {
return 0;
}
}
if ($addlinknoaddress == false) {
if (trim($link_url) == '') {
return 0;
}
}
if (empty($link_rating)) {
$link_rating = 0;
}
if (empty($link_image)) {
$link_image = '';
}
if (empty($link_target)) {
$link_target = '';
}
if (empty($link_visible)) {
$link_visible = 'Y';
}
if (empty($link_owner)) {
$link_owner = get_current_user_id();
}
if (empty($link_notes)) {
$link_notes = '';
}
if (empty($link_description)) {
$link_description = '';
}
if (empty($link_rss)) {
$link_rss = '';
}
if (empty($link_rel)) {
$link_rel = '';
}
// Make sure we set a valid category
if (!isset($link_category) || 0 == count($link_category) || !is_array($link_category)) {
$link_category = array(get_option('default_link_category'));
}
if ($update) {
if (false === $wpdb->update($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id'))) {
if ($wp_error) {
return new WP_Error('db_update_error', __('Could not update link in the database', 'link-library'), $wpdb->last_error);
} else {
return 0;
}
}
} else {
if (false === $wpdb->insert($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss'))) {
if ($wp_error) {
return new WP_Error('db_insert_error', __('Could not insert link into the database', 'link-library'), $wpdb->last_error);
} else {
return 0;
}
}
$link_id = (int) $wpdb->insert_id;
}
wp_set_link_cats($link_id, $link_category);
if ($update) {
do_action('edit_link', $link_id);
} else {
do_action('add_link', $link_id);
}
clean_bookmark_cache($link_id);
return $link_id;
}
示例3: wp_delete_user
/**
* Remove user and optionally reassign posts and links to another user.
*
* If the $reassign parameter is not assigned to an User ID, then all posts will
* be deleted of that user. The action 'delete_user' that is passed the User ID
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
*
* @since 2.0.0
*
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
* @return bool True when finished.
*/
function wp_delete_user($id, $reassign = 'novalue')
{
global $wpdb;
$id = (int) $id;
$user = new WP_User($id);
if (!$user->exists()) {
return false;
}
// allow for transaction statement
do_action('delete_user', $id);
if ('novalue' === $reassign || null === $reassign) {
$post_types_to_delete = array();
foreach (get_post_types(array(), 'objects') as $post_type) {
if ($post_type->delete_with_user) {
$post_types_to_delete[] = $post_type->name;
} elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
$post_types_to_delete[] = $post_type->name;
}
}
$post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
$post_types_to_delete = implode("', '", $post_types_to_delete);
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_type IN ('{$post_types_to_delete}')", $id));
if ($post_ids) {
foreach ($post_ids as $post_id) {
wp_delete_post($post_id);
}
}
// Clean links
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
if ($link_ids) {
foreach ($link_ids as $link_id) {
wp_delete_link($link_id);
}
}
} else {
$reassign = (int) $reassign;
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
$wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
if (!empty($post_ids)) {
foreach ($post_ids as $post_id) {
clean_post_cache($post_id);
}
}
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
$wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
if (!empty($link_ids)) {
foreach ($link_ids as $link_id) {
clean_bookmark_cache($link_id);
}
}
}
// FINALLY, delete user
if (is_multisite()) {
remove_user_from_blog($id, get_current_blog_id());
} else {
$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
foreach ($meta as $mid) {
delete_metadata_by_mid('user', $mid);
}
$wpdb->delete($wpdb->users, array('ID' => $id));
}
clean_user_cache($user);
// allow for commit transaction
do_action('deleted_user', $id);
return true;
}
示例4: save_settings
function save_settings ($reload = false) {
global $wpdb;
// Save channel-level meta-data
foreach (array('link_name', 'link_description', 'link_url') as $what) :
$alter[] = "{$what} = '".$wpdb->escape($this->link->{$what})."'";
endforeach;
// Save settings to the notes field
$alter[] = "link_notes = '".$wpdb->escape($this->settings_to_notes())."'";
// Update the properties of the link from settings changes, etc.
$update_set = implode(", ", $alter);
$result = $wpdb->query("
UPDATE $wpdb->links
SET $update_set
WHERE link_id='$this->id'
");
if ($reload) :
// force reload of link information from DB
if (function_exists('clean_bookmark_cache')) :
clean_bookmark_cache($this->id);
endif;
endif;
} /* SyndicatedLink::save_settings () */
示例5: wp_set_link_cats
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $link_id
* @param unknown_type $link_categories
*/
function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
// If $link_categories isn't already an array, make it one:
if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
$link_categories = array( get_option( 'default_link_category' ) );
$link_categories = array_map( 'intval', $link_categories );
$link_categories = array_unique( $link_categories );
wp_set_object_terms( $link_id, $link_categories, 'link_category' );
clean_bookmark_cache( $link_id );
} // wp_set_link_cats()
示例6: save_settings
function save_settings($reload = false)
{
global $wpdb;
// Save channel-level meta-data
foreach (array('link_name', 'link_description', 'link_url') as $what) {
$alter[] = "{$what} = '" . esc_sql($this->link->{$what}) . "'";
}
// Save settings to the notes field
$alter[] = "link_notes = '" . esc_sql($this->settings_to_notes()) . "'";
// Update the properties of the link from settings changes, etc.
$update_set = implode(", ", $alter);
$result = $wpdb->query("\n\t\tUPDATE {$wpdb->links}\n\t\tSET {$update_set}\n\t\tWHERE link_id='{$this->id}'\n\t\t");
if ($reload) {
// force reload of link information from DB
if (function_exists('clean_bookmark_cache')) {
clean_bookmark_cache($this->id);
}
}
}
示例7: fwp_linkedit_page
//.........这里部分代码省略.........
$userdata['ID'] = NULL;
$userdata['user_login'] = sanitize_user($newuser_name);
$userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
$userdata['user_nicename'] = sanitize_title($newuser_name);
$userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
$userdata['display_name'] = $wpdb->escape($newuser_name);
$newuser_id = wp_insert_user($userdata);
if (is_numeric($newuser_id)) {
$link->settings['map authors']['name'][$name] = $newuser_id;
} else {
// TODO: Add some error detection and reporting
}
} else {
// TODO: Add some error reporting
}
} else {
$link->settings['map authors']['name'][$name] = $author_action;
}
}
}
if (isset($GLOBALS['fwp_post']['cat_split'])) {
if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) {
$link->settings['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
} else {
unset($link->settings['cat_split']);
}
}
$alter[] = "link_notes = '" . $wpdb->escape($link->settings_to_notes()) . "'";
$alter_set = implode(", ", $alter);
// issue update query
$result = $wpdb->query("\n\t\t\t\tUPDATE {$wpdb->links}\n\t\t\t\tSET {$alter_set}\n\t\t\t\tWHERE link_id='{$link_id}'\n\t\t\t\t");
$updated_link = true;
// reload link information from DB
if (function_exists('clean_bookmark_cache')) {
clean_bookmark_cache($link_id);
}
$link =& new SyndicatedLink($link_id);
} else {
$updated_link = false;
}
$db_link = $link->link;
$link_url = wp_specialchars($db_link->link_url, 1);
$link_name = wp_specialchars($db_link->link_name, 1);
$link_description = wp_specialchars($db_link->link_description, 'both');
$link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
$post_status_global = get_option('feedwordpress_syndicated_post_status');
$comment_status_global = get_option('feedwordpress_syndicated_comment_status');
$ping_status_global = get_option('feedwordpress_syndicated_ping_status');
$status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => '');
if (SyndicatedPost::use_api('post_status_pending')) {
$status['post']['pending'] = '';
}
$status['comment'] = array('open' => '', 'closed' => '', 'site-default' => '');
$status['ping'] = array('open' => '', 'closed' => '', 'site-default' => '');
foreach (array('post', 'comment', 'ping') as $what) {
if (isset($link->settings["{$what} status"])) {
$status[$what][$link->settings["{$what} status"]] = ' checked="checked"';
} else {
$status[$what]['site-default'] = ' checked="checked"';
}
}
$unfamiliar['author'] = array('create' => '', 'default' => '', 'filter' => '');
$unfamiliar['category'] = array('create' => '', 'tag' => '', 'default' => '', 'filter' => '');
foreach (array('author', 'category') as $what) {
if (is_string($link->settings["unfamiliar {$what}"]) and array_key_exists($link->settings["unfamiliar {$what}"], $unfamiliar[$what])) {
$key = $link->settings["unfamiliar {$what}"];
示例8: save_settings
function save_settings($reload = false)
{
$link = get_bookmark($this->id, ARRAY_A);
// Save channel-level meta-data
foreach (array('link_name', 'link_description', 'link_url') as $what) {
$link[$what] = $this->link->{$what};
}
// Save settings to the notes field
$link['link_notes'] = $this->settings_to_notes();
$result = wp_update_link($link);
if ($reload) {
// force reload of link information from DB
if (function_exists('clean_bookmark_cache')) {
clean_bookmark_cache($this->id);
}
}
}
示例9: fwp_authors_page
//.........这里部分代码省略.........
unset($link->settings['map authors']);
foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) {
// Normalize for case and whitespace
$name = strtolower(trim($name));
$author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
if (strlen($name) > 0) {
if ('newuser' == $author_action) {
$newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
$link->map_name_to_new_user($name, $newuser_name);
} else {
$link->settings['map authors']['name'][$name] = $author_action;
}
}
}
}
if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) {
$name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
$author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
if (strlen($name) > 0) {
if ('newuser' == $author_action) {
$newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
$link->map_name_to_new_user($name, $newuser_name);
} else {
$link->settings['map authors']['name'][$name] = $author_action;
}
}
}
$alter[] = "link_notes = '" . $wpdb->escape($link->settings_to_notes()) . "'";
$alter_set = implode(", ", $alter);
// issue update query
$result = $wpdb->query("\n\t\t\t\tUPDATE {$wpdb->links}\n\t\t\t\tSET {$alter_set}\n\t\t\t\tWHERE link_id='{$link_id}'\n\t\t\t\t");
$updated_link = true;
// reload link information from DB
if (function_exists('clean_bookmark_cache')) {
clean_bookmark_cache($link_id);
}
$link =& new SyndicatedLink($link_id);
} else {
if ('newuser' == $GLOBALS['fwp_post']['unfamiliar_author']) {
$newuser_name = trim($GLOBALS['fwp_post']['unfamiliar_author_newuser']);
if (strlen($newuser_name) > 0) {
$userdata = array();
$userdata['ID'] = NULL;
$userdata['user_login'] = sanitize_user($newuser_name);
$userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
$userdata['user_nicename'] = sanitize_title($newuser_name);
$userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
$userdata['display_name'] = $wpdb->escape($newuser_name);
$newuser_id = wp_insert_user($userdata);
if (is_numeric($newuser_id)) {
update_option('feedwordpress_unfamiliar_author', $newuser_id);
} else {
// TODO: Add some error detection and reporting
}
} else {
// TODO: Add some error reporting
}
} else {
update_option('feedwordpress_unfamiliar_author', $GLOBALS['fwp_post']['unfamiliar_author']);
}
if (isset($GLOBALS['fwp_post']['match_author_by_email']) and $GLOBALS['fwp_post']['match_author_by_email'] == 'yes') {
update_option('feedwordpress_do_not_match_author_by_email', 'no');
} else {
update_option('feedwordpress_do_not_match_author_by_email', 'yes');
}
if (isset($GLOBALS['fwp_post']['null_emails'])) {