Skip to content

Instantly share code, notes, and snippets.

@hugosolar
hugosolar / youtube_video.php
Last active December 14, 2015 15:58
Youtube video class for wordpress
<?php
/**
* Obtain youtube video API object and transients it
* eg. $video = new youtube_videos('simonscat');
* $video->get_videos(array('offset' => 5,'num_videos' => 10));
* @param $account string Account youtube name
* @return none
* @author Hugo Solar <contacto@hugosolar.net>
* */
@hugosolar
hugosolar / bash-copy-newer file
Last active December 19, 2015 00:49
bash script que comprueba si archivos css en origen son mas nuevos que los del destino y los copia. y si no existe el directorio lo crea.
#!/bin/bash
for file in ./front-themes/*; do
if [ -d $file ]; then
DIRECTORY="${file##"./front-themes/"}"; #obtenemos el nombre del directorio de origen y lo aislamos (debe haber algo mas elegante para hacerlo)
if [[ "$DIRECTORY" == *"-2013" ]]; then
STYLE1="$file/style.css"; #archivo fuente
STYLE2="./htdocs/wp-content/themes/$DIRECTORY/style.css"; #archivo destino
DIRECTORY2="./htdocs/wp-content/themes/$DIRECTORY/"; #directorio de destino
if [[ "$STYLE1" -nt "$STYLE2" ]]; then #comparamos si origen es mas nuevo que destino
@hugosolar
hugosolar / menu_images.js
Last active November 21, 2017 18:34
Javascript class to use new wp.media uploader to upload or use an existing image to use it in the wordpress custom menu using this plugin idea https://github.com/blazersix/simple-image-widget
jQuery(function($) {
var $control;
mediaControl = {
// Initializes a new media manager or returns an existing frame.
// @see wp.media.featuredImage.frame()
frame: function() {
if ( this._frame )
return this._frame;
this._frame = wp.media({
@hugosolar
hugosolar / Estructura
Last active August 18, 2022 17:25
Gruntfile for Ember JS app
* significa que lo genera Grunt
------------------------------------
.
|-- Gruntfile.js ( el de arriba)
|-- css
| |-- style.css (development *)
| `-- style.min.css ( production * )
|-- font -> ../../framework/font
|-- img -> ../../framework/img
|-- index.html
@hugosolar
hugosolar / videos.php
Last active August 29, 2015 14:06
Class Videos
<?php
class videos {
/* function get_video
* Extract and return video id from youtbe & vimeo videos
* @param url : Video url
*/
static function get_video($url,$width=560,$height=315) {
if (strstr($url,'youtube')){
$parse_url=parse_url($url);
parse_str($parse_url['query']);
@hugosolar
hugosolar / custom-button-parallax.js
Last active August 27, 2015 20:57
Add buttons to tinyMCE on Wordpress
(function(){
/*
Este boton deja entre shortcodes el texto seleccionado
para dar el formato requerido por el layout
*/
tinymce.PluginManager.add('custom_button_parallax_content', function( editor, url ) {
editor.addButton( 'custom_button_parallax_content', {
text: '',
icon: 'icn icn-imagen',
title: 'Contenido Parallax',
@hugosolar
hugosolar / fsqm-pro-punga-exporter.php
Created October 23, 2015 18:09
Simple simple exporter to fsqm-pro plugin
<?php
error_reporting(0);
//FORM ID
$id_form = 8;
//manual translate of smileyrate
function smilley_translate($smile) {
switch ($smile) {
case 'frown': return 'molesto'; break;
case 'sad': return 'Muy insatisfecho(a)'; break;
<?php
// Social Feed para sitios en wordpress
class SocialFeed {
private static $instance;
public $feed_list;
public $yt_status;
public $fb_status;

Keybase proof

I hereby claim:

  • I am hugosolar on github.
  • I am hsolar (https://keybase.io/hsolar) on keybase.
  • I have a public key ASAt1Z0R_QV4ntyIrlfqgkVougp_9l6S2otDvPz3P3lRLgo

To claim this, I am signing this object:

@hugosolar
hugosolar / functions.php
Created November 30, 2018 01:50
Use category image instead custom placeholder on Woocommerce
/**
* Change the placeholder image
*/
add_filter('woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src');
function custom_woocommerce_placeholder_img_src($src)
{
global $post;
$terms = wp_get_post_terms($post->ID, 'product_cat');
$thumbnail_id = get_woocommerce_term_meta($terms[0]->term_id, 'thumbnail_id', true);