mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-02 05:31:25 +01:00
Add Additional filters to Press This
3 new filters that aim to improve the extensibility of Press This: 1) `press_this_save_post_content` - Applied right after the side_load_images in order to allow potential side loads of other types of media. Example use case: side load non-image media, such as audio or video. 2) `press_this_useful_html_elements` Allows filtering of currently hard coded array of HTML elements allowed in fetch_source_html step for special cases where additional HTML elements need to be kept. Example use case: HTML5 elements, such as amp-img, that someone wants to pull in. 3) `press_this_suggested_content` A filter for the content right before it's passed to the editor and presented to the user. Example use case is when someone stored posts in a different, non-HTML format, such as Markdown, this is essential. Fixes #34455. Props cadeyrn, kraftbj Built from https://develop.svn.wordpress.org/trunk@36672 git-svn-id: http://core.svn.wordpress.org/trunk@36639 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e4dc3d1232
commit
5c9d92b7f8
@ -91,7 +91,7 @@ class WP_Press_This {
|
||||
}
|
||||
}
|
||||
|
||||
// Edxpected slashed
|
||||
// Expected slashed
|
||||
return wp_slash( $content );
|
||||
}
|
||||
|
||||
@ -133,6 +133,17 @@ class WP_Press_This {
|
||||
|
||||
$post['post_content'] = $this->side_load_images( $post_id, $post['post_content'] );
|
||||
|
||||
/**
|
||||
* Filter the post_content of a Press This post before saving/updating, after
|
||||
* side_load_images action had run.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $content Content after side_load_images process.
|
||||
* @param int $post_id Post ID.
|
||||
*/
|
||||
$post['post_content'] = apply_filters( 'press_this_save_post_content', $post['post_content'], $post_id );
|
||||
|
||||
$updated = wp_update_post( $post, true );
|
||||
|
||||
if ( is_wp_error( $updated ) ) {
|
||||
@ -293,6 +304,15 @@ class WP_Press_This {
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Filter 'useful' HTML elements list for fetch source step.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param array $elements Default list of useful elements.
|
||||
*/
|
||||
$useful_html_elements = apply_filter( 'press_this_useful_html_elements', $useful_html_elements );
|
||||
|
||||
$source_content = wp_remote_retrieve_body( $remote_url );
|
||||
$source_content = wp_kses( $source_content, $useful_html_elements );
|
||||
|
||||
@ -1193,6 +1213,15 @@ class WP_Press_This {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the assembled HTML for the Press This editor.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $content Assembled end output of suggested content for the Press This editor.
|
||||
*/
|
||||
$content = apply_filters( 'press_this_suggested_content', $content );
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.5-alpha-36671';
|
||||
$wp_version = '4.5-alpha-36672';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user