Create Bookmarklet (browser bookmark that executes Javsacript) to copy a given text to Clipboard.
This is the base javascript:
(function (text) {
var node = document.createElement('textarea')
var selection = document.getSelection()
<?php | |
/** | |
* A pretty version of "print_r" function | |
* | |
* @param Array|stdClass $obj | |
* @param string $title Optional. | |
* @param bool $collapse Optional. | |
* @return string Type returned. | |
*/ |
<?php | |
/** | |
* There is not a hard and fast rule to check if the | |
* current page is the blog page (the page you set in | |
* the settings to display blog posts). This is what the | |
* documentation says: "There is no conditional tag for the blog page." | |
* | |
* Read the full section here: https://codex.wordpress.org/Conditional_Tags | |
* | |
* Not sure if there is another way to achieve this! |
<?php | |
/** | |
* Function to check for more than one | |
* array keys of a long/nested associative array. | |
* | |
* i.e, instead of doing this $var['key1']['key2'] (which will result in undefined | |
* notice if the key/index does not exist) you can do this isset_key($var, 'key1', 'key2') | |
* | |
* @param array $var Array variable |
<!-- Transparent GIF Image Favicon --> | |
<link rel="icon" href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" type="image/gif"> | |
<!-- Black GIF Image Favicon --> | |
<link rel="icon" href="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=" type="image/gif"> | |
<!-- Transparent PNG Image Favicon --> | |
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" type="image/png"> | |
<?php | |
/** | |
* This function retrieves post meta using a custom $wpdb query. There are two reasons for this approach. | |
* 1. When doing get_post_meta to query all the meta keys it returns an array or array | |
* 2. This function also queries for LIKE fields. i.e, get_post_meta2(1, 'first_name, last_name, hobby_%') | |
* | |
* TODO: distinct meta_key, meta_value | |
* | |
*/ |
<?php | |
/** | |
* wpadminbar toggle for conveniently showing/hiding adminbar from a URL parameter. | |
* | |
* USAGE: | |
* 1. Upload wp-adminbar-toggler.php to theme | |
* 2. Include this file in theme's functions.php | |
* - require_once( get_stylesheet_directory() . '/wp-adminbar-toggler.php' ); | |
* 3. Use ?adminbar=1 in the URL to show adminbar. Use ?adminbar=0 in the URL to |
<?php | |
/** | |
* Get next n number of dates from a specified date | |
* | |
* @param Integer $n Number of dates | |
* @param String $from Now or the from date | |
* @param Boolean $exclude_weekends Exclude weekends | |
* @return Array | |
*/ |
<?php | |
/** | |
* This function should be only used in AJAX templates & AJAX callbacks. | |
* | |
* | |
* Use cases of this function are when you need to get a URL param inside a | |
* PHP template rendered through AJAX or an AJAX callback that needs access | |
* to the parent URL param (From where the ajax call was made). i.e, | |
* calling ajax.php from http://exmple.com/my-page/?param1=v111¶m2=v222. | |
* A header of URLPARAMS needsto be added to the request headers. i.e, using |
<?php | |
/** | |
* WP_DEBUG toggle for conveniently turning on and off from the a URL param "debug" | |
* Its good when working on a staging site where you need debug functionality on/off | |
* | |
* usage: | |
* | |
* Include this file in wp-config.php (include 'wp-debug.php';) | |
* Make sure to comment out all these constants in wp-config.php | |
* |