9 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
22 const ALL_VIEWS_SLUG =
'gravityview_all_views';
24 const NEW_VIEW_SLUG =
'gravityview_new_view';
81 private static $__instance = null;
94 const FEATURE_GFQUERY =
'gfquery';
99 const FEATURE_JOINS =
'joins';
104 const FEATURE_UNIONS =
'unions';
109 const FEATURE_REST =
'rest_api';
116 public static function get() {
118 if ( ! self::$__instance instanceof
self ) {
119 self::$__instance =
new self;
122 return self::$__instance;
129 add_action(
'gravityview/loaded', array( $this,
'include_legacy_frontend' ) );
134 add_action(
'plugins_loaded', array( $this,
'load_settings' ) );
137 add_action(
'gk/foundation/initialized', array( $this,
'add_to_gravitykit_admin_menu' ) );
139 add_action(
'admin_menu', array( $this,
'setup_gravitykit_admin_menu_redirects' ) );
143 require_once $this->dir(
'future/includes/class-gv-settings-plugin.php' );
146 include_once $this->dir(
'includes/class-gravityview-settings.php' );
158 return version_compare(
'2.5-beta', \GFForms::$version,
'<=' );
170 return is_multisite() && ( function_exists(
'is_plugin_active_for_network' ) && is_plugin_active_for_network( $plugin_basename ) );
182 if (
gravityview()->request->is_admin() && ! $force ) {
186 include_once $this->dir(
'includes/class-gravityview-image.php' );
187 include_once $this->dir(
'includes/class-template.php' );
188 include_once $this->dir(
'includes/class-api.php' );
189 include_once $this->dir(
'includes/class-frontend-views.php' );
190 include_once $this->dir(
'includes/class-gravityview-change-entry-creator.php' );
199 do_action(
'gravityview_include_frontend_actions' );
208 if ( ! class_exists(
'\GravityView_Extension' ) ) {
209 include_once $this->dir(
'includes/class-gravityview-extension.php' );
217 include_once $this->dir(
'includes/fields/class-gravityview-fields.php' );
218 include_once $this->dir(
'includes/fields/class-gravityview-field.php' );
221 foreach ( glob( $this->dir(
'includes/fields/class-gravityview-field*.php' ) ) as $gv_field_filename ) {
222 include_once $gv_field_filename;
225 include_once $this->dir(
'includes/class-gravityview-entry-approval-status.php' );
226 include_once $this->dir(
'includes/class-gravityview-entry-approval-merge-tags.php' );
227 include_once $this->dir(
'includes/class-gravityview-entry-approval.php' );
229 include_once $this->dir(
'includes/class-gravityview-entry-notes.php' );
230 include_once $this->dir(
'includes/load-plugin-and-theme-hooks.php' );
234 include_once $this->dir(
'includes/extensions/edit-entry/class-edit-entry.php' );
235 include_once $this->dir(
'includes/extensions/delete-entry/class-delete-entry.php' );
236 include_once $this->dir(
'includes/extensions/duplicate-entry/class-duplicate-entry.php' );
237 include_once $this->dir(
'includes/extensions/entry-notes/class-gravityview-field-notes.php' );
238 include_once $this->dir(
'includes/extensions/lightbox/class-gravityview-lightbox.php' );
241 include_once $this->dir(
'includes/wordpress-widgets/register-wordpress-widgets.php' );
244 include_once $this->dir(
'includes/widgets/register-gravityview-widgets.php' );
247 include_once $this->dir(
'includes/class-api.php' );
248 include_once $this->dir(
'includes/class-oembed.php' );
251 include_once $this->dir(
'includes/class-gravityview-logging.php' );
253 include_once $this->dir(
'includes/class-ajax.php' );
254 include_once $this->dir(
'includes/class-gravityview-html-elements.php' );
255 include_once $this->dir(
'includes/class-frontend-views.php' );
256 include_once $this->dir(
'includes/class-gravityview-admin-bar.php' );
257 include_once $this->dir(
'includes/class-gravityview-entry-list.php' );
258 include_once $this->dir(
'includes/class-gravityview-merge-tags.php' );
260 include_once $this->dir(
'includes/class-data.php' );
261 include_once $this->dir(
'includes/class-gravityview-shortcode.php' );
262 include_once $this->dir(
'includes/class-gravityview-entry-link-shortcode.php' );
263 include_once $this->dir(
'includes/class-gvlogic-shortcode.php' );
264 include_once $this->dir(
'includes/presets/register-default-templates.php' );
266 if ( class_exists(
'\GFFormsModel' ) ) {
267 include_once $this->dir(
'includes/class-gravityview-gfformsmodel.php' );
278 register_activation_hook( $this->dir(
'gravityview.php' ), array( $this,
'activate' ) );
279 register_deactivation_hook( $this->dir(
'gravityview.php' ), array( $this,
'deactivate' ) );
292 if ( ! $this->is_compatible() ) {
297 require_once $this->dir(
'future/includes/class-gv-view.php' );
298 View::register_post_type();
301 require_once $this->dir(
'future/includes/class-gv-entry.php' );
302 Entry::add_rewrite_endpoint();
305 flush_rewrite_rules();
307 update_option(
'gv_version', self::$version );
310 set_transient(
'_gv_activation_redirect',
true, 60 );
313 delete_transient(
'gravityview_edd-activate_valid' );
326 flush_rewrite_rules();
338 public function dir( $path =
'' ) {
354 $dirname = trailingslashit( dirname( plugin_basename(
GRAVITYVIEW_FILE ) ) );
356 return wp_normalize_path( $dirname . ltrim( $path,
'/' ) );
368 public function url( $path =
'/' ) {
370 return plugins_url( $path, $this->dir(
'gravityview.php' ) );
384 $this->is_compatible_php()
385 && $this->is_compatible_wordpress()
386 && $this->is_compatible_gravityforms();
399 return version_compare( $this->get_php_version(), self::$min_php_version,
'>=' );
412 return version_compare( $this->get_php_version(), self::$future_min_php_version,
'>=' );
428 $version = self::$min_wp_version;
431 return version_compare( $this->get_wordpress_version(), $version,
'>=' );
444 $version = $this->get_wordpress_version();
446 return $version ? version_compare( $version, self::$future_min_wp_version,
'>=' ) :
false;
459 $version = $this->get_gravityforms_version();
461 return $version ? version_compare( $version, self::$min_gf_version,
'>=' ) :
false;
474 $version = $this->get_gravityforms_version();
476 return $version ? version_compare( $version, self::$future_min_gf_version,
'>=' ) :
false;
488 return ! empty( $GLOBALS[
'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] ) ?
489 $GLOBALS[
'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] : phpversion();
501 return ! empty( $GLOBALS[
'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] ) ?
502 $GLOBALS[
'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] : $GLOBALS[
'wp_version'];
514 if ( ! class_exists(
'\GFCommon' ) || ! empty( $GLOBALS[
'GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) ) {
515 gravityview()->log->error(
'Gravity Forms is inactive or not installed.' );
520 return ! empty( $GLOBALS[
'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] ) ?
521 $GLOBALS[
'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] : \GFCommon::$version;
538 $supports = apply_filters(
"gravityview/plugin/feature/$feature", null );
540 if ( ! is_null( $supports ) ) {
541 return (
bool) $supports;
545 case self::FEATURE_GFQUERY:
546 return class_exists(
'\GF_Query' );
547 case self::FEATURE_JOINS:
548 case self::FEATURE_UNIONS:
549 return apply_filters(
'gravityview/query/class',
false ) ===
'\GF_Patched_Query';
550 case self::FEATURE_REST:
551 return class_exists(
'\WP_REST_Controller' );
566 $suppress = $wpdb->suppress_errors();
571 $items = get_posts( array(
572 'post_type' =>
'gravityview',
573 'post_status' =>
'any',
574 'numberposts' => - 1,
578 foreach ( $items as $item ) {
579 wp_delete_post( $item,
true );
588 $tables [] = \GFFormsModel::get_entry_meta_table_name();
589 } elseif ( ! $this->is_GF_25() ) {
590 $tables [] = \GFFormsModel::get_lead_meta_table_name();
593 foreach ( $tables as $meta_table ) {
595 DELETE FROM $meta_table 597 `meta_key` = 'is_approved' 600 $wpdb->query( $sql );
609 $tables[] = \GFFormsModel::get_entry_notes_table_name();
610 } elseif ( ! $this->is_GF_25() ) {
611 $tables[] = \GFFormsModel::get_lead_notes_table_name();
614 $disapproved = __(
'Disapproved the Entry for GravityView',
'gk-gravityview' );
615 $approved = __(
'Approved the Entry for GravityView',
'gk-gravityview' );
617 $suppress = $wpdb->suppress_errors();
618 foreach ( $tables as $notes_table ) {
619 $sql = $wpdb->prepare(
" 620 DELETE FROM $notes_table 622 `note_type` = 'gravityview' OR 626 ", $approved, $disapproved );
627 $wpdb->query( $sql );
630 $wpdb->suppress_errors( $suppress );
640 delete_option(
'gravityview_cache_blacklist' );
641 delete_option(
'gravityview_cache_blocklist' );
642 delete_option(
'gv_version' );
643 delete_option(
'gv_version_upgraded_from' );
644 delete_transient(
'gravityview_edd-activate_valid' );
645 delete_transient(
'gravityview_edd-deactivate_valid' );
646 delete_transient(
'gravityview_dismissed_notices' );
647 delete_transient(
'_gv_activation_redirect' );
648 delete_transient(
'gravityview_edd-activate_valid' );
649 delete_site_transient(
'gravityview_related_plugins' );
660 if ( ! class_exists(
'GVCommon' ) || !
GVCommon::has_cap(
'edit_gravityviews' ) ) {
666 if ( ! $pagenow || ! is_admin() ) {
670 if (
'admin.php' === $pagenow ) {
671 if ( self::ALL_VIEWS_SLUG === GravityKitFoundation::helpers()->array->get( $_GET,
'page' ) ) {
672 wp_safe_redirect( $this->get_link_to_all_views() );
677 if ( self::NEW_VIEW_SLUG === GravityKitFoundation::helpers()->array->get( $_GET,
'page' ) ) {
678 wp_safe_redirect( $this->get_link_to_new_view() );
693 return add_query_arg(
694 [
'post_type' =>
'gravityview' ],
695 admin_url(
'post-new.php' )
707 return add_query_arg(
708 [
'post_type' =>
'gravityview' ],
709 admin_url(
'edit.php' )
723 if ( !
GVCommon::has_cap(
'edit_gravityviews' ) || GravityKitFoundation::helpers()->core->is_network_admin() ) {
727 $admin_menu = $foundation::admin_menu();
728 $post_type =
'gravityview';
729 $capability =
'edit_gravityviews';
730 $all_views_menu_id =
"{$post_type}_all_views";
731 $new_view_menu_id =
"{$post_type}_new_view";
733 $admin_menu::add_submenu_item( [
734 'page_title' => __(
'All Views',
'gk-gravityview' ),
735 'menu_title' => __(
'All Views',
'gk-gravityview' ),
736 'capability' => $capability,
737 'id' => $all_views_menu_id,
738 'callback' =>
'__return_false',
742 $admin_menu::add_submenu_item( [
743 'page_title' => __(
'New View',
'gk-gravityview' ),
744 'menu_title' => __(
'New View',
'gk-gravityview' ),
745 'capability' => $capability,
746 'id' => $new_view_menu_id,
747 'callback' =>
'__return_false',
751 add_filter(
'parent_file',
function ( $parent_file ) use ( $admin_menu, $post_type, $all_views_menu_id, $new_view_menu_id ) {
752 global $submenu_file;
754 if ( ! $submenu_file || strpos( $submenu_file,
"post_type={$post_type}" ) ===
false ) {
758 if ( strpos( $submenu_file,
'edit.php' ) !==
false ) {
759 $submenu_file = $all_views_menu_id;
762 if ( strpos( $submenu_file,
'post-new.php' ) !==
false ) {
763 $submenu_file = $new_view_menu_id;
766 return constant( get_class( $admin_menu ) .
'::WP_ADMIN_MENU_SLUG' );
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
const GV_PLUGIN_VERSION(! GravityKit\GravityView\Foundation\meets_min_php_version_requirement(__FILE__, '7.2.0'))
Constants.
deactivate()
Plugin deactivation function.
get_php_version()
Retrieve the current PHP version.
setup_gravitykit_admin_menu_redirects()
Redirects GravityKit's GravityView submenu pages to the appropriate custom post endpoints.
uninstall()
Delete GravityView Views, settings, roles, caps, etc.
is_compatible_future_gravityforms()
Is this version of GravityView compatible with the future version of Gravity Forms?
is_GF_25()
Check whether Gravity Forms is v2.5-beta or newer.
const GV_FUTURE_MIN_WP_VERSION
GravityView will soon require at least this version of WordPress to function properly.
is_compatible_future_wordpress()
Is this version of GravityView compatible with the future version of WordPress?
get_link_to_all_views()
Returns the URL to the "New View" page.
get_wordpress_version()
Retrieve the current WordPress version.
static is_network_activated()
Check whether GravityView `is network activated.
is_compatible_wordpress( $version=null)
Is this version of GravityView compatible with the current version of WordPress?
is_compatible_gravityforms()
Is this version of GravityView compatible with the current version of Gravity Forms?
is_compatible_future_php()
Is this version of GravityView compatible with the future required version of PHP?
get_gravityforms_version()
Retrieve the current Gravity Forms version.
include_legacy_core()
Load more legacy core files.
dir( $path='')
Retrieve an absolute path within the GravityView plugin directory.
add_to_gravitykit_admin_menu( $foundation)
Adds "All Views" and "New View" as submenus to the GravityKit menu.
relpath( $path='')
Retrieve a relative path to the GravityView plugin directory from the WordPress plugin directory...
const GV_FUTURE_MIN_PHP_VERSION
If this file is called directly, abort.
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
const GV_FUTURE_MIN_GF_VERSION
GravityView will soon require at least this version of Gravity Forms to function properly.
supports( $feature)
Feature support detection.
register_activation_hooks()
Register hooks that are fired when the plugin is activated and deactivated.
is_compatible()
Is everything compatible with this version of GravityView?
include_legacy_frontend( $force=false)
Include more legacy stuff.
gravityview()
The main GravityView wrapper function.
is_compatible_php()
Is this version of GravityView compatible with the current version of PHP?
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
activate()
Plugin activation function.
Ex-GF Addon Settings class that's been stripped of GF functionality.
url( $path='/')
Retrieve a URL within the GravityView plugin directory.
get_link_to_new_view()
Returns the URL to the "All Views" page.
const GV_MIN_GF_VERSION
GravityView requires at least this version of Gravity Forms to function properly. ...
const GV_MIN_PHP_VERSION
GravityView requires at least this version of PHP to function properly.
const GV_MIN_WP_VERSION
GravityView requires at least this version of WordPress to function properly.