';
} else {
echo '
';
echo '
';
}
}
echo '
' . wp_kses_post( $field_description ) . '
';
// For field with additional options / sub-fields, we add wrapper for them
if ( array_key_exists( 'field_options_wrapper', $args ) && $args['field_options_wrapper'] ) {
echo '
';
}
// For field with additional options / sub-fields, we add a wrapper to enclose field descriptions
if ( array_key_exists( 'field_options_wrapper', $args ) && $args['field_options_wrapper'] ) {
echo '
';
echo '
';
}
}
/**
* Render checkbox field as sub-field of a toggle/switcher checkbox
*
* @since 1.9.0
*/
function render_checkbox_plain( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_name = $args['field_name'];
$field_label = $args['field_label'];
$default_value = false;
switch ( $args['field_id'] ) {
case 'login_page_disable_registration':
$default_value = ( 1 == get_option( 'users_can_register' ) ? false : true );
break;
}
$field_option_value = ( isset( $options[$args['field_id']] ) ? $options[$args['field_id']] : $default_value );
$display_none_on_load = ( isset( $args['display_none_on_load'] ) ? $args['display_none_on_load'] : false );
if ( $display_none_on_load ) {
$inline_style = 'display:none;';
} else {
$inline_style = '';
}
echo '
';
echo '
' . wp_kses_post( $field_label ) . ' ';
}
/**
* Render checkbox field as sub-field of a toggle/switcher checkbox
*
* @since 1.3.0
*/
function render_checkbox_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_name = $args['field_name'];
$field_label = $args['field_label'];
$parent_field_id = ( isset( $args['parent_field_id'] ) ? $args['parent_field_id'] : '' );
$sub_field_id = ( isset( $args['sub_field_id'] ) ? $args['sub_field_id'] : '' );
if ( in_array( $parent_field_id, array('enable_duplication_for', 'enable_rest_api_for') ) ) {
// Default is true/enabled. Usually for options introduced at a later date where the previous default is true/enabled.
$default_value = true;
} else {
// Default is false / checked
$default_value = false;
}
if ( in_array( $parent_field_id, array('redirect_after_login_for_separate', 'redirect_after_logout_for_separate') ) && !empty( $sub_field_id ) ) {
$field_option_value = ( isset( $options[$sub_field_id][$args['field_id']] ) ? $options[$sub_field_id][$args['field_id']] : $default_value );
} else {
$field_option_value = ( isset( $options[$parent_field_id][$args['field_id']] ) ? $options[$parent_field_id][$args['field_id']] : $default_value );
}
echo '
';
echo '
' . wp_kses_post( $field_label ) . ' ';
}
/**
* Render radio buttons field as sub-field of a toggle/switcher checkbox
*
* @since 1.3.0
*/
function render_radio_buttons_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_name = $args['field_name'];
$field_radios = $args['field_radios'];
if ( !empty( $args['field_default'] ) ) {
$default_value = $args['field_default'];
} else {
$default_value = false;
}
$field_description = ( isset( $args['field_description'] ) ? $args['field_description'] : '' );
$field_option_value = ( isset( $options[$field_id] ) ? $options[$field_id] : $default_value );
echo '
';
foreach ( $field_radios as $radio_label => $radio_value ) {
echo ' ';
echo '' . wp_kses_post( $radio_label ) . ' ';
}
echo '
';
if ( !empty( $field_description ) ) {
echo '
' . wp_kses_post( $field_description ) . '
';
}
}
/**
* Render checkboxes field as sub-field of a toggle/switcher checkbox
*
* @since 6.9.2
*/
function render_checkboxes_subfield( $args ) {
$options = get_option( ASENHA_SLUG_U, array() );
$field_id = $args['field_id'];
$field_name = $args['field_name'];
$field_options = $args['field_options'];
$layout = ( !empty( $args['layout'] ) ? $args['layout'] : 'horizontal' );
$default_value = ( !empty( $args['field_default'] ) ? $args['field_default'] : array() );
$field_option_value = ( isset( $options[$field_id] ) ? (array) $options[$field_id] : $default_value );
echo '
';
foreach ( $field_options as $option_label => $option_value ) {
echo '
';
echo ' ';
echo '' . wp_kses_post( $option_label ) . ' ';
echo '
';
}
echo '
';
}
/**
* Render text field as sub-field of a toggle/switcher checkbox
*
* @since 1.4.0
*/
function render_text_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_slug = str_replace( '_', '-', $field_id );
$field_name = $args['field_name'];
$field_width_classname = ( isset( $args['field_width_classname'] ) ? $args['field_width_classname'] : '' );
$field_type = $args['field_type'];
$field_prefix = $args['field_prefix'];
$field_suffix = $args['field_suffix'];
$field_is_read_only = ( isset( $args['read_only'] ) ? $args['read_only'] : false );
$field_is_read_only_output = ( $field_is_read_only ? ' readonly="readonly"' : '' );
$field_placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' );
$field_description = $args['field_description'];
if ( isset( $options[$field_id] ) ) {
if ( 'live_site_url' == $field_id ) {
if ( false !== strpos( $options[$field_id], 'http' ) ) {
$field_option_value = $options[$field_id];
} else {
// Legacy support for when base64 encoding was used prior to v7.3.1
$field_option_value = base64_decode( $options[$field_id] );
}
} elseif ( 'login_page_logo_image_width' == $field_id || 'login_page_logo_image_height' == $field_id ) {
if ( isset( $options[$field_id] ) ) {
if ( is_numeric( $options[$field_id] ) ) {
$field_option_value = $options[$field_id];
} else {
$field_option_value = str_replace( 'px', '', $options[$field_id] );
}
}
} else {
$field_option_value = $options[$field_id];
}
} else {
if ( 'altcha_secret_key' == $field_id ) {
$field_option_value = '';
} else {
$field_option_value = '';
}
}
if ( !empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-prefix with-suffix';
} elseif ( !empty( $field_prefix ) && empty( $field_suffix ) ) {
$field_classname = ' with-prefix';
} elseif ( empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-suffix';
} else {
$field_classname = '';
}
if ( !empty( $field_width_classname ) ) {
$field_classname .= ' ' . $field_width_classname;
}
echo wp_kses_post( $field_prefix ) . '
' . wp_kses_post( $field_suffix );
echo '
' . esc_html( $field_description ) . ' ';
}
/**
* Render text field as sub-field of a checkbox field. e.g. in Redirect After Login module
*
* @since 7.3.3
*/
function render_checkbox_field_text_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_name = $args['field_name'];
$field_width_classname = ( isset( $args['field_width_classname'] ) ? $args['field_width_classname'] : '' );
$field_type = $args['field_type'];
$field_prefix = $args['field_prefix'];
$field_suffix = $args['field_suffix'];
$field_placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' );
$field_description = $args['field_description'];
$parent_field_id = ( isset( $args['parent_field_id'] ) ? $args['parent_field_id'] : '' );
$sub_field_id = ( isset( $args['sub_field_id'] ) ? $args['sub_field_id'] : '' );
if ( 'redirect_after_login_for_separate' == $parent_field_id && !empty( $sub_field_id ) ) {
$field_option_value = ( isset( $options[$sub_field_id][$field_id] ) ? $options[$sub_field_id][$field_id] : '' );
} else {
$field_option_value = ( isset( $options[$parent_field_id][$field_id] ) ? $options[$parent_field_id][$field_id] : '' );
}
// $field_option_value = ( isset( $options[$field_id] ) ) ? $options[$field_id] : '';
$field_option_value = ( isset( $options[$parent_field_id . '_slug'][$args['field_id']] ) ? $options[$parent_field_id . '_slug'][$field_id] : '' );
if ( !empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-prefix with-suffix';
} elseif ( !empty( $field_prefix ) && empty( $field_suffix ) ) {
$field_classname = ' with-prefix';
} elseif ( empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-suffix';
} else {
$field_classname = '';
}
if ( !empty( $field_width_classname ) ) {
$field_classname .= ' ' . $field_width_classname;
}
echo wp_kses_post( $field_prefix ) . '
' . wp_kses_post( $field_suffix );
echo '
' . esc_html( $field_description ) . ' ';
}
/**
* Render description field as sub-field of a toggle/switcher checkbox
*
* @since 4.6.0
*/
function render_description_subfield( $args ) {
$field_description = $args['field_description'];
echo '
' . wp_kses( $field_description, get_kses_with_style_src_svg_ruleset() ) . '
';
}
/**
* Render heading for sub-fields of a toggle/switcher checkbox
*
* @since 5.0.0
*/
function render_subfields_heading( $args ) {
$subfields_heading = $args['subfields_heading'];
echo '
' . wp_kses_post( $subfields_heading ) . '
';
}
/**
* Render password field as sub-field of a toggle/switcher checkbox
*
* @since 4.1.0
*/
function render_password_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_name = $args['field_name'];
$field_type = $args['field_type'];
$field_prefix = $args['field_prefix'];
$field_suffix = $args['field_suffix'];
$field_description = $args['field_description'];
$field_option_value = ( isset( $options[$args['field_id']] ) ? $options[$args['field_id']] : '' );
if ( !empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-prefix with-suffix';
} elseif ( !empty( $field_prefix ) && empty( $field_suffix ) ) {
$field_classname = ' with-prefix';
} elseif ( empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-suffix';
} else {
$field_classname = '';
}
$placeholder = '';
echo wp_kses_post( $field_prefix ) . '
' . wp_kses_post( $field_suffix );
echo '
' . esc_html( $field_description ) . ' ';
}
/**
* Render number field as sub-field of a toggle/switcher checkbox
*
* @since 1.4.0
*/
function render_number_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_name = $args['field_name'];
$field_type = $args['field_type'];
$field_prefix = $args['field_prefix'];
$field_suffix = $args['field_suffix'];
$field_intro = $args['field_intro'];
$field_placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' );
$field_min = ( isset( $args['field_min'] ) ? $args['field_min'] : 1 );
$field_max = ( isset( $args['field_max'] ) ? $args['field_max'] : 10 );
$field_description = ( isset( $args['field_description'] ) ? $args['field_description'] : '' );
$field_option_value = ( isset( $options[$args['field_id']] ) ? $options[$args['field_id']] : '' );
if ( !empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-prefix with-suffix';
} elseif ( !empty( $field_prefix ) && empty( $field_suffix ) ) {
$field_classname = ' with-prefix';
} elseif ( empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-suffix';
} else {
$field_classname = '';
}
echo '
';
if ( !empty( $field_intro ) ) {
echo '
' . wp_kses_post( $field_intro ) . '
';
}
echo '
' . wp_kses_post( $field_prefix ) . ' ' . wp_kses_post( $field_suffix ) . '
';
if ( !empty( $field_description ) ) {
echo '
' . wp_kses_post( $field_description ) . '
';
}
echo '
';
}
/**
* Render select field as sub-field of a toggle/switcher checkbox
*
* @since 1.4.0
*/
function render_select_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_name = $args['field_name'];
$field_type = $args['field_type'];
$field_prefix = $args['field_prefix'];
$field_suffix = $args['field_suffix'];
$field_select_options = $args['field_select_options'];
$field_select_default = $args['field_select_default'];
$field_intro = $args['field_intro'];
$field_description = $args['field_description'];
if ( !empty( $field_select_default ) ) {
$default_value = $field_select_default;
} else {
$default_value = false;
}
$field_option_value = ( isset( $options[$field_id] ) ? $options[$field_id] : $default_value );
if ( !empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-prefix with-suffix';
} elseif ( !empty( $field_prefix ) && empty( $field_suffix ) ) {
$field_classname = ' with-prefix';
} elseif ( empty( $field_prefix ) && !empty( $field_suffix ) ) {
$field_classname = ' with-suffix';
} else {
$field_classname = '';
}
$display_none_on_load = ( isset( $args['display_none_on_load'] ) ? $args['display_none_on_load'] : false );
if ( $display_none_on_load ) {
$inline_style = 'display:none;';
} else {
$inline_style = '';
}
echo '
';
if ( !empty( $field_intro ) ) {
echo '
' . wp_kses_post( $field_intro ) . '
';
}
echo '
' . wp_kses_post( $field_prefix );
echo '';
foreach ( $field_select_options as $label => $value ) {
echo '' . esc_html( $label ) . ' ';
}
echo ' ';
echo wp_kses_post( $field_suffix ) . '
';
if ( !empty( $field_description ) ) {
echo '
' . wp_kses_post( $field_description ) . '
';
}
echo '
';
}
/**
* Render textarea field as sub-field of a toggle/switcher checkbox
*
* @since 2.3.0
*/
function render_textarea_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_slug = $args['field_slug'];
$field_name = $args['field_name'];
$field_type = $args['field_type'];
$field_rows = $args['field_rows'];
$field_intro = $args['field_intro'];
$field_description = $args['field_description'];
$field_placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' );
// Always load textarea content from robots.txt URL, whether it's a real, custom-made robots.txt file or a virtual one generated by WordPress
if ( 'robots_txt_content' == $field_id ) {
if ( array_key_exists( 'manage_robots_txt', $options ) ) {
// Manage robots.txt feature has been enabled before
if ( !$options['manage_robots_txt'] ) {
// Manage robots.txt feature is NOT enabled
if ( array_key_exists( 'robots_txt_content', $options ) && $options['robots_txt_content'] ) {
$field_option_value = $options['robots_txt_content'];
} else {
$robots_txt_content = wp_remote_get( get_site_url() . '/robots.txt' );
$robots_txt_content = esc_textarea( trim( wp_remote_retrieve_body( $robots_txt_content ) ) );
$field_option_value = $robots_txt_content;
}
} else {
// Manage robots.txt feature is enabled
if ( array_key_exists( 'robots_txt_content', $options ) && $options['robots_txt_content'] ) {
$field_option_value = $options['robots_txt_content'];
} else {
$robots_txt_content = wp_remote_get( get_site_url() . '/robots.txt' );
$robots_txt_content = esc_textarea( trim( wp_remote_retrieve_body( $robots_txt_content ) ) );
$field_option_value = $robots_txt_content;
}
}
} else {
// Manage robots.txt feature has never been enabled yet
$robots_txt_content = wp_remote_get( get_site_url() . '/robots.txt' );
$robots_txt_content = esc_textarea( trim( wp_remote_retrieve_body( $robots_txt_content ) ) );
$field_option_value = $robots_txt_content;
}
} else {
$field_option_value = ( isset( $options[$args['field_id']] ) ? $options[$args['field_id']] : '' );
}
echo '
';
if ( !empty( $field_intro ) ) {
echo '
' . wp_kses_post( $field_intro ) . '
';
}
echo '
';
if ( !empty( $field_description ) ) {
echo '
' . wp_kses_post( $field_description ) . '
';
}
echo '
';
}
/**
* Render textarea field as sub-field of a toggle/switcher checkbox
*
* @since 2.3.0
*/
function render_wpeditor_subfield( $args ) {
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_slug = $args['field_slug'];
$field_name = $args['field_name'];
$field_type = $args['field_type'];
$field_intro = $args['field_intro'];
$field_description = $args['field_description'];
$field_placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' );
$field_option_value = ( isset( $options[$args['field_id']] ) ? $options[$args['field_id']] : '' );
$editor_settings = $args['editor_settings'];
// https://developer.wordpress.org/reference/classes/_wp_editors/parse_settings/
echo '
';
if ( !empty( $field_intro ) ) {
echo '
' . wp_kses_post( $field_intro ) . '
';
}
$content = $field_option_value;
$editor_id = str_replace( array('[', ']'), array('--', ''), $field_name );
// vi( $editor_id, '', 'for ' . $field_name );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wp_editor( $content, $editor_id, $editor_settings );
if ( !empty( $field_description ) ) {
echo '
' . wp_kses_post( $field_description ) . '
';
}
echo '
';
}
/**
* Render custom HTML subfield
*
* @since 5.3.0
*/
function render_custom_html( $args ) {
echo wp_kses( $args['html'], get_kses_with_custom_html_ruleset() );
}
/**
* Render media subfield
*
* @since 6.2.2
*/
function render_media_subfield( $args ) {
$field_id = $args['field_id'];
$field_slug = $args['field_slug'];
$field_name = $args['field_name'];
$field_media_frame_title = $args['field_media_frame_title'];
$field_media_frame_multiple = $args['field_media_frame_multiple'];
$field_media_frame_library_type = $args['field_media_frame_library_type'];
$field_media_frame_button_text = $args['field_media_frame_button_text'];
$field_intro = $args['field_intro'];
$field_description = $args['field_description'];
$options = get_option( $args['option_name'], array() );
$field_option_value = ( isset( $options[$field_id] ) ? $options[$field_id] : '' );
?>
' . wp_kses_post( $field_description ) . '
';
}
?>
';
// Hidden input field to store hidden menu items (from options as is, or 'Hide' checkbox clicks) upon clicking Save Changes.
$this->output_admin_menu_organizer_hidden_field( 'custom_menu_hidden' );
// Hidden input field to store custom menu titles (from options as is, or custom values entered on each non-WP-default menu items.
$this->output_admin_menu_organizer_hidden_field( 'custom_menu_titles' );
}
/**
* Output hidden field
*
* @since 6.9.13
*/
public function output_admin_menu_organizer_hidden_field( $field_id ) {
$options_extra = get_option( ASENHA_SLUG_U . '_extra', array() );
$options = ( isset( $options_extra['admin_menu'] ) ? $options_extra['admin_menu'] : array() );
$field_name = $field_id;
$field_option_value = ( isset( $options[$field_id] ) ? $options[$field_id] : '' );
echo '
';
}
/**
* Render textarea field as sub-field of a toggle/switcher checkbox
*
* @since 2.3.0
*/
function render_datatable( $args ) {
global $wpdb;
$option_name = $args['option_name'];
if ( !empty( $option_name ) ) {
$options = get_option( $option_name, array() );
} else {
$options = get_option( ASENHA_SLUG_U, array() );
}
$field_id = $args['field_id'];
$field_slug = $args['field_slug'];
$field_name = $args['field_name'];
$field_type = $args['field_type'];
$field_description = $args['field_description'];
$table_title = $args['table_title'];
$table_name = $args['table_name'];
$field_option_value = ( isset( $options[$args['field_id']] ) ? $options[$args['field_id']] : '' );
?>
' . esc_html( $field_description ) . '