Edit File by line
/home/barbar84/www/wp-inclu...
File: bookmark.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Link/Bookmark API
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Bookmark
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Retrieve Bookmark data
[9] Fix | Delete
*
[10] Fix | Delete
* @since 2.1.0
[11] Fix | Delete
*
[12] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[13] Fix | Delete
*
[14] Fix | Delete
* @param int|stdClass $bookmark
[15] Fix | Delete
* @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
[16] Fix | Delete
* correspond to an stdClass object, an associative array, or a numeric array,
[17] Fix | Delete
* respectively. Default OBJECT.
[18] Fix | Delete
* @param string $filter Optional. How to sanitize bookmark fields. Default 'raw'.
[19] Fix | Delete
* @return array|object|null Type returned depends on $output value.
[20] Fix | Delete
*/
[21] Fix | Delete
function get_bookmark( $bookmark, $output = OBJECT, $filter = 'raw' ) {
[22] Fix | Delete
global $wpdb;
[23] Fix | Delete
[24] Fix | Delete
if ( empty( $bookmark ) ) {
[25] Fix | Delete
if ( isset( $GLOBALS['link'] ) ) {
[26] Fix | Delete
$_bookmark = & $GLOBALS['link'];
[27] Fix | Delete
} else {
[28] Fix | Delete
$_bookmark = null;
[29] Fix | Delete
}
[30] Fix | Delete
} elseif ( is_object( $bookmark ) ) {
[31] Fix | Delete
wp_cache_add( $bookmark->link_id, $bookmark, 'bookmark' );
[32] Fix | Delete
$_bookmark = $bookmark;
[33] Fix | Delete
} else {
[34] Fix | Delete
if ( isset( $GLOBALS['link'] ) && ( $GLOBALS['link']->link_id == $bookmark ) ) {
[35] Fix | Delete
$_bookmark = & $GLOBALS['link'];
[36] Fix | Delete
} else {
[37] Fix | Delete
$_bookmark = wp_cache_get( $bookmark, 'bookmark' );
[38] Fix | Delete
if ( ! $_bookmark ) {
[39] Fix | Delete
$_bookmark = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark ) );
[40] Fix | Delete
if ( $_bookmark ) {
[41] Fix | Delete
$_bookmark->link_category = array_unique( wp_get_object_terms( $_bookmark->link_id, 'link_category', array( 'fields' => 'ids' ) ) );
[42] Fix | Delete
wp_cache_add( $_bookmark->link_id, $_bookmark, 'bookmark' );
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
if ( ! $_bookmark ) {
[49] Fix | Delete
return $_bookmark;
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
$_bookmark = sanitize_bookmark( $_bookmark, $filter );
[53] Fix | Delete
[54] Fix | Delete
if ( OBJECT == $output ) {
[55] Fix | Delete
return $_bookmark;
[56] Fix | Delete
} elseif ( ARRAY_A == $output ) {
[57] Fix | Delete
return get_object_vars( $_bookmark );
[58] Fix | Delete
} elseif ( ARRAY_N == $output ) {
[59] Fix | Delete
return array_values( get_object_vars( $_bookmark ) );
[60] Fix | Delete
} else {
[61] Fix | Delete
return $_bookmark;
[62] Fix | Delete
}
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Retrieve single bookmark data item or field.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 2.3.0
[69] Fix | Delete
*
[70] Fix | Delete
* @param string $field The name of the data field to return.
[71] Fix | Delete
* @param int $bookmark The bookmark ID to get field.
[72] Fix | Delete
* @param string $context Optional. The context of how the field will be used.
[73] Fix | Delete
* @return string|WP_Error
[74] Fix | Delete
*/
[75] Fix | Delete
function get_bookmark_field( $field, $bookmark, $context = 'display' ) {
[76] Fix | Delete
$bookmark = (int) $bookmark;
[77] Fix | Delete
$bookmark = get_bookmark( $bookmark );
[78] Fix | Delete
[79] Fix | Delete
if ( is_wp_error( $bookmark ) ) {
[80] Fix | Delete
return $bookmark;
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
if ( ! is_object( $bookmark ) ) {
[84] Fix | Delete
return '';
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
if ( ! isset( $bookmark->$field ) ) {
[88] Fix | Delete
return '';
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
return sanitize_bookmark_field( $field, $bookmark->$field, $bookmark->link_id, $context );
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Retrieves the list of bookmarks
[96] Fix | Delete
*
[97] Fix | Delete
* Attempts to retrieve from the cache first based on MD5 hash of arguments. If
[98] Fix | Delete
* that fails, then the query will be built from the arguments and executed. The
[99] Fix | Delete
* results will be stored to the cache.
[100] Fix | Delete
*
[101] Fix | Delete
* @since 2.1.0
[102] Fix | Delete
*
[103] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[104] Fix | Delete
*
[105] Fix | Delete
* @param string|array $args {
[106] Fix | Delete
* Optional. String or array of arguments to retrieve bookmarks.
[107] Fix | Delete
*
[108] Fix | Delete
* @type string $orderby How to order the links by. Accepts 'id', 'link_id', 'name', 'link_name',
[109] Fix | Delete
* 'url', 'link_url', 'visible', 'link_visible', 'rating', 'link_rating',
[110] Fix | Delete
* 'owner', 'link_owner', 'updated', 'link_updated', 'notes', 'link_notes',
[111] Fix | Delete
* 'description', 'link_description', 'length' and 'rand'.
[112] Fix | Delete
* When `$orderby` is 'length', orders by the character length of
[113] Fix | Delete
* 'link_name'. Default 'name'.
[114] Fix | Delete
* @type string $order Whether to order bookmarks in ascending or descending order.
[115] Fix | Delete
* Accepts 'ASC' (ascending) or 'DESC' (descending). Default 'ASC'.
[116] Fix | Delete
* @type int $limit Amount of bookmarks to display. Accepts any positive number or
[117] Fix | Delete
* -1 for all. Default -1.
[118] Fix | Delete
* @type string $category Comma-separated list of category IDs to include links from.
[119] Fix | Delete
* Default empty.
[120] Fix | Delete
* @type string $category_name Category to retrieve links for by name. Default empty.
[121] Fix | Delete
* @type int|bool $hide_invisible Whether to show or hide links marked as 'invisible'. Accepts
[122] Fix | Delete
* 1|true or 0|false. Default 1|true.
[123] Fix | Delete
* @type int|bool $show_updated Whether to display the time the bookmark was last updated.
[124] Fix | Delete
* Accepts 1|true or 0|false. Default 0|false.
[125] Fix | Delete
* @type string $include Comma-separated list of bookmark IDs to include. Default empty.
[126] Fix | Delete
* @type string $exclude Comma-separated list of bookmark IDs to exclude. Default empty.
[127] Fix | Delete
* @type string $search Search terms. Will be SQL-formatted with wildcards before and after
[128] Fix | Delete
* and searched in 'link_url', 'link_name' and 'link_description'.
[129] Fix | Delete
* Default empty.
[130] Fix | Delete
* }
[131] Fix | Delete
* @return object[] List of bookmark row objects.
[132] Fix | Delete
*/
[133] Fix | Delete
function get_bookmarks( $args = '' ) {
[134] Fix | Delete
global $wpdb;
[135] Fix | Delete
[136] Fix | Delete
$defaults = array(
[137] Fix | Delete
'orderby' => 'name',
[138] Fix | Delete
'order' => 'ASC',
[139] Fix | Delete
'limit' => -1,
[140] Fix | Delete
'category' => '',
[141] Fix | Delete
'category_name' => '',
[142] Fix | Delete
'hide_invisible' => 1,
[143] Fix | Delete
'show_updated' => 0,
[144] Fix | Delete
'include' => '',
[145] Fix | Delete
'exclude' => '',
[146] Fix | Delete
'search' => '',
[147] Fix | Delete
);
[148] Fix | Delete
[149] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[150] Fix | Delete
[151] Fix | Delete
$key = md5( serialize( $parsed_args ) );
[152] Fix | Delete
$cache = wp_cache_get( 'get_bookmarks', 'bookmark' );
[153] Fix | Delete
[154] Fix | Delete
if ( 'rand' !== $parsed_args['orderby'] && $cache ) {
[155] Fix | Delete
if ( is_array( $cache ) && isset( $cache[ $key ] ) ) {
[156] Fix | Delete
$bookmarks = $cache[ $key ];
[157] Fix | Delete
/**
[158] Fix | Delete
* Filters the returned list of bookmarks.
[159] Fix | Delete
*
[160] Fix | Delete
* The first time the hook is evaluated in this file, it returns the cached
[161] Fix | Delete
* bookmarks list. The second evaluation returns a cached bookmarks list if the
[162] Fix | Delete
* link category is passed but does not exist. The third evaluation returns
[163] Fix | Delete
* the full cached results.
[164] Fix | Delete
*
[165] Fix | Delete
* @since 2.1.0
[166] Fix | Delete
*
[167] Fix | Delete
* @see get_bookmarks()
[168] Fix | Delete
*
[169] Fix | Delete
* @param array $bookmarks List of the cached bookmarks.
[170] Fix | Delete
* @param array $parsed_args An array of bookmark query arguments.
[171] Fix | Delete
*/
[172] Fix | Delete
return apply_filters( 'get_bookmarks', $bookmarks, $parsed_args );
[173] Fix | Delete
}
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
if ( ! is_array( $cache ) ) {
[177] Fix | Delete
$cache = array();
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
$inclusions = '';
[181] Fix | Delete
if ( ! empty( $parsed_args['include'] ) ) {
[182] Fix | Delete
$parsed_args['exclude'] = ''; // Ignore exclude, category, and category_name params if using include.
[183] Fix | Delete
$parsed_args['category'] = '';
[184] Fix | Delete
$parsed_args['category_name'] = '';
[185] Fix | Delete
[186] Fix | Delete
$inclinks = wp_parse_id_list( $parsed_args['include'] );
[187] Fix | Delete
if ( count( $inclinks ) ) {
[188] Fix | Delete
foreach ( $inclinks as $inclink ) {
[189] Fix | Delete
if ( empty( $inclusions ) ) {
[190] Fix | Delete
$inclusions = ' AND ( link_id = ' . $inclink . ' ';
[191] Fix | Delete
} else {
[192] Fix | Delete
$inclusions .= ' OR link_id = ' . $inclink . ' ';
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
}
[197] Fix | Delete
if ( ! empty( $inclusions ) ) {
[198] Fix | Delete
$inclusions .= ')';
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
$exclusions = '';
[202] Fix | Delete
if ( ! empty( $parsed_args['exclude'] ) ) {
[203] Fix | Delete
$exlinks = wp_parse_id_list( $parsed_args['exclude'] );
[204] Fix | Delete
if ( count( $exlinks ) ) {
[205] Fix | Delete
foreach ( $exlinks as $exlink ) {
[206] Fix | Delete
if ( empty( $exclusions ) ) {
[207] Fix | Delete
$exclusions = ' AND ( link_id <> ' . $exlink . ' ';
[208] Fix | Delete
} else {
[209] Fix | Delete
$exclusions .= ' AND link_id <> ' . $exlink . ' ';
[210] Fix | Delete
}
[211] Fix | Delete
}
[212] Fix | Delete
}
[213] Fix | Delete
}
[214] Fix | Delete
if ( ! empty( $exclusions ) ) {
[215] Fix | Delete
$exclusions .= ')';
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
if ( ! empty( $parsed_args['category_name'] ) ) {
[219] Fix | Delete
$parsed_args['category'] = get_term_by( 'name', $parsed_args['category_name'], 'link_category' );
[220] Fix | Delete
if ( $parsed_args['category'] ) {
[221] Fix | Delete
$parsed_args['category'] = $parsed_args['category']->term_id;
[222] Fix | Delete
} else {
[223] Fix | Delete
$cache[ $key ] = array();
[224] Fix | Delete
wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
[225] Fix | Delete
/** This filter is documented in wp-includes/bookmark.php */
[226] Fix | Delete
return apply_filters( 'get_bookmarks', array(), $parsed_args );
[227] Fix | Delete
}
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
$search = '';
[231] Fix | Delete
if ( ! empty( $parsed_args['search'] ) ) {
[232] Fix | Delete
$like = '%' . $wpdb->esc_like( $parsed_args['search'] ) . '%';
[233] Fix | Delete
$search = $wpdb->prepare( ' AND ( (link_url LIKE %s) OR (link_name LIKE %s) OR (link_description LIKE %s) ) ', $like, $like, $like );
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
$category_query = '';
[237] Fix | Delete
$join = '';
[238] Fix | Delete
if ( ! empty( $parsed_args['category'] ) ) {
[239] Fix | Delete
$incategories = wp_parse_id_list( $parsed_args['category'] );
[240] Fix | Delete
if ( count( $incategories ) ) {
[241] Fix | Delete
foreach ( $incategories as $incat ) {
[242] Fix | Delete
if ( empty( $category_query ) ) {
[243] Fix | Delete
$category_query = ' AND ( tt.term_id = ' . $incat . ' ';
[244] Fix | Delete
} else {
[245] Fix | Delete
$category_query .= ' OR tt.term_id = ' . $incat . ' ';
[246] Fix | Delete
}
[247] Fix | Delete
}
[248] Fix | Delete
}
[249] Fix | Delete
}
[250] Fix | Delete
if ( ! empty( $category_query ) ) {
[251] Fix | Delete
$category_query .= ") AND taxonomy = 'link_category'";
[252] Fix | Delete
$join = " INNER JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
if ( $parsed_args['show_updated'] ) {
[256] Fix | Delete
$recently_updated_test = ', IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated ';
[257] Fix | Delete
} else {
[258] Fix | Delete
$recently_updated_test = '';
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
$get_updated = ( $parsed_args['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : '';
[262] Fix | Delete
[263] Fix | Delete
$orderby = strtolower( $parsed_args['orderby'] );
[264] Fix | Delete
$length = '';
[265] Fix | Delete
switch ( $orderby ) {
[266] Fix | Delete
case 'length':
[267] Fix | Delete
$length = ', CHAR_LENGTH(link_name) AS length';
[268] Fix | Delete
break;
[269] Fix | Delete
case 'rand':
[270] Fix | Delete
$orderby = 'rand()';
[271] Fix | Delete
break;
[272] Fix | Delete
case 'link_id':
[273] Fix | Delete
$orderby = "$wpdb->links.link_id";
[274] Fix | Delete
break;
[275] Fix | Delete
default:
[276] Fix | Delete
$orderparams = array();
[277] Fix | Delete
$keys = array( 'link_id', 'link_name', 'link_url', 'link_visible', 'link_rating', 'link_owner', 'link_updated', 'link_notes', 'link_description' );
[278] Fix | Delete
foreach ( explode( ',', $orderby ) as $ordparam ) {
[279] Fix | Delete
$ordparam = trim( $ordparam );
[280] Fix | Delete
[281] Fix | Delete
if ( in_array( 'link_' . $ordparam, $keys, true ) ) {
[282] Fix | Delete
$orderparams[] = 'link_' . $ordparam;
[283] Fix | Delete
} elseif ( in_array( $ordparam, $keys, true ) ) {
[284] Fix | Delete
$orderparams[] = $ordparam;
[285] Fix | Delete
}
[286] Fix | Delete
}
[287] Fix | Delete
$orderby = implode( ',', $orderparams );
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
if ( empty( $orderby ) ) {
[291] Fix | Delete
$orderby = 'link_name';
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
$order = strtoupper( $parsed_args['order'] );
[295] Fix | Delete
if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ), true ) ) {
[296] Fix | Delete
$order = 'ASC';
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
$visible = '';
[300] Fix | Delete
if ( $parsed_args['hide_invisible'] ) {
[301] Fix | Delete
$visible = "AND link_visible = 'Y'";
[302] Fix | Delete
}
[303] Fix | Delete
[304] Fix | Delete
$query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
[305] Fix | Delete
$query .= " $exclusions $inclusions $search";
[306] Fix | Delete
$query .= " ORDER BY $orderby $order";
[307] Fix | Delete
if ( -1 != $parsed_args['limit'] ) {
[308] Fix | Delete
$query .= ' LIMIT ' . absint( $parsed_args['limit'] );
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
$results = $wpdb->get_results( $query );
[312] Fix | Delete
[313] Fix | Delete
if ( 'rand()' !== $orderby ) {
[314] Fix | Delete
$cache[ $key ] = $results;
[315] Fix | Delete
wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
/** This filter is documented in wp-includes/bookmark.php */
[319] Fix | Delete
return apply_filters( 'get_bookmarks', $results, $parsed_args );
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
/**
[323] Fix | Delete
* Sanitizes all bookmark fields.
[324] Fix | Delete
*
[325] Fix | Delete
* @since 2.3.0
[326] Fix | Delete
*
[327] Fix | Delete
* @param stdClass|array $bookmark Bookmark row.
[328] Fix | Delete
* @param string $context Optional. How to filter the fields. Default 'display'.
[329] Fix | Delete
* @return stdClass|array Same type as $bookmark but with fields sanitized.
[330] Fix | Delete
*/
[331] Fix | Delete
function sanitize_bookmark( $bookmark, $context = 'display' ) {
[332] Fix | Delete
$fields = array(
[333] Fix | Delete
'link_id',
[334] Fix | Delete
'link_url',
[335] Fix | Delete
'link_name',
[336] Fix | Delete
'link_image',
[337] Fix | Delete
'link_target',
[338] Fix | Delete
'link_category',
[339] Fix | Delete
'link_description',
[340] Fix | Delete
'link_visible',
[341] Fix | Delete
'link_owner',
[342] Fix | Delete
'link_rating',
[343] Fix | Delete
'link_updated',
[344] Fix | Delete
'link_rel',
[345] Fix | Delete
'link_notes',
[346] Fix | Delete
'link_rss',
[347] Fix | Delete
);
[348] Fix | Delete
[349] Fix | Delete
if ( is_object( $bookmark ) ) {
[350] Fix | Delete
$do_object = true;
[351] Fix | Delete
$link_id = $bookmark->link_id;
[352] Fix | Delete
} else {
[353] Fix | Delete
$do_object = false;
[354] Fix | Delete
$link_id = $bookmark['link_id'];
[355] Fix | Delete
}
[356] Fix | Delete
[357] Fix | Delete
foreach ( $fields as $field ) {
[358] Fix | Delete
if ( $do_object ) {
[359] Fix | Delete
if ( isset( $bookmark->$field ) ) {
[360] Fix | Delete
$bookmark->$field = sanitize_bookmark_field( $field, $bookmark->$field, $link_id, $context );
[361] Fix | Delete
}
[362] Fix | Delete
} else {
[363] Fix | Delete
if ( isset( $bookmark[ $field ] ) ) {
[364] Fix | Delete
$bookmark[ $field ] = sanitize_bookmark_field( $field, $bookmark[ $field ], $link_id, $context );
[365] Fix | Delete
}
[366] Fix | Delete
}
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
return $bookmark;
[370] Fix | Delete
}
[371] Fix | Delete
[372] Fix | Delete
/**
[373] Fix | Delete
* Sanitizes a bookmark field.
[374] Fix | Delete
*
[375] Fix | Delete
* Sanitizes the bookmark fields based on what the field name is. If the field
[376] Fix | Delete
* has a strict value set, then it will be tested for that, else a more generic
[377] Fix | Delete
* filtering is applied. After the more strict filter is applied, if the `$context`
[378] Fix | Delete
* is 'raw' then the value is immediately return.
[379] Fix | Delete
*
[380] Fix | Delete
* Hooks exist for the more generic cases. With the 'edit' context, the {@see 'edit_$field'}
[381] Fix | Delete
* filter will be called and passed the `$value` and `$bookmark_id` respectively.
[382] Fix | Delete
*
[383] Fix | Delete
* With the 'db' context, the {@see 'pre_$field'} filter is called and passed the value.
[384] Fix | Delete
* The 'display' context is the final context and has the `$field` has the filter name
[385] Fix | Delete
* and is passed the `$value`, `$bookmark_id`, and `$context`, respectively.
[386] Fix | Delete
*
[387] Fix | Delete
* @since 2.3.0
[388] Fix | Delete
*
[389] Fix | Delete
* @param string $field The bookmark field.
[390] Fix | Delete
* @param mixed $value The bookmark field value.
[391] Fix | Delete
* @param int $bookmark_id Bookmark ID.
[392] Fix | Delete
* @param string $context How to filter the field value. Accepts 'raw', 'edit', 'attribute',
[393] Fix | Delete
* 'js', 'db', or 'display'
[394] Fix | Delete
* @return mixed The filtered value.
[395] Fix | Delete
*/
[396] Fix | Delete
function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) {
[397] Fix | Delete
switch ( $field ) {
[398] Fix | Delete
case 'link_id': // ints
[399] Fix | Delete
case 'link_rating':
[400] Fix | Delete
$value = (int) $value;
[401] Fix | Delete
break;
[402] Fix | Delete
case 'link_category': // array( ints )
[403] Fix | Delete
$value = array_map( 'absint', (array) $value );
[404] Fix | Delete
// We return here so that the categories aren't filtered.
[405] Fix | Delete
// The 'link_category' filter is for the name of a link category, not an array of a link's link categories.
[406] Fix | Delete
return $value;
[407] Fix | Delete
[408] Fix | Delete
case 'link_visible': // bool stored as Y|N
[409] Fix | Delete
$value = preg_replace( '/[^YNyn]/', '', $value );
[410] Fix | Delete
break;
[411] Fix | Delete
case 'link_target': // "enum"
[412] Fix | Delete
$targets = array( '_top', '_blank' );
[413] Fix | Delete
if ( ! in_array( $value, $targets, true ) ) {
[414] Fix | Delete
$value = '';
[415] Fix | Delete
}
[416] Fix | Delete
break;
[417] Fix | Delete
}
[418] Fix | Delete
[419] Fix | Delete
if ( 'raw' === $context ) {
[420] Fix | Delete
return $value;
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
if ( 'edit' === $context ) {
[424] Fix | Delete
/** This filter is documented in wp-includes/post.php */
[425] Fix | Delete
$value = apply_filters( "edit_{$field}", $value, $bookmark_id );
[426] Fix | Delete
[427] Fix | Delete
if ( 'link_notes' === $field ) {
[428] Fix | Delete
$value = esc_html( $value ); // textarea_escaped
[429] Fix | Delete
} else {
[430] Fix | Delete
$value = esc_attr( $value );
[431] Fix | Delete
}
[432] Fix | Delete
} elseif ( 'db' === $context ) {
[433] Fix | Delete
/** This filter is documented in wp-includes/post.php */
[434] Fix | Delete
$value = apply_filters( "pre_{$field}", $value );
[435] Fix | Delete
} else {
[436] Fix | Delete
/** This filter is documented in wp-includes/post.php */
[437] Fix | Delete
$value = apply_filters( "{$field}", $value, $bookmark_id, $context );
[438] Fix | Delete
[439] Fix | Delete
if ( 'attribute' === $context ) {
[440] Fix | Delete
$value = esc_attr( $value );
[441] Fix | Delete
} elseif ( 'js' === $context ) {
[442] Fix | Delete
$value = esc_js( $value );
[443] Fix | Delete
}
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
return $value;
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* Deletes the bookmark cache.
[451] Fix | Delete
*
[452] Fix | Delete
* @since 2.7.0
[453] Fix | Delete
*
[454] Fix | Delete
* @param int $bookmark_id Bookmark ID.
[455] Fix | Delete
*/
[456] Fix | Delete
function clean_bookmark_cache( $bookmark_id ) {
[457] Fix | Delete
wp_cache_delete( $bookmark_id, 'bookmark' );
[458] Fix | Delete
wp_cache_delete( 'get_bookmarks', 'bookmark' );
[459] Fix | Delete
clean_object_term_cache( $bookmark_id, 'link' );
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function