' . esc_html__( 'Settings', 'ai-for-seo' ) . ''; } return $notice; } /** * Explain unavailable account facts without presenting them as zero credits or a free plan. * * @param bool $show_link Include navigation when no adjacent account control exists. * @return string Escaped inline notice; no stored notification or refresh loop. */ function ai4seo_get_account_quality_notice( bool $show_link = true ): string { $account = ai4seo_get_account_readiness(); if ( $account['credits_ready'] && $account['plan_ready'] ) { return ''; } $html = '

' . esc_html( $account['message'] ) . '

'; if ( null !== $account['last_sync'] ) { $html .= '

' . sprintf( /* translators: %s: Date and time of the last successful account synchronization. */ esc_html__( 'Last confirmed account update: %s', 'ai-for-seo' ), esc_html( wp_date( 'Y-m-d H:i', $account['last_sync'] ) ) ) . '

'; } if ( $show_link && ai4seo_can_administer_plugin() ) { $html .= '

' . esc_html__( 'Account settings', 'ai-for-seo' ) . '

'; } elseif ( ! $show_link && ai4seo_can_administer_plugin() ) { $html .= ai4seo_get_icon_button_tag( 'rotate', __( 'Refresh account data', 'ai-for-seo' ), '', 'ai4seo_refresh_robhub_account(this); return false;' ); } return $html . '
'; } // region OUTPUT FUNCTIONS ====================================================================== \\ // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯. /** * Render an attachment preview as an image, with a local fallback for SVG load failures. * * @param string $image_url Image source URL, including filtered offloaded URLs. * @param string $alt_text Accessible image description. * @param string $mime_type Attachment MIME type. * @return string Escaped image markup; attachment SVG markup is never inlined. */ function ai4seo_get_attachment_preview_image_tag( string $image_url, string $alt_text, string $mime_type ): string { $attributes = ''; $image_url = esc_url( $image_url ); if ( 'image/svg+xml' === $mime_type ) { $fallback_url = ai4seo_get_assets_images_url( 'icons/document-svg.svg' ); $fallback_alt = __( 'SVG image preview unavailable', 'ai-for-seo' ); $attributes = ' class="ai4seo-svg-preview-image"' . ' data-ai4seo-image-fallback-src="' . esc_url( $fallback_url ) . '"' . ' data-ai4seo-image-fallback-alt="' . esc_attr( $fallback_alt ) . '"'; if ( '' === $image_url ) { $image_url = esc_url( $fallback_url ); $alt_text = $fallback_alt; } } return '' . esc_attr( $alt_text ) . ''; } /** * Returns the SVG tag for the given (fontawesome) icon name * * @param string $icon_name The name of the icon. Check function for allowed icon names. * @param string $alt_text Alternative text for a non-decorative icon. * @param string $icon_css_class Additional icon CSS classes. * @param bool $is_decorative Whether the icon is decorative (optional). * @return string The icon SVG tag */ function ai4seo_get_svg_tag( string $icon_name, string $alt_text = '', string $icon_css_class = '', bool $is_decorative = false ): string { // Use the shared icon registry so output helpers cannot render arbitrary SVG markup. $svg_tags = ai4seo_get_svg_tags(); // Return no markup when a caller requests an icon outside the registry. if ( ! isset( $svg_tags[ $icon_name ] ) ) { return ''; } $svg_tag = $svg_tags[ $icon_name ]; // Keep the base icon class on every registry entry while allowing one caller-specific modifier. if ( $icon_css_class ) { $icon_css_class = 'ai4seo-icon ' . $icon_css_class; } else { $icon_css_class = 'ai4seo-icon'; } $svg_tag = str_replace( '', '' . esc_html( $alt_text ) . '', $svg_tag ); } elseif ( $is_decorative ) { $svg_tag = str_replace( '