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 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-disable-embeds.php
admin-site-enhancements / classes Last commit date
class-activation.php 4 months ago class-admin-menu-organizer.php 4 months ago class-admin-menu-svg-icon-mask.php 4 months ago class-auto-publish-posts-with-missed-schedule.php 4 months ago class-avif-upload.php 4 months ago class-captcha-protection.php 4 months ago class-change-login-url.php 4 months ago class-cleanup-admin-bar.php 4 months ago class-common-methods.php 4 months ago class-content-duplication.php 4 months ago class-content-order.php 4 months ago class-custom-admin-footer-text.php 4 months ago class-custom-body-class.php 4 months ago class-custom-css.php 4 months ago class-custom-nav-menu-items-in-new-tab.php 4 months ago class-deactivation.php 4 months ago class-disable-author-archives.php 4 months ago class-disable-comments.php 4 months ago class-disable-dashboard-widgets.php 4 months ago class-disable-embeds.php 4 months ago class-disable-feeds.php 4 months ago class-disable-gutenberg.php 4 months ago class-disable-rest-api.php 4 months ago class-disable-smaller-components.php 4 months ago class-disable-updates.php 4 months ago class-disable-xml-rpc.php 4 months ago class-display-system-summary.php 4 months ago class-email-address-obfuscator.php 4 months ago class-email-delivery.php 4 months ago class-enhance-list-tables.php 4 months ago class-external-permalinks.php 4 months ago class-heartbeat-control.php 4 months ago class-hide-admin-bar.php 4 months ago class-hide-admin-notices.php 4 months ago class-image-sizes-panel.php 4 months ago class-image-upload-control.php 4 months ago class-insert-head-body-footer-code.php 4 months ago class-last-login-column.php 4 months ago class-limit-login-attempts.php 4 months ago class-login-id-type.php 4 months ago class-login-logout-menu.php 4 months ago class-maintenance-mode.php 4 months ago class-manage-ads-appads-txt.php 4 months ago class-manage-robots-txt.php 4 months ago class-media-files-visibility-control.php 4 months ago class-media-replacement.php 4 months ago class-multiple-user-roles.php 4 months ago class-obfuscate-author-slugs.php 4 months ago class-open-external-links-in-new-tab.php 4 months ago class-password-protection.php 4 months ago class-redirect-after-login.php 4 months ago class-redirect-after-logout.php 4 months ago class-redirect-fourofour.php 4 months ago class-registration-date-column.php 4 months ago class-revisions-control.php 4 months ago class-search-engines-visibility.php 4 months ago class-settings-fields-render.php 4 months ago class-settings-sanitization.php 4 months ago class-settings-sections-fields.php 4 months ago class-show-custom-taxonomy-filters.php 4 months ago class-site-identity-on-login-page.php 4 months ago class-svg-upload.php 4 months ago class-various-admin-ui-enhancements.php 4 months ago class-view-admin-as-role.php 4 months ago class-wider-admin-menu.php 4 months ago class-wp-config-transformer.php 4 months ago
class-disable-embeds.php
171 lines
1 <?php
2
3 namespace ASENHA\Classes;
4
5 /**
6 * Class for Disable Embeds module.
7 * Ported from the Disable Embeds plugin v1.5.0 by Pascal Birchler
8 * @link https://wordpress.org/plugins/disable-embeds/
9 *
10 * @since 8.0.0
11 */
12 class Disable_Embeds {
13
14 /**
15 * Disable embeds on init.
16 *
17 * - Removes the needed query vars.
18 * - Disables oEmbed discovery.
19 * - Completely removes the related JavaScript.
20 * - Disables the core-embed/wordpress block type (WordPress 5.0+)
21 *
22 * @link https://plugins.trac.wordpress.org/browser/disable-embeds/tags/1.5.0/disable-embeds.php#L23
23 * @since 8.0.0
24 */
25 public function disable_embeds_init() {
26 /* @var WP $wp */
27 global $wp;
28
29 // Remove the embed query var.
30 $wp->public_query_vars = array_diff( $wp->public_query_vars, array(
31 'embed',
32 ) );
33
34 // Remove the oembed/1.0/embed REST route.
35 add_filter( 'rest_endpoints', [ $this, 'disable_embeds_remove_embed_endpoint'] );
36
37 // Disable handling of internal embeds in oembed/1.0/proxy REST route.
38 add_filter( 'oembed_response_data', [ $this, 'disable_embeds_filter_oembed_response_data' ] );
39
40 // Turn off oEmbed auto discovery.
41 add_filter( 'embed_oembed_discover', '__return_false' );
42
43 // Don't filter oEmbed results.
44 remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
45
46 // Remove oEmbed discovery links.
47 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
48
49 // Remove oEmbed-specific JavaScript from the front-end and back-end.
50 remove_action( 'wp_head', 'wp_oembed_add_host_js' );
51 add_filter( 'tiny_mce_plugins', [ $this, 'disable_embeds_tiny_mce_plugin' ] );
52
53 // Remove all embeds rewrite rules.
54 add_filter( 'rewrite_rules_array', [ $this, 'disable_embeds_rewrites' ] );
55
56 // Remove filter of the oEmbed result before any HTTP requests are made.
57 remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
58
59 // Load block editor JavaScript.
60 add_action( 'enqueue_block_editor_assets', [ $this, 'disable_embeds_enqueue_block_editor_assets' ] );
61
62 // Remove wp-embed dependency of wp-edit-post script handle.
63 add_action( 'wp_default_scripts', [ $this, 'disable_embeds_remove_script_dependencies' ] );
64 }
65
66 /**
67 * Removes the oembed/1.0/embed REST route.
68 *
69 * @link https://plugins.trac.wordpress.org/browser/disable-embeds/tags/1.5.0/disable-embeds.php#L128
70 * @since 8.0.0
71 *
72 * @param array $endpoints Registered REST API endpoints.
73 * @return array Filtered REST API endpoints.
74 */
75 public function disable_embeds_remove_embed_endpoint( $endpoints ) {
76 unset( $endpoints['/oembed/1.0/embed'] );
77
78 return $endpoints;
79 }
80
81 /**
82 * Disables sending internal oEmbed response data in proxy endpoint.
83 *
84 * @link https://plugins.trac.wordpress.org/browser/disable-embeds/tags/1.5.0/disable-embeds.php#L142
85 * @since 8.0.0
86 *
87 * @param array $data The response data.
88 * @return array|false Response data or false if in a REST API context.
89 */
90 public function disable_embeds_filter_oembed_response_data( $data ) {
91 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
92 return false;
93 }
94
95 return $data;
96 }
97
98 /**
99 * Removes the 'wpembed' TinyMCE plugin.
100 *
101 * @link https://plugins.trac.wordpress.org/browser/disable-embeds/tags/1.5.0/disable-embeds.php#L74
102 * @since 8.0.0
103 *
104 * @param array $plugins List of TinyMCE plugins.
105 * @return array The modified list.
106 */
107 public function disable_embeds_tiny_mce_plugin( $plugins ) {
108 return array_diff( $plugins, array( 'wpembed' ) );
109 }
110
111 /**
112 * Remove all rewrite rules related to embeds.
113 *
114 * @link https://plugins.trac.wordpress.org/browser/disable-embeds/tags/1.5.0/disable-embeds.php#L86
115 * @since 8.0.0
116 *
117 * @param array $rules WordPress rewrite rules.
118 * @return array Rewrite rules without embeds rules.
119 */
120 public function disable_embeds_rewrites( $rules ) {
121 foreach ( $rules as $rule => $rewrite ) {
122 if ( false !== strpos( $rewrite, 'embed=true' ) ) {
123 unset( $rules[ $rule ] );
124 }
125 }
126
127 return $rules;
128 }
129
130 /**
131 * Enqueues JavaScript for the block editor.
132 *
133 * @link https://plugins.trac.wordpress.org/browser/disable-embeds/tags/1.5.0/disable-embeds.php#L157
134 * @since 8.0.0
135 *
136 * This is used to unregister the `core-embed/wordpress` block type.
137 */
138 public function disable_embeds_enqueue_block_editor_assets() {
139 $asset_file = ASENHA_PATH . 'includes/disable-embeds/build/index.asset.php';
140
141 $asset = is_readable( $asset_file ) ? require $asset_file : [];
142
143 $asset['dependencies'] = isset( $asset['dependencies'] ) ? $asset['dependencies'] : [];
144 $asset['version'] = isset( $asset['version'] ) ? $asset['version'] : '';
145
146 wp_enqueue_script(
147 'disable-embeds',
148 plugins_url( 'includes/disable-embeds/build/index.js', __DIR__ ),
149 $asset['dependencies'],
150 $asset['version'],
151 true
152 );
153 }
154
155 /**
156 * Removes wp-embed dependency of core packages.
157 *
158 * @link https://plugins.trac.wordpress.org/browser/disable-embeds/tags/1.5.0/disable-embeds.php#L180
159 * @since 8.0.0
160 *
161 * @param WP_Scripts $scripts WP_Scripts instance, passed by reference.
162 */
163 public function disable_embeds_remove_script_dependencies( $scripts ) {
164 if ( ! empty( $scripts->registered['wp-edit-post'] ) ) {
165 $scripts->registered['wp-edit-post']->deps = array_diff(
166 $scripts->registered['wp-edit-post']->deps,
167 array( 'wp-embed' )
168 );
169 }
170 }
171 }