-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathform2airtable.php
213 lines (176 loc) · 6.16 KB
/
form2airtable.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
/*
Plugin Name: Form 2 Airtable
Plugin URI: https://samjco.com/plugins/form2airtable
Description: Plugin that builds a simple form to submit to a Airtable database.
Version: 0.1
Author: Sam Cohen
Author URI: https://samjco.com/
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: form2airtable
Domain Path: /languages
*/
/**
* Copyright (c) YEAR Your Name (email: Email). All rights reserved.
*
* Released under the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This is an add-on for WordPress
* http://wordpress.org/
*
* **********************************************************************
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* **********************************************************************
*/
// don't call the file directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Form_2_Airtable class
*
* @class Form_2_Airtable The class that holds the entire Form_2_Airtable plugin
*/
class Form_2_Airtable {
/**
* Plugin version
*
* @var string
*/
public $version = '0.1.0';
/**
* Constructor for the Form_2_Airtable class
*
* Sets up all the appropriate hooks and actions
* within our plugin.
*
* @uses register_activation_hook()
* @uses register_deactivation_hook()
* @uses is_admin()
* @uses add_action()
*/
public function __construct() {
$this->define_constants();
register_activation_hook( __FILE__, array( $this, 'activate' ) );
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
$this->includes();
$this->init_hooks();
}
/**
* Define the constants
*
* @return void
*/
public function define_constants() {
define( 'FORM2AIRTABLE_VERSION', $this->version );
define( 'FORM2AIRTABLE_FILE', __FILE__ );
define( 'FORM2AIRTABLE_PATH', dirname( FORM2AIRTABLE_FILE ) );
define( 'FORM2AIRTABLE_INCLUDES', FORM2AIRTABLE_PATH . '/includes' );
define( 'FORM2AIRTABLE_URL', plugins_url( '', FORM2AIRTABLE_FILE ) );
define( 'FORM2AIRTABLE_ASSETS', FORM2AIRTABLE_URL . '/assets' );
}
/**
* Initializes the Form_2_Airtable() class
*
* Checks for an existing Form_2_Airtable() instance
* and if it doesn't find one, creates it.
*/
public static function init() {
static $instance = false;
if ( ! $instance ) {
$instance = new Form_2_Airtable();
}
return $instance;
}
/**
* Placeholder for activation function
*
* Nothing being called here yet.
*/
public function activate() {
update_option( 'form2airtable_version', FORM2AIRTABLE_VERSION );
}
/**
* Placeholder for deactivation function
*
* Nothing being called here yet.
*/
public function deactivate() {
}
/**
* Include the required files
*
* @return void
*/
public function includes() {
require_once dirname( __FILE__ ) .'/includes/codestar/cs-framework.php';
require_once dirname( __FILE__ ) .'/formdata.php';
require_once dirname( __FILE__ ) .'/formprocess.php';
}
/**
* Initialize the hooks
*
* @return void
*/
public function init_hooks() {
// Localize our plugin
add_action( 'init', array( $this, 'localization_setup' ) );
// Loads frontend scripts and styles
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
define( 'CS_ACTIVE_FRAMEWORK', true ); // default true
define( 'CS_ACTIVE_METABOX', false ); // default true
define( 'CS_ACTIVE_TAXONOMY', false ); // default true
define( 'CS_ACTIVE_SHORTCODE', false ); // default true
define( 'CS_ACTIVE_CUSTOMIZE', false ); // default true
define( 'CS_ACTIVE_LIGHT_THEME', true ); // default false
}
/**
* Initialize plugin for localization
*
* @uses load_plugin_textdomain()
*/
public function localization_setup() {
load_plugin_textdomain( 'form2airtable', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Enqueue admin scripts
*
* Allows plugin assets to be loaded.
*
* @uses wp_enqueue_script()
* @uses wp_localize_script()
* @uses wp_enqueue_style
*/
public function enqueue_scripts() {
/**
* All styles goes here
*/
wp_enqueue_style( 'form2airtable-styles', plugins_url( 'assets/css/style.css', __FILE__ ), false, date( 'Ymd' ) );
wp_enqueue_style( 'bootstrap4-styles', plugins_url( 'assets/css/bootstrap.min.css', __FILE__ ), false, date( 'Ymd' ) );
/**
* All scripts goes here
*/
wp_enqueue_script( 'form2airtable-scripts', plugins_url( 'assets/js/script.js', __FILE__ ), array( 'jquery' ), false, true );
wp_enqueue_script( 'bootstrap4-scripts', plugins_url( 'assets/js/bootstrap.min.js', __FILE__ ), array( 'jquery' ), false, true );
/**
* Example for setting up text strings from Javascript files for localization
*
* Uncomment line below and replace with proper localization variables.
*/
// $translation_array = array( 'some_string' => __( 'Some string to translate', 'form2airtable' ), 'a_value' => '10' );
// wp_localize_script( 'base-plugin-scripts', 'form2airtable', $translation_array ) );
}
} // Form_2_Airtable
$form2airtable = Form_2_Airtable::init();