|
2 | 2 |
|
3 | 3 | defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die(); |
4 | 4 |
|
5 | | -// Include the Gravity Forms add-on framework |
6 | | -GFForms::include_addon_framework(); |
| 5 | +// Include the Gravity Forms add-on framework, if available. |
| 6 | +// When running as a standalone WP-CLI package, GFForms is not loaded. |
| 7 | +if ( class_exists('GFForms' ) ) { |
| 8 | + GFForms::include_addon_framework(); |
| 9 | +} |
7 | 10 |
|
8 | | -class GF_CLI extends GFAddOn { |
9 | | - /** |
10 | | - * Contains an instance of this class, if available. |
11 | | - * |
12 | | - * @since 1.0-beta-1 |
13 | | - * @access private |
14 | | - * @var object $_instance If available, contains an instance of this class |
15 | | - */ |
16 | | - private static $_instance = null; |
| 11 | +if ( class_exists( 'GFAddOn' ) ) { |
17 | 12 |
|
18 | | - /** |
19 | | - * Defines the version of the WP-CLI add-on. |
20 | | - * |
21 | | - * @since 1.0-beta-1 |
22 | | - * @access protected |
23 | | - * @var string $_version Contains the version, defined from cli.php |
24 | | - */ |
25 | | - protected $_version = GF_CLI_VERSION; |
26 | | - /** |
27 | | - * Defines the minimum Gravity Forms version required. |
28 | | - * @since 1.0-beta-1 |
29 | | - * @access protected |
30 | | - * @var string $_min_gravityforms_version The minimum version required. |
31 | | - */ |
32 | | - protected $_min_gravityforms_version = GF_CLI_MIN_GF_VERSION; |
33 | | - /** |
34 | | - * Defines the plugin slug. |
35 | | - * |
36 | | - * @since 1.0-beta-1 |
37 | | - * @access protected |
38 | | - * @var string $_slug The slug used for this plugin. |
39 | | - */ |
40 | | - protected $_slug = 'gravityformscli'; |
41 | | - /** |
42 | | - * Defines the main plugin file. |
43 | | - * |
44 | | - * @since 1.0-beta-1 |
45 | | - * @access protected |
46 | | - * @var string $_path The path to the main plugin file, relative to the plugins folder. |
47 | | - */ |
48 | | - protected $_path = 'gravityformscli/cli.php'; |
49 | | - /** |
50 | | - * Defines the full path to this class file. |
51 | | - * |
52 | | - * @since 1.0-beta-1 |
53 | | - * @access protected |
54 | | - * @var string $_full_path The full path. |
55 | | - */ |
56 | | - protected $_full_path = __FILE__; |
57 | | - /** |
58 | | - * Defines the URL where this add-on can be found. |
59 | | - * |
60 | | - * @since 1.0-beta-1 |
61 | | - * @access protected |
62 | | - * @var string |
63 | | - */ |
64 | | - protected $_url = 'http://www.gravityforms.com'; |
65 | | - /** |
66 | | - * Defines the title of this add-on. |
67 | | - * |
68 | | - * @since 1.0-beta-1 |
69 | | - * @access protected |
70 | | - * @var string $_title The title of the add-on. |
71 | | - */ |
72 | | - protected $_title = 'Gravity Forms CLI Add-On'; |
73 | | - /** |
74 | | - * Defines the short title of the add-on. |
75 | | - * |
76 | | - * @since 1.0-beta-1 |
77 | | - * @access protected |
78 | | - * @var string $_short_title The short title. |
79 | | - */ |
80 | | - protected $_short_title = 'CLI'; |
| 13 | + class GF_CLI extends GFAddOn { |
| 14 | + /** |
| 15 | + * Contains an instance of this class, if available. |
| 16 | + * |
| 17 | + * @since 1.0-beta-1 |
| 18 | + * @access private |
| 19 | + * @var object $_instance If available, contains an instance of this class |
| 20 | + */ |
| 21 | + private static $_instance = null; |
81 | 22 |
|
82 | | - /** |
83 | | - * Returns an instance of this class, and stores it in the $_instance property. |
84 | | - * |
85 | | - * @since 1.0-beta-1 |
86 | | - * @access public |
87 | | - * @static |
88 | | - * @return object $_instance An instance of the GF_CLI class |
89 | | - */ |
90 | | - public static function get_instance() { |
91 | | - if ( self::$_instance == null ) { |
92 | | - self::$_instance = new GF_CLI(); |
93 | | - } |
| 23 | + /** |
| 24 | + * Defines the version of the WP-CLI add-on. |
| 25 | + * |
| 26 | + * @since 1.0-beta-1 |
| 27 | + * @access protected |
| 28 | + * @var string $_version Contains the version, defined from cli.php |
| 29 | + */ |
| 30 | + protected $_version = GF_CLI_VERSION; |
| 31 | + /** |
| 32 | + * Defines the minimum Gravity Forms version required. |
| 33 | + * @since 1.0-beta-1 |
| 34 | + * @access protected |
| 35 | + * @var string $_min_gravityforms_version The minimum version required. |
| 36 | + */ |
| 37 | + protected $_min_gravityforms_version = GF_CLI_MIN_GF_VERSION; |
| 38 | + /** |
| 39 | + * Defines the plugin slug. |
| 40 | + * |
| 41 | + * @since 1.0-beta-1 |
| 42 | + * @access protected |
| 43 | + * @var string $_slug The slug used for this plugin. |
| 44 | + */ |
| 45 | + protected $_slug = 'gravityformscli'; |
| 46 | + /** |
| 47 | + * Defines the main plugin file. |
| 48 | + * |
| 49 | + * @since 1.0-beta-1 |
| 50 | + * @access protected |
| 51 | + * @var string $_path The path to the main plugin file, relative to the plugins folder. |
| 52 | + */ |
| 53 | + protected $_path = 'gravityformscli/cli.php'; |
| 54 | + /** |
| 55 | + * Defines the full path to this class file. |
| 56 | + * |
| 57 | + * @since 1.0-beta-1 |
| 58 | + * @access protected |
| 59 | + * @var string $_full_path The full path. |
| 60 | + */ |
| 61 | + protected $_full_path = __FILE__; |
| 62 | + /** |
| 63 | + * Defines the URL where this add-on can be found. |
| 64 | + * |
| 65 | + * @since 1.0-beta-1 |
| 66 | + * @access protected |
| 67 | + * @var string |
| 68 | + */ |
| 69 | + protected $_url = 'http://www.gravityforms.com'; |
| 70 | + /** |
| 71 | + * Defines the title of this add-on. |
| 72 | + * |
| 73 | + * @since 1.0-beta-1 |
| 74 | + * @access protected |
| 75 | + * @var string $_title The title of the add-on. |
| 76 | + */ |
| 77 | + protected $_title = 'Gravity Forms CLI Add-On'; |
| 78 | + /** |
| 79 | + * Defines the short title of the add-on. |
| 80 | + * |
| 81 | + * @since 1.0-beta-1 |
| 82 | + * @access protected |
| 83 | + * @var string $_short_title The short title. |
| 84 | + */ |
| 85 | + protected $_short_title = 'CLI'; |
94 | 86 |
|
95 | | - return self::$_instance; |
96 | | - } |
| 87 | + /** |
| 88 | + * Returns an instance of this class, and stores it in the $_instance property. |
| 89 | + * |
| 90 | + * @since 1.0-beta-1 |
| 91 | + * @access public |
| 92 | + * @static |
| 93 | + * @return object $_instance An instance of the GF_CLI class |
| 94 | + */ |
| 95 | + public static function get_instance() { |
| 96 | + if ( self::$_instance == null ) { |
| 97 | + self::$_instance = new GF_CLI(); |
| 98 | + } |
97 | 99 |
|
98 | | - private function __clone() { |
99 | | - } /* do nothing */ |
| 100 | + return self::$_instance; |
| 101 | + } |
| 102 | + |
| 103 | + private function __clone() { |
| 104 | + } /* do nothing */ |
100 | 105 |
|
| 106 | + } |
101 | 107 | } |
102 | 108 |
|
103 | 109 |
|
|
0 commit comments