Skip to content

Commit 12c47f6

Browse files
authored
Merge pull request #773 from udx/develop-alexey
Release 4.1.2
2 parents 0871da6 + d118dd5 commit 12c47f6

28 files changed

+254
-1631
lines changed

changelog.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
== Changelog ==
2+
= 4.1.2 =
3+
* ENHANCEMENT - added `REST API Endpoint` setting, which useful when WordPress dashboard and frontend website utilize different domain names.
4+
* ENHANCEMENT - extended `Status Info` with the information to help diagnose REST API or AJAX issues.
5+
* COMPATIBILITY - SiteOrigin Widgets Bundle Compatibility replaced with [WP-Stateless - SiteOrigin Widgets Bundle Addon](https://wordpress.org/plugins/wp-stateless-siteorigin-widgets-bundle-addon/).
6+
* COMPATIBILITY - WPForms Compatibility replaced with [WP-Stateless - WPForms Addon](https://wordpress.org/plugins/wp-stateless-wpforms-addon/).
7+
* COMPATIBILITY - Easy Digital Downloads Compatibility replaced with [WP-Stateless - Easy Digital Downloads Addon](https://wordpress.org/plugins/wp-stateless-easy-digital-downloads-addon/).
8+
* COMPATIBILITY - LiteSpeed Cache Compatibility replaced with [WP-Stateless - LiteSpeed Cache Addon](https://wordpress.org/plugins/wp-stateless-litespeed-cache-addon/).
9+
* COMPATIBILITY - BuddyPress Compatibility replaced with [WP-Stateless - BuddyPress Addon](https://wordpress.org/support/plugin/wp-stateless-buddypress-addon/).
10+
* FIX: remove PHP warning on `Status` settings tab.
11+
* FIX: database updates to resolve conflicts with Polylang Pro compatibility.
12+
213
= 4.1.1 =
314
* FIX - cache issues during Data Optimization.
415

changes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
#### 4.1.2
2+
* ENHANCEMENT - added `REST API Endpoint` setting, which useful when WordPress dashboard and frontend website utilize different domain names.
3+
* ENHANCEMENT - extended `Status Info` with the information to help diagnose REST API or AJAX issues.
4+
* COMPATIBILITY - SiteOrigin Widgets Bundle Compatibility replaced with [WP-Stateless - SiteOrigin Widgets Bundle Addon](https://wordpress.org/plugins/wp-stateless-siteorigin-widgets-bundle-addon/).
5+
* COMPATIBILITY - WPForms Compatibility replaced with [WP-Stateless - WPForms Addon](https://wordpress.org/plugins/wp-stateless-wpforms-addon/).
6+
* COMPATIBILITY - Easy Digital Downloads Compatibility replaced with [WP-Stateless - Easy Digital Downloads Addon](https://wordpress.org/plugins/wp-stateless-easy-digital-downloads-addon/).
7+
* COMPATIBILITY - LiteSpeed Cache Compatibility replaced with [WP-Stateless - LiteSpeed Cache Addon](https://wordpress.org/plugins/wp-stateless-litespeed-cache-addon/).
8+
* COMPATIBILITY - BuddyPress Compatibility replaced with [WP-Stateless - BuddyPress Addon](https://wordpress.org/support/plugin/wp-stateless-buddypress-addon/).
9+
* FIX: PHP warning on `Status` settings tab.
10+
* FIX: database updates to resolve conflicts with Polylang Pro compatibility.
11+
112
#### 4.1.1
213
* FIX - cache issues during Data Optimization.
314

composer.lock

Lines changed: 7 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/classes/class-bootstrap.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public function init() {
140140
// Register meta boxes and fields for media modal page
141141
add_filter('attachment_fields_to_edit', array($this, 'attachment_modal_meta_box_callback'), 11, 2);
142142

143+
// Get the REST API root
144+
add_filter('wp_stateless_rest_api_root', array($this, 'get_rest_api_root'));
145+
143146
/**
144147
* Init hook
145148
*/
@@ -1265,7 +1268,12 @@ public function admin_init() {
12651268
wp_localize_script('wp-stateless', 'stateless_l10n', $this->get_l10n_data());
12661269
wp_localize_script('wp-stateless', 'wp_stateless_configs', array(
12671270
'WP_DEBUG' => defined('WP_DEBUG') ? WP_DEBUG : false,
1268-
'REST_API_TOKEN' => Utility::generate_jwt_token(['user_id' => get_current_user_id()], DAY_IN_SECONDS)
1271+
'REST_API_TOKEN' => Utility::generate_jwt_token(['user_id' => get_current_user_id()], DAY_IN_SECONDS),
1272+
'api_root' => apply_filters( 'wp_stateless_rest_api_root', '' ),
1273+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
1274+
'stateless_check_ajax_nonce' => wp_create_nonce('stateless_check_ajax'),
1275+
'text_ok' => __('Ok', ud_get_stateless_media()->domain),
1276+
'text_fail' => __('Fail', ud_get_stateless_media()->domain),
12691277
));
12701278

12711279
$settings = ud_get_stateless_media()->get('sm');
@@ -1282,6 +1290,7 @@ public function admin_init() {
12821290
wp_localize_script('wp-stateless-batch', 'wp_stateless_batch', array(
12831291
'REST_API_TOKEN' => Utility::generate_jwt_token(['user_id' => get_current_user_id()], DAY_IN_SECONDS),
12841292
'is_running' => BatchTaskManager::instance()->is_running(),
1293+
'api_root' => apply_filters( 'wp_stateless_rest_api_root', '' ),
12851294
));
12861295
}
12871296

@@ -2079,6 +2088,26 @@ public function is_mode($mode) {
20792088
public function get_default_cache_control() {
20802089
return Settings::DEFAULT_CACHE_CONTROL;
20812090
}
2091+
2092+
/**
2093+
* Override REST API root for headless CMS
2094+
*
2095+
* @return string
2096+
*/
2097+
public function get_rest_api_root($rest_api_root) {
2098+
$rest_api_root = sanitize_url( get_rest_url() );
2099+
$rest_api_root .= 'wp-stateless/v1/';
2100+
2101+
if ( $this->get('sm.use_api_siteurl') == 'WP_SITEURL' ) {
2102+
$home = get_home_url();
2103+
$site = get_site_url();
2104+
2105+
return str_replace( $home, $site, $rest_api_root );
2106+
}
2107+
2108+
2109+
return $rest_api_root;
2110+
}
20822111
}
20832112
}
20842113
}

lib/classes/class-db.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DB {
1515
use Singleton;
1616

1717
const DB_VERSION_KEY = 'sm_db_version';
18-
const DB_VERSION = '1.1';
18+
const DB_VERSION = '1.2';
1919
const FULL_SIZE = '__full';
2020

2121
/**
@@ -173,7 +173,8 @@ public function create_db() {
173173
`status` varchar(10) NULL DEFAULT NULL,
174174
PRIMARY KEY (`id`),
175175
KEY post_id (post_id),
176-
UNIQUE KEY `name` (`name`(191))
176+
KEY `name` (`name`(191)),
177+
UNIQUE KEY post_id_name (post_id, `name`(150))
177178
) $charset_collate;
178179
179180
CREATE TABLE $this->file_sizes (

lib/classes/class-module.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ public function __construct() {
2525
add_filter('wp_stateless_compatibility_tab_visible', array($this, 'compatibility_tab_visible'), 10, 1);
2626
add_action('wp_stateless_compatibility_tab_content', array($this, 'tab_content'));
2727

28-
/**
29-
* Support for BuddyPress
30-
*/
31-
new BuddyPress();
32-
33-
/**
34-
* Support for Easy Digital Downloads
35-
*/
36-
new EDDDownloadMethod();
37-
3828
/**
3929
* Support for Ewww Image Optimizer
4030
*/
@@ -50,11 +40,6 @@ public function __construct() {
5040
*/
5141
new LearnDash();
5242

53-
/**
54-
* Support for LiteSpeed Cache
55-
*/
56-
new LSCacheWP();
57-
5843
/**
5944
* Support for Polylang Pro
6045
*/
@@ -70,11 +55,6 @@ public function __construct() {
7055
*/
7156
new SimpleLocalAvatars();
7257

73-
/**
74-
* Support for SiteOrigin Widgets Bundle
75-
*/
76-
new SOWidgetCSS();
77-
7858
/**
7959
* Support for The Events Calendar
8060
*/
@@ -90,11 +70,6 @@ public function __construct() {
9070
*/
9171
new WPBakeryPageBuilder();
9272

93-
/**
94-
* Support for WPForms
95-
*/
96-
new WPForms();
97-
9873
/**
9974
* Support for Smush
10075
*/

lib/classes/class-settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ final class Settings extends \UDX\Settings {
5656
'status_email_type' => array('', 'true'),
5757
'status_email_address' => array('', ''),
5858
'use_postmeta' => array('WP_STATELESS_POSTMETA', ['false', '']),
59+
'use_api_siteurl' => array('WP_STATELESS_API_SITEURL', ['WP_HOME', '']),
5960
);
6061

6162
private $network_only_settings = array(

lib/classes/class-upgrader.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ public static function upgrade_db($new_version, $old_version) {
257257
Helper::log($e->getMessage());
258258
}
259259
}
260+
261+
if ( !empty($old_version) && version_compare($old_version, '1.2', '<') ) {
262+
try {
263+
// Remove UNIQUE indexes, which will be recreated later using dbDelta as non-unique
264+
$wpdb->query('ALTER TABLE ' . ud_stateless_db()->files . ' DROP INDEX name');
265+
266+
} catch (\Throwable $e) {
267+
Helper::log($e->getMessage());
268+
}
269+
}
260270
}
261271
}
262272
}

0 commit comments

Comments
 (0)