ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

colors.php (2617B)


      1 <?php
      2 
      3 function materialis_get_default_colors()
      4 {
      5     return array(
      6         array("label" => esc_html__("Primary", "materialis"), "name" => "color1", "value" => "#228ae6"),
      7         array("label" => esc_html__("Secondary", "materialis"), "name" => "color2", "value" => "#fa5252"),
      8         array("label" => esc_html__("color3", "materialis"), "name" => "color3", "value" => "#82c91e"),
      9         array("label" => esc_html__("color4", "materialis"), "name" => "color4", "value" => "#fab005"),
     10         array("label" => esc_html__("color5", "materialis"), "name" => "color5", "value" => "#7950f2"),
     11         array("label" => esc_html__("color6", "materialis"), "name" => "color6", "value" => "#e64980"),
     12     );
     13 }
     14 
     15 function materialis_get_theme_colors($color = false)
     16 {
     17     $colors = apply_filters("materialis_get_theme_colors", materialis_get_default_colors(), $color);
     18 
     19     if ($color) {
     20         global $materialis_cached_colors;
     21 
     22         if ( ! $materialis_cached_colors) {
     23 
     24             $materialis_cached_colors = array();
     25 
     26             foreach ($colors as $colorData) {
     27                 $materialis_cached_colors[$colorData['name']] = $colorData['value'];
     28             }
     29         }
     30 
     31         if (isset($materialis_cached_colors[$color])) {
     32             return $materialis_cached_colors[$color];
     33         } else {
     34             return esc_html(sprintf(__("color %s not found", "materialis"), $color));
     35         }
     36     }
     37 
     38     return $colors;
     39 }
     40 
     41 
     42 function materialis_get_changed_theme_colors()
     43 {
     44     $colors         = materialis_get_theme_colors();
     45     $default_colors = materialis_get_default_colors(true);
     46     $result         = array();
     47 
     48     foreach ($colors as $color) {
     49         $name = $color['name'];
     50 
     51         if (isset($default_colors[$name])) {
     52             if ($default_colors[$name] !== $color['value']) {
     53                 $result[] = $color;
     54             }
     55         } else {
     56             $result[] = $color;
     57         }
     58     }
     59 
     60     return $result;
     61 }
     62 
     63 add_filter('kirki_color_picker_palettes', 'materialis_theme_kirki_palettes');
     64 
     65 function materialis_theme_kirki_palettes($palettes)
     66 {
     67     $namedColors = materialis_get_theme_colors();
     68 
     69     foreach ($namedColors as $name => $color) {
     70         if (isset($color['value'])) {
     71             $palettes[] = $color['value'];
     72         }
     73     }
     74 
     75     array_unshift($palettes, '#ffffff');
     76     array_unshift($palettes, '#000000');
     77 
     78     return array_unique($palettes);
     79 }
     80 
     81 materialis_add_kirki_field(array(
     82     'type'     => 'ope-info-pro',
     83     'label'    => esc_html__('Customize all theme colors in PRO. @BTN@', 'materialis'),
     84     'section'  => 'colors',
     85     'settings' => "site_colors_info_pro",
     86 ));