Skip to content

Instantly share code, notes, and snippets.

View tanatip's full-sized avatar
🏠
Working from home

Tanatip Siriprathum tanatip

🏠
Working from home
View GitHub Profile
@woogists
woogists / wc-query-woocommerce-active.php
Last active March 1, 2023 14:02
[Theming Snippets] Query whether WooCommerce is activated
/**
* Check if WooCommerce is activated
*/
if ( ! function_exists( 'is_woocommerce_activated' ) ) {
function is_woocommerce_activated() {
if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; }
}
}
@scottparry
scottparry / functions.php
Created February 21, 2018 07:04
Enqueue Google fonts in WordPress theme
/**
* Enqueue custom fonts using protocol relative URL.
*
* Syntax: wp_enqueue_style( $handle, $src, $deps, $ver, $media );
* Ensure $handle is unique to prevent conflicts with plugins
*
* Note(s): The pipe (|) operator is used to load multiple typefaces in a single call. We also only load the weights we want * by comma seperating them, instead of loading every available weight.
*/
function theme_prefix_fonts()
{
<?php
/**
* Plugin Name: YOUR PLUGIN NAME
*/
include( dirname( __FILE__ ) . '/lib/requirements-check.php' );
$your_plugin_requirements_check = new YOUR_PREFIX_Requirements_Check( array(
'title' => 'YOUR PLUGIN NAME',
'php' => '5.4',
@damiencarbery
damiencarbery / cmb2-repeater-demo-display-data.php
Last active July 9, 2024 10:42
CMB2 Repeater Demo - a simple example
<?php
add_filter( 'the_content', 'crd_append_post_links' );
function crd_append_post_links( $content ) {
if ( is_page() ) {
$post_links_data = get_post_meta( get_the_ID() );
if ( isset( $post_links_data[ 'blog_group' ][ 0 ] ) ) {
$blog_list = maybe_unserialize( $post_links_data[ 'blog_group' ][ 0 ] );
$posts_list = '<ul>';
foreach ( $blog_list as $post_info ) {
@ControlledChaos
ControlledChaos / README.md
Last active August 5, 2022 15:00
Add data attributes to WordPress image links for use with Fancybox.

Fancybox Data Attributes to Images & Galleries

WordPress Snippet

@joshuadavidnelson
joshuadavidnelson / get-responsive-image.php
Last active August 7, 2023 13:16
Generate a img tag for responsive images in WordPress
<?php
/**
* Get the responsive image.
*
* @param string $image_id
* @param string $image_size optional
*
* @return string $output
*/
function get_responsive_image( $image_id, $size = 'medium' ) {
@daggerhart
daggerhart / wp-get-taxonomy-hierarchy.php
Last active December 18, 2022 03:22
WordPress function to get a complete taxonomy hierarchy of terms in PHP
<?php
/**
* Recursively get taxonomy and its children
*
* @param string $taxonomy
* @param int $parent - parent term id
* @return array
*/
function get_taxonomy_hierarchy( $taxonomy, $parent = 0 ) {
@chranderson
chranderson / nvmCommands.js
Last active April 19, 2025 05:20
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@lukecav
lukecav / add-to-cart.php
Created July 31, 2016 02:57
Display Product Variations in the Shop Loop
<?php
/**
* Loop Add to Cart
*
* This template can be overridden by copying it to yourtheme/woocommerce/loop/add-to-cart.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and