rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -250,6 +250,21 @@ class WC_Meta_Box_Order_Data {
?>
</p>
<?php
/**
* Hook allowing extenders to render custom content
* within the Order details box.
*
* This allows urgent notices or other important
* order-related info to be displayed upfront in
* the order page. Example: display a notice if
* the order is disputed.
*
* @param $order WC_Order The order object being displayed.
* @since 7.9.0
*/
do_action( 'woocommerce_admin_order_data_after_payment_info', $order );
?>
<div class="order_data_column_container">
<div class="order_data_column">
<h3><?php esc_html_e( 'General', 'woocommerce' ); ?></h3>

View File

@@ -0,0 +1,73 @@
<?php
/**
* Product Categories meta box
*
* Display the product categories meta box.
*
* @package WooCommerce\Admin\Meta Boxes
* @version 7.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* WC_Meta_Box_Product_Categories Class.
*/
class WC_Meta_Box_Product_Categories {
/**
* Output the metabox.
*
* @param WP_Post $post Current post object.
* @param array $box {
* Categories meta box arguments.
*
* @type string $id Meta box 'id' attribute.
* @type string $title Meta box title.
* @type callable $callback Meta box display callback.
* @type array $args {
* Extra meta box arguments.
*
* @type string $taxonomy Taxonomy. Default 'category'.
* }
* }
*/
public static function output( $post, $box ) {
$categories_count = (int) wp_count_terms( 'product_cat' );
/**
* Filters the category metabox search threshold, for when to render the typeahead field.
*
* @since 7.6.0
*
* @param number $threshold The default threshold.
* @returns number The threshold that will be used.
*/
if ( $categories_count <= apply_filters( 'woocommerce_product_category_metabox_search_threshold', 100 ) && function_exists( 'post_categories_meta_box' ) ) {
return post_categories_meta_box( $post, $box );
}
$defaults = array( 'taxonomy' => 'category' );
if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
$args = array();
} else {
$args = $box['args'];
}
$parsed_args = wp_parse_args( $args, $defaults );
$tax_name = $parsed_args['taxonomy'];
$selected_categories = wp_get_object_terms( $post->ID, 'product_cat' );
?>
<div id="taxonomy-<?php echo esc_attr( $tax_name ); ?>-metabox"></div>
<?php foreach ( (array) $selected_categories as $term ) { ?>
<input
type="hidden"
value="<?php echo esc_attr( $term->term_id ); ?>"
name="tax_input[<?php esc_attr( $tax_name ); ?>][]"
data-name="<?php echo esc_attr( $term->name ); ?>"
/>
<?php
}
}
}

View File

@@ -56,22 +56,7 @@ class WC_Meta_Box_Product_Data {
/* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
return apply_filters(
'product_type_options',
array(
'virtual' => array(
'id' => '_virtual',
'wrapper_class' => 'show_if_simple',
'label' => __( 'Virtual', 'woocommerce' ),
'description' => __( 'Virtual products are intangible and are not shipped.', 'woocommerce' ),
'default' => 'no',
),
'downloadable' => array(
'id' => '_downloadable',
'wrapper_class' => 'show_if_simple',
'label' => __( 'Downloadable', 'woocommerce' ),
'description' => __( 'Downloadable products give access to a file upon purchase.', 'woocommerce' ),
'default' => 'no',
),
)
wc_get_default_product_type_options(),
);
/* phpcs: enable */
}
@@ -186,14 +171,12 @@ class WC_Meta_Box_Product_Data {
global $post, $wpdb, $product_object;
/* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
$global_attributes_count = count( wc_get_attribute_taxonomies() );
$variation_attributes = array_filter( $product_object->get_attributes(), array( __CLASS__, 'filter_variation_attributes' ) );
$non_variation_attributes_count = count( array_filter( $product_object->get_attributes(), array( __CLASS__, 'filter_non_variation_attributes' ) ) );
$default_attributes = $product_object->get_default_attributes();
$variations_count = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_count', $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status IN ('publish', 'private')", $post->ID ) ), $post->ID ) );
$variations_per_page = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) );
$variations_total_pages = ceil( $variations_count / $variations_per_page );
$modal_title = get_bloginfo( 'name' ) . __( ' says', 'woocommerce' );
$variation_attributes = array_filter( $product_object->get_attributes(), array( __CLASS__, 'filter_variation_attributes' ) );
$default_attributes = $product_object->get_default_attributes();
$variations_count = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_count', $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status IN ('publish', 'private')", $post->ID ) ), $post->ID ) );
$variations_per_page = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) );
$variations_total_pages = ceil( $variations_count / $variations_per_page );
$modal_title = get_bloginfo( 'name' ) . __( ' says', 'woocommerce' );
/* phpcs: enable */
include __DIR__ . '/views/html-product-data-variations.php';

View File

@@ -93,28 +93,19 @@ if ( ! defined( 'ABSPATH' ) ) {
<tr>
<td>
<div class="enable_variation show_if_variable">
<label><input type="checkbox" class="woocommerce_attribute_used_for_variations checkbox" <?php checked( $attribute->get_variation(), true ); ?> <?php echo esc_attr( isset( $is_variations_screen ) ? 'disabled' : '' ); ?> name="attribute_variation[<?php echo esc_attr( $i ); ?>]" value="1" /> <?php esc_html_e( 'Used for variations', 'woocommerce' ); ?></label>
<?php
if ( isset( $is_variations_screen ) ) {
?>
<input type="hidden" name="attribute_variation[<?php echo esc_attr( $i ); ?>]" value="1" />
<?php
}
?>
<label><input type="checkbox" class="woocommerce_attribute_used_for_variations checkbox" <?php checked( $attribute->get_variation(), true ); ?> name="attribute_variation[<?php echo esc_attr( $i ); ?>]" value="1" /> <?php esc_html_e( 'Used for variations', 'woocommerce' ); ?></label>
</div>
</td>
</tr>
<?php
if ( ! isset( $is_variations_screen ) ) {
/**
* Hook to display custom attribute terms.
*
* @since 3.4.0
* @param WC_Product_Attribute $attribute Attribute object.
* @param number $i Attribute index.
*/
do_action( 'woocommerce_after_product_attribute_settings', $attribute, $i );
}
/**
* Hook to display custom attribute terms.
*
* @since 3.4.0
* @param WC_Product_Attribute $attribute Attribute object.
* @param number $i Attribute index.
*/
do_action( 'woocommerce_after_product_attribute_settings', $attribute, $i );
?>
</tbody>
</table>

View File

@@ -13,78 +13,27 @@ global $wc_product_attributes;
// Array of defined attribute taxonomies.
$attribute_taxonomies = wc_get_attribute_taxonomies();
// Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set.
$product_attributes = $product_object->get_attributes( 'edit' );
$has_local_attributes = empty( $attribute_taxonomies );
$has_global_attributes = empty( $product_attributes );
$is_add_global_attribute_visible = ! $has_local_attributes && $has_global_attributes;
$icon_url = WC_ADMIN_IMAGES_FOLDER_URL . '/icons/global-attributes-icon.svg';
$product_attributes = $product_object->get_attributes( 'edit' );
?>
<div id="product_attributes" class="panel wc-metaboxes-wrapper hidden">
<div class="toolbar toolbar-top <?php echo $is_add_global_attribute_visible ? ' expand-close-hidden' : ''; ?>">
<div class="add-global-attribute-container<?php echo $is_add_global_attribute_visible ? '' : ' hidden'; ?>">
<div class="actions">
<button type="button" class="button add_custom_attribute"><?php esc_html_e( 'Add new', 'woocommerce' ); ?></button>
<select class="wc-attribute-search" data-placeholder="<?php esc_attr_e( 'Add existing', 'woocommerce' ); ?>" data-minimum-input-length="0">
</select>
</div>
<div class="message">
<img src="<?php echo esc_url( $icon_url ); ?>" />
<p>
<?php
esc_html_e(
'Add descriptive pieces of information that customers can use to search for this product on your store, such as “Material” or “Brand”.',
'woocommerce'
);
?>
</p>
</div>
</div>
<div class="add-attribute-container<?php echo $is_add_global_attribute_visible ? ' hidden' : ' '; ?>">
<?php
if ( $has_local_attributes && $has_global_attributes ) :
?>
<div id="message" class="inline notice woocommerce-message">
<p>
<?php
esc_html_e(
'Add descriptive pieces of information that customers can use to search for this product on your store, such as “Material” or “Brand”.',
'woocommerce'
);
?>
</p>
</div>
<?php endif; ?>
<span class="expand-close">
<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>
</span>
<?php
/**
* Filter for the attribute taxonomy filter dropdown threshold.
*
* @since 7.0.0
* @param number $threshold The threshold for showing the simple dropdown.
*/
if ( count( $attribute_taxonomies ) <= apply_filters( 'woocommerce_attribute_taxonomy_filter_threshold', 20 ) ) :
?>
<select name="attribute_taxonomy" class="attribute_taxonomy">
<option value=""><?php esc_html_e( 'Custom product attribute', 'woocommerce' ); ?></option>
<div class="toolbar toolbar-top">
<div id="message" class="inline notice woocommerce-message">
<p>
<?php
if ( ! $has_local_attributes ) {
foreach ( $attribute_taxonomies as $attr_taxonomy ) {
$attribute_taxonomy_name = wc_attribute_taxonomy_name( $attr_taxonomy->attribute_name );
$label = $attr_taxonomy->attribute_label ? $attr_taxonomy->attribute_label : $attr_taxonomy->attribute_name;
echo '<option value="' . esc_attr( $attribute_taxonomy_name ) . '">' . esc_html( $label ) . '</option>';
}
}
esc_html_e(
'Add descriptive pieces of information that customers can use to search for this product on your store, such as “Material” or “Brand”.',
'woocommerce'
);
?>
</p>
</div>
<span class="expand-close">
<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>
</span>
<div class="actions">
<button type="button" class="button add_custom_attribute"><?php esc_html_e( 'Add new', 'woocommerce' ); ?></button>
<select class="wc-attribute-search" data-placeholder="<?php esc_attr_e( 'Add existing', 'woocommerce' ); ?>" data-minimum-input-length="0">
</select>
<button type="button" class="button add_attribute"><?php esc_html_e( 'Add', 'woocommerce' ); ?></button>
<?php else : ?>
<button type="button" class="button add_custom_attribute"><?php esc_html_e( 'Add custom attribute', 'woocommerce' ); ?></button>
<select class="wc-attribute-search attribute_taxonomy" id="attribute_taxonomy" name="attribute_taxonomy" data-placeholder="<?php esc_attr_e( 'Add existing attribute', 'woocommerce' ); ?>" data-minimum-input-length="0">
</select>
<?php endif; ?>
</div>
</div>
<div class="product_attributes wc-metaboxes">
@@ -104,7 +53,7 @@ $icon_url = WC_ADMIN_IMAGES_FOLDER_URL . '/icons/global-a
}
?>
</div>
<div class="toolbar toolbar-buttons<?php echo $is_add_global_attribute_visible ? ' hidden' : ''; ?>">
<div class="toolbar toolbar-buttons">
<span class="expand-close">
<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>
</span>

View File

@@ -93,7 +93,7 @@ defined( 'ABSPATH' ) || exit;
if ( $downloadable_files ) {
foreach ( $downloadable_files as $key => $file ) {
$disabled_download = isset( $file['enabled'] ) && false === $file['enabled'];
$disabled_download = isset( $file['enabled'] ) && false === $file['enabled'];
$disabled_downloads_count += (int) $disabled_download;
include __DIR__ . '/html-product-download.php';
}
@@ -105,8 +105,8 @@ defined( 'ABSPATH' ) || exit;
<th colspan="2">
<a href="#" class="button insert" data-row="
<?php
$key = '';
$file = array(
$key = '';
$file = array(
'file' => '',
'name' => '',
);

View File

@@ -34,7 +34,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<label for="<?php echo esc_attr( $option['id'] ); ?>" class="<?php echo esc_attr( $option['wrapper_class'] ); ?> tips" data-tip="<?php echo esc_attr( $option['description'] ); ?>">
<?php echo esc_html( $option['label'] ); ?>:
<input type="checkbox" name="<?php echo esc_attr( $option['id'] ); ?>" id="<?php echo esc_attr( $option['id'] ); ?>" <?php echo checked( $selected_value, true, false ); ?> />
<input type="checkbox" name="<?php echo esc_attr( $option['id'] ); ?>" id="<?php echo esc_attr( $option['id'] ); ?>" data-product-type-option-id="<?php echo esc_attr( $option['id'] ); ?>" <?php echo checked( $selected_value, true, false ); ?> />
</label>
<?php endforeach; ?>
</span>

View File

@@ -16,7 +16,7 @@ $arrow_img_url = WC_ADMIN_IMAGES_FOLDER_URL . '/product_data/no-variati
<div id="variable_product_options" class="panel wc-metaboxes-wrapper hidden">
<div id="variable_product_options_inner">
<?php if ( ! count( $variation_attributes ) && ( ( $global_attributes_count > 0 ) || ( $non_variation_attributes_count > 0 ) ) ) : ?>
<?php if ( ! count( $variation_attributes ) ) : ?>
<div class="add-attributes-container">
<div class="add-attributes-message">
@@ -36,27 +36,6 @@ $arrow_img_url = WC_ADMIN_IMAGES_FOLDER_URL . '/product_data/no-variati
</div>
</div>
<?php elseif ( ! count( $variation_attributes ) ) : ?>
<div id="message" class="inline notice woocommerce-message">
<p>
<?php echo esc_html_e( 'Offer customers multiple product options, like size and color. Start by creating a new custom attribute and enter available values (theyll be shown as selectable product options).', 'woocommerce' ); ?> <a target="_blank" href="https://woocommerce.com/document/variable-product/#add-variations"><?php esc_html_e( 'Learn more about creating variations', 'woocommerce' ); ?></a>
</p>
</div>
<div class="wc-metabox">
<div class="woocommerce_variation_new_attribute_data wc-metabox-content">
<?php
$i = 0;
$is_variations_screen = true;
$attribute = new WC_Product_Attribute();
$attribute->set_variation( true );
require __DIR__ . '/html-product-attribute-inner.php';
?>
<div class="toolbar">
<button type="button" aria-disabled="true" class="button button-primary create-variations disabled"><?php esc_html_e( 'Create variations', 'woocommerce' ); ?></button>
</div>
</div>
</div>
<?php else : ?>
<div class="toolbar toolbar-variations-defaults">