Skip to content

Instantly share code, notes, and snippets.

@jprieton
jprieton / envialosimple_member_edit
Created March 31, 2015 20:20
EnvialoSimple Member Edit
<?php
add_action('wp_ajax_envialosimple_member_edit', function() {
// Get the results
$baseURL = 'https://app.envialosimple.com';
$apiKey = '';
$remote_url = $baseURL . '/member/edit/format/json';
$params = array();
<?php
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
function woocommerce_header_add_to_cart_fragment( $fragments ) {
ob_start();
?>
<a class="cart-contents" href="<?php echo WC()->cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
<?php
@jprieton
jprieton / .htaccess
Created July 1, 2015 14:41
Alias for WP_Ajax
# BEGIN WP_Ajax alias
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^alias.php$ wp-admin/admin-ajax.php?%{QUERY_STRING} [L]
</IfModule>
# BEGIN WP_Ajax alias
@jprieton
jprieton / in_taxonomy.php
Created July 8, 2015 18:22
WordPress Search in taxonomy
<?php
add_filter('posts_search', function ($search, &$wp_query) {
global $wpdb;
if (empty($search) || is_admin()) {
return $search; // skip processing - no search term in query
}
$s = get_query_var('s');
@jprieton
jprieton / fade.less
Last active August 29, 2015 14:26
Bootstrap Carousel Fade transition
/* Sorurce: http://codepen.io/Rowno/pen/Afykb */
.carousel-fade {
.carousel-inner {
.item {
transition-property: opacity;
}
.item,
.active.left,
.active.right {
@jprieton
jprieton / wp_url_update.sql
Created August 11, 2015 19:28
Actualizacion de url
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@jprieton
jprieton / user_poll_vote.php
Created August 21, 2015 16:14
user_poll_vote
<form class="col-sm-6" action="<?php echo admin_url('admin-ajax.php') ?>" method="post">
<?php
$poll = current(get_posts('post_type=poll&posts_per_page=1'));
$poll_options = (array) get_post_meta($poll->ID, '_poll_options', TRUE);
?>
<input type="hidden" name="poll_id" value="<?php echo $poll->ID ?>">
<input type="hidden" name="action" value="user_poll_vote">
<?php wp_nonce_field('user_poll_vote') ?>
@jprieton
jprieton / .htaccess
Last active January 28, 2016 14:02 — forked from felipepodesta/.htaccess
# ----------------------------------------------------------------------
# WORDPRESS HTACCESS FIREWALL
# @ http://codex.wordpress.org/Hardening_WordPress
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# DISABLE DIRECTORY BROWSING
# ----------------------------------------------------------------------
Options All -Indexes
@jprieton
jprieton / post-hierarchical.php
Created March 2, 2016 15:30
Set WordPress post hierarchical
<?php
add_post_type_support( 'post', 'page-attributes' );
add_action( 'init', function() {
global $wp_post_types;
$wp_post_types['post']->hierarchical = true;
}, 99 );
@jprieton
jprieton / .htaccess
Created April 6, 2016 15:39
Block any attempted XML-RPC requests
## Block any attempted XML-RPC requests
<Files xmlrpc.php>
order deny,allow
deny from all
## allow from 123.123.123.123
</Files>