-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Theme): Storefront theme compatibilty
Added Storefront theme compatibilty so that the store page and the vendor dashboard page becomes full-width and doesn’t show sidebar.
- Loading branch information
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/** | ||
* Dokan Theme Support | ||
* | ||
* @since 3.0 | ||
* | ||
* @package Dokan | ||
*/ | ||
class Dokan_Theme_Support { | ||
|
||
/** | ||
* The currently active theme | ||
* | ||
* @var string | ||
*/ | ||
private $theme; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() { | ||
$this->theme = get_template(); | ||
|
||
$this->include_support(); | ||
} | ||
|
||
/** | ||
* Include supported theme compatibility | ||
* | ||
* @return void | ||
*/ | ||
private function include_support() { | ||
switch ( $this->theme ) { | ||
case 'storefront': | ||
require_once __DIR__ . '/theme-support/class-' . $this->theme . '.php'; | ||
break; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/** | ||
* Storefront Theme Support | ||
* | ||
* @see https://woocommerce.com/storefront/ | ||
* | ||
* @since 3.0 | ||
*/ | ||
class Dokan_Theme_Support_Storefront { | ||
|
||
/** | ||
* The constructor | ||
*/ | ||
function __construct() { | ||
add_action( 'storefront_page_after', [ $this, 'remove_sidebar'], 5 ); | ||
add_filter( 'body_class', [ $this, 'full_width_page'] ); | ||
} | ||
|
||
/** | ||
* Remove sidebar from store and dashboard page | ||
* | ||
* @return void | ||
*/ | ||
public function remove_sidebar() { | ||
if ( dokan_is_store_page() || dokan_is_seller_dashboard() ) { | ||
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 ); | ||
} | ||
} | ||
|
||
/** | ||
* Makes the store and dashboard page full width | ||
* | ||
* @param array $classes | ||
* | ||
* @return array | ||
*/ | ||
public function full_width_page( $classes ) { | ||
|
||
if ( dokan_is_store_page() || dokan_is_seller_dashboard() ) { | ||
|
||
if ( ! in_array( 'page-template-template-fullwidth-php', $classes ) ) { | ||
$classes[] = 'page-template-template-fullwidth-php'; | ||
} | ||
} | ||
|
||
return $classes; | ||
} | ||
} | ||
|
||
return new Dokan_Theme_Support_Storefront(); |