ru-se.com

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

layout-settings.php (3341B)


      1 <?php
      2 
      3 function materialis_add_layout_options()
      4 {
      5 
      6     $section = 'layout_settings';
      7 
      8     if (apply_filters('materialis_is_companion_installed', false)) {
      9         $section = 'page_content_settings';
     10     }
     11 
     12     $priority = 1;
     13 
     14     materialis_add_kirki_field(array(
     15         'type'     => 'sectionseparator',
     16         'settings' => "layout_section_settings_separator",
     17         'label'    => esc_html__('Layout Settings', 'materialis'),
     18         'section'  => $section,
     19         'priority' => $priority,
     20     ));
     21 
     22     materialis_add_kirki_field(array(
     23         'type'      => 'checkbox',
     24         'settings'  => 'layout_boxed_content_enabled',
     25         'label'     => esc_html__('Enable Boxed Content', 'materialis'),
     26         'section'   => $section,
     27         'default'   => false,
     28         'transport' => 'postMessage',
     29     ));
     30 
     31     materialis_add_kirki_field(array(
     32         'type'            => 'color',
     33         'settings'        => 'layout_boxed_content_background_color',
     34         'label'           => esc_html__('Box Background Color', 'materialis'),
     35         'section'         => $section,
     36         'default'         => '#f5fafd',
     37         'choices'         => array(
     38             'alpha' => true,
     39         ),
     40         'active_callback' => array(
     41             array(
     42                 'setting'  => 'layout_boxed_content_enabled',
     43                 'operator' => '==',
     44                 'value'    => true,
     45             ),
     46         ),
     47         'transport'       => 'postMessage',
     48         'output'          => array(
     49             array(
     50                 'element'  => '#page',
     51                 'property' => 'background-color',
     52             ),
     53         ),
     54     ));
     55 
     56     materialis_add_kirki_field(array(
     57         'type'            => 'number',
     58         'settings'        => 'layout_boxed_content_overlap_height',
     59         'label'           => esc_html__('Overlap Height', 'materialis'),
     60         'section'         => $section,
     61         'default'         => 50,
     62         'choices'         => array(
     63             'min' => 0,
     64             'max' => 100,
     65         ),
     66         'transport'       => 'postMessage',
     67         'active_callback' => array(
     68             array(
     69                 'setting'  => 'layout_boxed_content_enabled',
     70                 'operator' => '==',
     71                 'value'    => true,
     72             ),
     73         ),
     74     ));
     75 }
     76 
     77 materialis_add_layout_options();
     78 
     79 
     80 function materialis_page_content_atts_boxed_layout_content($attrs)
     81 {
     82 
     83     $boxed_enabled = materialis_get_theme_mod('layout_boxed_content_enabled', false);
     84     if (intval($boxed_enabled)) {
     85         $overlap_height = materialis_get_theme_mod('layout_boxed_content_overlap_height', 50);
     86 
     87         $attrs['class'] .= " mdc-elevation--z20 ";
     88         $attrs['class'] .= " boxed-layout ";
     89         $attrs['style'] .= "margin-top:-" . esc_attr($overlap_height) . "px";
     90     }
     91 
     92     return $attrs;
     93 }
     94 
     95 add_filter("materialis_page_content_atts", 'materialis_page_content_atts_boxed_layout_content', 1, 1);
     96 
     97 function materialis_page_content_atts($class = "page-content")
     98 {
     99 
    100     $attrs = array(
    101         'class' => $class,
    102         'style' => "",
    103         'id' => 'page-content'
    104     );
    105 
    106     $attrs = apply_filters('materialis_page_content_atts', $attrs);
    107 
    108     $result = "";
    109     foreach ($attrs as $key => $value) {
    110         $value  = trim($value);
    111         $result .= " {$key}='" . esc_attr($value) . "'";
    112     }
    113 
    114     return $result;
    115 }