-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeveloper-helper.php
70 lines (52 loc) · 2.03 KB
/
developer-helper.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
<?php
/*
* Plugin Name: Demo plugin creator
* Version: 5.4
* Plugin URI: https://svitsoft.com/
* Description: developer plugin.
* Author: Svitsoft
* Author URI: https://svitsoft.com/
*/
if ( !defined( 'ABSPATH' ) ) exit;
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
use HaydenPierce\ClassFinder\ClassFinder;
class DeveloperHelper {
static $plugin_dir;
private static $basedir;
private static $namespace = 'DeveloperHelper';
public function __construct() {
self::$plugin_dir = plugin_dir_path( __FILE__ );
self::$basedir = plugin_dir_path( __FILE__ ) . '/inc/classes/';
self::cc_autoload();
}
private static function cc_autoload() {
foreach (glob(self::$basedir . '*.*') as $file) {
include_once ( self::$basedir . basename($file) );
}
$namespaces = self::getDefinedNamespaces();
foreach ($namespaces as $namespace => $path) {
$clear = str_replace('\\', '', $namespace);
ClassFinder::setAppRoot( self::$plugin_dir );
$level = error_reporting(E_ERROR);
$classes = ClassFinder::getClassesInNamespace( $clear );
error_reporting($level);
foreach ( $classes as $class ) {
new $class();
}
}
}
private static function getDefinedNamespaces()
{
$composerJsonPath = dirname( __FILE__ ) . '/composer.json';
$composerConfig = json_decode(file_get_contents($composerJsonPath));
//Apparently PHP doesn't like hyphens, so we use variable variables instead.
$psr4 = "psr-4";
return (array) $composerConfig->autoload->$psr4;
}
}
new DeveloperHelper();
require 'vendor/updater/plugin-update-checker.php';
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker('https://github.com/gerasart/developer-helper/',__FILE__,'developer-helper');
$myUpdateChecker->setAuthentication('a283aeca2b507dd9d43b8e5b0cf8f6a3e8be50ad');
$myUpdateChecker->setBranch('master');
$myUpdateChecker->getVcsApi()->enableReleaseAssets();