Skip to content

Instantly share code, notes, and snippets.

View jarcos's full-sized avatar
🐐
On the farm

José Arcos jarcos

🐐
On the farm
View GitHub Profile
$('#form').submit( function (event) { // Needs to be submit to catch all the fields
event.preventDefault();
var formContent = $( this ).serialize();
});
$('input[name=checkboxes[]]:checked').serialize(); // Capture all checked checkboxes
@jarcos
jarcos / cloudSettings
Last active September 10, 2020 13:12
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-06-18T09:45:41.725Z","extensionVersion":"v3.4.3"}
@jarcos
jarcos / add-page-template.php
Last active January 5, 2019 21:03
Add a WordPress Page Template from a Plugin from a functional programming point of view
<?php
/**
* Inspiration: https://www.wpexplorer.com/wordpress-page-templates-plugin/
*/
add_filter( 'theme_page_templates', 'add_new_template' );
add_filter( 'wp_insert_post_data', 'register_templates' );
add_filter( 'template_include', 'view_template' );
function register_templates( $atts ) {
@jarcos
jarcos / sort_array.php
Last active January 1, 2018 21:57
Sort array by date
<?php
/**
* In this case, the value to sort is a date in string, i.e. "01/01/2018" or "2017-12-31"
*/
/**
* Example of array
*/
$array = array(
array( "01/01/1968", "Do Androids Dream of Electric Sheep?", "Philip K. Dick", "Philosophical novel" ),
@jarcos
jarcos / functions.php
Last active March 2, 2017 15:39
Returns to product category page after click on Continue Shopping button
<?php
/**
* It takes the first category find on the array.
* Ideally for stores with products with a single category.
*/
add_filter( 'woocommerce_continue_shopping_redirect', 'wa_custom_redirect_continue_shopping' );
function wa_custom_redirect_continue_shopping() {
global $woocommerce;