class-redux-raw.php (1833B)
1 <?php 2 /** 3 * Raw Field. 4 * 5 * @package ReduxFramework/Fields 6 * @author Dovy Paukstys & Kevin Provance (kprovance) 7 * @version 4.0.0 8 */ 9 10 defined( 'ABSPATH' ) || exit; 11 12 if ( ! class_exists( 'Redux_Raw', false ) ) { 13 14 /** 15 * Class Redux_Raw 16 */ 17 class Redux_Raw extends Redux_Field { 18 19 /** 20 * Set field defaults. 21 */ 22 public function set_defaults() { 23 $defaults = array( 24 'full_width' => true, 25 'markdown' => false, 26 ); 27 28 $this->field = wp_parse_args( $this->field, $defaults ); 29 } 30 31 /** 32 * Field Render Function. 33 * Takes the vars and outputs the HTML for the field in the settings 34 * 35 * @since ReduxFramework 1.0.0 36 */ 37 public function render() { 38 if ( ! empty( $this->field['include'] ) && file_exists( $this->field['include'] ) ) { 39 require_once $this->field['include']; 40 } 41 42 if ( isset( $this->field['content_path'] ) && ! empty( $this->field['content_path'] ) && file_exists( $this->field['content_path'] ) ) { 43 $this->field['content'] = $this->parent->filesystem->execute( 'get_contents', $this->field['content_path'] ); 44 } 45 46 if ( ! empty( $this->field['content'] ) && isset( $this->field['content'] ) ) { 47 if ( isset( $this->field['markdown'] ) && true === $this->field['markdown'] && ! empty( $this->field['content'] ) ) { 48 require_once dirname( __FILE__ ) . '/parsedown.php'; 49 $parsedown = new Redux_Parsedown(); 50 51 echo( $parsedown->text( $this->field['content'] ) ); // phpcs:ignore WordPress.Security.EscapeOutput 52 } else { 53 echo( $this->field['content'] ); // phpcs:ignore WordPress.Security.EscapeOutput 54 } 55 } 56 57 // phpcs:ignore WordPress.NamingConventions.ValidHookName 58 do_action( 'redux-field-raw-' . $this->parent->args['opt_name'] . '-' . $this->field['id'] ); 59 } 60 } 61 } 62 63 class_alias( 'Redux_Raw', 'ReduxFramework_Raw' );