This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Simple Code Obfuscator for PHP | |
* See: http://stackoverflow.com/questions/232736/code-obfuscator-for-php/3781356#3781356 | |
*/ | |
$infile=$_SERVER['argv'][1]; | |
$outfile=$_SERVER['argv'][2]; | |
if (!$infile || !$outfile) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE tablename | |
SET columnname = ELT(0.5 + RAND() * 6, 'value 1','value 2','value 3','value 4','value 5','value 6') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.resolveLocalFileSystemURI(filePath, function(fileEntry) { | |
fileEntry.file(function(fileObj) { | |
console.log("Size = " + fileObj.size); | |
console.log("Size = " + fileObj.fullPath); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Delete all products from WooCommerce DB | |
#http://wordpress.org/support/topic/remove-all-woocommerce-products | |
DELETE relations.*, taxes.*, terms.* | |
FROM wp_term_relationships AS relations | |
INNER JOIN wp_term_taxonomy AS taxes | |
ON relations.term_taxonomy_id=taxes.term_taxonomy_id | |
INNER JOIN wp_terms AS terms | |
ON taxes.term_id=terms.term_id | |
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Code for template file: | |
global $post; | |
if ( get_post_meta($post->ID, 'active_page_showzipform', true ) ) : | |
//Checkbox is checked... do somehting | |
endif; | |
//Code for functions.php --- Begin Custom Code for Page Metabox | |
function active_add_meta_box() { | |
add_meta_box( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Delete all WooCommerce Products from Wordpress Database | |
-- Thanks to http://www.kc-webdesign.co.uk/e_commerce/woocommerce-how-to-delete-all-products/ | |
DELETE relations.*, taxes.*, terms.* | |
FROM wp_term_relationships AS relations | |
INNER JOIN wp_term_taxonomy AS taxes | |
ON relations.term_taxonomy_id=taxes.term_taxonomy_id | |
INNER JOIN wp_terms AS terms | |
ON taxes.term_id=terms.term_id | |
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Usage | |
$myData = csvParse(file_get_contents('csv.file'),true); | |
function csvParse($in, $hasHeaders=false, &$returnHeadersList=NULL){ | |
$in .= "\n"; //NL required to allow reading when the last line hasn't been terminated. | |
$data=array(); //All Data here | |
$dataRow=array(); //Row of date being read | |
$dataInQuotes=false; //Is reading byte currently in Quotes? | |
$dataTemp = ''; //Storate of Value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
The best solution to make sure that your child theme's style.css loads after the parent theme's layout.css. | |
Then you can easily override the small things you need in the usual manner via style.css and upgrade the | |
parent theme without worry Here is some code that works for WooThemes products, which ensures that your | |
child theme css is always loaded after the parent child's layout.css | |
It belongs in the child theme's functions.php | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Reference/source: http://stackoverflow.com/a/1464155/933782 | |
* | |
* I want a short alphanumeric hash that’s unique and who’s sequence is difficult to deduce. | |
* I could run it out to md5 and trim the first n chars but that’s not going to be very unique. | |
* Storing a truncated checksum in a unique field means that the frequency of collisions will increase | |
* geometrically as the number of unique keys for a base 62 encoded integer approaches 62^n. | |
* I’d rather do it right than code myself a timebomb. So I came up with this. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ch = curl_init(); | |
$localfile = '/path/to/file.zip'; | |
$remotefile = 'filename.zip'; | |
$fp = fopen($localfile, 'r'); | |
curl_setopt($ch, CURLOPT_URL, 'ftp://ftp_login:[email protected]/'.$remotefile); | |
curl_setopt($ch, CURLOPT_UPLOAD, 1); | |
curl_setopt($ch, CURLOPT_INFILE, $fp); | |
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile)); |
OlderNewer