PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.1
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.1
8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 7.8.6 7.8.5 All 44 releases
gamipress / libraries / html-field-type.php

html-field-type.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 8.0.1, at libraries/html-field-type.php

39 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CMB2 HTML Field Type
4 */
5
6 if( ! function_exists( 'cmb2_render_html' ) ) :
7
8 /**
9 * Render the HTML content
10 *
11 * @param array $field The field data array
12 * @param mixed $value The stored value for this field
13 * @param integer|string $object_id The object ID
14 * @param string $object_type The object type
15 * @param CMB2_Types $field_type The field type object
16 *
17 * @return string HTML markup for our field
18 */
19 function cmb2_render_html( $field, $value, $object_id, $object_type, $field_type ) {
20
21 // Parse args
22 $attrs = $field_type->parse_args( 'html', array(
23 'id' => $field_type->_id(),
24 ) );
25
26 if( isset( $field->args['content_cb'] ) && ! empty( $field->args['content_cb'] ) ) {
27 ob_start();
28 call_user_func_array( $field->args['content_cb'], array( $field, $object_id, $object_type ) );
29 $field->args['content'] = ob_get_clean();
30 }
31
32 echo sprintf( '<div %s>%s</div>',
33 $field_type->concat_attrs( $attrs ),
34 ( isset( $field->args['content'] ) && ! empty( $field->args['content'] ) ? $field->args['content'] : '' )
35 );
36 }
37 add_action( 'cmb2_render_html', 'cmb2_render_html', 10, 5 );
38
39 endif;