Skip to content

Instantly share code, notes, and snippets.

View jroquejr's full-sized avatar

Roque Junior jroquejr

View GitHub Profile
@jroquejr
jroquejr / wordpress_header_title.php
Created August 20, 2013 17:21
Wordpress - General Master Title
<?php
$wp_title = "";
if (function_exists('is_tag') && is_tag()) {
$wp_title = ' Listagem da tag &quot;' . $tag . '&quot; - ';
} elseif (is_archive()) {
$wp_title = wp_title('', false) . ' Listagem - ';
} elseif (is_search()) {
$wp_title = 'Buscando por &quot;' . wp_specialchars($s) . '&quot; - ';
} elseif (!(is_404()) && (is_single()) || (is_page())) {
$wp_title = wp_title('', false). ' - ';
@jroquejr
jroquejr / custommenu.php
Created August 23, 2013 14:36
Customizar o menu do WordPress
<?php
/**
* Extende-se a classe Walker_Nav_Menu
* Lembrar de passar uma instancia dessa classe no parametro walker do wp_nav_menu
*
*/
$custom_walker = new Menu_With_Description();
wp_nav_menu(array(
@jroquejr
jroquejr / seo__url.xml
Created August 31, 2013 13:13
Opencart Seo Url
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>SEO - Custom url - adaptado de http://www.davidchc.com.br/tutoriais/opencart-tutoriais/transformando-as-outras-url-do-opencart-em-amigaveis/</id>
<version>1.0</version>
<vqmver>2.2.1</vqmver>
<author>jroqueweb</author>
<file name="catalog/controller/common/seo_url.php">
<operation>
<search position="before" index="1"><![CDATA[public function index() {]]></search>
<add><![CDATA[
@jroquejr
jroquejr / Varnish WordPress multidevice
Created October 3, 2013 17:45
Varnish VCL to Wordpress multidevice site with allowed purge from localhost
backend default {
.host = "127.0.0.1";
.port = "81";
}
acl purge {
"localhost";
}
# Rutine to try and identify device
@jroquejr
jroquejr / limita_caracteres.php
Created January 30, 2014 13:41
Limitador de caracteres para o editor do WordPress
<?php add_action( 'admin_init', function(){ add_action( 'dbx_post_sidebar', function(){ ?>
<style type="text/css">
.char-limit.over-limit{
color: red;
}
.char-limit.over-limit:after{
content: ' LIMITE DE CARACTERS ATINGIDO. POR FAVOR REVISE O SEU TEXTO';
color: red;
@jroquejr
jroquejr / lock.css
Created March 28, 2014 19:49 — forked from visnup/lock.css
/* if portrait mode is detected, rotate the entire site -90 degrees to hint rotating to landscape */
@media (orientation: portrait) {
body {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
}
}
@jroquejr
jroquejr / gist:9875621
Last active April 9, 2019 02:12
WordPress - Remover acentos dos nomes de imagens no upload
<?php
// remove_accents: https://codex.wordpress.org/Function_Reference/remove_accents
add_filter('sanitize_file_name', 'sa_sanitize_spanish_chars', 10);
function sa_sanitize_spanish_chars ($filename) {
return remove_accents( $filename );
}
import simplejson
import json
def put(data, filename):
try:
jsondata = simplejson.dumps(data, indent=4, skipkeys=True, sort_keys=True)
fd = open(filename, 'w')
fd.write(jsondata)
fd.close()
except:
<?php
/*
Plugin Name: Remote Login
Description: Log into the site with creds that work on remote site (as defined in plugin). The remote site must have XML-RPC enabled.
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
THIS IS NOT COMPLETE - DO NOT USE IN PRODUCTION
The remote site (defined below in $server) is the "master" site.
from scrapy.spider import BaseSpider
# Requires this patch:
# https://github.com/joehillen/scrapy/commit/6301adcfe9933b91b3918a93387e669165a215c9
from scrapy.selector import PyQuerySelector
class DmozSpiderPyQuery(BaseSpider):
name = "pyquery"
allowed_domains = ["dmoz.org"]
start_urls = [