bobbingwide / oik-loader

WordPress Must Use plugin to load required plugins
0 stars 0 forks source link

Extend oik-loader to work like oik-unloader but in reverse #13

Open bobbingwide opened 2 years ago

bobbingwide commented 2 years ago

On cwiccer.com, I'm preparing a presentation for the WordPress Portsmouth Meetup on Performance. Trouble is, with so many poor performing plugins activated, the system's really slow to edit. How easy would it be to change the code to operate like oik-unloader, but in reverse?

It needs to be able to activate plugins for a particular URL.

Can we use the oik-loader-extras.csv file to achieve this? Or do we need to use the post meta data the same as in wp-a2z?

bobbingwide commented 2 years ago

Can we use the oik-loader-extras.csv file to achieve this?

Yes. I tested it in s.b/cwiccer with two URLs: /cwiccer/process/elementor/ and /cwiccer/process/

I copied the extras ( oik-loader-extras.csv ) file from s.b/wp-a2z

/wp-json/wp/v2/download_category,0,edd-blocks/edd-blocks.php,easy-digital-downloads/easy-digital-downloads.php
/wp-json/wp/v2/download_tag,0,edd-blocks/edd-blocks.php,easy-digital-downloads/easy-digital-downloads.php
edd-api=products,0,edd-blocks/edd-blocks.php

and added two new lines

/cwiccer/process/elementor/,2332,nextgen-gallery/nggallery.php,oik-magnetic-poetry/oik-magnetic-poetry.php
/cwiccer/process/,2330,oik-magnetic-poetry/oik-magnetic-poetry.php,hello-dolly/hello.php,cwiccer/cwiccer.php

elementor's dependent upon NextGEN Gallery and Magnetic Poetry process is dependent upon Magnetic Poetry and Hello Dolly

In order to activate the changed extras file visit oik options > oik loader and choose Click to rebuild index. This will append the extras file to the loader file ( oik-loader.1.csv )

Completing the post ID's enables the plugins in the block editor as well.

A quick fix for cwiccer.com is needed to enable editing of the extras file in the oik-loader page.

bobbingwide commented 2 years ago

A similar problem happened with oik-loader as with oik-unloader. NextGEN Gallery updated the active_plugins entry at shutdown. So, when I visited a page where NextGEN Gallery was dynamically loaded then all the other plugins were activated as well.

Need to remove the filters some time on / after plugins_loaded and before shutdown.

See https://github.com/bobbingwide/oik-unloader/issues/6