| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <?php
- /**
- * The admin-specific functionality of the plugin.
- *
- * Defines the plugin name, version, and hooks for
- * the admin area of the site.
- *
- * @package QDR_Temporary_Shared_Storage
- * @since 1.0.0
- */
- class QDR_TSS_Admin {
- /**
- * The ID of this plugin.
- *
- * @since 1.0.0
- * @access private
- * @var string $plugin_name The ID of this plugin.
- */
- private $plugin_name;
- /**
- * The version of this plugin.
- *
- * @since 1.0.0
- * @access private
- * @var string $version The current version of this plugin.
- */
- private $version;
- /**
- * Initialize the class and set its properties.
- *
- * @since 1.0.0
- * @param string $plugin_name The name of this plugin.
- * @param string $version The version of this plugin.
- */
- public function __construct($plugin_name, $version) {
- $this->plugin_name = $plugin_name;
- $this->version = $version;
- }
- /**
- * Register the stylesheets for the admin area.
- *
- * @since 1.0.0
- */
- public function enqueue_styles() {
- // Only load on plugin admin pages
- $screen = get_current_screen();
- if (strpos($screen->id, 'qdr-temporary-shared-storage') === false) {
- return;
- }
-
- wp_enqueue_style(
- $this->plugin_name . '-admin',
- plugin_dir_url(dirname(__FILE__)) . 'admin/css/admin.css',
- array(),
- $this->version,
- 'all'
- );
-
- // Add jQuery UI styles for datepicker
- wp_enqueue_style('jquery-ui-datepicker');
- }
- /**
- * Register the JavaScript for the admin area.
- *
- * @since 1.0.0
- */
- public function enqueue_scripts() {
- // Only load on plugin admin pages
- $screen = get_current_screen();
- if (strpos($screen->id, 'qdr-temporary-shared-storage') === false) {
- return;
- }
-
- wp_enqueue_script(
- $this->plugin_name . '-admin',
- plugin_dir_url(dirname(__FILE__)) . 'admin/js/admin.js',
- array('jquery', 'jquery-ui-datepicker'),
- $this->version,
- true
- );
-
- // Localize script with translations and data
- wp_localize_script($this->plugin_name . '-admin', 'qdr_tss', array(
- 'ajaxurl' => admin_url('admin-ajax.php'),
- 'nonce' => wp_create_nonce('qdr_tss_nonce'),
- 'strings' => array(
- 'loading' => __('Loading...', 'qdr-temporary-shared-storage'),
- 'saving' => __('Saving...', 'qdr-temporary-shared-storage'),
- 'no_items' => __('No items', 'qdr-temporary-shared-storage'),
- 'no_items_found' => __('No items found.', 'qdr-temporary-shared-storage'),
- 'showing' => __('Showing', 'qdr-temporary-shared-storage'),
- 'of' => __('of', 'qdr-temporary-shared-storage'),
- 'first_page' => __('First Page', 'qdr-temporary-shared-storage'),
- 'previous_page' => __('Previous Page', 'qdr-temporary-shared-storage'),
- 'next_page' => __('Next Page', 'qdr-temporary-shared-storage'),
- 'last_page' => __('Last Page', 'qdr-temporary-shared-storage'),
- 'view_details' => __('View Details', 'qdr-temporary-shared-storage'),
- 'edit' => __('Edit', 'qdr-temporary-shared-storage'),
- 'delete' => __('Delete', 'qdr-temporary-shared-storage'),
- 'copy_permalink' => __('Copy Permalink', 'qdr-temporary-shared-storage'),
- 'force_activate' => __('Force Activate', 'qdr-temporary-shared-storage'),
- 'confirm_delete' => __('Are you sure you want to delete this file?', 'qdr-temporary-shared-storage'),
- 'confirm_purge' => __('Are you sure you want to purge all expired files?', 'qdr-temporary-shared-storage'),
- 'confirm_force_activate' => __('Are you sure you want to force activate this file? This will reset the active period starting from now.', 'qdr-temporary-shared-storage'),
- 'error_loading_items' => __('Error loading items.', 'qdr-temporary-shared-storage'),
- 'error_loading_items_try_again' => __('Error loading items. Please try again.', 'qdr-temporary-shared-storage'),
- 'error_loading_item_details' => __('Error loading item details.', 'qdr-temporary-shared-storage'),
- 'error_loading_item_details_try_again' => __('Error loading item details. Please try again.', 'qdr-temporary-shared-storage'),
- 'changes_saved' => __('Changes saved successfully.', 'qdr-temporary-shared-storage'),
- 'error_saving_changes' => __('Error saving changes.', 'qdr-temporary-shared-storage'),
- 'error_saving_changes_try_again' => __('Error saving changes. Please try again.', 'qdr-temporary-shared-storage'),
- 'file_deleted' => __('File deleted successfully.', 'qdr-temporary-shared-storage'),
- 'error_deleting_file' => __('Error deleting file.', 'qdr-temporary-shared-storage'),
- 'error_deleting_file_try_again' => __('Error deleting file. Please try again.', 'qdr-temporary-shared-storage'),
- 'shortcode_copied' => __('Shortcode copied to clipboard.', 'qdr-temporary-shared-storage'),
- 'permalink_copied' => __('Permalink copied to clipboard.', 'qdr-temporary-shared-storage'),
- 'permalink_copied_to_clipboard' => __('Permalink copied to clipboard successfully.', 'qdr-temporary-shared-storage'),
- 'error_getting_permalink' => __('Error getting permalink.', 'qdr-temporary-shared-storage'),
- 'error_getting_permalink_try_again' => __('Error getting permalink. Please try again.', 'qdr-temporary-shared-storage'),
- 'item_force_activated' => __('Item has been force activated successfully.', 'qdr-temporary-shared-storage'),
- 'error_force_activating' => __('Error force activating item.', 'qdr-temporary-shared-storage'),
- 'error_force_activating_try_again' => __('Error force activating item. Please try again.', 'qdr-temporary-shared-storage'),
- )
- ));
- }
- /**
- * Add admin menu items.
- *
- * @since 1.0.0
- */
- public function add_admin_menu() {
- // Add Shared Storage page under Media menu
- add_submenu_page(
- 'upload.php',
- __('Shared Storage', 'qdr-temporary-shared-storage'),
- __('Shared Storage', 'qdr-temporary-shared-storage'),
- 'manage_options',
- 'qdr-temporary-shared-storage',
- array($this, 'render_media_page')
- );
-
- // Add Settings page
- add_submenu_page(
- 'options-general.php',
- __('Shared Storage Settings', 'qdr-temporary-shared-storage'),
- __('Shared Storage', 'qdr-temporary-shared-storage'),
- 'manage_options',
- 'qdr-temporary-shared-storage-settings',
- array($this, 'render_settings_page')
- );
- }
- /**
- * Render the Media Shared Storage admin page.
- *
- * @since 1.0.0
- */
- public function render_media_page() {
- require_once plugin_dir_path(dirname(__FILE__)) . 'admin/partials/media-page.php';
- }
- /**
- * Render the Settings admin page.
- *
- * @since 1.0.0
- */
- public function render_settings_page() {
- require_once plugin_dir_path(dirname(__FILE__)) . 'admin/partials/settings-page.php';
- }
- }
|