| @@ -1,28 +1,14 @@ | ||
| 1 | -<?php | |
| 1 | +<?php if ( ! defined( 'ABSPATH' ) ) { | |
| 2 | + die; } // Cannot access directly. | |
| 2 | 3 | /** |
| 3 | - * Helpers. | |
| 4 | 4 | * |
| 5 | - * @package post-carousel | |
| 5 | + * Array search key & value | |
| 6 | + * | |
| 7 | + * @since 1.0.0 | |
| 8 | + * @version 1.0.0 | |
| 6 | 9 | */ |
| 7 | - | |
| 8 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | - die; } // Cannot access directly. | |
| 10 | - | |
| 11 | 10 | 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 | 11 | function spf_array_search( $array, $key, $value ) { |
| 26 | 12 | |
| 27 | 13 | $results = array(); |
| 28 | 14 | |
| @@ -40,19 +26,62 @@ | ||
| 40 | 26 | |
| 41 | 27 | } |
| 42 | 28 | } |
| 43 | 29 | |
| 30 | +/** | |
| 31 | + * | |
| 32 | + * Getting POST Var | |
| 33 | + * | |
| 34 | + * @since 1.0.0 | |
| 35 | + * @version 1.0.0 | |
| 36 | + */ | |
| 37 | +if ( ! function_exists( 'spf_get_var' ) ) { | |
| 38 | + function spf_get_var( $var, $default = '' ) { | |
| 39 | + | |
| 40 | + if ( isset( $_POST[ $var ] ) ) { | |
| 41 | + return $_POST[ $var ]; | |
| 42 | + } | |
| 43 | + | |
| 44 | + if ( isset( $_GET[ $var ] ) ) { | |
| 45 | + return $_GET[ $var ]; | |
| 46 | + } | |
| 47 | + | |
| 48 | + return $default; | |
| 49 | + | |
| 50 | + } | |
| 51 | +} | |
| 52 | + | |
| 53 | +/** | |
| 54 | + * | |
| 55 | + * Getting POST Vars | |
| 56 | + * | |
| 57 | + * @since 1.0.0 | |
| 58 | + * @version 1.0.0 | |
| 59 | + */ | |
| 60 | +if ( ! function_exists( 'spf_get_vars' ) ) { | |
| 61 | + function spf_get_vars( $var, $depth, $default = '' ) { | |
| 62 | + | |
| 63 | + if ( isset( $_POST[ $var ][ $depth ] ) ) { | |
| 64 | + return $_POST[ $var ][ $depth ]; | |
| 65 | + } | |
| 66 | + | |
| 67 | + if ( isset( $_GET[ $var ][ $depth ] ) ) { | |
| 68 | + return $_GET[ $var ][ $depth ]; | |
| 69 | + } | |
| 70 | + | |
| 71 | + return $default; | |
| 72 | + | |
| 73 | + } | |
| 74 | +} | |
| 75 | + | |
| 76 | +/** | |
| 77 | + * | |
| 78 | + * Between Microtime | |
| 79 | + * | |
| 80 | + * @since 1.0.0 | |
| 81 | + * @version 1.0.0 | |
| 82 | + */ | |
| 44 | 83 | 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 | 84 | function sps_pcp_timeout( $timenow, $starttime, $timeout = 30 ) { |
| 56 | 85 | |
| 57 | 86 | return ( ( $timenow - $starttime ) < $timeout ) ? true : false; |
| 58 | 87 | |
| @@ -58,16 +87,16 @@ | ||
| 58 | 87 | |
| 59 | 88 | } |
| 60 | 89 | } |
| 61 | 90 | |
| 91 | +/** | |
| 92 | + * | |
| 93 | + * Check for wp editor api | |
| 94 | + * | |
| 95 | + * @since 1.0.0 | |
| 96 | + * @version 1.0.0 | |
| 97 | + */ | |
| 62 | 98 | 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 | 99 | function spf_wp_editor_api() { |
| 71 | 100 | |
| 72 | 101 | global $wp_version; |
| 73 | 102 | |