-
Notifications
You must be signed in to change notification settings - Fork 12
/
fewbricks.php
65 lines (46 loc) · 1.76 KB
/
fewbricks.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
<?php
/*
Plugin Name: Fewbricks
Plugin URI: https://github.com/folbert/fewbricks
Description: A module extension to Advanced Custom Fields
Author: Björn Folbert
Version: 2.0.1
Author URI: https://folbert.com
License: GPLv3
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
if(file_exists(__DIR__.'/vendor/autoload.php')) {
require_once __DIR__.'/vendor/autoload.php';
} else {
// Lets use a custom autoload regardless of if Fewbricks has been installed using Composer or not.
spl_autoload_register(function ($class) {
$namespaceParts = explode('\\', $class);
// Make sure that we are dealing with something in the Fewbricks namespace
if (count($namespaceParts) > 1
&& $namespaceParts[0] === 'Fewbricks'
) {
// First item will always be "Fewbricks" and we don't need that when building the path
// Yes, by not checking of the file exists, we do get ugly error messages but we save some execution time.
/** @noinspection PhpIncludeInspection */
include __DIR__ . '/src/' . implode('/', array_slice($namespaceParts, 1)) . '.php';
}
});
}
add_action('acf/init', function () {
\Fewbricks\Fewbricks::run();
});
if(!function_exists('fewbricks_check_version')) {
add_action('init', 'fewbricks_check_version');
function fewbricks_check_version()
{
require_once 'src/WP_AutoUpdate.php';
// set auto-update params
$plugin_current_version = \Fewbricks\Fewbricks::FEWBRICKS_VERSION;
$plugin_remote_path = 'https://version.fewbricks2.folbert.com/version-info.php';
$plugin_slug = plugin_basename(__FILE__);
new WP_AutoUpdate($plugin_current_version, $plugin_remote_path, $plugin_slug);
}
}