<?php
Route::get('test/', 'TestController@show');
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 | |
| function get_the_terms_deepest($taxonomies, $term_order = false) { | |
| $categories = get_the_terms(get_the_ID(), $taxonomies); // get all product cats for the current post | |
| if($categories && !is_wp_error($categories)){ // wrapper to hide any errors from top level categories or products without category | |
| if(count($categories) == 1){ // Case: Select only Category of Top Level. (Required: Activate Plugin Parent Category Toggler) | |
| $return = $categories; | |
| }elseif(count($categories) > 1){ | |
| $return = array(); | |
| foreach($categories as $category){ // loop through each cat | |
| $children = get_categories(array('taxonomy' => $taxonomies, 'parent' => $category->term_id)); // get the children (if any) of the current cat |
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 | |
| function array_remove_empty( $array ) { | |
| foreach ( $array as $key => $value ) { | |
| if ( is_array($value) ) { | |
| $array[$key] = array_remove_empty( $array[$key] ); | |
| } | |
| if ( empty( $array[$key] ) ) { | |
| unset( $array[$key] ); | |
| } |
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 | |
| function get_token($length = 32) { | |
| if ( ! isset($length) || intval($length) <= 8 ) { | |
| $length = 32; | |
| } | |
| // PHP 7.0+ | |
| if ( function_exists('random_bytes') ) { | |
| return bin2hex(random_bytes($length)); | |
| } | |
| // PHP 5.3+ |
OlderNewer