Search
 
SCRIPT & CODE EXAMPLE
 

PHP

WordPress oEmbed Funktion abschalten

<?php
/**
 * Disable embeds on init.

 *
 * - Removes the needed query vars.

 * - Disables oEmbed discovery.

 * - Completely removes the related JavaScript.

 *
 * @since 1.0.0
 */
function evolution_disable_embeds_init() {
    /* @var WP $wp */
    global $wp;
    // Remove the embed query var.

    $wp->public_query_vars = array_diff( $wp->public_query_vars, array(
        'embed',
    ) );
    // Remove the REST API endpoint.

    remove_action( 'rest_api_init', 'wp_oembed_register_route' );
    // Turn off oEmbed auto discovery.

    add_filter( 'embed_oembed_discover', '__return_false' );
    // Don't filter oEmbed results.

    remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
    // Remove oEmbed discovery links.

    remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
    // Remove oEmbed-specific JavaScript from the front-end and back-end.

    remove_action( 'wp_head', 'wp_oembed_add_host_js' );
    add_filter( 'tiny_mce_plugins', 'evolution_disable_embeds_tiny_mce_plugin' );
    // Remove all embeds rewrite rules.

    add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
    // Remove filter of the oEmbed result before any HTTP requests are made.

    remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
}
add_action( 'init', 'evolution_disable_embeds_init', 9999 );
/**
 * Removes the 'wpembed' TinyMCE plugin.

 *
 * @since 1.0.0
 *
 * @param array $plugins List of TinyMCE plugins.

 * @return array The modified list.

 */
function evolution_disable_embeds_tiny_mce_plugin( $plugins ) {
    return array_diff( $plugins, array( 'wpembed' ) );
}
/**
 * Remove all rewrite rules related to embeds.

 *
 * @since 1.0.0
 *
 * @param array $rules WordPress rewrite rules.

 * @return array Rewrite rules without embeds rules.

 */
function evolution_disable_embeds_rewrites( $rules ) {
    foreach ( $rules as $rule => $rewrite ) {
        if ( false !== strpos( $rewrite, 'embed=true' ) ) {
            unset( $rules[ $rule ] );
        }
    }
    return $rules;
}
/**
 * Remove embeds rewrite rules on plugin activation.

 *
 * @since 1.0.0
 */
function evolution_disable_embeds_remove_rewrite_rules() {
    add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
    flush_rewrite_rules( false );
}
register_activation_hook( __FILE__, 'evolution_disable_embeds_remove_rewrite_rules' );
/**
 * Flush rewrite rules on plugin deactivation.

 *
 * @since 1.0.0
 */
function evolution_disable_embeds_flush_rewrite_rules() {
    remove_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
    flush_rewrite_rules( false );
}
register_deactivation_hook( __FILE__, 'evolution_disable_embeds_flush_rewrite_rules' );
Comment

PREVIOUS NEXT
Code Example
Php :: base64 encode php check 
Php :: HASHING in php double scripting 
Php :: php tasks 
Php :: image upload in cake 2 
Php :: drupal 9 custom access checking for routes 
Php :: wp automatic-feed-links 
Php :: BelongsToMany relations pivot fields are null in Livewire refresh 
Php :: Maintenace Mode Up using cron 
Php :: how to make login and logout to blog with php without database or MySQL 
Php :: how to pass javascript variable to php 
Php :: keep track of view count php 
Php :: php artisan spark not working in codeigniter 
Php :: php array_intersect_assoc 
Php :: doctrine findby regex 
Php :: how to access the name of menu in worpress 
Php :: laravel view-model 
Php :: is_wplogin 
Php :: laravel child relation get max value 
Php :: how to clear post array on referesh + not refill when return 
Php :: php delete acc 
Php :: run drush command from php 
Php :: Autoriser les contributeurs à télécharger des images 
Php :: php move uploaded file 
Php :: laravel file permission denied 
Php :: how to push associative array in php 
Php :: my xampp 
Php :: function with parament php 
Php :: php class comment 
Java :: basic hello world program in java 
Java :: android get screen width and height 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =