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

Fix: Make Non-Static Method Not Static; Globalize WP_Term_Order #22

Conversation

ggwicz
Copy link
Contributor

@ggwicz ggwicz commented Apr 19, 2022

Summary

1. Make Non-Static Method Not Static

  • The WP_Term_Order::term_order_add_form_field() method is declared as a static method, but only ever used in a non-static object context.
  • This PR removes the unnecessary static method from that method declaration.

2. Globalize WP_Term_Order

  • WP Term Order has hook callback methods that cannot be unhooked via remove_action(). This is bad practice for a WordPress plugin or theme, and should be fixed.
  • A few different fixes are possible; one example is to implement a singleton design pattern for the WP_Term_Order class.
  • But to keep things simple, I've just made the single existing object (created on an init hook callback) a global variable: global $wp_term_order.
  • This global can then be referenced by remove_action() calls, without otherwise affecting any existing plugin functionality.

@JJJ JJJ merged commit 41740a6 into stuttter:master Jun 7, 2022
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

Successfully merging this pull request may close these issues.

2 participants