awps / smk-sidebar-generator Goto Github PK
View Code? Open in Web Editor NEWWordPress Sidebar Generator fully managed from WP Admin. No code required!
Home Page: https://zerowp.com/sidebar-generator
WordPress Sidebar Generator fully managed from WP Admin. No code required!
Home Page: https://zerowp.com/sidebar-generator
Hey mate, me again.
The sidebar seems to be broken for term archives as well.
- How to reproduce?
Sidebars to replace:
add either Post Sidebar
and Archive Sidebar
, or only Archive Sidebar
. Shoudn't make a difference for that case.and is equal to
-> Anything you want + Any(archives or single)
- Or nothing. Both ways the sidebar should now replace an archive-sidebar on the specific post-type's term-archive, which it doesn't.- Fix
When you set it up like above, you should end up in the else statement on L:101 in conditiin-cpt.php
for custom post types. If you didn't set anything in and is equal to
the first if-case empty($second_selection)
will be true, otherwise the following elseif
should be true. You then use is_post_type_archive( $first_selection )
( where first_selection is the post type slug ). Unfortunately this method will return false for term archives as it does not check whether the archive is "any archive within the post type", but rather checks if it is the root post type archive - at least that's how I understood it from some test queries ;)
To check if the archive belongs to a term within the post type, use is_tax
(https://developer.wordpress.org/reference/functions/is_tax/) and then simply check for all taxonomies within the post type: is_tax(get_object_taxonomies($first_selection))
. Add this as additional else case in both checks. Then you have covered singular, post-type archive and term archives.
This at least brings back the sidebar for my case and everythings seems to be working fine. I'm not 100% confident though that this is the correct method for the job, but it seems like.
Thanks for your work I use the plugin in quite some projects. Glad I can contribute.
Cheers again!
Forgive my ignorance, but after selecting the sidebar from the dropdown list in the metabox on the edit page/post screen, how do I make that sidebar actually appear when the page gets published?
I already added the following to my functions.php file:
if( class_exists('SMK_Sidebar_Metabox') ) {
new SMK_Sidebar_Metabox( 'post',
array('no', 'left', 'right', 'left-right')
);
new SMK_Sidebar_Metabox( 'portfolio',
array('no', 'left', 'right')
);
new SMK_Sidebar_Metabox( 'page',
array(
'no' => array(
'default',
'page-right-sidebar.php',
'template-simple.php',
),
'left' => array(
'default',
'page-right-sidebar.php',
),
'right' => array(
'default',
'page-right-sidebar.php',
'template-simple.php',
),
'left-right' => array(
'default',
'page-right-sidebar.php',
),
)
);
}
So the meta box appears as it should.
If I wanted to use a specific sidebar by hardcoding it I would do this:
<?php if(function_exists('dynamic_sidebar') && dynamic_sidebar('my-sidebar-name')) : >
How do I do the dynamic equivalent of the above, so that whatever sidebar I pick from the dropdown menu appears?
How i generate sidebar using function. Because Widget Importer & Exporter plugin cant import generated sidebars.
Installed version 3.2.0 of the plugin and received the following error message:
Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in …/wp-content/plugins/smk-sidebar-generator/html.php on line 83
Looks to be a PHP 7.3 compatibility issue.
Hey,
I need a little help here. I'm not able to assign my sidebars. I can create them, but there is no option showing up at page/posts to allow me to assign them. Bellow is my sidebar.php
<div id="secondary" class="sidebar" role="complementary">
<div class="sidebar-inner">
<div class="widget-area">
<?php smk_custom_dynamic_sidebar(); ?>
</div><!-- .widget-area -->
</div><!-- .sidebar-inner -->
</div><!-- #sidebar -->
Am I missing something?
Hello,
Yes, I have this warning when i try to creat a costome sidebar. Can you get a look? My config: WP: 5.0.1 PHP 7.0 an MySql 5.7.
Warning: Illegal string offset 'cart-1' in /home/clients/wwwwooolllccczzz/wp-content/plugins/vipertf-sidebar-generator/render.php on line 388
Warning: Illegal string offset 'home_sidebar' in /home/clients/wwwwooolllccczzz/wp-content/plugins/vipertf-sidebar-generator/render.php on line 388
Warning: Illegal string offset 'footer_sidebar_1' in /home/clients/wwwwooolllccczzz/wp-content/plugins/vipertf-sidebar-generator/render.php on line 388
Warning: Illegal string offset 'footer_sidebar_2' in /home/clients/wwwwooolllccczzz/wp-content/plugins/vipertf-sidebar-generator/render.php on line 388
Warning: Illegal string offset 'footer_sidebar_3' in /home/clients/wwwwooolllccczzz/wp-content/plugins/vipertf-sidebar-generator/render.php on line 388
Regards.
Hello,
It's very nice to see someone keeping sidebar-generator alive. Well done!
I'm having an issue. If I want to delete a just created sidebar I'm getting this pop up window.
Ajax error. Cannot add sidebar
The message says 'add'.. but that only happens when I'm trying to delete it.
Thanks,
Is there a way to not show the metabox at all on posts page (set in Settings -> reading)?
Is there any way to prevent non-sidebar positions from showing in the metabox select? For example, I have several footer widget positions, 2 sidebars coded into the them, plus several sidebars via the unlimited sidebar v2 plugin. Is there any way to prevent the footer widget positions from showing in the metabox select?
I'm receiving this error on my blog post page where I use sidebars, it won't even allow me to post to my site anymore. I need to be able to rollback to the previous version of this until this is fixed, please provide a link to the previous version until this is corrected!
Fatal error: Call to undefined method Smk_Sidebar_Generator::get_all_sidebars() in /home/content/p3pnexwpnas04_data01/51/2239551/html/wp-content/themes/dynamic/inc/lib/metabox/init.php on line 215
After installation, when entering on Appearance -> SideBar Generator a PHP Fatal error is generated:
Cannot use string offset as an array in wp-content/plugins/smk-sidebar-generator/render.php on line 436
I have something like this in my functions:
if(class_exists('SMK_Sidebar_Metabox')) {
new SMK_Sidebar_Metabox( 'page',
array(
'no' => array(
'default',
'full-width.php',
),
'left' => array(
'default',
),
'right' => array(
'default',
),
)
);
}
When I go to page edit and set template to full-width.php template, sidebar positions no/left/right still show for this template. Why is this?
I thought only the "no" option would show in this case, but it doesn't. Also, is there a way to not show the metabox at all when the template doesn't support any sidebars?
Smartik's been down for ages, and zerowp just redirects to the github...
Any plans for making this PHP v8 compatible?
Version 3.0
Wordpress version: 4.1.1
Fatal error: Call to undefined method Smk_Sidebar_Generator::get_all_sidebars() in /home/sites/punchdesign.co.uk/public_html/wp-content/themes/eight/inc/lib/metabox/init.php on line 215
Hi, Nice plugin :)
I try to bundling this plugin into my theme, and success. I just want to recommend to change all wp_enqueue source into SMK_SBG_URI . [file location]. So, we get dynamic pointing to each files.
Here is what i do to get all your scripts and style work with my theme:
wp_enqueue_style( 'smk_sbg_styles', SMK_SBG_URI . 'assets/styles.css' );
wp_enqueue_script( 'smk_sbg_scripts', SMK_SBG_URI . 'assets/scripts.js' );
wp_enqueue_script( 'smk_sbg_metabox_scripts', SMK_SBG_URI . 'assets/metabox.js' );
Thanks.
Hi,
I'm having problems with $all_sidebars = SidebarGenerator::get_all_sidebars();
. The array format that I get from it is not like:
array(
"Default Sidebar" => "Default Sidebar",
"Sidebar Name" => "Sidebar Name",
"Sidebar Name 1" => "Sidebar Name 1",
"Sidebar Name 2" => "Sidebar Name 2"
)
is like this when I printed out:
[Default Sidebar] => Default Sidebar
[Top Header Widget] => Top Header Widget
[Footer Widget 01] => Footer Widget 01
[Footer Widget 02] => Footer Widget 02
[Footer Widget 03] => Footer Widget 03
[Footer Widget 04] => Footer Widget 04
[Front-Page] => Front-Page
My problem is that on my meta-box, the array will only works if is like the first format. I hope I could make you understand the issue.
Thanks
I define 3 sidebars.
Each sidebar replace the main sidebar with a condition:
Sidebar1: Replace if 'Classes' == 'custom1'
Sidebar2: Replace if 'Classes' == 'custom2'
Sidebar3: Replace if 'Classes' == 'custom3'
When i call an URL with /?wcs3_class=custom1
the sidebar always will be replaced with Sidebar3
not width Sidebar1.
The function canReplace
show on a var_dump:
$frist_selection = 'wcs3_class';
$second_selection = array('251');
...
$frist_selection = 'wcs3_class';
$second_selection = array('252');
...
$frist_selection = 'wcs3_class';
$second_selection = array('253');
and return true on:
if( empty($second_selection) ){
if( is_singular( $first_selection ) || is_post_type_archive( $first_selection ) ){
$can = true;
}
}
elseif( 'all_archives_single' && ( is_singular( $first_selection ) || is_post_type_archive( $first_selection ) ) ){
// HERE: fulfilled is_singular( $first_selection )
$can = true;
}
elseif( 'all_archives' && is_post_type_archive( $first_selection ) ){
$can = true;
}
elseif( is_single( $second_selection ) ){
// BUT it should do it here once ???
$can = true;
}
Other thing in the condition above you check / forgett to check the strings:
elseif( 'all_archives_single' &&
elseif( 'all_archives' &&
Hallo, I would love to be able to use my website's categories as a condition for the display of the sidebar. Is that possible or can you suggest a quick fix for that?
Hey,
For all the sidebars that you created, they will always appear on the botton of Widget page. They will be always after any sidebar you had created on functions.php. Is there a way to change that? For example, if I create a sidebar using your class, I would like that sidebar to be on top of Widget page.
Hey Guys,
when setting a sidebar for "All Single" for a given post-type, since the last plugin update the custom post-type condition for single posts in Smk_Sidebar_Generator_Condition_Cpt::canReplace()
will always fail, as you provide the post-type to the is_single()
method. The is_single method expects a post/post-title/post id to be checked against, not a post type (https://developer.wordpress.org/reference/classes/wp_query/is_single/).
Smk_Sidebar_Generator_Condition_Cpt::canReplace() L:116
Change
is_single( $first_selection )
to is_singular( $first_selection )
Thanks, and cheers! Enjoy the weekend
We are getting a blank page when we try to open the SMK Sidebar Generator from our Appearance menu. Nothing else if there on the page just the WordPress sidebar and header. Is there any fix for this?
Thanks
Hi. Is this possible to customize widget output like before_widget
, after_widget
, before_title
and after_title
without directly modifying register_sidebars()
function?
Refactoring to a newer more robust generator with more modern possibilities
I'm trying to use Sidebar Generator with: https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress but I have a small issue.
In the select element it only returns the first letter of each sidebar
Example:
$all_sidebars = SidebarGenerator::get_all_sidebars();
$meta_boxes[] = array(
'id' => 'test_metabox',
'title' => 'Test Metabox',
'pages' => array( 'page', ),
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
'fields' => array(
array(
'name' => 'Sidebar',
'desc' => 'Select which sidebar to display',
'id' => $prefix . 'sidebar',
'type' => 'select',
'options' => $all_sidebars,
),
),
);
This will return a select element with options of: P, F, t, h, h
This exactly matches the first letter in each sidebar name.
Any idea what might be going on and how to display the full name?
After installation the plugin works fine; its easy to add or delete sidebars.
However, after deleting all sidebars and saving the changes, its impossible to add new sidebar entirely.
I am getting this error: "The sidebar already exists. Please change the name." Even when I try different names altogether.
I have tried to look at the code and couldn't get to a possible solution.
But when I delete the 'smk_sidebar_generator_option' option_name from 'options' table in my database, the problems gets solved. And it becomes possible to add new sidebars again.
I also need to add that the problem only occurs when all sidebars are deleted.
I'm not sure if its a database issue after deleting all the sidebars and then saving the changes.
Can $page parameter be array in contructor of SMK_Sidebar_Metabox class?
I can see code in constructor:
$this->page = $page;
if( ! is_array( $this->page ) )
$this->page = array( $this->page );
Does it mean $page can be array, not string like here:
new SMK_Sidebar_Metabox( 'page',
array(
'no' => array(
'default',
'entire-width.php',
),
'left' => array(
'default',
),
'right' => array(
'default',
),
)
);
Can you please give example when $page is array?
Today I'm planing to start working to version 2.0. Why I say 2.0 and not 1.x.x? Because this will be a totally differend code, I will write the whole plugin from scratch(only some functions from old code will be used). I say plugin because v2.0 will be a plugin that can be installed and will be available to use only for themes that have support for it. OK, in short, here is the TODO list:
That's just a quick list, if you have any ideas don't hesitate to leave them in comments here.
here is the video:
https://www.dropbox.com/s/rioxcw88p5ldxs7/capture-1.mp4?dl=0
in wp-options this key smk_sidebar_generator
has this value:
a:2:{s:7:"counter";s:1:"1";s:8:"sidebars";a:1:{s:12:"sg442_110bku";a:4:{s:4:"name";s:13:"New sidebar 1";s:11:"description";s:0:"";s:2:"id";s:12:"sg442_110bku";s:10:"conditions";a:1:{i:0;a:1:{s:2:"if";s:15:"post_type::post";}}}}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.