Skip to content

Commit

Permalink
Merge pull request #29 from mailchimp/feat/move-menu-page
Browse files Browse the repository at this point in the history
Make settings page top-level
  • Loading branch information
dkotter authored Jun 17, 2024
2 parents 7a090c4 + f44128c commit 11a4124
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,19 @@ function mailchimp_sf_load_resources() {
/**
* Loads resources for the Mailchimp admin page
*
* @param string $hook_suffix The current admin page.
* @return void
*/
function mc_admin_page_load_resources() {
function mailchimp_admin_page_scripts( $hook_suffix ) {
if ( 'toplevel_page_mailchimp_sf_options' !== $hook_suffix ) {
return;
}

wp_enqueue_style( 'mailchimp_sf_admin_css', MCSF_URL . 'css/admin.css', array(), true );
wp_enqueue_script( 'showMe', MCSF_URL . 'js/hidecss.js', array( 'jquery' ), MCSF_VER, true );
}

add_action( 'load-settings_page_mailchimp_sf_options', 'mc_admin_page_load_resources' );
add_action( 'admin_enqueue_scripts', 'mailchimp_admin_page_scripts', 10, 1 );


/**
Expand Down Expand Up @@ -194,12 +200,13 @@ function mailchimp_sf_main_css() {
*/
function mailchimp_sf_add_pages() {
// Add settings page for users who can edit plugins
add_options_page(
__( 'Mailchimp Setup', 'mailchimp_i18n' ),
add_menu_page(
__( 'Mailchimp Setup', 'mailchimp_i18n' ),
__( 'Mailchimp', 'mailchimp_i18n' ),
MCSF_CAP_THRESHOLD,
'mailchimp_sf_options',
'mailchimp_sf_setup_page'
'mailchimp_sf_setup_page',
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJub25lIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PGcgZmlsbD0iI2E3YWFhZCIgY2xpcC1wYXRoPSJ1cmwoI2EpIj48cGF0aCBkPSJNNzEuOTcyIDQ3LjQ0OWMuOTk0IDAgMS44LT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LjAwOC0uMDY5LS4wODctMy45MzUtLjE2LTUuNTk1LS4wNTMtMS4yLS4xNTYtMy4wNzMtLjczNy00LjkxOC0uNjkyLTIuNDk3LTEuOS00LjY4My0zLjQwNi02LjA4IDQuMTU4LTQuMzEgNi43NTItOS4wNTcgNi43NDYtMTMuMTMtLjAxMi03LjgzMS05LjYzLTEwLjItMjEuNDgyLTUuMjkzbC0yLjUxMiAxLjA2NmMtLjAxLS4wMS00LjU0LTQuNDU0LTQuNjA4LTQuNTE0QzM5LjQwNS00Ljg1Ny0yLjg0NyA0Mi4xMDggMTAuNjYyIDUzLjUxNGwyLjk1MiAyLjVjLS43NjYgMS45ODUtMS4wNjcgNC4yNTctLjgyIDYuNzAxLjMxNSAzLjE0IDEuOTM0IDYuMTQ5IDQuNTU5IDguNDc0IDIuNDkxIDIuMjA4IDUuNzY3IDMuNjA1IDguOTQ2IDMuNjAyIDUuMjU3IDEyLjExNCAxNy4yNjggMTkuNTQ2IDMxLjM1MSAxOS45NjQgMTUuMTA3LjQ0OSAyNy43ODgtNi42NCAzMy4xMDItMTkuMzczLjM0OC0uODk0IDEuODIzLTQuOTIgMS44MjMtOC40NzUgMC0zLjU3My0yLjAyLTUuMDUzLTMuMzA2LTUuMDUzWiIvPjwvZz48ZGVmcz48Y2xpcFBhdGggaWQ9ImEiPjxwYXRoIGQ9Ik04IDVoODQuNjZ2ODkuODNIOHoiLz48L2NsaXBQYXRoPjwvZGVmcz48L3N2Zz4='
);
}
add_action( 'admin_menu', 'mailchimp_sf_add_pages' );
Expand Down Expand Up @@ -790,7 +797,6 @@ function mailchimp_sf_get_interest_categories( $list_id, $new_list ) {
*/
function mailchimp_sf_setup_page() {
$path = plugin_dir_path( __FILE__ );
wp_enqueue_script( 'showMe', MCSF_URL . 'js/hidecss.js', array( 'jquery' ), MCSF_VER, true );
require_once $path . '/views/setup_page.php';
}

Expand Down

0 comments on commit 11a4124

Please sign in to comment.