Like Mika I primarily develop sites using Genesis themes. I write a plugin to customise the Genesis child theme instead of modifying the child theme – I want to be able to easily update the child theme if a new version is released.
Some encourage developers to edit the child theme (e.g. Nathan Rice, Genesis creator and Nuts and Bolts Media, owners of Daily Bolt) while I prefer not to (as does Jon Barratt, developer of WP Clips).
A few months ago Mika wrote about making page templates in a plugin available for selection when editing a page. She mentioned my comment on an earlier article. Mika had modified code written by WPExplorer. Both versions required that the template files be listed in the code. I wanted this to be dynamic. My plan is to use the dynamic code in future plugins and be able to update it easily, regardless of what template files are involved – identical to the Genesis problem I am trying to solve.
I found the regex in WordPress core that extracted the template name from a page template – in the get_file_description() code. I also added an apply_filters() call to allow users of the code change the location of the template files – for a better organised plugin file structure.
Using it is simple: