Consider supporting my work by purchasing the course this tutorial is a part of i.e. VSCode Power User →
- Make sure your
Local by FlyWheel
WordPress install is a custom install
Consider supporting my work by purchasing the course this tutorial is a part of i.e. VSCode Power User →
Local by FlyWheel
WordPress install is a custom install<?php | |
/** | |
* Insert an attachment from a URL address. | |
* | |
* @param string $url The URL address. | |
* @param int|null $parent_post_id The parent post ID (Optional). | |
* @return int|false The attachment ID on success. False on failure. | |
*/ | |
function wp_insert_attachment_from_url( $url, $parent_post_id = null ) { |
// Random terminal tip #1 | |
//You'll see this message if you git commit without a message (-m) | |
// You can get out of it with two steps: | |
// 1.a. Type a multi-line message to move foward with the commit. | |
// 1.b. Leave blank to abort the commit. | |
// 2. Hit "esc" then type ":wq" and hit enter to save your choice. Viola! | |
# Please enter the commit message for your changes. Lines starting | |
# with '#' will be ignored, and an empty message aborts the commit. |
<?php | |
// Source: http://goo.gl/qyLFbg | |
$html = '<img border="0" src="/images/image.jpg" alt="Image" width="100" height="100" />'; | |
preg_match( '@src="([^"]+)"@' , $html, $match ); | |
$src = array_pop($match); | |
// will return /images/image.jpg |
function formatBytes(bytes,decimals) { | |
if(bytes == 0) return '0 Bytes'; | |
var k = 1024, | |
dm = decimals || 2, | |
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | |
i = Math.floor(Math.log(bytes) / Math.log(k)); | |
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; | |
} | |
// Usage: |
afghanistan : Afghanistan | |
albania : Albania | |
algeria : Algeria | |
american_samoa : American Samoa | |
andorra : Andorra | |
angola : Angola | |
anguilla : Anguilla | |
antigua_and_barbuda : Antigua and Barbuda | |
argentina : Argentina | |
armenia : Armenia |
<?php | |
require_once("wp-load.php"); | |
add_action('http_api_debug', 'test_http_api_debug', 10, 5); | |
add_filter('oembed_remote_get_args', 'test_oembed_remote_get_args', 10, 2); | |
add_filter('oembed_fetch_url', 'test_oembed_fetch_url', 10, 3); | |
$embed_code = wp_oembed_get('http://vimeo.com/75343493'); |
/** | |
* Use this class to ensure Google Maps API javascript is loaded before running any google map specific code. | |
*/ | |
export class GoogleMapsApi { | |
/** | |
* Constructor set up config. | |
*/ | |
constructor() { | |
// api key for google maps |