Skip to content

Commit

Permalink
fix: Support depricated widget classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ediamin committed Jan 21, 2020
1 parent cd680f7 commit c0a38b1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions depricated/class-dokan-store-location-widget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

class Dokan_Store_Location {}
1 change: 1 addition & 0 deletions depricated/depricated-classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function __construct() {
require_once $dir_path . '/class-abstrct-dokan-rest-store-controller.php';
require_once $dir_path . '/class-dokan-vendor.php';
require_once $dir_path . '/class-dokan-email.php';
require_once $dir_path . '/class-dokan-store-location-widget.php';
}
}

Expand Down
26 changes: 26 additions & 0 deletions depricated/depricated-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,29 @@ function dokan_get_product_status( $status ) {
_deprecated_function( 'dokan_get_product_status', '2.5', 'dokan_get_product_types' );
return dokan_get_product_types( $status );
}

/**
* Load depericated widget class dynamically
*
* @since DOKAN_LITE_SINCE
*
* @return void
*/
function dokan_depricated_widget_classes() {
global $wp_widget_factory;

$widget_classes = [
'Dokan_Best_Selling_Widget' => \WeDevs\Dokan\Widgets\BestSellingProducts::class,
'Dokan_Store_Contact_Form' => \WeDevs\Dokan\Widgets\StoreContactForm::class,
'Dokan_Store_Location' => \WeDevs\Dokan\Widgets\StoreLocation::class,
'Dokan_Store_Category_Menu' => \WeDevs\Dokan\Widgets\StoreCategoryMenu::class,
'Dokan_Store_Open_Close' => \WeDevs\Dokan\Widgets\StoreOpenClose::class,
'Dokan_Toprated_Widget' => \WeDevs\Dokan\Widgets\TopratedProducts::class,
];

foreach ( $widget_classes as $deprecated_class => $new_class ) {
$wp_widget_factory->widgets[ $deprecated_class ] = $wp_widget_factory->widgets[ $new_class ];
}
}

add_action( 'woocommerce_before_main_content', 'dokan_depricated_widget_classes' );

0 comments on commit c0a38b1

Please sign in to comment.