Skip to content

Instantly share code, notes, and snippets.

@adnan360
adnan360 / huge-sql-import.php
Created February 22, 2017 05:29
No limit database import (huge sql files import with automatic break and resume)
<?php
// Source: http://stackoverflow.com/a/25749714
if (empty($_GET['pass'])) { die('error'); }
// your config
$filename = 'yourGigaByteDump.sql';
$dbHost = 'localhost';
$dbUser = 'user';
$dbPass = '__pass__';
$dbName = 'dbname';
@adnan360
adnan360 / functions.php_snip
Created January 27, 2017 03:15
Woocommerce Subscriptions: get all subscribed products for a subscriber (find if a product is subscribed)
<?php
function has_an_active_subscriber( $product_id = null ){
// Empty array to store ALL existing Subscription PRODUCTS
$products_arr = array();
$products_subscr = get_posts( array(
'numberposts' => -1,
'post_status' => 'publish',
@adnan360
adnan360 / xampp-control-panel.desktop
Last active January 19, 2017 03:00
XAMPP GUI Control Panel shortcut for linux
[Desktop Entry]
Comment=Start and Stop XAMPP
Name=XAMPP Control Panel
Exec=gksudo python2 /opt/lampp/share/xampp-control-panel/xampp-control-panel.py
#Exec=gksudo /opt/lampp/manager-linux.run
Icon=/usr/share/icons/Humanity/devices/24/network-wired.svg
Encoding=UTF-8
Terminal=false
Name=XAMPP Control Panel
Comment=Start and Stop XAMPP
@adnan360
adnan360 / fixme_booked.php
Created January 5, 2017 01:51
Booked plugin - a fix plugin for the problem
<?php
/*
Plugin Name: fixme test for booked plugin
Using: place it in the plugins dir and activate from wp-admin
*/
if( ! function_exists( 'mplus_fix_query' ) )
{
function mplus_fix_query( $args ) {
// echo '<pre>'.print_r($args, true).'</pre>';
@adnan360
adnan360 / functions.php_snip
Created January 5, 2017 01:44
Booked plugin - test timestamp (fix)
$start_timestamp = strtotime('-1 second',strtotime($year.'-'.$month.'-'.$day.' 00:00:01'));
$end_timestamp = strtotime('+1 second',strtotime($year.'-'.$month.'-'.$day.' 23:59:58'));
@adnan360
adnan360 / functions.php_snip
Created January 5, 2017 01:42
Booked plugin - test timestamp
$start_timestamp = strtotime('-1 second',strtotime($year.'-'.$month.'-'.$day.' 00:00:00'));
$end_timestamp = strtotime('+1 second',strtotime($year.'-'.$month.'-'.$day.' 23:59:59'));
@adnan360
adnan360 / functions.php_snip
Created January 5, 2017 01:40
Booked plugin - range checking - test echo
echo "<p>Start time: $start_timestamp</p>";
echo "<p>End time:&nbsp; $end_timestamp</p>";
@adnan360
adnan360 / functions.php_snip
Created January 5, 2017 01:38
Booked plugin - $args array
$bookedAppointments = new WP_Query( apply_filters('booked_fe_date_content_query',$args) );
@adnan360
adnan360 / functions.php_snip
Created January 5, 2017 01:36
Booked plugin snip
$args = array(
'post_type' => 'booked_appointments',
'posts_per_page' => -1,
'post_status' => 'any',
'meta_query' => array(
array(
'key' => '_appointment_timestamp',
'value' => array( $start_timestamp, $end_timestamp ),
'compare' => 'BETWEEN'
)
@adnan360
adnan360 / test.php
Last active January 5, 2017 01:31
PHP mktime() test
<?php
echo mktime().'<br/>';
sleep(1);
echo mktime().'<br/>';
sleep(1);
echo mktime().'<br/>';
sleep(1);