|
11 | 11 | GFForms::include_feed_addon_framework(); |
12 | 12 |
|
13 | 13 | class GWiz_GF_Code_Chest extends GFFeedAddOn { |
14 | | - /** |
15 | | - * @var Inc2734\WP_GitHub_Plugin_Updater\Bootstrap The updater instance. |
16 | | - */ |
17 | | - public $updater; |
18 | | - |
19 | 14 | /** |
20 | 15 | * @var null|GWiz_GF_Code_Chest |
21 | 16 | */ |
@@ -109,98 +104,18 @@ public function minimum_requirements() { |
109 | 104 | } |
110 | 105 |
|
111 | 106 | /** |
112 | | - * Load dependencies and initialize auto-updater |
| 107 | + * Load dependencies |
113 | 108 | */ |
114 | 109 | public function pre_init() { |
115 | 110 | parent::pre_init(); |
116 | 111 |
|
117 | | - $this->init_auto_updater(); |
118 | | - |
119 | 112 | /** |
120 | 113 | * Hooks for exporting and importing feeds with forms. |
121 | 114 | */ |
122 | 115 | add_filter( 'gform_export_form', array( $this, 'export_feeds_with_form' ) ); |
123 | 116 | add_action( 'gform_forms_post_import', array( $this, 'import_feeds_with_form' ) ); |
124 | 117 | } |
125 | 118 |
|
126 | | - /** |
127 | | - * Initialize the auto-updater. |
128 | | - */ |
129 | | - public function init_auto_updater() { |
130 | | - // Initialize GitHub auto-updater |
131 | | - add_filter( |
132 | | - 'inc2734_github_plugin_updater_plugins_api_gravitywiz/gf-code-chest', |
133 | | - array( $this, 'filter_auto_updater_response' ), 10, 2 |
134 | | - ); |
135 | | - |
136 | | - $this->updater = new Inc2734\WP_GitHub_Plugin_Updater\Bootstrap( |
137 | | - plugin_basename( plugin_dir_path( __FILE__ ) . 'gf-code-chest.php' ), |
138 | | - 'gravitywiz', |
139 | | - 'gf-code-chest', |
140 | | - array( |
141 | | - 'description_url' => 'https://raw.githubusercontent.com/gravitywiz/gf-code-chest/main/readme.md', |
142 | | - 'changelog_url' => 'https://raw.githubusercontent.com/gravitywiz/gf-code-chest/main/changelog.txt', |
143 | | - 'icons' => array( |
144 | | - 'svg' => 'https://raw.githubusercontent.com/gravitywiz/gf-code-chest/main/assets/images/icon.svg', |
145 | | - '1x' => 'https://raw.githubusercontent.com/gravitywiz/gf-code-chest/main/assets/images/icon-1x.png', |
146 | | - '2x' => 'https://raw.githubusercontent.com/gravitywiz/gf-code-chest/main/assets/images/icon-2x.png', |
147 | | - ), |
148 | | - 'banners' => array( |
149 | | - 'low' => 'https://raw.githubusercontent.com/gravitywiz/gf-code-chest/main/assets/images/banner-low.png', |
150 | | - 'high' => 'https://raw.githubusercontent.com/gravitywiz/gf-code-chest/main/assets/images/banner-high.png', |
151 | | - ), |
152 | | - 'requires_php' => '5.6.0', |
153 | | - ) |
154 | | - ); |
155 | | - } |
156 | | - |
157 | | - /** |
158 | | - * Filter the GitHub auto-updater response to remove sections we don't need and update various fields. |
159 | | - * |
160 | | - * @param stdClass $obj |
161 | | - * @param stdClass $response |
162 | | - * |
163 | | - * @return stdClass |
164 | | - */ |
165 | | - public function filter_auto_updater_response( $obj, $response ) { |
166 | | - $remove_sections = array( |
167 | | - 'installation', |
168 | | - 'faq', |
169 | | - 'screenshots', |
170 | | - 'reviews', |
171 | | - 'other_notes', |
172 | | - ); |
173 | | - |
174 | | - foreach ( $remove_sections as $section ) { |
175 | | - if ( isset( $obj->sections[ $section ] ) ) { |
176 | | - unset( $obj->sections[ $section ] ); |
177 | | - } |
178 | | - } |
179 | | - |
180 | | - if ( isset( $obj->active_installs ) ) { |
181 | | - unset( $obj->active_installs ); |
182 | | - } |
183 | | - |
184 | | - $obj->homepage = 'https://gravitywiz.com/gf-code-chest/'; |
185 | | - $obj->author = '<a href="https://gravitywiz.com/" target="_blank">Gravity Wiz</a>'; |
186 | | - |
187 | | - $parsedown = new Parsedown(); |
188 | | - $changelog = trim( $obj->sections['changelog'] ); |
189 | | - |
190 | | - // Remove the "Changelog" h1. |
191 | | - $changelog = preg_replace( '/^# Changelog/m', '', $changelog ); |
192 | | - |
193 | | - // Remove the tab before the list item so it's not treated as code. |
194 | | - $changelog = preg_replace( '/^\t- /m', '- ', $changelog ); |
195 | | - |
196 | | - // Convert h2 to h4 to avoid weird styles that add a lot of whitespace. |
197 | | - $changelog = preg_replace( '/^## /m', '#### ', $changelog ); |
198 | | - |
199 | | - $obj->sections['changelog'] = $parsedown->text( $changelog ); |
200 | | - |
201 | | - return $obj; |
202 | | - } |
203 | | - |
204 | 119 | /** |
205 | 120 | * Initialize the add-on. Similar to construct, but done later. |
206 | 121 | * |
|
0 commit comments