Skip to content

Instantly share code, notes, and snippets.

simongcc / css-table.scss
Created Sep 19, 2020
CSS Table example
View css-table.scss
.table {
// display: table;
width: 100%;
background: red;
.tbl-col-group {
display: table-column-group;
.tbl-col {
display: table-column;
simongcc / delete-all-woocommerce-products.php
Last active Sep 7, 2020 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
View delete-all-woocommerce-products.php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");

=INDEX('[Healh-Factor-product list_Health-lookup.xlsx]Sheet1'!$A:$A,MATCH(""&TRIM(E313)&"",'[Healh-Factor-product list_Health-lookup.xlsx]Sheet1'!$D:$D,),0)

simongcc /
Last active Aug 18, 2020
Bash batch file notes
for file in *.po; do
po-to-xls ${file%.*}.po -o ${file%.*}.xlsx
# $file is the file original name
# no extension: ${file%.*}.po
# s=/the/path/foo.txt
# echo "${s##*/}"
# foo.txt
View WP-Trace-Intercept-codes.php
if( strpos( $this->request, 'SQL_CALC_FOUND_ROWS' ) > 0 ) {
file_put_contents('/volumes/ram/test_'. time() .'.txt', $this->request);
simongcc / WordPress-Force-Post-ID.php
Created Apr 7, 2020
Force to change current page post object in WordPrress
View WordPress-Force-Post-ID.php
// $post = get_post( 33, OBJECT ); // use ID or
$post = get_page_by_path( $path ); // url path such as /people/staff or /people/staff/ both work
setup_postdata( $post ); // change global post object
$post->ID; // new ID
wp_reset_postdata(); // reset to original post data
View YouTube API — getting video thumbnail
Each YouTube video has 4 generated images. They are predictably formatted as follows:<insert-youtube-video-id-here>/0.jpg<insert-youtube-video-id-here>/1.jpg<insert-youtube-video-id-here>/2.jpg<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:<insert-youtube-video-id-here>/default.jpg
simongcc / custom-search-acf-wordpress.php
Created Mar 2, 2020 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
View custom-search-acf-wordpress.php
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
simongcc / wp-sample-add_post_type_support.php
Created Jan 21, 2020
Wordpress - add post type support to existing post types
View wp-sample-add_post_type_support.php
function sing_update_post_types_support() {
// add_post_type_support( 'events', 'post-formats' );
add_action( 'init', 'sing_update_post_types_support' );
simongcc / horizontal-infinite-carousel.html
Created Oct 30, 2019 — forked from dongyuwei/horizontal-infinite-carousel.html
infinite loop carousel(vertical or horizontal)
View horizontal-infinite-carousel.html
You can’t perform that action at this time.