'bg-green-100 text-green-700', 'pending' => 'bg-yellow-100 text-yellow-700', 'paused' => 'bg-gray-100 text-gray-600', 'expired' => 'bg-red-100 text-red-600', // log levels 'info' => 'bg-teal-50 text-teal-700', 'warning' => 'bg-yellow-100 text-yellow-700', 'error' => 'bg-red-100 text-red-600', 'critical' => 'bg-red-200 text-red-800', 'debug' => 'bg-purple-50 text-purple-700', ); public static function buildBadge( $status ) { $status_class = self::STATUS_BADGE[ strtolower( $status ) ] ?? 'bg-gray-100 text-gray-600'; return '' . esc_html( ucfirst( $status ) ) . ''; } /* ── Notices ────────────────────────────────────────────── */ public static function successNotice( string $message, array $args = array() ): string { if ( empty( trim( $message ) ) ) { return ''; } $defaults = array( 'id' => 'adfuz-success-notice', 'title' => '', 'dismissible' => true, 'icon' => 'yes-alt', 'promo' => self::noticePromo( 'success', $message ), ); $args = wp_parse_args( $args, $defaults ); $args = apply_filters( 'adfuz/ui/notice/success_args', $args, $message ); $id = sanitize_html_class( $args['id'] ); $title = sanitize_text_field( $args['title'] ); $dismissible = ! empty( $args['dismissible'] ); $icon = sanitize_html_class( $args['icon'] ); $promo = wp_parse_args( is_array( $args['promo'] ) ? $args['promo'] : array(), self::noticePromo( 'success', $message ) ); if ( empty( $promo['button_text'] ) && ! empty( $promo['buttontext'] ) ) { $promo['button_text'] = $promo['buttontext']; } $promo_title = sanitize_text_field( $promo['title'] ?? '' ); $promo_text = sanitize_text_field( $promo['text'] ?? '' ); $promo_button_text = sanitize_text_field( $promo['button_text'] ?? '' ); $promo_url = ! empty( $promo['url'] ) ? esc_url( $promo['url'] ) : ''; $promo_target = ( $promo['target'] ?? '_blank' ) === '_self' ? '_self' : '_blank'; $show_promo = ! empty( $promo['show'] ); ob_start(); ?>

%s ', esc_attr( $id ), esc_html( $message ), esc_attr( $id ) ); } // src/Helpers/Common.php public static function svg_icon_allowed_html(): array { $common_attrs = array( 'class' => true, 'id' => true, 'style' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'stroke-dasharray' => true, 'stroke-dashoffset' => true, 'd' => true, 'points' => true, 'x' => true, 'y' => true, 'x1' => true, 'y1' => true, 'x2' => true, 'y2' => true, 'cx' => true, 'cy' => true, 'r' => true, 'rx' => true, 'ry' => true, 'width' => true, 'height' => true, 'transform' => true, 'opacity' => true, ); return array( 'svg' => array_merge( $common_attrs, array( 'xmlns' => true, 'viewbox' => true, 'fill' => true, 'aria-hidden' => true, 'role' => true, 'focusable' => true, ) ), 'path' => $common_attrs, 'circle' => $common_attrs, 'ellipse' => $common_attrs, 'rect' => $common_attrs, 'line' => $common_attrs, 'polyline' => $common_attrs, 'polygon' => $common_attrs, 'g' => $common_attrs, 'defs' => $common_attrs, 'use' => array_merge( $common_attrs, array( 'href' => true, 'xlink:href' => true, ) ), 'symbol' => array_merge( $common_attrs, array( 'viewBox' => true ) ), 'title' => array( 'id' => true ), 'desc' => array(), ); } public static function floating_icons() { return array( 'expanded_icon' => apply_filters( 'adfuz/floating_sidebar/expanded_icon', 'dashicons-no-alt' ), 'expanded_label' => apply_filters( 'adfuz/floating_sidebar/expanded_label', '' ), 'collapsed_icon' => apply_filters( 'adfuz/floating_sidebar/collapsed_icon', 'dashicons-editor-help' ), 'collapsed_label' => apply_filters( 'adfuz/floating_sidebar/collapsed_label', 'Help' ), 'collapsed_color' => apply_filters( 'adfuz/floating_sidebar/collapsed_color', '#4CAF50' ), ); } public static function toastPromoConfig(): array { $default = array( 'enabled' => true, 'upgradeUrl' => admin_url( 'admin.php?page=ad-fuz' ), 'buttonText' => __( 'Upgrade to Pro', 'ad-fuz' ), 'caption' => __( 'Unlock premium ad placements, advanced controls, and pro tools.', 'ad-fuz' ), 'allowedTypes' => array( 'success', 'warning', 'info' ), 'dismissible' => true, 'icon' => 'sparkles', ); $config = apply_filters( 'adfuz/ui/toast/promo_config', $default ); $enabled = apply_filters( 'adfuz/ui/toast/promo_enabled', (bool) ( $config['enabled'] ?? true ) ); $config['enabled'] = (bool) $enabled; return $config; } public static function noticePromo( string $context = 'success', string $message = '' ): array { $defaults = array( 'enabled' => false, 'title' => '', 'text' => '', 'button_text' => '', 'buttontext' => '', 'url' => '', 'target' => '_blank', 'types' => array( 'success' ), ); $config = apply_filters( 'adfuz/ui/notice/promo', $defaults, $context, $message ); $config = wp_parse_args( is_array( $config ) ? $config : array(), $defaults ); if ( empty( $config['button_text'] ) && ! empty( $config['buttontext'] ) ) { $config['button_text'] = $config['buttontext']; } if ( empty( $config['buttontext'] ) && ! empty( $config['button_text'] ) ) { $config['buttontext'] = $config['button_text']; } $config['enabled'] = ! empty( $config['enabled'] ); $config['title'] = sanitize_text_field( $config['title'] ); $config['text'] = sanitize_text_field( $config['text'] ); $config['button_text'] = sanitize_text_field( $config['button_text'] ); $config['buttontext'] = sanitize_text_field( $config['buttontext'] ); $config['url'] = ! empty( $config['url'] ) ? esc_url( $config['url'] ) : ''; $config['target'] = ( $config['target'] ?? '_blank' ) === '_self' ? '_self' : '_blank'; $config['types'] = array_values( array_filter( array_map( 'sanitize_key', (array) $config['types'] ) ) ); $allowed_type = empty( $config['types'] ) || in_array( sanitize_key( $context ), $config['types'], true ); $has_content = ! empty( $config['text'] ) || ( ! empty( $config['url'] ) && ! empty( $config['button_text'] ) ); $config['show'] = $config['enabled'] && $allowed_type && $has_content; return $config; } }