Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
helgatheviking / functions.php
Last active August 29, 2015 14:18
WooCommerce Name Your Price: Filter price input field to not show suggested/minimum prices
function woocommerce_nyp_price_input_no_price( $html, $product_id, $prefix ) {
// only get the posted price (price submitted on add-to-cart) otherwise NULL
$price = WC_Name_Your_Price_Helpers::get_posted_price( $product_id, $prefix );
return sprintf( '<input id="nyp%s" name="nyp%s" type="text" value="%s" size="6" title="nyp" class="input-text amount nyp-input text" />', $prefix, $prefix, WC_Name_Your_Price_Helpers::format_price( $price ) );
;
}
add_filter( 'woocommerce_get_price_input', 'woocommerce_nyp_price_input_no_price', 10, 3 );
@helgatheviking
helgatheviking / functions
Last active August 29, 2015 14:18
WooCommerce Name Your Price: Make NYP field required
add_filter( 'woocommerce_add_to_cart_validation', 'woocommerce_nyp_make_field_required', 10, 5 );
function woocommerce_nyp_make_field_required( $passed, $product_id, $quantity, $variation_id = '', $variations= '' ) {
if( $variation_id )
$product_id = $variation_id;
// skip if not a nyp product - send original status back
if ( ! WC_Name_Your_Price_Helpers::is_nyp( $product_id ) ){
return $passed;
@helgatheviking
helgatheviking / functions.php
Created July 30, 2015 18:37
Ninja Forms AWeber: Suppress Errors
/*
* Submit form even if user is already subscribed to AWeber List
*
* @param $msg - current message from Ninja Forms for AWeber
* @param $error_code - null, placeholder for when AWeber gets error codes
* @param $error_message - original message from AWeber
* @param $subscriber - array of info about the subscriber submitted via form
* -- nb the form's ID can be found in $subscriber['form_id']
* @param $list_id the list ID
*/
@helgatheviking
helgatheviking / wpalchemy-tinymce-template.php
Created February 11, 2012 03:01 — forked from mamouneyya/wpalchemy-tinymce-template.php
Repeatable and sortable TinyMCE fields for WP Alchemy class
<?php while($mb->have_fields_and_multi('GROUP-NAME')): ?>
<?php $mb->the_group_open(); ?>
<p class="update-warning">Remember, you must save the page for the sort order to take effect.</p>
<?php $metabox->the_field('CONTENT-FIELD'); ?>
<label for="<?php $metabox->the_name(); ?>">FIELD LABEL</label>
<div class="customEditor">
<textarea rows="10" cols="50" name="<?php $mb->the_name(); ?>" id="<?php $mb->the_name(); ?>"><?php $mb->the_value(); ?></textarea>
</div>
@helgatheviking
helgatheviking / editor_meta.php
Created February 15, 2012 18:35 — forked from bicyclista/wpalchemy wp_editor()
wpalchemy metaboxes VS. wordpress wp_editor()
<div class="my_meta_control">
<?php $mb->the_field('test_editor');
$settings = array(
'textarea_rows' => '10',
'media_buttons' => 'false',
'tabindex' =>2
);
@helgatheviking
helgatheviking / flexslider.css
Created April 13, 2012 19:57
Show attachments as flexslider carousel on single posts
/*
* jQuery FlexSlider v1.8
* http://www.woothemes.com/flexslider/
*
* Copyright 2012 WooThemes
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
/* Browser Resets */
<?php
/**
* Content Extensions
*
* @package ThematicCoreLibrary
* @subpackage ContentExtensions
* @todo revisit docblock desciptions & tags
*/
@helgatheviking
helgatheviking / nmr-session-roles.php
Created October 13, 2015 17:42
Hide custom menu items based on session variables
<?php
/*
Plugin Name: Nav Menu Roles + Session Roles
Plugin URI: http://www.kathyisawesome.com/449/nav-menu-roles/
Description: Hide custom menu items based on session variables
Version: 1.0.0
Author: Kathy Darling
Author URI: http://www.kathyisawesome.com
License: GPL-3.0
@helgatheviking
helgatheviking / functions.php
Created November 29, 2015 07:19
Add multiple wp_editor() inputs to a single metabox. Save as single meta value.
/**
* Adds a box to the main column on the Post and Page edit screens.
*/
function myplugin_add_meta_box() {
$screens = array( 'post', 'page' );
foreach ( $screens as $screen ) {
add_meta_box(
@helgatheviking
helgatheviking / functions.php
Created July 7, 2013 15:41
Example of a working WP_User_Query search by simple user meta using Simple User Listing In this example I am searching for users by the meta field "billing_city"
<?php
/**
* Place this in your theme's functions.php file
* Or a site-specific plugin
*
*/
// Switch the WP_User_Query args to a meta search
function kia_meta_search( $args ){