mirror of
https://github.com/gantry/gantry5.git
synced 2026-08-19 01:15:04 -05:00
WordPress: Allow Gantry theme upgrades from WordPress theme uploader (#1165)
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
3. [](#bugfix)
|
||||
- Fixed error on saving system outline layouts (#1167)
|
||||
3. [WordPress](#wordpress)
|
||||
1. [](#new)
|
||||
- Allow Gantry theme upgrades from WordPress theme uploader (#1165)
|
||||
3. [](#bugfix)
|
||||
- Fixed Hydrogen Child theme to reference properly `g5_hydrogen` parent directory
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ defined('ABSPATH') or die;
|
||||
add_action( 'admin_init', 'gantry5_admin_start_buffer', -10000 );
|
||||
add_action( 'admin_enqueue_scripts', 'gantry5_admin_scripts' );
|
||||
add_action( 'wp_ajax_gantry5', 'gantry5_layout_manager' );
|
||||
add_filter( 'upgrader_package_options', 'gantry5_upgrader_package_options', 10000 );
|
||||
add_filter( 'upgrader_source_selection', 'gantry5_upgrader_source_selection', 0, 4 );
|
||||
|
||||
// Check if Timber is active before displaying sidebar button
|
||||
if ( class_exists( 'Timber' ) ) {
|
||||
@@ -78,3 +80,26 @@ function gantry5_layout_manager() {
|
||||
// wp_die( $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
// SimpleXmlElement is a weird class that acts like a boolean, we are going to take advantage from that.
|
||||
class Gantry5Truthy extends SimpleXmlElement { }
|
||||
|
||||
function gantry5_upgrader_package_options($options) {
|
||||
if ($options['abort_if_destination_exists'] && !$options['clear_destination']) {
|
||||
$options['abort_if_destination_exists'] = new Gantry5Truthy('<bool><true></true></bool>');
|
||||
$options['hook_extra']['gantry5_abort'] = $options['abort_if_destination_exists'];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function gantry5_upgrader_source_selection($source, $remote_source, $this, $hook_extra) {
|
||||
if (isset($hook_extra['gantry5_abort'])) {
|
||||
// Allow upgrading Gantry themes from uploader.
|
||||
if (file_exists($source . '/gantry/theme.yaml')) {
|
||||
unset($hook_extra['gantry5_abort']->true);
|
||||
}
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user