Skip to content

Instantly share code, notes, and snippets.

@jmcausing
jmcausing / gist:5cd4122d3f24e9543d80556f8e476fe8
Created November 8, 2023 23:09
WP recommended resources, forums, or websites for further reading and continued learning.
Documentation/Resources:
- WordPress Codex: Official WordPress documentation providing extensive information and troubleshooting guides.
Link: https://codex.wordpress.org/
- WordPress Support Forums: Community-driven forums where users can ask questions and find solutions to various WordPress issues.
Link: https://wordpress.org/support/
- WPBeginner: Offers tutorials, tips, and resources for WordPress beginners and advanced users.
Link: https://www.wpbeginner.com/
@jmcausing
jmcausing / gist:a04a03b8ba451aacf4569beb4b7addc5
Created November 8, 2023 23:05
WordPress 500 Simulation
Creating plugins intentionally causing a 500 Internal Server Error is not a common practice due to the potential risks and impact on a live website. However, for educational purposes or testing on a local or staging site, you might create custom plugins that result in an error, simulating a 500 Internal Server Error.
Here are three basic examples of custom plugins that could potentially cause a 500 Internal Server Error:
### Plugin 1: PHP Fatal Error
Create a custom plugin with PHP code that causes a fatal error.
```php
<?php
/*
@jmcausing
jmcausing / gist:5860ecbbd5c885df414e0c8ee1559717
Created June 2, 2023 07:41
Shoptimizer - Add product to cart but disable the add-to-cart ajax (opens the cart side bar)
add_action( 'after_setup_theme', 'cg_remove_default_cart_drawer', 99 );
function cg_remove_default_cart_drawer() {
remove_action( 'shoptimizer_before_site', 'shoptimizer_header_cart_drawer', 5 );
add_action( 'shoptimizer_before_site', 'shoptimizer_header_cart_drawer_updated', 5 );
}
if ( ! function_exists( 'shoptimizer_header_cart_drawer_updated' ) ) {
/**
* Display Header Cart Drawer
*
@jmcausing
jmcausing / gist:3172104e28cca6fd5329d6f6c73a4663
Created May 31, 2023 08:47
WooCommerce - Add additional sorting by sales (ASC) - exclude out of stock
// Add sorting option to sort products by sales (ASC) on the shop page
function add_custom_product_sorting_option( $options ) {
$options['sales_asc'] = __( 'Sort by Sales (ASC)', 'text-domain' );
return $options;
}
add_filter( 'woocommerce_get_catalog_ordering_args', 'add_custom_product_sorting_option' );
// Define sorting option arguments for sorting by sales (ASC) and excluding out-of-stock products
function set_custom_product_sorting_option( $sort_args ) {
if ( isset( $_GET['orderby'] ) && 'sales_asc' === $_GET['orderby'] ) {
@jmcausing
jmcausing / gist:377321eb2760eb350b573ea011a8dcd2
Created May 31, 2023 08:46
WooCommerce - Add additional sorting by sales (ASC)
// Add sorting option to sort products by sales (ASC) on the shop page
function add_custom_product_sorting_option( $options ) {
$options['sales_asc'] = __( 'Sort by Sales (ASC)', 'text-domain' );
return $options;
}
add_filter( 'woocommerce_get_catalog_ordering_args', 'add_custom_product_sorting_option' );
// Define sorting option arguments for sorting by sales (ASC)
function set_custom_product_sorting_option( $sort_args ) {
if ( isset( $_GET['orderby'] ) && 'sales_asc' === $_GET['orderby'] ) {
@jmcausing
jmcausing / gist:af1be9cbfd25ddbca9f51107382890d3
Created May 29, 2023 10:23
CommerceKit - add to cart without opening the sidebar cart automatically.
add_action( 'after_setup_theme', 'cg_remove_default_cart_drawer', 99 );
function cg_remove_default_cart_drawer() {
remove_action( 'shoptimizer_before_site', 'shoptimizer_header_cart_drawer', 5 );
add_action( 'shoptimizer_before_site', 'shoptimizer_header_cart_drawer_updated', 5 );
}
if ( ! function_exists( 'shoptimizer_header_cart_drawer_updated' ) ) {
/**
* Display Header Cart Drawer
*
@jmcausing
jmcausing / gist:b0f9d5132e5b35bcae7266367eaae969
Created December 25, 2022 01:07
Serial port 1 (console)
Serial port 1 (console) output for instance-1-eng-2819
[=3h[=3hCSM BBS Table full.
BdsDxe: loading Boot0003 "ubuntu" from HD(15,GPT,75740168-3E29-49A1-B76C-768ECDE1FF97,0x2800,0x35000)/\EFI\ubuntu\shimx64.efi
BdsDxe: starting Boot0003 "ubuntu" from HD(15,GPT,75740168-3E29-49A1-B76C-768ECDE1FF97,0x2800,0x35000)/\EFI\ubuntu\shimx64.efi
UEFI: Attempting to start image.
Description: ubuntu
FilePath: HD(15,GPT,75740168-3E29-49A1-B76C-768ECDE1FF97,0x2800,0x35000)/\EFI\ubuntu\shimx64.efi
OptionNumber: 3.
vagrant@causingdesigns:~/trellis$ ansible-playbook deploy.yml -e env=staging -e site=staging-rosellejoycausing.kinsta.cloud --limit=kinsta_staging
/usr/local/lib/python2.7/dist-packages/cryptography/__init__.py:39: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
CryptographyDeprecationWarning,
PLAY [Ensure necessary variables are defined] *******************************************************************************************************************************
[WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin
(<ansible.plugins.callback./home/vagrant/trellis/lib/trellis/plugins/callback/vars.CallbackModule object at 0x7f891b69c990>): 'AnsibleUnicode' object has no attribute
'get_groups'
skipping: no hosts matched
jQuery(document).ready(function ($) {
// Create contents -- START
$( ".wcg_submit" ).click(function() {
post_type = jQuery('select.wgc_post_type').val();
qty = jQuery('.wcg_count').val();
data = {
"action": "wcg_start_generate",
/// This is your ajax handler called to generate contents file
function wcg_start_generate_function() {
// Retrieve data from ajax
if( isset( $_POST[ "post_type" ] ) ) {
$post_type = $_POST[ "post_type" ];
$quantity = $_POST[ "post_qty" ];