Нет описания

functions.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. // Exit if accessed directly
  3. if ( ! defined( 'ABSPATH' ) ) {
  4. exit;
  5. }
  6. if ( ! function_exists( "get_all_modals" ) ) {
  7. function enqueue_modal( $id ) {
  8. if ( ! is_array( $id ) ) {
  9. EModal_Modals::enqueue_modal( $id );
  10. } else {
  11. foreach ( $id as $i ) {
  12. EModal_Modals::enqueue_modal( $i );
  13. }
  14. }
  15. }
  16. }
  17. if ( ! function_exists( "emodal_get_option" ) ) {
  18. function emodal_get_option( $key ) {
  19. global $blog_id;
  20. if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
  21. return get_blog_option( $blog_id, $key );
  22. } else {
  23. return get_site_option( $key );
  24. }
  25. }
  26. }
  27. if ( ! function_exists( "emodal_update_option" ) ) {
  28. function emodal_update_option( $key, $value ) {
  29. global $blog_id;
  30. if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
  31. return update_blog_option( $blog_id, $key, $value );
  32. } else {
  33. return update_site_option( $key, $value );
  34. }
  35. }
  36. }
  37. if ( ! function_exists( "emodal_delete_option" ) ) {
  38. function emodal_delete_option( $key ) {
  39. global $blog_id;
  40. if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
  41. return delete_blog_option( $blog_id, $key );
  42. } else {
  43. return delete_site_option( $key );
  44. }
  45. }
  46. }
  47. if ( ! function_exists( "emodal_get_license" ) ) {
  48. function emodal_get_license( $key = null ) {
  49. $license = emodal_get_option( EMCORE_SLUG . '-license' );
  50. if ( ! $license ) {
  51. $license = array(
  52. 'valid' => false,
  53. 'key' => '',
  54. 'status' => array(
  55. 'code' => null,
  56. 'message' => null,
  57. 'expires' => null,
  58. 'domains' => null
  59. )
  60. );
  61. emodal_update_option( EMCORE_SLUG . '-license', $license );
  62. }
  63. return $license && $key ? emresolve( $license, $key ) : $license;
  64. }
  65. }
  66. if ( ! function_exists( "emresolve" ) ) {
  67. function emresolve( array $a, $path, $default = null ) {
  68. $current = $a;
  69. $p = strtok( $path, '.' );
  70. while ( $p !== false ) {
  71. if ( ! isset( $current[ $p ] ) ) {
  72. return $default;
  73. }
  74. $current = $current[ $p ];
  75. $p = strtok( '.' );
  76. }
  77. return $current;
  78. }
  79. }