Skip to content

Instantly share code, notes, and snippets.

View fearlex's full-sized avatar
🎯
Focused

Arleys Resco fearlex

🎯
Focused
View GitHub Profile
@fearlex
fearlex / functions.php
Last active October 1, 2016 03:46
Restore WP separators
/**
* Restore Wordpress Separators
*/
function SLUG_admin_separators()
{
echo '<style type="text/css">
#adminmenu li.wp-menu-separator {margin: 0;}
.admin-color-fresh #adminmenu li.wp-menu-separator {background: #444;}
.admin-color-midnight #adminmenu li.wp-menu-separator {background: #4a5258;}
.admin-color-light #adminmenu li.wp-menu-separator {background: #c2c2c2;}
@fearlex
fearlex / functions.php
Last active October 1, 2016 03:52
Removing WP default roles.
/** Remove WP unnecessary roles **/
remove_role('subscriber');
remove_role('editor');
remove_role('author');
remove_role('contributor');
@fearlex
fearlex / function.php
Last active October 1, 2016 05:32
Remove Slider Revolution metaboxes
function SLUG_remove_revolution_slider_meta_boxes() {
remove_meta_box( 'mymetabox_revslider_0', 'page', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'post', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'post_type', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'post_type', 'normal' );
}
add_action( 'do_meta_boxes', 'SLUG_remove_revolution_slider_meta_boxes' );
@fearlex
fearlex / file.php
Created October 3, 2016 23:33
Get Current User Role name.
// -- Get Current User Role.
global $wp_roles;
$roles = wp_get_current_user()->roles[ 0 ];
$role_display = $wp_roles->roles[ $roles ][ 'name' ];
@fearlex
fearlex / woocommerce.php
Created October 7, 2016 11:48
A collection of WooCommerce Snippets that can be useful for different tasks.
// -- Remove WooCommerce SKUs Completely
add_filter( 'wc_product_sku_enabled', '__return_false' );
@fearlex
fearlex / functions.php
Created October 10, 2016 20:00
A Collection of Wordpress Snippets
// -- Changing Image Library Processor. Fix Http Error on Media Upload.
add_filter( 'wp_image_editors', 'prefix_image_editor_default_to_gd' );
/**
* Changing Image Library Processor.
*
* @param $editors
*
* @return array
@fearlex
fearlex / .htaccess
Created October 14, 2016 16:45
Forcing HTTPS Everywhere
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@fearlex
fearlex / .htaccess
Created October 17, 2016 21:47
Wordpress Force https and non-www
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://domain.com%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule (.*) https://domain.com%{REQUEST_URI} [L,R=301,NC]
@fearlex
fearlex / wp-cli.php
Created November 16, 2016 11:08
WP CLI - Clean WP Defaults
This should be done by WP-CLI
wp post delete $(wp post list --name="$(wp eval 'echo sanitize_title( _x( "hello-world", "Default post slug" ) );')" --posts_per_page=1 --format=ids)
wp post delete $(wp post list --post_type=page --name="$(wp eval 'echo __( "sample-page" );')" --posts_per_page=1 --format=ids)
wp comment delete 1
wp option update blogdescription ""
wp plugin uninstall akismet
wp plugin uninstall hello-dolly
wp theme delete twentyfifteen
wp theme delete twentyfourteen
@fearlex
fearlex / .htaccess
Created May 4, 2017 06:28 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/