Skip to content

Commit fd052da

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents ee50a3d + 1b15034 commit fd052da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1503
-620
lines changed

extendify-sdk/app/Admin.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,27 +128,19 @@ public function addScopedScriptsAndStyles()
128128
'sitesettings' => json_decode(SiteSettings::data()),
129129
'sdk_partner' => \esc_attr(APP::$sdkPartner),
130130
'asset_path' => \esc_url(EXTENDIFY_URL . 'public/assets'),
131+
'standalone' => \esc_attr(APP::$standalone),
131132
]
132133
);
133134
\wp_enqueue_script(App::$slug . '-scripts');
134135

135-
\wp_set_script_translations(App::$slug . '-scripts', App::$textDomain);
136+
\wp_set_script_translations(App::$slug . '-scripts', 'extendify');
136137

137-
\wp_enqueue_style(
138-
App::$slug,
139-
EXTENDIFY_BASE_URL . 'public/build/extendify.css',
140-
[],
141-
$version,
142-
'all'
143-
);
144-
145-
\wp_enqueue_style(
146-
App::$slug . '-utilities',
147-
EXTENDIFY_BASE_URL . 'public/build/extendify-utilities.css',
148-
[],
149-
$version,
150-
'all'
151-
);
138+
// Inline the library styles to keep them out of the iframe live preview.
139+
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
140+
$css = file_get_contents(EXTENDIFY_PATH . 'public/build/extendify.css');
141+
\wp_register_style(App::$slug, false, [], $version);
142+
\wp_enqueue_style(App::$slug);
143+
\wp_add_inline_style(App::$slug, $css);
152144
}
153145

154146
/**
@@ -158,6 +150,10 @@ public function addScopedScriptsAndStyles()
158150
*/
159151
private function isAdmin()
160152
{
153+
if (\is_multisite()) {
154+
return \is_super_admin();
155+
}
156+
161157
return in_array('administrator', \wp_get_current_user()->roles, true);
162158
}
163159

extendify-sdk/app/App.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class App
4242
public static $apiVersion = 'v1';
4343

4444
/**
45-
* Plugin text domain
45+
* Whether this is the standalone plugin
4646
*
47-
* @var string
47+
* @var boolean
4848
*/
49-
public static $textDomain = '';
49+
public static $standalone;
5050

5151
/**
5252
* Plugin environment
@@ -60,7 +60,7 @@ class App
6060
*
6161
* @var string
6262
*/
63-
public static $sdkPartner = '';
63+
public static $sdkPartner = 'standalone';
6464

6565
/**
6666
* Host plugin
@@ -83,10 +83,8 @@ class App
8383
*/
8484
public function __construct()
8585
{
86-
// Set the "partner" plugin/theme here with a fallback to support the previous plugin implementation.
87-
self::$sdkPartner = isset($GLOBALS['extendify_sdk_partner']) ? $GLOBALS['extendify_sdk_partner'] : '';
88-
if (!self::$sdkPartner && isset($GLOBALS['extendifySdkSourcePlugin'])) {
89-
self::$sdkPartner = $GLOBALS['extendifySdkSourcePlugin'];
86+
if (isset($GLOBALS['extendify_sdk_partner'])) {
87+
self::$sdkPartner = $GLOBALS['extendify_sdk_partner'];
9088
}
9189

9290
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
@@ -103,7 +101,7 @@ public function __construct()
103101
$isDev = is_readable(EXTENDIFY_PATH . 'node_modules') || is_readable(EXTENDIFY_PATH . '.devbuild');
104102
self::$environment = $isDev ? 'DEVELOPMENT' : 'PRODUCTION';
105103

106-
self::$textDomain = Plugin::getPluginInfo('TextDomain', self::$slug);
104+
self::$standalone = self::$sdkPartner === 'standalone';
107105

108106
// Add the config.
109107
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents

extendify-sdk/app/Controllers/PluginController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,24 @@ public static function active()
4444
/**
4545
* Install plugins
4646
*
47+
* @param \WP_REST_Request $request - The request.
4748
* @return bool|WP_Error
4849
*/
49-
public static function install()
50+
public static function install($request)
5051
{
5152
if (!\current_user_can('activate_plugins')) {
5253
return new \WP_Error('not_allowed', \__('You are not allowed to activate plugins on this site.', 'extendify'));
5354
}
5455

56+
$requiredPlugins = json_decode($request->get_param('plugins'), true);
57+
foreach ($requiredPlugins as $plugin) {
58+
$status = Plugin::install_and_activate_plugin($plugin);
59+
if (\is_wp_error($status)) {
60+
// Return first error encountered.
61+
return $status;
62+
}
63+
}
64+
5565
return true;
5666
}
5767
}

extendify-sdk/app/Frontend.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,5 @@ function () {
5858
*/
5959
public function addStylesheets()
6060
{
61-
$version = App::$environment === 'PRODUCTION' ? App::$version : uniqid();
62-
\wp_enqueue_style(
63-
App::$slug . '-utilities',
64-
EXTENDIFY_BASE_URL . 'public/build/extendify-utilities.css',
65-
[],
66-
$version,
67-
'all'
68-
);
6961
}
7062
}

0 commit comments

Comments
 (0)