PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.76
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.76
1.2.76 1.2.75 1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 All 176 releases
← All changes | vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php +126 -65 1.2.74 → 1.2.76 View file →
@@ -34,9 +34,9 @@
34 34 * Class version version.
35 35 *
36 36 * @var string
37 37 */
38 - public $version = '0.2.54';
38 + public $version = '0.2.56';
39 39
40 40 /**
41 41 * Class textdomain.
42 42 *
@@ -151,24 +151,25 @@
151 151 /**
152 152 * Setup some constants.
153 153 */
154 154 public function constants(){
155 - define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156 - define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157 - define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158 - define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159 - define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160 - define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161 - define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162 - define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163 - define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164 - define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165 - define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166 - define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167 - define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168 - define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169 - define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170 - define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
155 + // Another copy of this package may have defined these already.
156 + defined( 'AUI_PRIMARY_COLOR_ORIGINAL' ) || define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
157 + defined( 'AUI_SECONDARY_COLOR_ORIGINAL' ) || define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
158 + defined( 'AUI_INFO_COLOR_ORIGINAL' ) || define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
159 + defined( 'AUI_WARNING_COLOR_ORIGINAL' ) || define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
160 + defined( 'AUI_DANGER_COLOR_ORIGINAL' ) || define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
161 + defined( 'AUI_SUCCESS_COLOR_ORIGINAL' ) || define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
162 + defined( 'AUI_LIGHT_COLOR_ORIGINAL' ) || define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
163 + defined( 'AUI_DARK_COLOR_ORIGINAL' ) || define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
164 + defined( 'AUI_WHITE_COLOR_ORIGINAL' ) || define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
165 + defined( 'AUI_PURPLE_COLOR_ORIGINAL' ) || define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
166 + defined( 'AUI_SALMON_COLOR_ORIGINAL' ) || define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
167 + defined( 'AUI_CYAN_COLOR_ORIGINAL' ) || define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
168 + defined( 'AUI_GRAY_COLOR_ORIGINAL' ) || define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
169 + defined( 'AUI_INDIGO_COLOR_ORIGINAL' ) || define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
170 + defined( 'AUI_ORANGE_COLOR_ORIGINAL' ) || define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
171 + defined( 'AUI_BLACK_COLOR_ORIGINAL' ) || define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
171 172
172 173 if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173 174 define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174 175 }
@@ -744,52 +745,52 @@
744 745 wp_enqueue_style( 'iconpicker' );
745 746 wp_enqueue_script( 'iconpicker' );
746 747 }
747 748
748 - /**
749 - * Get the url path to the current folder.
750 - *
751 - * This can be called very early, hence the need for the dynamic way of getting the URL.
752 - *
753 - * @since 0.2.31 changed to support edge cases like bitnami containers.
754 - * @return string
755 - */
756 - public function get_url() {
757 - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
758 - $content_url = untrailingslashit( WP_CONTENT_URL );
749 + /**
750 + * Get the url path to the current folder.
751 + *
752 + * This can be called very early, hence the need for the dynamic way of getting the URL.
753 + *
754 + * @since 0.2.31 changed to support edge cases like bitnami containers.
755 + * @return string
756 + */
757 + public function get_url() {
758 + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
759 + $content_url = untrailingslashit( WP_CONTENT_URL );
759 760
760 - // maybe Replace http:// to https://.
761 - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
762 - $content_url = str_replace( 'http://', 'https://', $content_url );
763 - }
761 + // maybe Replace http:// to https://.
762 + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
763 + $content_url = str_replace( 'http://', 'https://', $content_url );
764 + }
764 765
765 - // First find where in the path our content directory starts
766 - $content_basename = basename($content_dir);
767 - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
766 + // First find where in the path our content directory starts
767 + $content_basename = basename($content_dir);
768 + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
768 769
769 - // Find the relative path by matching from content directory name
770 - $after_content = substr($file_dir, strpos($file_dir, '/' . $content_basename . '/') + strlen('/' . $content_basename . '/'));
770 + // Find the relative path by matching from content directory name
771 + $after_content = substr($file_dir, strpos($file_dir, '/' . $content_basename . '/') + strlen('/' . $content_basename . '/'));
771 772
772 - // Build URL using WP_CONTENT_URL and the relative path
773 - $url = trailingslashit($content_url) . $after_content;
773 + // Build URL using WP_CONTENT_URL and the relative path
774 + $url = trailingslashit($content_url) . $after_content;
774 775
775 - // some hosts end up with /wp-content/wp-content/
776 - $url = str_replace( '/wp-content/wp-content/', '/wp-content/', $url );
776 + // some hosts end up with /wp-content/wp-content/
777 + $url = str_replace( '/wp-content/wp-content/', '/wp-content/', $url );
777 778
778 - /**
779 - * Filters the URL to the AyeCode UI folder.
780 - *
781 - * Useful when the folder URL can't be worked out from its path, e.g. a symlinked plugin.
782 - *
783 - * @since 0.2.54
784 - *
785 - * @param string $url The AyeCode UI folder URL.
786 - * @param string $file_dir The AyeCode UI folder path.
787 - */
788 - $url = apply_filters( 'ayecode_ui_url', $url, $file_dir );
779 + /**
780 + * Filters the URL to the AyeCode UI folder.
781 + *
782 + * Useful when the folder URL can't be worked out from its path, e.g. a symlinked plugin.
783 + *
784 + * @since 0.2.54
785 + *
786 + * @param string $url The AyeCode UI folder URL.
787 + * @param string $file_dir The AyeCode UI folder path.
788 + */
789 + $url = apply_filters( 'ayecode_ui_url', $url, $file_dir );
789 790
790 - return trailingslashit($url);
791 - }
791 + return trailingslashit($url);
792 + }
792 793
793 794 /**
794 795 * Get the url path to the current folder.
795 796 * @todo remove
@@ -1358,8 +1359,15 @@
1358 1359 return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1359 1360 }
1360 1361
1361 1362 public static function hex_to_rgb( $hex ) {
1363 + $hex = trim( (string) $hex );
1364 +
1365 + // CSS variables can't be resolved to RGB server side.
1366 + if ( $hex === '' || strpos( $hex, 'var(' ) !== false ) {
1367 + return '';
1368 + }
1369 +
1362 1370 // Remove '#' if present
1363 1371 $hex = str_replace( '#', '', $hex );
1364 1372
1365 1373 // Check if input is RGB
@@ -1372,10 +1380,15 @@
1372 1380
1373 1381 return $rgb;
1374 1382 }
1375 1383
1376 - // Convert 3-digit hex to 6-digit hex
1377 - if ( strlen( $hex ) == 3 ) {
1384 + // Only 3, 4, 6 or 8 digit hex can be converted, anything else (named colours, hsl() etc.) would give a wrong value.
1385 + if ( ! preg_match( '/^([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i', $hex ) ) {
1386 + return '';
1387 + }
1388 +
1389 + // Convert 3 or 4 digit hex to 6-digit hex (alpha is ignored)
1390 + if ( strlen( $hex ) <= 4 ) {
1378 1391 $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
1379 1392 }
1380 1393
1381 1394 // Convert hex to RGB
@@ -1387,8 +1400,34 @@
1387 1400 return $r . ',' . $g . ',' . $b;
1388 1401 }
1389 1402
1390 1403 /**
1404 + * Replace --bs-{type}-rgb usages when the color has no RGB value (eg a CSS variable).
1405 + *
1406 + * rgba(var(--bs-{type}-rgb), .5) would be invalid without the -rgb variable, so use color-mix() on the color itself.
1407 + *
1408 + * @param string $css The generated CSS.
1409 + * @param string $type The color slug.
1410 + * @param string $color_code The color value.
1411 + *
1412 + * @return string
1413 + */
1414 + public static function css_rgb_fallback( $css, $type, $color_code ) {
1415 + $type = preg_quote( $type, '/' );
1416 +
1417 + // A comma triplet is required here, so leave the value from the stylesheet in place.
1418 + $css = preg_replace( '/--bs-btn-focus-shadow-rgb:\s*var\(--bs-' . $type . '-rgb\);/', '', $css );
1419 +
1420 + return preg_replace_callback( '/rgba?\(\s*var\(--bs-' . $type . '-rgb\)\s*(?:,\s*([0-9]*\.?[0-9]+)\s*)?\)/', function( $m ) use ( $color_code ) {
1421 + if ( ! isset( $m[1] ) || (float) $m[1] >= 1 ) {
1422 + return $color_code;
1423 + }
1424 +
1425 + return 'color-mix(in srgb, ' . $color_code . ' ' . round( (float) $m[1] * 100, 2 ) . '%, transparent)';
1426 + }, $css );
1427 + }
1428 +
1429 + /**
1391 1430 * Build the CSS to overwrite a bootstrap color variable.
1392 1431 *
1393 1432 * @param $type
1394 1433 * @param $color_code
@@ -1505,9 +1544,9 @@
1505 1544 } else if ( $aui_bs5 ) {
1506 1545 $output .= $prefix . ' .text-' . sanitize_key( $type ) . '{color: var(--bs-' . sanitize_key( $type ) . ') !important;}';
1507 1546 }
1508 1547
1509 - $output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}';
1548 + $output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).') !important;}';
1510 1549 $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1511 1550
1512 1551 // buttons
1513 1552 $output .= $prefix . ' .btn-'.esc_attr($type).'{';
@@ -1515,9 +1554,9 @@
1515 1554 --bs-btn-bg: '.esc_attr($color_code).';
1516 1555 --bs-btn-border-color: '.esc_attr($color_code).';
1517 1556 --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1518 1557 --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1519 - --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb;
1558 + --bs-btn-focus-shadow-rgb: var(--bs-'.esc_attr($type).'-rgb);
1520 1559 --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1521 1560 --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1522 1561 --bs-btn-active-shadow: unset;
1523 1562 --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
@@ -1537,9 +1576,9 @@
1537 1576 --bs-btn-color: '.esc_attr($color_code).';
1538 1577 --bs-btn-border-color: '.esc_attr($color_code).';
1539 1578 --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1540 1579 --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1541 - --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb;
1580 + --bs-btn-focus-shadow-rgb: var(--bs-'.esc_attr($type).'-rgb);
1542 1581 --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1543 1582 --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1544 1583 --bs-btn-active-shadow: unset;
1545 1584 --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
@@ -1568,16 +1607,15 @@
1568 1607 }
1569 1608
1570 1609 // $output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1571 1610 $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1572 - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1611 +
1612 + if ( $rgb !== '' ) {
1613 + $output .= 'html body {--bs-' . esc_attr( $type ) . '-rgb: ' . $rgb . '; }';
1614 + }
1573 1615 }
1574 1616
1575 -
1576 1617 if ( $is_custom ) {
1577 -
1578 -// echo '###'.$type;exit;
1579 -
1580 1618 // build rules into each type
1581 1619 foreach($selectors as $selector => $types){
1582 1620 $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1583 1621 $types = array_combine($types,$types);
@@ -1678,8 +1716,18 @@
1678 1716 // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} ";
1679 1717 $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1680 1718 }
1681 1719
1720 + if ( $rgb === '' ) {
1721 + // The stylesheet builds these from --bs-{type}-rgb, which is not set for this color.
1722 + if ( $aui_bs5 ) {
1723 + $output .= $prefix . " .bg-{$type}{background-color: color-mix(in srgb, $color_code calc(var(--bs-bg-opacity, 1) * 100%), transparent) !important;} ";
1724 + $output .= $prefix . " .border-{$type}{border-color: color-mix(in srgb, $color_code calc(var(--bs-border-opacity, 1) * 100%), transparent) !important;} ";
1725 + }
1726 +
1727 + $output = self::css_rgb_fallback( $output, $type, $color_code );
1728 + }
1729 +
1682 1730 return $output;
1683 1731 }
1684 1732
1685 1733 /**
@@ -1796,9 +1844,12 @@
1796 1844 $output = '';
1797 1845
1798 1846 if ( $aui_bs5 ) {
1799 1847 // $output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1800 - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1848 +
1849 + if ( $rgb !== '' ) {
1850 + $output .= 'html body {--bs-' . esc_attr( $type ) . '-rgb: ' . $rgb . '; }';
1851 + }
1801 1852 }
1802 1853
1803 1854 // build rules into each type
1804 1855 foreach($selectors as $selector => $types){
@@ -1892,8 +1943,18 @@
1892 1943 // alerts
1893 1944 if ( $aui_bs5 ) {
1894 1945 // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} ";
1895 1946 $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1947 + }
1948 +
1949 + if ( $rgb === '' ) {
1950 + // The stylesheet builds these from --bs-{type}-rgb, which is not set for this color.
1951 + if ( $aui_bs5 ) {
1952 + $output .= $prefix . " .bg-{$type}{background-color: color-mix(in srgb, $color_code calc(var(--bs-bg-opacity, 1) * 100%), transparent) !important;} ";
1953 + $output .= $prefix . " .border-{$type}{border-color: color-mix(in srgb, $color_code calc(var(--bs-border-opacity, 1) * 100%), transparent) !important;} ";
1954 + }
1955 +
1956 + $output = self::css_rgb_fallback( $output, $type, $color_code );
1896 1957 }
1897 1958
1898 1959 return $output;
1899 1960 }