Keine Beschreibung

deprecated.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2019, Code Atlantic LLC
  4. ******************************************************************************/
  5. /**
  6. * Returns a popup object.
  7. *
  8. * @deprecated 1.7
  9. *
  10. * @param null $popup_id
  11. *
  12. * @return false|PUM_Model_Popup
  13. */
  14. function pum_popup( $popup_id = null ) {
  15. return pum_get_popup( $popup_id );
  16. }
  17. /**
  18. * Returns the meta group of a popup or value if key is set.
  19. *
  20. * @since 1.3.0
  21. * @deprecated 1.4
  22. *
  23. * @param $group
  24. * @param int $popup_id ID number of the popup to retrieve a overlay meta for
  25. * @param null $key
  26. * @param null $default
  27. *
  28. * @return mixed array|string
  29. */
  30. function popmake_get_popup_meta( $group, $popup_id = null, $key = null, $default = null ) {
  31. if ( ! $popup_id ) {
  32. $popup_id = pum_get_popup_id();
  33. }
  34. $values = get_post_meta( $popup_id, "popup_{$group}", true );
  35. if ( ! $values ) {
  36. $defaults = apply_filters( "popmake_popup_{$group}_defaults", array() );
  37. $values = array_merge( $defaults, popmake_get_popup_meta_group( $group, $popup_id ) );
  38. } else {
  39. $values = array_merge( popmake_get_popup_meta_group( $group, $popup_id ), $values );
  40. }
  41. if ( $key ) {
  42. // Check for dot notation key value.
  43. $test = uniqid();
  44. $value = popmake_resolve( $values, $key, $test );
  45. if ( $value == $test ) {
  46. $key = str_replace( '.', '_', $key );
  47. if ( ! isset( $values[ $key ] ) ) {
  48. $value = $default;
  49. } else {
  50. $value = $values[ $key ];
  51. }
  52. }
  53. return apply_filters( "popmake_get_popup_{$group}_$key", $value, $popup_id );
  54. } else {
  55. return apply_filters( "popmake_get_popup_{$group}", $values, $popup_id );
  56. }
  57. }
  58. /**
  59. * Returns the meta group of a popup or value if key is set.
  60. *
  61. * @since 1.0
  62. * @deprecated 1.3.0
  63. *
  64. * @param int $popup_id ID number of the popup to retrieve a overlay meta for
  65. *
  66. * @return mixed array|string
  67. */
  68. function popmake_get_popup_meta_group( $group, $popup_id = null, $key = null, $default = null ) {
  69. if ( ! $popup_id || $group === 'secure_logout') {
  70. $popup_id = pum_get_popup_id();
  71. }
  72. $post_meta = get_post_custom( $popup_id );
  73. if ( ! is_array( $post_meta ) ) {
  74. $post_meta = array();
  75. }
  76. $default_check_key = 'popup_defaults_set';
  77. if ( ! in_array( $group, array( 'auto_open', 'close', 'display', 'targeting_condition' ) ) ) {
  78. $default_check_key = "popup_{$group}_defaults_set";
  79. }
  80. $group_values = array_key_exists( $default_check_key, $post_meta ) ? array() : apply_filters( "popmake_popup_{$group}_defaults", array() );
  81. foreach ( $post_meta as $meta_key => $value ) {
  82. if ( strpos( $meta_key, "popup_{$group}_" ) !== false ) {
  83. $new_key = str_replace( "popup_{$group}_", '', $meta_key );
  84. if ( count( $value ) == 1 ) {
  85. $group_values[ $new_key ] = $value[0];
  86. } else {
  87. $group_values[ $new_key ] = $value;
  88. }
  89. }
  90. }
  91. if ( $key ) {
  92. $key = str_replace( '.', '_', $key );
  93. if ( ! isset( $group_values[ $key ] ) ) {
  94. $value = $default;
  95. } else {
  96. $value = $group_values[ $key ];
  97. }
  98. return apply_filters( "popmake_get_popup_{$group}_$key", $value, $popup_id );
  99. } else {
  100. return apply_filters( "popmake_get_popup_{$group}", $group_values, $popup_id );
  101. }
  102. }