Skip to content

Instantly share code, notes, and snippets.

View iecoding's full-sized avatar
🎯
Focusing

Israel Estrada iecoding

🎯
Focusing
View GitHub Profile
@mikejolley
mikejolley / gist:2044109
Last active April 10, 2024 13:17 — forked from jameskoster/header.php
WooCommerce - Update number of items in cart and total after Ajax
<?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_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
<?php
anonymous
anonymous / gist:2912227
Created June 11, 2012 19:44
php slugify string
<?php
function slugify($str) {
$search = array('Ș', 'Ț', 'ş', 'ţ', 'Ş', 'Ţ', 'ș', 'ț', 'î', 'â', 'ă', 'Î', 'Â', 'Ă', 'ë', 'Ë');
$replace = array('s', 't', 's', 't', 's', 't', 's', 't', 'i', 'a', 'a', 'i', 'a', 'a', 'e', 'E');
$str = str_ireplace($search, $replace, strtolower(trim($str)));
$str = preg_replace('/[^\w\d\-\ ]/', '', $str);
$str = str_replace(' ', '-', $str);
return preg_replace('/\-{2,}', '-', $str);
}
@jonathantneal
jonathantneal / README.md
Last active March 19, 2024 23:31
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@kylephillips
kylephillips / favorites-display.php
Last active October 14, 2022 19:33
Using the Favorites get_user_favorites() function to display favorited post data in a custom format
<?php
// Method 1: simple foreach loop
$favorites = get_user_favorites();
if ( isset($favorites) && !empty($favorites) ) :
foreach ( $favorites as $favorite ) :
// You'll have access to the post ID in this foreach loop, so you can use WP functions like get_the_title($favorite);
endforeach;
endif;
<?php
// Example meta box field
$cmb->add_field( array(
'name' => 'Test Select',
'id' => 'test_select',
'type' => 'pw_multiselect',
'options_cb' => 'iweb_get_cmb2_post_options',
'wp_query_args' => array(
'post_type' => 'page',
),
@danfisher85
danfisher85 / woo-pagination-arrows.php
Created October 30, 2015 20:13
Change arrows for pagination (woocommerce)
<?php
add_filter( 'woocommerce_pagination_args', 'rocket_woo_pagination' );
function rocket_woo_pagination( $args ) {
$args['prev_text'] = '<i class="fa fa-angle-left"></i>';
$args['next_text'] = '<i class="fa fa-angle-right"></i>';
return $args;
}
@cleverinx
cleverinx / custom_walker.php
Created May 8, 2016 04:15
Custom Wordpress Sub-Menu Walker
class custom_sub_walker extends Walker_Nav_Menu {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\">\n";
}
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';

#Error: Database creation error: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template.

##solution

root@server:~# su postgres
postgres@server:~ $ psql -U postgres
psql (9.0.3)
Type "help" for help.
@nonbeing
nonbeing / git-deployment.md
Last active July 13, 2024 23:11 — forked from noelboss/git-deployment.md
Simple deployment using git's post-receive hook

Also see: https://gist.github.com/lemiorhan/8912188

Simple automated deployment using git hooks

Here are the simple steps needed to push your local git repository directly to a remote (e.g. prod) server over ssh. This is based on Digital Ocean's Tutorial.

Overview

You are developing in a working-directory on your local machine, let's say on the master branch. Usually people push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use GitHub's webhooks to send a POST request to a webserver to take appropriate actions such as cloning/checking out a branch on the remote (prod) server.

@aslamdoctor
aslamdoctor / woocommerce-mini-cart.php
Last active April 21, 2022 01:42
Woocommerce : Update Cart Count & Mini Cart
<!-- Add this to Header -->
<div class="header-mini-cart"><?php woocommerce_mini_cart();?></div>
<?php
// Update Cart Count & Mini Cart
add_filter( 'woocommerce_add_to_cart_fragments', 'iconic_cart_count_fragments', 10, 1 );
function iconic_cart_count_fragments( $fragments ) {
if(!empty(WC()->cart->get_cart_contents_count())){