Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../EmbedPre...
File: DisablerLegacy.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace EmbedPress;
[2] Fix | Delete
[3] Fix | Delete
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Entity responsible for replace the WordPress default embed-related shortcodes with the EmbedPress one.
[7] Fix | Delete
*
[8] Fix | Delete
* @package EmbedPress
[9] Fix | Delete
* @author EmbedPress <help@embedpress.com>
[10] Fix | Delete
* @copyright Copyright (C) 2023 WPDeveloper. All rights reserved.
[11] Fix | Delete
* @license GPLv3 or later
[12] Fix | Delete
* @since 1.0.0
[13] Fix | Delete
*/
[14] Fix | Delete
class DisablerLegacy
[15] Fix | Delete
{
[16] Fix | Delete
/**
[17] Fix | Delete
* Method that replaces the embed shortcodes.
[18] Fix | Delete
*
[19] Fix | Delete
* @since 1.0.0
[20] Fix | Delete
*
[21] Fix | Delete
* @return void
[22] Fix | Delete
*/
[23] Fix | Delete
public static function run()
[24] Fix | Delete
{
[25] Fix | Delete
self::disableNativeEmbedHooks();
[26] Fix | Delete
[27] Fix | Delete
Shortcode::register();
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Disable all actions/filters related to the embed. This is required to make sure our "shortcode" overrides the
[32] Fix | Delete
* WordPress one.
[33] Fix | Delete
*
[34] Fix | Delete
* @since 1.0.0
[35] Fix | Delete
* @access protected
[36] Fix | Delete
* @static
[37] Fix | Delete
*
[38] Fix | Delete
* @return void
[39] Fix | Delete
*/
[40] Fix | Delete
protected static function disableNativeEmbedHooks()
[41] Fix | Delete
{
[42] Fix | Delete
global $wp, $wp_embed;
[43] Fix | Delete
[44] Fix | Delete
// Remove the embed query var.
[45] Fix | Delete
$wp->public_query_vars = array_diff($wp->public_query_vars, ["embed"]);
[46] Fix | Delete
[47] Fix | Delete
// Remove the REST API endpoint.
[48] Fix | Delete
remove_action('rest_api_init', 'wp_oembed_register_route');
[49] Fix | Delete
[50] Fix | Delete
// Turn off oEmbed auto discovery.
[51] Fix | Delete
add_filter('embed_oembed_discover', '__return_false');
[52] Fix | Delete
[53] Fix | Delete
// Don't filter oEmbed results.
[54] Fix | Delete
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);
[55] Fix | Delete
[56] Fix | Delete
// Remove oEmbed discovery links.
[57] Fix | Delete
remove_action('wp_head', 'wp_oembed_add_discovery_links');
[58] Fix | Delete
[59] Fix | Delete
// Remove oEmbed-specific JavaScript from the front-end and back-end.
[60] Fix | Delete
remove_action('wp_head', 'wp_oembed_add_host_js');
[61] Fix | Delete
[62] Fix | Delete
// Disable all TinyMCE plugins embed-related.
[63] Fix | Delete
add_filter('tiny_mce_plugins', ['\\EmbedPress\\DisablerLegacy', 'disableDefaultEmbedTinyMCERelatedPlugins']);
[64] Fix | Delete
[65] Fix | Delete
remove_action('rest_api_init', 'wp_oembed_register_route');
[66] Fix | Delete
[67] Fix | Delete
// Remove embed-related scripts from the queue
[68] Fix | Delete
remove_action('embed_head', 'enqueue_embed_scripts');
[69] Fix | Delete
remove_action('embed_head', 'wp_print_head_scripts');
[70] Fix | Delete
[71] Fix | Delete
add_filter('load_default_embeds', false);
[72] Fix | Delete
[73] Fix | Delete
wp_embed_unregister_handler("video");
[74] Fix | Delete
wp_embed_unregister_handler("youtube_embed_url");
[75] Fix | Delete
wp_embed_unregister_handler("googlevideo");
[76] Fix | Delete
[77] Fix | Delete
// Remove all embeds rewrite rules.
[78] Fix | Delete
add_filter('rewrite_rules_array', ['\\EmbedPress\\DisablerLegacy', 'disableDefaultEmbedRewriteRules']);
[79] Fix | Delete
[80] Fix | Delete
// Disable the method that determines if default embed handlers should be loaded.
[81] Fix | Delete
add_filter('wp_maybe_load_embeds', '__return_false');
[82] Fix | Delete
[83] Fix | Delete
// Disable the method that transform any URL from content to {@link WP_Embed::shortcode()}.
[84] Fix | Delete
remove_filter('the_content', [$wp_embed, 'run_shortcode'], 8);
[85] Fix | Delete
remove_filter('the_content', [$wp_embed, 'autoembed'], 8);
[86] Fix | Delete
[87] Fix | Delete
// Remove {@link WP_Embed::shortcode()} from execution.
[88] Fix | Delete
remove_shortcode(EMBEDPRESS_SHORTCODE);
[89] Fix | Delete
[90] Fix | Delete
// Attempts to embed all URLs in a post.
[91] Fix | Delete
add_filter('the_content', ['\\EmbedPress\\Ends\\Front\\Handler', 'autoEmbedUrls']);
[92] Fix | Delete
[93] Fix | Delete
wp_deregister_script('wp-embed');
[94] Fix | Delete
[95] Fix | Delete
add_filter('http_request_host_is_external', ['\\EmbedPress\\CoreLegacy', 'allowApiHost'], 10, 3);
[96] Fix | Delete
[97] Fix | Delete
add_action('tiny_mce_before_init', ['\\EmbedPress\\Ends\\Front\\Handler', 'renderPreviewBoxInEditors']);
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Remove all rewrite rules related to embeds.
[102] Fix | Delete
*
[103] Fix | Delete
* @since 1.0.0
[104] Fix | Delete
* @static
[105] Fix | Delete
*
[106] Fix | Delete
* @param array $rules WordPress rewrite rules.
[107] Fix | Delete
*
[108] Fix | Delete
* @return array
[109] Fix | Delete
*/
[110] Fix | Delete
public static function disableDefaultEmbedRewriteRules($rules)
[111] Fix | Delete
{
[112] Fix | Delete
if (count($rules) > 0) {
[113] Fix | Delete
foreach ($rules as $rule => $rewrite) {
[114] Fix | Delete
if (strpos($rewrite, 'embed=true') !== false) {
[115] Fix | Delete
unset($rules[$rule]);
[116] Fix | Delete
}
[117] Fix | Delete
}
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
return $rules;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Disable all TinyMCE plugins related to the embed.
[125] Fix | Delete
*
[126] Fix | Delete
* @since 1.0.0
[127] Fix | Delete
* @static
[128] Fix | Delete
*
[129] Fix | Delete
* @param array $plugins An array containing enabled plugins.
[130] Fix | Delete
*
[131] Fix | Delete
* @return array
[132] Fix | Delete
*/
[133] Fix | Delete
public static function disableDefaultEmbedTinyMCERelatedPlugins($plugins)
[134] Fix | Delete
{
[135] Fix | Delete
$blackListedPlugins = ["wpembed", "wpview"];
[136] Fix | Delete
[137] Fix | Delete
return array_diff($plugins, $blackListedPlugins);
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function