field_before( $args );
?>
field_description( $args );
$this->field_after();
}
/**
* Text Callback
*
* Renders text fields.
*
* @param array $args Arguments passed by the setting
*
* @param string $value
*/
public function text_callback( $args, $value = null ) {
if ( 'text' !== $args['type'] ) {
$args['class'] .= ' pum-field-text';
}
$this->field_before( $args );
if ( ! $value ) {
$value = isset( $args['std'] ) ? $args['std'] : '';
}
$this->field_label( $args );
?>
/>
field_description( $args );
$this->field_after();
}
/**
* Textarea Callback
*
* Renders textarea fields.
*
* @param array $args Arguments passed by the setting
*
* @param string $value
*/
public function textarea_callback( $args, $value = null ) {
$this->field_before( $args );
if ( ! $value ) {
$value = isset( $args['std'] ) ? $args['std'] : '';
}
$this->field_label( $args );
?>
field_description( $args );
$this->field_after();
}
/**
* Hidden Callback
*
* Renders hidden fields.
*
* @param array $args Arguments passed by the setting
*
* @param $value
*/
public function hidden_callback( $args, $value = null ) {
$class = $this->field_classes( $args );
if ( ! $value ) {
$value = isset( $args['std'] ) ? $args['std'] : '';
}
?>
field_before( $args );
$this->field_label( $args );
?>
field_description( $args );
$this->field_after();
}
/**
* Checkbox Callback
*
* Renders checkboxes.
*
* @param array $args Arguments passed by the setting
*
* @param $value
*/
public function checkbox_callback( $args, $value ) {
$this->field_before( $args );
$this->field_label( $args );
?>
/>
field_description( $args );
$this->field_after();
}
/**
* Multicheck Callback
*
* Renders multiple checkboxes.
*
* @param array $args Arguments passed by the setting
*
* @param array $values
*/
public function multicheck_callback( $args, $values = [] ) {
$this->field_before( $args );
$this->field_label( $args );
if ( ! empty( $args['options'] ) ) {
foreach ( $args['options'] as $key => $option ) {
if ( ! is_array( $option ) ) {
$option = [
'label' => $option,
];
}
$option = wp_parse_args(
$option,
[
'label' => '',
'required' => false,
'disabled' => false,
]
);
$checked = isset( $values[ $key ] );
?>
/>
field_description( $args ); $this->field_after(); } // endregion Standard Fields // region HTML5 Text Fields /** * Password Callback * * Renders password fields. * * @param array $args Arguments passed by the setting * * @param string $value */ public function password_callback( $args, $value = null ) { $args['type'] = 'password'; $this->text_callback( $args, $value ); } /** * Email Callback * * Renders email fields. * * @param array $args Arguments passed by the setting * * @param string $value */ public function email_callback( $args, $value = null ) { $args['type'] = 'email'; $this->text_callback( $args, $value ); } /** * Search Callback * * Renders search fields. * * @param array $args Arguments passed by the setting * * @param string $value */ public function search_callback( $args, $value = null ) { $args['type'] = 'search'; $this->text_callback( $args, $value ); } /** * URL Callback * * Renders url fields. * * @param array $args Arguments passed by the setting * * @param string $value */ public function url_callback( $args, $value = null ) { $args['type'] = 'url'; $this->text_callback( $args, $value ); } /** * Telephone Callback * * Renders telelphone number fields. * * @param array $args Arguments passed by the setting * * @param string $value */ public function tel_callback( $args, $value = null ) { $args['type'] = 'tel'; $this->text_callback( $args, $value ); } /** * Number Callback * * Renders number fields. * * @param array $args Arguments passed by the setting * * @param string $value */ public function number_callback( $args, $value = null ) { $args['type'] = 'number'; $this->text_callback( $args, $value ); } /** * Range Callback * * Renders range fields. * * @param array $args Arguments passed by the setting * * @param string $value */ public function range_callback( $args, $value = null ) { $args['type'] = 'range'; $this->text_callback( $args, $value ); } // endregion HTML5 Text Fields // region Custom Fields (post_type, taxonomy, object, rangeslider) /** * Object Select Callback * * Renders select fields. * * @param array $args Arguments passed by the setting * * @param null $value */ public function objectselect_callback( $args, $value = null ) { if ( 'objectselect' !== $args['type'] ) { $args['class'] .= ' pum-field-objectselect'; } $args['class'] .= ' pum-field-select pum-field-select2'; if ( ! $value ) { $value = isset( $args['std'] ) ? $args['std'] : ''; } $multiple = null; if ( $args['multiple'] ) { $multiple = 'multiple'; $args['class'] .= ' pum-field-select--multiple'; $args['name'] .= $args['as_array'] ? '[]' : ''; $value = ! is_array( $value ) ? [ $value ] : $value; $value = wp_parse_id_list( $value ); } $this->field_before( $args ); $this->field_label( $args ); ?> field_description( $args ); $this->field_after(); } /** * Taxonomy Select Callback * * Renders select fields. * * @param array $args Arguments passed by the setting * * @param $value */ public function taxonomyselect_callback( $args, $value ) { $args['object_type'] = 'taxonomy'; $args['object_key'] = $args['taxonomy']; $args['class'] = ! empty( $args['class'] ) ? $args['class'] : '' . ' pum-taxonomyselect'; $this->objectselect_callback( $args, $value ); } /** * Select Callback * * Renders select fields. * * @param array $args Arguments passed by the setting * * @param $value */ public function postselect_callback( $args, $value = null ) { $args['object_type'] = 'post_type'; $args['object_key'] = $args['post_type']; $args['class'] = ! empty( $args['class'] ) ? $args['class'] : '' . ' pum-postselect'; $this->objectselect_callback( $args, $value ); } /** * Rangeslider Callback * * Renders the rangeslider. * * @param array $args Arguments passed by the setting * * @param $value */ public function rangeslider_callback( $args, $value = null ) { $this->field_before( $args ); if ( ! $value ) { $value = isset( $args['std'] ) ? $args['std'] : ''; } $this->field_label( $args ); ?> data-force-minmax="" /> field_description( $args ); $this->field_after(); } // endregion Custom Fields (post_type, taxonomy, object, rangeslider) // region Templ Non Fields public function heading_templ_callback( $args ) { $this->heading_callback( $args ); } // endregion Non Fields public function text_templ_callback( $args ) { if ( 'text' !== $args['type'] ) { $args['class'] .= ' pum-field-text'; } $this->field_before( $args ); $this->field_label( $args ); ?> field_description( $args ); $this->field_after(); } /** * Password Callback * * Renders password fields. * * @param array $args Arguments passed by the setting */ public function password_templ_callback( $args ) { $args['type'] = 'password'; $this->text_templ_callback( $args ); } /** * Email Callback * * Renders email fields. * * @param array $args Arguments passed by the setting * * @return void */ public function email_templ_callback( $args ) { $args['type'] = 'email'; $this->text_templ_callback( $args ); } /** * Search Callback * * Renders search fields. * * @param array $args Arguments passed by the setting * * @return void */ public function search_templ_callback( $args ) { $args['type'] = 'search'; $this->text_templ_callback( $args ); } /** * URL Callback * * Renders url fields. * * @param array $args Arguments passed by the setting * * @return void */ public function url_templ_callback( $args ) { $args['type'] = 'url'; $this->text_templ_callback( $args ); } /** * Telephone Callback * * Renders telelphone number fields. * * @param array $args Arguments passed by the setting * * @return void */ public function tel_templ_callback( $args ) { $args['type'] = 'tel'; $this->text_templ_callback( $args ); } /** * Number Callback * * Renders number fields. * * @param array $args Arguments passed by the setting * * @return void */ public function number_templ_callback( $args ) { $args['type'] = 'number'; $this->text_templ_callback( $args ); } /** * Range Callback * * Renders range fields. * * @param array $args Arguments passed by the setting * * @return void */ public function range_templ_callback( $args ) { $args['type'] = 'range'; $this->text_templ_callback( $args ); } /** * Hidden Callback * * Renders hidden fields. * * @param array $args Arguments passed by the setting */ public function hidden_templ_callback( $args ) { $class = $this->field_classes( $args ); ?> field_before( $args ); $this->field_label( $args ); ?> field_description( $args ); $this->field_after(); } /** * Posttype Select Callback * * Renders select fields. * * @param array $args Arguments passed by the setting */ public function postselect_templ_callback( $args ) { $args['object_type'] = 'post_type'; $args['object_key'] = $args['post_type']; $args['class'] .= ' pum-postselect'; $this->objectselect_templ_callback( $args ); } public function objectselect_templ_callback( $args ) { if ( 'objectselect' !== $args['type'] ) { $args['class'] .= ' pum-field-objectselect'; } $args['class'] .= ' pum-field-select pum-field-select2'; $multiple = null; if ( $args['multiple'] ) { $multiple = 'multiple'; $args['class'] .= ' pum-field-select--multiple'; $args['name'] .= $args['as_array'] ? '[]' : ''; } $this->field_before( $args ); $this->field_label( $args ); ?> <# var templ_name = ''; #> <# if (typeof data[templ_name] === 'undefined') { data[templ_name] = ''; } #> field_description( $args ); $this->field_after(); } /** * Select Callback * * Renders select fields. * * @param array $args Arguments passed by the setting */ public function taxonomyselect_templ_callback( $args ) { $args['object_type'] = 'taxonomy'; $args['object_key'] = $args['taxonomy']; $args['class'] .= ' pum-field-taxonomyselect'; $this->objectselect_templ_callback( $args ); } public function checkbox_templ_callback( $args ) { $this->field_before( $args ); $this->field_label( $args ); ?> <# var checked = data. !== undefined && data. ? true : false; #> field_description( $args ); $this->field_after(); } public function multicheck_templ_callback( $args ) { $this->field_before( $args ); $this->field_label( $args ); $this->field_description( $args ); ?> <# var checked = data. !== undefined && data. && typeof data. === 'object' ? data. : {}; #> $label ) { ?> <# if (checked. === undefined) { checked. = false; } #> , '', true)}} /> field_after(); } public function rangeslider_templ_callback( $args ) { $value = '{{data.' . $args['templ_name'] . '}}'; $this->rangeslider_callback( $args, $value ); } public function postselect_sanitize( $value = [], $args = [] ) { return $this->objectselect_sanitize( $value, $args ); } public function objectselect_sanitize( $value = [], $args = [] ) { return wp_parse_id_list( $value ); } public function taxonomyselect_sanitize( $value = [], $args = [] ) { return $this->objectselect_sanitize( $value, $args ); } /** * TODO: Finish adding the following field types for HTML & underscore.js */ /* * Radio Callback * * Renders radio boxes. * * @param array $args Arguments passed by the setting * * @return void * * public function radio_callback( $args, $value ) { * if ( ! empty( $args['options'] ) ) { * * foreach ( $args['options'] as $key => $option ) { * $checked = false; * * $value = $this->get_option( $args['id'] ); * * if ( $value == $key || ( ! $value && isset( $args['std'] ) && $args['std'] == $key ) ) { * $checked = true; * } * * echo ' '; * echo ' '; * } * * echo ' ' . $args['desc'] . ' '; * * } * } * * * * * * * * /** * Color select Callback * * Renders color select fields. * * @param array $args Arguments passed by the setting * * @return void * * public function color_select_callback( $args ) { * * $value = $this->get_option( $args['id'] ); * * if ( ! $value ) { * $value = isset( $args['std'] ) ? $args['std'] : ''; * } * * $html = ''; * * if ( ! empty( $args['options'] ) ) { * foreach ( $args['options'] as $option => $color ) { * $selected = selected( $option, $value, false ); * $html .= ''; * } * } * * $html .= ''; * $html .= ''; * * echo $html; * } * * /** * Rich Editor Callback * * Renders rich editor fields. * * @param array $args Arguments passed by the setting * * @global $wp_version WordPress Version * * public function rich_editor_callback( $args ) { * global $wp_version; * $value = $this->get_option( $args['id'] ); * * if ( ! $value ) { * $value = isset( $args['std'] ) ? $args['std'] : ''; * } * * $rows = isset( $args['size'] ) ? $args['size'] : 20; * * if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { * ob_start(); * wp_editor( stripslashes( $value ), $this->options_key . '_' . $args['id'], array( * 'textarea_name' => '' . $this->options_key . '[' . $args['id'] . ']', * 'textarea_rows' => $rows * ) ); * $html = ob_get_clean(); * } else { * $html = ''; * } * * $html .= ''; * * echo $html; * } * * /** * Upload Callback * * Renders upload fields. * * @param array $args Arguments passed by the setting * * @return void * * public function upload_callback( $args ) { * $value = $this->get_option( $args['id'] ); * * if ( ! $value ) { * $value = isset( $args['std'] ) ? $args['std'] : ''; * } * * $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; * $html = ''; * $html .= ' '; * $html .= ''; * * echo $html; * } * * /** * Color picker Callback * * Renders color picker fields. * * @param array $args Arguments passed by the setting * * @return void * * public function color_callback( $args ) { * $value = $this->get_option( $args['id'] ); * * if ( ! $value ) { * $value = isset( $args['std'] ) ? $args['std'] : ''; * } * * $default = isset( $args['std'] ) ? $args['std'] : ''; * * $html = ''; * $html .= ''; * * echo $html; * } * * /** * Descriptive text callback. * * Renders descriptive text onto the settings field. * * @param array $args Arguments passed by the setting * * @return void * * public function descriptive_text_callback( $args ) { * echo esc_html( $args['desc'] ); * } * * /** * Registers the license field callback for Software Licensing * * @param array $args Arguments passed by the setting * * @return void * * public function license_key_callback( $args ) { * $value = $this->get_option( $args['id'] ); * * if ( ! $value ) { * $value = isset( $args['std'] ) ? $args['std'] : ''; * } * * $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; * * $html = ''; * * if ( 'valid' == get_option( $args['options']['is_valid_license_option'] ) ) { * $html .= ''; * } * $html .= ''; * * echo $html; * } * * */ } |