Skip to content

Instantly share code, notes, and snippets.

View mdemrs's full-sized avatar

Mdemrs mdemrs

  • Mdemrs
  • Marseille
View GitHub Profile
@mdemrs
mdemrs / Image replacement
Last active August 29, 2015 14:14
css: Image replacement
.ir{
border:0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@mdemrs
mdemrs / wp_add_dashboard_widget
Last active August 29, 2015 14:16
wp: wp_add_dashboard_widget
<?php
/**
* Add a widget to the dashboard.
*
* This function is hooked into the 'wp_dashboard_setup' action below.
*/
function example_add_dashboard_widgets() {
wp_add_dashboard_widget(
@mdemrs
mdemrs / remove_meta_box
Last active August 29, 2015 14:16
wp: admin remove_meta_box
function remove_dashboard_meta() {
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal');//since 3.8
@mdemrs
mdemrs / add_submenu_page
Last active August 29, 2015 14:16
wp: admin sidebar add_submenu_page
add_action('admin_menu', 'wpautop_control_menu');
function wpautop_control_menu() {
add_submenu_page('options-general.php', 'wpautop-control', 'wpautop control', 'manage_options', 'wpautop-control-menu', 'wpautop_control_options');
}
@mdemrs
mdemrs / Redirect non super-admin to dashboard, Benjamin Denis
Last active August 29, 2015 14:16
wp: redirect users to dashboard based on admin
//Redirect users to Dashboard based on Admin, wp tech Nantes, Benjamin Denis
$pages = array( 'tools', 'options-general', 'options-writing', 'options-reading', 'options-discussion', 'options-permalink', 'options-media'); //pages
foreach( $pages as $page )
add_action( "load-".$page.".php", 'wpc_block_users' );
function wpc_block_users() {
wp_redirect( admin_url() );
exit();
}
@mdemrs
mdemrs / To disable update notifications - Sanjeev Mishra
Last active August 29, 2015 14:16
wp: to disable update notifications
//www.wpoptimus.com/626/7-ways-disable-update-wordpress-notifications/
//To Disable Update WordPress nag
add_action('after_setup_theme','remove_core_updates');
function remove_core_updates(){
if(! current_user_can('update_core')){return;}
add_action('init', create_function('$a',"remove_action( 'init', 'wp_version_check' );"),2);
add_filter('pre_option_update_core','__return_null');
add_filter('pre_site_transient_update_core','__return_null');
}
@mdemrs
mdemrs / Remove Get Shortlink, Benjamin Denis
Last active August 29, 2015 14:16
wp: Remove Get Shortlink
@mdemrs
mdemrs / enable full TinyMCE by default
Last active August 29, 2015 14:16
wp: enable full TinyMCE by default
//Enable full TinyMCE by default
function my_mce_options( $init ) {
$init['wordpress_adv_hidden'] = false;
return $init;
}
add_filter('tiny_mce_before_init', 'my_mce_options');
//Add buttons in TinyMCE, list http://www.tinymce.com/wiki.php/TinyMCE3x:Buttons/controls
function wpc_add_more_buttons($buttons){
$buttons[] = 'charmap';
@mdemrs
mdemrs / Favicon in Wordpress admin
Created March 9, 2015 16:30
wp: Favicon in Wordpress admin
// Favicon in wordpress admin
function wpc_admin_favicon(){
echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_stylesheet_directory_uri().'/img/favicon.ico" />';
}
add_action('admin_head', 'wpc_admin_favicon');
@mdemrs
mdemrs / remove or add Wordpress Footer Credits, Benjamin Denis
Created March 9, 2015 16:38
wp: remove or add Wordpress Footer Credits