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

DO NOT MERGE | POC | Enhancement / 652 Migration UI From Old Modules to Standalone Plugins #806

Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -59,3 +59,8 @@ temp/
._*
.Trashes
.svn

############
## Assets
############
admin/assets
39 changes: 37 additions & 2 deletions admin/load.php
Expand Up @@ -5,10 +5,43 @@
* @package performance-lab
*/

use PerformanceLab\classes\Plugin_Manager as Plugin_Manager;
use PerformanceLab\REST_API\REST_Routes as REST_Routes;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

add_action( 'admin_enqueue_scripts', 'admin_scripts' );

/**
* Callback function to handle admin scripts.
*
* @return void
*/
function admin_scripts() {
wp_enqueue_script(
'wpp-plugin-manager',
plugin_dir_url( __FILE__ ) . 'assets/js/plugin_manager.js',
array( 'jquery' ),
'1.0.0',
array(
'strategy' => 'defer',
)
);

wp_localize_script(
'wpp-plugin-manager',
'wpp_plugin_manager',
array(
'rest_base' => esc_url_raw( rest_url() ),
'rest_namespace' => REST_Routes::REST_ROOT,
'nonce' => wp_create_nonce( 'wp_rest' ),
'wpp_plugins' => Plugin_Manager::get_standalone_plugins(),
)
);
}

/**
* Adds the modules page to the Settings menu.
*
Expand Down Expand Up @@ -107,9 +140,11 @@ static function() use ( $module_slug, $module_data, $module_settings ) {
function perflab_render_modules_page() {
?>
<div class="wrap">
<h1>
<?php Plugin_Manager::render_plugins_ui(); ?>

<h2>
<?php esc_html_e( 'Performance Modules', 'performance-lab' ); ?>
</h1>
</h2>

<form action="options.php" method="post">
<?php settings_fields( PERFLAB_MODULES_SCREEN ); ?>
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Expand Up @@ -48,5 +48,8 @@
"psr-4": {
"PerformanceLab\\Tests\\": "tests/utils"
}
},
"autoload": {
"classmap": ["includes/"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, let's avoid the usage of Composer within the actual plugin.

}
}