Skip to content

Commit

Permalink
add options page;show WP2Static active
Browse files Browse the repository at this point in the history
  • Loading branch information
leonstafford committed May 9, 2020
1 parent 1f74797 commit c657c83
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
33 changes: 30 additions & 3 deletions src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

class Controller {
public function run() : void {
add_filter( 'wp2static_add_menu_items', [ 'WP2StaticBunnyCDN\Controller', 'addSubmenuPage' ] );

add_action(
'admin_post_wp2static_bunnycdn_save_options',
[ $this, 'saveOptionsFromUI' ],
Expand All @@ -20,6 +18,15 @@ public function run() : void {
1
);

add_action(
'admin_menu',
[ $this, 'addOptionsPage' ],
15,
1
);

add_filter('parent_file', [ $this, 'setActiveParentMenu' ]);

add_action(
'wp2static_post_deploy_trigger',
[ 'WP2StaticBunnyCDN\BunnyCDN', 'bunnycdn_purge_cache' ],
Expand Down Expand Up @@ -154,7 +161,7 @@ public static function activate_for_single_site() : void {

do_action(
'wp2static_register_addon',
'wp2static-addon-bunnycdn',
'wp2static_addon_bunnycdn',
'deploy',
'BunnyCDN Deployment',
'https://wp2static.com/addons/bunnycdn/',
Expand Down Expand Up @@ -280,5 +287,25 @@ public static function getValue( string $name ) : string {

return $option_value;
}

public function addOptionsPage() {
add_submenu_page(
null,
'BunnyCDN Deployment Options',
'BunnyCDN Deployment Options',
'manage_options',
'wp2static_addon_bunnycdn',
[ $this, 'renderBunnyCDNPage' ]
);
}

// ensure WP2Static menu is active for addon
public function setActiveParentMenu() {
global $plugin_page;

if ('wp2static_addon_bunnycdn' === $plugin_page) {
$plugin_page = 'wp2static';
}
}
}

2 changes: 0 additions & 2 deletions views/bunnycdn-page.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<h2>BunnyCDN Deployment Options</h2>

<h3>BunnyCDN</h3>

<form
name="wp2static-bunnycdn-save-options"
method="POST"
Expand Down

0 comments on commit c657c83

Please sign in to comment.