Skip to content

Instantly share code, notes, and snippets.

Avatar

Julio Potier JulioPotier

View GitHub Profile
View gist:5ccf7f11549a4e0f4aaa
<?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+
*
*/
View gist:516294870ac38028fcce
<?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+
*
*/
View gist:e03703d3f4d2e6d1ab6d
<?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+
*
*/
View gist:5c5197e0d18bcb7debe1
<?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+
*
*/
View gist:96340d7753de1dbb1b38
<?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+
*
*/
View gist:63c589de8c81cea284e1
// 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;
}
View gist:7e6c24d2bcb7b250a5ca
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 );
}
View gist:0cc73e5fc691783c0dcb
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 );
View gist:c1837ab497ab24faadb0
<?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';