Skip to content

Commit

Permalink
Addressing #751 page builder shop
Browse files Browse the repository at this point in the history
  • Loading branch information
shramee committed Nov 30, 2019
1 parent bc1eb77 commit 4ca9102
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ppbpro/inc/ext/woocommerce/class-ppb-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private function __construct( $file ) {

add_action( 'init', array( $this, 'init' ) );
add_action( 'admin_init', array( $this, 'check_ppb_version' ) );

} // End __construct()

/**
Expand Down Expand Up @@ -140,6 +141,9 @@ private function _admin() {
add_filter( 'pootlepb_content_block_fields', array( $this->admin, 'content_block_fields' ) );
//Add our awesome stuff
add_action( 'pootlepb_content_block_wc_prods_tab_after_fields', array( $this->admin, 'wc_required_notice' ) );
// Adds shop replace setting
add_action( 'admin_init', array( $this->admin, 'admin_init' ) );


}

Expand All @@ -157,6 +161,8 @@ private function _public() {
add_filter( 'woocommerce_tab_manager_tab_panel_content', array( $this->public, 'wc_tabs_filter' ), 7, 3 );
//Add the products to content block
add_action( 'pootlepb_render_content_block', array( $this->public, 'render_products' ), 52 );
// Process PPB shop page
add_action( 'woocommerce_archive_description', array( $this->public, 'maybe_clear_shop_content' ), 99 );

} // End enqueue()

Expand Down
16 changes: 15 additions & 1 deletion ppbpro/inc/ext/woocommerce/inc/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class pootle_page_builder_for_WooCommerce_Admin{
/**
* Main Pootle Slider Instance
* Ensures only one instance of Storefront_Extension_Boilerplate is loaded or can be loaded.
* @return pootle_page_builder_for_WooCommerce instance
* @return self instance
* @since 1.0.0
*/
public static function instance() {
Expand Down Expand Up @@ -305,4 +305,18 @@ public function wc_required_notice() {
return;
}
}

public function admin_init() {
register_setting( 'pootlepage-display', 'ppb_wc_shop' );
add_settings_field( 'ppb_wc_shop', __( 'Enable Page Builder Shop', 'ppb-panels' ), [ $this, 'render_shop_field' ], 'pootlepage-display', 'display' );
}

public function render_shop_field() {
?>
<label>
<input type="checkbox" name="ppb_wc_shop" id="ppb_wc_shop" <?php checked( get_option( 'ppb_wc_shop' ) ) ?> value="1"/>
<?php _e( 'Enabled', 'ppb-panels' ) ?>
</label>
<?php
}
}
29 changes: 27 additions & 2 deletions ppbpro/inc/ext/woocommerce/inc/class-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @property string $path Plugin root dir path
* @property string $version Plugin version
*/
class pootle_page_builder_for_WooCommerce_Public{
class pootle_page_builder_for_WooCommerce_Public {

private $i = 1;
private $id = '';
Expand All @@ -33,7 +33,7 @@ class pootle_page_builder_for_WooCommerce_Public{
* Main Pootle Slider Instance
* Ensures only one instance of Storefront_Extension_Boilerplate is loaded or can be loaded.
* @since 1.0.0
* @return pootle_page_builder_for_WooCommerce instance
* @return self instance
*/
public static function instance() {
if ( null == self::$_instance ) {
Expand Down Expand Up @@ -68,6 +68,31 @@ public function enqueue() {
wp_enqueue_script( 'owl-carousel-js', 'https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js', array( 'jquery' ) );
} // End enqueue()

public function maybe_clear_shop_content() {
// @TODO check if shop page uses ppb
if ( get_option( 'ppb_wc_shop' ) && is_shop() ) {
?>
<style>
.woocommerce-products-header {
padding: 0 !important;
}
.woocommerce-products-header ~ * {
display: none;
}
</style>
<?php
$GLOBALS['woocommerce_loop']['total'] = 0;
remove_all_actions( 'woocommerce_before_main_content' );
remove_all_actions( 'woocommerce_archive_description' );
remove_all_actions( 'woocommerce_before_shop_loop' );
remove_all_actions( 'woocommerce_shop_loop' );
remove_all_actions( 'woocommerce_after_shop_loop' );
remove_all_actions( 'woocommerce_no_products_found' );
remove_all_actions( 'woocommerce_after_main_content' );
remove_all_actions( 'woocommerce_sidebar' );
}
}

/**
* Handles the rendering of the tabs
* @param $tab_content
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Author URI: http://www.pootlepress.com
Author: PootlePress
Donate link:
Requires at least: 4.1.0
Tested up to: 5.0.0
Tested up to: 5.3.0
Stable tag: 5.5.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -133,7 +133,7 @@ We encourage everyone to contribute their ideas, thoughts and code snippets. Thi
5. Row display settings / Background video

6. Row display settings / Layout

t
7. Modules

8. WooCommerce module (pro version only)
Expand Down

0 comments on commit 4ca9102

Please sign in to comment.