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

Don't use globals #1

Open
curtismchale opened this issue Aug 25, 2023 · 0 comments
Open

Don't use globals #1

curtismchale opened this issue Aug 25, 2023 · 0 comments

Comments

@curtismchale
Copy link

@lukefretwell we shouldn't be using globals like is done here.

The action hook passes the admin menu value you use. When you use a global I can't edit the menu stuff again later with a custom plugin without messing with load orders.

add_action( 'admin_bar_menu', 'lukes_admin_bar' );
function lukes_admin_bar( $admin_bar ){

  $args = array(
        'id' => 'media-library',
        'title' => 'Media Library', 
        'href' => esc_url( admin_url( 'upload.php' ) )
    );
    $admin_bar->add_node($args);

}

This is how it should be done. In general if you think you should use global you should not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant