'; 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'] ) { // For when the options / sub-fields occupy lengthy vertical space, we add show all / less toggler if ( array_key_exists( 'field_options_moreless', $args ) && $args['field_options_moreless'] ) { echo '
'; echo '' . __( 'Expand', 'admin-site-enhancements' ) . ' ▼'; echo '
'; } 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 = ''; } $field_disabled = !empty( $args['field_disabled'] ); // Disabled checkboxes are omitted from POST; preserve a checked value so save does not wipe it. if ( $field_disabled && $field_option_value ) { echo ''; } echo ''; echo ''; } /** * 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'] : '' ); $field_id = ( isset( $args['field_id'] ) ? $args['field_id'] : '' ); if ( 'image_upload_control_client_side_processing' === $field_id ) { // Default on for WP 7.1+ when the option has never been saved. $default_value = true; } elseif ( 'external_links_new_tab_add_nofollow' === $field_id ) { // Default on so existing sites keep adding nofollow until the option is saved. $default_value = true; } elseif ( 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 ( !empty( $parent_field_id ) && !empty( $sub_field_id ) && isset( $options[$parent_field_id][$sub_field_id][$args['field_id']] ) ) { $field_option_value = $options[$parent_field_id][$sub_field_id][$args['field_id']]; } elseif ( in_array( $parent_field_id, array('redirect_after_login_for_separate', 'redirect_after_logout_for_separate'), true ) && !empty( $sub_field_id ) ) { $field_option_value = ( isset( $options[$sub_field_id][$args['field_id']] ) ? $options[$sub_field_id][$args['field_id']] : $default_value ); } elseif ( empty( $parent_field_id ) && !empty( $args['field_id'] ) ) { $field_option_value = ( isset( $options[$args['field_id']] ) ? $options[$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 ''; if ( !empty( $args['field_description'] ) ) { $desc_display = ( isset( $args['field_description_display'] ) ? $args['field_description_display'] : 'inline' ); if ( 'tooltip' === $desc_display ) { echo ''; echo ''; echo '' . esc_html( $args['field_description'] ) . ''; echo ''; } else { echo '
' . wp_kses_post( $args['field_description'] ) . '
'; } } } /** * 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 ''; } 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() ); $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 ( !empty( $parent_field_id ) && !empty( $sub_field_id ) && isset( $options[$parent_field_id][$sub_field_id][$field_id] ) ) { $field_option_value = (array) $options[$parent_field_id][$sub_field_id][$field_id]; } else { $field_option_value = ( isset( $options[$field_id] ) ? (array) $options[$field_id] : $default_value ); } // Back-compat: legacy naming for Two-Factor Recovery Codes. if ( in_array( $field_id, array('two_factor_available_providers', 'available_providers'), true ) && is_array( $field_option_value ) ) { $field_option_value = array_map( static function ( $provider_key ) { return ( 'backup_codes' === $provider_key ? 'recovery_codes' : $provider_key ); }, $field_option_value ); } echo '
'; foreach ( $field_options as $option_label => $option_value ) { $checkbox_id = ( !empty( $parent_field_id ) && !empty( $sub_field_id ) ? $parent_field_id . '_' . $sub_field_id . '_' . $field_id . '_' . $option_value : $field_id . '_' . $option_value ); echo '
'; echo ''; echo ''; 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 = ( isset( $args['field_prefix'] ) ? $args['field_prefix'] : '' ); $field_suffix = ( isset( $args['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 { $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 ); if ( !empty( $field_description ) ) { echo ''; } } /** * Render a sensitive key subfield with a mostly masked value (asterisks + trailing chars). * * Full keys are never echoed into the HTML value attribute. Editable fields clear the * mask on focus via admin-page.js so a replacement key can be pasted. * * @since 9.0.3 * * @param array $args Settings field arguments. * @return void */ function render_sensitive_key_subfield( $args ) { $option_name = ( isset( $args['option_name'] ) ? $args['option_name'] : ASENHA_SLUG_U ); 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_prefix = ( isset( $args['field_prefix'] ) ? $args['field_prefix'] : '' ); $field_suffix = ( isset( $args['field_suffix'] ) ? $args['field_suffix'] : '' ); $field_placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' ); $field_description = ( isset( $args['field_description'] ) ? $args['field_description'] : '' ); $field_is_read_only = ( isset( $args['read_only'] ) ? (bool) $args['read_only'] : false ); $stored_value = ( isset( $options[$field_id] ) ? (string) $options[$field_id] : '' ); $common_methods = new Common_Methods(); $display_value = $common_methods->asenha_mask_sensitive_key( $stored_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; } $field_classname .= ' asenha-sensitive-key'; echo wp_kses_post( $field_prefix ); echo ''; echo wp_kses_post( $field_suffix ); if ( !empty( $field_description ) ) { echo ''; } } /** * 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 ''; } /** * 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_post( $field_description ) . '
'; } /** * Render View Admin as Role recovery URL description at display time. * * @since 8.8.5 * @param array $args Settings field arguments. * @return void */ function render_view_admin_as_role_recovery_description( $args ) { $view_admin_as_role = new View_Admin_As_Role(); $recovery_url = $view_admin_as_role->get_recovery_url_for_settings( get_current_user_id() ); $field_description = '
'; $field_description .= esc_html__( 'Logging out, or returning after the login session ends, restores your administrator role. Log in again with your usual password.', 'admin-site-enhancements' ); $field_description .= '

' . sprintf( /* translators: %s is the secret recovery URL or instructional text */ __( 'If a firewall blocks the account, or that automatic restore does not run, visit this secret URL while logged out:
%s', 'admin-site-enhancements' ), esc_html( $recovery_url ) ); $field_description .= '

' . __( 'If you use Ninja Firewall, please uncheck "Block attempts to gain administrative privileges" in the Firewall Policies settings before you try to view as a non-admin user role to prevent being locked out of your admin account.', 'admin-site-enhancements' ); $field_description .= '

' . __( 'Please also create at least one backup admin user as a last resort if your primary admin user cannot log in as an administrator. With this second admin user, you can restore the administrator role for your primary admin user.', 'admin-site-enhancements' ); $field_description .= '
'; echo '
' . wp_kses_post( $field_description ) . '
'; } /** * 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']] : '' ); $hide_stored_value = ( isset( $args['hide_stored_value'] ) ? (bool) $args['hide_stored_value'] : false ); 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 ( $hide_stored_value ) { $field_option_value = ''; } $placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' ); echo wp_kses_post( $field_prefix ) . '' . wp_kses_post( $field_suffix ); echo ''; } /** * Render SMTP password field with live storage status and inline warning. * * @since 8.8.7 * * @param array $args Field registration arguments. * @return void */ function render_smtp_password_subfield( $args ) { $option_name = ( isset( $args['option_name'] ) ? $args['option_name'] : ASENHA_SLUG_U ); $field_name = $args['field_name']; $placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' ); if ( function_exists( '\\asenha_get_option_array' ) ) { $options = \asenha_get_option_array( $option_name, true ); } else { $options = get_option( $option_name, array() ); } $email_delivery = new Email_Delivery(); $ui_state = ( method_exists( $email_delivery, 'get_smtp_password_ui_state' ) ? $email_delivery->get_smtp_password_ui_state( $options ) : array( 'description' => __( 'Leave blank to keep the current password.', 'admin-site-enhancements' ), 'show_warning' => false, 'warning_message' => '', ) ); echo '
'; echo ''; echo ''; echo ''; echo '
'; } /** * Render encrypted Google Maps API key subfield for Custom Content Types. * * @since 8.9.2 * * @param array $args Field registration arguments. * @return void */ function render_cct_google_maps_api_key_subfield( $args ) { $option_name = ( isset( $args['option_name'] ) ? $args['option_name'] : ASENHA_SLUG_U ); $field_name = $args['field_name']; $placeholder = ( isset( $args['field_placeholder'] ) ? $args['field_placeholder'] : '' ); if ( function_exists( '\\asenha_get_option_array' ) ) { $options = \asenha_get_option_array( $option_name, true ); } else { $options = get_option( $option_name, array() ); } if ( !class_exists( __NAMESPACE__ . '\\CCT_Secrets' ) ) { require_once ASENHA_PATH . 'includes/premium/custom-content/class-cct-secrets.php'; } $cct_secrets = new CCT_Secrets(); $ui_state = $cct_secrets->get_api_key_ui_state( $options ); echo '
'; echo ''; echo ''; echo '
'; } /** * 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']; $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 ( isset( $field_select_default ) && false !== $field_select_default && '' !== $field_select_default ) { $default_value = $field_select_default; } else { $default_value = false; } if ( !empty( $parent_field_id ) && !empty( $sub_field_id ) && isset( $options[$parent_field_id][$sub_field_id][$field_id] ) ) { $field_option_value = $options[$parent_field_id][$sub_field_id][$field_id]; } else { $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 ''; 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' ); } /** * Decode and re-encode JSON option values for AMO hidden fields so WordPress-slashed or legacy * strings become valid for JavaScript JSON.parse(), without applying stripslashes() to raw strings * (which would break JSON \\u Unicode escapes). * * @since 8.5.3 * * @param string $value Raw option value. * @return string */ private function normalize_admin_menu_json_option_for_output( $value ) { if ( !is_string( $value ) || '' === $value ) { return $value; } // Use objects (not associative arrays) so JSON objects stay objects and arrays stay arrays. $decoded = json_decode( $value, false ); if ( JSON_ERROR_NONE === json_last_error() ) { return wp_json_encode( $decoded ); } $decoded = json_decode( wp_unslash( $value ), false ); if ( JSON_ERROR_NONE === json_last_error() ) { return wp_json_encode( $decoded ); } return $value; } /** * 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] : '' ); $json_option_field_ids = array( 'custom_menu_new_separators', 'custom_menu_deleted_separators', 'custom_submenus_order', 'custom_menu_always_hidden', 'custom_submenu_always_hidden', 'custom_menu_new_items' ); if ( in_array( $field_id, $json_option_field_ids, true ) ) { $field_option_value = $this->normalize_admin_menu_json_option_for_output( $field_option_value ); } 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']] : '' ); $login_fails_allowed = ( isset( $options['login_fails_allowed'] ) ? (int) $options['login_fails_allowed'] : 3 ); $login_lockout_maxcount = ( isset( $options['login_lockout_maxcount'] ) ? (int) $options['login_lockout_maxcount'] : 3 ); $login_fails_allowed = ( $login_fails_allowed > 0 ? $login_fails_allowed : 3 ); $login_lockout_maxcount = ( $login_lockout_maxcount > 0 ? $login_lockout_maxcount : 3 ); $default_lockout_period = 60 * 15; // 15 minutes in seconds. $extended_lockout_period = 24 * 60 * 60; // 24 hours in seconds. $now = time(); $ip_address_whitelist = array(); ?> prepare( "SELECT * FROM {$table_name} ORDER BY unixtime DESC LIMIT %d", array($limit) ); $entries = $wpdb->get_results( $sql, ARRAY_A ); foreach ( $entries as $entry ) { $unixtime = $entry['unixtime']; $ip_address = ( isset( $entry['ip_address'] ) ? (string) $entry['ip_address'] : '' ); $fail_count = ( isset( $entry['fail_count'] ) ? (int) $entry['fail_count'] : 0 ); $lockout_count = ( isset( $entry['lockout_count'] ) ? (int) $entry['lockout_count'] : 0 ); $locked_condition = $fail_count > 0 && $fail_count % $login_fails_allowed === 0; $is_extended_lockout = $lockout_count >= $login_lockout_maxcount; $lockout_period = ( $is_extended_lockout ? $extended_lockout_period : $default_lockout_period ); $is_locked_out = $locked_condition && $now - (int) $unixtime <= $lockout_period; $is_whitelisted = in_array( $ip_address, $ip_address_whitelist, true ); if ( function_exists( 'wp_date' ) ) { $date = wp_date( 'F j, Y', $unixtime ); $time = wp_date( 'H:i:s', $unixtime ); } else { $date = date_i18n( 'F j, Y', $unixtime ); $time = date_i18n( 'H:i:s', $unixtime ); } ?>
Last Username', 'admin-site-enhancements' ); ?> Lockouts', 'admin-site-enhancements' ); ?>



' . esc_html( $field_description ) . '
'; echo ''; } /** * Render checks and status for AVIF support * * @link https://php.watch/versions/8.1/gd-avif * @since 5.7.0 */ public function render_avif_support_status() { // Check status of GD extension and it's AVIF support if ( extension_loaded( 'gd' ) && function_exists( 'gd_info' ) ) { $is_gd_enabled = true; $gd_info = gd_info(); $gd_version = $gd_info['GD Version']; $gd_avif_support = ( isset( $gd_info['AVIF Support'] ) ? isset( $gd_info['AVIF Support'] ) : false ); if ( $gd_avif_support ) { $gd_status = $gd_version . ' ' . __( 'with AVIF support', 'admin-site-enhancements' ) . ''; } else { $gd_status = $gd_version . ' ' . __( 'without AVIF support', 'admin-site-enhancements' ) . ''; } } else { $is_gd_enabled = false; $gd_avif_support = false; $gd_status = __( 'Not available', 'admin-site-enhancements' ); } // Check status of ImageMagick library and it's AVIF support if ( extension_loaded( 'imagick' ) && class_exists( 'Imagick' ) ) { $is_imagick_enabled = true; $imagick_version = \Imagick::getVersion(); if ( preg_match( '/((?:[0-9]+\\.?)+)/', $imagick_version['versionString'], $matches ) ) { $imagick_version = $matches[0]; } else { $imagick_version = $imagick_version['versionString']; } if ( version_compare( $imagick_version, '7.0.25', '>=' ) ) { $imagick_avif_support = true; $imagick_status = $imagick_version . ' with AVIF support'; } else { $imagick_avif_support = false; $imagick_status = $imagick_version . ' without AVIF support'; } } else { $is_imagick_enabled = false; $imagick_avif_support = false; $imagick_status = __( 'Not available', 'admin-site-enhancements' ); } echo '
'; echo '
' . __( 'AVIF Support Status', 'admin-site-enhancements' ) . '
'; echo '
'; echo '
PHP : ' . wp_kses_post( phpversion() ) . '
'; echo '
GD : ' . wp_kses_post( $gd_status ) . '
'; echo '
ImageMagick : ' . wp_kses_post( $imagick_status ) . '
'; echo '
'; echo ''; echo '
'; } }