Hi, I’m designing a plugin for WordPress that allow admins to create sidebar content and blocks from the admin area without having to go and change the actual code in sidebar.php. The blocks and content will be stored in the database and be selectable for order of appearance and such.
This is being designed for non-programmers and such who don’t know how to go in and alter the actual code in the template area.
So far the only way I see of adding content to the sidebar.php area is to hook into wp-meta and make an action to add my content when that is called by WordPress. One problem I see though is that most templates for WordPress have “hard coded” Meta area links and data (a big mistake in my opinion) such as admin login location, and other links. What I would like to do is create a way in my plugin to filter this stuff and give the user the ability to show this or not. Now the important bit is considering the target audience for my plugin, I can’t expect the user to go in and mess with the code, I need the plugin to be able to do this for them.
Is there a way to capture this stuff and have an add_filter be able to do a str_replace to remove it? I suspect the_content won’t see this stuff.
If there isn’t a current way to do this I think there needs to be something added to affect this type of stuff. Optimally I want my plugin to work with any template.
I might be wrong but aren’t the widget gizmos doing exactly what described above? – i.e. messing with the sidebar without touching the code in the template file.
I’ll look into that system a bit to see if it’s what I am looking to do, but one thing is still bothersome about it, it requires someone to still do some alteration to their code to get it to work (now, if it gets integrated into a new version of WordPress as a default, that would be great). You have to have a template that is preset to use the widgets, or you have to mess with some code. Most of the people I want to create this plugin for are artists or other non-programmers who quiver at the idea of even looking at the template code. I’m still curious if there is a way to filter “hard coded” content in any of the template files…….Hmmm, I wonder if you could add the “dynamic sidebar” code using a filter? Maybe then do a rewind to re parse the page and then boom have the thing use the widgets as if the template already supported them?
I’ve found this thread probably too late for my reply to be helpful to harknell, but I ended up here because I had a similar issue, and a solution that worked for my situation.
Something to keep in mind with the sidebar is that the code of your plugin is available to you, just not through filters like the_content and others. If widgetizing is unappealing for any reason, you can make direct php calls to functions in your plugin.
This means putting a line of php code in the template, which harkin wants to avoid, but if you can set up your plugin so it can be a really simple line of code, perhaps that won’t be too much to ask of your non-techie users.
- The topic ‘WordPress filter for “hard coded” template content’ is closed to new replies.