| @@ -39,11 +39,51 @@ | ||
| 39 | 39 | * |
| 40 | 40 | * @return void |
| 41 | 41 | */ |
| 42 | 42 | public function hooks() { |
| 43 | + $this->replicate_core_content_filters(); | |
| 44 | + | |
| 43 | 45 | add_filter( 'content_control/restricted_post_content', '\ContentControl\append_post_excerpts', 9, 2 ); |
| 44 | - add_filter( 'content_control/restricted_post_content', '\ContentControl\the_content_filters', 10 ); | |
| 46 | + add_filter( 'content_control/restricted_post_excerpt', '\ContentControl\append_post_excerpts', 9, 2 ); | |
| 47 | + } | |
| 45 | 48 | |
| 46 | - add_filter( 'content_control/restricted_post_excerpt', '\ContentControl\append_post_excerpts', 9, 2 ); | |
| 47 | - add_filter( 'content_control/restricted_post_excerpt', '\ContentControl\the_excerpt_filters', 10 ); | |
| 49 | + /** | |
| 50 | + * Replicate core content filters. | |
| 51 | + * | |
| 52 | + * @return void | |
| 53 | + */ | |
| 54 | + private function replicate_core_content_filters() { | |
| 55 | + /** | |
| 56 | + * Instance of WP_Embed class. | |
| 57 | + * | |
| 58 | + * @var \WP_Embed $wp_embed | |
| 59 | + */ | |
| 60 | + global $wp_embed; | |
| 61 | + | |
| 62 | + $the_content = 'content_control/restricted_post_content'; | |
| 63 | + $the_excerpt = 'content_control/restricted_post_excerpt'; | |
| 64 | + | |
| 65 | + // These all follow WP core's `the_content` filter. | |
| 66 | + add_filter( $the_content, 'do_blocks', 9 ); | |
| 67 | + add_filter( $the_content, 'wptexturize' ); | |
| 68 | + add_filter( $the_content, 'convert_smilies', 20 ); | |
| 69 | + add_filter( $the_content, 'wpautop' ); | |
| 70 | + add_filter( $the_content, 'shortcode_unautop' ); | |
| 71 | + add_filter( $the_content, 'prepend_attachment' ); | |
| 72 | + add_filter( $the_content, 'wp_replace_insecure_home_url' ); | |
| 73 | + add_filter( $the_content, 'do_shortcode', 11 ); // AFTER wpautop(). | |
| 74 | + add_filter( $the_content, 'wp_filter_content_tags', 12 ); // Runs after do_shortcode(). | |
| 75 | + add_filter( $the_content, 'capital_P_dangit', 11 ); | |
| 76 | + add_filter( $the_content, [ $wp_embed, 'run_shortcode' ], 8 ); | |
| 77 | + add_filter( $the_content, [ $wp_embed, 'autoembed' ], 8 ); | |
| 78 | + | |
| 79 | + // These all follow WP core's `the_excerpt` filter. | |
| 80 | + add_filter( $the_excerpt, 'wptexturize' ); | |
| 81 | + add_filter( $the_excerpt, 'convert_smilies' ); | |
| 82 | + add_filter( $the_excerpt, 'convert_chars' ); | |
| 83 | + add_filter( $the_excerpt, 'wpautop' ); | |
| 84 | + add_filter( $the_excerpt, 'shortcode_unautop' ); | |
| 85 | + add_filter( $the_excerpt, 'wp_replace_insecure_home_url' ); | |
| 86 | + add_filter( $the_excerpt, 'wp_filter_content_tags', 12 ); | |
| 87 | + add_filter( $the_excerpt, 'capital_P_dangit', 11 ); | |
| 48 | 88 | } |
| 49 | 89 | } |