-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocation-addon-for-gravity-forms.php
87 lines (75 loc) · 2.63 KB
/
location-addon-for-gravity-forms.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
<?php
/**
* Location Add-on For Gravity Forms
*
* @category Plugin
* @package LocationAddonForGravityForms
* @author Tanner Record <[email protected]>
* @copyright 2021 Tanner Record
* @license GPL-2.0-or-later <http://www.gnu.org/licenses/gpl-2.0.txt>
* @link https://www.tannerrecord.com/location-add-on-for-gravity-forms
*
* @wordpress-plugin
* Plugin Name: Location Add-on For Gravity Forms
* Plugin URI: https://www.tannerrecord.com/location-add-on-for-gravity-forms
* Description: An Add-on for Gravity Forms that displays the posts & pages on which a form has been used.
* Version: 2.0.2
* Requires at least: 5.6
* Requires PHP: 7.1
* Author: Tanner Record
* Author URI: https://www.tannerrecord.com
* Text Domain: location-add-on-for-gravity-forms
* License: GPL v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
/**
* Include the autoloader.
*/
require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php';
/**
* Since this plugin depends on Gravity Forms, we need to check if
* Gravity Forms is currently active.
*
* If not, display an error to the user explaining why this plugin
* could not be activated.
*/
add_action( 'plugins_loaded', 'lagf_dependency_check' );
/**
* Checks to see if Gravity Forms is installed, activated and the correct version.
*
* @since 1.0.0
*/
function lagf_dependency_check() {
// If Parent Plugin is NOT active.
if ( current_user_can( 'activate_plugins' ) && ! class_exists( 'GFForms' ) ) {
add_action( 'admin_init', 'lagf_deactivate' );
add_action( 'admin_notices', 'lagf_admin_notice' );
/**
* Deactivate the plugin.
*/
function lagf_deactivate() {
deactivate_plugins( plugin_basename( __FILE__ ) );
}
/**
* Throw an Alert to tell the Admin why it didn't activate.
*/
function lagf_admin_notice() {
$lagf_child_plugin = __( 'Location Add-On For Gravity Forms', 'location-add-on-for-gravity-forms' );
$lagf_parent_plugin = __( 'Gravity Forms', 'location-add-on-for-gravity-forms' );
echo sprintf(
'<div class="error"><p>Please activate <strong>%2$s</strong> before activating <strong>%1$s</strong>. For now, the plugin has been deactivated.</p></div>',
esc_html( $lagf_child_plugin ),
esc_html( $lagf_parent_plugin )
);
// phpcs:disable
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
// phpcs:enable
}
}
}
$lagf_plugin = new \TARecord\LocationAddonForGravityForms\Core( __FILE__ );
// Handle activation.
register_activation_hook( __FILE__, [ $lagf_plugin, 'activate' ] );
$lagf_plugin->init();