';
// === AI4SEO_SETTING_GLOBAL_CUSTOM_INSTRUCTIONS ========================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_GLOBAL_CUSTOM_INSTRUCTIONS;
$ai4seo_this_setting_description = esc_html__( 'These instructions are added to every metadata and media attribute generation prompt.', 'ai-for-seo' );
// Render the setting through the shared wrapper so save-anything names and counters stay aligned.
ai4seo_echo_wp_kses(
ai4seo_get_custom_instructions_setting_form_item_tag(
$ai4seo_this_setting_name,
esc_html__( 'Global Custom Instructions', 'ai-for-seo' ) . ':',
$ai4seo_this_setting_description,
esc_html__( 'Global Custom Instructions', 'ai-for-seo' ),
'',
'',
'global'
)
);
// === AI4SEO_SETTING_DEFAULT_EDITOR_VIEW_MODE =========================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_DEFAULT_EDITOR_VIEW_MODE;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_editor_default_view_mode();
// Keep this global choice beside the instructions shared by both entry editors.
echo "";
echo "
";
echo "';
echo "
";
echo "';
echo "
" . esc_html__( 'Choose whether Preview or Editor mode opens first in both the Metadata and Media Attributes editors. You can switch modes at any time inside an editor.', 'ai-for-seo' ) . '
';
echo '
';
echo '
';
// === AI4SEO_SETTING_ENABLE_NATIVE_BULK_ACTIONS ========================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_ENABLE_NATIVE_BULK_ACTIONS;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = (bool) ai4seo_get_setting( $ai4seo_this_setting_name );
// Resolve plugin-name text once so native-list integration copy stays aligned; escape at output boundaries.
$ai4seo_plugin_name = ai4seo_get_plugin_name();
$ai4seo_this_setting_checkbox_label = sprintf(
/* translators: %s: Plugin name. */
__( 'Show %s bulk actions in native WordPress lists', 'ai-for-seo' ),
$ai4seo_plugin_name
);
$ai4seo_this_setting_description = sprintf(
/* translators: %1$s: Plugin name, %2$s: Plugin name. */
__(
'Enable this to add %1$s bulk actions to native WordPress post, page, product, and Media Library tables. When disabled, bulk actions remain available only inside %2$s plugin pages.',
'ai-for-seo'
),
$ai4seo_plugin_name,
$ai4seo_plugin_name
);
// Separate this site-integration toggle from the global prompt instructions above it.
echo "";
// Render as a normal boolean setting so the shared save-anything handler can persist the checkbox value.
echo "
';
// === AI4SEO_SETTING_ACTIVE_META_TAGS ========================================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_ACTIVE_META_TAGS;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = esc_html__( 'Select which meta tags to include or exclude from plugin generation. Does not affect meta tags from other plugins.', 'ai-for-seo' );
// Divider
// echo "";.
// Display form elements.
echo "
';
// Reuse the active SEO plugin details for the external metadata button copy and the third-party sync settings below.
$ai4seo_active_third_party_seo_plugin_details = ai4seo_get_active_third_party_seo_plugin_details();
// === AI4SEO_SETTING_ENABLE_EXTERNAL_METADATA_GENERATE_BUTTONS ======================================= \\
$ai4seo_this_setting_name = AI4SEO_SETTING_ENABLE_EXTERNAL_METADATA_GENERATE_BUTTONS;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = (bool) ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_external_metadata_generate_button_location_names = array();
// List only SEO integrations where external metadata buttons can appear on this site.
$ai4seo_external_metadata_generate_button_seo_plugin_identifiers = array(
AI4SEO_THIRD_PARTY_PLUGIN_YOAST_SEO,
AI4SEO_THIRD_PARTY_PLUGIN_RANK_MATH,
AI4SEO_THIRD_PARTY_PLUGIN_SEO_KEY,
);
foreach ( $ai4seo_external_metadata_generate_button_seo_plugin_identifiers as $ai4seo_this_external_metadata_generate_button_seo_plugin_identifier ) {
if ( empty( $ai4seo_active_third_party_seo_plugin_details[ $ai4seo_this_external_metadata_generate_button_seo_plugin_identifier ] ) ) {
continue;
}
$ai4seo_this_external_metadata_generate_button_seo_plugin_details = $ai4seo_active_third_party_seo_plugin_details[ $ai4seo_this_external_metadata_generate_button_seo_plugin_identifier ];
$ai4seo_external_metadata_generate_button_location_names[] = $ai4seo_this_external_metadata_generate_button_seo_plugin_details['name'] ?? $ai4seo_this_external_metadata_generate_button_seo_plugin_identifier;
}
// Add page-builder locations separately because they do not live in the active SEO plugin details map.
if ( ai4seo_is_plugin_or_theme_active( AI4SEO_THIRD_PARTY_PLUGIN_ELEMENTOR ) ) {
$ai4seo_external_metadata_generate_button_location_names[] = 'Elementor';
}
if ( ai4seo_is_plugin_or_theme_active( AI4SEO_THIRD_PARTY_PLUGIN_BETHEME ) ) {
$ai4seo_external_metadata_generate_button_location_names[] = 'BeBuilder (BeTheme)';
}
$ai4seo_external_metadata_generate_button_location_names = array_unique( $ai4seo_external_metadata_generate_button_location_names );
$ai4seo_this_setting_description = esc_html__( 'Show "Generate with SOOZ" buttons and Metadata Editor shortcuts in supported third-party SEO plugins and page builders.', 'ai-for-seo' );
if ( $ai4seo_external_metadata_generate_button_location_names ) {
$ai4seo_this_setting_description .= ' ';
// Wrap active location names after de-duplication so the dynamic list can be safely passed through KSES.
$ai4seo_external_metadata_generate_button_location_name_tags = array_map(
function ( $ai4seo_this_external_metadata_generate_button_location_name ) {
return '' . esc_html( $ai4seo_this_external_metadata_generate_button_location_name ) . '';
},
$ai4seo_external_metadata_generate_button_location_names
);
/* translators: %s: comma-separated list of active third-party plugins and page builders */
$ai4seo_this_setting_description .= sprintf( esc_html__( 'Supported third-party SEO plugins and page builders where additional metadata buttons and shortcuts can be displayed: %s.', 'ai-for-seo' ), implode( ', ', $ai4seo_external_metadata_generate_button_location_name_tags ) );
} else {
$ai4seo_this_setting_description .= ' ' . esc_html__( 'No supported third-party SEO plugin or page builder was found where our additional metadata buttons or shortcuts can be displayed.', 'ai-for-seo' );
}
// Build logo-aware labels manually because the visible copy includes the sanitized SOOZ SVG.
$ai4seo_this_setting_description .= ' ' . esc_html__( 'Disable this to keep external metadata editors unchanged while keeping the Metadata Editor available from the top bar.', 'ai-for-seo' );
$ai4seo_sooz_logo_tag = ai4seo_get_svg_tag( 'sooz', 'SOOZ', 'ai4seo-sooz-logo' );
/* translators: %s: SOOZ logo */
$ai4seo_generate_with_sooz_buttons_label = sprintf( esc_html__( '"Generate with %s" buttons', 'ai-for-seo' ), $ai4seo_sooz_logo_tag );
/* translators: %s: SOOZ logo */
$ai4seo_generate_with_sooz_buttons_toggle_label = sprintf( esc_html__( 'Show additional "Generate with %s" buttons in external editors', 'ai-for-seo' ), $ai4seo_sooz_logo_tag );
echo "";
echo "
';
// === AI4SEO_SETTING_DISABLED_TAXONOMY_TERMS ================================================ \\
$ai4seo_this_setting_name = AI4SEO_SETTING_DISABLED_TAXONOMY_TERMS;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_disabled_taxonomy_terms = ai4seo_get_disabled_taxonomy_terms();
$ai4seo_supported_taxonomy_terms = ai4seo_get_supported_taxonomy_terms();
/* translators: %s: plugin name */
$ai4seo_this_setting_description = esc_html__( 'Uncheck any categories if you don’t want their content to be included in the dashboard and the SEO Autopilot. Categories (taxonomy terms) are grouped by taxonomy, and newly detected entries remain enabled by default.', 'ai-for-seo' );
echo "";
echo "
';
// === AI4SEO_SETTING_EXCLUDE_POSTS_IF_ANY_DISABLED_TAXONOMY_TERM ======================= \\
$ai4seo_this_setting_name = AI4SEO_SETTING_EXCLUDE_POSTS_IF_ANY_DISABLED_TAXONOMY_TERM;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = __( 'Keep this disabled to exclude entries only when all assigned categories (taxonomy terms) covered by the filter are disabled.', 'ai-for-seo' );
$ai4seo_this_setting_description .= '
' . esc_html__( 'Enable it if a single disabled category (taxonomy term) should always exclude the entry, even when additional active categories are assigned.', 'ai-for-seo' );
echo "";
echo "
';
// === AI4SEO_SETTING_DISABLED_METADATA_WPML_LANGUAGES ===================================== \\
if ( ai4seo_is_plugin_or_theme_active( AI4SEO_THIRD_PARTY_PLUGIN_WPML ) ) {
$ai4seo_this_setting_name = AI4SEO_SETTING_DISABLED_METADATA_WPML_LANGUAGES;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_disabled_metadata_wpml_language_codes = ai4seo_get_disabled_metadata_wpml_language_codes();
$ai4seo_available_wpml_languages = ai4seo_get_available_wpml_languages();
$ai4seo_available_wpml_language_codes = array_keys( $ai4seo_available_wpml_languages );
$ai4seo_active_metadata_wpml_language_codes = array_values( array_diff( $ai4seo_available_wpml_language_codes, $ai4seo_disabled_metadata_wpml_language_codes ) );
$ai4seo_this_setting_description = esc_html__( 'Uncheck any WPML language if you do not want posts WPML assigns to that language to be included in the dashboard and the SEO Autopilot. Newly detected WPML languages stay active by default.', 'ai-for-seo' );
echo "";
echo "
';
}
// === AI4SEO_SETTING_METADATA_GENERATION_LANGUAGE =========================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_METADATA_GENERATION_LANGUAGE;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = '';
if ( ai4seo_is_plugin_or_theme_active( AI4SEO_THIRD_PARTY_PLUGIN_WPML ) ) {
$ai4seo_this_setting_description .= sprintf(
/* translators: 1: WPML (plugin name), 2: WPML (plugin name) */
esc_html__( '%1$s detected. Use “Automatic” to determine which language to use based on %2$s.', 'ai-for-seo' ),
'WPML',
'WPML'
);
} else {
$ai4seo_this_setting_description .= esc_html__( "Select a specific language or choose 'Automatic' to let AI determine the best language for each content entry.", 'ai-for-seo' );
}
// Divider.
echo "";
echo "
";
echo esc_html__( 'Choose how each meta tag should behave when no value is available or has not been generated.', 'ai-for-seo' );
echo '
';
echo '
';
echo '
';
// === AI4SEO_SETTING_METADATA_PREFIXES & AI4SEO_SETTING_METADATA_SUFFIXES =================== \\
$ai4seo_metadata_prefix_setting_name = AI4SEO_SETTING_METADATA_PREFIXES;
$ai4seo_metadata_suffix_setting_name = AI4SEO_SETTING_METADATA_SUFFIXES;
// Prefix.
$ai4seo_metadata_prefix_setting_input_name = "ai4seo_{$ai4seo_metadata_prefix_setting_name}";
$ai4seo_metadata_prefix_setting_input_value = ai4seo_get_setting( $ai4seo_metadata_prefix_setting_name );
// Suffix.
$ai4seo_metadata_suffix_setting_input_name = "ai4seo_{$ai4seo_metadata_suffix_setting_name}";
$ai4seo_metadata_suffix_setting_input_value = ai4seo_get_setting( $ai4seo_metadata_suffix_setting_name );
// Description for both prefix and suffix.
$ai4seo_this_setting_description = esc_html__( "Add prefix and suffix text to metadata fields. Applied only when 'Meta Tag Output Mode' is set to 'Replace' or 'Force'. Useful for including website name or branding elements consistently across all metadata.", 'ai-for-seo' );
$ai4seo_metadata_placeholders_tooltip = __( 'Available placeholders (case-insensitive; supports {PLACEHOLDER}, [PLACEHOLDER], or %%placeholder%% formats): WEBSITE_URL - Site URL. WEBSITE_NAME - Site name. POST_ID - Current entry ID. TITLE - Current entry title. PRODUCT_NAME - WooCommerce product title (products only). PRODUCT_PRICE - WooCommerce product price (products only).
Placeholders are replaced automatically when meta tags are injected on the frontend.', 'ai-for-seo' );
// Divider.
echo "";
// Display form elements.
echo "
';
// === AI4SEO_SETTING_APPLY_CHANGES_TO_THIRD_PARTY_SEO_PLUGIN ============================================= \\
$ai4seo_this_setting_name = AI4SEO_SETTING_APPLY_CHANGES_TO_THIRD_PARTY_SEO_PLUGINS;
$ai4seo_sync_activated_third_party_seo_plugins = array();
$ai4seo_uses_workarounds_for_third_party_seo_plugins = false;
$ai4seo_inbound_sync_third_party_seo_plugin_identifiers = array();
$ai4seo_sync_workaround_plugin_identifiers = array(
AI4SEO_THIRD_PARTY_PLUGIN_SLIM_SEO,
AI4SEO_THIRD_PARTY_PLUGIN_ALL_IN_ONE_SEO,
AI4SEO_THIRD_PARTY_PLUGIN_SQUIRRLY_SEO,
);
// Derive warning and reverse-sync presentation state from the active integration registry in one pass.
foreach ( $ai4seo_active_third_party_seo_plugin_details as $ai4seo_active_third_party_seo_plugin_identifier => $ai4seo_active_third_party_seo_plugin_detail ) {
if ( in_array( $ai4seo_active_third_party_seo_plugin_identifier, $ai4seo_sync_workaround_plugin_identifiers, true ) ) {
$ai4seo_uses_workarounds_for_third_party_seo_plugins = true;
}
$ai4seo_supports_inbound_sync = ai4seo_does_third_party_seo_plugin_support_inbound_sync(
$ai4seo_active_third_party_seo_plugin_detail
);
if ( $ai4seo_supports_inbound_sync ) {
$ai4seo_inbound_sync_third_party_seo_plugin_identifiers[] = $ai4seo_active_third_party_seo_plugin_identifier;
}
}
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
// Resolve reverse-sync names through the shared registry naming helper used by operation reporting.
$ai4seo_inbound_sync_third_party_seo_plugin_names = ai4seo_get_third_party_seo_plugin_names(
$ai4seo_inbound_sync_third_party_seo_plugin_identifiers
);
// Mention active reverse-capable integrations only when the registry supplies at least one display name.
if ( $ai4seo_inbound_sync_third_party_seo_plugin_names ) {
$ai4seo_this_setting_description = sprintf(
/* translators: %1$s: AI for SEO plugin name, %2$s: comma-separated third-party SEO plugin names. */
esc_html__( 'Sync %1$s changes to selected third-party SEO plugins. Saved changes in supported integrations (%2$s) also sync back to %1$s for the metadata selected below.', 'ai-for-seo' ),
esc_html( AI4SEO_PLUGIN_NAME ),
esc_html( implode( ', ', $ai4seo_inbound_sync_third_party_seo_plugin_names ) )
);
} else {
// Keep the description accurate when no active integration currently supports reverse synchronization.
$ai4seo_this_setting_description = sprintf(
/* translators: %s: AI for SEO plugin name. */
esc_html__( 'Sync %s changes to selected third-party SEO plugins for the metadata selected below.', 'ai-for-seo' ),
esc_html( AI4SEO_PLUGIN_NAME )
);
}
if ( $ai4seo_uses_workarounds_for_third_party_seo_plugins ) {
$ai4seo_this_setting_description .= '
";
if ( $ai4seo_active_third_party_seo_plugin_details ) {
// Define variable for the selected user-roles based on plugin-settings.
$ai4seo_sync_activated_third_party_seo_plugins = ( $ai4seo_this_setting_input_value && is_array( $ai4seo_this_setting_input_value ) ? $ai4seo_this_setting_input_value : array() );
// Name the synchronization group when multiple provider choices need a select-all control.
if ( count( $ai4seo_active_third_party_seo_plugin_details ) > 1 ) {
ai4seo_echo_wp_kses( ai4seo_get_select_all_checkbox( $ai4seo_this_setting_input_name, 'auto', __( 'Synchronize Metadata:', 'ai-for-seo' ) ) );
echo "";
}
// Loop through all available user-roles and display checkboxes for each of them.
foreach ( $ai4seo_active_third_party_seo_plugin_details as $ai4seo_this_third_party_seo_plugin_identifier => $ai4seo_this_third_party_seo_plugin_details ) {
// Restore whether this integration is enabled in the saved synchronization setting.
$ai4seo_is_this_checkbox_checked = in_array( $ai4seo_this_third_party_seo_plugin_identifier, $ai4seo_sync_activated_third_party_seo_plugins, true );
$ai4seo_this_checkbox_id = "{$ai4seo_this_setting_input_name}-{$ai4seo_this_third_party_seo_plugin_identifier}";
echo "';
}
echo "
";
echo "";
echo esc_html__( 'Metadata to Sync with Third-Party Plugins:', 'ai-for-seo' );
echo '';
echo "
";
// Define variable for the selected user-roles based on plugin-settings.
$ai4seo_this_checked_values = ( $ai4seo_this_setting_input_value && is_array( $ai4seo_this_setting_input_value ) ? $ai4seo_this_setting_input_value : array() );
// Distinguish synchronized fields from the provider-selection group above.
ai4seo_echo_wp_kses( ai4seo_get_select_all_checkbox( $ai4seo_this_setting_input_name, 'auto', __( 'Metadata to Sync with Third-Party Plugins:', 'ai-for-seo' ) ) );
echo "";
// Loop through all available user-roles and display checkboxes for each of them.
foreach ( $ai4seo_metadata_field_descriptors as $ai4seo_this_metadata_identifier => $ai4seo_this_metadata_details ) {
$ai4seo_this_translated_checkbox_label = $ai4seo_this_metadata_details['name'] ?? $ai4seo_this_metadata_identifier;
$ai4seo_this_checkbox_id = "{$ai4seo_this_setting_input_name}-{$ai4seo_this_metadata_identifier}";
// Restore whether this metadata field is enabled for synchronization.
$ai4seo_is_this_checkbox_checked = in_array( $ai4seo_this_metadata_identifier, $ai4seo_this_checked_values, true );
echo "';
}
echo "
";
echo esc_html__( 'Choose how WooCommerce product prices should be handled in generated metadata: never include them, store a fixed price, or use a dynamic placeholder that updates at render time.', 'ai-for-seo' );
echo '
';
echo '
';
echo '
';
}
// === AI4SEO_SETTING_OVERWRITE_EXISTING_META_TAGS ========================================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_OVERWRITE_EXISTING_METADATA;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = __( 'Overwrite existing metadata when using SEO Autopilot. If disabled, only missing metadata will be generated.', 'ai-for-seo' );
$ai4seo_this_setting_description .= "
";
$ai4seo_this_setting_description .= __( 'Warning: Permanently overwrites existing metadata. Backup recommended before activating SEO Autopilot.', 'ai-for-seo' );
$ai4seo_this_setting_description .= '';
// Divider.
echo "";
// Display form elements.
echo "
';
// === AI4SEO_SETTING_GENERATE_METADATA_FOR_FULLY_COVERED_ENTRIES ========================================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_GENERATE_METADATA_FOR_FULLY_COVERED_ENTRIES;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = __( 'Generate metadata for entries that already have a complete set of metadata. Disable this option to generate metadata only for entries with at least one missing field.', 'ai-for-seo' );
$ai4seo_has_active_overwrite = ! empty( ai4seo_get_active_overwrite_existing_metadata() );
$ai4seo_overwrite_requirement_id = $ai4seo_this_setting_input_name . '-requirement';
// Divider.
echo "";
// Display form elements.
echo "
";
echo "';
echo "
";
echo "';
echo "
';
echo esc_html__( 'Select at least one active field under Overwrite Existing Metadata to enable this option.', 'ai-for-seo' );
echo '
";
ai4seo_echo_wp_kses( __( 'Control how focus keyphrases are generated when a meta title and meta description already exist for an entry. This only affects SEO Autopilot (bulk generation).', 'ai-for-seo' ) );
echo '
';
echo "
";
ai4seo_echo_wp_kses( __( 'Attention: For "Regenerate metadata", make sure that Meta Title and Meta Description are checked in the "Overwrite Existing Metadata" setting.', 'ai-for-seo' ) );
echo '
";
// Disable 'AI for SEO' Meta Tags.
ai4seo_echo_wp_kses( __( 'Disable: Disables all plugin meta tags. Only useful when completely syncing to other SEO plugins.', 'ai-for-seo' ) );
echo '
';
// Force 'AI for SEO' Meta Tags.
ai4seo_echo_wp_kses( __( 'Force: Outputs plugin meta tags regardless of other plugins. May create duplicates.', 'ai-for-seo' ) );
echo '
';
// Replace Existing Meta Tags.
ai4seo_echo_wp_kses( __( 'Replace (Recommended): Replaces existing meta tags, preventing duplicates and cleaning HTML header.', 'ai-for-seo' ) );
echo '
';
// Complement Existing Meta Tags.
ai4seo_echo_wp_kses( __( 'Complement: Adds missing meta tags without overwriting existing ones.', 'ai-for-seo' ) );
echo '
';
// Generation eligibility is separate from viewing and editing existing media attributes.
$ai4seo_file_types_input = ai4seo_get_prefixed_input_name( AI4SEO_SETTING_ENABLED_ATTACHMENT_FILE_TYPES );
$ai4seo_enabled_file_types = ai4seo_get_setting( AI4SEO_SETTING_ENABLED_ATTACHMENT_FILE_TYPES );
echo "
";
// Define variable for the selected user-roles based on plugin-settings.
$ai4seo_this_checked_values = ( $ai4seo_this_setting_input_value && is_array( $ai4seo_this_setting_input_value ) ? $ai4seo_this_setting_input_value : array() );
// Identify the media-attribute group when navigating select-all controls by accessible name.
ai4seo_echo_wp_kses( ai4seo_get_select_all_checkbox( $ai4seo_this_setting_input_name, 'auto', __( 'Active Media Attributes:', 'ai-for-seo' ) ) );
echo "";
// Loop through all available user-roles and display checkboxes for each of them.
foreach ( $ai4seo_attachment_field_descriptors as $ai4seo_this_media_attribute_identifier => $ai4seo_this_media_attribute_details ) {
$ai4seo_this_translated_checkbox_label = $ai4seo_this_media_attribute_details['name'] ?? $ai4seo_this_media_attribute_identifier;
$ai4seo_this_checkbox_id = "{$ai4seo_this_setting_input_name}-{$ai4seo_this_media_attribute_identifier}";
// Restore whether this media attribute is enabled for generation.
$ai4seo_is_this_checkbox_checked = in_array( $ai4seo_this_media_attribute_identifier, $ai4seo_this_checked_values, true );
echo "';
}
echo "
';
// === AI4SEO_SETTING_DISABLED_ATTACHMENT_ATTRIBUTES_WPML_LANGUAGES =========================== \\
if ( ai4seo_is_plugin_or_theme_active( AI4SEO_THIRD_PARTY_PLUGIN_WPML ) ) {
$ai4seo_this_setting_name = AI4SEO_SETTING_DISABLED_ATTACHMENT_ATTRIBUTES_WPML_LANGUAGES;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_disabled_attachment_attributes_wpml_language_codes = ai4seo_get_disabled_attachment_attributes_wpml_language_codes();
$ai4seo_available_wpml_languages = ai4seo_get_available_wpml_languages();
$ai4seo_available_wpml_language_codes = array_keys( $ai4seo_available_wpml_languages );
$ai4seo_active_attachment_attributes_wpml_language_codes = array_values( array_diff( $ai4seo_available_wpml_language_codes, $ai4seo_disabled_attachment_attributes_wpml_language_codes ) );
$ai4seo_this_setting_description = esc_html__( 'Uncheck any WPML language if you do not want media entries WPML assigns to that language to be included in the dashboard and the SEO Autopilot. Newly detected WPML languages stay active by default.', 'ai-for-seo' );
echo "";
echo "
';
}
// === AI4SEO_SETTING_ATTACHMENT_ATTRIBUTES_GENERATION_LANGUAGE ============================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_ATTACHMENT_ATTRIBUTES_GENERATION_LANGUAGE;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
if ( ai4seo_is_plugin_or_theme_active( AI4SEO_THIRD_PARTY_PLUGIN_WPML ) ) {
$ai4seo_this_setting_description = sprintf(
/* translators: %s: WordPress language */
esc_html__( 'WPML detected. Use "Automatic" to detect the language from the image usage context. If the context is unavailable or unclear, it falls back to the WPML language first and then the system language (%s).', 'ai-for-seo' ),
'' . $ai4seo_wordpress_language . '',
);
} else {
$ai4seo_this_setting_description = sprintf(
/* translators: %s: WordPress language */
esc_html__( 'Select a specific language, or choose "- Automatic -" to let the plugin detect the language from the context where the image is used. If the context is unavailable or unclear, it will fall back to the system language (%s).', 'ai-for-seo' ),
'' . $ai4seo_wordpress_language . '',
);
}
// Divider.
echo "";
// Form element.
echo "
';
// === AI4SEO_SETTING_ATTACHMENT_ATTRIBUTES_PREFIXES & AI4SEO_SETTING_ATTACHMENT_ATTRIBUTES_SUFFIXES =================== \\
$ai4seo_attachment_attributes_prefix_setting_name = AI4SEO_SETTING_ATTACHMENT_ATTRIBUTES_PREFIXES;
$ai4seo_attachment_attributes_suffix_setting_name = AI4SEO_SETTING_ATTACHMENT_ATTRIBUTES_SUFFIXES;
// Prefix.
$ai4seo_attachment_attributes_prefix_setting_input_name = "ai4seo_{$ai4seo_attachment_attributes_prefix_setting_name}";
$ai4seo_attachment_attributes_prefix_setting_input_value = ai4seo_get_setting( $ai4seo_attachment_attributes_prefix_setting_name );
// Suffix.
$ai4seo_attachment_attributes_suffix_setting_input_name = "ai4seo_{$ai4seo_attachment_attributes_suffix_setting_name}";
$ai4seo_attachment_attributes_suffix_setting_input_value = ai4seo_get_setting( $ai4seo_attachment_attributes_suffix_setting_name );
// Description for both prefix and suffix.
$ai4seo_this_setting_description = esc_html__( 'Add prefix and suffix text to media attributes for consistent branding. Note: Only applied to newly generated attributes, not existing ones.', 'ai-for-seo' );
$ai4seo_attachment_placeholders_tooltip = __( 'Available placeholders (case-insensitive): {WEBSITE_URL} - Site URL. {WEBSITE_NAME} - Site name. {FILE_NAME} - File name without extension. {FILE_TYPE} - File extension. {FILE_SIZE} - File size in kilobytes. {IMAGE_DIMENSIONS} - Image width x height.
Placeholders are replaced when attributes are saved or injected into the frontend.', 'ai-for-seo' );
// Divider.
echo "";
// Display form elements.
echo "
';
// === AI4SEO_SETTING_ENABLE_ENHANCED_CELEBRITY_RECOGNITION ======================================================== \\
echo "";
$ai4seo_this_setting_name = AI4SEO_SETTING_ENABLE_ENHANCED_CELEBRITY_RECOGNITION;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = (bool) ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = esc_html__( 'Helps identify public figures in images using enhanced recognition. Recognition is not guaranteed; review generated names before publishing.', 'ai-for-seo' );
$ai4seo_premium_plan_html = '';
$ai4seo_upgrade_to_premium_html = '';
// Paid users keep the compact badge, while lower tiers see the shared direct-pricing upgrade prompt.
if ( ! $ai4seo_user_has_premium_plan_or_higher ) {
$ai4seo_upgrade_to_premium_html = ai4seo_get_subscription_upgrade_prompt_tag(
'l',
'use_this_feature',
'ai4seo-setting-upgrade-prompt'
);
} else {
$ai4seo_premium_plan_html = ai4seo_get_plan_badge( 'l' );
}
echo "
";
echo "';
echo "
";
// Keep active Premium accounts visually compact and use the upgrade prompt only when the setting is disabled.
if ( $ai4seo_user_has_premium_plan_or_higher ) {
echo ' ';
ai4seo_echo_wp_kses( $ai4seo_premium_plan_html );
} else {
ai4seo_echo_wp_kses( $ai4seo_upgrade_to_premium_html );
}
echo ' ';
echo "';
echo "
';
// === ALLOWED USER ROLES =========================================================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_ALLOWED_USER_ROLES;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = esc_html__( "Select user roles that should have access to this plugin. Only roles with 'edit_posts' capability are listed.", 'ai-for-seo' );
// Display form elements.
echo "
';
// Divider.
echo "";
// === AI4SEO_SETTING_DEEP_CONTEXT_SEARCH_FOR_IMAGES ===================================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_DEEP_CONTEXT_SEARCH_FOR_IMAGES;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_deep_context_search_site_support_status = ai4seo_get_deep_context_search_site_support_status();
$ai4seo_is_deep_context_search_supported = (bool) ( $ai4seo_deep_context_search_site_support_status['is_supported'] ?? false );
$ai4seo_deep_context_search_blocking_reasons = isset( $ai4seo_deep_context_search_site_support_status['blocking_reasons'] ) && is_array( $ai4seo_deep_context_search_site_support_status['blocking_reasons'] )
? $ai4seo_deep_context_search_site_support_status['blocking_reasons']
: array();
$ai4seo_are_deep_context_search_counts_unavailable = in_array( 'posts_count_unavailable', $ai4seo_deep_context_search_blocking_reasons, true )
|| in_array( 'postmeta_count_unavailable', $ai4seo_deep_context_search_blocking_reasons, true );
if ( ! $ai4seo_is_deep_context_search_supported ) {
ai4seo_maybe_disable_deep_context_search_for_large_site();
$ai4seo_this_setting_input_value = false;
}
$ai4seo_this_setting_description = '';
if ( ! $ai4seo_is_deep_context_search_supported ) {
$ai4seo_this_setting_description .= '' . esc_html__( 'Note:', 'ai-for-seo' ) . ' ';
if ( $ai4seo_are_deep_context_search_counts_unavailable ) {
$ai4seo_this_setting_description .= esc_html__( 'We could not verify the current database size, so this function is unavailable for safety.', 'ai-for-seo' );
} else {
$ai4seo_this_setting_description .= sprintf(
/* translators: 1: posts table entry limit, 2: postmeta table entry limit. */
esc_html__( 'We currently do not support this function for large websites. It is unavailable when the posts table has at least %1$s entries or the postmeta table has at least %2$s entries.', 'ai-for-seo' ),
esc_html( ai4seo_format_number_i18n( AI4SEO_LARGE_SITE_POSTS_THRESHOLD ) ),
esc_html( ai4seo_format_number_i18n( AI4SEO_DEEP_CONTEXT_SEARCH_POSTMETA_THRESHOLD ) )
);
}
$ai4seo_this_setting_description .= '
';
}
$ai4seo_this_setting_description .= esc_html__( 'Enable this option to allow deeper database searches to determine the usage context of images. This can improve the relevance of generated image metadata, especially when context is missing.', 'ai-for-seo' );
$ai4seo_this_setting_description .= '
' . esc_html__( 'On large websites, these extended searches may increase database load during generation. Use this setting if many images lack context and you are comfortable with potential performance impact while content is being processed.', 'ai-for-seo' );
echo "
';
// === AI4SEO_SETTING_ENABLE_RENDER_LEVEL_ALT_TEXT_INJECTION ========================================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_ENABLE_RENDER_LEVEL_ALT_TEXT_INJECTION;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = __( 'Inject alt text at render time and dynamically via JavaScript so images always include the correct alt text, even when themes or page builders omit it.', 'ai-for-seo' );
$ai4seo_this_setting_description .= '
' . __( 'Enable this setting if your theme or page builder does not display alt text generated by the plugin (or omits alt text entirely).', 'ai-for-seo' );
// Divider.
echo "";
// Display form elements.
echo "
';
$ai4seo_alt_injection_enabled = (bool) $ai4seo_this_setting_input_value;
// === AI4SEO_SETTING_ENABLE_JS_ALT_TEXT_INJECTION ===================================================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_ENABLE_JS_ALT_TEXT_INJECTION;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = __( 'Load a JavaScript fallback that injects alt text on the frontend after the page loads. Disable if another script handles this or if only server-side injection should be used. Attention: Can cause slower page loads on some setups.', 'ai-for-seo' );
$ai4seo_potential_js_alt_text_setting_hidden_class = $ai4seo_alt_injection_enabled ? '' : ' ai4seo-js-alt-text-setting-hidden';
echo "
';
// === AI4SEO_SETTING_QUERY_IDS_CHUNK_SIZE ===================================================== \
$ai4seo_this_setting_name = AI4SEO_SETTING_QUERY_IDS_CHUNK_SIZE;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = (int) ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = __( 'Controls how many IDs are grouped per database query when processing large batches.', 'ai-for-seo' );
$ai4seo_this_setting_description .= '
' . __( 'Depending on your MySQL configuration, lowering this value can help resolve query or packet size issues. Higher values can improve performance when your MySQL limits allow larger queries.', 'ai-for-seo' );
// Divider.
echo "";
echo "
';
// === AI4SEO_SETTING_IMAGE_UPLOAD_METHOD ============================== \\
$ai4seo_this_setting_name = AI4SEO_SETTING_IMAGE_UPLOAD_METHOD;
$ai4seo_this_setting_input_name = ai4seo_get_prefixed_input_name( $ai4seo_this_setting_name );
$ai4seo_this_setting_input_value = ai4seo_get_setting( $ai4seo_this_setting_name );
$ai4seo_this_setting_description = __( 'Choose how images are sent to our server: Auto (recommended): Selects method based on accessibility. URL: Always sends image URL. Data: Always sends full image data.', 'ai-for-seo' );
$ai4seo_this_setting_description .= '
';
// Explain why generation can change Auto to Data while preserving an explicit URL preference.
$ai4seo_this_setting_description .= __( 'Auto switches to Data after three consecutive URL requests fail and each retry with image data succeeds. You can change the method again at any time. A manually selected URL method stays unchanged.', 'ai-for-seo' );
$ai4seo_this_setting_description .= '
';
// Keep the manual recovery advice alongside the automatic transport explanation.
$ai4seo_this_setting_description .= __( "Try 'Data' if you experience generation issues. Slower but more reliable in some situations.", 'ai-for-seo' );
// Divider.
echo "";
// Display form elements.
echo "