forked from edusnets/ninja-forms-layout-styles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ninja-forms-style.php
118 lines (92 loc) · 3.88 KB
/
ninja-forms-style.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/*
* Plugin Name: Ninja Forms - Layout & Styles
* Plugin URI: https://ninjaforms.com/extensions/layout-styles/
* Description: Form layout and styling add-on for Ninja Forms.
* Version: 3.0.25
* Author: The WP Ninjas
* Author URI: http://ninjaforms.com
* Text Domain: ninja-forms-layout-styles
*
* Copyright 2016 The WP Ninjas.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
if( ! class_exists( 'NF_Layouts_Conversion', false ) ) {
require_once 'lib/conversion.php';
}
if( ! defined( 'NINJA_FORMS_STYLE_VERSION' ) ) {
define("NINJA_FORMS_STYLE_VERSION", "3.0.25");
}
if( version_compare( get_option( 'ninja_forms_version', '0.0.0' ), '3', '<' ) || get_option( 'ninja_forms_load_deprecated', FALSE ) ) {
if( ! defined( 'NINJA_FORMS_STYLE_DIR' ) ) {
define("NINJA_FORMS_STYLE_DIR", plugin_dir_path(__FILE__) . '/deprecated');
}
if( ! defined( 'NINJA_FORMS_STYLE_URL' ) ) {
define("NINJA_FORMS_STYLE_URL", plugin_dir_url(__FILE__) . '/deprecated');
}
include 'deprecated/ninja-forms-style.php';
} else {
include 'layouts/ninja-forms-layouts.php';
if( ! function_exists( 'NF_Layouts' ) ) {
function NF_Layouts() { return NF_Layouts::instance(); }
}
NF_Layouts();
include 'styles/ninja-forms-styles.php';
if( ! function_exists( 'NF_Styles' ) ) {
function NF_Styles() { return NF_Styles::instance(); }
}
NF_Styles();
add_action( 'admin_init', 'ninja_forms_layout_styles_setup_license' );
if( ! function_exists( 'ninja_forms_layout_styles_setup_license' ) ) {
function ninja_forms_layout_styles_setup_license()
{
if (!class_exists('NF_Extension_Updater')) return;
new NF_Extension_Updater('Layout and Styles', NINJA_FORMS_STYLE_VERSION, 'WP Ninjas', __FILE__, 'style');
}
}
}
add_filter( 'ninja_forms_upgrade_settings', 'ninja_forms_styles_upgrade_form_settings' );
if( ! function_exists( 'ninja_forms_styles_upgrade_form_settings' ) ) {
function ninja_forms_styles_upgrade_form_settings( $data ){
if( ! isset( $data[ 'settings' ][ 'style' ][ 'groups' ] ) ) return $data;
foreach( $data[ 'settings' ][ 'style' ][ 'groups' ] as $group => $settings ){
if( 'field' == $group ) $group = 'element';
foreach( $settings as $setting => $value ){
$setting = $group . '_styles_' . $setting;
$data[ 'settings' ][ $setting ] = $value;
}
}
return $data;
}
}
add_filter( 'ninja_forms_upgrade_settings', 'ninja_forms_styles_upgrade_plugin_settings' );
if( ! function_exists( 'ninja_forms_styles_upgrade_plugin_settings' ) ) {
function ninja_forms_styles_upgrade_plugin_settings( $data ){
return $data;
}
}
add_filter( 'ninja_forms_upgrade_field', 'ninja_forms_styles_upgrade_field_settings' );
if( ! function_exists( 'ninja_forms_styles_upgrade_field_settings' ) ) {
function ninja_forms_styles_upgrade_field_settings( $data ){
if( ! isset( $data[ 'style' ][ 'groups' ] ) ) return $data;
foreach( $data[ 'style' ][ 'groups' ] as $group => $settings ){
if( 'field' == $group ) $group = 'element';
foreach( $settings as $setting => $value ){
$setting = $group . '_styles_' . $setting;
$data[ $setting ] = $value;
}
}
unset( $data[ 'style' ] );
return $data;
}
}