Skip to content

Instantly share code, notes, and snippets.

View agustinprosperi's full-sized avatar

Agustin Prosperi agustinprosperi

View GitHub Profile
@agustinprosperi
agustinprosperi / rename-uploads.php
Created September 19, 2016 11:34 — forked from onnimonni/rename-uploads.php
Remove accents from Wordpress uploads. This renames all files and replaces corresponding attachment in WordPress database. You probably use linux in production and might run OS X in development. This helps to avoid possible problems with filenames. To avoid this in future install mu-plugin which hooks in 'sanitize_file_name'
<?php
/*
* Replace-uploads.php
* This replaces all accents from your uploads
* you can run this with wp-cli: $ wp eval-file replace-uploads.php
*/
/**
* cd to right path before changes
*/
<?php
/***************************woocommerce*hooks*********************************/
// simulacion de webservices
function wc_batela_get_vars(){
return $las_vars = array(
'var1'=>'Var 1',
'new_price'=>'Nuevo precio',
);
}
// aqui se imprimen las variaciones en el detalle del producto
@agustinprosperi
agustinprosperi / export.php
Last active September 2, 2016 10:45
Export-Import posts en excel con PHPExcel_1.8.0_doc con las imagenes adjuntas
<?php
// Incluir en el functions.php del sitio a exportar
// exportLocales
if( isset($_GET['exportLocales']) ){
// error_reporting(E_ALL);
// ini_set('display_errors', TRUE);
// ini_set('display_startup_errors', TRUE);
add_action( 'init', function(){
$locales = new WP_Query( array(
'post_type' => 'locales',
@agustinprosperi
agustinprosperi / wp_ajax_callback_example.php
Last active June 9, 2017 22:14
wordpress ajax callback example
<form id="search">
<input type="hidden" name="action" value="custom_search" />
<input type="text" id="texto" name="texto" />
<input type="submit" value="submit" />
</form>
<div id="answer"></div>
<script type="text/javascript">
jQuery(function($){
$("#search").submit(function(e){
if( $("#search").hasClass("sending") ) return false;
@agustinprosperi
agustinprosperi / jquery.example.js
Last active November 1, 2017 11:57
jquery short examples
// wait for images to load
$(window).bind("load", function() {
// code here, masonry for example
});
// validateEmail
function validateEmail(email) {
var re = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
return re.test(email);
}
// Ajax call
@agustinprosperi
agustinprosperi / get_titdesc_object.php
Last active April 29, 2016 08:00
php curl call to webservice example
<?php
/*
* Get json data, from webservice, for loop on the front
*/
function get_titdesc_object(){
$options = get_option( 'tooltyp_settings' );
$curl = curl_init( $options['wsurl'] );
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, $options['wsuser'].":".$options['wspassword']); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@agustinprosperi
agustinprosperi / getWeek.js
Created February 10, 2016 15:59 — forked from dblock/getWeek.js
get week of the year in JavaScript
function( d ) {
// Create a copy of this date object
var target = new Date(d.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (d.getDay() + 6) % 7;
// Set the target to the thursday of this week so the
@agustinprosperi
agustinprosperi / change_featured_image_labels.php
Last active April 29, 2016 07:55 — forked from slushman/gist:454cc8b26c330727df13
Customize the Featured Image labels
<?php
// add new column(s) to custom taxonomy list
add_filter('manage_edit-taconomyName_columns','manage_taconomyName_columns');
function manage_taconomyName_columns($columns){
foreach( $columns as $k=>$v )
$ke = $k;
array_pop( $columns );
return array_merge( $columns,
array( 'f_image'=>__('Image') ),
array( $ke=>$v )
<div id="loadgooglemap"></div>
<script src="//maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function($) {
//------- Google Maps ---------//
<?php
$latlng = '-17.8126693,-63.1751292';
$cr_text = 'mi texto va aquí';
?>