Skip to content

Instantly share code, notes, and snippets.

View rwkyyy's full-sized avatar
🏠
Working from home

RwkY rwkyyy

🏠
Working from home
View GitHub Profile
@nunomorgadinho
nunomorgadinho / archive_historial_orders.sql
Created April 23, 2021 08:08
SQL query to remove old orders in WooCommerce
DELETE
FROM wp_woocommerce_order_itemmeta
WHERE order_item_id IN (
SELECT order_item_id
FROM wp_woocommerce_order_items
WHERE order_id IN (
SELECT ID
FROM wp_posts
WHERE post_date < '2017-01-01'
)
@helgatheviking
helgatheviking / display-attributes-as-table.php
Created May 21, 2020 14:52
Display the WooCommerce product attributes as a table element via shortcode [display_attributes]
<?php
/**
* Attributes shortcode callback.
*/
function so_39394127_attributes_shortcode( $atts ) {
global $product;
if( ! is_object( $product ) || ! $product->has_attributes() ){
@RadGH
RadGH / wp-get-terms-straight-join.php
Last active March 13, 2022 03:41
WordPress get_terms replace INNER JOIN with STRAIGHT_JOIN using filters
<?php
// Step 1. Add the filters surrounding the get_terms (which should be used in your code)
add_filter( 'terms_clauses', 'rs_replace_inner_with_straight_joins', 20 );
$terms = get_terms( $args );
remove_filter( 'terms_clauses', 'rs_replace_inner_with_straight_joins', 20 );
// Step 2. Add to functions.php or similar:
function rs_replace_inner_with_straight_joins( $pieces, $taxonomies = null, $args = null ) {
global $wpdb;
@trey8611
trey8611 / import-optimizations.md
Last active April 17, 2024 17:40
WP All Import - Optimize your import speed.
<?php
/*
Plugin Name: CI Comment Rating
Description: Adds a star rating system to WordPress comments
Version: 1.0.0
Author: The CSSIgniter Team
Author URI: https://cssigniter.com/
*/
//Enqueue the plugin's styles.
@maddisondesigns
maddisondesigns / functions.php
Last active February 7, 2024 13:42
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@xadapter
xadapter / functoin.php
Last active July 13, 2020 15:26
Snippet to hide WooCommerce shipping methods on the cart/checkout page based on the destination country. Supports PluginHive Shipping Plugins: https://www.pluginhive.com/product-category/woocommerce-plugin/woocommerce-shipping/
add_filter('woocommerce_package_rates', 'wf_remove_shipping_options_for_particular_country', 10, 2);
function wf_remove_shipping_options_for_particular_country($available_shipping_methods, $package){
global $woocommerce;
//Config this array with country code and corresponding shipping methods to hide.
$country_list = array(
'CA' => array('wf_fedex_woocommerce_shipping','free_shipping'),
);
@MrJSdev
MrJSdev / functions.php
Last active August 11, 2020 12:51
The guide for this code is available at http://extracatchy.net/resize-wordpress-images-on-upload
<?php
/**resize on upload to the largest size in media setting */
function replace_uploaded_image($image_data) {
// if there is no large image : return
if (!isset($image_data['sizes']['large'])) return $image_data;
// path to the uploaded image and the large image
$upload_dir = wp_upload_dir();
@lukecav
lukecav / DNS Prefetch domains
Last active March 30, 2024 20:53
WP Rocket - Advanced Options Prefetch DNS requests examples
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
@beovulf
beovulf / if_else_lang.php
Created December 1, 2016 08:19
If else language wordpress (polylang)
<?php
$currentlang = get_bloginfo('language');
if($currentlang=="en-GB"):
?>
<?php elseif($currentlang=="pl-PL"): ?>
<?php endif; ?>