This gist is about:
- https://twitter.com/taylorotwell/status/600680897550098432
- https://twitter.com/Ocramius/status/600705252539691008
Mainly:
functioncannot (should not) be used when side-effects occur
| <?php | |
| function resizeImage($source, $dest, $new_width, $new_height, $quality) | |
| { | |
| // Taken from http://salman-w.blogspot.com/2009/04/crop-to-fit-image-using-aspphp.html | |
| $image = new Phalcon\Image\Adapter\GD($source); | |
| $source_height = $image->getHeight(); | |
| $source_width = $image->getWidth(); | |
| $source_aspect_ratio = $source_width / $source_height; | |
| $desired_aspect_ratio = $new_width / $new_height; | |
| if ($source_aspect_ratio > $desired_aspect_ratio) { |
This gist is about:
Mainly:
function cannot (should not) be used when side-effects occur| (function( $ ) { | |
| 'use strict'; | |
| $(function() { | |
| alert( 'JavaScript Loaded!' ); | |
| }); | |
| })( jQuery ); |
| <?php | |
| $results = $wpdb->get_results( | |
| " | |
| SELECT key2.meta_value as cat_id, $wpdb->posts.ID as action_id -- , $wpdb->posts.post_title as title | |
| FROM $wpdb->posts | |
| INNER JOIN $wpdb->postmeta key1 | |
| ON $wpdb->posts.ID = key1.post_id | |
| INNER JOIN $wpdb->postmeta key2 | |
| ON $wpdb->posts.ID = key2.post_id | |
| WHERE key1.meta_key = 'active' |
| <?php | |
| /** | |
| * WordPress Query Comprehensive Reference | |
| * Compiled by luetkemj - luetkemj.com | |
| * | |
| * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters | |
| * Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php | |
| */ | |
| $args = array( |
| <?php | |
| // http://wordpress.stackexchange.com/questions/64338/how-to-get-a-meta-value-from-all-post | |
| // https://wordpress.org/support/topic/how-to-get-a-meta-values-from-all-posts-in-a-special-category | |
| function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) { | |
| if( empty( $key ) ) return; | |
| global $wpdb; | |
| $r = $wpdb->get_results( $wpdb->prepare( " | |
| SELECT p.ID, pm.meta_value FROM {$wpdb->postmeta} pm |
| $(function () { | |
| //grab the entire query string | |
| var query = document.location.search.replace('?', ''); | |
| //extract each field/value pair | |
| query = query.split('&'); | |
| //run through each pair | |
| for (var i = 0; i < query.length; i++) { | |
| //split up the field/value pair into an array | |
| var field = query[i].split("="); | |
| //target the field and assign its value |
| function list_hooked_functions($tag=false){ | |
| global $wp_filter; | |
| if ($tag) { | |
| $hook[$tag]=$wp_filter[$tag]; | |
| if (!is_array($hook[$tag])) { | |
| trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); | |
| return; | |
| } | |
| } | |
| else { |
| Snippet: [[SnippetName]] | |
| Chunk: [[$ChunkName]] | |
| System Setting: [[++SettingName]] | |
| TV: [[*fieldName/TvName]] | |
| Link tag: [[~PageId? ¶mName=`value`]] | |
| Placeholder: [[+PlaceholderName]] | |
| <?php |