Skip to content

Instantly share code, notes, and snippets.

@FesoVel
FesoVel / WordPress - Insert HTML In Header
Created January 4, 2019 12:48
How to add html code to WordPress <head> using wp_head hook.
function insert_html_in_header() {
echo '<<< html here >>>';
}
/* Admin Dashboard */
add_action( 'admin_head', 'insert_html_in_header' );
/* Front End */
add_action( 'wp_head', 'insert_html_in_header' );
@FesoVel
FesoVel / WordPress - Remove Version Number
Created January 10, 2019 18:09
WordPress - Remove Version Number
function remove_wp_version() {
return '';
}
add_filter('the_generator', 'remove_wp_version');
@FesoVel
FesoVel / How to remove query strings from resources
Last active January 14, 2019 13:37
WordPress - Remove Query Strings
function remove_query_strings( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', 'remove_query_strings', 15, 1 );
add_filter( 'style_loader_src', 'remove_query_strings', 15, 1 );
@FesoVel
FesoVel / WordPress - Removing Styles
Last active April 4, 2019 19:12
Manually remove any .css file by it's URL.
add_filter( 'style_loader_src', function($href){
if(strpos($href, "//example.com/") === false) {
return $href;
}
return false;
});
@FesoVel
FesoVel / Insert WordPress Admin User SQL
Last active April 9, 2019 12:59
Insert a new WordPress admin user using SQL directly in code or phpMyAdmin interface.
INSERT INTO `de72g_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('111111', 'admin', MD5('admin123'), 'admin', 'viktor@agorawebdesigns.com', '', '2019-04-09 15:00:00', '', '0', 'admin');
INSERT INTO `de72g_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '111111', 'wp_capabilities', 'a:1:{s:13:\"administrator\";s:1:\"1\";}');
INSERT INTO `de72g_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '111111', 'wp_user_level', 'wp_user_level');
@FesoVel
FesoVel / gist:76b7222e07d70aef744333d3e1701dc3
Created April 9, 2019 13:01
Set proper WordPress file system permissions.
chown www-data:www-data -R * # Let Apache be owner
find . -type d -exec chmod 755 {} \; # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \; # Change file permissions rw-r--r--