View gist:02c7fa67268bce7724937472c187383b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'mepr-validate-login', 'secupress_support_11052021_no_admins' ); | |
function secupress_support_11052021_no_admins( $errors ) { | |
if ( ! isset( $_SERVER['REQUEST_METHOD'], $_POST['log'] ) || 'POST' !== $_SERVER['REQUEST_METHOD'] ) { | |
return $errors; | |
} | |
// Check for login by email address | |
$by = is_email( $_POST['log'] ) ? 'email' : 'login'; |
View gist:5238fd962059ddf590dfefca72e02434
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function human_filesize( $bytes, $decimals = 2 ) { | |
$sz = 'BKMGTP'; | |
$factor = floor( ( strlen( $bytes ) - 1 ) / 3 ); | |
return sprintf( "%.{$decimals}f", $bytes / pow( 1024, $factor ) ) . @$sz[ $factor ]; | |
} | |
add_filter( 'media_send_to_editor', 'baw_media_to_shortcode', 10, 3 ); | |
function baw_media_to_shortcode( $html, $id, $attachment ) { | |
$media_type = strtolower( pathinfo( $attachment['url'], PATHINFO_EXTENSION ) ); | |
switch ( $media_type ) { |
View wp_open_body_compatilibity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
View sp_hide_licence.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
NewerOlder