Skip to content

Instantly share code, notes, and snippets.

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

Haroon Rasheed dancywritter

🏠
Working from home
View GitHub Profile
@dancywritter
dancywritter / repeater_array.php
Created November 6, 2020 17:42 — forked from luclemo/repeater_array.php
Creating objects using ACF repeater fields #wordpress #acf
<?php
// check if the repeater field has rows of data
if( have_rows('drop-down_menus') ) :
$array = array(); // empty array, must be declared outside of while loop
$i = 0; // incrementer
// loop through the rows of data and add to our array
while ( have_rows('drop-down_menus') ) : the_row();
@dancywritter
dancywritter / countries
Created February 22, 2021 07:45 — forked from kalinchernev/countries
Plain text list of countries
Afghanistan
Albania
Algeria
Andorra
Angola
Antigua & Deps
Argentina
Armenia
Australia
Austria
@dancywritter
dancywritter / gist:b156c6a1fbf44ed7cd9ffc12a8376fa7
Created March 11, 2021 18:42 — forked from wpmark/gist:9d5d2395cb01a2de0179
Check If WordPress Post is Older than X Days
<?php
/*******************************
* this will work in the loop
*******************************/
/* check if the posts publish date is older than 60 days */
if( strtotime( $post->post_date ) < strtotime('-60 days') ) {
/* post is older than 60 days - do something with it!! */
@dancywritter
dancywritter / functions.pnp
Created August 8, 2021 08:31 — forked from gmmedia/functions.php
Add featured image column to WP admin panel - posts AND pages
/**
* Add featured image column to WP admin panel - posts AND pages
* See: https://j0e.org/featured-image-admin/
*/
// Set thumbnail size
add_image_size( 'j0e_admin-featured-image', 60, 60, false );
// Add the posts and pages columns filter. Same function for both.
add_filter('manage_posts_columns', 'j0e_add_thumbnail_column', 2);
@dancywritter
dancywritter / lenura_empty_cart_before_add.php
Created September 23, 2021 23:31 — forked from viniciusrtf/lenura_empty_cart_before_add.php
WooCommerce Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
<?php
/**
* Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
*/
add_action ('woocommerce_add_to_cart', 'lenura_empty_cart_before_add', 0);
function lenura_empty_cart_before_add() {
global $woocommerce;
// Get 'product_id' and 'quantity' for the current woocommerce_add_to_cart operation
@dancywritter
dancywritter / QRLogo.php
Created December 6, 2021 12:27 — forked from NTICompass/QRLogo.php
QR Code + Logo Generator
<?php
/**
* QR Code + Logo Generator
*
* http://labs.nticompassinc.com
*/
$data = isset($_GET['data']) ? $_GET['data'] : 'http://labs.nticompassinc.com';
$size = isset($_GET['size']) ? $_GET['size'] : '200x200';
$logo = isset($_GET['logo']) ? $_GET['logo'] : FALSE;