Repository navigation
Expand file tree
/
Copy pathgravityview.php
More file actions
301 lines (237 loc) · 8.57 KB
/
Copy pathgravityview.php
File metadata and controls
301 lines (237 loc) · 8.57 KB
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?php
/**
* The GravityView plugin
*
* Create directories based on a Gravity Forms form, insert them using a shortcode, and modify how they output.
*
* @package GravityView
* @license GPL2+
* @author Katz Web Services, Inc.
* @link http://gravityview.co
* @copyright Copyright 2014, Katz Web Services, Inc.
*
* @wordpress-plugin
* Plugin Name: GravityView
* Plugin URI: http://gravityview.co
* Description: Create directories based on a Gravity Forms form, insert them using a shortcode, and modify how they output.
* Version: 1.6.1
* Author: Katz Web Services, Inc.
* Author URI: http://www.katzwebservices.com
* Text Domain: gravityview
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Domain Path: /languages
* GitHub Plugin URI: ToBeDefined
*/
/** If this file is called directly, abort. */
if ( ! defined( 'ABSPATH' ) ) {
die;
}
/** Constants */
if( !defined('GRAVITYVIEW_FILE') )
define( 'GRAVITYVIEW_FILE', __FILE__ );
if ( !defined('GRAVITYVIEW_URL') )
define( 'GRAVITYVIEW_URL', plugin_dir_url( __FILE__ ) );
if ( !defined('GRAVITYVIEW_DIR') )
define( 'GRAVITYVIEW_DIR', plugin_dir_path( __FILE__ ) );
if ( !defined('GV_MIN_GF_VERSION') ) {
/**
* GravityView requires at least this version of Gravity Forms to function properly.
*/
define( 'GV_MIN_GF_VERSION', '1.8' );
}
/** Load common & connector functions */
require_once( GRAVITYVIEW_DIR . 'includes/class-common.php');
require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php');
/** Register Post Types and Rewrite Rules */
require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php');
/** Add Cache Class */
require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php');
/** Register hooks that are fired when the plugin is activated and deactivated. */
if( is_admin() ) {
register_activation_hook( __FILE__, array( 'GravityView_Plugin', 'activate' ) );
register_deactivation_hook( __FILE__, array( 'GravityView_Plugin', 'deactivate' ) );
}
/**
* GravityView_Plugin main class.
*/
final class GravityView_Plugin {
const version = '1.6.1';
public static $theInstance;
/**
* Singleton instance
*
* @return GravityView_Plugin GravityView_Plugin object
*/
public static function getInstance() {
if( empty( self::$theInstance ) ) {
self::$theInstance = new GravityView_Plugin;
}
return self::$theInstance;
}
public function __construct() {
require_once( GRAVITYVIEW_DIR .'includes/class-admin.php' );
// If Gravity Forms doesn't exist or is outdated, load the admin view class to
// show the notice, but not load any post types or process shortcodes.
// Without Gravity Forms, there is no GravityView. Beautiful, really.
if( !class_exists('GFForms') || false === version_compare(GFCommon::$version, GV_MIN_GF_VERSION, ">=") ) {
// If the plugin's not loaded, might as well hide the shortcode for people.
add_shortcode( 'gravityview', '__return_null' );
return;
}
// Load Extensions
// @todo: Convert to a scan of the directory or a method where this all lives
include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' );
include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' );
// Load Widgets
include_once( GRAVITYVIEW_DIR .'includes/widgets.php' );
// Add oEmbed
include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' );
// Add logging
require_once( GRAVITYVIEW_DIR . 'includes/class-logging.php');
require_once( GRAVITYVIEW_DIR . 'includes/class-ajax.php' );
require_once( GRAVITYVIEW_DIR . 'includes/class-settings.php');
include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' );
include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' );
/**
* Encrypt Email Addresses
* @link https://github.com/jnicol/standalone-phpenkoder
*/
if( !class_exists( 'StandalonePHPEnkoder' ) ) {
include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' );
}
// Load plugin text domain
add_action( 'init', array( $this, 'load_plugin_textdomain' ), 1 );
if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
add_action( 'init', array( $this, 'frontend_actions' ), 20 );
}
// Load default templates
add_action( 'init', array( $this, 'register_default_templates' ), 11 );
// Load default widgets
add_action( 'init', array( $this, 'register_widgets' ), 11 );
}
/**
* Plugin activate function.
*
* @access public
* @static
* @param mixed $network_wide
* @return void
*/
public static function activate( $network_wide ) {
// register post types
GravityView_Post_Types::init_post_types();
// register rewrite rules
GravityView_Post_Types::init_rewrite();
flush_rewrite_rules();
// Update the current GV version
update_option( 'gv_version', self::version );
// Add the transient to redirect to configuration page
set_transient( '_gv_activation_redirect', true, 60 );
// Clear settings transient
delete_transient( 'redux_edd_license_license_valid' );
}
/**
* Plugin deactivate function.
*
* @access public
* @static
* @param mixed $network_wide
* @return void
*/
public static function deactivate( $network_wide ) {
flush_rewrite_rules();
}
/**
* Include the extension class
*
* @since 1.5.1
* @return void
*/
public static function include_extension_framework() {
require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-extension.php' );
}
/**
* Loads the plugin's translated strings.
*
* @access public
* @return void
*/
public function load_plugin_textdomain() {
$loaded = load_plugin_textdomain( 'gravityview', false, '/languages/' );
if ( ! $loaded ) {
$loaded = load_muplugin_textdomain( 'gravityview', '/languages/' );
}
if ( ! $loaded ) {
$loaded = load_theme_textdomain( 'gravityview', '/languages/' );
}
if ( ! $loaded ) {
$locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' );
$mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo';
load_textdomain( 'gravityview', $mofile );
}
}
/**
* Function to launch frontend objects
*
* @access public
* @return void
*/
public function frontend_actions() {
include_once( GRAVITYVIEW_DIR .'includes/class-image.php' );
include_once( GRAVITYVIEW_DIR .'includes/class-template.php' );
include_once( GRAVITYVIEW_DIR .'includes/class-api.php' );
include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' );
include_once( GRAVITYVIEW_DIR . 'includes/class-change-entry-creator.php' );
// Nice place to insert extensions' frontend stuff
do_action('gravityview_include_frontend_actions');
}
/**
* Registers the default templates
* @todo Move somehere logical
* @return void
*/
function register_default_templates() {
include_once( GRAVITYVIEW_DIR .'includes/default-templates.php' );
}
/**
* Register the default widgets
* @todo Move somehere logical
* @return void
*/
function register_widgets() {
include_once( GRAVITYVIEW_DIR .'includes/default-widgets.php' );
include_once( GRAVITYVIEW_DIR .'includes/extensions/search-widget/class-search-widget.php' );
}
/**
* helper function to define the default widget areas
* @todo Move somehere logical
* @return array definition for default widget areas
*/
public static function get_default_widget_areas() {
$default_areas = array(
array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ),
array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ),
//array( '1-1' => array( array( 'areaid' => 'bottom', 'title' => __('Full Width Bottom', 'gravityview') , 'subtitle' => '' ) ) )
);
return apply_filters( 'gravityview_widget_active_areas', $default_areas );
}
/** DEBUG */
/**
* Logs messages using Gravity Forms logging add-on
* @param string $message log message
* @return void
*/
public static function log_debug( $message, $data = null ){
do_action( 'gravityview_log_debug', $message, $data );
}
/**
* Logs messages using Gravity Forms logging add-on
* @param string $message log message
* @return void
*/
public static function log_error( $message, $data = null ){
do_action( 'gravityview_log_error', $message, $data );
}
} // end class GravityView_Plugin
add_action('plugins_loaded', array('GravityView_Plugin', 'getInstance'), 1);