: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @subpackage Classes/PUM_Fields
* @copyright Copyright (c) 2023, Code Atlantic LLC
* @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
class PUM_Fields extends Popmake_Fields {
* @param array $args Arguments passed by the setting
public function hook_callback( $args ) {
do_action( $args['hook'], $args );
* @param array $args Arguments passed by the setting
public function heading_callback( $args ) { ?>
</td></tr></tbody></table>
<h2 class="pum-setting-heading"><?php echo esc_html( $args['desc'] ); ?></h2>
<table class="form-table"><tbody><tr style="display:none;"><td colspan="2">
// region Standard Fields
* @param array $args Arguments passed by the setting
public function button_callback( $args ) {
$this->field_before( $args );
<button type="<?php echo esc_attr( $args['button_type'] ); ?>" class="pum-button-<?php echo esc_attr( $args['size'] ); ?>" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>"><?php echo esc_html( $args['label'] ); ?></button>
$this->field_description( $args );
* @param array $args Arguments passed by the setting
public function text_callback( $args, $value = null ) {
if ( 'text' !== $args['type'] ) {
$args['class'] .= ' pum-field-text';
$this->field_before( $args );
$value = isset( $args['std'] ) ? $args['std'] : '';
$this->field_label( $args );
<input type="<?php echo esc_attr( $args['type'] ); ?>" placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" class="<?php echo esc_attr( $args['size'] ); ?>-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
if ( $args['required'] ) {
$this->field_description( $args );
* Renders textarea fields.
* @param array $args Arguments passed by the setting
public function textarea_callback( $args, $value = null ) {
$this->field_before( $args );
$value = isset( $args['std'] ) ? $args['std'] : '';
$this->field_label( $args );
<textarea placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" class="<?php echo esc_attr( $args['size'] ); ?>-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" cols="<?php echo esc_attr( $args['cols'] ); ?>" rows="<?php echo esc_attr( $args['rows'] ); ?>"
if ( $args['required'] ) {
><?php echo esc_textarea( stripslashes( $value ) ); ?></textarea>
$this->field_description( $args );
* @param array $args Arguments passed by the setting
public function hidden_callback( $args, $value = null ) {
$class = $this->field_classes( $args );
$value = isset( $args['std'] ) ? $args['std'] : '';
<input type="hidden" class="<?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( stripslashes( $value ) ); ?>"/>
* @param array $args Arguments passed by the setting
public function select_callback( $args, $value = null ) {
if ( isset( $args['select2'] ) ) {
$args['class'] .= ' pum-field-select2';
$value = isset( $args['std'] ) ? $args['std'] : '';
if ( $args['multiple'] ) {
$args['class'] .= ' pum-field-select--multiple';
$args['name'] .= $args['as_array'] ? '[]' : '';
$value = ! is_array( $value ) ? [ $value ] : $value;
$this->field_before( $args );
$this->field_label( $args );
<select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" data-placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" data-allow-clear="true" <?php echo $multiple; ?> <?php
if ( $args['required'] ) {
if ( ! empty( $args['options'] ) ) {
foreach ( $args['options'] as $label => $option ) {
$selected = ( ! $multiple && $option === $value ) || ( $multiple && in_array( $option, $value ) );
<option value="<?php echo esc_attr( $option ); ?>" <?php selected( 1, $selected ); ?>><?php echo esc_html( $label ); ?></option>
$this->field_description( $args );
* @param array $args Arguments passed by the setting
public function checkbox_callback( $args, $value ) {
$this->field_before( $args );
$this->field_label( $args );
<input type="checkbox" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( $args['checkbox_val'] ); ?>" <?php checked( 1, $value ); ?> />
$this->field_description( $args );
* Renders multiple checkboxes.
* @param array $args Arguments passed by the setting
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 ) ) {
$checked = isset( $values[ $key ] );
<input name="<?php echo esc_attr( $args['name'] ); ?>[<?php echo esc_attr( $key ); ?>]" id="<?php echo esc_attr( $args['id'] . '_' . $key ); ?>" type="checkbox" value="<?php echo esc_html( $option ); ?>" <?php checked( true, $checked ); ?> <?php
if ( $option['disabled'] ) {
echo 'disabled="disabled"'; }
if ( $option['required'] ) {
<label for="<?php echo esc_attr( $args['id'] . '_' . $key ); ?>"><?php echo esc_html( $option['label'] ); ?></label><br/>
$this->field_description( $args );
// endregion Standard Fields
// region HTML5 Text Fields
* Renders password fields.
* @param array $args Arguments passed by the setting
public function password_callback( $args, $value = null ) {
$args['type'] = 'password';
$this->text_callback( $args, $value );
* @param array $args Arguments passed by the setting
public function email_callback( $args, $value = null ) {
$this->text_callback( $args, $value );
* @param array $args Arguments passed by the setting
public function search_callback( $args, $value = null ) {
$args['type'] = 'search';
$this->text_callback( $args, $value );
* @param array $args Arguments passed by the setting
public function url_callback( $args, $value = null ) {
$this->text_callback( $args, $value );
* Renders telelphone number fields.
* @param array $args Arguments passed by the setting
public function tel_callback( $args, $value = null ) {
$this->text_callback( $args, $value );
* @param array $args Arguments passed by the setting
public function number_callback( $args, $value = null ) {
$args['type'] = 'number';
$this->text_callback( $args, $value );
* @param array $args Arguments passed by the setting
public function range_callback( $args, $value = null ) {
$this->text_callback( $args, $value );
// endregion HTML5 Text Fields
// region Custom Fields (post_type, taxonomy, object, rangeslider)
* @param array $args Arguments passed by the setting
public function objectselect_callback( $args, $value = null ) {
if ( 'objectselect' !== $args['type'] ) {
$args['class'] .= ' pum-field-objectselect';
$args['class'] .= ' pum-field-select pum-field-select2';
$value = isset( $args['std'] ) ? $args['std'] : '';
if ( $args['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 );
<select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" data-placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" data-allow-clear="true" <?php echo $multiple; ?> data-objecttype="<?php echo esc_attr( $args['object_type'] ); ?>" data-objectkey="<?php echo esc_attr( $args['object_key'] ); ?>" data-current="<?php echo maybe_json_attr( $value, true ); ?>"
if ( $args['required'] ) {
if ( ! empty( $args['options'] ) ) {
foreach ( $args['options'] as $label => $option ) {
$selected = ( $multiple && in_array( $option, $value ) ) || ( ! $multiple && $option === $value );
<option value="<?php echo esc_attr( $option ); ?>" <?php selected( 1, $selected ); ?>><?php echo esc_html( $label ); ?></option>
$this->field_description( $args );
* Taxonomy Select Callback
* @param array $args Arguments passed by the setting
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 );
* @param array $args Arguments passed by the setting
public function postselect_callback( $args, $value = null ) {
$args['object_type'] = 'post_type';
$args['object_key'] = $args['post_type'];