Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrei Chira fasterwp

View GitHub Profile
@fasterwp
fasterwp / hide-plugins-if-not-ID.php
Created Sep 2, 2021 — forked from wpmudev-sls/hide-plugins-if-not-ID.php
Hides specific menus from any users if they don't have the given ID
View hide-plugins-if-not-ID.php
<?php
/**
* Plugin Name: Hide Plugins
* Plugin URI: https://premium.wpmudev.org/
* Description: Hides specific plugins from Admin Menus & Plugins List
* Version: 1.0.0
* Author: Konstantinos Xenos @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
@fasterwp
fasterwp / create-wp-admin-account.sql
Last active Aug 16, 2021 — forked from azizur/create-wp-admin-account.sql
Create a WordPress Administrator user account using SQL
View create-wp-admin-account.sql
SET @username = 'simplenet';
SET @password = MD5('password');
SET @fullname = 'Simplenet Suport';
SET @email = 'noreply@simplenet.ro';
SET @url = 'https://simplenet.ro/';
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_status`, `display_name`) VALUES (@username, @password, @fullname, @email, @url, NOW(), '0', @fullname);
SET @userid = LAST_INSERT_ID();
INSERT INTO `wp_usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES (@userid, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
@fasterwp
fasterwp / delete-generated-wp-images.sh
Created Apr 22, 2020 — forked from neverything/delete-generated-wp-images.sh
Sometimes you only want the original images and not the generated sizes <name-of-image>-150x150.png. This command deletes all the files with a certain pattern in the file name.
View delete-generated-wp-images.sh
# List the files
find -E . -type f -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)"
# DANGER! Delete the files
find -E . -type f -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -delete
View genesis-homepage
//* Unregister widgets areas & layouts
unregister_sidebar( 'sidebar-alt' );
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
//* Register Home Slider widget area
genesis_register_sidebar( array(
'id' => 'home-slider',
View delete-cron
SELECT * FROM `wp_options` WHERE option_name = 'cron'
@fasterwp
fasterwp / enqueue Google fonts
Last active Nov 14, 2018
how to add google fonts to toki theme that has only system fotns
View enqueue Google fonts
wp_enqueue_style(
'google-fonts',
'//fonts.googleapis.com/css?family=Noto+Sans:400,700|Noto+Serif:400,400i,700,700i',
array(),
CHILD_THEME_VERSION
);
@fasterwp
fasterwp / empty-trash
Created Jun 25, 2018
set interval to empty WordPress trash
View empty-trash
define( 'EMPTY_TRASH_DAYS', 5 );
@fasterwp
fasterwp / post-revisions
Created Jun 25, 2018
set post revions in wp-config.php
View post-revisions
define( 'WP_POST_REVISIONS', 3 );
@fasterwp
fasterwp / remove-transients
Created Jun 25, 2018
mysql query to remove WordPress transients from wp_options table
View remove-transients
DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%');
@fasterwp
fasterwp / register-widgets-genesis
Created Jun 12, 2018
Register a home widget in Genesis and unregister unused areas and layouts
View register-widgets-genesis
//* Unregister widgets areas & layouts
unregister_sidebar( 'sidebar-alt' );
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
//* Register Home Slider widget area
genesis_register_sidebar( array(
'id' => 'home-slider',