class-acf-field-output.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. if ( ! class_exists( 'acf_field_output' ) ) :
  3. class acf_field_output extends acf_field {
  4. /*
  5. * __construct
  6. *
  7. * This function will setup the field type data
  8. *
  9. * @type function
  10. * @date 5/03/2014
  11. * @since 5.0.0
  12. *
  13. * @param n/a
  14. * @return n/a
  15. */
  16. function initialize() {
  17. // vars
  18. $this->name = 'output';
  19. $this->label = 'output';
  20. $this->public = false;
  21. $this->defaults = array(
  22. 'html' => false,
  23. );
  24. }
  25. /*
  26. * render_field()
  27. *
  28. * Create the HTML interface for your field
  29. *
  30. * @param $field (array) the $field being rendered
  31. *
  32. * @type action
  33. * @since 3.6
  34. * @date 23/01/13
  35. *
  36. * @param $field (array) the $field being edited
  37. * @return n/a
  38. */
  39. function render_field( $field ) {
  40. // bail early if no html
  41. if ( ! $field['html'] ) {
  42. return;
  43. }
  44. // html
  45. if ( is_string( $field['html'] ) && ! function_exists( $field['html'] ) ) {
  46. echo $field['html'];
  47. // function
  48. } else {
  49. call_user_func_array( $field['html'], array( $field ) );
  50. }
  51. }
  52. }
  53. // initialize
  54. acf_register_field_type( 'acf_field_output' );
  55. endif; // class_exists check