Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -9,10 +9,10 @@
|
|||
class WP_Embed {
|
||||
public $handlers = array();
|
||||
public $post_ID;
|
||||
public $usecache = true;
|
||||
public $usecache = true;
|
||||
public $linkifunknown = true;
|
||||
public $last_attr = array();
|
||||
public $last_url = '';
|
||||
public $last_attr = array();
|
||||
public $last_url = '';
|
||||
|
||||
/**
|
||||
* When a URL cannot be embedded, return false instead of returning a link
|
||||
|
@ -81,16 +81,17 @@ class WP_Embed {
|
|||
public function maybe_run_ajax_cache() {
|
||||
$post = get_post();
|
||||
|
||||
if ( ! $post || empty( $_GET['message'] ) )
|
||||
if ( ! $post || empty( $_GET['message'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post->ID, 'relative' ); ?>");
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,7 +107,7 @@ class WP_Embed {
|
|||
* @param int $priority Optional. Used to specify the order in which the registered handlers will be tested (default: 10). Lower numbers correspond with earlier testing, and handlers with the same priority are tested in the order in which they were added to the action.
|
||||
*/
|
||||
public function register_handler( $id, $regex, $callback, $priority = 10 ) {
|
||||
$this->handlers[$priority][$id] = array(
|
||||
$this->handlers[ $priority ][ $id ] = array(
|
||||
'regex' => $regex,
|
||||
'callback' => $callback,
|
||||
);
|
||||
|
@ -156,7 +157,7 @@ class WP_Embed {
|
|||
}
|
||||
|
||||
$rawattr = $attr;
|
||||
$attr = wp_parse_args( $attr, wp_embed_defaults( $url ) );
|
||||
$attr = wp_parse_args( $attr, wp_embed_defaults( $url ) );
|
||||
|
||||
$this->last_attr = $attr;
|
||||
|
||||
|
@ -169,7 +170,7 @@ class WP_Embed {
|
|||
foreach ( $this->handlers as $priority => $handlers ) {
|
||||
foreach ( $handlers as $id => $handler ) {
|
||||
if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
|
||||
if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) )
|
||||
if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) {
|
||||
/**
|
||||
* Filters the returned embed handler.
|
||||
*
|
||||
|
@ -182,6 +183,7 @@ class WP_Embed {
|
|||
* @param array $attr An array of shortcode attributes.
|
||||
*/
|
||||
return apply_filters( 'embed_handler_html', $return, $url, $attr );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +218,7 @@ class WP_Embed {
|
|||
$cached_post_id = $this->find_oembed_post_id( $key_suffix );
|
||||
|
||||
if ( $post_ID ) {
|
||||
$cache = get_post_meta( $post_ID, $cachekey, true );
|
||||
$cache = get_post_meta( $post_ID, $cachekey, true );
|
||||
$cache_time = get_post_meta( $post_ID, $cachekey_time, true );
|
||||
|
||||
if ( ! $cache_time ) {
|
||||
|
@ -285,32 +287,44 @@ class WP_Embed {
|
|||
}
|
||||
|
||||
$insert_post_args = array(
|
||||
'post_name' => $key_suffix,
|
||||
'post_name' => $key_suffix,
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'oembed_cache',
|
||||
'post_type' => 'oembed_cache',
|
||||
);
|
||||
|
||||
if ( $html ) {
|
||||
if ( $cached_post_id ) {
|
||||
wp_update_post( wp_slash( array(
|
||||
'ID' => $cached_post_id,
|
||||
'post_content' => $html,
|
||||
) ) );
|
||||
} else {
|
||||
wp_insert_post( wp_slash( array_merge(
|
||||
$insert_post_args,
|
||||
array(
|
||||
'post_content' => $html,
|
||||
wp_update_post(
|
||||
wp_slash(
|
||||
array(
|
||||
'ID' => $cached_post_id,
|
||||
'post_content' => $html,
|
||||
)
|
||||
)
|
||||
) ) );
|
||||
);
|
||||
} else {
|
||||
wp_insert_post(
|
||||
wp_slash(
|
||||
array_merge(
|
||||
$insert_post_args,
|
||||
array(
|
||||
'post_content' => $html,
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
} elseif ( ! $cache ) {
|
||||
wp_insert_post( wp_slash( array_merge(
|
||||
$insert_post_args,
|
||||
array(
|
||||
'post_content' => '{{unknown}}',
|
||||
wp_insert_post(
|
||||
wp_slash(
|
||||
array_merge(
|
||||
$insert_post_args,
|
||||
array(
|
||||
'post_content' => '{{unknown}}',
|
||||
)
|
||||
)
|
||||
)
|
||||
) ) );
|
||||
);
|
||||
}
|
||||
|
||||
if ( $has_kses ) {
|
||||
|
@ -335,12 +349,14 @@ class WP_Embed {
|
|||
*/
|
||||
public function delete_oembed_caches( $post_ID ) {
|
||||
$post_metas = get_post_custom_keys( $post_ID );
|
||||
if ( empty($post_metas) )
|
||||
if ( empty( $post_metas ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $post_metas as $post_meta_key ) {
|
||||
if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) )
|
||||
if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) ) {
|
||||
delete_post_meta( $post_ID, $post_meta_key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,15 +374,15 @@ class WP_Embed {
|
|||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param array $post_types Array of post types to cache oEmbed results for. Defaults to post types with `show_ui` set to true.
|
||||
* @param string[] $post_types Array of post type names to cache oEmbed results for. Defaults to post types with `show_ui` set to true.
|
||||
*/
|
||||
if ( empty( $post->ID ) || ! in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', $post_types ) ) ){
|
||||
if ( empty( $post->ID ) || ! in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', $post_types ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Trigger a caching
|
||||
if ( ! empty( $post->post_content ) ) {
|
||||
$this->post_ID = $post->ID;
|
||||
$this->post_ID = $post->ID;
|
||||
$this->usecache = false;
|
||||
|
||||
$content = $this->run_shortcode( $post->post_content );
|
||||
|
@ -406,9 +422,9 @@ class WP_Embed {
|
|||
* @return string The embed HTML on success, otherwise the original URL.
|
||||
*/
|
||||
public function autoembed_callback( $match ) {
|
||||
$oldval = $this->linkifunknown;
|
||||
$oldval = $this->linkifunknown;
|
||||
$this->linkifunknown = false;
|
||||
$return = $this->shortcode( array(), $match[2] );
|
||||
$return = $this->shortcode( array(), $match[2] );
|
||||
$this->linkifunknown = $oldval;
|
||||
|
||||
return $match[1] . $return . $match[3];
|
||||
|
@ -425,7 +441,7 @@ class WP_Embed {
|
|||
return false;
|
||||
}
|
||||
|
||||
$output = ( $this->linkifunknown ) ? '<a href="' . esc_url($url) . '">' . esc_html($url) . '</a>' : $url;
|
||||
$output = ( $this->linkifunknown ) ? '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>' : $url;
|
||||
|
||||
/**
|
||||
* Filters the returned, maybe-linked embed URL.
|
||||
|
@ -454,17 +470,19 @@ class WP_Embed {
|
|||
return $oembed_post_id;
|
||||
}
|
||||
|
||||
$oembed_post_query = new WP_Query( array(
|
||||
'post_type' => 'oembed_cache',
|
||||
'post_status' => 'publish',
|
||||
'name' => $cache_key,
|
||||
'posts_per_page' => 1,
|
||||
'no_found_rows' => true,
|
||||
'cache_results' => true,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
'lazy_load_term_meta' => false,
|
||||
) );
|
||||
$oembed_post_query = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'oembed_cache',
|
||||
'post_status' => 'publish',
|
||||
'name' => $cache_key,
|
||||
'posts_per_page' => 1,
|
||||
'no_found_rows' => true,
|
||||
'cache_results' => true,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
'lazy_load_term_meta' => false,
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $oembed_post_query->posts ) ) {
|
||||
// Note: 'fields'=>'ids' is not being used in order to cache the post object as it will be needed.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue