Skip to content

Commit

Permalink
Merge pull request #2823 from woocommerce/release/3.3.0
Browse files Browse the repository at this point in the history
Release/3.3.0
  • Loading branch information
layoutd authored Nov 7, 2024
2 parents 01a358c + d3ecc1e commit 93ac576
Show file tree
Hide file tree
Showing 16 changed files with 189 additions and 48 deletions.
5 changes: 5 additions & 0 deletions assets/css/admin/facebook-for-woocommerce-connection.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
background-image: url( '../../images/icon-2.png' );
}

#wc-facebook-connection-box .actions {
display: flex;
align-items: center;
}

#wc-facebook-connection-box .button {
color: rgb( 5, 5, 5 );
background-color: rgb( 228, 230, 235 );
Expand Down
6 changes: 6 additions & 0 deletions assets/css/facebook.css
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,9 @@
div#message:has(a[href*="facebook_messenger_deprecation_warning"]) {
border-left-color: #dba617 !important;
}

#mainform .actions{
display: flex;
max-width: 635px;
flex-direction: column;
}
4 changes: 2 additions & 2 deletions assets/js/admin/products-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,12 @@ jQuery( document ).ready( function( $ ) {
$container.find( `.show-if-product-image-source-${imageSource}` ).closest( '.form-field' ).show();
} );

$( '.js-fb-product-image-source:checked:visible' ).trigger( 'change' );
$( '.js-fb-product-image-source:checked' ).trigger( 'change' );

// trigger settings fields modifiers when variations are loaded
$productData.on( 'woocommerce_variations_loaded', function() {
$( '.js-variable-fb-sync-toggle:visible' ).trigger( 'change' );
$( '.js-fb-product-image-source:checked:visible' ).trigger( 'change' );
$( '.js-fb-product-image-source:checked' ).trigger( 'change' );
$( '.variable_is_virtual:visible' ).trigger( 'change' );
} );

Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
*** Facebook for WooCommerce Changelog ***

= 3.3.0 - 2024-11-07 =
* Add - Extension navigation tabs on Product Sets screens.
* Tweak - Tooltips, config labels, documentation links.
* Tweak - WC 9.4 compatibility.
* Tweak - WP 6.7 compatibility.

= 3.2.10 - 2024-09-30 =
* Update - Remove Marketing Products Sets menu entry.

Expand Down
2 changes: 1 addition & 1 deletion class-wc-facebookcommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public function register_custom_taxonomy() {
// translators: No items found text
'not_found' => sprintf( esc_html__( 'No %s found.', 'facebook-for-woocommerce' ), $plural ),
// translators: Search label
'search_items' => sprintf( esc_html__( 'Search %s.', 'facebook-for-woocommerce' ), $plural ),
'search_items' => sprintf( esc_html__( 'Search %s', 'facebook-for-woocommerce' ), $plural ),
// translators: Text label
'separate_items_with_commas' => sprintf( esc_html__( 'Separate %s with commas', 'facebook-for-woocommerce' ), $plural ),
// translators: Text label
Expand Down
8 changes: 4 additions & 4 deletions facebook-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
* Description: Grow your business on Facebook! Use this official plugin to help sell more of your products using Facebook. After completing the setup, you'll be ready to create ads that promote your products and you can also create a shop section on your Page where customers can browse your products on Facebook.
* Author: Facebook
* Author URI: https://www.facebook.com/
* Version: 3.2.10
* Version: 3.3.0
* Requires at least: 5.6
* Requires PHP: 7.4
* Text Domain: facebook-for-woocommerce
* Requires Plugins: woocommerce
* Tested up to: 6.6
* Tested up to: 6.7
* WC requires at least: 6.4
* WC tested up to: 9.3
* WC tested up to: 9.4
*
* @package FacebookCommerce
*/
Expand Down Expand Up @@ -49,7 +49,7 @@ class WC_Facebook_Loader {
/**
* @var string the plugin version. This must be in the main plugin file to be automatically bumped by Woorelease.
*/
const PLUGIN_VERSION = '3.2.10'; // WRCS: DEFINED_VERSION.
const PLUGIN_VERSION = '3.3.0'; // WRCS: DEFINED_VERSION.

// Minimum PHP version required by this plugin.
const MINIMUM_PHP_VERSION = '7.4.0';
Expand Down
20 changes: 14 additions & 6 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function enqueue_scripts() {
array(
'i18n' => array(
'top_level_dropdown_placeholder' => __( 'Search main categories...', 'facebook-for-woocommerce' ),
'second_level_empty_dropdown_placeholder' => __( 'Choose a main category', 'facebook-for-woocommerce' ),
'second_level_empty_dropdown_placeholder' => __( 'Choose a main category first', 'facebook-for-woocommerce' ),
'general_dropdown_placeholder' => __( 'Choose a category', 'facebook-for-woocommerce' ),
),
)
Expand Down Expand Up @@ -1201,13 +1201,15 @@ public function add_product_settings_tab_content() {
woocommerce_wp_select(
array(
'id' => 'wc_facebook_sync_mode',
'label' => __( 'Facebook sync', 'facebook-for-woocommerce' ),
'label' => __( 'Facebook Sync', 'facebook-for-woocommerce' ),
'options' => array(
self::SYNC_MODE_SYNC_AND_SHOW => __( 'Sync and show in catalog', 'facebook-for-woocommerce' ),
self::SYNC_MODE_SYNC_AND_HIDE => __( 'Sync and hide in catalog', 'facebook-for-woocommerce' ),
self::SYNC_MODE_SYNC_DISABLED => __( 'Do not sync', 'facebook-for-woocommerce' ),
),
'value' => $sync_mode,
'value' => $sync_mode,
'desc_tip' => true,
'description' => __( 'Choose whether to sync this product to Facebook and, if synced, whether it should be visible in the catalog.', 'facebook-for-woocommerce' ),
)
);

Expand All @@ -1229,7 +1231,7 @@ public function add_product_settings_tab_content() {
'id' => 'fb_product_image_source',
'label' => __( 'Facebook Product Image', 'facebook-for-woocommerce' ),
'desc_tip' => true,
'description' => __( 'Choose the product image that should be synced to the Facebook catalog for this product. If using a custom image, please enter an absolute URL (e.g. https://domain.com/image.jpg).', 'facebook-for-woocommerce' ),
'description' => __( 'Choose the product image that should be synced to the Facebook catalog and displayed for this product.', 'facebook-for-woocommerce' ),
'options' => array(
Products::PRODUCT_IMAGE_SOURCE_PRODUCT => __( 'Use WooCommerce image', 'facebook-for-woocommerce' ),
Products::PRODUCT_IMAGE_SOURCE_CUSTOM => __( 'Use custom image', 'facebook-for-woocommerce' ),
Expand All @@ -1246,6 +1248,8 @@ public function add_product_settings_tab_content() {
'label' => __( 'Custom Image URL', 'facebook-for-woocommerce' ),
'value' => $image,
'class' => sprintf( 'enable-if-sync-enabled product-image-source-field show-if-product-image-source-%s', Products::PRODUCT_IMAGE_SOURCE_CUSTOM ),
'desc_tip' => true,
'description' => __( 'Please enter an absolute URL (e.g. https://domain.com/image.jpg).', 'facebook-for-woocommerce' ),
)
);

Expand Down Expand Up @@ -1337,13 +1341,15 @@ public function add_product_variation_edit_fields( $index, $variation_data, $pos
array(
'id' => "variable_facebook_sync_mode$index",
'name' => "variable_facebook_sync_mode[$index]",
'label' => __( 'Facebook sync', 'facebook-for-woocommerce' ),
'label' => __( 'Facebook Sync', 'facebook-for-woocommerce' ),
'options' => array(
self::SYNC_MODE_SYNC_AND_SHOW => __( 'Sync and show in catalog', 'facebook-for-woocommerce' ),
self::SYNC_MODE_SYNC_AND_HIDE => __( 'Sync and hide in catalog', 'facebook-for-woocommerce' ),
self::SYNC_MODE_SYNC_DISABLED => __( 'Do not sync', 'facebook-for-woocommerce' ),
),
'value' => $sync_mode,
'desc_tip' => true,
'description' => __( 'Choose whether to sync this product to Facebook and, if synced, whether it should be visible in the catalog.', 'facebook-for-woocommerce' ),
'class' => 'js-variable-fb-sync-toggle',
'wrapper_class' => 'form-row form-row-full',
)
Expand All @@ -1370,7 +1376,7 @@ public function add_product_variation_edit_fields( $index, $variation_data, $pos
'name' => "variable_fb_product_image_source[$index]",
'label' => __( 'Facebook Product Image', 'facebook-for-woocommerce' ),
'desc_tip' => true,
'description' => __( 'Choose the product image that should be synced to the Facebook catalog for this product. If using a custom image, please enter an absolute URL (e.g. https://domain.com/image.jpg).', 'facebook-for-woocommerce' ),
'description' => __( 'Choose the product image that should be synced to the Facebook catalog and displayed for this product.', 'facebook-for-woocommerce' ),
'options' => array(
Products::PRODUCT_IMAGE_SOURCE_PRODUCT => __( 'Use variation image', 'facebook-for-woocommerce' ),
Products::PRODUCT_IMAGE_SOURCE_PARENT_PRODUCT => __( 'Use parent image', 'facebook-for-woocommerce' ),
Expand All @@ -1390,6 +1396,8 @@ public function add_product_variation_edit_fields( $index, $variation_data, $pos
'value' => $image_url,
'class' => sprintf( 'enable-if-sync-enabled product-image-source-field show-if-product-image-source-%s', Products::PRODUCT_IMAGE_SOURCE_CUSTOM ),
'wrapper_class' => 'form-row form-row-full',
'desc_tip' => true,
'description' => __( 'Please enter an absolute URL (e.g. https://domain.com/image.jpg).', 'facebook-for-woocommerce' ),
)
);

Expand Down
34 changes: 31 additions & 3 deletions includes/Admin/Abstract_Settings_Screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ abstract class Abstract_Settings_Screen {
/** @var string screen description, for display */
protected $description;

/** @var string documentation URL for the more information link */
protected $documentation_url;


/**
* Renders the screen.
Expand Down Expand Up @@ -68,16 +71,41 @@ public function render() {
<?php woocommerce_admin_fields( $settings ); ?>

<?php if ( $is_connected ) : ?>
<input type="hidden" name="screen_id" value="<?php echo esc_attr( $this->get_id() ); ?>">
<?php wp_nonce_field( 'wc_facebook_admin_save_' . $this->get_id() . '_settings' ); ?>
<?php submit_button( __( 'Save changes', 'facebook-for-woocommerce' ), 'primary', 'save_' . $this->get_id() . '_settings' ); ?>
<div class="actions">
<input type="hidden" name="screen_id" value="<?php echo esc_attr( $this->get_id() ); ?>">
<?php wp_nonce_field( 'wc_facebook_admin_save_' . $this->get_id() . '_settings' ); ?>
<?php submit_button( __( 'Save changes', 'facebook-for-woocommerce' ), 'primary', 'save_' . $this->get_id() . '_settings' ); ?>
<?php $this->maybe_render_learn_more_link( $this->get_label() ); ?>
</div>
<?php endif; ?>

</form>

<?php
}

/**
* Renders the learn more link if the documentation URL is set.
*
* @param string $screen_label The screen label/title, translated.
*
* @since 3.3.0
*/
protected function maybe_render_learn_more_link( $screen_label ) {
if ( $this->documentation_url ) :
?>
<span class="learn-more-link"><a href="<?php echo esc_url( $this->documentation_url ); ?>" class="" target="_blank">
<?php
/*
* Translators: %s Settings screen label/title, in lowercase.
*/
echo esc_html( sprintf( __( 'Learn more about %s', 'facebook-for-woocommerce' ), strtolower( $screen_label ) ) );
?>
</a></span>
<?php
endif;
}


/**
* Saves the settings.
Expand Down
2 changes: 1 addition & 1 deletion includes/Admin/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function render_google_product_category_fields( \WC_Product $produ
?>
<p class="form-field">
<label for="<?php echo esc_attr( self::FIELD_GOOGLE_PRODUCT_CATEGORY_ID ); ?>">
<?php esc_html_e( 'Google product category', 'facebook-for-woocommerce' ); ?>
<?php esc_html_e( 'Google Product Category', 'facebook-for-woocommerce' ); ?>
<?php echo wc_help_tip( __( 'Choose the Google product category and (optionally) sub-categories associated with this product.', 'facebook-for-woocommerce' ) ); ?>
</label>
<input
Expand Down
96 changes: 84 additions & 12 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use WooCommerce\Facebook\Admin\Settings_Screens;
use WooCommerce\Facebook\Admin\Settings_Screens\Connection;
use WooCommerce\Facebook\Framework\Helper;
use WooCommerce\Facebook\Framework\Plugin\Compatibility;
use WooCommerce\Facebook\Framework\Plugin\Exception as PluginException;

defined( 'ABSPATH' ) || exit;
Expand Down Expand Up @@ -52,6 +51,8 @@ public function __construct( bool $is_connected ) {
add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
add_action( 'wp_loaded', array( $this, 'save' ) );
add_filter( 'parent_file', array( $this, 'set_parent_and_submenu_file' ) );

add_action( 'all_admin_notices', array( $this, 'add_tabs_to_product_sets_taxonomy' ) );
}

/**
Expand Down Expand Up @@ -191,19 +192,11 @@ private function connect_to_enhanced_admin( $screen_id ) {
* @since 2.0.0
*/
public function render() {
$tabs = $this->get_tabs();
$current_tab = Helper::get_requested_value( 'tab' );
if ( ! $current_tab ) {
$current_tab = current( array_keys( $tabs ) );
}
$screen = $this->get_screen( $current_tab );
$current_tab = $this->get_current_tab();
$screen = $this->get_screen( $current_tab );
?>
<div class="wrap woocommerce">
<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 $this->render_tabs( $current_tab ); ?>
<?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 All @@ -214,6 +207,40 @@ public function render() {
<?php
}

/**
* Render the Facebook for WooCommerce extension navigation tabs.
*
* @since 3.3.0
*
* @param string $current_tab The current tab ID.
*/
public function render_tabs( $current_tab ) {
$tabs = $this->get_tabs();
?>
<nav class="nav-tab-wrapper woo-nav-tab-wrapper facebook-for-woocommerce-tabs">
<?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
}

/**
* Get the current tab ID.
*
* @since 3.3.0
*
* @return string
*/
protected function get_current_tab() {
$tabs = $this->get_tabs();
$current_tab = Helper::get_requested_value( 'tab' );
if ( ! $current_tab ) {
$current_tab = current( array_keys( $tabs ) );
}
return $current_tab;
}


/**
* Saves the settings page.
Expand Down Expand Up @@ -312,4 +339,49 @@ public function get_tabs() {
*/
return (array) apply_filters( 'wc_facebook_admin_settings_tabs', $tabs, $this );
}

/**
* Add the Facebook for WooCommerce tabs to the Facebook Product Set taxonomy page.
* Renders the tabs (hidden by default) at the stop of the page,
* then moves them to the correct DOM location with JavaScript and displays them.
*
* @since 3.3.0
*/
public function add_tabs_to_product_sets_taxonomy() {

// Only load this on the edit-tags.php page
$screen = get_current_screen();
$is_taxonomy_list_page = 'edit-tags' === $screen->base;
$is_taxonomy_term_page = 'term' === $screen->base;
$is_taxonomy_page = $is_taxonomy_list_page || $is_taxonomy_term_page;
$is_product_set_taxonomy = 'fb_product_set' === $screen->taxonomy && $is_taxonomy_page;

if ( $is_product_set_taxonomy ) {
$this->render_tabs( Settings_Screens\Product_Sets::ID );
?>
<style>
.facebook-for-woocommerce-tabs {
margin: 30px 20px 0 20px;
}
#wpbody-content > .wrap > h1 {
font-size: 1.3em;
font-weight: 600;
}

@media (max-width: 782px) {
.facebook-for-woocommerce-tabs {
padding-top: 19px;
margin-bottom: -1px;
}
.edit-tags-php .facebook-for-woocommerce-tabs {
clear: both;
padding-top: 0;
position: relative;
top: -10px;
margin-bottom: -11px;
}
</style>
<?php
}
}
}
6 changes: 4 additions & 2 deletions includes/Admin/Settings_Screens/Advertise.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class Advertise extends Abstract_Settings_Screen {
*/
public function __construct() {
$this->id = self::ID;
$this->label = __( 'Advertise', 'facebook-for-woocommerce' );
$this->title = __( 'Advertise', 'facebook-for-woocommerce' );
$this->label = __( 'Advertise', 'facebook-for-woocommerce' );
$this->title = __( 'Advertise', 'facebook-for-woocommerce' );
$this->documentation_url = 'https://woocommerce.com/document/facebook-for-woocommerce/#how-to-create-ads-on-facebook';

$this->add_hooks();
}
Expand Down Expand Up @@ -216,6 +217,7 @@ class="fb-lwi-ads-insights"
data-fbe-scopes="manage_business_extension"
data-fbe-redirect-uri="https://mariner9.s3.amazonaws.com/"></div>
<?php
$this->maybe_render_learn_more_link( __( 'Advertising', 'facebook-for-woocommerce' ) );

parent::render();
}
Expand Down
Loading

0 comments on commit 93ac576

Please sign in to comment.