mirror of
https://github.com/WenPai-org/bulk-installer-server.git
synced 2025-08-03 02:48:43 +08:00
dev
This commit is contained in:
parent
860a7a1b0f
commit
ef86b0264a
4 changed files with 3133 additions and 0 deletions
1003
assets/css/admin.css
Normal file
1003
assets/css/admin.css
Normal file
File diff suppressed because it is too large
Load diff
1031
assets/js/admin.js
Normal file
1031
assets/js/admin.js
Normal file
File diff suppressed because it is too large
Load diff
585
bulk-installer-server.php
Normal file
585
bulk-installer-server.php
Normal file
|
@ -0,0 +1,585 @@
|
|||
<?php
|
||||
/**
|
||||
* Plugin Name: Bulk Installer Server
|
||||
* Plugin URI: https://wpmultisite.com/plugins/bulk-installer-server/
|
||||
* Description: Create and manage plugin/theme collections that can be used with the Bulk Plugin Installer client.
|
||||
* Version: 1.0.1
|
||||
* Author: WPMultisite.com
|
||||
* Author URI: https://wpmultisite.com
|
||||
* License: GPL v2 or later
|
||||
* Text Domain: bulk-installer-server
|
||||
* Requires PHP: 7.4
|
||||
* Domain Path: /languages
|
||||
*/
|
||||
|
||||
if (!defined('WPINC')) {
|
||||
die;
|
||||
}
|
||||
|
||||
define('BIS_VERSION', '1.0.1');
|
||||
define('BIS_PATH', plugin_dir_path(__FILE__));
|
||||
define('BIS_URL', plugin_dir_url(__FILE__));
|
||||
|
||||
/**
|
||||
* Initialize the plugin
|
||||
*/
|
||||
function bis_init() {
|
||||
load_plugin_textdomain('bulk-installer-server', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
||||
add_action('admin_menu', 'bis_add_menu_page');
|
||||
add_action('admin_enqueue_scripts', 'bis_admin_scripts');
|
||||
add_action('rest_api_init', 'bis_register_rest_routes');
|
||||
|
||||
// Ajax handlers
|
||||
add_action('wp_ajax_bis_save_collection', 'bis_ajax_save_collection');
|
||||
add_action('wp_ajax_bis_delete_collection', 'bis_ajax_delete_collection');
|
||||
add_action('wp_ajax_bis_import_collection', 'bis_ajax_import_collection');
|
||||
add_action('wp_ajax_bis_get_collection', 'bis_ajax_get_collection');
|
||||
}
|
||||
add_action('plugins_loaded', 'bis_init');
|
||||
|
||||
/**
|
||||
* Register REST API routes
|
||||
*/
|
||||
function bis_register_rest_routes() {
|
||||
// 获取所有合集
|
||||
register_rest_route('bulk-installer-server/v1', '/collections', [
|
||||
'methods' => 'GET',
|
||||
'callback' => 'bis_rest_get_collections',
|
||||
'permission_callback' => '__return_true'
|
||||
]);
|
||||
|
||||
// 按 slug 获取特定合集 - 使用 WordPress 标准的 slug 格式(字母、数字、连字符)
|
||||
register_rest_route('bulk-installer-server/v1', '/collection/(?P<slug>[\w-]+)', [
|
||||
'methods' => 'GET',
|
||||
'callback' => 'bis_rest_get_collection',
|
||||
'permission_callback' => '__return_true'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* REST API handler for getting all collections
|
||||
*/
|
||||
function bis_rest_get_collections() {
|
||||
$collections = bis_get_collections();
|
||||
|
||||
return new WP_REST_Response([
|
||||
'version' => BIS_VERSION,
|
||||
'last_updated' => gmdate('Y-m-d'),
|
||||
'collections' => $collections
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* REST API handler for getting a specific collection
|
||||
*/
|
||||
function bis_rest_get_collection($request) {
|
||||
$slug = $request['slug'];
|
||||
$collections = bis_get_collections();
|
||||
|
||||
if (!isset($collections[$slug])) {
|
||||
return new WP_REST_Response([
|
||||
'error' => 'Collection not found',
|
||||
'requested_slug' => $slug,
|
||||
'available_slugs' => array_keys($collections)
|
||||
], 404);
|
||||
}
|
||||
|
||||
return new WP_REST_Response([
|
||||
'version' => BIS_VERSION,
|
||||
'last_updated' => gmdate('Y-m-d'),
|
||||
'collections' => [
|
||||
$slug => $collections[$slug]
|
||||
]
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add admin menu page
|
||||
*/
|
||||
function bis_add_menu_page() {
|
||||
add_menu_page(
|
||||
__('Collection Manager', 'bulk-installer-server'),
|
||||
__('Collection Manager', 'bulk-installer-server'),
|
||||
'manage_options',
|
||||
'bulk-installer-server',
|
||||
'bis_render_admin_page',
|
||||
'dashicons-layout',
|
||||
65
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue admin scripts and styles
|
||||
*/
|
||||
function bis_admin_scripts($hook) {
|
||||
if ($hook !== 'toplevel_page_bulk-installer-server') {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style('bis-admin-style', BIS_URL . 'assets/css/admin.css', [], BIS_VERSION);
|
||||
wp_enqueue_script('bis-admin', BIS_URL . 'assets/js/admin.js', ['jquery', 'jquery-ui-sortable'], BIS_VERSION, true);
|
||||
|
||||
wp_localize_script('bis-admin', 'bisAjax', [
|
||||
'nonce' => wp_create_nonce('bis_nonce'),
|
||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
||||
'rest_url' => rest_url('bulk-installer-server/v1/collections'),
|
||||
'siteurl' => site_url(),
|
||||
'i18n' => [
|
||||
'confirm_delete' => __('Are you sure you want to delete this collection?', 'bulk-installer-server'),
|
||||
'saving' => __('Saving...', 'bulk-installer-server'),
|
||||
'save_error' => __('Error saving collection', 'bulk-installer-server'),
|
||||
'add_plugin' => __('Add Plugin', 'bulk-installer-server'),
|
||||
'add_theme' => __('Add Theme', 'bulk-installer-server'),
|
||||
'invalid_json' => __('Invalid JSON format', 'bulk-installer-server'),
|
||||
'add_collection' => __('Create New Collection', 'bulk-installer-server'),
|
||||
'edit_collection' => __('Edit Collection', 'bulk-installer-server'),
|
||||
'slug_generated' => __('A slug has been automatically generated for this collection', 'bulk-installer-server'),
|
||||
'name_required' => __('Collection name is required', 'bulk-installer-server'),
|
||||
'item_required' => __('Please add at least one plugin or theme', 'bulk-installer-server'),
|
||||
'confirm_regenerate_slug' => __('This will generate a new slug for this collection. API URLs and bookmarks to this collection may break. Continue?', 'bulk-installer-server')
|
||||
]
|
||||
]);
|
||||
|
||||
// Enqueue WordPress media scripts
|
||||
wp_enqueue_media();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the admin page
|
||||
*/
|
||||
function bis_render_admin_page() {
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_die(__('You do not have sufficient permissions to access this page.', 'bulk-installer-server'));
|
||||
}
|
||||
|
||||
$collections = bis_get_collections();
|
||||
include BIS_PATH . 'templates/admin-page.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all collections
|
||||
*
|
||||
* @return array Collections data
|
||||
*/
|
||||
function bis_get_collections() {
|
||||
$collections = get_option('bis_collections', []);
|
||||
return $collections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a WordPress-compatible slug
|
||||
*
|
||||
* @param string $name The collection name
|
||||
* @param array $existing_collections Existing collections
|
||||
* @return string The generated slug
|
||||
*/
|
||||
function bis_generate_slug($name, $existing_collections = []) {
|
||||
// 使用 WordPress 原生函数生成 slug
|
||||
$slug = sanitize_title($name);
|
||||
|
||||
// 如果 slug 为空(可能由于只包含特殊字符),则生成一个默认 slug
|
||||
if (empty($slug)) {
|
||||
$slug = 'collection-' . substr(md5($name), 0, 8);
|
||||
}
|
||||
|
||||
$original_slug = $slug;
|
||||
$counter = 1;
|
||||
|
||||
// 确保 slug 的唯一性
|
||||
while (isset($existing_collections[$slug])) {
|
||||
$slug = $original_slug . '-' . $counter;
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a collection
|
||||
*
|
||||
* @param array $collection Collection data
|
||||
* @param string $slug Collection slug
|
||||
* @param bool $force_new_slug Whether to force generating a new slug
|
||||
* @return bool|string True if successful, error message if failed
|
||||
*/
|
||||
function bis_save_collection($collection, $slug = '', $force_new_slug = false) {
|
||||
if (!current_user_can('manage_options')) {
|
||||
return __('Insufficient permissions', 'bulk-installer-server');
|
||||
}
|
||||
|
||||
$collections = bis_get_collections();
|
||||
|
||||
// 获取集合名称
|
||||
$name = isset($collection['name']) ? trim($collection['name']) : '';
|
||||
|
||||
if (empty($name)) {
|
||||
return __('Collection name is required', 'bulk-installer-server');
|
||||
}
|
||||
|
||||
// 处理 slug 生成
|
||||
if (empty($slug) || $force_new_slug) {
|
||||
// 生成新的 slug
|
||||
$slug = bis_generate_slug($name, $collections);
|
||||
} else if (!isset($collections[$slug])) {
|
||||
// 如果提供了 slug 但不存在,检查它是否是有效的
|
||||
if (!preg_match('/^[\w-]+$/', $slug)) {
|
||||
// 无效的 slug,生成新的
|
||||
$slug = bis_generate_slug($name, $collections);
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize collection data
|
||||
$collection['name'] = sanitize_text_field($name);
|
||||
$collection['slug'] = $slug; // 存储生成的 slug
|
||||
$collection['description'] = isset($collection['description']) ? sanitize_textarea_field($collection['description']) : '';
|
||||
$collection['icon'] = isset($collection['icon']) ? sanitize_text_field($collection['icon']) : 'dashicons-admin-plugins';
|
||||
$collection['category'] = isset($collection['category']) ? sanitize_text_field($collection['category']) : 'other';
|
||||
$collection['level'] = isset($collection['level']) ? sanitize_text_field($collection['level']) : 'beginner';
|
||||
$collection['author'] = isset($collection['author']) ? sanitize_text_field($collection['author']) : get_bloginfo('name');
|
||||
|
||||
if (!empty($collection['screenshot'])) {
|
||||
$collection['screenshot'] = esc_url_raw($collection['screenshot']);
|
||||
}
|
||||
|
||||
// Sanitize plugins/themes
|
||||
$collection['plugins'] = isset($collection['plugins']) ? bis_sanitize_items($collection['plugins']) : ['repository' => [], 'wenpai' => [], 'url' => []];
|
||||
$collection['themes'] = isset($collection['themes']) ? bis_sanitize_items($collection['themes']) : ['repository' => [], 'wenpai' => [], 'url' => []];
|
||||
|
||||
// Store in the collections array
|
||||
$collections[$slug] = $collection;
|
||||
|
||||
// Save to the database
|
||||
$updated = update_option('bis_collections', $collections);
|
||||
|
||||
if (!$updated) {
|
||||
return __('Failed to save collection', 'bulk-installer-server');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize plugin/theme items
|
||||
*
|
||||
* @param array $items Items to sanitize
|
||||
* @return array Sanitized items
|
||||
*/
|
||||
function bis_sanitize_items($items) {
|
||||
$sanitized = [
|
||||
'repository' => [],
|
||||
'wenpai' => [],
|
||||
'url' => []
|
||||
];
|
||||
|
||||
if (!is_array($items)) {
|
||||
return $sanitized;
|
||||
}
|
||||
|
||||
foreach (['repository', 'wenpai', 'url'] as $source) {
|
||||
if (!isset($items[$source]) || !is_array($items[$source])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($items[$source] as $item) {
|
||||
if (is_array($item)) {
|
||||
$sanitized_item = [
|
||||
'id' => isset($item['id']) ? absint($item['id']) : 0,
|
||||
'slug' => sanitize_text_field($item['slug'] ?? ''),
|
||||
'name' => sanitize_text_field($item['name'] ?? ''),
|
||||
'description' => sanitize_textarea_field($item['description'] ?? ''),
|
||||
'required' => !empty($item['required'])
|
||||
];
|
||||
|
||||
// Add URL for URL source items
|
||||
if ($source === 'url' && !empty($item['url'])) {
|
||||
$sanitized_item['url'] = esc_url_raw($item['url']);
|
||||
}
|
||||
|
||||
$sanitized[$source][] = $sanitized_item;
|
||||
} else if (is_string($item)) {
|
||||
$sanitized[$source][] = sanitize_text_field($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sanitized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for getting a collection
|
||||
*/
|
||||
function bis_ajax_get_collection() {
|
||||
check_ajax_referer('bis_nonce', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Insufficient permissions', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
$slug = isset($_GET['collection_id']) ? sanitize_text_field(wp_unslash($_GET['collection_id'])) : '';
|
||||
|
||||
if (empty($slug)) {
|
||||
wp_send_json_error([
|
||||
'message' => __('No collection ID provided', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
$collections = bis_get_collections();
|
||||
|
||||
if (!isset($collections[$slug])) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Collection not found', 'bulk-installer-server'),
|
||||
'requested_slug' => $slug,
|
||||
'available_slugs' => array_keys($collections)
|
||||
]);
|
||||
}
|
||||
|
||||
wp_send_json_success([
|
||||
'collection' => $collections[$slug]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving collections
|
||||
*/
|
||||
function bis_ajax_save_collection() {
|
||||
check_ajax_referer('bis_nonce', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Insufficient permissions', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
$collection_data = isset($_POST['collection']) ? json_decode(stripslashes($_POST['collection']), true) : [];
|
||||
$slug = isset($_POST['collection_id']) ? sanitize_text_field(wp_unslash($_POST['collection_id'])) : '';
|
||||
$force_new_slug = isset($_POST['force_new_slug']) && $_POST['force_new_slug'] === 'true';
|
||||
|
||||
if (empty($collection_data) || !is_array($collection_data)) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Invalid collection data', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
$result = bis_save_collection($collection_data, $slug, $force_new_slug);
|
||||
|
||||
if ($result === true) {
|
||||
// 如果是新集合,我们需要找到新的 slug
|
||||
if (empty($slug) || $force_new_slug) {
|
||||
$slug = bis_generate_slug($collection_data['name'], bis_get_collections());
|
||||
|
||||
// 再次检查是否匹配,因为可能在保存过程中其他集合也创建了相同的 slug
|
||||
$collections = bis_get_collections();
|
||||
foreach ($collections as $collection_slug => $collection) {
|
||||
if ($collection['name'] === $collection_data['name'] && $collection_slug !== $slug) {
|
||||
$slug = $collection_slug;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp_send_json_success([
|
||||
'message' => __('Collection saved successfully', 'bulk-installer-server'),
|
||||
'collection_id' => $slug,
|
||||
'collections' => bis_get_collections()
|
||||
]);
|
||||
} else {
|
||||
wp_send_json_error([
|
||||
'message' => $result
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for deleting collections
|
||||
*/
|
||||
function bis_ajax_delete_collection() {
|
||||
check_ajax_referer('bis_nonce', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Insufficient permissions', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
$slug = isset($_POST['collection_id']) ? sanitize_text_field(wp_unslash($_POST['collection_id'])) : '';
|
||||
|
||||
if (empty($slug)) {
|
||||
wp_send_json_error([
|
||||
'message' => __('No collection ID provided', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
$collections = bis_get_collections();
|
||||
|
||||
if (!isset($collections[$slug])) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Collection not found', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
unset($collections[$slug]);
|
||||
|
||||
$updated = update_option('bis_collections', $collections);
|
||||
|
||||
if (!$updated) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Failed to delete collection', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
wp_send_json_success([
|
||||
'message' => __('Collection deleted successfully', 'bulk-installer-server'),
|
||||
'collections' => $collections
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for importing collections
|
||||
*/
|
||||
function bis_ajax_import_collection() {
|
||||
check_ajax_referer('bis_nonce', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Insufficient permissions', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
$json_data = isset($_POST['import_data']) ? json_decode(stripslashes($_POST['import_data']), true) : [];
|
||||
|
||||
if (empty($json_data) || !is_array($json_data)) {
|
||||
wp_send_json_error([
|
||||
'message' => __('Invalid JSON data', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
|
||||
$imported = 0;
|
||||
$existing_collections = bis_get_collections();
|
||||
|
||||
// Check if we have a "collections" key (full format) or direct collection data
|
||||
if (isset($json_data['collections']) && is_array($json_data['collections'])) {
|
||||
foreach ($json_data['collections'] as $imported_slug => $collection) {
|
||||
if (isset($existing_collections[$imported_slug])) {
|
||||
// 已存在同名集合,生成新 slug
|
||||
$result = bis_save_collection($collection);
|
||||
} else {
|
||||
// 使用导入文件中的 slug
|
||||
$result = bis_save_collection($collection, $imported_slug);
|
||||
}
|
||||
|
||||
if ($result === true) {
|
||||
$imported++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Assume it's a single collection
|
||||
$result = bis_save_collection($json_data);
|
||||
|
||||
if ($result === true) {
|
||||
$imported++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($imported > 0) {
|
||||
wp_send_json_success([
|
||||
'message' => sprintf(_n('%d collection imported successfully', '%d collections imported successfully', $imported, 'bulk-installer-server'), $imported),
|
||||
'collections' => bis_get_collections()
|
||||
]);
|
||||
} else {
|
||||
wp_send_json_error([
|
||||
'message' => __('No collections were imported', 'bulk-installer-server')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin activation hook
|
||||
*/
|
||||
register_activation_hook(__FILE__, 'bis_activate');
|
||||
function bis_activate() {
|
||||
if (version_compare(PHP_VERSION, '7.4', '<')) {
|
||||
deactivate_plugins(plugin_basename(__FILE__));
|
||||
wp_die(__('This plugin requires PHP 7.4 or higher.', 'bulk-installer-server'));
|
||||
}
|
||||
|
||||
// Create default collection if none exist
|
||||
$collections = bis_get_collections();
|
||||
|
||||
if (empty($collections)) {
|
||||
$default_collection = [
|
||||
'name' => __('Business Website', 'bulk-installer-server'),
|
||||
'description' => __('Essential plugins for a professional business website.', 'bulk-installer-server'),
|
||||
'icon' => 'dashicons-building',
|
||||
'category' => 'business',
|
||||
'level' => 'beginner',
|
||||
'author' => get_bloginfo('name'),
|
||||
'plugins' => [
|
||||
'repository' => [
|
||||
[
|
||||
'id' => 1,
|
||||
'slug' => 'wordpress-seo',
|
||||
'name' => 'Yoast SEO',
|
||||
'description' => __('The leading SEO plugin for WordPress', 'bulk-installer-server'),
|
||||
'required' => true
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'slug' => 'contact-form-7',
|
||||
'name' => 'Contact Form 7',
|
||||
'description' => __('Simple but flexible contact form plugin', 'bulk-installer-server'),
|
||||
'required' => true
|
||||
]
|
||||
],
|
||||
'wenpai' => [],
|
||||
'url' => []
|
||||
],
|
||||
'themes' => [
|
||||
'repository' => [
|
||||
[
|
||||
'id' => 3,
|
||||
'slug' => 'astra',
|
||||
'name' => 'Astra',
|
||||
'description' => __('Fast, lightweight theme for business websites', 'bulk-installer-server'),
|
||||
'required' => false
|
||||
]
|
||||
],
|
||||
'wenpai' => [],
|
||||
'url' => []
|
||||
]
|
||||
];
|
||||
|
||||
bis_save_collection($default_collection, 'business');
|
||||
}
|
||||
|
||||
// Create required directories
|
||||
$upload_dir = wp_upload_dir();
|
||||
$export_dir = $upload_dir['basedir'] . '/bis-exports';
|
||||
|
||||
if (!file_exists($export_dir)) {
|
||||
wp_mkdir_p($export_dir);
|
||||
}
|
||||
|
||||
// Create .htaccess file to protect directory
|
||||
$htaccess_file = $export_dir . '/.htaccess';
|
||||
if (!file_exists($htaccess_file)) {
|
||||
$htaccess_content = "Options -Indexes\n";
|
||||
$htaccess_content .= "<Files \"*.json\">\n";
|
||||
$htaccess_content .= "Header set Access-Control-Allow-Origin \"*\"\n";
|
||||
$htaccess_content .= "Header set Content-Type \"application/json\"\n";
|
||||
$htaccess_content .= "</Files>\n";
|
||||
|
||||
file_put_contents($htaccess_file, $htaccess_content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection JSON URL
|
||||
*
|
||||
* @param string $slug Collection slug
|
||||
* @return string Collection JSON URL
|
||||
*/
|
||||
function bis_get_collection_json_url($slug) {
|
||||
return rest_url("bulk-installer-server/v1/collection/" . urlencode($slug));
|
||||
}
|
514
templates/admin-page.php
Normal file
514
templates/admin-page.php
Normal file
|
@ -0,0 +1,514 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin page template for Collection Manager
|
||||
*/
|
||||
?>
|
||||
<div class="wrap bis-wrap">
|
||||
<h1><?php echo esc_html__('Collection Manager', 'bulk-installer-server'); ?>
|
||||
<span class="bis-version-tag"><?php printf(esc_html__('Version: %s', 'bulk-installer-server'), esc_html(BIS_VERSION)); ?></span>
|
||||
</h1>
|
||||
|
||||
<div class="bis-container">
|
||||
<div class="bis-sidebar">
|
||||
<div class="bis-card">
|
||||
<h3><?php _e('Your Collections', 'bulk-installer-server'); ?></h3>
|
||||
<p><?php _e('Create and manage plugin & theme collections for bulk installation.', 'bulk-installer-server'); ?></p>
|
||||
|
||||
<div class="bis-collections-list">
|
||||
<?php if (empty($collections)) : ?>
|
||||
<p class="bis-empty-message"><?php _e('No collections found. Create one now!', 'bulk-installer-server'); ?></p>
|
||||
<?php else : ?>
|
||||
<ul>
|
||||
<?php foreach ($collections as $slug => $collection) : ?>
|
||||
<li class="bis-collection-item" data-id="<?php echo esc_attr($slug); ?>">
|
||||
<div class="bis-collection-icon">
|
||||
<span class="dashicons <?php echo esc_attr($collection['icon'] ?? 'dashicons-admin-plugins'); ?>"></span>
|
||||
</div>
|
||||
<div class="bis-collection-details">
|
||||
<h4><?php echo esc_html($collection['name']); ?></h4>
|
||||
<div class="bis-collection-meta">
|
||||
<?php
|
||||
$plugin_count = 0;
|
||||
$theme_count = 0;
|
||||
|
||||
if (!empty($collection['plugins'])) {
|
||||
foreach ($collection['plugins'] as $source => $plugins) {
|
||||
$plugin_count += count($plugins);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($collection['themes'])) {
|
||||
foreach ($collection['themes'] as $source => $themes) {
|
||||
$theme_count += count($themes);
|
||||
}
|
||||
}
|
||||
|
||||
$category = !empty($collection['category']) ? $collection['category'] : '';
|
||||
$level = !empty($collection['level']) ? $collection['level'] : '';
|
||||
?>
|
||||
<span class="bis-item-count bis-plugin-count">
|
||||
<span class="dashicons dashicons-admin-plugins"></span>
|
||||
<?php echo sprintf(_n('%s plugin', '%s plugins', $plugin_count, 'bulk-installer-server'), $plugin_count); ?>
|
||||
</span>
|
||||
<span class="bis-item-count bis-theme-count">
|
||||
<span class="dashicons dashicons-admin-appearance"></span>
|
||||
<?php echo sprintf(_n('%s theme', '%s themes', $theme_count, 'bulk-installer-server'), $theme_count); ?>
|
||||
</span>
|
||||
<?php if ($category) : ?>
|
||||
<span class="bis-meta-tag bis-category-tag"><?php echo esc_html(ucfirst($category)); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if ($level) : ?>
|
||||
<span class="bis-meta-tag bis-level-tag"><?php echo esc_html(ucfirst($level)); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bis-collection-actions">
|
||||
<button type="button" class="bis-edit-collection button button-small" data-id="<?php echo esc_attr($slug); ?>">
|
||||
<span class="dashicons dashicons-edit"></span> <?php _e('Edit', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
<button type="button" class="bis-delete-collection button button-small" data-id="<?php echo esc_attr($slug); ?>">
|
||||
<span class="dashicons dashicons-trash"></span> <?php _e('Delete', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="bis-actions">
|
||||
<button type="button" class="button button-primary bis-new-collection">
|
||||
<span class="dashicons dashicons-plus"></span> <?php _e('Create New Collection', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
<button type="button" class="button bis-import-collection">
|
||||
<span class="dashicons dashicons-upload"></span> <?php _e('Import Collection', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-card">
|
||||
<h3><?php _e('Export Collections', 'bulk-installer-server'); ?></h3>
|
||||
<p><?php _e('Export collections to JSON for use in other sites:', 'bulk-installer-server'); ?></p>
|
||||
|
||||
<div class="bis-export-options">
|
||||
<div class="bis-form-row">
|
||||
<label class="bis-export-label"><?php _e('Export Format:', 'bulk-installer-server'); ?></label>
|
||||
<select id="bis-export-format" class="bis-select">
|
||||
<option value="all"><?php _e('All Collections (Complete JSON)', 'bulk-installer-server'); ?></option>
|
||||
<option value="selected"><?php _e('Selected Collection Only', 'bulk-installer-server'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="bis-export-collection-select" class="bis-form-row" style="display: none;">
|
||||
<label class="bis-export-label"><?php _e('Collection:', 'bulk-installer-server'); ?></label>
|
||||
<select id="bis-export-collection" class="bis-select">
|
||||
<?php if (!empty($collections)) : ?>
|
||||
<?php foreach ($collections as $slug => $collection) : ?>
|
||||
<option value="<?php echo esc_attr($slug); ?>"><?php echo esc_html($collection['name']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<option value=""><?php _e('No collections available', 'bulk-installer-server'); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="button" class="button button-secondary bis-export-collections">
|
||||
<span class="dashicons dashicons-download"></span> <?php _e('Export JSON', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-card">
|
||||
<h3><?php _e('Collections API', 'bulk-installer-server'); ?></h3>
|
||||
<p><?php _e('Access your collections via these API URLs:', 'bulk-installer-server'); ?></p>
|
||||
|
||||
<div class="bis-api-info">
|
||||
<div class="bis-api-endpoint">
|
||||
<label><?php _e('All Collections:', 'bulk-installer-server'); ?></label>
|
||||
<div class="bis-endpoint-url">
|
||||
<code><?php echo esc_url(rest_url('bulk-installer-server/v1/collections')); ?></code>
|
||||
<button type="button" class="button button-small bis-copy-url" data-url="<?php echo esc_url(rest_url('bulk-installer-server/v1/collections')); ?>">
|
||||
<span class="dashicons dashicons-clipboard"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($collections)) : ?>
|
||||
<div class="bis-collection-endpoints">
|
||||
<label><?php _e('Individual Collections:', 'bulk-installer-server'); ?></label>
|
||||
<?php foreach ($collections as $slug => $collection) : ?>
|
||||
<div class="bis-endpoint-url">
|
||||
<strong><?php echo esc_html($collection['name']); ?>:</strong>
|
||||
<code><?php echo esc_url(bis_get_collection_json_url($slug)); ?></code>
|
||||
<button type="button" class="button button-small bis-copy-url" data-url="<?php echo esc_url(bis_get_collection_json_url($slug)); ?>">
|
||||
<span class="dashicons dashicons-clipboard"></span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="bis-client-instructions">
|
||||
<h4><?php _e('How to use with Bulk Plugin Installer', 'bulk-installer-server'); ?></h4>
|
||||
<ol>
|
||||
<li><?php _e('Copy the URL for "All Collections" or an individual collection', 'bulk-installer-server'); ?></li>
|
||||
<li><?php _e('In the client site, go to Bulk Plugin Installer > Settings', 'bulk-installer-server'); ?></li>
|
||||
<li><?php _e('Add this URL as a Collection Source', 'bulk-installer-server'); ?></li>
|
||||
<li><?php _e('Your collections will be available in the Collections tab', 'bulk-installer-server'); ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-content">
|
||||
<div class="bis-card" id="bis-editor-card" style="display: none;">
|
||||
<h2 id="bis-editor-title"><?php _e('Create New Collection', 'bulk-installer-server'); ?></h2>
|
||||
|
||||
<form id="bis-collection-form">
|
||||
<input type="hidden" id="bis-collection-id" name="collection_id" value="">
|
||||
|
||||
<div class="bis-form-section">
|
||||
<h3 class="bis-section-title"><?php _e('Basic Information', 'bulk-installer-server'); ?></h3>
|
||||
|
||||
<div class="bis-form-row">
|
||||
<label for="bis-collection-name"><?php _e('Collection Name:', 'bulk-installer-server'); ?> <span class="bis-required">*</span></label>
|
||||
<input type="text" id="bis-collection-name" name="collection_name" class="regular-text" required>
|
||||
</div>
|
||||
|
||||
<!-- 新增:显示 slug 信息 -->
|
||||
<div class="bis-form-row bis-slug-display" style="display: none;">
|
||||
<label><?php _e('Collection Slug:', 'bulk-installer-server'); ?></label>
|
||||
<div class="bis-slug-info-wrapper">
|
||||
<code class="bis-slug-info"></code>
|
||||
<button type="button" class="button button-small bis-regenerate-slug" title="<?php esc_attr_e('Regenerate slug based on collection name. Warning: this will change API URLs', 'bulk-installer-server'); ?>">
|
||||
<span class="dashicons dashicons-update-alt"></span> <?php _e('Regenerate', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
<span class="bis-tooltip" data-tooltip="<?php esc_attr_e('This is the unique identifier used in API URLs. It is automatically generated from the collection name.', 'bulk-installer-server'); ?>">
|
||||
<span class="dashicons dashicons-info-outline"></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-row">
|
||||
<label for="bis-collection-description"><?php _e('Description:', 'bulk-installer-server'); ?></label>
|
||||
<textarea id="bis-collection-description" name="collection_description" rows="3" class="large-text"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-grid">
|
||||
<div class="bis-form-group">
|
||||
<label for="bis-collection-icon"><?php _e('Icon:', 'bulk-installer-server'); ?></label>
|
||||
<div class="bis-icon-select-wrapper">
|
||||
<select id="bis-collection-icon" name="collection_icon" class="bis-select">
|
||||
<option value="dashicons-admin-plugins"><?php _e('Plugins', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-admin-appearance"><?php _e('Themes', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-building"><?php _e('Business', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-cart"><?php _e('E-Commerce', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-groups"><?php _e('Community', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-edit"><?php _e('Blog', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-format-gallery"><?php _e('Portfolio', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-calendar"><?php _e('Events', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-admin-users"><?php _e('Membership', 'bulk-installer-server'); ?></option>
|
||||
<option value="dashicons-networking"><?php _e('Network', 'bulk-installer-server'); ?></option>
|
||||
</select>
|
||||
<span class="bis-selected-icon dashicons dashicons-admin-plugins"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-group">
|
||||
<label for="bis-collection-category"><?php _e('Category:', 'bulk-installer-server'); ?></label>
|
||||
<select id="bis-collection-category" name="collection_category" class="bis-select">
|
||||
<option value="business"><?php _e('Business', 'bulk-installer-server'); ?></option>
|
||||
<option value="ecommerce"><?php _e('E-Commerce', 'bulk-installer-server'); ?></option>
|
||||
<option value="community"><?php _e('Community', 'bulk-installer-server'); ?></option>
|
||||
<option value="content"><?php _e('Content', 'bulk-installer-server'); ?></option>
|
||||
<option value="utilities"><?php _e('Utilities', 'bulk-installer-server'); ?></option>
|
||||
<option value="development"><?php _e('Development', 'bulk-installer-server'); ?></option>
|
||||
<option value="other"><?php _e('Other', 'bulk-installer-server'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-group">
|
||||
<label for="bis-collection-level"><?php _e('Level:', 'bulk-installer-server'); ?></label>
|
||||
<select id="bis-collection-level" name="collection_level" class="bis-select">
|
||||
<option value="beginner"><?php _e('Beginner', 'bulk-installer-server'); ?></option>
|
||||
<option value="intermediate"><?php _e('Intermediate', 'bulk-installer-server'); ?></option>
|
||||
<option value="advanced"><?php _e('Advanced', 'bulk-installer-server'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-group">
|
||||
<label for="bis-collection-author"><?php _e('Author:', 'bulk-installer-server'); ?></label>
|
||||
<input type="text" id="bis-collection-author" name="collection_author" class="regular-text" value="<?php echo esc_attr(get_bloginfo('name')); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-row">
|
||||
<label for="bis-collection-screenshot"><?php _e('Screenshot:', 'bulk-installer-server'); ?></label>
|
||||
<div class="bis-screenshot-field">
|
||||
<input type="text" id="bis-collection-screenshot" name="collection_screenshot" class="regular-text" placeholder="<?php esc_attr_e('Enter URL or upload image', 'bulk-installer-server'); ?>">
|
||||
<button type="button" class="button bis-upload-screenshot">
|
||||
<span class="dashicons dashicons-upload"></span> <?php _e('Upload', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<div id="bis-screenshot-preview" class="bis-screenshot-preview"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-section">
|
||||
<h3 class="bis-section-title"><?php _e('Plugins & Themes', 'bulk-installer-server'); ?></h3>
|
||||
<p class="bis-section-description"><?php _e('Add the plugins and themes you want to include in this collection.', 'bulk-installer-server'); ?></p>
|
||||
|
||||
<div class="bis-tabs">
|
||||
<div class="bis-tabs-nav">
|
||||
<button type="button" class="bis-tab active" data-tab="plugins">
|
||||
<span class="dashicons dashicons-admin-plugins"></span> <?php _e('Plugins', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
<button type="button" class="bis-tab" data-tab="themes">
|
||||
<span class="dashicons dashicons-admin-appearance"></span> <?php _e('Themes', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="bis-tab-plugins" class="bis-tab-content active">
|
||||
<div class="bis-source-sections">
|
||||
<div class="bis-source-section" data-source="repository">
|
||||
<h4>
|
||||
<span class="dashicons dashicons-wordpress"></span>
|
||||
<?php _e('WordPress.org Repository', 'bulk-installer-server'); ?>
|
||||
</h4>
|
||||
<p class="bis-source-description"><?php _e('Add plugins from the official WordPress.org plugin repository.', 'bulk-installer-server'); ?></p>
|
||||
<div class="bis-items-container" id="bis-plugins-repository"></div>
|
||||
<button type="button" class="button bis-add-item" data-type="plugin" data-source="repository">
|
||||
<span class="dashicons dashicons-plus"></span> <?php _e('Add Repository Plugin', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="bis-source-section" data-source="wenpai">
|
||||
<h4>
|
||||
<span class="dashicons dashicons-share-alt"></span>
|
||||
<?php _e('WenPai.org Repository', 'bulk-installer-server'); ?>
|
||||
</h4>
|
||||
<p class="bis-source-description"><?php _e('Add plugins from the WenPai.org plugin repository.', 'bulk-installer-server'); ?></p>
|
||||
<div class="bis-items-container" id="bis-plugins-wenpai"></div>
|
||||
<button type="button" class="button bis-add-item" data-type="plugin" data-source="wenpai">
|
||||
<span class="dashicons dashicons-plus"></span> <?php _e('Add WenPai Plugin', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="bis-source-section" data-source="url">
|
||||
<h4>
|
||||
<span class="dashicons dashicons-admin-links"></span>
|
||||
<?php _e('Remote URLs', 'bulk-installer-server'); ?>
|
||||
</h4>
|
||||
<p class="bis-source-description"><?php _e('Add plugins from direct download URLs (ZIP files).', 'bulk-installer-server'); ?></p>
|
||||
<div class="bis-items-container" id="bis-plugins-url"></div>
|
||||
<button type="button" class="button bis-add-item" data-type="plugin" data-source="url">
|
||||
<span class="dashicons dashicons-plus"></span> <?php _e('Add URL Plugin', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="bis-tab-themes" class="bis-tab-content">
|
||||
<div class="bis-source-sections">
|
||||
<div class="bis-source-section" data-source="repository">
|
||||
<h4>
|
||||
<span class="dashicons dashicons-wordpress"></span>
|
||||
<?php _e('WordPress.org Repository', 'bulk-installer-server'); ?>
|
||||
</h4>
|
||||
<p class="bis-source-description"><?php _e('Add themes from the official WordPress.org theme repository.', 'bulk-installer-server'); ?></p>
|
||||
<div class="bis-items-container" id="bis-themes-repository"></div>
|
||||
<button type="button" class="button bis-add-item" data-type="theme" data-source="repository">
|
||||
<span class="dashicons dashicons-plus"></span> <?php _e('Add Repository Theme', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="bis-source-section" data-source="wenpai">
|
||||
<h4>
|
||||
<span class="dashicons dashicons-share-alt"></span>
|
||||
<?php _e('WenPai.org Repository', 'bulk-installer-server'); ?>
|
||||
</h4>
|
||||
<p class="bis-source-description"><?php _e('Add themes from the WenPai.org theme repository.', 'bulk-installer-server'); ?></p>
|
||||
<div class="bis-items-container" id="bis-themes-wenpai"></div>
|
||||
<button type="button" class="button bis-add-item" data-type="theme" data-source="wenpai">
|
||||
<span class="dashicons dashicons-plus"></span> <?php _e('Add WenPai Theme', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="bis-source-section" data-source="url">
|
||||
<h4>
|
||||
<span class="dashicons dashicons-admin-links"></span>
|
||||
<?php _e('Remote URLs', 'bulk-installer-server'); ?>
|
||||
</h4>
|
||||
<p class="bis-source-description"><?php _e('Add themes from direct download URLs (ZIP files).', 'bulk-installer-server'); ?></p>
|
||||
<div class="bis-items-container" id="bis-themes-url"></div>
|
||||
<button type="button" class="button bis-add-item" data-type="theme" data-source="url">
|
||||
<span class="dashicons dashicons-plus"></span> <?php _e('Add URL Theme', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-actions">
|
||||
<button type="submit" class="button button-primary button-large bis-save-collection">
|
||||
<span class="dashicons dashicons-saved"></span> <?php _e('Save Collection', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
<button type="button" class="button button-large bis-cancel-edit">
|
||||
<span class="dashicons dashicons-no"></span> <?php _e('Cancel', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="bis-card" id="bis-welcome-card">
|
||||
<h2><?php _e('Welcome to Collection Manager', 'bulk-installer-server'); ?></h2>
|
||||
<p class="bis-welcome-intro"><?php _e('Create and manage collections of plugins and themes that can be easily installed with the Bulk Plugin Installer client.', 'bulk-installer-server'); ?></p>
|
||||
|
||||
<div class="bis-welcome-content">
|
||||
<div class="bis-welcome-step">
|
||||
<div class="bis-step-icon">
|
||||
<span class="dashicons dashicons-plus-alt"></span>
|
||||
</div>
|
||||
<div class="bis-step-content">
|
||||
<h3><?php _e('Create Collections', 'bulk-installer-server'); ?></h3>
|
||||
<p><?php _e('Build collections of plugins and themes for different website types like e-commerce, business, portfolio, etc.', 'bulk-installer-server'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-welcome-step">
|
||||
<div class="bis-step-icon">
|
||||
<span class="dashicons dashicons-rest-api"></span>
|
||||
</div>
|
||||
<div class="bis-step-content">
|
||||
<h3><?php _e('Share via API', 'bulk-installer-server'); ?></h3>
|
||||
<p><?php _e('Your collections are automatically available via the REST API. Simply share the URL with your clients or team.', 'bulk-installer-server'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-welcome-step">
|
||||
<div class="bis-step-icon">
|
||||
<span class="dashicons dashicons-download"></span>
|
||||
</div>
|
||||
<div class="bis-step-content">
|
||||
<h3><?php _e('Export and Import', 'bulk-installer-server'); ?></h3>
|
||||
<p><?php _e('Export collections as JSON files that can be imported on other sites or shared with your team.', 'bulk-installer-server'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-welcome-step">
|
||||
<div class="bis-step-icon">
|
||||
<span class="dashicons dashicons-admin-tools"></span>
|
||||
</div>
|
||||
<div class="bis-step-content">
|
||||
<h3><?php _e('Faster Site Setup', 'bulk-installer-server'); ?></h3>
|
||||
<p><?php _e('Create website templates with pre-defined sets of plugins and themes for faster site setup.', 'bulk-installer-server'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bis-welcome-actions">
|
||||
<button type="button" class="button button-hero button-primary bis-new-collection">
|
||||
<span class="dashicons dashicons-plus"></span>
|
||||
<?php _e('Create Your First Collection', 'bulk-installer-server'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Item Template -->
|
||||
<script type="text/template" id="bis-item-template">
|
||||
<div class="bis-item" data-id="{{id}}">
|
||||
<div class="bis-item-header">
|
||||
<div class="bis-item-info">
|
||||
<h4 class="bis-item-title">{{name}}</h4>
|
||||
<div class="bis-item-slug">{{slug}}</div>
|
||||
</div>
|
||||
<div class="bis-item-actions">
|
||||
<label class="bis-required-toggle">
|
||||
<input type="checkbox" class="bis-item-required" {{required}}>
|
||||
<?php _e('Required', 'bulk-installer-server'); ?>
|
||||
</label>
|
||||
<button type="button" class="bis-edit-item button button-small">
|
||||
<span class="dashicons dashicons-edit"></span>
|
||||
</button>
|
||||
<button type="button" class="bis-remove-item button button-small">
|
||||
<span class="dashicons dashicons-no"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bis-item-description">{{description}}</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- Item Edit Modal -->
|
||||
<div id="bis-item-modal" class="bis-modal" style="display:none;">
|
||||
<div class="bis-modal-content">
|
||||
<div class="bis-modal-header">
|
||||
<h3 id="bis-modal-title"><?php _e('Edit Item', 'bulk-installer-server'); ?></h3>
|
||||
<button type="button" class="bis-modal-close">×</button>
|
||||
</div>
|
||||
<div class="bis-modal-body">
|
||||
<form id="bis-item-form">
|
||||
<input type="hidden" id="bis-item-id" name="item_id" value="">
|
||||
<input type="hidden" id="bis-item-type" name="item_type" value="">
|
||||
<input type="hidden" id="bis-item-source" name="item_source" value="">
|
||||
|
||||
<div class="bis-form-row">
|
||||
<label for="bis-item-slug"><?php _e('Slug:', 'bulk-installer-server'); ?> <span class="bis-required">*</span></label>
|
||||
<input type="text" id="bis-item-slug" name="item_slug" required>
|
||||
<p class="description"><?php _e('The plugin/theme slug from the repository or a unique identifier for URL items.', 'bulk-installer-server'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-row">
|
||||
<label for="bis-item-name"><?php _e('Name:', 'bulk-installer-server'); ?> <span class="bis-required">*</span></label>
|
||||
<input type="text" id="bis-item-name" name="item_name" required>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-row">
|
||||
<label for="bis-item-description"><?php _e('Description:', 'bulk-installer-server'); ?></label>
|
||||
<textarea id="bis-item-description" name="item_description" rows="3"></textarea>
|
||||
</div>
|
||||
|
||||
<div id="bis-url-field" class="bis-form-row" style="display:none;">
|
||||
<label for="bis-item-url"><?php _e('URL:', 'bulk-installer-server'); ?> <span class="bis-required">*</span></label>
|
||||
<input type="url" id="bis-item-url" name="item_url">
|
||||
<p class="description"><?php _e('Direct download URL for the ZIP file.', 'bulk-installer-server'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="bis-form-row">
|
||||
<label class="bis-checkbox-label">
|
||||
<input type="checkbox" id="bis-item-required" name="item_required">
|
||||
<?php _e('Required', 'bulk-installer-server'); ?>
|
||||
</label>
|
||||
<p class="description"><?php _e('Mark as required if this item is essential for the collection.', 'bulk-installer-server'); ?></p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="bis-modal-footer">
|
||||
<button type="button" class="button bis-modal-cancel"><?php _e('Cancel', 'bulk-installer-server'); ?></button>
|
||||
<button type="button" class="button button-primary bis-save-item"><?php _e('Save Item', 'bulk-installer-server'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import Modal -->
|
||||
<div id="bis-import-modal" class="bis-modal" style="display:none;">
|
||||
<div class="bis-modal-content">
|
||||
<div class="bis-modal-header">
|
||||
<h3><?php _e('Import Collection', 'bulk-installer-server'); ?></h3>
|
||||
<button type="button" class="bis-modal-close">×</button>
|
||||
</div>
|
||||
<div class="bis-modal-body">
|
||||
<p><?php _e('Paste the JSON collection data below:', 'bulk-installer-server'); ?></p>
|
||||
<textarea id="bis-import-data" rows="10" class="large-text code" placeholder="<?php esc_attr_e('Paste JSON collection data here...', 'bulk-installer-server'); ?>"></textarea>
|
||||
</div>
|
||||
<div class="bis-modal-footer">
|
||||
<button type="button" class="button bis-modal-cancel"><?php _e('Cancel', 'bulk-installer-server'); ?></button>
|
||||
<button type="button" class="button button-primary bis-import-submit"><?php _e('Import', 'bulk-installer-server'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue