Skip to content

Instantly share code, notes, and snippets.

Avatar

Fernan fernandiez

View GitHub Profile
@fernandiez
fernandiez / .htaccess
Created Sep 1, 2021
Bloqueo de IPs .htaccess - Allow Deny
View .htaccess
# 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
Remote WordPress API REST request
View remote-api-rest.php
<?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 Dec 20, 2018
Shortcode Placeholder Image dummyimage_shortcode_function
View functions.php
// 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 Oct 18, 2018
Redirect 301 from old domain to new domain HTTPS
View .htaccess
# 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]
View gist:bd4c085bbdc27e5a5a59f9d18eebbe6f
// default task
gulp.task('default', ['build', 'watch']);
View gist:15336964a9e2f5fd485ac4b88a7d9f0b
// 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
View gist:58a1910283524d5bbce9fee60ee4ae93
// Browsersync options
const syncOpts = {
proxy : 'localhost',
files : dir.build + '**/*',
open : false,
notify : false,
ghostMode : false,
ui: {
port: 8001
}
View gist:1eacd3568029adcedd574f9633101df2
// recopilar acciones
gulp.task('build', ['php', 'css', 'js']);
View gulpfile.js
// JavaScript settings
const js = {
src : dir.src + 'js/**/*',
build : dir.build + 'js/',
filename : 'scripts.js'
};
// JavaScript processing
gulp.task('js', () => {
View gist:ab5c22c10a920bf8f4275d1186edfe29
// 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