I hereby claim:
- I am bebaps on github.
- I am apersky (https://keybase.io/apersky) on keybase.
- I have a public key whose fingerprint is 5D7D EB25 B38F 7731 3FB5 DDAF 091F DA36 8E8E EE0A
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| <?php | |
| /** | |
| * Defer all JS files | |
| * | |
| * @method defer_parsing_of_js | |
| * @param String $url The URL of the script | |
| * @return String The "cleaned" URL, including the additional defer attribute | |
| */ | |
| function defer_parsing_of_js( $url ) { | |
| // If the URL is not of a .js file, just return it |
| <?php | |
| // An older method, a hack really that works by reseting the default WP_Query in order to trick WordPress into thinking that our custom query is the default query | |
| // Not a fan of this method, but post it because it is still a reliable alternative | |
| // Store the orginal, default WP_Query in a temp variable | |
| $temp = $wp_query; | |
| // Flush the default WP_Qeury | |
| $wp_query = null; |
| <?php | |
| // Set up the variable(s) to be passed as an associative array | |
| // NOTE: it MUST be an associative array for this to work, because of the 'extract()' function to be used | |
| $variables = [ | |
| 'text' => 'See you on the other side!' | |
| ]; | |
| // Pass the array along with a reference name using the 'set_query_var()' function | |
| // This function basically passes variables via a URL query string | |
| set_query_var( 'passed-variables', $variables ); |
| <?php | |
| // Standard API query arguments | |
| $args = array( | |
| 'orderby' => 'title', | |
| 'per_page' => 3 | |
| ); | |
| // Put into the `add_query_arg();` to build a URL for use | |
| // Just an alternative to manually typing the query string | |
| $url = add_query_arg( $args, rest_url('wp/v2/posts') ); |
| // This function implements a "Load More" button. | |
| // It assumes that there is already a matching query that has executed on the page, so this AJAX call is just a continuation of that query to grab additional posts. | |
| // There are no animations added here. For a smoother experience, it is a good idea to add animations to the button (ex. a loading icon during the request), or making the new posts animate in (ex, using Animate.css to fade them into the page) | |
| $(function() { | |
| // Grab the load more button, since I only want to run the code if the button is on the page | |
| var loadMoreButton = $('#load-more'); | |
| if (loadMoreButton) { | |
| // Because there are already posts on the page, we need to manually tell this query what page of results to grab so that is doesn't load duplicate posts | |
| var loadPosts = function(page) { |
| // This function uses AJAX to run a query. | |
| // It assumes that there are no posts on the page, and they will be loaded by the user on demand. | |
| // // There are no animations added here. For a smoother experience, it is a good idea to add animations to the button (ex. a loading icon during the request), or making the new posts animate in (ex, using Animate.css to fade them into the page) | |
| $(function() { | |
| // Grab the load button, since I only want to run the code if the button is on the page | |
| var ajaxButton = $('#ajax-button'); | |
| if (ajaxButton) { | |
| // The AJAX request | |
| var getPosts = function() { |
| scp -r username@remote:/path/to/folder /dest/local/path |
| @function remove-unit($value) { | |
| @return $value / ($value * 0 + 1); | |
| } |
| <?php | |
| /** | |
| * Debug some piece of code | |
| * | |
| * @method debug | |
| * @param Variable|Function $code The code that you want to check | |
| * @param Boolen $die Should the rest of the code on the page be prevented from executing | |
| */ | |
| function debug( $code, $die = true ) { | |
| printf( '<pre>%s</pre>', print_r( $code, true ) ); |