Skip to content

Instantly share code, notes, and snippets.

@koko-ng
koko-ng / fix.php
Last active March 16, 2024 14:51
Synchronize Woocommerce memberships with linked subsciptions
<?php
$user_membership_ids = new \WP_Query( array(
'post_type' => 'wc_user_membership',
'post_status' => wc_memberships_get_user_membership_statuses( false ),
'fields' => 'ids',
'nopaging' => true,
'suppress_filters' => 1,
'meta_query' => array(
'relation' => 'OR',
array(
@koko-ng
koko-ng / pre-ssh.php
Created July 28, 2021 22:16
Automatically install wp-cli on first connection
<?php
/**
* Automatically install wp-cli on remote hosts if absent
*
* @author koko-ng <koko@kokong.info>
* @package koko-ng/wp-cli-config
*/
WP_CLI::add_hook(
'before_ssh',
@koko-ng
koko-ng / functions.php
Last active October 17, 2017 16:47 — forked from yratof/functions.php
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_oembed_data( $video_uri ) {
//second false skip ACF pre-processcing
$url = get_field('videos', false, false);
//get wp_oEmed object, not a public method. new WP_oEmbed() would also be possible
$oembed = _wp_oembed_get_object();
//get provider
$provider = $oembed->get_provider($url);