Skip to content

Instantly share code, notes, and snippets.

View jmarreros's full-sized avatar
🏠
Working from home

Jhon Marreros Guzman jmarreros

🏠
Working from home
View GitHub Profile
@jmarreros
jmarreros / RESTAPI_modificacion_entrada.php
Last active November 18, 2016 13:14
En donde 123 es el ID del posts a modificar
<?php
$host = 'http://tudominio.com/wp-json/wp/v2/posts/123';
$data = array('title' => 'Titulo Post Nuevo Modif', 'content' => 'Contenido de prueba Modif', 'status' => 'publish');
$data_string = json_encode($data);
$headers = array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string),
@jmarreros
jmarreros / RESTAPI_borrado_entrada.php
Created November 13, 2016 03:45
En donde 123 es el ID del post a eliminar.
<?php
$host = 'http:/tudominio.com/wp-json/wp/v2/posts/123';
$headers = array(
'Content-Type:application/json',
'Authorization: Basic '. base64_encode('admin:clave')
);
$ch = curl_init($host);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
@jmarreros
jmarreros / maintenance.php
Last active January 2, 2017 16:09
Pantalla Mantenimiento WordPress con SVG incluído
<?php
header( $_SERVER["SERVER_PROTOCOL"] . ' 503 Service Temporarily Unavailable', true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 600' );
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
@jmarreros
jmarreros / Lista_subcategorias.php
Last active February 27, 2017 15:40
Lista Subcategorías WordPress
<?php
// $list_subcat = get_terms( ['taxonomy' => 'category', 'hide_empty' => false, 'parent' => $cat] );
// $list_subcat = get_categories( ['hide_empty' => false, 'parent' => $cat] );
$list_subcat = array();
if ( !empty($cat) ) $list_subcat = get_categories( ['hide_empty' => false, 'parent' => $cat] );
if ( count($list_subcat)):
echo "<div class='subcat'>";
@jmarreros
jmarreros / Filtro_descripcion_categoria.php
Last active February 27, 2017 15:40
Para colocar código html en la descripción de categoría
<?php
// Unfilter Description
foreach ( array( 'pre_term_description' ) as $filter ) {
remove_filter( $filter, 'wp_filter_kses' );
}
foreach ( array( 'term_description' ) as $filter ) {
remove_filter( $filter, 'wp_kses_data' );
}
@jmarreros
jmarreros / api-woocommerce.php
Last active March 28, 2017 23:20
Conexión y Validación de errores para la REST API Woocommerce
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
use Automattic\WooCommerce\HttpClient\HttpClientException;
try {
$woocommerce = new Client(
@jmarreros
jmarreros / muestra-pagina-estatica.php
Last active June 20, 2017 21:23
Código que muestra una página estática
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ( $paged == 1 && is_home() ) {
$idPage = 2;
$page = get_post( $idPage );
$title = $page->post_title;
@jmarreros
jmarreros / install.php
Last active July 4, 2017 21:07
Archivo para generar un Quickstart en WordPress, depende del archivo srdb.class.php
<?php
require_once( realpath( dirname( __FILE__ ) ) . '/srdb.class.php' );
if (array_key_exists("step",$_REQUEST) && $_REQUEST["step"] == 2){
add_action("shutdown", "dcms_install_data");
}
function dcms_install_data() {
global $wpdb, $wp_rewrite;
@jmarreros
jmarreros / EntradasRecientes.php
Last active August 8, 2017 13:31
Shortcut WordPress para mostrar las entradas recientes.
<?php
add_action( 'init', 'dcms_agregar_shortcode' );
function dcms_agregar_shortcode(){
add_shortcode('EntradasRecientes', 'dcms_entradasrecientes');
}
function dcms_entradasrecientes( $atts , $content ){
@jmarreros
jmarreros / konami.js
Last active December 5, 2017 13:14
Código Konami personalizado usando javascript, secuencia de caracteres tipeadas por el usuario para reproducir determinada acción
var pressed = [];
var secretcode = 'navidad';
window.addEventListener('keyup', function (e) {
pressed.push(e.key);
pressed.splice(-secretcode.length -1, pressed.length - secretcode.length);
if (pressed.join('') == secretcode) {
console.log('Se usó el código secreto :)');
}