Per Page Widgets
-
Hi,
Not really a support request but more some code that can be used to enhance the plugin
add the following function
function return_template_sidebars() { global $post; $sidebarsArr = array(); $template = file_get_contents( get_template_directory() . DIRECTORY_SEPARATOR . $post->page_template ); if ( $template != false ) { preg_match( '|Sidebars:(.*)$|mi', $template, $matches ); if (!empty($matches[1])) { $tempArr = explode(",", $matches[1]); } foreach ($tempArr as $temp) { $sidebarsArr[] = trim($temp); } } return $sidebarsArr; }
Then modify i123_widgets_custom_fields_controllbox by adding
$sidebarsArray = return_template_sidebars();
just before
foreach($wp_registered_sidebars as $key => $value) {
and
if (!in_array($value['id'], $sidebarsArray, false)) continue;
just before
<div class="i123_widgets_formline">
This then allows you to add
* Sidebars: sidebar-1, sidebar-2
into your template files which means you limit the sidebars shown based on the template being used to display the page.It needs a little more code writing so that it will pick up default templates but the basics are there
https://www.ads-software.com/extend/plugins/per-page-widgets/
- The topic ‘Per Page Widgets’ is closed to new replies.