Skip to content

Instantly share code, notes, and snippets.

View sebastianmoran-mainwp's full-sized avatar
🚀
Fast Lane Strategies: Turbocharging Your WordPress Website for Optimal Speed.

Sebastian Moran sebastianmoran-mainwp

🚀
Fast Lane Strategies: Turbocharging Your WordPress Website for Optimal Speed.
View GitHub Profile
@mglaman
mglaman / woocommerce-products.sql
Last active August 7, 2023 13:52
MySQL query for wooCommerce to export products.
SELECT product.ID as product_id, product.post_title as product_name, replace(product.post_content, '"', "'") as product_content, product_sku.meta_value as product_sku, product_price.meta_value as product_price, product_weight.meta_value as product_weight
FROM wp_posts as product
LEFT JOIN wp_postmeta as product_sku ON product.ID = product_sku.post_ID
LEFT JOIN wp_postmeta as product_price ON product.ID = product_price.post_ID
LEFT JOIN wp_postmeta as product_weight ON product.ID = product_weight.post_ID
WHERE (product.post_type = 'product' OR product.post_type = 'product_variation') AND product_sku.meta_key = '_sku' AND product_price.meta_key = '_price' AND product_weight.meta_key = '_weight'
ORDER BY product_id ASC
@ashfame
ashfame / woocommerce-category-images-from-product.php
Last active June 6, 2023 00:46
Use WooCommerce product image as its category image, if category image is missing
<?php
/**
* Plugin Name: WooCommerce Category Images Modification
* Plugin URI: http://blog.ashfame.com/?p=1117
* Description: Use product image as its category image on category archive pages (To override image for product category, upload one for that category and it will override)
* Author: Ashfame
* Version: 0.1.2
* Author URI: http://ashfame.com/
*/
@thisislawatts
thisislawatts / update.php
Last active May 25, 2021 02:54
Force database upgrade
<?php
class acf_update {
/*
* __construct
*
* A good place to add actions / filters
*
* @type functionac
@danieliser
danieliser / functions.php
Last active April 13, 2023 16:48
Fetch Active Install Count from WordPress Plugins API
<?php
function get_plugin_install_count( $plugin ) {
$api = plugins_api( 'plugin_information', array(
'slug' => 'popup-maker',
'fields' => array( 'active_installs' => true )
) );
if( ! is_wp_error( $api ) ) {
return $api->active_installs;
}
@danieliser
danieliser / functions.php
Last active April 13, 2023 16:48
Plugins API Active Install Count Shortcode for WordPress
<?php
function plugin_install_count_shortcode( $atts ) {
$a = shortcode_atts( array(
'plugin' => NULL,
), $atts );
if( ! $a['plugin'] ) {
return;
}
@mattclements
mattclements / function.php
Last active April 16, 2024 17:04
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active April 26, 2024 10:15
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@veselosky
veselosky / s3gzip.py
Last active May 8, 2023 21:42
How to store and retrieve gzip-compressed objects in AWS S3
# vim: set fileencoding=utf-8 :
#
# How to store and retrieve gzip-compressed objects in AWS S3
###########################################################################
#
# Copyright 2015 Vince Veselosky and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@bjornjohansen
bjornjohansen / run-wp-cron.sh
Last active September 17, 2023 21:12
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
#!/bin/bash
# Copyright © 2015 Bjørn Johansen
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
WP_PATH="/path/to/wp"
# Check if WP-CLI is available
if ! hash wp 2>/dev/null; then
@sc0ttkclark
sc0ttkclark / add-product-to-cart.php
Last active March 5, 2020 08:28 — forked from kloon/gist:2376300
WooCommerce Automatically add product to cart on site visit
<?php
/*
* This code goes into theme functions.php or a custom plugin
*/
/**
* Add product to cart on page load
*/
function add_product_to_cart() {