Skip to content

Commit

Permalink
Merge pull request #3 from justcoded/develop
Browse files Browse the repository at this point in the history
Hotfix: PageBuilderWidget raise fatal error when Site Origin Widgets Bundle is off
  • Loading branch information
aprokopenko authored May 26, 2017
2 parents 4406b1c + 996b87b commit ca753eb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
9 changes: 9 additions & 0 deletions framework/PageBuilder/v25/PageBuilderLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ public static function plugin_active() {
return is_plugin_active( 'siteorigin-panels/siteorigin-panels.php' );
}

/**
* Check that widgets bundle plugin is installed and activated
*
* @return bool
*/
public static function widgets_bundle_active() {
return is_plugin_active( 'so-widgets-bundle/so-widgets-bundle.php' );
}

/**
* Init row/widgets layouts and change disabled plugins list.
* Called at the end of the __contruct() method
Expand Down
36 changes: 33 additions & 3 deletions framework/PageBuilder/v25/PageBuilderWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,42 @@

namespace JustCoded\ThemeFramework\PageBuilder\v25;

if ( ! PageBuilderLoader::widgets_bundle_active() ) {
/**
* Class PageBuilderWidget
* if widgets bundle is not enabled we create a dummy class to prevent errors.
*/
class PageBuilderWidget extends \WP_Widget {
/**
* Constructor.
*
* @param string $id Widget id.
* @param string $name Widget title.
* @param array $widget_options Optional Normal WP_Widget widget options and a few extras.
* - help: A URL which, if present, causes a help link to be displayed on the Edit Widget modal.
* - instance_storage: Whether or not to temporarily store instances of this widget.
* - has_preview: Whether or not this widget has a preview to display. If false, the form does not output a
* 'Preview' button.
* @param array $control_options Optional Normal WP_Widget control options.
* @param array $form_options Optional An array describing the form fields used to configure SiteOrigin widgets.
* @param mixed $base_folder Optional Some compatibility param.
*/
function __construct( $id, $name, $widget_options = array(), $control_options = array(), $form_options = array(), $base_folder = false ) {
}
}

return false;
}

/**
* Class PageBuilderWidget
*/
class PageBuilderWidget extends \SiteOrigin_Widget {
/**
* Form fields configuration
*
* @return array
* @throws \Exception
* @throws \Exception Method should be overwritten in nested class.
*/
public function get_widget_form() {
throw new \Exception( 'PageBuilderWidget::get_widget_form() : You should overwrite get_widget_form() method inside your own class.' );
Expand All @@ -25,7 +55,7 @@ public function get_widget_form() {
* @param array $instance submitted form values.
*
* @return array
* @throws \Exception
* @throws \Exception Method should be overwritten in nested class.
*/
public function modify_instance( $instance ) {
throw new \Exception( 'PageBuilderWidget::modify_instance() : You should overwrite modify_instance() method inside your own class.' );
Expand All @@ -37,7 +67,7 @@ public function modify_instance( $instance ) {
* @param array $args Widget display arguments.
* @param array $instance Widget settings.
*
* @throws \Exception
* @throws \Exception Method should be overwritten in nested class.
*/
public function widget( $args, $instance ) {
throw new \Exception( 'PageBuilderWidget::widget() : You should overwrite widget() method inside your own class.' );
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ To upgrade remove the old plugin folder. After than follow the installation step

== Changelog ==

= Version 1.2.3 - 26 May 2017 =
* Hotfix: PageBuilderWidget raise fatal error when Site Origin Widgets Bundle plugin is not installed or deactivated.
= Version 1.2.2 - 12 May 2017 =
* Hotfix: Page Builder design options (background, borders) were missing in new version. Fixed.
= Version 1.2.1 - 12 May 2017 =
Expand Down

0 comments on commit ca753eb

Please sign in to comment.