This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (function_exists('register_sidebar')) { | |
register_sidebar(array( | |
'before_widget' => '<li id="%1$s" class="widget %2$s">', | |
'after_widget' => '</li>', | |
'before_title' => '<h2 class="widgettitle">', | |
'after_title' => '</h2>', | |
)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// filter the Gravity Forms button type | |
add_filter("gform_submit_button", "form_submit_button", 10, 2); | |
function form_submit_button($button, $form){ | |
// The following line is from the Gravity Forms documentation - it doesn't include your custom button text | |
// return "<button class='button' id='gform_submit_button_{$form["id"]}'>'Submit'</button>"; | |
// This includes your custom button text: | |
return "<button class='button' id='gform_submit_button_{$form["id"]}'>{$form['button']['text']}</button>"; | |
} | |
// Oops this strips important stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WooCommerce Ajax Handlers | |
* | |
* Handles AJAX requests via wp_ajax hook (both admin and front-end events) | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
/** Frontend AJAX events **************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* http://www.codemyownroad.com/add-currency-code-suffix-prices-woocommerce/ | |
// Location: add to functions.php | |
// Output: displays $0.00 AUD on all pages | |
function addPriceSuffix($format, $currency_pos) { | |
switch ( $currency_pos ) { | |
case 'left' : | |
$currency = get_woocommerce_currency(); | |
$format = '%1$s%2$s ' . $currency; | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp_enqueue_scripts', 'pt_like_it_scripts' ); | |
function pt_like_it_scripts() { | |
if( is_single() ) { | |
wp_enqueue_style( 'like-it', trailingslashit( plugin_dir_url( __FILE__ ) ).'css/like-it.css' ); | |
if (!wp_script_is( 'jquery', 'enqueued' )) { | |
wp_enqueue_script( 'jquery' );// Comment this line if you theme has already loaded jQuery | |
} | |
wp_enqueue_script( 'like-it', trailingslashit( plugin_dir_url( __FILE__ ) ).'js/like-it.js', array('jquery'), '1.0', true ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); | |
add_action( 'woocommerce_single_product_summary', 'itl_woocommerce_template_single_add_to_cart', 30 ); | |
/* | |
* replace WooCommerce add-to-cart button with download link when product is downloadable & free | |
*/ | |
function itl_woocommerce_template_single_add_to_cart() { | |
global $product; | |
if ( $product->is_downloadable('yes') ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $product; | |
$attachment_ids = $product->get_gallery_attachment_ids(); | |
foreach( $attachment_ids as $attachment_id ) | |
{ | |
//Get URL of Gallery Images - default wordpress image sizes | |
echo $Original_image_url = wp_get_attachment_url( $attachment_id ); | |
echo $full_url = wp_get_attachment_image_src( $attachment_id, 'full' )[0]; | |
echo $medium_url = wp_get_attachment_image_src( $attachment_id, 'medium' )[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Display variations dropdowns on shop page for variable products | |
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' ); | |
function woo_display_variation_dropdown_on_shop_page() { | |
global $product; | |
if( $product->is_type( 'variable' )) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- What is Functions File in WordPress? --> | |
<!-- Functions file commonly known as functions.php file is a WordPress theme file. | |
It comes with all free and premium WordPress themes. | |
The purpose of this file is to allow theme developers to define theme features and functions. This file acts just like a WordPress plugin and can be used to add your own custom code snippets in WordPress. | |
You would find many of these code snippets on websites like https://deardorffassociatesweb.wordpress.com/ with instructions telling you to add this code in your theme’s functions.php file or a site-specific WordPress plugin. | |
Now you may be thinking what’s the difference between a site-specific WordPress plugin and functions.php file? Which one is better? |
OlderNewer