Skip to content

Instantly share code, notes, and snippets.

View ashub1n's full-sized avatar

Alex Shubin ashub1n

View GitHub Profile
@ashub1n
ashub1n / dl-file.php
Last active August 29, 2015 14:06 — forked from hakre/dl-file.php
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+
@ashub1n
ashub1n / add_query
Last active August 29, 2015 14:18
Page rewrite
<?php
function add_query_vars($aVars) {
$aVars[] = "locname"; // query slug
return $aVars;
}
function add_rewrite_rules2($aRules) {
$aNewRules = array('location/([^/]+)/?$' => 'index.php?pagename=location&locname=$matches[1]');
$aRules = $aNewRules + $aRules;
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@ashub1n
ashub1n / woocommerce-export-product-attributes-and-categories
Created October 8, 2015 00:06 — forked from haroldkyle/woocommerce-export-product-attributes-and-categories
This SQL script allows us to export woocommerce items (both single products and variable products) alongside their attributes and parent>child product categories. You can change values in the mapped parent categories ('Cards' or 'pa_attribute_cards' etc in my case) to suit your need. I wrote this to facilitate importing of woocommerce items into…
select distinct
# uncomment these rows for debugging
# p.ID,
# v.ID,
if( isnull(vm_sku.meta_value), pm_sku.meta_value, vm_sku.meta_value ) as 'sku',
p.post_title,
# need to cast prices to decimal because the datatype is not enforced otherwise
@ashub1n
ashub1n / script.sh
Last active February 8, 2018 08:22
mysql to oracle
#!/bin/bash
echo "start"
user=root
pass=root
database=centent_db_dev
o_user=OR_AD
o_pass=or_ad
o_database=or
o_user_upper=OR_AD
path="$(pwd)/mod_bk.sql"