Skip to content

Instantly share code, notes, and snippets.

Julio Potier BoiteAWeb

Block or report user

Report or block BoiteAWeb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@BoiteAWeb
BoiteAWeb / wp_open_body_compatilibity.php
Created Apr 27, 2019
Compatibilité de la fonction wp_open_body() pour tous les thèmes
View wp_open_body_compatilibity.php
add_action( 'get_header', 'baw_wp_body_open_buffer' );
function baw_wp_body_open_buffer() {
ob_start();
do_action( 'wp_body_open' );
$wp_body_open_content = ob_get_clean();
ob_start( function( $buffer ) use( $wp_body_open_content ) {
return preg_replace( '(<body.*>)', "$0\n$wp_body_open_content", $buffer );
} );
}
View add upgrade notice
<?php
if ( ! isset( $remote_version ) ) {
return;
}
$body = get_transient( 'secupress_updates_message' );
if ( ! isset( $body[ $remote_version ] ) ) {
$url = 'https://plugins.svn.wordpress.org/secupress/trunk/readme.txt';
View better changelog
<?php
add_action( 'admin_init', 'secupress_hook_changelog' );
function secupress_hook_changelog() {
if ( isset( $_GET['tab'], $_GET['plugin'], $_GET['section'] )
&& 'secupress' === $_GET['plugin'] && 'changelog' === $_GET['section'] && 'plugin-information' === $_GET['tab'] ) {
remove_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' );
add_action( 'install_plugins_pre_plugin-information', 'secupress_hack_changelog' );
}
}
View _secupress_htmlentities_get.php
<?php
/*
Plugin Name: SecuPress htmlentities $_GET array
Author: SecuPress
Author URI: https://secupress.pro
*/
foreach ( $_GET as &$g ) {
$g = htmlentities( $g, ENT_QUOTES, 'UTF-8' );
}
View gist:050fa23e33510f27543d49435b401f36
<?php
add_shortcode( 'script_foo', 'sc_script_foo_cb' );
function sc_script_foo_cb( $atts, $content ) {
echo '<script type="text/javascript" src="https://example.com/foo.js" />';
}
/*
Then in your content just use [script_foo] (the first parameter from 'add_shortcode')
*/
View gist:29e86b9aeee62c5b0151ed104dfec496
<?php
add_shortcode( 'script_foo', 'sc_script_foo_cb' );
function sc_script_foo_cb( $atts, $content ) {
echo '<script type="text/javascript" src="https://example.com/foo.js" />';
}
/*
Puis dans votre contenu utilisez simplement [script_foo] (le premier paramètre de 'add_shortcode')
*/
View gist:8425920d137dbbc56c47aa3537abb082
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && 'menu-quick-search' == $_POST['action'] ) {
add_filter( 'wp_setup_nav_menu_item', 'sp_wp_setup_nav_menu_item' );
function sp_wp_setup_nav_menu_item( $menu_item ) {
if ( isset( $menu_item->post_title ) ) {
$menu_item->post_title = $menu_item->post_title . ' (' . pll_get_post_language( $menu_item->ID ) . ')';
}
return $menu_item;
}
}
@BoiteAWeb
BoiteAWeb / sp_hide_licence.php
Last active Dec 7, 2017
SecuPress Pro Hide Licence Keys
View sp_hide_licence.php
<?php
/*
Plugin Name: Hide Licence Keys
*/
add_filter( 'secupress.global_settings.modules', 'secupress_hide_licence_keys' );
function secupress_hide_licence_keys( $modules ) {
unset( $modules[0] );
return $modules;
}
@BoiteAWeb
BoiteAWeb / gist:756f6873d6231133fc756095c8295a58
Created May 4, 2017
Patch WordPress Reset Password Vulnerability
View gist:756f6873d6231133fc756095c8295a58
add_filter( 'wp_mail_from', 'baw_fix_wp_474_mail_reset_vulnerability' );
function baw_fix_wp_474_mail_reset_vulnerability( $from_email ) {
return 'wordpress@example.com';
}
View gist:45a425c14adbc807e62d
add_filter( 'embed_site_title_html', 'baw_embed_site_title' );
function baw_embed_site_title( $title ) {
return '<a href="http://wpsolo.fr" target="_top"><img src="/wp-content/uploads/2011/07/iMovie-Logo.png" width="32" height="32" alt="" class="wp-embed-site-icon"><span>MyMovies</span></a>';
}
add_action( 'embed_content', 'baw_embed_content' );
function baw_embed_content() {
echo '<i>Rating</i>: ' . str_repeat( '&bigstar;', 5 );
}
You can’t perform that action at this time.