Skip to content

Instantly share code, notes, and snippets.

@wpweb101
wpweb101 / woo_vou_remove_dashboard_widget
Created June 22, 2018 04:20
WooCommerce Pdf Vouchers - Code to remove Voucher status Widget area from the admin dashboard
<?php
/**
* If you want to remove Voucher status Widget area from the admin then use below code
*/
function woo_vou_remove_dashboard_widget(){
global $woo_vou_admin;
remove_action( 'wp_dashboard_setup', array( $woo_vou_admin,'woo_vou_add_dashboard_widgets') );
}
@wpweb101
wpweb101 / woo_vou_preview_img.php
Last active May 29, 2018 11:38
WooCommerce PDF Vouchers - Remove preview image
<?php
/**
* Add filter to remove the preview image
*/
function woo_vou_preview_img_func( $img_file ) {
return '';
}
// Add filter to remove the preview image
add_filter('woo_vou_preview_img', 'woo_vou_preview_img_func' );
@wpweb101
wpweb101 / woo_vou_preview_pdf_title.php
Last active June 28, 2018 06:17
WooCommerce PDF Vouchers - Modify the "Preview" title and text on single product page
<?php // Do not add this if it's already added.
/**
* Modify the "Preview" title and text on single product page
*/
function woo_vou_preview_pdf_title_func( $preview_title ) {
return __('Preview Voucher', 'woovoucher');
}
// Add filter to modify the "Preview" title and text on single product page
add_filter('woo_vou_preview_pdf_title', 'woo_vou_preview_pdf_title_func' );
@wpweb101
wpweb101 / woo_vou_download_page_vou_download_btn.php
Last active August 23, 2021 11:07
WooCommerce Pdf Vouchers - Function to change Download button text, on downloads page
<?php
/**
* Handles to change download button text on downloads page
*/
function woo_vou_download_page_vou_download_btn_func($btn_name, $product_id, $product_name, $download_file, $voucher_number, $order_date){
return __("Download {$voucher_number} ( {$order_date} )", 'woovoucher');
}
add_filter( 'woo_vou_download_page_vou_download_btn', 'woo_vou_download_page_vou_download_btn_func', 10, 6 );
@wpweb101
wpweb101 / wpw-social-auto-poster
Created May 7, 2018 11:14
Code to remove products from scheduling
add_action('admin_init', 'wpw_unschedule_all_posts');
function wpw_unschedule_all_posts(){
$postargs = array(
'post_type' => 'product',
'posts_per_page'=> 50,
'meta_query' => array(
array(
'key' => WPW_AUTO_POSTER_META_PREFIX . 'schedule_wallpost',
'value' => '',
@wpweb101
wpweb101 / woo_vou_cstm_recipient_input_html.php
Last active May 4, 2018 13:37
WooCommerce Pdf Vouchers - Changing input recipient field to textarea
<?php
function woo_vou_cstm_recipient_input_html_func($html, $variation_id, $maxlength, $recipient_col_val, $recipient_column){
$prefix = WOO_VOU_META_PREFIX;
return '<textarea '. $maxlength .' class="woo-vou-recipient-details" id="'.$recipient_column.'-'.$variation_id.'" name="'. $prefix.$recipient_column.'['.$variation_id.']">'.$recipient_col_val.'</textarea>';
}
add_filter( 'woo_vou_cstm_recipient_input_html', 'woo_vou_cstm_recipient_input_html_func', 10, 5 );
?>
@wpweb101
wpweb101 / woo-vou-new-recipient-fields.php
Last active May 9, 2018 13:40
WooCommerce Pdf Vouchers - Function to create new Recipient Field (Recipient From name)
<?php
// Define constant
if( !defined( 'WOO_VOU_CSTM_RECIPIENT_FIELD' ) ) {
define( 'WOO_VOU_CSTM_RECIPIENT_FIELD', 'recipient_from_name' );
}
/**
* Add new Recipient field information in recipient details array
*/
@wpweb101
wpweb101 / woo_vou_get_date_format.php
Last active June 7, 2018 12:00
WooCommerce Pdf Vouchers - Added function to change date format
<?php // Do not add this if its already added in file
/*
* By default plugin use WordPress date and time format set in Settings -> General page
*
* If you want to change date format without changing general settings then you can use this code
*/
function woo_vou_change_date_format($format ) {
$format = 'F j, Y g:i a'; // June 7, 2018 11:39 am
return $format;
@wpweb101
wpweb101 / woo-vou-resolved-conflict-woo-pre-order.php
Last active July 5, 2018 11:44
WooCommerce PDF Vouchers - Added function to remove conflict with WooCommerce pre-orders
<?php // Do not add this if its already added.
/**
* WooCoommerce Pre Orders adding timepicker js in header and that's why WooCommerce product add/edit page not working.
*
* Solution is remove timepicker js and add it again but in footer
*/
function woo_vou_resolve_conflict_with_pre_orders( $hook_suffix ) {
if( in_array( $hook_suffix, array( 'post.php', 'post-new.php') ) ) {
@wpweb101
wpweb101 / woo_vou_voucher_date_format.php
Last active June 7, 2018 12:16
WooCommerce Pdf Vouchers - Added function to change the date format from Y-m-d to d-m-Y at all those places where PDF/CSV is downloaded
<?php
// Function use to change the date format from Y-m-d to d-m-Y at all those places where PDF/CSV is downloaded
function woo_vou_voucher_date_format_func($date_format){
/*
* If you are not using English as your site's default language, then we would recommend you to use fromats from 'Y-m-d' or 'd-m-Y'
* Also we recommend using dash('-') rather then other seperator
*/
$date_format = 'd-m-Y';
return $date_format;