gravityview /
GravityView
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Plugin Name: GravityView |
||
| 4 | * Plugin URI: https://gravityview.co |
||
| 5 | * Description: The best, easiest way to display Gravity Forms entries on your website. |
||
| 6 | * Version: 1.19.4 |
||
| 7 | * Author: GravityView |
||
| 8 | * Author URI: https://gravityview.co |
||
| 9 | * Text Domain: gravityview |
||
| 10 | * License: GPLv2 or later |
||
| 11 | * License URI: http://www.gnu.org/licenses/gpl-2.0.html |
||
| 12 | * Domain Path: /languages |
||
| 13 | */ |
||
| 14 | |||
| 15 | /** If this file is called directly, abort. */ |
||
| 16 | if ( ! defined( 'ABSPATH' ) ) { |
||
| 17 | die; |
||
| 18 | } |
||
| 19 | |||
| 20 | /** Constants */ |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Full path to the GravityView file |
||
| 24 | * @define "GRAVITYVIEW_FILE" "./gravityview.php" |
||
| 25 | */ |
||
| 26 | define( 'GRAVITYVIEW_FILE', __FILE__ ); |
||
| 27 | |||
| 28 | /** |
||
| 29 | * The URL to this file, with trailing slash |
||
| 30 | */ |
||
| 31 | define( 'GRAVITYVIEW_URL', plugin_dir_url( __FILE__ ) ); |
||
| 32 | |||
| 33 | |||
| 34 | /** @define "GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory */ |
||
| 35 | define( 'GRAVITYVIEW_DIR', plugin_dir_path( __FILE__ ) ); |
||
| 36 | |||
| 37 | /** |
||
| 38 | * GravityView requires at least this version of Gravity Forms to function properly. |
||
| 39 | */ |
||
| 40 | define( 'GV_MIN_GF_VERSION', '1.9.14' ); |
||
| 41 | |||
| 42 | /** |
||
| 43 | * GravityView requires at least this version of WordPress to function properly. |
||
| 44 | * @since 1.12 |
||
| 45 | */ |
||
| 46 | define( 'GV_MIN_WP_VERSION', '4.0' ); |
||
| 47 | |||
| 48 | /** |
||
| 49 | * GravityView requires at least this version of PHP to function properly. |
||
| 50 | * @since 1.12 |
||
| 51 | */ |
||
| 52 | define( 'GV_MIN_PHP_VERSION', '5.2.4' ); |
||
| 53 | |||
| 54 | /** |
||
| 55 | * GravityView will require this version of PHP soon. False if no future PHP version changes are planned. |
||
| 56 | * @since 1.19.2 |
||
| 57 | * @var string|false |
||
| 58 | */ |
||
| 59 | define( 'GV_FUTURE_MIN_PHP_VERSION', '5.3' ); |
||
| 60 | |||
| 61 | /** |
||
| 62 | * GravityView will soon require at least this version of Gravity Forms to function properly. |
||
| 63 | * @since 1.19.4 |
||
| 64 | */ |
||
| 65 | define( 'GV_FUTURE_MIN_GF_VERSION', '2.0.0-rc-1' ); |
||
| 66 | |||
| 67 | /** Register hooks that are fired when the plugin is activated and deactivated. */ |
||
| 68 | register_activation_hook( __FILE__, array( 'GravityView_Plugin', 'activate' ) ); |
||
| 69 | |||
| 70 | register_deactivation_hook( __FILE__, array( 'GravityView_Plugin', 'deactivate' ) ); |
||
| 71 | |||
| 72 | /** |
||
| 73 | * The future is here and now. |
||
| 74 | */ |
||
| 75 | require GRAVITYVIEW_DIR . '/future/gravityview.php'; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * GravityView_Plugin main class. |
||
| 79 | */ |
||
| 80 | final class GravityView_Plugin { |
||
| 81 | |||
| 82 | const version = '1.19.4'; |
||
| 83 | |||
| 84 | private static $instance; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Singleton instance |
||
| 88 | * |
||
| 89 | * @return GravityView_Plugin GravityView_Plugin object |
||
| 90 | */ |
||
| 91 | public static function getInstance() { |
||
| 92 | |||
| 93 | if( empty( self::$instance ) ) { |
||
| 94 | self::$instance = new self; |
||
| 95 | } |
||
| 96 | |||
| 97 | return self::$instance; |
||
| 98 | } |
||
| 99 | |||
| 100 | private function __construct() { |
||
| 101 | |||
| 102 | self::require_files(); |
||
| 103 | |||
| 104 | if( ! GravityView_Compatibility::is_valid() ) { |
||
| 105 | return; |
||
| 106 | } |
||
| 107 | |||
| 108 | $this->include_files(); |
||
| 109 | |||
| 110 | $this->add_hooks(); |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Include files that are required by the plugin |
||
| 115 | * @since 1.18 |
||
| 116 | */ |
||
| 117 | private static function require_files() { |
||
| 118 | require_once( GRAVITYVIEW_DIR . 'includes/helper-functions.php' ); |
||
| 119 | require_once( GRAVITYVIEW_DIR . 'includes/class-common.php'); |
||
| 120 | require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php'); |
||
| 121 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-compatibility.php' ); |
||
| 122 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-roles-capabilities.php' ); |
||
| 123 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-notices.php' ); |
||
| 124 | require_once( GRAVITYVIEW_DIR .'includes/class-admin.php' ); |
||
| 125 | require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php'); |
||
| 126 | require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php'); |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Add hooks to set up the plugin |
||
| 131 | * |
||
| 132 | * @since 1.12 |
||
| 133 | */ |
||
| 134 | private function add_hooks() { |
||
| 135 | // Load plugin text domain |
||
| 136 | add_action( 'init', array( $this, 'load_plugin_textdomain' ), 1 ); |
||
| 137 | |||
| 138 | // Load frontend files |
||
| 139 | add_action( 'init', array( $this, 'frontend_actions' ), 20 ); |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Include global plugin files |
||
| 144 | * |
||
| 145 | * @since 1.12 |
||
| 146 | */ |
||
| 147 | public function include_files() { |
||
| 148 | |||
| 149 | // Load fields |
||
| 150 | include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-fields.php' ); |
||
| 151 | include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
||
| 152 | |||
| 153 | // Load all field files automatically |
||
| 154 | foreach ( glob( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field*.php' ) as $gv_field_filename ) { |
||
| 155 | include_once( $gv_field_filename ); |
||
| 156 | } |
||
| 157 | |||
| 158 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-approval-status.php' ); |
||
| 159 | include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-approval.php' ); |
||
| 160 | |||
| 161 | include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-notes.php' ); |
||
| 162 | include_once( GRAVITYVIEW_DIR .'includes/load-plugin-and-theme-hooks.php' ); |
||
| 163 | |||
| 164 | // Load Extensions |
||
| 165 | // @todo: Convert to a scan of the directory or a method where this all lives |
||
| 166 | include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' ); |
||
| 167 | include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' ); |
||
| 168 | include_once( GRAVITYVIEW_DIR .'includes/extensions/entry-notes/class-gravityview-field-notes.php' ); |
||
| 169 | |||
| 170 | // Load WordPress Widgets |
||
| 171 | include_once( GRAVITYVIEW_DIR .'includes/wordpress-widgets/register-wordpress-widgets.php' ); |
||
| 172 | |||
| 173 | // Load GravityView Widgets |
||
| 174 | include_once( GRAVITYVIEW_DIR .'includes/widgets/register-gravityview-widgets.php' ); |
||
| 175 | |||
| 176 | // Add oEmbed |
||
| 177 | include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' ); |
||
| 178 | |||
| 179 | // Add logging |
||
| 180 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-logging.php' ); |
||
| 181 | |||
| 182 | include_once( GRAVITYVIEW_DIR . 'includes/class-ajax.php' ); |
||
| 183 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-settings.php' ); |
||
| 184 | include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' ); |
||
| 185 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' ); |
||
| 186 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' ); |
||
| 187 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */ |
||
| 188 | include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' ); |
||
| 189 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-shortcode.php' ); |
||
| 190 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-link-shortcode.php' ); |
||
| 191 | include_once( GRAVITYVIEW_DIR . 'includes/class-gvlogic-shortcode.php' ); |
||
| 192 | include_once( GRAVITYVIEW_DIR . 'includes/presets/register-default-templates.php' ); |
||
| 193 | |||
| 194 | } |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Check whether GravityView is network activated |
||
| 198 | * @since 1.7.6 |
||
| 199 | * @return bool |
||
| 200 | */ |
||
| 201 | public static function is_network_activated() { |
||
| 202 | return is_multisite() && ( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network( 'gravityview/gravityview.php' ) ); |
||
| 203 | } |
||
| 204 | |||
| 205 | |||
| 206 | /** |
||
| 207 | * Plugin activate function. |
||
| 208 | * |
||
| 209 | * @access public |
||
| 210 | * @static |
||
| 211 | * @return void |
||
| 212 | */ |
||
| 213 | public static function activate() { |
||
| 214 | |||
| 215 | self::require_files(); |
||
| 216 | |||
| 217 | // register post types |
||
| 218 | GravityView_Post_Types::init_post_types(); |
||
| 219 | |||
| 220 | // register rewrite rules |
||
| 221 | GravityView_Post_Types::init_rewrite(); |
||
| 222 | |||
| 223 | flush_rewrite_rules(); |
||
| 224 | |||
| 225 | // Update the current GV version |
||
| 226 | update_option( 'gv_version', self::version ); |
||
| 227 | |||
| 228 | // Add the transient to redirect to configuration page |
||
| 229 | set_transient( '_gv_activation_redirect', true, 60 ); |
||
| 230 | |||
| 231 | // Clear settings transient |
||
| 232 | delete_transient( 'gravityview_edd-activate_valid' ); |
||
| 233 | |||
| 234 | GravityView_Roles_Capabilities::get_instance()->add_caps(); |
||
| 235 | } |
||
| 236 | |||
| 237 | |||
| 238 | /** |
||
| 239 | * Plugin deactivate function. |
||
| 240 | * |
||
| 241 | * @access public |
||
| 242 | * @static |
||
| 243 | * @return void |
||
| 244 | */ |
||
| 245 | public static function deactivate() { |
||
| 246 | flush_rewrite_rules(); |
||
| 247 | } |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Include the extension class |
||
| 251 | * |
||
| 252 | * @since 1.5.1 |
||
| 253 | * @return void |
||
| 254 | */ |
||
| 255 | public static function include_extension_framework() { |
||
| 256 | if ( ! class_exists( 'GravityView_Extension' ) ) { |
||
| 257 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-extension.php' ); |
||
| 258 | } |
||
| 259 | } |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Load GravityView_Widget class |
||
| 263 | * |
||
| 264 | * @since 1.7.5.1 |
||
| 265 | */ |
||
| 266 | public static function include_widget_class() { |
||
| 267 | include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
||
| 268 | } |
||
| 269 | |||
| 270 | |||
| 271 | /** |
||
| 272 | * Loads the plugin's translated strings. |
||
| 273 | * |
||
| 274 | * @access public |
||
| 275 | * @return void |
||
| 276 | */ |
||
| 277 | public function load_plugin_textdomain() { |
||
| 278 | |||
| 279 | $loaded = load_plugin_textdomain( 'gravityview', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
||
| 280 | |||
| 281 | if ( ! $loaded ) { |
||
| 282 | $loaded = load_muplugin_textdomain( 'gravityview', '/languages/' ); |
||
| 283 | } |
||
| 284 | if ( ! $loaded ) { |
||
| 285 | $loaded = load_theme_textdomain( 'gravityview', '/languages/' ); |
||
| 286 | } |
||
| 287 | if ( ! $loaded ) { |
||
| 288 | $locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' ); |
||
| 289 | $mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo'; |
||
| 290 | load_textdomain( 'gravityview', $mofile ); |
||
| 291 | } |
||
| 292 | |||
| 293 | } |
||
| 294 | |||
| 295 | /** |
||
| 296 | * Check if is_admin(), and make sure not DOING_AJAX |
||
| 297 | * @since 1.7.5 |
||
| 298 | * @return bool |
||
| 299 | */ |
||
| 300 | public static function is_admin() { |
||
| 301 | |||
| 302 | $doing_ajax = defined( 'DOING_AJAX' ) ? DOING_AJAX : false; |
||
| 303 | |||
| 304 | return is_admin() && ! $doing_ajax; |
||
| 305 | } |
||
| 306 | |||
| 307 | /** |
||
| 308 | * Function to launch frontend objects |
||
| 309 | * |
||
| 310 | * @since 1.17 Added $force param |
||
| 311 | * |
||
| 312 | * @access public |
||
| 313 | * |
||
| 314 | * @param bool $force Whether to force loading, even if GravityView_Plugin::is_admin() returns true |
||
| 315 | * |
||
| 316 | * @return void |
||
| 317 | */ |
||
| 318 | public function frontend_actions( $force = false ) { |
||
| 319 | |||
| 320 | if( self::is_admin() && ! $force ) { return; } |
||
| 321 | |||
| 322 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-image.php' ); |
||
| 323 | include_once( GRAVITYVIEW_DIR .'includes/class-template.php' ); |
||
| 324 | include_once( GRAVITYVIEW_DIR .'includes/class-api.php' ); |
||
| 325 | include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' ); |
||
| 326 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
||
| 327 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 328 | |||
| 329 | /** |
||
| 330 | * When an entry is created, check if we need to update the custom slug meta |
||
| 331 | * todo: move this to its own class.. |
||
| 332 | */ |
||
| 333 | add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
||
| 334 | |||
| 335 | /** |
||
| 336 | * @action `gravityview_include_frontend_actions` Triggered after all GravityView frontend files are loaded |
||
| 337 | * |
||
| 338 | * Nice place to insert extensions' frontend stuff |
||
| 339 | */ |
||
| 340 | do_action( 'gravityview_include_frontend_actions' ); |
||
| 341 | } |
||
| 342 | |||
| 343 | /** |
||
| 344 | * helper function to define the default widget areas |
||
| 345 | * @todo Move somewhere logical |
||
| 346 | * @return array definition for default widget areas |
||
| 347 | */ |
||
| 348 | public static function get_default_widget_areas() { |
||
| 349 | $default_areas = array( |
||
| 350 | array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ), |
||
| 351 | array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ), |
||
| 352 | ); |
||
| 353 | |||
| 354 | /** |
||
| 355 | * @filter `gravityview_widget_active_areas` Array of zones available for widgets to be dropped into |
||
| 356 | * @param array $default_areas Definition for default widget areas |
||
| 357 | */ |
||
| 358 | return apply_filters( 'gravityview_widget_active_areas', $default_areas ); |
||
| 359 | } |
||
| 360 | |||
| 361 | /** DEBUG */ |
||
| 362 | |||
| 363 | /** |
||
| 364 | * Logs messages using Gravity Forms logging add-on |
||
| 365 | * @param string $message log message |
||
| 366 | * @param mixed $data Additional data to display |
||
| 367 | * @return void |
||
| 368 | */ |
||
| 369 | public static function log_debug( $message, $data = null ){ |
||
| 370 | /** |
||
| 371 | * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
||
| 372 | * @param string $message Message to display |
||
| 373 | * @param mixed $data Supporting data to print alongside it |
||
| 374 | */ |
||
| 375 | do_action( 'gravityview_log_debug', $message, $data ); |
||
| 376 | } |
||
| 377 | |||
| 378 | /** |
||
| 379 | * Logs messages using Gravity Forms logging add-on |
||
| 380 | * @param string $message log message |
||
| 381 | * @return void |
||
| 382 | */ |
||
| 383 | public static function log_error( $message, $data = null ){ |
||
| 384 | /** |
||
| 385 | * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
||
| 386 | * @param string $message Error message to display |
||
| 387 | * @param mixed $data Supporting data to print alongside it |
||
| 388 | */ |
||
| 389 | do_action( 'gravityview_log_error', $message, $data ); |
||
| 390 | } |
||
| 391 | |||
| 392 | } // end class GravityView_Plugin |
||
| 393 | |||
| 394 | add_action('plugins_loaded', array('GravityView_Plugin', 'getInstance'), 1); |
||
| 395 |