Skip to content

Instantly share code, notes, and snippets.

@bacoords
bacoords / pull.sh
Created January 18, 2025 18:35
Pull production database and wp-content into your local environment with WP-CLI
#!/bin/bash
# Configuration variables - replace with your values
REMOTE_HOST="username@ip.address"
REMOTE_PATH="files"
LOCAL_PATH="wp-content"
# Database name
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
DB_BACKUP="wp_backup_${TIMESTAMP}.sql"
@wpeasy
wpeasy / DummyJSON_API.php
Last active October 28, 2025 06:08
Bricks Builder: : Query Loop anything from any API!
<?php
define("WPE_JSON_TRANSIENT_NAME", "wpe_dummyjson");
define("WPE_JSON_TRANSIENT_TTL", 60);
define("WPE_JSON_ENDPOINT_BASE", "https://dummyjson.com/");
/** Add query type to dropdown */
add_filter("bricks/setup/control_options", function ($control_options) {
// Add a new query loop type
$control_options["queryTypes"]["wpe_json"] = esc_html__(
"DummyJSON",
/**
* Adds "failed" status to Action Scheduler cleanup action.
*
* Default is "complete" and "canceled," leaving "failed" actions
* in the Action Scheduler to pile up indefinitely.
*
* Filter located in action-scheduler/classes/ActionScheduler_QueueCleaner.php
*
* @see https://wpcodebook.com/woocommerce-action-scheduler-cleanup-php/
*/
@hssktm
hssktm / Woo Fields
Last active October 28, 2024 11:41
Extract different woocommerce fields easily
function woo_field($property) {
$date_format = 'd - M - Y'; // Format Date
$info = null;
if (!in_array($property, ['cart_product_ids', 'cart_total_items', 'cart_total_price'])) {
global $product;
if (!$product) {
$product = wc_get_product(get_the_ID());
}
@liranop
liranop / expend shipping row
Last active August 11, 2023 05:58
Make shipping row in woocommerce cart and checkout to full width
/**
* @snippet Expend WooCommerce Shipping Row in Cart and Checkout
*/
add_action( 'wp_footer', 'expend_shipping_row_jscript', 9999 );
function expend_shipping_row_jscript() {
if ( is_cart() || is_checkout() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ) {
?>
<script type="text/javascript">
@fliedonion
fliedonion / seafile-ignore.txt
Last active November 4, 2025 05:35
My Seafile ignore
# put this file your ROOT of share folder.
## comments below are tips or examples
# # a regular file (put both)
# test-file
# **/test-file
#
# # a dir (put both)
# test-dir/
# **/test-dir/
#
@yankiara
yankiara / oxygen-pro-menu-mobile-accessibility.js
Last active February 16, 2022 01:54
Oxygen ProMenu mobile accessibility
jQuery(document).ready(function($) {
// Initialize roles and aria attributes
$('.oxy-pro-menu-list .menu-item-has-children > a').attr('aria-haspopup','true').attr('aria-expanded','false');
$('.oxy-pro-menu-list .sub-menu').each(function(){
$(this).attr('aria-label', $(this).prev('a').text());
});
if ( $('.oxy-pro-menu-mobile-open-icon').css('display') == 'none' ) {
@katsar0v
katsar0v / remove-not-needed-libraries.php
Created July 25, 2021 13:58
Optimize WooCommerce For Web Vitals
<?php
/**
* Disable WooCommerce block styles (front-end).
*/
function slug_disable_woocommerce_block_styles() {
if( function_exists( 'is_woocommerce') ) {
if( !is_woocommerce() && !is_cart() && !is_checkout() ) {
wp_dequeue_style( 'wc-block-style' );
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'woocommerce-layout' );
<?php
/**
* A Hack to generate mock WP Post objects from any arbitrary array
* A possible use case is to render a list of taxonomy terms using Oxygen Builder's repeater element,
* as the repeater allows only WP_Query as a source of data
*
* @author: Gagan S Goraya
* @link: https://gagangoraya.com
*
@xandl
xandl / woocommerce_custom_sale_price_based_on_user_role.php
Last active January 9, 2025 05:58
WooCommerce custom sale price based on role
<?php
/**
* Put this into your functions.php of your child-theme or custom plugin
* you can create the role with wp-cli by running `wp shell` and running the command:
* add_role('merchant','Merchant',array('read' => true, 'delete_posts' => false) );
*/
/**
* Step #1: create the field used to store the new sale_price for product_variation and for products
*/