Everything cool and wrong about upcoming WordPress 4.7


WordPress 4.7 has been announced for christmas this year and it will have great changes for developers. It finally cleans up some things and not only have a hyped Twentyseventeen theme. I reviewed the commits and like to share with you what is new and what might break your site. Nice shiny code in the upcoming WordPress 4.7
Some in the community complain about bad code and sometimes it really hurts my eyes too. But while reading the commits I found some interesting approaches to clean up everything. Read on to see how the code gets better.
WordPress wants to get rid of global variables
Usually you and the whole WordPress-Core-Team does this whenever they need a query:
global $wpdb;
Scott Taylor on 18.08.16 at 20:20
Query: add a `protected` field, `$db`, (composition, as it were) to `WP_*_Query` classes to hold the value for the database abstraction, instead of importing the `global $wpdb` into every method that uses it. Reduces the number of global imports by 32.
So after WordPress 4.7 on you can use the protected $db field
$this->db->posts // to get the name of the posts table
I hope for a getter because right now this field is protected and does not really have any advantage
Source: https://managewp.org/articles/13571/everything-cool-and-wrong-about-upcoming-wordpress-4-7




source https://williechiu40.wordpress.com/2016/10/10/everything-cool-and-wrong-about-upcoming-wordpress-4-7/