Skip to content

Instantly share code, notes, and snippets.

@daigo75
daigo75 / gist:5141929
Last active December 14, 2015 20:09 — forked from linc/gist:700805
<?php
/**
* @copyright Vanilla Forums Inc.
* @license GNU GPL2
*/
/**
* Instantiating this class will store current user's ID from cookie as $this->UserID.
*
* Usage
@daigo75
daigo75 / dateFormat.js
Last active October 31, 2019 22:53 — forked from micah1701/dateFormat.js
Replicate PHP's native date() formatting in JavaScript for many common format types
/**
* Return a formated string from a date Object mimicking PHP's date() functionality
*
* format string "Y-m-d H:i:s" or similar PHP-style date format string
* date mixed Date Object, Datestring, or milliseconds
*
*/
function date_format(format,date){
if(!date || date === "")
@daigo75
daigo75 / example-complex-product-meta-fields.php
Created May 5, 2024 20:22 — forked from mattsherman/example-complex-product-meta-fields.php
Example how to handle "packed" meta values in WooCommerce's new product editor
<?php
use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\GroupInterface;
add_filter(
'woocommerce_rest_prepare_product_object',
function ( $response, $post ) {
$custom_regular_prices_encoded = get_post_meta( $post->get_id(), '_custom_regular_prices', true );
$custom_regular_prices = json_decode(