Skip to content

Instantly share code, notes, and snippets.

View OscarAbadFolgueira's full-sized avatar

Oscar Abad Folgueira OscarAbadFolgueira

View GitHub Profile
<?php
/**
* Plugin Name: WooCommerce Settings Tab Demo
* Plugin URI: https://gist.github.com/BFTrick/b5e3afa6f4f83ba2e54a
* Description: A plugin demonstrating how to add a WooCommerce settings tab.
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@OscarAbadFolgueira
OscarAbadFolgueira / functions.php
Created September 25, 2017 17:55 — forked from amitramani/functions.php
[WooCommerce] How to add Custom Fields to Products
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
woocommerce_wp_checkbox(
array(
'id' => '_no_free_shipping_checkbox',
/**
* Only display minimum price for WooCommerce variable products
**/
add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);
function custom_variation_price( $price, $product ) {
$price = '';
@OscarAbadFolgueira
OscarAbadFolgueira / gist:9b755d664d6d888593e5c42e7626fc50
Created September 22, 2017 19:10 — forked from icemancast/gist:d94c2fcfe5ccf073330aab4a7d55765b
WooCommerce: change "add to cart" button text by product type
<?php
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
* custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->get_type();
@OscarAbadFolgueira
OscarAbadFolgueira / edit-woocommerce-checkout-template.php
Created September 22, 2017 18:20 — forked from bekarice/edit-woocommerce-checkout-template.php
Add content and notices to the WooCommerce checkout - sample code
/**
* Each of these samples can be used - note that you should pick one rather than add them all.
*
* How to use WC notices: https://github.com/woothemes/woocommerce/blob/master/includes/wc-notice-functions.php#L96
* Tutorial: http://www.skyverge.com/blog/edit-woocommerce-templates/
**/
/**
* Add a content block after all notices, such as the login and coupon notices.
*
@OscarAbadFolgueira
OscarAbadFolgueira / wpinstall.sh
Created May 3, 2017 17:44 — forked from rutger1140/wpinstall.sh
WordPress install script bases on wp-cli - work in progress
#!/bin/bash
# Input database name
echo "---"
echo "wpinstall.sh - A WordPress installation shell script"
echo "by Rutger Laurman"
echo "---"
echo "- Requires WP-CLI, make sure you install that first (http://wp-cli.org/)"
echo "- Check file for configurations"
echo "- Downloads, configures, installs WordPress, default theme and plugins"
@OscarAbadFolgueira
OscarAbadFolgueira / gist:ae9382641f86b60da65f9c18e3b761f6
Created March 27, 2017 09:32 — forked from Tabrisrp/gist:13348dbcd2bbb0d9406f
WordPress customizer custom tinymce control
class Text_Editor_Custom_Control extends WP_Customize_Control
{
public $type = 'textarea';
/**
** Render the content on the theme customizer page
*/
public function render_content() { ?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php
<?php
// Remove Footer
remove_action('genesis_footer', 'genesis_do_footer');
remove_action('genesis_footer', 'genesis_footer_markup_open', 5);
remove_action('genesis_footer', 'genesis_footer_markup_close', 15);
@OscarAbadFolgueira
OscarAbadFolgueira / pe-customize-controls.css
Created March 2, 2017 22:03 — forked from OriginalEXE/pe-customize-controls.css
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
/**
* WP_Customize_Manager->add_setting(); // adds a new setting to the database
* WP_Customize_Manager->add_section(); // adds a new section (i.e. category/group) to the Theme Customizer page
* WP_Customize_Manager->add_control(); // creates an HTML control that admins can use to change settings.
* WP_Customize_Manager->get_setting(); // can be used to fetch any existing setting, in the event you need to modify something
*/
add_action( 'customize_register', 'my_customize_register' );
function my_customize_register( $wp_customize ) {