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 | |
// improved version: https://gist.github.com/RadGH/31f16cd4705a2d8076021a9ad528f34f | |
// ---------- | |
// Example #1: HTML | |
$phone_number = '555.123.4567'; | |
echo format_phone( $phone_number ); |
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
/* | |
Based on: http://wordpress.stackexchange.com/questions/42652/#answer-42729 | |
These functions provide a simple way to interact with TinyMCE (wp_editor) visual editor. | |
This is the same thing that WordPress does, but a tad more intuitive. | |
Additionally, this works for any editor - not just the "content" editor. | |
Usage: |
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 | |
// UPDATE: Stefan from Stack Overflow has explained a better way to handle cart item data. | |
// See http://stackoverflow.com/a/32327810/470480 | |
// ---------------------- | |
/* | |
Instructions: |
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
// Converts a (user-pasted) string to a 2d array, utilizing line breaks and tabs. | |
function interpret_table( data ) { | |
var table = data.split("\n"); | |
for (i in table) { | |
table[i] = table[i].split("\t"); | |
} | |
return table; |
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
// EXAMPLE USAGE IN A COMMENT BELOW. | |
/* | |
Rad's Debug Console: | |
A safe-to-use JavaScript logging tool which can be disabled by setting window.error_log to false | |
@Thanks http://stackoverflow.com/questions/26554807 | |
log( [mixed] ) | |
log.__log( [mixed] ) | |
Displays the value of one or more arguments in the developer's console. |
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 | |
/* | |
* Overwrites the default environment in /wp-admin/includes/upgrade.php. | |
* | |
* Originally this function will: | |
* 1: Create a category titled "Uncategorized" | |
* 2: Create a post titled "Test Post" | |
* 3: Create a comment by "Mr WordPress" | |
* 4: Create a page called "Sample Page" | |
* 5: Create some widgets for the sidebar |
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
// Allows downloading the background image from the "Earth View from Google Maps" extension for Chrome: | |
// https://chrome.google.com/webstore/detail/earth-view-from-google-ma/bhloflhklmhfpedakmangadcdofhnnoh | |
// | |
// HOW TO USE: | |
// 1. Open a new tab to see your earth view, preferably something you want to download. | |
// 2. Open the javascript console (Ctrl+Shift+J). Note that the regular inspector may freeze due to the large data-uri, so you must go straight to the javascript console. | |
// 3. Paste the following code to the console, which will create a download link above the earth icon in the corner: | |
// 4. Image will open in a new tab when you click the link. You can then save it. | |
var link = document.createElement('a'); |
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
var ratingToInt = function( str ) { | |
// numstr = ' 18.6k ' | |
str = str.trim(); // "18.6k" | |
var number = parseFloat(str); // 18.6 | |
var letter = str.replace(/[^kmb]/g, '');//"k" | |
switch( letter ) { | |
case 'k': | |
number = number * 1000; |
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
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.3.2",function($,L){var ratingToInt=function(t){t=t.trim();var e=parseFloat(t),i=t.replace(/[^kmb]/g,"");switch(i){case"k":e=1e3*e;break;case"m":e=1e6*e}return parseInt(e)},ratingsGetValues=function(t){var e=t.children("li");if(e.length<3)return!1;var i={up:ratingToInt(e.eq(0).text()),down:ratingToInt(e.eq(1).text()),play:ratingToInt(e.eq(2).text())};return i.rating=(i.up-i.down)/i.up,i},updateList=function(){var t=jQuery("#search-results-list"),e=t.find("tr.mission-result-text");e.each(function(){var t=jQuery(this),i=t.find("ul.ratings");if(!(i.find("li.percent").length>0)){var a=ratingsGetValues |