Skip to content

Instantly share code, notes, and snippets.

@stkdr
stkdr / Redux-required-arg-exampes.php
Created Sep 19, 2017 — forked from dovy/Redux-required-arg-exampes.php
Example of the required attribute for the Redux Framework.
View Redux-required-arg-exampes.php
<?php
$options = array(
'required' => array('id','equals',array( 1,3 ) ) // Multiple values
);
$options = array(
'required' => array('id','equals', array( 1 ) ) // Single value
);
@stkdr
stkdr / add-wordpress-settings-page.php
Created Sep 19, 2017 — forked from DavidWells/add-wordpress-settings-page.php
WordPress :: Add Settings Page with All Fields
View add-wordpress-settings-page.php
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@stkdr
stkdr / add-to-cart.php
Created Sep 21, 2017 — forked from Jplus2/add-to-cart.php
Add quantity button and ajax functionality to add to cart button on product archive page.
View add-to-cart.php
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@stkdr
stkdr / gist:60214f8e17bc5a69d9333caed2894c5e
Created Sep 21, 2017 — forked from webaware/gist:6260468
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/
View gist:60214f8e17bc5a69d9333caed2894c5e
<?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');
@stkdr
stkdr / gist:6825f25c27b0d6784f6d91cd3767cd93
Created Sep 25, 2017 — forked from mohammadmursaleen/gist:9622098e43afdab6025e
Adding custom fields above WOOCOMMERCE add to cart button
View gist:6825f25c27b0d6784f6d91cd3767cd93
<?php
// To add custom data above add to cart button in woocommerce
// step 1
add_action('wp_ajax_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
add_action('wp_ajax_nopriv_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
function wdm_add_user_custom_data_options_callback()
View google_font.php
<?php
/*
Register Fonts
*/
function studio_fonts_url() {
$font_url = '';
/*
Translators: If there are characters in your language that are not supported
by chosen font(s), translate this to 'off'. Do not translate into your own language.
@stkdr
stkdr / gist:1bbcdc1a4ff6087fa746e2d03d9f7a46
Created Nov 21, 2017
Disable Redux activation redirect
View gist:1bbcdc1a4ff6087fa746e2d03d9f7a46
add_action( 'redux/construct', 'radium_remove_as_plugin_flag' );
/**
* Remove plugin flag from redux. Get rid of redirect
*
* @since 1.0.0
*/
function radium_remove_as_plugin_flag() {
ReduxFramework::$_as_plugin = false;
}
View gist:b203a8faae0a97ce94f2f271cd6cfa7b
/**
* Escape translated strings with:
*/
__( ‘Hello world’, ‘text-domain’ ); _e( ‘Hello world’, ‘text-domain’ );.
/**
* If there is no HTML use:
*/
esc_html__( ‘Hello world’, ‘text-domain’ ); esc_html_e( ‘Hello world’, ‘text-domain’ );
@stkdr
stkdr / creatSpanTag.php
Created Dec 28, 2017 — forked from mdjwel/creatSpanTag.php
Convert a special sign to HTML Tag
View creatSpanTag.php
<?php
function Convert_to_htmlTag($string, $tagSign='|') {
$firstSign = strpos($string, $tagSign);
$lastSign = strpos($string, $tagSign, $firstSign+1);
$strArray = str_split($string);
$replaceSigns = array($firstSign=>'<span class="se-s-color">', $lastSign=>'</span>');
$replaceSigns = array_replace($strArray, $replaceSigns);
echo implode($replaceSigns);
}