Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Niloy Niloys7

🏠
Working from home
View GitHub Profile
View change_order_status_on_preorder_date.php
add_filter('change_order_status_on_preorder_date','bp_change_order_status',20,1);
function bp_change_order_status($status){
return 'processing';
}
@Niloys7
Niloys7 / hide_x_button.php
Created Feb 10, 2022
Hide Remove Button [x] from Specific product from WooCommerce Cart
View hide_x_button.php
add_filter( 'woocommerce_cart_item_remove_link', 'ns_cart_item_remove_link', 20, 2 );
/**
* @snippet Hide Remove Button [x] from Specific product from WooCommerce Cart
* @author Niloy , iamniloy.com
* @param $button_link
* @param $cart_item_key
* @return mixed
*/
function ns_cart_item_remove_link( $button_link, $cart_item_key ) {
//SET HERE your specific products IDs
@Niloys7
Niloys7 / preorder_avaiable_date_text.php
Created Aug 16, 2021
Filter for preorder available date text on single product page
View preorder_avaiable_date_text.php
add_filter('preorder_avaiable_date_text','bp_custom_available_date',10,1);
function bp_custom_available_date($text){
return '<span class="preorder-bp-single-date">'.$text.'</span>';
}
@Niloys7
Niloys7 / functions.php
Created Aug 9, 2021
Update preorder date programmatically for Variable products
View functions.php
add_action('wp_head','bp_preorder_script');
function bp_preorder_script() {
$args = array(
'post_type' => 'product_variation',
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
@Niloys7
Niloys7 / dcpt.php
Created Apr 17, 2021
//Delete all posts of a custom post type with its included post meta data and taxonomies by using wpdb
View dcpt.php
function deletePostType($postType = ''){
global $wpdb;
$result = $wpdb->query(
$wpdb->prepare("
DELETE posts,pt,pm
FROM {$wpdb->prefix}posts posts
LEFT JOIN {$wpdb->prefix}term_relationships pt ON pt.object_id = posts.ID
LEFT JOIN {$wpdb->prefix}postmeta pm ON pm.post_id = posts.ID
WHERE posts.post_type = %s
@Niloys7
Niloys7 / porto-theme-quickview.php
Last active Dec 29, 2020
Since Porto theme has there owned gallery markup that reason the quick view feature is not working properly with the "product gallery slider" . so we need to override the ajax function only for the quick view mode.to do this just copy the code from below and paste it into your child-theme/functions.php or create a custom plugin to add this code.
View porto-theme-quickview.php
<?php
add_action( 'init', 'cix_new_hooks');
function cix_new_hooks(){
remove_action( 'wp_ajax_porto_product_quickview', 'porto_product_quickview' );
remove_action( 'wp_ajax_nopriv_porto_product_quickview', 'porto_product_quickview' );
add_action( 'wp_ajax_porto_product_quickview', 'cix_porto_product_quickview' );
add_action( 'wp_ajax_nopriv_porto_product_quickview', 'cix_porto_product_quickview' );
}
View wp provision data
{
"plugins": [
"query-monitor",
"regenerate-thumbnails",
{
"slug": "envato-theme-check",
"source": "https://github.com/envato/envato-theme-check/archive/master.zip"
}
View Unyson Option TAB Structure
<?php
/*
http://manual.unyson.io/en/latest/options/introduction.html#content
*/
$options = array(
'tab_1' => array(
'title' => esc_html__('Logo Options', 'academic'),
'type' => 'tab',
'options' => array(
'heading' => array(
View utils.php
// Display Taxomonies
$terms = get_terms( 'fw-portfolio-category' ); // Taxomony Name
foreach ( $terms as $term ) {
// The $term is an object, so we don't need to specify the $taxonomy.
$term_link = get_term_link( $term );
// If there was an error, continue to the next term.
if ( is_wp_error( $term_link ) ) {
@Niloys7
Niloys7 / gist:17b88d36c1c38844a6cf2127c15dee63
Created Feb 24, 2017
Get Product Gallery Images - WooCommerce
View gist:17b88d36c1c38844a6cf2127c15dee63
<?php
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id )
{
//Get URL of Gallery Images - default wordpress image sizes
echo $Original_image_url = wp_get_attachment_url( $attachment_id );
echo $full_url = wp_get_attachment_image_src( $attachment_id, 'full' )[0];
echo $medium_url = wp_get_attachment_image_src( $attachment_id, 'medium' )[0];