Skip to content

Instantly share code, notes, and snippets.

View crewstyle's full-sized avatar
💭
Good mood! Wanna try new tools for WordPress

Achraf Chouk crewstyle

💭
Good mood! Wanna try new tools for WordPress
View GitHub Profile
@crewstyle
crewstyle / functions.php
Last active March 9, 2019 12:56
WordPress ~ Close database connections - #security #optimisation
<?php
/**
* Close database connections
*
* It's very dangerous to let connections opened. In a website
* with high traffic volume, you can kill your database just
* because of unclosed DB connections.
* This little snippet prevent that drama ;)
*
@crewstyle
crewstyle / functions.php
Last active April 20, 2016 08:18
WordPress ~ Remove WordPress version in head HTML tag - #frontend #security #optimisation
<?php
//Remove WordPress version.
//<meta name="generator" content="WordPress __WP_VERSION__" />
remove_action('wp_head', 'wp_generator');
/**
* Remove WordPress generator info.
*
* @see https://github.com/crewstyle/clean-wordpress
@crewstyle
crewstyle / functions.php
Last active April 20, 2016 08:17
WordPress ~ Remove admin bar - #frontend #optimisation
<?php
//Remove admin bar since WP v3.1
add_filter('show_admin_bar', '__return_false');
remove_action('init', 'wp_admin_bar_init');
@crewstyle
crewstyle / functions.php
Last active April 20, 2016 08:30
WordPress ~ Remove emojicons scripts - #frontend #backend #optimisation
<?php
/**
* Disable emojicons introduced with WP 4.2 in frontend panel.
*
* @uses remove_action()
* @uses add_filter()
* @see https://github.com/crewstyle/clean-wordpress
*/
add_action('init', '_cw_disable_wp_emojicons');
@crewstyle
crewstyle / functions.php
Last active September 30, 2018 07:00
WordPress ~ Clean head HTML tag - #frontend #optimisation
<?php
/**
* Define what to clean from the theme header frontend, via the "remove_action" hook.
*
* @see https://github.com/GetOlympus/Zeus-Core
*/
$optims = [
'adjacent_posts_rel', // Removes the next and previous post links from the header
@crewstyle
crewstyle / functions.php
Last active April 20, 2016 08:30
WordPress ~ Make medias works in all browsers (such as Safari) - #backend #optimisation
<?php
/**
* Sanitize filenames.
*
* This script has been made because of a bug on Safari which
* does not display medias if its name contains special character
* such as "é", "à" or a simple " ".
* This script transform all these specials to prevent this bug.
*
@crewstyle
crewstyle / functions.php
Created April 20, 2016 08:27
WordPress ~ Clean admin bar - #backend #optimisation
<?php
/**
* Remove menu items from WordPress admin bar.
*
* @uses remove_menu() To remove specific menu.
* @see https://github.com/crewstyle/clean-wordpress
*/
add_action('wp_before_admin_bar_render', '_cw_remove_bar_icons');
function _cw_remove_bar_icons()
@crewstyle
crewstyle / functions.php
Created April 20, 2016 08:30
WordPress ~ Remove dashboard menus to editor role - #backend #security
<?php
/**
* Remove dashboard menus to editor role.
*
* @uses current_user_can() To know if current user has permissions.
* @uses remove_menu_page() To remove a menu page.
* @uses remove_submenu_page() To remove a submenu page.
* @see https://github.com/crewstyle/clean-wordpress
*/
@crewstyle
crewstyle / functions.php
Created April 20, 2016 08:33
WordPress ~ WP version check for admin role only - #backend #security
<?php
/**
* Sets up WP version check for admin role only.
*
* @uses current_user_can() To know if current user has permissions.
* @uses add_action() To add a hook action.
* @uses add_filter() To add a hook filter.
* @see https://github.com/crewstyle/clean-wordpress
*/
@crewstyle
crewstyle / wp-update.sh
Last active April 20, 2016 08:57
WordPress updater bash script on remote server - #optimisation #bash #remote
#!/bin/bash
####################################################################
# WordPress updater script
#
# This script has been made to update WordPress sites quickly
# and works on remote server.
#
# It works with this simple command line:
# /path/to/wp-update.sh folder_name user:group