Skip to content

Instantly share code, notes, and snippets.

View psorensen's full-sized avatar

Peter Sorensen psorensen

  • 10up
  • United States
View GitHub Profile
@psorensen
psorensen / Yoast_SEO_JS_fix
Created February 13, 2015 14:36
Yoast SEO JS Fix
function yst_clean(a){if(""==a||void 0==a)return"";try{a=jQuery("<div/>").html(a).text(),a=a.replace(/<\/?[^>]+>/gi,""),a=a.replace(/\[(.+?)\](.+?\[\/\\1\])?/g,"")}catch(b){}return a}function ptest(a,b){a=yst_clean(a),a=a.toLowerCase();var c=a.match(b);return null!=c?'<span class="good">Yes ('+c.length+")</span>":'<span class="wrong">No</span>'}function removeLowerCaseDiacritics(a){var b,c=[{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{ba
add_action('pmxi_attachment_uploaded', 'my_attachment_uploaded', 10, 3);
function my_attachment_uploaded($pid, $attid, $filepath){
$attachment = get_post($attid);
// do something with $attachment file
if (get_post($pid) == 'industry-resource') {
wp_update_post(array('ID' => $attid, 'guid' => str_replace('uploads/', 'uploads/indres/', $filepath)));
}
}
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed