Make WordPress Themes

source: lightning/13.8.0/functions-compatible.php

Last change on this file was 139911, checked in by themedropbox, 5 years ago

New version of Lightning - 13.3.1

File size: 3.4 KB
Line 
1<?php
2// add_action( 'after_setup_theme', 'lightning_options_compatible' );
3/**
4 * This is converter that old options to new options value
5 * This function is also used in test-lightning.php
6 *
7 * @return void
8 */
9function lightning_options_compatible() {
10        $options = get_option( 'lightning_theme_options' );
11        global $wp_query;
12
13        $additional_post_types = get_post_types(
14                array(
15                        'public'   => true,
16                        '_builtin' => false,
17                ),
18                'names'
19        );
20
21        $archive_post_types = array( 'post' ) + $additional_post_types;
22
23        if ( isset( $options['top_sidebar_hidden'] ) ) {
24                if ( $options['top_sidebar_hidden'] ) {
25                        if ( isset( $options['layout']['front-page'] ) && $options['layout']['front-page'] === 'col-two' ) {
26
27                        } else {
28                                $options['layout']['front-page'] = 'col-one-no-subsection';
29                        }
30                }
31                $options['top_sidebar_hidden'] = null;
32                update_option( 'lightning_theme_options', $options );
33        }
34        if ( isset( $options['layout']['archive'] ) ) {
35                foreach ( $archive_post_types as $archive_post_type ) {
36                        // Old parameter exist && not default
37                        if ( $options['layout']['archive'] && $options['layout']['archive'] !== 'default' ){
38                                // New parameter is not exist.
39                                if ( empty ( $options['layout'][ 'archive-' . $archive_post_type ] ) ){
40                                        $options['layout'][ 'archive-' . $archive_post_type ] = $options['layout']['archive'];
41                                }
42                        }
43                }
44                $options['layout']['archive'] = null;
45                update_option( 'lightning_theme_options', $options );
46               
47        }
48        if ( isset( $options['layout']['single'] ) && $options['layout']['single'] != 'default' ) {
49                foreach ( $archive_post_types as $archive_post_type ) {
50                        $options['layout'][ 'single-' . $archive_post_type ] = $options['layout']['single'];
51                }
52                $options['layout']['single'] = null;
53                update_option( 'lightning_theme_options', $options );
54               
55        }
56        if ( isset( $options['layout']['page'] ) && $options['layout']['page'] != 'default' ) {
57                $options['layout']['single-page'] = $options['layout']['page'];
58                $options['layout']['page'] = null;
59                update_option( 'lightning_theme_options', $options );
60        }
61}
62
63
64/*
65  Deal with typo name action
66/*-------------------------------------------*/
67add_action( 'lightning_entry_body_after', 'lightning_ligthning_entry_body_after' );
68function lightning_ligthning_entry_body_after() {
69        do_action( 'ligthning_entry_body_after' );
70}
71add_action( 'lightning_entry_body_before', 'lightning_ligthning_entry_body_before' );
72function lightning_ligthning_entry_body_before() {
73        do_action( 'ligthning_entry_body_before' );
74}
75
76/*
77  Deactive Lightning Advanced Unit
78/*-------------------------------------------*/
79add_action( 'init', 'lightning_deactive_adv_unit' );
80function lightning_deactive_adv_unit() {
81        $plugin_path = 'lightning-advanced-unit/lightning_advanced_unit.php';
82        VK_Helpers::deactivate_plugin( $plugin_path );
83}
84
85function lightning_pageheader_and_breadcrumb_compatible(){
86       
87        $post_types = get_post_types();
88        foreach ( $post_types as $key => $post_type ){
89                $args = array(
90                        'post_type' => $key,
91                        'posts_per_page' => -1,
92                );
93                $posts = get_posts( $args );
94               
95                foreach ( $posts as $post ){
96                        setup_postdata( $post );
97                        $meta_value = $post->_lightning_design_setting;
98                        if ( ! empty( $meta_value['hidden_page_header_and_breadcrumb'] ) ){
99                                unset( $meta_value['hidden_page_header_and_breadcrumb'] );
100                                $meta_value['hidden_page_header'] = true;
101                                $meta_value['hidden_breadcrumb'] = true;
102                                update_post_meta( $post->ID, '_lightning_design_setting', $meta_value );
103                        }
104                        wp_reset_postdata();
105                }
106        }
107}
Note: See TracBrowser for help on using the repository browser.