PluginProbe
Extendify / 0.5.0
Extendify v0.5.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / app / App.php

App.php in Extendify 0.5.0, at app/App.php

112 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The App details file
4 */
5
6 namespace Extendify\Library;
7
8 use Extendify\Library\Plugin;
9
10 /**
11 * Controller for handling various app data
12 */
13 class App
14 {
15
16 /**
17 * Plugin name
18 *
19 * @var string
20 */
21 public static $name = '';
22
23 /**
24 * Plugin slug
25 *
26 * @var string
27 */
28 public static $slug = '';
29
30 /**
31 * Plugin version
32 *
33 * @var string
34 */
35 public static $version = '';
36
37 /**
38 * Plugin API REST version
39 *
40 * @var string
41 */
42 public static $apiVersion = 'v1';
43
44 /**
45 * Whether this is the standalone plugin
46 *
47 * @var boolean
48 */
49 public static $standalone;
50
51 /**
52 * Plugin environment
53 *
54 * @var string
55 */
56 public static $environment = '';
57
58 /**
59 * The partner plugin/theme
60 *
61 * @var string
62 */
63 public static $sdkPartner = 'standalone';
64
65 /**
66 * Host plugin
67 *
68 * @var string
69 */
70 public static $requiredCapability = 'upload_files';
71
72 /**
73 * Plugin config
74 *
75 * @var array
76 */
77 public static $config = [];
78
79 /**
80 * Process the readme file to get version and name
81 *
82 * @return void
83 */
84 public function __construct()
85 {
86 if (isset($GLOBALS['extendify_sdk_partner']) && $GLOBALS['extendify_sdk_partner']) {
87 self::$sdkPartner = $GLOBALS['extendify_sdk_partner'];
88 }
89
90 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
91 $readme = file_get_contents(dirname(__DIR__) . '/readme.txt');
92
93 preg_match('/=== (.+) ===/', $readme, $matches);
94 self::$name = $matches[1];
95 self::$slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', self::$name), '-'));
96
97 preg_match('/Stable tag: ([0-9.:]+)/', $readme, $matches);
98 self::$version = $matches[1];
99
100 // An easy way to check if we are in dev mode is to look for a dev specific file.
101 $isDev = is_readable(EXTENDIFY_PATH . 'node_modules') || is_readable(EXTENDIFY_PATH . '.devbuild');
102 self::$environment = $isDev ? 'DEVELOPMENT' : 'PRODUCTION';
103
104 self::$standalone = self::$sdkPartner === 'standalone';
105
106 // Add the config.
107 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
108 $config = file_get_contents(dirname(__DIR__) . '/config.json');
109 self::$config = json_decode($config, true);
110 }
111 }
112