Skip to content

Instantly share code, notes, and snippets.

View QROkes's full-sized avatar

Cristhian Martínez Ochoa QROkes

View GitHub Profile
@QROkes
QROkes / functions.php
Last active September 14, 2015 05:47
Remove WordPress generator meta tag
// Remove WordPress Generator Meta Tag
function remove_generator_filter() { return ''; }
if (function_exists('add_filter')) {
$types = array('html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export');
foreach ($types as $type)
add_filter('get_the_generator_'.$type, 'remove_generator_filter');
}
// Another option:
function qr_remove_wp_version() {return '';}
@QROkes
QROkes / functions.php
Created September 14, 2015 05:52
Change squema.org markup (Wordpress - Genesis Framework)
// Change schema.org markup
function qr_body_schema( $attr ) {
$attr['class'] = join( ' ', get_body_class() );
$attr['itemscope'] = 'itemscope';
$attr['itemtype'] = 'http://schema.org/Restaurant';
return $attr;
}
add_filter( 'genesis_attr_body', 'qr_body_schema', 20 );
@QROkes
QROkes / front-page.php
Created December 30, 2015 00:14
Full width landing pages (Wordpress & Genesis Framework)
<?php
// Full Width Landing Pages in Genesis
// http://www.billerickson.net/full-width-landing-pages-in-genesis/
function qr_frontpage() {
// Insert custom sctruture/content instead of genesis() --> 'genesis_loop'
}
add_action( 'qr_content_area', 'qr_frontpage' );
@QROkes
QROkes / example.php
Created January 17, 2016 15:07
Convert Unicode Escape Sequences to UTF-8.
// Convert Unicode Escape Sequences to UTF-8.
$content = preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}, $content);
@QROkes
QROkes / functions.php
Created January 17, 2016 15:09
Custom header CSS Style (Wordpress & Genesis Framework)
/** Fix header image aligment
add_theme_support( 'genesis-custom-header', array( 'width' => 396, 'height' => 120 ) );
remove_action( 'wp_head', 'genesis_custom_header_style' );
function qr_custom_header() {
$header_image = get_header_image();
$output .= sprintf( '%s { background: url(%s) center no-repeat !important; }', genesis_html5() ? '.title-area' : '#header', esc_url( $header_image ) );
printf( '<style type="text/css">%s</style>' . "\n", $output );
}
add_action( 'wp_head','qr_custom_header' ); */
@QROkes
QROkes / le-renew.sh
Created February 7, 2016 02:20
Let's Encrypt renewal script for Nginx on Ubuntu
#!/bin/bash
#================================================================
# Let's Encrypt renewal script for Nginx on Ubuntu
# Modified by Cristhian Martinez Ochoa <cristhian@qrokes.com> https://qrokes.com
# Original author Erika Heidi <erika@do.co>
# Usage: sudo le-renew [base-domain-name]
#================================================================
# Modify le_path with your current ubuntu username
domain=$1
le_path='/home/user/letsencrypt'
@QROkes
QROkes / functions.php
Last active February 23, 2016 03:56
Modify entry comments in WordPress according to the e-mail address.
// Modify entry comments
function qr_admin_author($comment_data){
if ($comment_data['comment_author_email'] == 'mail@domain.com') {
$comment_data['user_ID'] = 1;
$comment_data['comment_author'] = 'Author Name';
$comment_data['comment_author_url'] = 'Author URL';
}
return $comment_data;
}
add_filter('preprocess_comment','qr_admin_author');
@QROkes
QROkes / functions-2.php
Last active February 25, 2016 23:46
Some functions to modify Yoast SEO breadcrumbs. (WordPress)
// Add an element after "Home" to Yoast SEO breadcrumbs. (WordPress)
add_filter( 'wpseo_breadcrumb_links', 'qr_add_breadcrumb' );
function qr_add_breadcrumb( $links ) {
$breadcrumb[] = array(
'url' => 'URL',
'text' => 'Text',
);
array_splice( $links, 1, -2, $breadcrumb );
return $links;
}
@QROkes
QROkes / functions.php
Last active February 26, 2016 00:35
Add widget to the Primary Menu (Wordpress & Genesis Framework)
// Add widget to the Primary Menu (Social Icons)
genesis_register_sidebar( array(
'id' => 'nav-social-menu',
'name' => __( 'Nav Social Menu', 'text-domain' ),
'description' => __( 'Primary menu widget for social icons.', 'text-domain' ),
) );
add_filter( 'genesis_nav_items', 'qr_social_icons', 10, 2 );
add_filter( 'wp_nav_menu_items', 'qr_social_icons', 10, 2 );
function qr_social_icons($menu, $args) {
@QROkes
QROkes / functions.php
Last active February 26, 2016 02:55
Add last updated date to the post info in entry header (Wordpress - Genesis Framework)
//* Add last updated date to the post info in entry header (requires HTML5 theme support)
add_filter( 'genesis_post_info', 'qr_post_info_filter' );
function qr_post_info_filter($post_info) {
if (get_the_modified_time() != get_the_time()) {
$post_info = $post_info . '<br/>Last updated on: ' . the_modified_date('j/m/Y', '', '', false);
}
return $post_info;
}