Skip to content

Commit 8bc50c9

Browse files
committed
use wp auto update
1 parent 87a0e4a commit 8bc50c9

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ gulpfile.js export-ignore
66
package*.json export-ignore
77
/src export-ignore
88
wp-plugin-boilerplate.json export-ignore
9+
.wp-release-info.json export-ignore
10+
.editorconfig export-ignore

README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ ACF-Customizer
33

44
Bringing ACF Fields to the WordPress Customizer.
55

6-
- Supported ACF versions: 5.6 – 6.0
7-
- Tested with WordPress 4.9 – 5.6
8-
- Tested with PHP <= 8.0
9-
106
This plugin is currently in beta stadium.
117
Any Help testing and bugfixing is highly appreciated (and bundled with my premature apologies for late responses).
128

139
Installation
1410
------------
1511

16-
### Production (using Github Updater – recommended for Multisite)
17-
- Install [Andy Fragen's GitHub Updater](https://github.com/afragen/github-updater) first.
18-
- In WP Admin go to Settings / GitHub Updater / Install Plugin. Enter `mcguffin/acf-customizer` as a Plugin-URI.
12+
### Production
13+
- Head over to [releases](../../releases)
14+
- Download 'acf-customizer.zip'
15+
- Upload and activate it like any other WordPress plugin
16+
- AutoUpdate will run as long as the plugin is active
1917

2018
### Development
2119
- cd into your plugin directory
@@ -29,13 +27,6 @@ Installation
2927
composer require mcguffin/acf-customizer
3028
```
3129

32-
Installation
33-
------------
34-
- Head over to [releases](../../releases)
35-
- Download 'acf-customizer.zip'
36-
- Install and activate it like any other WordPress plugin
37-
- As long as the plugin is active, it will check for updates
38-
3930
Usage
4031
-----
4132
There is some documentation in the [wiki](../../wiki).

index.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
License: GPL3
1414
Text Domain: acf-customizer
1515
Domain Path: /languages/
16+
Update URI: https://github.com/mcguffin/acf-customizer/raw/main/.wp-release-info.json
1617
*/
1718

1819
/* Copyright 2018 Jörn Lund
@@ -41,3 +42,19 @@
4142
require_once dirname(__FILE__) . '/include/autoload.php';
4243

4344
Core\Core::instance( __FILE__ );
45+
46+
// Enable WP auto update
47+
add_filter( 'update_plugins_github.com', function( $update, $plugin_data, $plugin_file, $locales ) {
48+
49+
if ( ! preg_match( "@{$plugin_file}$@", __FILE__ ) ) { // not our plugin
50+
return $update;
51+
}
52+
53+
$response = wp_remote_get( $plugin_data['UpdateURI'] );
54+
55+
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) > 200 ) { // response error
56+
return $update;
57+
}
58+
59+
return json_decode( wp_remote_retrieve_body( $response ), true, 512 );
60+
}, 10, 4 );

0 commit comments

Comments
 (0)