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

Latest => v4.0 #775

Merged
merged 5 commits into from
Dec 3, 2024
Merged
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
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
== Changelog ==
= 4.1.2 =
* ENHANCEMENT - added `REST API Endpoint` setting, which useful when WordPress dashboard and frontend website utilize different domain names.
* ENHANCEMENT - extended `Status Info` with the information to help diagnose REST API or AJAX issues.
* COMPATIBILITY - SiteOrigin Widgets Bundle Compatibility replaced with [WP-Stateless - SiteOrigin Widgets Bundle Addon](https://wordpress.org/plugins/wp-stateless-siteorigin-widgets-bundle-addon/).
* COMPATIBILITY - WPForms Compatibility replaced with [WP-Stateless - WPForms Addon](https://wordpress.org/plugins/wp-stateless-wpforms-addon/).
* COMPATIBILITY - Easy Digital Downloads Compatibility replaced with [WP-Stateless - Easy Digital Downloads Addon](https://wordpress.org/plugins/wp-stateless-easy-digital-downloads-addon/).
* COMPATIBILITY - LiteSpeed Cache Compatibility replaced with [WP-Stateless - LiteSpeed Cache Addon](https://wordpress.org/plugins/wp-stateless-litespeed-cache-addon/).
* COMPATIBILITY - BuddyPress Compatibility replaced with [WP-Stateless - BuddyPress Addon](https://wordpress.org/support/plugin/wp-stateless-buddypress-addon/).
* FIX: remove PHP warning on `Status` settings tab.
* FIX: database updates to resolve conflicts with Polylang Pro compatibility.

= 4.1.1 =
* FIX - cache issues during Data Optimization.

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

#### 4.1.1
* FIX - cache issues during Data Optimization.

Expand Down
74 changes: 7 additions & 67 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 30 additions & 1 deletion lib/classes/class-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public function init() {
// Register meta boxes and fields for media modal page
add_filter('attachment_fields_to_edit', array($this, 'attachment_modal_meta_box_callback'), 11, 2);

// Get the REST API root
add_filter('wp_stateless_rest_api_root', array($this, 'get_rest_api_root'));

/**
* Init hook
*/
Expand Down Expand Up @@ -1265,7 +1268,12 @@ public function admin_init() {
wp_localize_script('wp-stateless', 'stateless_l10n', $this->get_l10n_data());
wp_localize_script('wp-stateless', 'wp_stateless_configs', array(
'WP_DEBUG' => defined('WP_DEBUG') ? WP_DEBUG : false,
'REST_API_TOKEN' => Utility::generate_jwt_token(['user_id' => get_current_user_id()], DAY_IN_SECONDS)
'REST_API_TOKEN' => Utility::generate_jwt_token(['user_id' => get_current_user_id()], DAY_IN_SECONDS),
'api_root' => apply_filters( 'wp_stateless_rest_api_root', '' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'stateless_check_ajax_nonce' => wp_create_nonce('stateless_check_ajax'),
'text_ok' => __('Ok', ud_get_stateless_media()->domain),
'text_fail' => __('Fail', ud_get_stateless_media()->domain),
));

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

Expand Down Expand Up @@ -2079,6 +2088,26 @@ public function is_mode($mode) {
public function get_default_cache_control() {
return Settings::DEFAULT_CACHE_CONTROL;
}

/**
* Override REST API root for headless CMS
*
* @return string
*/
public function get_rest_api_root($rest_api_root) {
$rest_api_root = sanitize_url( get_rest_url() );
$rest_api_root .= 'wp-stateless/v1/';

if ( $this->get('sm.use_api_siteurl') == 'WP_SITEURL' ) {
$home = get_home_url();
$site = get_site_url();

return str_replace( $home, $site, $rest_api_root );
}


return $rest_api_root;
}
}
}
}
5 changes: 3 additions & 2 deletions lib/classes/class-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DB {
use Singleton;

const DB_VERSION_KEY = 'sm_db_version';
const DB_VERSION = '1.1';
const DB_VERSION = '1.2';
const FULL_SIZE = '__full';

/**
Expand Down Expand Up @@ -173,7 +173,8 @@ public function create_db() {
`status` varchar(10) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY post_id (post_id),
UNIQUE KEY `name` (`name`(191))
KEY `name` (`name`(191)),
UNIQUE KEY post_id_name (post_id, `name`(150))
) $charset_collate;

CREATE TABLE $this->file_sizes (
Expand Down
25 changes: 0 additions & 25 deletions lib/classes/class-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ public function __construct() {
add_filter('wp_stateless_compatibility_tab_visible', array($this, 'compatibility_tab_visible'), 10, 1);
add_action('wp_stateless_compatibility_tab_content', array($this, 'tab_content'));

/**
* Support for BuddyPress
*/
new BuddyPress();

/**
* Support for Easy Digital Downloads
*/
new EDDDownloadMethod();

/**
* Support for Ewww Image Optimizer
*/
Expand All @@ -50,11 +40,6 @@ public function __construct() {
*/
new LearnDash();

/**
* Support for LiteSpeed Cache
*/
new LSCacheWP();

/**
* Support for Polylang Pro
*/
Expand All @@ -70,11 +55,6 @@ public function __construct() {
*/
new SimpleLocalAvatars();

/**
* Support for SiteOrigin Widgets Bundle
*/
new SOWidgetCSS();

/**
* Support for The Events Calendar
*/
Expand All @@ -90,11 +70,6 @@ public function __construct() {
*/
new WPBakeryPageBuilder();

/**
* Support for WPForms
*/
new WPForms();

/**
* Support for Smush
*/
Expand Down
1 change: 1 addition & 0 deletions lib/classes/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ final class Settings extends \UDX\Settings {
'status_email_type' => array('', 'true'),
'status_email_address' => array('', ''),
'use_postmeta' => array('WP_STATELESS_POSTMETA', ['false', '']),
'use_api_siteurl' => array('WP_STATELESS_API_SITEURL', ['WP_HOME', '']),
);

private $network_only_settings = array(
Expand Down
10 changes: 10 additions & 0 deletions lib/classes/class-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ public static function upgrade_db($new_version, $old_version) {
Helper::log($e->getMessage());
}
}

if ( !empty($old_version) && version_compare($old_version, '1.2', '<') ) {
try {
// Remove UNIQUE indexes, which will be recreated later using dbDelta as non-unique
$wpdb->query('ALTER TABLE ' . ud_stateless_db()->files . ' DROP INDEX name');

} catch (\Throwable $e) {
Helper::log($e->getMessage());
}
}
}
}
}
Expand Down
Loading
Loading