- https://jwt.io/
- https://blog.pusher.com/build-rest-api-laravel-api-resources/
- https://stackoverflow.com/questions/33723033/single-sign-on-flow-using-jwt-for-cross-domain-authentication
- https://stackoverflow.com/questions/33900667/how-to-implement-logout-in-a-jwt-based-single-sign-on-authentication-architectur
- https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
- https://jcubic.wordpress.com/2014/06/20/cross-domain-localstorage/
- https://blog.zok.pw/web/2015/10/21/3rd-party-cookies-in-practice/
- https://gist.github.com/pbojinov/8965299
- https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage
| <div class="row"> | |
| <div class="col-md-2 col-sm-2 col-xs-2"> | |
| <p><button class="btn btn-primary btn-sm" id="map-address-btn"><span>Find It</span></button></p> | |
| </div><!-- .col --> | |
| <div class="col-md-10 col-sm-10 col-xs-10"> | |
| <div class="panel panel-default"> | |
| <div class="panel-heading">Location Response</div> | |
| <div class="panel-body"> | |
| <p>Enter Address: <input id="location-address" type="text" class="form-control" placeholder="Street, City, State"/</p> | |
| <p>Map:</p><div id="map-canvas" style="height: 400px;"></div> |
Using the REST API to upload a file to WordPress is
quite simple. All you need is to send the file in a
POST-Request to the wp/v2/media route.
There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:
| <!doctype html> | |
| <title>Site Maintenance</title> | |
| <style> | |
| body { text-align: center; padding: 150px; } | |
| h1 { font-size: 50px; } | |
| body { font: 20px Helvetica, sans-serif; color: #333; } | |
| article { display: block; text-align: left; width: 650px; margin: 0 auto; } | |
| a { color: #dc8100; text-decoration: none; } | |
| a:hover { color: #333; text-decoration: none; } | |
| </style> |
| <?php | |
| /** | |
| * Post view Count | |
| */ | |
| remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); | |
| function wpb_set_post_views($postID) { | |
| $count_key = 'wpb_post_views_count'; | |
| $count = get_post_meta($postID, $count_key, true); | |
| if($count==''){ | |
| $count = 0; |
| URL="http://stackoverflow.com/" | |
| # store the whole response with the status at the and | |
| HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST $URL) | |
| # extract the body | |
| HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') | |
| # extract the status | |
| HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') |
This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247
Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book
I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!
A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.
Recently I was asked to generate PDF invoices for an online shop. I looked at various PHP PDF generators, but wasn't particularly impressed with any of them.
Then I found (via Stack Overflow) a command-line HTML-to-PDF convertor called wkhtmltopdf, which uses WebKit (the same layout engine as Safari and Google Chrome) and therefore is very accurate.
There is a class for PHP integration on the Wiki, but I found it overly complicated and it uses temp files which aren't necessary. This is the code I wrote instead.
I used Smarty for generating the HTML for the PDF, but you can use any template engine, or pure PHP if you prefer.
Note: I originally tried to install wkhtmltopdf from source, but it's much easier to use the static binary instead.