This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Setup wp_query arguments for the loop. Cache the results for 4 hours. | |
| * | |
| * @link http://codex.wordpress.org/Transients_API | |
| */ | |
| // Check for transient | |
| if ( ! ( $my_query = get_transient( 'foo_featured_posts' ) ) ) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Cross-browser solution for semi-transparent backgrounds using RGBA. | |
| * Read more: http://hammerspace.co.uk/2011/10/cross-browser-alpha-transparent-background-css | |
| * | |
| * Note: in IE ARGB AA is a HEX value, not a floating point. | |
| * Note: there is some info that IE turns off ClearType with filters. | |
| * | |
| * 2Do: explore solution for semi-transparent foregrounds. | |
| * 2Do: convert to SASS mixin. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Stop SASS Build package from compiling _chunks and always compile one style.scss which @imports all _chunks | |
| * /scss/style.scss => /style.css | |
| * Based on http://hovercraftie.tumblr.com/post/61592756918/update-sass-build-plug-in-for-sublime-text-2-to-allow | |
| */ | |
| // Put this in SASS.sublime-build | |
| "cmd": ["sass", "--update", "${file_path}/style.scss:${file_path}/../style.css", "--stop-on-error", "--no-cache"], | |
| // Put this is SASS - Compressed.sublime-build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| human_time_diff( $from, $to ); | |
| echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isMobile = { | |
| Android: function() { | |
| return navigator.userAgent.match(/Android/i); | |
| }, | |
| BlackBerry: function() { | |
| return navigator.userAgent.match(/BlackBerry/i); | |
| }, | |
| iOS: function() { | |
| return navigator.userAgent.match(/iPhone|iPad|iPod/i); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| html { | |
| background: #red; /* fallback color */ | |
| background: linear-gradient( to bottom, #red, #blue); | |
| background-repeat: no-repeat; | |
| background-size: cover; | |
| width: 100%; | |
| height: 100%; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Standard Size Thumbnail | |
| if(false === get_option("thumbnail_crop")) { | |
| add_option("thumbnail_crop", "1"); | |
| } else { | |
| update_option("thumbnail_crop", "1"); | |
| } | |
| // Medium Size Thumbnail | |
| if(false === get_option("medium_crop")) { | |
| add_option("medium_crop", "1"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include_once(ABSPATH . WPINC . '/rss.php'); | |
| // Feed URL | |
| $feed = 'http://example.com/feed/'; | |
| $rss = fetch_feed($feed); | |
| if (!is_wp_error( $rss ) ) : | |
| // Number of maximum items to get | |
| $maxitems = $rss->get_item_quantity(3); | |
| $rss_items = $rss->get_items(0, $maxitems); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get any existing copy of our transient data | |
| if ( false === ( $special_query_results = get_transient( 'special_query_results' ) ) ) { | |
| // It wasn't there, so regenerate the data and save the transient | |
| $special_query_results = new WP_Query( '_YOUR_QUERY_ARGS_HERE_' ); | |
| set_transient( 'special_query_results', $special_query_results ); | |
| } | |
| // Use the data like you would have normally... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Other transients stuff here http://www.catswhocode.com/blog/wordpress-transients-api-practical-examples | |
| */ | |
| function my_followers_count($screen_name = 'kovshenin'){ | |
| $key = 'my_followers_count_' . $screen_name; | |
| // Let's see if we have a cached version | |
| $followers_count = get_transient($key); | |
| if ($followers_count !== false) |
OlderNewer