Skip to content

Commit

Permalink
Removes WooCommerce navigation items (#2800)
Browse files Browse the repository at this point in the history
* Removes WooCommerce navigation code
* Removes Navigation class import
  • Loading branch information
ibndawood authored Sep 9, 2024
1 parent 4a56dd9 commit b3270f9
Showing 1 changed file with 6 additions and 53 deletions.
59 changes: 6 additions & 53 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace WooCommerce\Facebook\Admin;

use Automattic\WooCommerce\Admin\Features\Features as WooAdminFeatures;
use Automattic\WooCommerce\Admin\Features\Navigation\Menu as WooAdminMenu;
use WooCommerce\Facebook\Admin\Settings_Screens;
use WooCommerce\Facebook\Admin\Settings_Screens\Connection;
use WooCommerce\Facebook\Framework\Helper;
Expand Down Expand Up @@ -40,13 +39,6 @@ class Settings {
/** @var Abstract_Settings_Screen[] */
private $screens;

/**
* Whether the new Woo nav should be used.
*
* @var bool
*/
public $use_woo_nav;

/**
* Settings constructor.
*
Expand Down Expand Up @@ -91,9 +83,7 @@ private function build_menu_item_array( bool $is_connected ): array {
public function add_menu_item() {
$root_menu_item = 'woocommerce';
$is_marketing_enabled = false;
$this->use_woo_nav = class_exists( WooAdminFeatures::class )
&& class_exists( WooAdminMenu::class )
&& WooAdminFeatures::is_enabled( 'navigation' );

if ( Compatibility::is_enhanced_admin_available() ) {
if ( class_exists( WooAdminFeatures::class ) ) {
$is_marketing_enabled = WooAdminFeatures::is_enabled( 'marketing' );
Expand All @@ -115,7 +105,6 @@ public function add_menu_item() {
5
);
$this->connect_to_enhanced_admin( $is_marketing_enabled ? 'marketing_page_wc-facebook' : 'woocommerce_page_wc-facebook' );
$this->register_woo_nav_menu_items();

if ( $is_marketing_enabled ) {
$this->add_fb_product_sets_to_marketing_menu();
Expand Down Expand Up @@ -218,13 +207,11 @@ public function render() {
$screen = $this->get_screen( $current_tab );
?>
<div class="wrap woocommerce">
<?php if ( ! $this->use_woo_nav ) : ?>
<nav class="nav-tab-wrapper woo-nav-tab-wrapper">
<?php foreach ( $tabs as $id => $label ) : ?>
<a href="<?php echo esc_html( admin_url( 'admin.php?page=' . self::PAGE_ID . '&tab=' . esc_attr( $id ) ) ); ?>" class="nav-tab <?php echo $current_tab === $id ? 'nav-tab-active' : ''; ?>"><?php echo esc_html( $label ); ?></a>
<?php endforeach; ?>
</nav>
<?php endif; ?>
<nav class="nav-tab-wrapper woo-nav-tab-wrapper">
<?php foreach ( $tabs as $id => $label ) : ?>
<a href="<?php echo esc_html( admin_url( 'admin.php?page=' . self::PAGE_ID . '&tab=' . esc_attr( $id ) ) ); ?>" class="nav-tab <?php echo $current_tab === $id ? 'nav-tab-active' : ''; ?>"><?php echo esc_html( $label ); ?></a>
<?php endforeach; ?>
</nav>
<?php facebook_for_woocommerce()->get_message_handler()->show_messages(); ?>
<?php if ( $screen ) : ?>
<h1 class="screen-reader-text"><?php echo esc_html( $screen->get_title() ); ?></h1>
Expand Down Expand Up @@ -333,38 +320,4 @@ public function get_tabs() {
*/
return (array) apply_filters( 'wc_facebook_admin_settings_tabs', $tabs, $this );
}

/**
* Register nav items for new Woo nav.
*
* @since 2.3.3
*/
private function register_woo_nav_menu_items() {
if ( ! $this->use_woo_nav ) {
return;
}
WooAdminMenu::add_plugin_category(
array(
'id' => 'facebook-for-woocommerce',
'title' => __( 'Facebook', 'facebook-for-woocommerce' ),
'capability' => 'manage_woocommerce',
)
);
$order = 1;
foreach ( $this->get_screens() as $screen_id => $screen ) {
$url = $screen instanceof Settings_Screens\Product_Sets
? 'edit-tags.php?taxonomy=fb_product_set&post_type=product'
: 'wc-facebook&tab=' . $screen->get_id();
WooAdminMenu::add_plugin_item(
array(
'id' => 'facebook-for-woocommerce-' . $screen->get_id(),
'parent' => 'facebook-for-woocommerce',
'title' => $screen->get_label(),
'url' => $url,
'order' => $order,
)
);
++$order;
}
}
}

0 comments on commit b3270f9

Please sign in to comment.