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 | |
| /** Delete All the Taxonomies */ | |
| foreach ( array( 'my_first_custom_tax', 'my_second_custom_tax', 'my_third_custom_tax', ) as $taxonomy ) { | |
| // Prepare & excecute SQL, Delete Terms | |
| $wpdb->get_results( $wpdb->prepare( "DELETE t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s')", $taxonomy ) ); | |
| // Delete Taxonomy | |
| $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); | |
| } |
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 | |
| $iter = 500000; | |
| $start = microtime(true); | |
| $n = 0; | |
| for ($c=0; $c<7*$iter; $c++) { | |
| $i = $c % 16; | |
| if ($i===0) $n += 0; |
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 declare(strict_types = 1); | |
| function testPerformance($name, Closure $closure, $runs = 1000000) | |
| { | |
| $start = microtime(true); | |
| for (; $runs > 0; $runs--) | |
| { | |
| $closure(); | |
| } | |
| $end = microtime(true); |
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 | |
| /** | |
| * Get posts in range date by a specific custom field(post meta) | |
| * But, the date needs to be in the format YYYYMMDD | |
| * | |
| * @param string $start start date | |
| * @param string $end end date | |
| * @param string $field specific custom field | |
| * @param string $ctype |
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 if (($wp_query->current_post +1) == ($wp_query->post_count)) { | |
| echo 'This is the last post'; | |
| } ?> | |
| <?php if (($wp_query->current_post +1) != ($wp_query->post_count)) { | |
| echo 'This is the not the last post'; | |
| } ?> |
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
| function titleCase($string) { | |
| //reference http://grammar.about.com/od/tz/g/Title-Case.htm | |
| // The below array contains the most commonly non-capitalized words in title casing - I'm not so sure about the commented ones that follow it... | |
| $minorWords = array('a','an','and','as','at','but','by','for','in','nor','of','on','or','per','the','to','with'); // but, is, if, then, else, when, from, off, out, over, into, | |
| // take the input string, trim whitespace from the ends, single out all repeating whitespace | |
| $string = preg_replace('/[ ]+/', ' ', trim($string)); | |
| // explode string into array of words | |
| $pieces = explode(' ', $string); | |
| // for each element in array... | |
| for($p = 0; $p <= (count($pieces) - 1); $p++){ |
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 | |
| # SHORTS | |
| # DIRECTORY SEPARATOR | |
| define( 'DS', DIRECTORY_SEPARATOR ); | |
| # PATH SEPARATOR | |
| define( 'PS', PATH_SEPARATOR ); | |
| # Absolute path to the WordPress directory. | |
| ! defined( 'ABSPATH' ) | |
| AND define( 'ABSPATH', dirname( __FILE__ ).DS ); |
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
| /** | |
| * Fix for vw, vh, vmin, vmax on iOS 7. | |
| * http://caniuse.com/#feat=viewport-units | |
| * | |
| * This fix works by replacing viewport units with px values on known screen sizes. | |
| * | |
| * iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix. | |
| * Target devices running iOS 8+ will incidentally execute the media query, | |
| * but this will still produce the expected result; so this is not a problem. |
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 namespace PaintedCloud\WP\Classes; | |
| if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
| class AssetRegister { | |
| public $scripts_base_uri; | |
| public $styles_base_uri; | |
| protected $scripts; | |
| protected $stylesheets; |
NewerOlder