helpers.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
  2. /**
  3. *
  4. * Array search key & value
  5. *
  6. * @since 1.0.0
  7. * @version 1.0.0
  8. *
  9. */
  10. if ( ! function_exists( 'csf_array_search' ) ) {
  11. function csf_array_search( $array, $key, $value ) {
  12. $results = array();
  13. if ( is_array( $array ) ) {
  14. if ( isset( $array[$key] ) && $array[$key] == $value ) {
  15. $results[] = $array;
  16. }
  17. foreach ( $array as $sub_array ) {
  18. $results = array_merge( $results, csf_array_search( $sub_array, $key, $value ) );
  19. }
  20. }
  21. return $results;
  22. }
  23. }
  24. /**
  25. *
  26. * Between Microtime
  27. *
  28. * @since 1.0.0
  29. * @version 1.0.0
  30. *
  31. */
  32. if ( ! function_exists( 'csf_timeout' ) ) {
  33. function csf_timeout( $timenow, $starttime, $timeout = 30 ) {
  34. return ( ( $timenow - $starttime ) < $timeout ) ? true : false;
  35. }
  36. }
  37. /**
  38. *
  39. * Check for wp editor api
  40. *
  41. * @since 1.0.0
  42. * @version 1.0.0
  43. *
  44. */
  45. if ( ! function_exists( 'csf_wp_editor_api' ) ) {
  46. function csf_wp_editor_api() {
  47. global $wp_version;
  48. return version_compare( $wp_version, '4.8', '>=' );
  49. }
  50. }