Brak opisu

functions-backcompat.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2019, Code Atlantic LLC
  4. ******************************************************************************/
  5. if ( ! defined( 'ABSPATH' ) ) {
  6. exit; // Exit if accessed directly
  7. }
  8. add_filter( 'pum_settings_fields', 'pum_merge_deprecated_settings_fields' );
  9. /**
  10. * Merge old deprecated settings from extensions into the new settings API.
  11. *
  12. * @since 1.7.0
  13. * @deprecated 1.7.0
  14. *
  15. * @param array $tabs
  16. *
  17. * @return array
  18. */
  19. function pum_merge_deprecated_settings_fields( $tabs = array() ) {
  20. /**
  21. * Apply @deprecated filters & process old fields for compatibility.
  22. */
  23. $old_fields = popmake_get_registered_settings();
  24. $old_fields = array_map( 'array_filter', $old_fields );
  25. $old_fields = array_filter( $old_fields );
  26. if ( ! empty( $old_fields ) ) {
  27. foreach ( $old_fields as $tab_id => $fields ) {
  28. foreach ( $fields as $field_id => $field_args ) {
  29. if ( is_numeric( $field_id ) && ! empty( $field_args['id'] ) ) {
  30. $field_id = $field_args['id'];
  31. unset( $field_args['id'] );
  32. }
  33. $field_args['label'] = ! empty( $field_args['name'] ) ? $field_args['name'] : '';
  34. if ( $field_args['type'] == 'header' ) {
  35. $field_args['type'] = 'separator';
  36. } else if ( $field_args['type'] == 'gaeventlabel' ) {
  37. $field_args['type'] = 'ga_event_labels';
  38. } else if ( $field_args['type'] == 'hook' ) {
  39. $field_args['type'] = 'html';
  40. ob_start();
  41. do_action( 'popmake_' . $field_id );
  42. $field_args['content'] = ob_get_clean();
  43. }
  44. unset( $field_args['name'] );
  45. $tabs[ array_key_exists( $tab_id, $tabs ) ? $tab_id : 'general' ]['main'][ $field_id ] = $field_args;
  46. }
  47. }
  48. }
  49. return $tabs;
  50. }