-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgf-poplink.php
75 lines (62 loc) · 1.79 KB
/
gf-poplink.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
<?php
/**
* Plugin Name: GF Population Link
* Plugin URI: https://github.com/bosconian-dynamics/gf-poplink
* Description: Provides strategies and options to pre-populate Gravity Forms forms.
* Version: 0.2.0
* Requires at least: 5.2
* Tested up to: 5.6
* Requires PHP: 7.2
* Author: Adam Bosco <wordpress@adambos.co>
* License: MIT
* Text-Domain: gf-poplink
*
* @package BosconianDynamics\GFPopLink
*/
namespace BosconianDynamics\GFPopLink;
require_once __DIR__ . '/vendor/autoload.php';
/**
* Public addon instance accessor.
*
* @return GFpoplinkAddOn
*/
function addon() {
return GFPopLinkAddOn::get_instance();
}
/**
* Check for new releases on the GitHub repo.
*
* @return void
*/
function check_for_updates() {
$puc = \Puc_v4_Factory::buildUpdateChecker(
'https://github.com/bosconian-dynamics/gf-poplink/',
__FILE__,
'gf-poplink'
);
$puc->getVcsApi()->enableReleaseAssets();
}
\add_action( 'plugins_loaded', __NAMESPACE__ . '\check_for_updates' );
/**
* Print an error to admin notices if Gravity Forms or the GF Addon Framework appear to be absent.
*
* @return void
*/
function check_gf_dependency() {
if( method_exists( 'GFForms', 'include_addon_framework' ) )
return;
echo '<div class="notice notice-error"><p>' . \esc_html__( 'The GF Population Link plugin depends on Gravity Forms.', 'gf-poplink' ) . '</p></div>';
}
\add_action( 'admin_notices', __NAMESPACE__ . '\check_gf_dependency' );
/**
* Load the poplink addon
*
* @return void
*/
function load() {
if( ! method_exists( 'GFForms', 'include_addon_framework' ) )
return;
require_once __DIR__ . '/inc/GFPopLinkAddOn.php';
\GFAddOn::register( __NAMESPACE__ . '\GFPopLinkAddOn' );
}
\add_action( 'gform_loaded', __NAMESPACE__ . '\load', 5 );