Skip to content

Commit

Permalink
Add field to show template
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Taylor committed Jan 19, 2024
1 parent a367e32 commit d2a8edf
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions custom-file-organizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,44 @@
Text Domain: custom-file-organizer
Domain Path: /languages
Requires at least: 5.0
Tested up to: 5.8
Requires PHP: 7.0
Requires PHP: 7.4
*/

if (! defined('ABSPATH') ) {
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}

if (defined('WP_CLI') && WP_CLI ) {
add_filter('upload_dir', 'wpb_custom_upload_directory');

/**
* Change custom upload directory pattern.
*/
function wpb_custom_upload_directory($param)
{
$uploadPattern = get_current_upload_pattern();
$param['path'] = $param['basedir'] . $uploadPattern;
$param['url'] = $param['baseurl'] . $uploadPattern;
return $param;
}


/**
* Get the current upload directory pattern.
*
* @return string The upload directory pattern.
*/
function get_current_upload_pattern()
{
$time = current_time('mysql');
$y = substr($time, 0, 4);
$m = substr($time, 5, 2);
$d = substr($time, 8, 2);
return "/$y/$m/$d";
}



if (defined('WP_CLI') && WP_CLI) {
include_once __DIR__ . '/includes/class-custom-file-organizer-cli.php';
WP_CLI::add_command('file-organizer', 'Custom_File_Organizer_CLI');
}
Expand All @@ -40,39 +69,26 @@ function custom_file_organizer_admin_menu()

function custom_file_organizer_admin_page()
{
?>
<div class="wrap">
<h1>
<?php _e('File Organizer', 'custom-file-organizer'); ?>
</h1>
<!-- TODO: Add content and logic for admin page here -->
</div>
<?php
}
$uploadPattern = get_current_upload_pattern();

function custom_file_organizer_admin_page()
{
// Example content - modify as needed
echo '<div class="wrap">';
echo '<h1>' . esc_html__('File Organizer Status', 'custom-file-organizer') . '</h1>';

// Display the current upload pattern
echo '<h2>' . esc_html__('Current Upload Directory Pattern', 'custom-file-organizer') . '</h2>';
echo '<input type="text" value="' . esc_attr($uploadPattern) . '" disabled>';


// Example table
echo '<h2>' . esc_html__('Recent File Movements', 'custom-file-organizer') . '</h2>';
echo '<table class="wp-list-table widefat fixed striped">';
echo '<thead><tr><th>' . esc_html__('Before', 'custom-file-organizer') . '</th><th>' . esc_html__('After', 'custom-file-organizer') . '</th></tr></thead>';
echo '<tbody>';

// Fetch and display recent file movement data
// This is a placeholder - you'll need to fetch real data
echo '<tr><td>' . esc_html__('Path/Before.jpg', 'custom-file-organizer') . '</td><td>' . esc_html__('Path/After.jpg', 'custom-file-organizer') . '</td></tr>';

echo '</tbody></table>';
echo '</div>';
}

add_action('admin_enqueue_scripts', 'custom_file_organizer_admin_scripts');

function custom_file_organizer_admin_scripts()
{
// Enqueue custom styles and scripts here
}

0 comments on commit d2a8edf

Please sign in to comment.