Skip to content

Instantly share code, notes, and snippets.

View fernandiez's full-sized avatar

Fernan fernandiez

View GitHub Profile
@fernandiez
fernandiez / .htaccess
Created September 1, 2021 14:56
Bloqueo de IPs .htaccess - Allow Deny
# IPs whitelist - block
# deny all Ips
# allow only certain IPs or IP range
ErrorDocument 403 /error403.html
order deny,allow
deny from all
allow from xx.xx.xx.xx
allow from 55.99.66.111
allow from 55.99.66.0/23
allow from 55.99.66.0/24
@fernandiez
fernandiez / remote-api-rest.php
Created May 31, 2019 05:15
Remote WordPress API REST request
<?php
$uri = 'http://www.dominio.com/wp-json/wp/v2/posts/?page=1&per_page=3';
$json = file_get_contents($uri);
$posts= json_decode($json);
echo "<h1>Listado de entradas</h1><ul>";
foreach ($posts as $post) {
echo "<h2><a href='" . $post->link . "'>" . $post->title->rendered . "</a></h2>\n";
echo "<p>" . $post->excerpt->rendered . "</p>";
echo "<p><a href='" . $post->link . "'>Enlace directo</a></p>\n";
@fernandiez
fernandiez / functions.php
Last active December 20, 2018 09:58
Shortcode Placeholder Image dummyimage_shortcode_function
// Añadir Shortcode
function dummyimage_shortcode_function( $atts ) {
// Atributos
$atts = shortcode_atts(
array(
'width' => '600',
'height' => '300',
'background' => 'eeeeee',
'text' => 'ffffff',
@fernandiez
fernandiez / .htaccess
Created October 18, 2018 13:06
Redirect 301 from old domain to new domain HTTPS
# Redirect from old domain to new domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ https://www.newdomain.com/$1 [R=301,L]
// default task
gulp.task('default', ['build', 'watch']);
// watch for file changes
gulp.task('watch', ['browsersync'], () => {
// page changes
gulp.watch(php.src, ['php'], browsersync ? browsersync.reload : {});
// image changes
gulp.watch(images.src, ['images']);
// CSS changes
// Browsersync options
const syncOpts = {
proxy : 'localhost',
files : dir.build + '**/*',
open : false,
notify : false,
ghostMode : false,
ui: {
port: 8001
}
// recopilar acciones
gulp.task('build', ['php', 'css', 'js']);
@fernandiez
fernandiez / gulpfile.js
Created September 20, 2018 16:25
Compilar JS
// JavaScript settings
const js = {
src : dir.src + 'js/**/*',
build : dir.build + 'js/',
filename : 'scripts.js'
};
// JavaScript processing
gulp.task('js', () => {
// CSS settings
var css = {
src : dir.src + 'scss/style.scss',
watch : dir.src + 'scss/**/*',
build : dir.build,
sassOpts: {
outputStyle : 'nested',
imagePath : images.build,
precision : 3,
errLogToConsole : true