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 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 / 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 / nginx.conf
Last active September 26, 2023 16:41
NGINX Configuration for WordPress Multisite + Domain Mapping with HTTPS
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com subsite.com www.subsite.com another.com www.another.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
@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 / index.html
Created March 6, 2016 00:21
How to center an image (vertically & horizontally) on a simple HTML web page.
<!DOCTYPE html>
<html lang="es-MX">
<head>
<meta charset="UTF-8" />
<title>Tituo de la pagina</title>
<meta name="description" content="Agregar descripcion">
<style type="text/css"> <!--Fix width, height and margin -->
img {
width: 600px;
height: 340px;
@QROkes
QROkes / page_archive.php
Created March 6, 2016 01:50
Multilingual archive sitemap template (WordPress + Genesis Framework + Poylang)
<?php
/**
* Genesis Framework
* Multilingual archive sitemap template (page_archive.php)
**/
//* Template Name: Archive
// Remove standard post content output
remove_action( 'genesis_post_content', 'genesis_do_post_content' );
@QROkes
QROkes / file.php
Created March 18, 2016 18:49
Get HTML source code with cUrl (file_get_contents as fallback)
$urlcontent = qr_loadUrl( 'http://myurl.com' );
function qr_loadUrl( $url ) {
if(is_callable( 'curl_init' )) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
@QROkes
QROkes / functions.php
Created March 18, 2016 19:15
WordPress exclude posts from Loop.
add_action( 'pre_get_posts', 'qr_exclude_tagged_posts' );
function qr_exclude_tagged_posts( $query ) {
if ( $query->is_main_query() && $query->is_home() ) {
$query->set( 'tag__not_in', array( 63 ) );
}
}