Thread Starter
EloB
(@elob)
Here is a better solution:
In siteorigin-panels.php:399
foreach ( $panels_data['widgets'] as $i => $widget ) {
$info = $widget['info'];
if ( !class_exists( $widget['info']['class'] ) ) continue;
$the_widget = new $widget['info']['class'];
if ( method_exists( $the_widget, 'update' ) ) {
unset( $widget['info'] );
$widget = $the_widget->update( $widget, $widget );
}
$widget['info'] = $info;
$panels_data['widgets'][$i] = $widget;
}
Change to:
foreach ( $panels_data['widgets'] as $i => $widget ) {
$info = $widget['info'];
if ( !class_exists( $widget['info']['class'] ) ) continue;
$the_widget = new $widget['info']['class'];
if ( method_exists( $the_widget, 'update' ) ) {
unset( $widget['info'] );
$widget = $the_widget->update( $widget, $widget );
}
$info['class'] = addslashes($info['class']);
$widget['info'] = $info;
$panels_data['widgets'][$i] = $widget;
}
And in js/panels.admin.panels:42
var $$ = dialogWrapper.find('.panel-type[data-class="' + type + '"]' );
Change to:
var $$ = dialogWrapper.find('.panel-type' ).filter(function() { return $(this).data('class') === type });
Thread Starter
EloB
(@elob)
This wasn’t a jQuery bug. They closed the bug report. So we need either my posted solution or fix the bug. 🙂
I’ll get on this for the next update. I hadn’t actually tested for namespaced widgets yet. Thanks for the code contributions!
Thread Starter
EloB
(@elob)
Awesome! 🙂
[Moderator Note: No bumping, thank you.]
Just letting you know I’ve applied the changes. It seems like everything is working with namespaced widgets now. I’ll be pushing the 1.3.8 update either later today or tomorrow.
Thread Starter
EloB
(@elob)
Hi Mate!
Great but I doesn’t work… It only works the first time you save but when you click update the widget will get removed… You must addslashes to the class…
$info['class'] = get_class($the_widget);
To
$info['class'] = addslashes(get_class($the_widget));