ru-se.com

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

footer-options.php (16479B)


      1 <?php
      2 
      3 
      4 function materialis_get_footer_contact_boxes($index = 0)
      5 {
      6 
      7     $contact_boxes = array(
      8         array(
      9             'icon_mod'     => 'footer_box1_content_icon',
     10             'icon_default' => 'mdi-pin',
     11             'text_mod'     => 'footer_box1_content_text',
     12             'text_default' => esc_html__('San Francisco - Adress - 18 California Street 1100.', 'materialis'),
     13         ),
     14         array(
     15             'icon_mod'     => 'footer_box2_content_icon',
     16             'icon_default' => 'mdi-email',
     17             'text_mod'     => 'footer_box2_content_text',
     18             'text_default' => esc_html__('hello@mycoolsite.com', 'materialis'),
     19         ),
     20         array(
     21             'icon_mod'     => 'footer_box3_content_icon',
     22             'icon_default' => 'mdi-cellphone-android',
     23             'text_mod'     => 'footer_box3_content_text',
     24             'text_default' => esc_html__('+1 (555) 345 234343', 'materialis'),
     25         ),
     26     );
     27 
     28     return $contact_boxes[$index];
     29 
     30 }
     31 
     32 function materialis_footer_filter()
     33 {
     34     $footer_template = materialis_get_theme_mod('footer_template', 'simple');
     35 
     36     $theme      = wp_get_theme();
     37     $textDomain = materialis_get_text_domain();
     38 
     39     if ($footer_template == 'simple') {
     40         $footer_template = '';
     41     }
     42 
     43     return $footer_template;
     44 }
     45 
     46 add_filter('materialis_footer', 'materialis_footer_filter');
     47 
     48 function materialis_footer_settings()
     49 {
     50 
     51     $section = 'footer_settings';
     52 
     53     materialis_add_kirki_field(array(
     54         'type'     => 'sectionseparator',
     55         'label'    => esc_html__('Footer Content', 'materialis'),
     56         'section'  => $section,
     57         'settings' => 'footer_content_separator',
     58         'priority' => 1,
     59     ));
     60 
     61     materialis_add_kirki_field(array(
     62         'type'      => 'checkbox',
     63         'settings'  => 'footer_paralax',
     64         'label'     => esc_html__('Use footer parallax', 'materialis'),
     65         'section'   => $section,
     66         'default'   => false,
     67         'priority'  => 4,
     68         'transport' => 'postMessage',
     69         'active_callback' => array(
     70             array(
     71                 'setting'  => 'layout_boxed_content_enabled',
     72                 'operator' => '==',
     73                 'value'    => false,
     74             ),
     75         ),
     76     ));
     77 
     78 
     79     materialis_add_kirki_field(array(
     80         'type'      => 'ope-info-pro',
     81         'label'     => esc_html__('More colors and typography options available in PRO. @BTN@', 'materialis'),
     82         'section'   => $section,
     83         'priority'  => 4,
     84         'settings'  => 'footer_content_typography_pro_info',
     85         'default'   => true,
     86         'transport' => 'postMessage',
     87     ));
     88 
     89     materialis_add_kirki_field(array(
     90         'type'     => 'select',
     91         'settings' => 'footer_template',
     92         'label'    => esc_html__('Footer Template', 'materialis'),
     93         'section'  => $section,
     94         'priority' => 1,
     95         'default'  => 'simple',
     96         'choices'  => apply_filters('materialis_footer_templates', array(
     97             'simple'        => esc_html__('Copyright text only', 'materialis'),
     98             'contact-boxes' => esc_html__('Contact Boxes', 'materialis'),
     99             'dark'          => esc_html__('Dark Footer With Menu', 'materialis'),
    100         )),
    101         'update'   => apply_filters('materialis_footer_templates_update', array()),
    102     ));
    103 
    104     // Contact Boxes options button and section
    105 
    106     $group = 'footer_content_contact_boxes_group_button';
    107 
    108     materialis_add_kirki_field(array(
    109         'type'            => 'sectionseparator',
    110         'label'           => esc_html__('Box 1 Content', 'materialis'),
    111         'section'         => $section,
    112         'settings'        => 'footer_box1_content_separator',
    113         'priority'        => 1,
    114         'group'           => $group,
    115         'active_callback' => array(
    116             array(
    117                 'setting'  => 'footer_template',
    118                 'operator' => '==',
    119                 'value'    => 'contact-boxes',
    120             ),
    121         ),
    122     ));
    123 
    124     materialis_add_kirki_field(array(
    125         'type'            => 'material-icons-icon-control',
    126         'settings'        => 'footer_box1_content_icon',
    127         'label'           => esc_html__('Icon', 'materialis'),
    128         'section'         => $section,
    129         'priority'        => 1,
    130         'group'           => $group,
    131         'default'         => 'mdi-map-marker',
    132         'active_callback' => array(
    133             array(
    134                 'setting'  => 'footer_template',
    135                 'operator' => '==',
    136                 'value'    => 'contact-boxes',
    137             ),
    138         ),
    139     ));
    140 
    141     materialis_add_kirki_field(array(
    142         'type'              => 'textarea',
    143         'settings'          => 'footer_box1_content_text',
    144         'label'             => esc_html__('Text', 'materialis'),
    145         'section'           => $section,
    146         'priority'          => 1,
    147         'group'             => $group,
    148         'default'           => 'San Francisco - Adress - 18 California Street 1100.',
    149         'sanitize_callback' => 'wp_kses_post',
    150         'active_callback'   => array(
    151             array(
    152                 'setting'  => 'footer_template',
    153                 'operator' => '==',
    154                 'value'    => 'contact-boxes',
    155             ),
    156         ),
    157         'transport'         => 'postMessage',
    158         'js_vars'           => array(
    159             array(
    160                 'element'  => '[data-focus-control="footer_box1_content_icon"] > p',
    161                 'function' => 'html',
    162             ),
    163         ),
    164     ));
    165 
    166     materialis_add_kirki_field(array(
    167         'type'            => 'sectionseparator',
    168         'label'           => esc_html__('Box 2 Content', 'materialis'),
    169         'section'         => $section,
    170         'settings'        => 'footer_box2_content_separator',
    171         'priority'        => 1,
    172         'group'           => $group,
    173         'active_callback' => array(
    174             array(
    175                 'setting'  => 'footer_template',
    176                 'operator' => '==',
    177                 'value'    => 'contact-boxes',
    178             ),
    179         ),
    180     ));
    181 
    182     materialis_add_kirki_field(array(
    183         'type'            => 'material-icons-icon-control',
    184         'settings'        => 'footer_box2_content_icon',
    185         'label'           => esc_html__('Icon', 'materialis'),
    186         'section'         => $section,
    187         'priority'        => 1,
    188         'group'           => $group,
    189         'default'         => 'mdi-email',
    190         'active_callback' => array(
    191             array(
    192                 'setting'  => 'footer_template',
    193                 'operator' => '==',
    194                 'value'    => 'contact-boxes',
    195             ),
    196         ),
    197     ));
    198 
    199     materialis_add_kirki_field(array(
    200         'type'              => 'textarea',
    201         'settings'          => 'footer_box2_content_text',
    202         'label'             => esc_html__('Text', 'materialis'),
    203         'section'           => $section,
    204         'priority'          => 1,
    205         'group'             => $group,
    206         'default'           => 'hello@mycoolsite.com',
    207         'sanitize_callback' => 'wp_kses_post',
    208         'active_callback'   => array(
    209             array(
    210                 'setting'  => 'footer_template',
    211                 'operator' => '==',
    212                 'value'    => 'contact-boxes',
    213             ),
    214         ),
    215         'transport'         => 'postMessage',
    216         'js_vars'           => array(
    217             array(
    218                 'element'  => '[data-focus-control="footer_box2_content_icon"] > p',
    219                 'function' => 'html',
    220 
    221             ),
    222         ),
    223     ));
    224 
    225     materialis_add_kirki_field(array(
    226         'type'            => 'sectionseparator',
    227         'label'           => esc_html__('Box 3 Content', 'materialis'),
    228         'section'         => $section,
    229         'settings'        => 'footer_box3_content_separator',
    230         'priority'        => 1,
    231         'group'           => $group,
    232         'active_callback' => array(
    233             array(
    234                 'setting'  => 'footer_template',
    235                 'operator' => '==',
    236                 'value'    => 'contact-boxes',
    237             ),
    238         ),
    239     ));
    240 
    241     materialis_add_kirki_field(array(
    242         'type'            => 'material-icons-icon-control',
    243         'settings'        => 'footer_box3_content_icon',
    244         'label'           => esc_html__('Icon', 'materialis'),
    245         'section'         => $section,
    246         'priority'        => 1,
    247         'group'           => $group,
    248         'default'         => 'mdi-cellphone-android',
    249         'active_callback' => array(
    250             array(
    251                 'setting'  => 'footer_template',
    252                 'operator' => '==',
    253                 'value'    => 'contact-boxes',
    254             ),
    255         ),
    256     ));
    257 
    258     materialis_add_kirki_field(array(
    259         'type'              => 'textarea',
    260         'settings'          => 'footer_box3_content_text',
    261         'label'             => esc_html__('Text', 'materialis'),
    262         'section'           => $section,
    263         'priority'          => 1,
    264         'group'             => $group,
    265         'default'           => '+1 (555) 345 234343',
    266         'sanitize_callback' => 'wp_kses_post',
    267         'active_callback'   => array(
    268             array(
    269                 'setting'  => 'footer_template',
    270                 'operator' => '==',
    271                 'value'    => 'contact-boxes',
    272             ),
    273         ),
    274         'transport'         => 'postMessage',
    275         'js_vars'           => array(
    276             array(
    277                 'element'  => '[data-focus-control="footer_box3_content_icon"] > p',
    278                 'function' => 'html',
    279 
    280             ),
    281         ),
    282     ));
    283 
    284     materialis_add_kirki_field(array(
    285         'type'            => 'sidebar-button-group',
    286         'settings'        => 'footer_content_contact_boxes_group_button',
    287         'label'           => esc_html__('Contact Boxes Options', 'materialis'),
    288         'section'         => $section,
    289         'priority'        => 1,
    290         'active_callback' => array(
    291             array(
    292                 'setting'  => 'footer_template',
    293                 'operator' => '==',
    294                 'value'    => 'contact-boxes',
    295             ),
    296         ),
    297     ));
    298 
    299     // Social icons options button and section
    300 
    301     $footers_with_social_icons = apply_filters('materialis_footer_templates_with_social', array('contact-boxes', 'content-lists'));
    302 
    303     $group = 'footer_content_social_icons_group_button';
    304 
    305     $materialis_footer_socials_icons = materialis_default_icons();
    306 
    307     $count = 0;
    308     foreach ($materialis_footer_socials_icons as $social) {
    309         $socialid   = 'social_icon_' . $count;
    310         $social_url = $social['link'];
    311         $count++;
    312 
    313         $social_separator_label = sprintf(__('Social Icon %s Options', 'materialis'), $count);
    314 
    315         $social_enable_label = sprintf(__('Show Icon %s', 'materialis'), $count);
    316         $social_url_label    = sprintf(__('Icon %s url', 'materialis'), $count);
    317         $social_url_icon     = sprintf(__('Icon %s icon', 'materialis'), $count);
    318 
    319         materialis_add_kirki_field(array(
    320             'type'            => 'sectionseparator',
    321             'label'           => esc_html($social_separator_label),
    322             'section'         => $section,
    323             'settings'        => 'footer_content_' . $socialid . '_separator',
    324             'priority'        => 1,
    325             'group'           => $group,
    326             'active_callback' => array(
    327                 array(
    328                     'setting'  => 'footer_template',
    329                     'operator' => 'in',
    330                     'value'    => $footers_with_social_icons,
    331                 ),
    332             ),
    333         ));
    334 
    335         materialis_add_kirki_field(array(
    336             'type'            => 'checkbox',
    337             'settings'        => 'footer_content_' . $socialid . '_enabled',
    338             'label'           => esc_html($social_enable_label),
    339             'section'         => $section,
    340             'priority'        => 1,
    341             'group'           => $group,
    342             'default'         => true,
    343             'transport'       => 'postMessage',
    344             'active_callback' => array(
    345                 array(
    346                     'setting'  => 'footer_template',
    347                     'operator' => 'in',
    348                     'value'    => $footers_with_social_icons,
    349                 ),
    350             ),
    351         ));
    352 
    353         materialis_add_kirki_field(array(
    354             'type'            => 'url',
    355             'settings'        => 'footer_content_' . $socialid . '_link',
    356             'label'           => esc_html($social_url_label),
    357             'section'         => $section,
    358             'priority'        => 1,
    359             'group'           => $group,
    360             'default'         => '#',
    361             'transport'       => 'postMessage',
    362             'active_callback' => array(
    363                 array(
    364                     'setting'  => 'footer_content_' . $socialid . '_enabled',
    365                     'operator' => '==',
    366                     'value'    => true,
    367                 ),
    368                 array(
    369                     'setting'  => 'footer_template',
    370                     'operator' => 'in',
    371                     'value'    => $footers_with_social_icons,
    372                 ),
    373             ),
    374         ));
    375 
    376         materialis_add_kirki_field(array(
    377             'type'            => 'material-icons-icon-control',
    378             'settings'        => 'footer_content_' . $socialid . '_icon',
    379             'label'           => esc_html($social_url_icon),
    380             'section'         => $section,
    381             'priority'        => 1,
    382             'group'           => $group,
    383             'default'         => $social['icon'],
    384             'transport'       => 'postMessage',
    385             'active_callback' => array(
    386                 array(
    387                     'setting'  => 'footer_content_' . $socialid . '_enabled',
    388                     'operator' => '==',
    389                     'value'    => true,
    390                 ),
    391                 array(
    392                     'setting'  => 'footer_template',
    393                     'operator' => 'in',
    394                     'value'    => $footers_with_social_icons,
    395                 ),
    396             ),
    397         ));
    398 
    399     }
    400 
    401     materialis_add_kirki_field(array(
    402         'type'            => 'sidebar-button-group',
    403         'settings'        => 'footer_content_social_icons_group_button',
    404         'label'           => esc_html__('Social Icons Options', 'materialis'),
    405         'section'         => $section,
    406         'priority'        => 1,
    407         'active_callback' => array(
    408             array(
    409                 'setting'  => 'footer_template',
    410                 'operator' => 'in',
    411                 'value'    => $footers_with_social_icons,
    412             ),
    413         ),
    414     ));
    415 
    416 
    417 }
    418 
    419 function materialis_print_widget($id)
    420 {
    421     if ( ! is_active_sidebar($id) && is_customize_preview()) {
    422         $focusAttr = materialis_customizer_focus_control_attr("sidebars_widgets[{$id}]", false);
    423         echo "<div {$focusAttr}>" . esc_html__("Go to widgets section to add a widget here.", 'materialis') . "</div>";
    424     } else {
    425         dynamic_sidebar($id);
    426     }
    427 }
    428 
    429 function materialis_footer_container_atts($attrs)
    430 {
    431     $paralax = materialis_get_theme_mod('footer_paralax', false);
    432     if ($paralax) {
    433         $attrs['class'] .= " paralax ";
    434     }
    435 
    436     return $attrs;
    437 }
    438 
    439 add_filter('materialis_footer_container_atts', 'materialis_footer_container_atts');
    440 
    441 /* start contact boxes */
    442 
    443 function materialis_footer_contact_boxes_content_print()
    444 {
    445     materialis_print_contact_boxes();
    446 }
    447 
    448 add_filter('materialis_footer_contact_boxes_content_print', 'materialis_footer_contact_boxes_content_print');
    449 
    450 function materialis_print_contact_boxes($index = 0)
    451 {
    452 
    453     $fields = materialis_get_footer_contact_boxes($index);
    454 
    455     $preview_atts = "";
    456 
    457     if (materialis_is_customize_preview()) {
    458         $setting      = esc_attr($fields['icon_mod']);
    459         $preview_atts = "data-focus-control='{$setting}'";
    460     }
    461 
    462 
    463     $icon = materialis_get_theme_mod($fields['icon_mod'], $fields['icon_default']);
    464     ?>
    465     <div data-type="group" <?php echo $preview_atts; ?> data-dynamic-mod="true">
    466         <i class="big-icon mdi <?php echo esc_attr($icon) ?>"></i>
    467         <p>
    468             <?php echo wp_kses_post(materialis_get_theme_mod($fields['text_mod'], $fields['text_default'])); ?>
    469         </p>
    470     </div>
    471     <?php
    472 }
    473 
    474 /* end contact boxes */
    475 
    476 function materialis_customize_register_options_footer_settings()
    477 {
    478     materialis_footer_settings();
    479 }
    480 
    481 add_action('materialis_customize_register_options', 'materialis_customize_register_options_footer_settings');