Make WordPress Themes

source: lightning/11.3.2/functions-compatible.php

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

New version of Lightning - 11.3.2

File size: 3.1 KB
Line 
1<?php
2add_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                                update_option( 'lightning_theme_options', $options );
30                        }
31                }
32                unset( $options['top_sidebar_hidden'] );
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                update_option( 'lightning_theme_options', $options );
45                unset( $options['layout']['archive'] );
46        }
47        if ( isset( $options['layout']['single'] ) && $options['layout']['single'] != 'default' ) {
48                foreach ( $archive_post_types as $archive_post_type ) {
49                        $options['layout'][ 'single-' . $archive_post_type ] = $options['layout']['single'];
50                }
51                update_option( 'lightning_theme_options', $options );
52                unset( $options['layout']['single'] );
53        }
54        if ( isset( $options['layout']['page'] ) && $options['layout']['page'] != 'default' ) {
55                $options['layout']['single-page'] = $options['layout']['page'];
56                update_option( 'lightning_theme_options', $options );
57                unset( $options['layout']['page'] );
58        }
59}
60
61
62/*
63  Deal with typo name action
64/*-------------------------------------------*/
65add_action( 'lightning_entry_body_after', 'lightning_ligthning_entry_body_after' );
66function lightning_ligthning_entry_body_after() {
67        do_action( 'ligthning_entry_body_after' );
68}
69add_action( 'lightning_entry_body_before', 'lightning_ligthning_entry_body_before' );
70function lightning_ligthning_entry_body_before() {
71        do_action( 'ligthning_entry_body_before' );
72}
73
74/*
75  Deactive Lightning Advanced Unit
76/*-------------------------------------------*/
77add_action( 'init', 'lightning_deactive_adv_unit' );
78function lightning_deactive_adv_unit() {
79        $plugin_path = 'lightning-advanced-unit/lightning_advanced_unit.php';
80        lightning_deactivate_plugin( $plugin_path );
81}
82function lightning_deactivate_plugin( $plugin_path ) {
83        include_once ABSPATH . 'wp-admin/includes/plugin.php';
84        if ( is_plugin_active( $plugin_path ) ) {
85                $active_plugins = get_option( 'active_plugins' );
86                // delete item
87                $active_plugins = array_diff( $active_plugins, array( $plugin_path ) );
88                // re index
89                $active_plugins = array_values( $active_plugins );
90                update_option( 'active_plugins', $active_plugins );
91        }
92}
Note: See TracBrowser for help on using the repository browser.