Skip to content

Instantly share code, notes, and snippets.

View fernandiez's full-sized avatar

Fernan fernandiez

View GitHub Profile
@fernandiez
fernandiez / sample.html
Created January 11, 2018 10:31
HTML sample content
<h1>Headline 1</h1>
This is an example of a WordPress post, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many posts as you like in order to share with your readers what is on your mind.
<h2>Headline 2</h2>
This is an example of a WordPress post, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many posts as you like in order to share with your readers what is on your mind.
<h3>Headline 3</h3>
This is an example of a WordPress post, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many posts as you like in order to share with your readers what is on your mind.
<h4>Headline 4</h4>
This is an example of a WordPress post, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many posts as you like in ord
@fernandiez
fernandiez / functions.php
Created December 27, 2017 10:54
Remove WordPress admin bar
// Remove WordPress admin bar
add_filter('show_admin_bar', '__return_false')
@fernandiez
fernandiez / functions.php
Created December 20, 2017 17:33
Simple Google Analytics WordPress code snippet
// Adds Google Analytics code to the header
function fernan_analytics_code() { ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-1');
@fernandiez
fernandiez / google-analytics-plugin.php
Last active December 20, 2017 17:34
Simple Google Analytics WordPress plugin
<?php
/**
*
* Simple Google Analytics WordPress plugin
*
* @link https://www.fernan.com.es/
* @since 1.0.0
*
* Plugin Name: Fernan Google Analytics
@fernandiez
fernandiez / block.js
Created November 30, 2017 10:31
Registering the Block Gutenberg
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
blockStyle = { backgroundColor: '#900', color: '#fff', padding: '20px' };
registerBlockType( 'gutenberg-boilerplate-es5/hello-world-step-01', {
title: 'Hello World (Step 1)',
icon: 'universal-access-alt',
category: 'layout',
@fernandiez
fernandiez / index.php
Created November 30, 2017 10:29
Enqueuing Block Scripts Gutenberg
<?php
/*
Enqueuing Block Scripts
https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/
*/
function gutenberg_boilerplate_enqueue_block_editor_assets() {
wp_enqueue_script(
'gutenberg-boilerplate-es5-step01',
plugins_url( 'step-01/block.js', __FILE__ ),
array( 'wp-blocks', 'wp-element' )
@fernandiez
fernandiez / functions.php
Last active March 11, 2019 12:25
Create menu section under Tools in WordPress admin dashboard and Editor role redirect
<?php
// Create menu section under Tools in WordPress admin
add_action( 'admin_menu', 'docs_admin_menu' );
// New section under Tools
function docs_admin_menu() {
add_management_page( 'Docs', 'Docs', 'manage_categories', 'docs', 'content_docs_admin_menu' );
}
@fernandiez
fernandiez / functions.php
Created September 18, 2017 16:56
Color Buttons Shortcode - Genesis
// Color Buttons Shortcode - Genesis
// Add Shortcode
function function_color_button( $atts , $content = null ) {
// Attributes
$atts = shortcode_atts(
array(
'link' => '',
'color' => '',
@fernandiez
fernandiez / functions.php
Created September 18, 2017 16:55
Content Boxes Shortcode - Genesis
// Content Boxes Shortcode - Genesis
function function_content_box( $atts , $content = null ) {
// Attributes
$atts = shortcode_atts(
array(
'color' => '',
),
$atts,
'content-box'
@fernandiez
fernandiez / .htaccess
Created August 30, 2017 10:47
Redirection 301 .htaccess from HTTP to HTTPS (without www)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
</IfModule>