Skip to content

Instantly share code, notes, and snippets.

View JulioPotier's full-sized avatar

Julio Potier JulioPotier

View GitHub Profile
<?php
/**
* Plugin Name: Disable Embeds posts for me
* Description: Don't want to fetch external emebed posts?
* Version: 1.0
* Author: Julio Potier
* Author URI: https://wp-rocket.me
* License: GPLv2+
*
*/
<?php
/**
* Plugin Name: Disable Thumbnails Embeds
* Description: Don't like the thumbnails embed?
* Version: 1.0
* Author: Julio Potier
* Author URI: https://wp-rocket.me
* License: GPLv2+
*
*/
<?php
/**
* Plugin Name: Empty Embeds cache
* Description: You already read it
* Version: 1.0
* Author: Julio Potier
* Author URI: https://wp-rocket.me
* License: GPLv2+
*
*/
<?php
/**
* Plugin Name: Disable Embeds for others
* Description: Don't want people can embed your posts?
* Version: 1.0
* Author: Julio Potier
* Author URI: https://wp-rocket.me
* License: GPLv2+
*
*/
<?php
/**
* Plugin Name: Disable Embeds Cache
* Description: Don't like the 1 day embed cache?
* Version: 1.0
* Author: Julio Potier
* Author URI: https://wp-rocket.me
* License: GPLv2+
*
*/
// MY_PLUGIN_FOLDER est une constante imaginaire correspondant au dossier de votre plugin qui contient ce template
add_filter( 'template_include', 'my_plugin_embed_template_include' );
function my_plugin_embed_template_include( $template ) {
if ( basename( $template ) == 'embed-template.php' ) {
return MY_PLUGIN_FOLDER . '/embed-template.php';
}
return $template;
}
add_action( 'embed_content_meta', 'the_date' );
add_filter( 'get_comment_text', 'add_post_oembed_comment_support', 0 );
function add_post_oembed_comment_support( $comment_text ) {
return $GLOBALS['wp_embed']->autoembed( $comment_text );
}
add_filter( 'get_comment_text', 'add_post_oembed_comment_support', 0 );
function add_post_oembed_comment_support( $comment_text ) {
if ( ! class_exists( 'WP_oEmbed' ) ) {
include( ABSPATH . WPINC . '/class-oembed.php' );
}
$WP_oEmbed = new WP_oEmbed();
if ( $WP_oEmbed->get_provider( $comment_text, array( 'discover' => false ) ) ) {
return $comment_text;
}
return $GLOBALS['wp_embed']->autoembed( $comment_text );
<?php
add_action( 'after_setup_theme', 'my_square_size' );
function my_square_size() {
add_image_size( 'square', 320, 320, true );
}
add_filter( 'embed_thumbnail_image_size', '__return_square' );
add_filter( 'embed_thumbnail_image_shape', '__return_square' );
function __return_square() {
return 'square';