the mysterious 7th argument

wpHakka.com.br - underground guerrilla - plugin arsenal for wp warfare

is just another stone in wp’s graveyard . . .

arguments are parameters passed to a method or function, in order to work they have defined formats, like string, number or whatever, sometimes they are optional, means you can omit them

wp dev docs explain the 7th argument is supposed to be an integer and in this case it is supposed to define the menu position, means when you add several items, with the position number you can order them in an adequate manner for their purpose, quite logical that it exist, as well as quite necessary in order not to come out like windows control panel with a wild random order . . .

then happens that the order isn’t obeyed, wp core adds the item in arbitrary order and the mess is on the table

then you find some notes about wp core function that the 7th argument is discontinued . . . hun? why that? probably they weren’t able to fix it, because it doesn’t worked anyway, they just chose to ignore it . . . hahaha

so ok, believe it, but better not, it isn’t true, the 7th argument is just ignored . . . as long as it exist and is NOT discontinued or removed, you still get an error like the 7th argument is supposed to be INT . . . haha

funny it is, but absurdly stupid, a menu without possibility to order the entries? only in a madhouse, what wp probably is . . .

how to solve it?

first, we defined our desired item order as default option

second, we have to compare the actual menu order with our desired order and reorganize it accordingly

third, the moment is the key, this has to be done after all plugins got through the wp admin ini phase, before the adm is displayed, so we hook into admin_head and run an order update

important is to run all checkes conditioned so that no arbitrary loop runs thousand times every day

of course it was an interesting journey through wp’s dark chambers and a good self-teaching lesson, but quite sad that such an extra work is necessary to compansate lazy core programmer’s leftovers . . . what is a very friendly comment

now you’re ready to dive in, or you can opt in to use our underground mainframe to be always one step in front of the crap

take care, peace!
H.Mich




hakka quote … most people have a skull, I have a light bulb powered by a crap burner oven

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *