Skip to content

Instantly share code, notes, and snippets.

@pmgarman
pmgarman / flashsale.php
Created March 15, 2019 16:02
Old code for WC 2.x to set a flash sale price on all products.
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Check if WP_CLI exists, and only extend it if it does
if ( defined( 'WP_CLI' ) && WP_CLI && ! class_exists( 'CP_CLI' ) ) {
/**
* Class CP_CLI
*/
<?php
/*
* Plugin Name: Remove crazy counts slowing down my dashboard
* Plugin URI: https://pmgarman.me
* Description: Those comment counts are such a pain when you have a lot of comments
* Author: Patrick Garman
* Author URI: https://pmgarman.me
* Version: 1.0.0
* License: GPLv2
*/
<?php
function pmgarman_custom_wc_thankyou_action( $order_id = 0 ) { ?>
<script>
var leadNumber = '<?php echo $order_id; ?>';
</script>
<?php }
add_action( 'woocommerce_thankyou', 'pmgarman_custom_wc_thankyou_action' );
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
# Apache .htaccess
RedirectMatch 301 ^/wp-content/uploads/(.*) http://livewebsite.com/wp-content/uploads/$1
# Nginx
location ~ ^/wp-content/uploads/(.*) {
rewrite ^/wp-content/uploads/(.*)$ http://livewebsite.com/wp-content/uploads/$1 redirect;
}
@pmgarman
pmgarman / vhost
Created November 26, 2013 22:41
Reverse Proxy Nginx > Ghost w/SSL
server {
listen 80;
listen 443 ssl;
server_name dev.pmgarman.me;
root /home/pmgarman/dev.pmgarman.me;
ssl_certificate /home/pmgarman/ssl/dev.pmgarman.me/dev_pmgarman_me.selfsigned.crt;
ssl_certificate_key /home/pmgarman/ssl/dev.pmgarman.me/dev_pmgarman_me.key;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
@pmgarman
pmgarman / imagerows
Created August 8, 2013 18:48
Example image rows shortcodes creating three rows of images.
[imagerow images="http://pmgarman.me/wp-content/uploads/2013/08/DSCN1989-1024x768.jpg"]
[imagerow images="http://pmgarman.me/wp-content/uploads/2013/08/DSCN2052-1024x768.jpg,http://pmgarman.me/wp-content/uploads/2013/08/DSCN2018-1024x768.jpg,http://pmgarman.me/wp-content/uploads/2013/08/DSCN2041-1024x768.jpg"]
[imagerow images="http://pmgarman.me/wp-content/uploads/2013/08/DSCN2022-1024x768.jpg,http://pmgarman.me/wp-content/uploads/2013/08/DSCN1874-1024x768.jpg"]
@pmgarman
pmgarman / delete.sql
Created August 1, 2013 22:35
How to find and delete orphaned product variations from WooCommerce sites.
DELETE o FROM `wp_posts` o
LEFT OUTER JOIN `wp_posts` r
ON o.post_parent = r.ID
WHERE r.id IS null AND o.post_type = 'product_variation'
@pmgarman
pmgarman / site.pp
Created July 30, 2013 17:35
Puppet > Nginx > Ghost Proxy
class do-stuff {
include apt
include nginx
exec { 'first update':
command => '/usr/bin/apt-get update'
}
apt::ppa { 'ppa:chris-lea/node.js':
require => Exec['first update'],
@pmgarman
pmgarman / install-puppet-agent.sh
Created July 28, 2013 15:43
Install Puppet agent on Ubuntu 12.04 Precise Pangolin
wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
dpkg -i puppetlabs-release-precise.deb
apt-get update
apt-get install puppet
puppet resource service puppet ensure=running enable=true