diff --git a/framework/PageBuilder/v25/PageBuilderLoader.php b/framework/PageBuilder/v25/PageBuilderLoader.php index 22c3d00..d78b9bd 100644 --- a/framework/PageBuilder/v25/PageBuilderLoader.php +++ b/framework/PageBuilder/v25/PageBuilderLoader.php @@ -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 diff --git a/framework/PageBuilder/v25/PageBuilderWidget.php b/framework/PageBuilder/v25/PageBuilderWidget.php index 55ddf6e..36754f3 100644 --- a/framework/PageBuilder/v25/PageBuilderWidget.php +++ b/framework/PageBuilder/v25/PageBuilderWidget.php @@ -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.' ); @@ -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.' ); @@ -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.' ); diff --git a/readme.txt b/readme.txt index b34f554..abc4fd1 100644 --- a/readme.txt +++ b/readme.txt @@ -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 =