upskill-event-manager/wordpress-dev/wordpress/wp-content/plugins/astra-addon/classes/class-astra-ext-extension.php
bengizmo d1509b3d60 feat(dev-env): implement backup-based development workflow
This commit introduces a more reliable and consistent approach to setting up
the development environment using backups:

- Add setup-from-backup.sh script for environment setup from existing backups
- Standardize script naming and organization
- Move obsolete scripts to bin/obsolete directory
- Update documentation with new workflow instructions
- Create migration guide for transitioning to new workflow
- Update Memory Bank with workflow improvements

The new workflow provides:
- More reliable environment setup
- Faster setup process
- Offline development capability
- Consistent development environments across team members

Breaking changes:
- setup-dev.sh is replaced by setup-from-backup.sh
- sync-and-setup.sh is replaced by separate scripts
- verify-with-wpcli.sh is no longer used

Migration path is documented in MIGRATION_GUIDE.md
2025-03-26 11:26:18 -03:00

163 lines
4 KiB
PHP

<?php
/**
* Astra Extension Class
*
* @package Astra Addon
*/
/**
* Provide Extension related data.
*
* @since 1.0
*/
// @codingStandardsIgnoreStart
final class Astra_Ext_Extension {
// @codingStandardsIgnoreEnd
/**
* Default Extensions
*
* @since 1.4.8
* @return array
*/
public static function get_default_addons() {
return apply_filters(
'astra_addon_ext_default_addons',
array(
'advanced-search' => 'advanced-search',
)
);
}
/**
* Provide Extension array().
*
* @return array()
* @since 1.0
*/
public static function get_addons() {
$extensions = array(
'advanced-hooks' => array(),
'blog-pro' => array(),
'colors-and-background' => array(),
'advanced-footer' => array(),
'mobile-header' => array(),
'header-sections' => array(),
'lifterlms' => array(),
'learndash' => array(),
'advanced-headers' => array(),
'site-layouts' => array(),
'spacing' => array(),
'sticky-header' => array(),
'transparent-header' => array(),
'typography' => array(),
'woocommerce' => array(),
'edd' => array(),
'nav-menu' => array(),
);
return apply_filters( 'astra_addon_get_addons', $extensions );
}
/**
* Provide Enable Extension array().
*
* @return array()
* @since 1.0
*/
public static function get_enabled_addons() {
$enabled_data = array();
$extensions = self::get_addons();
$enabled_extensions = Astra_Admin_Helper::get_admin_settings_option( '_astra_ext_enabled_extensions' );
if ( empty( $enabled_extensions ) ) {
foreach ( $extensions as $slug => $data ) {
$enabled_data[ $slug ] = ( isset( $data['default'] ) ) ? $data['default'] : false;
}
$enabled_data['all'] = 'all';
} else {
$enabled_data = $enabled_extensions;
if ( isset( $enabled_extensions['all'] ) && false != $enabled_extensions['all'] ) {
// add new key.
foreach ( $extensions as $slug => $data ) {
if ( ! array_key_exists( $slug, $enabled_extensions ) ) {
$enabled_data[ $slug ] = ( isset( $data['default'] ) ) ? $data['default'] : false;
}
}
}
}
return apply_filters( 'astra_addon_enabled_extensions', $enabled_data );
}
/**
* Activates the specified extension.
*
* @param string $extension_name Extension Name.
* @param boolean $force Force to activate.
*
* @return void
*
* @since 4.8.8
*/
public static function activate_extension( $extension_name, $force = true ) {
// Get the list of currently enabled extensions.
$extensions = self::get_enabled_addons();
// Check if the extension needs to be activated.
if ( ! isset( $extensions[ $extension_name ] ) || ( $force && ! $extensions[ $extension_name ] ) || $extensions[ $extension_name ] === false ) {
$extensions[ $extension_name ] = $extension_name;
Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $extensions );
}
}
/**
* Check extension status
*
* @param string $key Key to find in Extensions Array.
* @param boolean $default Default if Key not exist in Extensions Array.
* @return boolean
* @since 1.0
*/
public static function is_active( $key, $default = false ) {
$extensions = array_merge( self::get_enabled_addons(), self::get_default_addons() );
if ( array_key_exists( $key, $extensions ) && $extensions[ $key ] ) {
return true;
} else {
return $default;
}
}
/**
* Provide Custom 404 array().
*
* @return array()
* @since 1.0
*/
public static function get_custom_404() {
$custom_404_default = array(
'enable_404' => false,
'page_404' => '',
'page_404_id' => '',
);
$custom_404 = Astra_Admin_Helper::get_admin_settings_option( '_astra_ext_custom_404' );
if ( empty( $custom_404 ) ) {
$custom_404 = $custom_404_default;
}
$custom_404 = apply_filters( 'astra_addon_custom_404_options', $custom_404_default );
return $custom_404;
}
}