Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add library update #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,107 changes: 564 additions & 543 deletions class-redux-framework-plugin.php

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion extendify-sdk/.github/workflows/force-production-on-main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build production assets
name: Build production and deploy
on:
push:
branches:
Expand Down Expand Up @@ -53,9 +53,11 @@ jobs:
npm run build
env:
CI: true

- name: Increment version number
run: |
perl -i -pe 's/(Stable tag: )([\d.]+)$/$1.($2+.1)/e' readme.txt
perl -i -pe 's/(Version: )([\d.]+)$/$1.($2+.1)/e' extendify-sdk.php
- name: Commit dist folder if needed #it fails if nothing has changed so we allow an error
run: git commit -am 'Build produciton assets'
continue-on-error: true
Expand All @@ -64,3 +66,9 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main

- name: Deploy to library.extendify.com
uses: fjogeleit/http-request-action@master
with:
url: ${{ secrets.DEPLOY_WEBHOOK }}
method: 'POST'
1 change: 1 addition & 0 deletions extendify-sdk/.node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.18.1
1 change: 1 addition & 0 deletions extendify-sdk/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
44 changes: 42 additions & 2 deletions extendify-sdk/app/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Extendify\ExtendifySdk\App;
use Extendify\ExtendifySdk\User;
use Extendify\ExtendifySdk\SiteSettings;

/**
* This class handles any file loading for the admin area.
Expand Down Expand Up @@ -54,6 +55,10 @@ function ($hook) {
return;
}

if (!$this->isLibraryEnabled()) {
return;
}

$this->addScopedScriptsAndStyles();
}
);
Expand Down Expand Up @@ -87,7 +92,6 @@ public function addScopedScriptsAndStyles()
App::$slug . '-scripts',
EXTENDIFYSDK_BASE_URL . 'public/build/extendify-sdk.js',
[
'wp-api',
'wp-i18n',
'wp-components',
'wp-element',
Expand All @@ -103,7 +107,8 @@ public function addScopedScriptsAndStyles()
'root' => \esc_url_raw(rest_url(APP::$slug . '/' . APP::$apiVersion)),
'nonce' => \wp_create_nonce('wp_rest'),
'user' => json_decode(User::data('extendifysdk_user_data'), true),
'source' => \esc_attr(APP::$sourcePlugin),
'sitesettings' => json_decode(SiteSettings::data()),
'sdk_partner' => \esc_attr(APP::$sdkPartner),
]
);
\wp_enqueue_script(App::$slug . '-scripts');
Expand All @@ -117,5 +122,40 @@ public function addScopedScriptsAndStyles()
$version,
'all'
);

\wp_enqueue_style(
App::$slug . '-utility-classes',
EXTENDIFYSDK_BASE_URL . 'public/build/extendify-utilities.css',
[],
$version,
'all'
);
}

/**
* Check if current user is Admin
*
* @return Boolean
*/
private function isAdmin()
{
return in_array('administrator', \wp_get_current_user()->roles, true);
}

/**
* Check if scripts should add
*
* @return Boolean
*/
public function isLibraryEnabled()
{
$settings = json_decode(SiteSettings::data());

// If it's disabled, only show it for admins.
if (isset($settings->state) && (isset($settings->state->enabled)) && !$settings->state->enabled) {
return $this->isAdmin();
}

return true;
}
}
10 changes: 6 additions & 4 deletions extendify-sdk/app/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class App
public static $environment = '';

/**
* Host plugin
* The partner plugin/theme
*
* @var string
*/
public static $sourcePlugin = 'Not set';
public static $sdkPartner = '';

/**
* Host plugin
Expand All @@ -83,8 +83,10 @@ class App
*/
public function __construct()
{
if (isset($GLOBALS['extendifySdkSourcePlugin'])) {
self::$sourcePlugin = $GLOBALS['extendifySdkSourcePlugin'];
// Set the "partner" plugin/theme here with a fallback to support the previous plugin implementation.
self::$sdkPartner = isset($GLOBALS['extendify_sdk_partner']) ? $GLOBALS['extendify_sdk_partner'] : '';
if (!self::$sdkPartner && isset($GLOBALS['extendifySdkSourcePlugin'])) {
self::$sdkPartner = $GLOBALS['extendifySdkSourcePlugin'];
}

// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
Expand Down
42 changes: 42 additions & 0 deletions extendify-sdk/app/Controllers/SiteSettingsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Controls User info
*/

namespace Extendify\ExtendifySdk\Controllers;

use Extendify\ExtendifySdk\SiteSettings;

if (!defined('ABSPATH')) {
die('No direct access.');
}

/**
* The controller for managing Extendify SiteSettings.
*/
class SiteSettingsController
{

/**
* Return Current SiteSettings meta data
*
* @return array
*/
public static function show()
{
return new \WP_REST_Response(SiteSettings::data());
}

/**
* Persist the data
*
* @param \WP_REST_Request $request - The request.
* @return array
*/
public static function store($request)
{
$settingsData = json_decode($request->get_param('data'), true);
\update_option(SiteSettings::key(), $settingsData, true);
return new \WP_REST_Response(SiteSettings::data());
}
}
3 changes: 1 addition & 2 deletions extendify-sdk/app/Controllers/TaxonomyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
*/
class TaxonomyController
{

/**
* Return all taxonomies
*
* @return WP_REST_Response|WP_Error
*/
public static function index()
{
$response = Http::get('/airtable-taxonomies', []);
$response = Http::get('/airtable-taxonomies-simple', []);
return new \WP_REST_Response($response);
}
}
70 changes: 70 additions & 0 deletions extendify-sdk/app/Frontend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Manage any frontend related tasks here.
*/

namespace Extendify\ExtendifySdk;

use Extendify\ExtendifySdk\App;

/**
* This class handles any file loading for the frontend of the site.
*/
class Frontend
{

/**
* The instance
*
* @var $instance
*/
public static $instance = null;

/**
* Adds various actions to set up the page
*
* @return self|void
*/
public function __construct()
{
if (self::$instance) {
return self::$instance;
}

self::$instance = $this;
$this->loadScripts();
}

/**
* Adds scripts and styles to every page is enabled
*
* @return void
*/
public function loadScripts()
{
\add_action(
'wp_enqueue_scripts',
function () {
// TODO: Determine a way to conditionally load assets (https://github.com/extendify/company-product/issues/72).
$this->addStylesheets();
}
);
}

/**
* Adds stylesheets as needed
*
* @return void
*/
public function addStylesheets()
{
$version = App::$environment === 'PRODUCTION' ? App::$version : uniqid();
\wp_enqueue_style(
App::$slug . '-utility-classes',
EXTENDIFYSDK_BASE_URL . 'public/build/extendify-utilities.css',
[],
$version,
'all'
);
}
}
5 changes: 4 additions & 1 deletion extendify-sdk/app/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ public function __construct($request)
$this->baseUrl = $request->get_header('x_extendify_local_mode') !== 'false' ? App::$config['api']['local'] : $this->baseUrl;

$this->data = [
'wp_language' => \get_locale(),
'wp_theme' => \get_option('template'),
'mode' => App::$environment,
'uuid' => User::data('uuid'),
'sdk_version' => App::$version,
'wp_plugins' => $request->get_method() === 'POST' ? array_keys(\get_plugins()) : [],
'wp_active_plugins' => $request->get_method() === 'POST' ? \get_option('active_plugins') : [],
'sdk_partner' => App::$sdkPartner,
];

$this->headers = [
Expand Down
Loading