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
// 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' ); |
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
function title_format( $content ) { | |
return '%s'; | |
} | |
add_filter( 'private_title_format', 'title_format' ); | |
add_filter( 'protected_title_format', 'title_format' ); |
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
function mmuk_scripts() { | |
wp_enqueue_script( 'retina-js', get_template_directory_uri() . '/js/retina.js', '', '', true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'mmuk_scripts' ); |
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_filter( 'delete_attachment', 'delete_retina_support_images' ); | |
function delete_retina_support_images( $attachment_id ) { | |
$meta = wp_get_attachment_metadata( $attachment_id ); | |
$upload_dir = wp_upload_dir(); | |
$path = pathinfo( $meta['file'] ); | |
foreach ( $meta as $key => $value ) { | |
if ( 'sizes' === $key ) { | |
foreach ( $value as $sizes => $size ) { | |
$original_filename = $upload_dir['basedir'] . '/' . $path['dirname'] . '/' . $size['file']; | |
$retina_filename = substr_replace( $original_filename, '@2x.', strrpos( $original_filename, '.' ), strlen( '.' ) ); |
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
function retina_support_create_images( $file, $width, $height, $crop = false ) { | |
if ( $width || $height ) { | |
$resized_file = wp_get_image_editor( $file ); | |
if ( ! is_wp_error( $resized_file ) ) { | |
$filename = $resized_file->generate_filename( $width . 'x' . $height . '@2x' ); | |
$resized_file->resize( $width * 2, $height * 2, $crop ); | |
$resized_file->save( $filename ); | |
$info = $resized_file->get_size(); |
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_filter( 'wp_generate_attachment_metadata', 'retina_support_attachment_meta', 10, 2 ); | |
function retina_support_attachment_meta( $metadata, $attachment_id ) { | |
foreach ( $metadata as $key => $value ) { | |
if ( is_array( $value ) ) { | |
foreach ( $value as $image => $attr ) { | |
if ( is_array( $attr ) ) | |
retina_support_create_images( get_attached_file( $attachment_id ), $attr['width'], $attr['height'], 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
function new_mail_from( $old ) { | |
return 'your.name@your-domain.co.uk'; | |
} | |
function new_mail_from_name( $old ) { | |
return 'Your Name'; | |
} | |
add_filter('wp_mail_from', 'new_mail_from'); | |
add_filter('wp_mail_from_name', 'new_mail_from_name'); |
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
From: "Example User" <email@example.com> |
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
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 ); |
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 echo copydate(); ?> [Your business name here]. |
OlderNewer