Skip to content

Instantly share code, notes, and snippets.

@bplv112
bplv112 / functions.php
Created January 21, 2026 21:06
Elementor Loop grid block compatibility with woocommerce filters
<?php
//Fixes issue with loop grid block -- not working with the woocommerce product sort filters like price low to high / high to low.
add_action( 'pre_get_posts', 'modify_elementor_loop_grid_on_woo_archives', 20 );
function modify_elementor_loop_grid_on_woo_archives( $wp_query ) {
// Check if this is a Loop Grid query in WooCommerce context
if ( ! is_admin() &&
! $wp_query->is_main_query() &&
is_woocommerce() &&
( is_shop() || is_product_category() || is_product_tag() ) ) {
@bplv112
bplv112 / ctct-generator.php
Created November 3, 2022 16:44
Generator for creating instances of cc woo plugin.
<?php
/*
Plugin Name: CTCT Generator
Plugin URI: https://webdevstudios.com/
Author: Biplav Subedi
Version: 1.0.0
Author URI: https://webdevstudios.com/
**/
add_action( 'init', function(){
@bplv112
bplv112 / command.sh
Last active May 2, 2022 19:52
Delete multiple terms / categories in WP VIP
vip @appname.develop -- wp term list category --exclude=123,223,234 --field=term_id --format=csv | xargs -I % sh -c 'echo "vip @appname.develop -- wp term delete category % " >> commands.sh '
//Then run.
$ chmod +x commands.sh
$ ./commands.sh
We can't make this file beautiful and searchable because it's too large.
age job marital education default balance housing loan contact day month duration campaign pdays previous poutcome y
58 management married tertiary no 2143 yes no unknown 5 may 261 1 -1 0 unknown no
44 technician single secondary no 29 yes no unknown 5 may 151 1 -1 0 unknown no
33 entrepreneur married secondary no 2 yes yes unknown 5 may 76 1 -1 0 unknown no
47 blue-collar married unknown no 1506 yes no unknown 5 may 92 1 -1 0 unknown no
33 unknown single unknown no 1 no no unknown 5 may 198 1 -1 0 unknown no
35 management married tertiary no 231 yes no unknown 5 may 139 1 -1 0 unknown no
28 management single tertiary no 447 yes yes unknown 5 may 217 1 -1 0 unknown no
42 entrepreneur divorced tertiary yes 2 yes no unknown 5 may 380 1 -1 0 unknown no
add_action('hustle_module_main_content_allowed_html', 'prefix_allow_scripts_hustle', 10, 2);
function prefix_allow_scripts_hustle( $allowed_html, $module )
{
$allowed_html['script'] = array(
'src' => array(),
);
return $allowed_html;
}
add_action( 'forminator_after_field_render', function(){
echo do_shortcode( '[wd_hustle id="your-embed-id" type="embedded"/]' );
});
add_action( 'init', 'wpmud_set_current_user', -1 );
function wpmud_set_current_user(){
if( 0 !== get_current_user_id() && ! did_action( 'set_current_user' ) ) {
do_action( 'set_current_user' );
}
}
/**
* Generate the PKCE hash
*
* @since 4.0.3
*
* @return string $hash - code verifier
*/
public function get_pkce(){
return str_replace( '=', '', base64_encode( hash( 'sha256', $this->_get_pkce_verifier() ) ) ); // phpcs:ignore -- ignore base64_encode warning
}
@bplv112
bplv112 / functions.php
Last active June 3, 2019 18:53
Hustle Compatibility with Geodirectory
<?php
add_action( 'wp_super_duper_widget_init', 'hustle_geo_directory_compat', 10, 2 );
function hustle_geo_directory_compat( $options, $class ){
$hustle = array( 'hustle_slidein', 'hustle_popup', 'hustle_embedded', 'hustle_sshare', 'hustle_settings' );
if( isset( $_GET['page'] ) && in_array( $_GET['page'], $hustle, true ) ){
remove_action( 'media_buttons', array( $class, 'shortcode_insert_button' ) );
}
}
.main-navigation li a:hover,
.main-navigation li.current-menu-item > a,
.main-navigation li.current_page_item > a,
.main-navigation li:hover > a {
background: inherit;
color: #222222;
}
.main-navigation li a:hover::before,
.main-navigation li.current-menu-item > a::before,