| 1 |
<?php |
| 2 |
/** |
| 3 |
* Helpers. |
| 4 |
* |
| 5 |
* @package post-carousel |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
die; } // Cannot access directly. |
| 10 |
|
| 11 |
if ( ! function_exists( 'spf_array_search' ) ) { |
| 12 |
/** |
| 13 |
* |
| 14 |
* Array search key & value |
| 15 |
* |
| 16 |
* @since 1.0.0 |
| 17 |
* @version 1.0.0 |
| 18 |
* |
| 19 |
* @param array $array search array. |
| 20 |
* @param string $key the array key. |
| 21 |
* @param mixed $value The array value. |
| 22 |
* |
| 23 |
* @return $results |
| 24 |
*/ |
| 25 |
function spf_array_search( $array, $key, $value ) { |
| 26 |
|
| 27 |
$results = array(); |
| 28 |
|
| 29 |
if ( is_array( $array ) ) { |
| 30 |
if ( isset( $array[ $key ] ) && $array[ $key ] == $value ) { |
| 31 |
$results[] = $array; |
| 32 |
} |
| 33 |
|
| 34 |
foreach ( $array as $sub_array ) { |
| 35 |
$results = array_merge( $results, spf_array_search( $sub_array, $key, $value ) ); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
return $results; |
| 40 |
|
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
if ( ! function_exists( 'spf_pcp_microtime' ) ) { |
| 45 |
/** |
| 46 |
* Between microtime. |
| 47 |
* |
| 48 |
* @since 1.0.0 |
| 49 |
* |
| 50 |
* @param integer $timenow Current time. |
| 51 |
* @param integer $starttime Starting time. |
| 52 |
* @param integer $timeout Time out. |
| 53 |
* @return boolean |
| 54 |
*/ |
| 55 |
function sps_pcp_timeout( $timenow, $starttime, $timeout = 30 ) { |
| 56 |
|
| 57 |
return ( ( $timenow - $starttime ) < $timeout ) ? true : false; |
| 58 |
|
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
if ( ! function_exists( 'spf_wp_editor_api' ) ) { |
| 63 |
/** |
| 64 |
* |
| 65 |
* Check for wp editor api |
| 66 |
* |
| 67 |
* @since 1.0.0 |
| 68 |
* @version 1.0.0 |
| 69 |
*/ |
| 70 |
function spf_wp_editor_api() { |
| 71 |
|
| 72 |
global $wp_version; |
| 73 |
|
| 74 |
return version_compare( $wp_version, '4.8', '>=' ); |
| 75 |
|
| 76 |
} |
| 77 |
} |
| 78 |
|