Skip to content

Instantly share code, notes, and snippets.

Avatar

Julio Potier JulioPotier

View GitHub Profile
View gist:2714688
<?php
/*
* Plugin Name: Password Reset Removed
* Description: Removes the ability for non admin users to change/reset their passwords.
* Version: 1.1
* Author: Derek Herman ; Modified by Juliobox (boiteaweb.fr)
* Author URI: http://valendesigns.com
*/
add_filter( 'show_password_fields', 'baw_prr_i_am_admin' );
add_filter( 'allow_password_reset', 'baw_prr_i_am_admin' );
View plugin_multi_authors.php
add_filter( 'plugin_row_meta', 'pastacode_plugin_row_meta', 10, 2 );
function pastacode_plugin_row_meta( $plugin_meta, $plugin_file )
{
if( plugin_basename( __FILE__ ) == $plugin_file ){
$last = end( $plugin_meta );
$plugin_meta = array_slice( $plugin_meta, 0, -2 );
$a = array();
$authors = array(
array( 'name'=>'Willy Bahaud', 'url'=>'http://www.wabeo.fr' ),
array( 'name'=>'Julio Potier', 'url'=>'http://www.boiteaweb.fr' ),
View add_meta_box.php
add_action( 'add_meta_boxes', 'add_my_box' );
function add_my_box() {
add_meta_box( 'mybox', 'My Box !', '_add_my_box', get_post_type() );
}
function _add_my_box() {
echo 'Ma boite :)';
}
View Action sur une page
add_action( 'wp_head', 'page_into_contact_form' );
function page_into_contact_form(){
if( is_main_query() && is_page( get_option( 'contact_page_id' ) ){
add_filter( 'the_content', 'content_into_contact_form' );
}
}
function content_into_contact_form( $content ){
// $content est le contenu par défaut de l'article
if( $GLOBALS['post']->ID == get_option( 'contact_page_id' ) ){
View Action sur une page
function content_into_contact_form( $content ){
if( $GLOBALS['post']->ID == get_option( 'contact_page_id' ) ){
$content = '[contact-form-7 id="2" title="Contact form 1"]';
}
return $content;
}
View Action sur une page
function page_into_contact_form(){
if( is_main_query() && is_page( get_option( 'contact_page_id' ) ){
add_filter( 'the_content', 'content_into_contact_form' );
}
}
View option_ demo
<?php
/*
Plugin Name: Do not load this plugins
Description: Do not load this plugins on wp-login.php page
Author: Julio Potier
*/
add_action( 'muplugins_loaded', 'pre_baw_do_not_load_this_plugin' );
function pre_baw_do_not_load_this_plugin() {
if( '/wp-login.php' == $_SERVER['SCRIPT_NAME'] ) {
View Force options
<?php
/*
Plugin Name: Forcer des valeurs absolues par sécurité
Author: Julio Potier
AuthorURI: http://boiteaweb.fr
*/
// Forcer l'adresse email admin
add_filter( 'option_admin_email', '_option_admin_email' );
function _option_admin_email( $value ) {
View pre_option_
add_filter( 'pre_option_image_default_align', '__image_default_align' );
function __image_default_align() {
return 'left';
}
add_filter( 'pre_option_image_default_link_type', '__image_default_link_type' );
function __image_default_link_type() {
return 'none';
}