| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <?php
- /**
- * Category Manipulations page view
- *
- * @since 1.0.0
- * @package Studiou_WC_Product_Cat_Manage
- */
- // If this file is called directly, abort.
- if (!defined('WPINC')) {
- die;
- }
- // Get categories with counts for select boxes
- $manipulator = new Studiou_WC_Product_Cat_Manage_Manipulator(new Studiou_WC_Product_Cat_Manage_DB());
- $categories = $manipulator->get_categories_with_counts();
- $media_categories = $manipulator->get_media_categories_with_counts();
- ?>
- <div class="wrap studiou-wcpcm-wrap">
- <h1><?php echo esc_html__('Category Manipulations', 'studiou-wc-product-cat-manage'); ?></h1>
-
- <div class="studiou-wcpcm-notice-area">
- <!-- Area for displaying notices -->
- </div>
-
- <!-- Move Products Between Categories Operation -->
- <div class="studiou-wcpcm-card">
- <h2><?php echo esc_html__('Move products between categories', 'studiou-wc-product-cat-manage'); ?></h2>
-
- <p><?php echo esc_html__('This operation allows you to move all products from one category to another. Products will be removed from the source category and added to the target category.', 'studiou-wc-product-cat-manage'); ?></p>
-
- <form id="studiou-wcpcm-move-form" method="post">
- <table class="form-table">
- <tr>
- <th scope="row">
- <label for="source_category"><?php echo esc_html__('Source Category', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <select name="source_category" id="source_category" class="regular-text" required>
- <option value=""><?php echo esc_html__('-- Select Source Category --', 'studiou-wc-product-cat-manage'); ?></option>
- <?php foreach ($categories as $category): ?>
- <option value="<?php echo esc_attr($category['id']); ?>">
- <?php echo esc_html($category['display_name']); ?>
- </option>
- <?php endforeach; ?>
- </select>
- <p class="description"><?php echo esc_html__('Select the category from which products will be moved.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- <tr>
- <th scope="row">
- <label for="target_category"><?php echo esc_html__('Target Category', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <select name="target_category" id="target_category" class="regular-text" required>
- <option value=""><?php echo esc_html__('-- Select Target Category --', 'studiou-wc-product-cat-manage'); ?></option>
- <?php foreach ($categories as $category): ?>
- <option value="<?php echo esc_attr($category['id']); ?>">
- <?php echo esc_html($category['display_name']); ?>
- </option>
- <?php endforeach; ?>
- </select>
- <p class="description"><?php echo esc_html__('Select the category to which products will be moved.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- </table>
-
- <div class="submit-buttons">
- <button type="submit" class="button button-primary" id="studiou-wcpcm-move-button">
- <?php echo esc_html__('Do', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <span class="spinner"></span>
- </div>
- </form>
-
- <div class="studiou-wcpcm-move-results" style="display: none;">
- <h3><?php echo esc_html__('Move Results', 'studiou-wc-product-cat-manage'); ?></h3>
- <div id="studiou-wcpcm-move-message"></div>
- </div>
- </div>
-
- <!-- Batch Description Between Categories Operation -->
- <div class="studiou-wcpcm-card">
- <h2><?php echo esc_html__('Batch description between categories', 'studiou-wc-product-cat-manage'); ?></h2>
-
- <p><?php echo esc_html__('This operation allows you to set the same description for multiple categories at once.', 'studiou-wc-product-cat-manage'); ?></p>
-
- <form id="studiou-wcpcm-batch-description-form" method="post">
- <table class="form-table">
- <tr>
- <th scope="row">
- <label for="categories_list"><?php echo esc_html__('Select Categories', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <div class="studiou-wcpcm-categories-list-container">
- <div class="studiou-wcpcm-list-actions">
- <button type="button" id="studiou-wcpcm-check-all" class="button">
- <?php echo esc_html__('Check All', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <button type="button" id="studiou-wcpcm-uncheck-all" class="button">
- <?php echo esc_html__('Uncheck All', 'studiou-wc-product-cat-manage'); ?>
- </button>
- </div>
- <div class="studiou-wcpcm-categories-list" id="categories_list">
- <?php foreach ($categories as $category): ?>
- <label class="studiou-wcpcm-category-item">
- <input type="checkbox" name="selected_categories[]" value="<?php echo esc_attr($category['id']); ?>">
- <span><?php echo esc_html($category['display_name']); ?></span>
- </label>
- <?php endforeach; ?>
- </div>
- </div>
- <p class="description"><?php echo esc_html__('Select the categories for which you want to set the description.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- <tr>
- <th scope="row">
- <label for="category_description"><?php echo esc_html__('Product categories description', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <textarea name="category_description" id="category_description" rows="5" cols="50" class="large-text"></textarea>
- <p class="description"><?php echo esc_html__('Enter the description that will be applied to all selected categories.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- </table>
-
- <div class="submit-buttons">
- <button type="submit" class="button button-primary" id="studiou-wcpcm-batch-description-button">
- <?php echo esc_html__('Do', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <span class="spinner"></span>
- </div>
- </form>
-
- <div class="studiou-wcpcm-batch-description-results" style="display: none;">
- <h3><?php echo esc_html__('Batch Description Results', 'studiou-wc-product-cat-manage'); ?></h3>
- <div id="studiou-wcpcm-batch-description-message"></div>
- </div>
- </div>
-
- <!-- Delete Products in Category Operation -->
- <div class="studiou-wcpcm-card">
- <h2><?php echo esc_html__('Delete products in category', 'studiou-wc-product-cat-manage'); ?></h2>
- <p><?php echo esc_html__('This operation allows you to permanently delete all products and their variants from selected categories. This action cannot be undone!', 'studiou-wc-product-cat-manage'); ?></p>
- <form id="studiou-wcpcm-delete-products-form" method="post">
- <table class="form-table">
- <tr>
- <th scope="row">
- <label for="delete_categories_list"><?php echo esc_html__('Select Categories', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <div class="studiou-wcpcm-categories-list-container">
- <div class="studiou-wcpcm-list-actions">
- <button type="button" id="studiou-wcpcm-delete-check-all" class="button">
- <?php echo esc_html__('Check All', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <button type="button" id="studiou-wcpcm-delete-uncheck-all" class="button">
- <?php echo esc_html__('Uncheck All', 'studiou-wc-product-cat-manage'); ?>
- </button>
- </div>
- <div class="studiou-wcpcm-categories-list" id="delete_categories_list">
- <?php foreach ($categories as $category): ?>
- <label class="studiou-wcpcm-category-item">
- <input type="checkbox" name="delete_categories[]" value="<?php echo esc_attr($category['id']); ?>">
- <span><?php echo esc_html($category['display_name']); ?></span>
- </label>
- <?php endforeach; ?>
- </div>
- </div>
- <p class="description"><?php echo esc_html__('Select the categories from which all products will be permanently deleted.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- </table>
- <div class="studiou-wcpcm-warning-message">
- <p><strong><?php echo esc_html__('WARNING: This operation will permanently delete all products (including variants) in the selected categories. This action cannot be undone!', 'studiou-wc-product-cat-manage'); ?></strong></p>
- </div>
- <div class="submit-buttons">
- <button type="submit" class="button button-primary button-danger" id="studiou-wcpcm-delete-products-button">
- <?php echo esc_html__('Delete', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <span class="spinner"></span>
- </div>
- </form>
- <div class="studiou-wcpcm-delete-progress" style="display: none;">
- <h3><?php echo esc_html__('Deletion Progress', 'studiou-wc-product-cat-manage'); ?></h3>
- <div class="studiou-wcpcm-progress-bar-container">
- <div class="studiou-wcpcm-progress-bar" id="studiou-wcpcm-delete-progress-bar"></div>
- </div>
- <div class="studiou-wcpcm-progress-text" id="studiou-wcpcm-delete-progress-text"></div>
- </div>
- <div class="studiou-wcpcm-delete-results" style="display: none;">
- <h3><?php echo esc_html__('Deletion Results', 'studiou-wc-product-cat-manage'); ?></h3>
- <div id="studiou-wcpcm-delete-message"></div>
- </div>
- </div>
- <!-- Clear Media Categories Operation -->
- <div class="studiou-wcpcm-card">
- <h2><?php echo esc_html__('Clear Media Categories', 'studiou-wc-product-cat-manage'); ?></h2>
- <p><?php echo esc_html__('This operation allows you to permanently delete all media files from selected media categories. This action cannot be undone!', 'studiou-wc-product-cat-manage'); ?></p>
- <?php if (empty($media_categories)): ?>
- <p><em><?php echo esc_html__('No media categories found. Please install a media category plugin (e.g., Media Library Categories) to use this feature.', 'studiou-wc-product-cat-manage'); ?></em></p>
- <?php else: ?>
- <form id="studiou-wcpcm-clear-media-form" method="post">
- <table class="form-table">
- <tr>
- <th scope="row">
- <label for="clear_media_categories_list"><?php echo esc_html__('Select Media Categories', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <div class="studiou-wcpcm-categories-list-container">
- <div class="studiou-wcpcm-list-actions">
- <button type="button" id="studiou-wcpcm-clear-media-check-all" class="button">
- <?php echo esc_html__('Check All', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <button type="button" id="studiou-wcpcm-clear-media-uncheck-all" class="button">
- <?php echo esc_html__('Uncheck All', 'studiou-wc-product-cat-manage'); ?>
- </button>
- </div>
- <div class="studiou-wcpcm-categories-list" id="clear_media_categories_list">
- <?php foreach ($media_categories as $category): ?>
- <label class="studiou-wcpcm-category-item">
- <input type="checkbox" name="media_categories[]" value="<?php echo esc_attr($category['id']); ?>">
- <span><?php echo esc_html($category['display_name']); ?></span>
- </label>
- <?php endforeach; ?>
- </div>
- </div>
- <p class="description"><?php echo esc_html__('Select the media categories from which all files will be permanently deleted.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- </table>
- <div class="studiou-wcpcm-warning-message">
- <p><strong><?php echo esc_html__('WARNING: This operation will permanently delete all media files in the selected categories. The files will be removed from the server. This action cannot be undone!', 'studiou-wc-product-cat-manage'); ?></strong></p>
- </div>
- <div class="submit-buttons">
- <button type="submit" class="button button-primary button-danger" id="studiou-wcpcm-clear-media-button">
- <?php echo esc_html__('Delete', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <span class="spinner"></span>
- </div>
- </form>
- <div class="studiou-wcpcm-clear-media-progress" style="display: none;">
- <h3><?php echo esc_html__('Deletion Progress', 'studiou-wc-product-cat-manage'); ?></h3>
- <div class="studiou-wcpcm-progress-bar-container">
- <div class="studiou-wcpcm-progress-bar" id="studiou-wcpcm-clear-media-progress-bar"></div>
- </div>
- <div class="studiou-wcpcm-progress-text" id="studiou-wcpcm-clear-media-progress-text"></div>
- </div>
- <div class="studiou-wcpcm-clear-media-results" style="display: none;">
- <h3><?php echo esc_html__('Deletion Results', 'studiou-wc-product-cat-manage'); ?></h3>
- <div id="studiou-wcpcm-clear-media-message"></div>
- </div>
- <?php endif; ?>
- </div>
- <!-- Important Notes -->
- <div class="studiou-wcpcm-card">
- <h2><?php echo esc_html__('Important Notes', 'studiou-wc-product-cat-manage'); ?></h2>
- <ul>
- <li><?php echo esc_html__('Products can be assigned to multiple categories. This operation will remove the product from the source category and add it to the target category.', 'studiou-wc-product-cat-manage'); ?></li>
- <li><?php echo esc_html__('If a product is only assigned to the source category, it will be moved entirely to the target category.', 'studiou-wc-product-cat-manage'); ?></li>
- <li><?php echo esc_html__('If a product is assigned to multiple categories including the source category, it will remain in the other categories and be moved to the target category.', 'studiou-wc-product-cat-manage'); ?></li>
- <li><?php echo esc_html__('The operation processes all products regardless of their status (published, draft, private).', 'studiou-wc-product-cat-manage'); ?></li>
- <li><?php echo esc_html__('The batch description operation will overwrite the existing descriptions for all selected categories.', 'studiou-wc-product-cat-manage'); ?></li>
- <li><strong><?php echo esc_html__('The delete products operation will permanently delete all products and variants from the selected categories. This action cannot be undone!', 'studiou-wc-product-cat-manage'); ?></strong></li>
- <li><strong><?php echo esc_html__('The clear media categories operation will permanently delete all media files from the selected media categories and remove them from the server. This action cannot be undone!', 'studiou-wc-product-cat-manage'); ?></strong></li>
- </ul>
- </div>
- </div>
|