Skip to content

Instantly share code, notes, and snippets.

View danmeade's full-sized avatar

Dan Meade danmeade

View GitHub Profile
@webaware
webaware / add-to-cart.php
Last active October 9, 2024 00:33 — forked from mikejolley/functions.php
WooCommerce purchase page add-to-cart with quantity and AJAX, by customising the add-to-cart template in the WooCommerce loop. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* Loop Add to Cart -- with quantity and AJAX
* requires associated JavaScript file qty-add-to-cart.js
*
* @link http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
* @link https://gist.github.com/mikejolley/2793710/
*/
// add this file to folder "woocommerce/loop" inside theme
@JiveDig
JiveDig / acf_front_end_edit.php
Last active July 24, 2024 18:03
ACF front end post editing
<?php
/**
* Check if user is logged in and is post author
* Setup functions for front end post editing
* @author Mike Hemberger
* @link http://thestizmedia.com/front-end-post-editing-with-acf-pro/
* @uses Advanced Custom Fields Pro
* @uses Sidr
*/
@JiveDig
JiveDig / is-current-users-post.php
Last active January 20, 2021 16:19
Helper function to check if the currently logged in user is the author of a specific post, by post ID
<?php
/**
* Helper function to check if a user is the author of a specific post
*
* @author Mike Hemberger
* @link http://thestizmedia.com/front-end-post-editing-with-caldera-forms/
* @param int $post_id Post ID
* @return bool
*/
@bekarice
bekarice / wc-prevent-checkout-for-cart-with-specific-category.php
Last active June 29, 2023 20:32
Prevents checkout if the WooCommerce cart only contains items from a specific category
<?php // only copy this line if needed
/**
* Renders a notice and prevents checkout if the cart
* only contains products in a specific category
*/
function sv_wc_prevent_checkout_for_category() {
// set the slug of the category for which we disallow checkout
$category = 'clothing';
@yanknudtskov
yanknudtskov / gravityforms-auto-trigger-next-previous.js
Last active October 7, 2021 20:03
jQuery example to trigger next/previous buttons on GravityForms #gravity-forms
// This is the initial GravityForms binding, it will be lost upon a page change with next/previous
// Thus we make a bind on gform_page_loaded event also
if( jQuery('.custom-form').length > 0 ) {
jQuery('.gfield_radio input[type=radio]').bind("click", function() {
//console.log('Clicked: ' + jQuery( this ).closest('.gform_page').find('.gform_page_footer .gform_next_button.button') );
jQuery(this).closest('.gform_page').find('.gform_page_footer .gform_next_button.button').click();
});
}
jQuery(document).bind('gform_page_loaded', function(event, form_id, current_page){
<html>
<head>
<title>API Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var accessToken = "<your agent's client access token>";
var baseUrl = "https://api.api.ai/v1/";
@yanknudtskov
yanknudtskov / wp-reset-password-emails.php
Created February 5, 2018 05:36
WordPress Password Reset mails filter, because gmail sometimes removes the link, this fixes it. #passwordreset #wpmail
<?php
add_filter('retrieve_password_message', 'yanco_custom_password_reset', 99, 4);
function yanco_custom_password_reset($message, $key, $user_login, $user_data ) {
$message = __('Someone has requested a password reset for the following account:') . "<br><br>";
$message .= network_home_url( '/' ) . "<br><br>";
$message .= sprintf(__('%s'), $user_data->user_email) . "<br><br>";
$message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "<br><br>";
$message .= __('To reset your password use the link below:') . "<br><br>";
@yanknudtskov
yanknudtskov / wc-remove-zoom-galleries.php
Created March 9, 2018 12:04
Remove Zoom from WooCommerce Galleries
<?php
/*
* Remove Zoom from WooCommerce Galleries
*/
add_action( 'after_setup_theme', 'yanco_after_setup_theme', 100 );
function yanco_after_setup_theme() {
remove_theme_support( 'wc-product-gallery-zoom' );
}
@yanknudtskov
yanknudtskov / functions.php
Last active October 7, 2021 20:25
Remove Heading from the WordPress Editor #tinymce #removeheadings
<?php
/**
* Remove the h4 to h6 tag from the WordPress editor.
*
* @param array $settings The array of editor settings
* @return array The modified edit settings
*/
function remove_headings_from_editor( $settings ) {
// Default as example
// $settings['block_formats'] = 'Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre;';
@yanknudtskov
yanknudtskov / admin-column-user-registered-date.php
Created April 19, 2018 14:52
Add a column to the Users overview in WordPress Admin to display the registration date
<?php
/*
* Create a column. And maybe remove some of the default ones
* @param array $columns Array of all user table columns {column ID} => {column Name}
*/
add_filter( 'manage_users_columns', 'yanco_modify_user_table' );
function yanco_modify_user_table( $columns ) {
// unset( $columns['posts'] ); // maybe you would like to remove default columns
$columns['registration_date'] = 'Registreret'; // add new