Skip to content

Instantly share code, notes, and snippets.

@Sanabria
Sanabria / .gitignore
Created June 14, 2021 20:18 — forked from lumpysimon/.gitignore
A .gitignore file for WordPress that ignores pretty much everything except for the specified plugin(s), theme(s) and mu-plugins folder
# .gitignore file for WordPress that ignores everything except:
#
# - .gitignore
# - favicon.ico
# - wp-config.php
# - everything in mu-plugins
# - my-plugin
# - my-theme (except for .sass-cache)
#
# based on https://gist.github.com/jdbartlett/444295
@Sanabria
Sanabria / hooks.php
Created June 16, 2021 21:46 — forked from ashokmhrj/hooks.php
WooCommerce mnicart qty update
<?php
add_action('woocommerce_widget_shopping_cart_before_buttons','ask_woo_mini_cart_before_buttons' );
function ask_woo_mini_cart_before_buttons(){
wp_nonce_field( 'woocommerce-cart' );
?>
<div class="submit-button">
<input type="submit" class="button" name="update_cart" value="<?php esc_attr_e('Uppdatera varukorg', 'tidymerch'); ?>"/>
</div>
<?php
@Sanabria
Sanabria / woocommerce_simple_add_to_cart.js
Created June 16, 2021 22:44 — forked from mircian/woocommerce_simple_add_to_cart.js
Create a simple function which you can globally call to easily add a product to the cart by id.
<script type="text/javascript">
function m_wc_add_to_cart( product_id ) {
if ( 'undefined' === typeof wc_add_to_cart_params ) {
// The add to cart params are not present.
return false;
}
var data = {
product_id: product_id,
@Sanabria
Sanabria / loop-products-woocommerce.php
Created July 30, 2021 23:30 — forked from eliasfaical/loop-products-woocommerce.php
Sample products loop - Woocommerce
<ul class="products">
<?php
$args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'camisa' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<h2>Shoes</h2>
<li class="product">
<a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>">
<?php
woocommerce_show_product_sale_flash( $post, $product );
@Sanabria
Sanabria / functions.php
Created October 27, 2021 04:47 — forked from kloon/functions.php
WooCommerce 3.2: Add resend admin order email option that was removed
<?php
/**
* This adds back an option to resend the admin new order email from the order edit screen that was removed in WooCommerce 3.2
*/
/**
* Filter to add a new menu to the dropdown
*
* @param array $actions
* @return array
@Sanabria
Sanabria / functions.php
Created October 27, 2021 04:47 — forked from pacmanito/functions.php
WooCommerce - Add send customer order notes email option
<?php
/**
* This adds an option to send order notes email manually via order actions drop-down.
*/
/**
* Filter to add a new menu to the dropdown
*
* @param array $actions
* @return array
@Sanabria
Sanabria / functions.php
Created November 3, 2021 21:20 — forked from ronipl/functions.php
Woocommerce custom date picker field on checkout page
<?php
/**
* Add the custom field on checkout page
*/
add_action( 'woocommerce_after_checkout_billing_form', 'display_extra_fields_after_billing_address' , 10, 1 );
function display_extra_fields_after_billing_address () {
_e( "Delivery Date: ", "add_extra_fields");
?>
@Sanabria
Sanabria / editor-add-roles.php
Created November 9, 2021 22:25 — forked from chrisguitarguy/editor-add-roles.php
Allow users with the role editor to add users to WordPress -- but only subscribers.
<?php
/*
Plugin Name: Editors Add Users
Description: Allow editors to add user roles
Author: Christopher Davis
Author URI: http://www.christopherguitar.me
License: GPL2
*/
register_activation_hook( __FILE__, 'wpse42003_activation' );
@Sanabria
Sanabria / debug-scroll.md
Created January 19, 2022 05:05 — forked from cuth/debug-scroll.md
Find the elements that are causing a horizontal scroll. Based on http://css-tricks.com/findingfixing-unintended-body-overflow/

Debug Horizontal Scroll

(function (d) {
    var w = d.documentElement.offsetWidth,
        t = d.createTreeWalker(d.body, NodeFilter.SHOW_ELEMENT),
        b;
    while (t.nextNode()) {
        b = t.currentNode.getBoundingClientRect();
 if (b.right &gt; w || b.left &lt; 0) {
@Sanabria
Sanabria / functions.php
Created March 4, 2022 03:29 — forked from claudiosanches/functions.php
Wordpress Related Posts function
<?php
/**
* Related Posts.
*
* Usage:
* To show related by categories:
* Add in single.php <?php dfw_related_posts(); ?>.
* To show related by tags:
* Add in single.php <?php dfw_related_posts('tag'); ?>.