PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.6.0
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.6.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / classes / Controllers / Frontend.php

Frontend.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More 2.6.0, at classes/Controllers/Frontend.php

90 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Frontend general setup.
4 *
5 * @copyright (c) 2023, Code Atlantic LLC.
6 * @package ContentControl
7 */
8
9 namespace ContentControl\Controllers;
10
11 use ContentControl\Base\Controller;
12
13 use ContentControl\Controllers\Frontend\Blocks;
14 use ContentControl\Controllers\Frontend\Restrictions;
15 use ContentControl\Controllers\Frontend\Widgets;
16
17 defined( 'ABSPATH' ) || exit;
18
19 /**
20 * Class Frontend
21 */
22 class Frontend extends Controller {
23
24 /**
25 * Initialize Hooks & Filters
26 */
27 public function init() {
28 $this->container->register_controllers([
29 'Frontend\Blocks' => new Blocks( $this->container ),
30 'Frontend\Restrictions' => new Restrictions( $this->container ),
31 'Frontend\Widgets' => new Widgets( $this->container ),
32 ]);
33
34 $this->hooks();
35 }
36
37 /**
38 * Register general frontend hooks.
39 *
40 * @return void
41 */
42 public function hooks() {
43 $this->replicate_core_content_filters();
44
45 add_filter( 'content_control/restricted_post_content', '\ContentControl\append_post_excerpts', 9, 2 );
46 add_filter( 'content_control/restricted_post_excerpt', '\ContentControl\append_post_excerpts', 9, 2 );
47 }
48
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 );
88 }
89 }
90