array( 'name' => 'Hyperion (Sunset)', 'css' => 'linear-gradient(to right, #FF512F, #DD2476)', 'text_mode' => 'light', ), 2 => array( 'name' => 'Azure (Trust)', 'css' => 'linear-gradient(to right, #2193b0, #6dd5ed)', 'text_mode' => 'light', ), 3 => array( 'name' => 'Emerald (Growth)', 'css' => 'linear-gradient(to right, #11998e, #38ef7d)', 'text_mode' => 'light', ), 4 => array( 'name' => 'Amethyst (Tech)', 'css' => 'linear-gradient(to right, #8E2DE2, #4A00E0)', 'text_mode' => 'light', ), 5 => array( 'name' => 'Carbon (Neutral)', 'css' => 'linear-gradient(to right, #232526, #414345)', 'text_mode' => 'light', ), 6 => array( 'name' => 'Citrine (Caution)', 'css' => 'linear-gradient(to right, #F2994A, #F2C94C)', 'text_mode' => 'dark', ), 7 => array( 'name' => 'Prism (Light Rainbow)', 'css' => 'linear-gradient(to right, #ff9a9e, #fecfef, #a18cd1)', 'text_mode' => 'dark', ), 8 => array( 'name' => 'Cotton Candy (Pastel)', 'css' => 'linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%)', 'text_mode' => 'dark', ), // New Pastel & Modern Gradients 9 => array( 'name' => 'Morning Mist (Pastel Cyan)', 'css' => 'linear-gradient(to right, #a8edea, #fed6e3)', 'text_mode' => 'dark', ), 10 => array( 'name' => 'Gentle Glow (Warm)', 'css' => 'linear-gradient(to right, #ff9a9e, #fad0c4)', 'text_mode' => 'dark', ), 11 => array( 'name' => 'Lavender Dream (Purple)', 'css' => 'linear-gradient(to right, #e6dee9, #afc9e6)', 'text_mode' => 'dark', ), 12 => array( 'name' => 'Soft Grass (Nature)', 'css' => 'linear-gradient(to right, #deecdd, #c1dfc4)', 'text_mode' => 'dark', ), 13 => array( 'name' => 'Sunny Morning (Cheerful)', 'css' => 'linear-gradient(120deg, #f6d365 0%, #fda085 100%)', 'text_mode' => 'dark', ), 14 => array( 'name' => 'Rare Wind (Elegant)', 'css' => 'linear-gradient(to top, #a18cd1 0%, #fbc2eb 100%)', 'text_mode' => 'dark', ), 15 => array( 'name' => 'Near Moon (Cool)', 'css' => 'linear-gradient(to top, #5ee7df 0%, #b490ca 100%)', 'text_mode' => 'dark', ), 16 => array( 'name' => 'Wild Apple (Fresh)', 'css' => 'linear-gradient(to top, #d299c2 0%, #fef9d7 100%)', 'text_mode' => 'dark', ), 17 => array( 'name' => 'Saint Petersburg (Classy)', 'css' => 'linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%)', 'text_mode' => 'dark', ), 18 => array( 'name' => 'Plum Plate (Deep)', 'css' => 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', 'text_mode' => 'light', ), 99 => array( 'name' => 'Pro: Custom Gradient Configuration', 'css' => 'linear-gradient(90deg, #cccccc, #999999)', 'text_mode' => 'light', // Handled dynamically in preview but defaults to light ), ); } /** * Get CSS for a specific gradient ID or Custom * * @param int $id * @param string $custom_start * @param string $custom_end * @return string */ public static function get_gradient_css($id, $custom_start = '', $custom_end = '') { $gradients = self::get_gradients(); if (99 === (int) $id) { // Pro Feature: Custom Gradient // Sanitize hex colors to be safe using internal helper to avoid undefined function errors in REST API $start = self::sanitize_hex($custom_start); $end = self::sanitize_hex($custom_end); // Fallback defaults if empty if (!$start) $start = '#cccccc'; if (!$end) $end = '#999999'; return "linear-gradient(90deg, {$start}, {$end})"; } if (isset($gradients[$id])) { return $gradients[$id]['css']; } // Default to preset 1 if not found return $gradients[1]['css']; } /** * Sanitizes a hex color. * * @param string $color * @return string|null */ public static function sanitize_hex($color) { $color = ltrim($color, '#'); if (preg_match('/^([A-Fa-f0-9]{3}){1,2}$/', $color)) { return '#' . $color; } return null; // Invalid } /** * Determine text color class based on preset * * @param int $id * @param string $custom_mode 'auto', 'light', 'dark' * @return string */ public static function get_text_color_class($id, $custom_mode = 'auto') { if (99 === (int) $id) { if ('light' === $custom_mode) { return 'affnotice-text-light'; } elseif ('dark' === $custom_mode) { return 'affnotice-text-dark'; } // Fallback/Auto for custom could be complex, let's default to dark for safety or make it a setting? // PRD says "User Selects" for custom. So we rely on custom_mode. return 'affnotice-text-dark'; } $gradients = self::get_gradients(); if (isset($gradients[$id])) { return 'affnotice-text-' . $gradients[$id]['text_mode']; } return 'affnotice-text-light'; } /** * Check if user is premium * * @return bool */ public static function is_premium() { if (function_exists('affnotice_fs')) { return affnotice_fs()->is_paying(); } return false; } }