output.php 1.31 KB
Newer Older
imac's avatar
imac committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
<?php

/*
*  ACF Output Field Class
*
*  All the logic for this field type
*
*  @class 		acf_field_output
*  @extends		acf_field
*  @package		ACF
*  @subpackage	Fields
*/

if( ! class_exists('acf_field_output') ) :

class acf_field_output extends acf_field {
	
	
	/*
	*  __construct
	*
	*  This function will setup the field type data
	*
	*  @type	function
	*  @date	5/03/2014
	*  @since	5.0.0
	*
	*  @param	n/a
	*  @return	n/a
	*/
	
	function __construct() {
		
		// vars
		$this->name = 'output';
		$this->label = 'output';
		$this->public = false;
		$this->defaults = array(
			'html'	=> false
		);
		
		
		// do not delete!
    	parent::__construct();
	}
		
	
	/*
	*  render_field()
	*
	*  Create the HTML interface for your field
	*
	*  @param	$field (array) the $field being rendered
	*
	*  @type	action
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$field (array) the $field being edited
	*  @return	n/a
	*/
	
	function render_field( $field ) {
		
		// bail early if no html
		if( !$field['html'] ) return;
		
		
		// html
		if( is_string($field['html']) && !function_exists($field['html']) ) {
			
			echo $field['html'];
		
		// function	
		} else {
			
			call_user_func_array($field['html'], array($field));
			
		}
		
	}
		
}


// initialize
acf_register_field_type( new acf_field_output() );

endif; // class_exists check

?>