Skip to content

Instantly share code, notes, and snippets.

@franz-josef-kaiser
franz-josef-kaiser / upgdate.php
Created March 15, 2011 19:25
Update/Upgrade class for WordPress plugins in repos outside wp.org (Original Class: March 8, 2011 by Ronald Huereca)
<?php
//Plugin Upgrade Class
if ( !class_exists( 'PluginUpgrade' ) )
{
class PluginUpgrade
{
private $plugin_url = false;
private $remote_url = false;
@styledev
styledev / Parse Tweet Message to Link Entities
Last active March 24, 2016 16:24
This function will linkify your tweet messages from the Twitter API using include_entities=true
@webaware
webaware / force-ssl-url-scheme.php
Last active September 3, 2023 00:05
For WordPress, force the protocol scheme to be HTTPS when is_ssl() doesn't work, e.g. on a load-balanced server where _SERVER['HTTPS'] and _SERVER['SERVER_PORT'] don't indicate that SSL is being used. NB: may not be needed now, see SSL Insecure Content Fixer and HTTP Detection: https://ssl.webaware.net.au/https-detection/
<?php
/*
Plugin Name: Force SSL URL Scheme
Plugin URI: https://gist.github.com/webaware/4688802
Description: Force the protocol scheme to be HTTPS when is_ssl() doesn't work
Version: 1.0.0
Author: WebAware
Author URI: http://webaware.com.au/
@ref: http://wordpress.org/support/topic/ssl-insecure-needs-35-compatibility
@schpet
schpet / bootstrap-typeahead-hacks.coffee
Last active December 14, 2015 16:58
A collection of bootstrap-typeahead.js hacks: don't autocomplete and have the tab key move your selection (coffeescript & js versions)
$.fn.typeahead.Constructor::render = (items) ->
items = $(items).map (i, item) =>
i = $(@options.item).attr("data-value", item)
i.find("a").html @highlighter(item)
i[0]
@$menu.html items
this
@ChromeOrange
ChromeOrange / gist:5778923
Created June 14, 2013 01:59
Remove postcode requirement if billing or shipping country is Ireland
/**
* Remove postcode requirement if billing or shipping country is Ireland
* Add to your theme functions.php file
*/
add_action( 'woocommerce_checkout_process', 'custom_country_check' );
function custom_country_check(){
global $woocommerce;
@strangerstudios
strangerstudios / heartbeat-api-demo.php
Last active April 30, 2024 17:08
Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
<?php
/*
Plugin Name: Heartbeat API Demo
Plugin URI: http://www.strangerstudios.com/wp/heartbeat-api-demo
Description: Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
Version: .1
Author: strangerstudios
If logged in as a user and viewing the frontend of your website,
every 15 seconds you should see the following in your Javascript console:
@webaware
webaware / gist:6260468
Last active June 6, 2023 18:00
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
@richardW8k
richardW8k / button_filters.php
Last active April 29, 2022 18:37
convert the next, previous and/or submit button <input> to <button> and uses the input value to create the button text inside a <span>, this means you can set the button text by editing the form or page break settings.
<?php
/**
* Filters the next, previous and submit buttons.
* Replaces the forms <input> buttons with <button> while maintaining attributes from original <input>.
* @param string $button Contains the <input> tag to be filtered.
* @param object $form Contains all the properties of the current form.
* @return string The filtered button.
*/
add_filter( 'gform_next_button', 'input_to_button', 10, 2 );
add_filter( 'gform_previous_button', 'input_to_button', 10, 2 );
@kloon
kloon / functions.php
Created January 30, 2014 08:23
WooCommerce import Points & Rewards using Customer Order CSV Importer
<?php
add_action( 'woocommerce_api_points_rewards_custom_generator', 'wc_points_rewards_generate_custom_points' );
function wc_points_rewards_generate_custom_points() {
$customers = get_users( array(
'meta_key' => 'wc_points_balance'
) );
foreach ( $customers as $customer ) {
$points = get_user_meta( $customer->ID, 'wc_points_balance', true );
if ( $points > 0 ) {
if ( WC_Points_Rewards_Manager::increase_points( $customer->ID, $points, 'IMPORT' ) ) {
@spivurno
spivurno / gw-gravity-forms-unrequire-required-fields-usage.php
Last active June 13, 2022 20:04
Gravity Wiz // Gravity Forms Unrequire Required Fields for Speedy Testing
<?php
# Basic Usage
# requires that the user be logged in as an administrator and that a 'gwunrequire' parameter be added to the query string
# http://youurl.com/your-form-page/?gwunrequire=1
new GWUnrequire();
# Enable for All Users (Including Visitors)
# still requires the 'gwunrequire' parameter be added to the query string
new GWUnrequire( array(