Skip to content

Instantly share code, notes, and snippets.

View thierrypigot's full-sized avatar

Thierry Pigot thierrypigot

View GitHub Profile
@thierrypigot
thierrypigot / tp-tinymce-style.php
Last active August 29, 2015 14:18
Custom TinyMCE style in list
<?php
// Ajout du menu de selection STYLES
// http://codex.wordpress.org/TinyMCE_Custom_Styles
function tp_mce_buttons_2( $buttons ) {
array_splice( $buttons, 1, 0, 'styleselect' );
return $buttons;
}
// Register our callback to the appropriate filter
add_filter('mce_buttons_2', 'tp_mce_buttons_2');
@thierrypigot
thierrypigot / tp-shortcode-antispam.php
Created April 7, 2015 18:29
WordPress Email Antispam Shortcode
<?php
/**
* Anti Spam Email
* [email]contact@thierry-pigot.fr[/email]
**/
function tp_antispam_email_shortcode( $atts , $content = null )
{
if ( ! is_email( $content ) ) {
return;
}
@thierrypigot
thierrypigot / tp_shortcode_children.php
Created April 7, 2015 18:31
List all children of current item (page, custom post type ...) #WordPress
<?php
/**
* Shortcode Custom post type children as list
* Thierry Pigot
* 2015-04-07
*
* [children id='ID' nb='-1' type='page' depth='1']
**/
function tp_shortcode_children( $atts )
{
@thierrypigot
thierrypigot / cookieExpiration.php
Created April 21, 2015 13:14
Changer le timeout de connexion WordPress.
<?php
/**
* Filter the duration of the authentication cookie expiration period.
*
* @since 2.8.0
*
* @param int $length Duration of the expiration period in seconds.
* @param int $user_id User ID.
* @param bool $remember Whether to remember the user login. Default false.
*/
@thierrypigot
thierrypigot / hide-acf.php
Created April 27, 2015 13:23
Masquer ACF dans WordPress
<?php
define( 'ACF_LITE' , true );
@thierrypigot
thierrypigot / tp-tinymce-style-formats.php
Created April 27, 2015 15:44
Ajouter une liste déroulante dans TinyMCE avec des styles ou balises personnalisés.
<?php
add_action( 'after_setup_theme', 'tp_after_setup_theme' );
function tp_after_setup_theme()
{
add_editor_style();
}
add_filter('mce_buttons_2', 'tp_mce_buttons_2');
function tp_mce_buttons_2($buttons)
{
@thierrypigot
thierrypigot / tp-custom-title-placeholder.php
Last active August 29, 2015 14:20
Changer le placeholder du chanp titre, en fonction du Custom Post Type
<?php
/**
* Change le titre par défaut
**/
function tp_custom_title_placeholder( $title )
{
$screen = get_current_screen();
switch( $screen->post_type )
{
case 'FAQ':
@thierrypigot
thierrypigot / wp-config.php
Created May 4, 2015 16:24
Limit plugin/theme edits and installations
<?php
/**
* remove the ability for users to install or edit themes or plugins,
* you can use the following definitions to take care of that.
* The first will disable the editors, but still allow installations
* and updates of themes/plugins, whereas the second definition will disable all of these functions
*
**/
define('DISALLOW_FILE_EDIT',true);
@thierrypigot
thierrypigot / bcpj_query_exclude_offre_id.php
Created May 19, 2015 17:42
ACF : Exclude current post/page/cpt from relationship field results
<?php
/**
* Exclude current post/page/cpt from relationship field results
*/
add_filter('acf/fields/relationship/query/name=NAME-OF-THE-FIELD', 'bcpj_query_exclude_offre_id', 10, 3);
function bcpj_query_exclude_offre_id( $options, $field, $the_post )
{
if( is_admin() )
{
$options['post__not_in'] = array( $the_post->ID );
@thierrypigot
thierrypigot / .htaccess
Created May 28, 2015 08:08
.htaccess : Redirection permanente – Changement de domaine
RewriteCond %{HTTP_HOST} ^(www\.campus\.ccip\.fr)(:80)? [NC]
RewriteRule ^(.*) http://www.campus.cci-paris-idf.fr/$1 [R=301,L]