This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Navigate to web root and run: | |
``` | |
wp post delete $(wp post list --post_type='shop_order' --post_status=wc-pending --format=ids --force) --force | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Check if current archive is a category listing or if it is the lowest level category, in which case, list products. Useful for having different styles for products and categories. | |
``` | |
/** | |
* Determine if a listing page us a category with subcategories, or a category with products | |
* @return string | |
*/ | |
function get_wc_list_type() { | |
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); // get current term | |
$parent = get_term($term->parent, get_query_var('taxonomy') ); // get parent term | |
$children = get_term_children($term->term_id, get_query_var('taxonomy')); // get children |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
/** | |
* Display categories or products view | |
* | |
* If the display type (set in product categories in WP) is set to "standard", add a div with categories so that it can | |
* be styled. Else, use the set display type value as the class | |
*/ | |
add_action('woocommerce_before_shop_loop', function(){ | |
$current_term = get_queried_object(); | |
$display_type = get_term_meta( $current_term->term_id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
// Initialize modules | |
// Importing specific gulp API functions lets us write them below as series() instead of gulp.series() | |
const { src, dest, watch, series, parallel } = require('gulp'); | |
// Importing all the Gulp-related packages we want to use | |
const sourcemaps = require('gulp-sourcemaps'); | |
const sass = require('gulp-sass'); | |
const concat = require('gulp-concat'); | |
const uglify = require('gulp-uglify'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
<?php | |
/** | |
* Add generic tracking code to all pages except "Thank you" page | |
*/ ?> | |
<!-- Global site tag (gtag.js) - Google Ads: 734634785 --> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXXXXX"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); gtag('config', 'AW-XXXXXXXXXXX'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
/* | |
Plugin Name: Bulk Update Post | |
Description: Quick plugin to update posts with whatever you want | |
Author: James Wills | |
*/ | |
add_action('init','update_stuff'); | |
function update_stuff(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Check if the user is logged in as admin so we can test data dumps: | |
``` | |
$current_user = wp_get_current_user(); | |
if (user_can( $current_user, 'administrator' )) { | |
echo '<pre>'; | |
print_r($my_dump); | |
echo '</pre>'; | |
} | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Differences between MySQL and MongoDB | |
Selecting records from the customer table: | |
``` | |
MySQL: SELECT * FROM customer | |
MongoDB: db.customer.find() | |
``` | |
Inserting records into the customer table: | |
``` | |
MySQL: INSERT INTO customer (cust_id, branch, status) VALUES ('appl01', 'main', 'A') |