Skip to content

Instantly share code, notes, and snippets.

View ontiuk's full-sized avatar

Stephen Betley ontiuk

View GitHub Profile
@ontiuk
ontiuk / woocommerce-select2-selectwoo-remove
Last active September 2, 2024 04:54
Woocommerce Remove Select2 / SelectWoo
// Add to your theme's functions.php file. De-queues Select2 styles & scripts. Useful to keep Boostrap form control formatting
/**
* Remove Woocommerce Select2 - Pre WC 3.2.1-ish
*/
function woo_dequeue_select2() {
if ( class_exists( 'woocommerce' ) ) {
wp_dequeue_style( 'select2' );
wp_deregister_style( 'select2' );
@ontiuk
ontiuk / ipress-rd2-additional-footer-sidebars
Created February 21, 2018 13:10
iPress RD2 - Config - Additional footer sidebars
@ontiuk
ontiuk / wordpress-nav-remove-li-attr
Created February 20, 2018 00:44
WordPress - Nav - Remove injected list item attributes
/**
* Themify menu links
*
* - Trim injected classes
*/
function theme_nav_link( $classes, $item ) {
// Tidy up li classes
if ( ( $key = array_search( 'menu-item-type-post_type', $classes ) ) !== false ) { unset($classes[$key]); }
if ( ( $key = array_search( 'menu-item-type-custom', $classes ) ) !== false ) { unset($classes[$key]); }
@ontiuk
ontiuk / ipress-rd2-config-jquery-v2
Created February 19, 2018 12:15
iPress RD2 - Config - Update jQuery to latest v2
// Contained within /inc/config.php. Modify default settings
// Dequeue default v1 jQuery, requeue jquery-migrate, add external cdn reference to jQuery v2. Load in header (true)
// Set up scripts - filterable array. See definitions for structure
$ipress_scripts = [
// Core scripts: [ 'script-name', 'script-name2' ... ]
'undo' => [ 'jquery' ],
// Core scripts: [ 'script-name', 'script-name2' ... ]
@ontiuk
ontiuk / php-array-to-csv-function
Created August 19, 2017 08:20
Array to CSV with PHP
/**
* Array to CSV
*/
function array2csv( $array) { 
// Check input
if ( !is_array( $array ) || count( $array ) == 0 ) {  return null; } 
// Buffer output
ob_start(); 
@ontiuk
ontiuk / php-get-remote-image-dimensions-curl
Created August 18, 2017 19:58
Get Remote Image Dimensions With PHP and cURL - GetImageSize Alternative
<?php
/** 
* Retrieve remote image dimensions 
* - getimagesize alternative 
*/
/**
* Get Image Size 
@ontiuk
ontiuk / php-convert-json-to-array
Created August 18, 2017 19:07
Convert jSON object to XML with PHP
<?php
/** 
* Convert jSON object to XML
*/
// jSON object
$json = '{"China":["Guangzhou","Fuzhou","Beijing","Baotou","Hohhot","Guiyang","Yinchuan","Nanjing","Changzhou","Chuzhou","Hefei","Jinan","Qingdao","Harbin","Zhaodong","Taiyuan","Xian","Xianyang","Shenzhen","Nanning","Zhengzhou","Xinxiang","Luohe","Luoyang","Chaoyang","Xingyi","Foshan","Haikou","Chengdu","Dongguan","Mingzhou","Chongqing","Zhuhai","Kunming","Wuhan","Xiling","Huizhou","Jiangmen","Shantou","Changxiacun","Zhongshan","Lhasa","Nanchang","Tianjin","Shanghai","Hebei","Shijiazhuang","Quanzhou","Putian","Xiamen","Chengyang","Zhangzhou","Sanming","Nanping","Baoding","Langfang","Yantai","Binzhou","Lanzhou","Yueqing","Zhongxin","Zhoushan","Hangzhou","Ningbo","Wenzhou","Changchun","Fuyang","Jieshou","Anqing","Wuhu","Shishi","Shishi","Weitang","Shenyang","Changsha","Yongjiawan","Lengshuijiang","Shijiazhuang","Xuchang","Suzhou","Xuzhou","Taizhou","Nanyang","Xinhua","Ürümqi","Yanan Beilu","Baotao","Macao","Wuxi","Yangzhou","Baiyin","Tongren","Kunshan
@ontiuk
ontiuk / wordpress-scheduled-posts
Created January 3, 2017 13:43
WordPress Scheduled Posts
<?php
// Set future post status
$args = array(
'post_type' => 'post',
'post_status' => 'future'
);
// Process Query
$scheduled = new WP_Query( $args );
@ontiuk
ontiuk / wordpress-default-loop
Created January 3, 2017 13:40
WordPress Default Loop
<?php if ( have_posts() ) : ?>
<?php while( have_posts() ) : the_post() ?>
<!-- Post Content Here -->
<?php endwhile ?>
<?php else : ?>
<!-- Content If No Posts -->
<?php endif ?>
@ontiuk
ontiuk / wordpress-pre-get-terms
Created December 28, 2016 13:24
WordPress: Taxonomy Term Meta Drill Down With Pre_Get_Terms
add_action( 'pre_get_terms', 'filter_pre_get_terms', 10, 2 );
/** 
* Filter WP_Term_Query meta query 
* - a better drill down for filtering term meta data 
* - keeps pagination in line with term count 
* - used in term edit page 
* @param   object  $query  WP_Term_Query 
*/