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 / tp-tinymce-background-color.php
Created April 23, 2015 10:01
Add Background Color (Highlight) Option in WordPress Editor TinyMCE
<?php
/* Hook to init */
add_action( 'init', 'tp_editor_background_color' );
/**
* Add TinyMCE Button
*/
function tp_editor_background_color()
{
/* Add the button/option in second row */
@thierrypigot
thierrypigot / tp-tinymce-remove-unused-formats.php
Created April 23, 2015 10:26
Remove unused formats in WordPress Editor TinyMCE
<?php
/*
* Modify TinyMCE editor to remove H1.
*/
add_filter('tiny_mce_before_init', 'tp_tinymce_remove_unused_formats' );
function tp_tinymce_remove_unused_formats($init)
{
// Add block format elements you want to show in dropdown
// $init['block_formats'] = 'Paragraph=p;Address=address;Pre=pre;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6';
$init['block_formats'] = 'Paragraph=p;Pre=pre;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6';
@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);