Skip to content

Instantly share code, notes, and snippets.

View mcgregormedia's full-sized avatar

Andy McGregor mcgregormedia

View GitHub Profile
@mcgregormedia
mcgregormedia / mmwd_update_frontend_woocommerce_fields
Last active August 29, 2015 14:16
Add WooCommerce _visibility and _regular_price metakeys in WPUF form
// Update price and visibility
function mmwd_update_frontend_woocommerce_fields( $post_id, $form_id, $form_settings, $form_vars ){
// update _price depending on _sale_price or _regular_price
$_price = ( $_POST['_sale_price'] ) ? esc_html( $_POST['_sale_price'] ) : esc_html( $_POST['_regular_price'] );
update_post_meta( $post_id, '_price', $_price );
// update _visibility
update_post_meta( $post_id, '_visibility', 'visible' );
function title_format( $content ) {
return '%s';
}
add_filter( 'private_title_format', 'title_format' );
add_filter( 'protected_title_format', 'title_format' );
/**
* Show only free shipping option when available
*
* @param array $available_methods
*/
function show_only_free_shipping( $available_methods ) {
if( isset( $available_methods['free_shipping'] ) ) :
// Get Free Shipping array into a new array
<?php the_content(); ?>
<?php
$required_paragraphs = 3;
$content = apply_filters( 'the_content', $post->post_content );
if( substr_count ( $content, '<p>' ) > $required_paragraphs ){
$contents = explode( "</p>", $content );
$paragraphs = 1;
foreach( $contents as $content ){
echo $content;
if( $paragraphs == $required_paragraphs ){
/* Advert code here */
function mmuk_replace_howdy_message( $wp_admin_bar ) {
$my_account = $wp_admin_bar -> get_node( 'my-account' );
$newtitle = str_replace( 'Howdy,', 'Logged in as', $my_account->title );
$wp_admin_bar -> add_node( array(
'id' => 'my-account',
'title' => $newtitle,
) );
}
add_filter( 'admin_bar_menu', 'mmuk_replace_howdy_message',25 );