167 lines
8.3 KiB
PHP
167 lines
8.3 KiB
PHP
|
<div class="wrap">
|
||
|
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
||
|
|
||
|
<?php if (!empty($settings['connection_status'])) : ?>
|
||
|
<?php if ($settings['connection_status'] === 'connected') : ?>
|
||
|
<div class="notice notice-success">
|
||
|
<p><?php _e('Successfully connected to Bluesky!', 'bluesky-connector'); ?></p>
|
||
|
</div>
|
||
|
<?php else : ?>
|
||
|
<div class="notice notice-error">
|
||
|
<p><?php printf(__('Connection error: %s', 'bluesky-connector'), esc_html($settings['last_error'])); ?></p>
|
||
|
</div>
|
||
|
<?php endif; ?>
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<div class="card">
|
||
|
<h2><?php _e('Connection Settings', 'bluesky-connector'); ?></h2>
|
||
|
<form method="post" action="">
|
||
|
<?php wp_nonce_field('bluesky_connector_settings'); ?>
|
||
|
<input type="hidden" name="action" value="update_bluesky_settings">
|
||
|
|
||
|
<table class="form-table" role="presentation">
|
||
|
<tr>
|
||
|
<th scope="row">
|
||
|
<label for="bluesky_domain"><?php _e('Bluesky Domain', 'bluesky-connector'); ?></label>
|
||
|
</th>
|
||
|
<td>
|
||
|
<input name="bluesky_domain"
|
||
|
type="url"
|
||
|
id="bluesky_domain"
|
||
|
value="https://bsky.social"
|
||
|
class="regular-text"
|
||
|
readonly>
|
||
|
<p class="description">
|
||
|
<?php _e('The Bluesky API domain (fixed to https://bsky.social)', 'bluesky-connector'); ?>
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th scope="row">
|
||
|
<label for="bluesky_identifier"><?php _e('Bluesky Handle', 'bluesky-connector'); ?></label>
|
||
|
</th>
|
||
|
<td>
|
||
|
<input name="bluesky_identifier"
|
||
|
type="text"
|
||
|
id="bluesky_identifier"
|
||
|
value="<?php echo esc_attr($settings['identifier']); ?>"
|
||
|
class="regular-text"
|
||
|
placeholder="username.bsky.social"
|
||
|
required>
|
||
|
<p class="description">
|
||
|
<?php _e('Your full Bluesky handle (e.g., username.bsky.social)', 'bluesky-connector'); ?>
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th scope="row">
|
||
|
<label for="bluesky_password"><?php _e('App Password', 'bluesky-connector'); ?></label>
|
||
|
</th>
|
||
|
<td>
|
||
|
<input name="bluesky_password"
|
||
|
type="password"
|
||
|
id="bluesky_password"
|
||
|
class="regular-text"
|
||
|
<?php echo empty($settings['identifier']) ? 'required' : ''; ?>>
|
||
|
<p class="description">
|
||
|
<?php _e('Your Bluesky app password (will not be stored)', 'bluesky-connector'); ?>
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<?php submit_button(__('Save Connection Settings', 'bluesky-connector')); ?>
|
||
|
</form>
|
||
|
</div>
|
||
|
|
||
|
<?php if (!empty($settings['connection_status']) && $settings['connection_status'] === 'connected') : ?>
|
||
|
<div class="card" style="margin-top: 20px;">
|
||
|
<h2><?php _e('Post Format Settings', 'bluesky-connector'); ?></h2>
|
||
|
<form method="post" action="options.php">
|
||
|
<?php settings_fields('bluesky_connector_settings'); ?>
|
||
|
<table class="form-table" role="presentation">
|
||
|
<tr>
|
||
|
<th scope="row">
|
||
|
<label for="bluesky_post_format"><?php _e('Post Layout', 'bluesky-connector'); ?></label>
|
||
|
</th>
|
||
|
<td>
|
||
|
<select name="bluesky_post_format" id="bluesky_post_format">
|
||
|
<option value="title-excerpt-link" <?php selected(get_option('bluesky_post_format'), 'title-excerpt-link'); ?>>
|
||
|
<?php _e('Title + Excerpt + Link (No Image)', 'bluesky-connector'); ?>
|
||
|
</option>
|
||
|
<option value="image-title-excerpt-link" <?php selected(get_option('bluesky_post_format'), 'image-title-excerpt-link'); ?>>
|
||
|
<?php _e('Image + Title + Excerpt + Link (Image will appear at top)', 'bluesky-connector'); ?>
|
||
|
</option>
|
||
|
</select>
|
||
|
<p class="description">
|
||
|
<?php _e('Note: When including images, Bluesky will always display them at the top of the post regardless of format selection.', 'bluesky-connector'); ?>
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th scope="row">
|
||
|
<label for="bluesky_include_title"><?php _e('Title Options', 'bluesky-connector'); ?></label>
|
||
|
</th>
|
||
|
<td>
|
||
|
<label>
|
||
|
<input type="checkbox"
|
||
|
name="bluesky_include_title"
|
||
|
id="bluesky_include_title"
|
||
|
value="1"
|
||
|
<?php checked(get_option('bluesky_include_title', true)); ?>>
|
||
|
<?php _e('Include post title when format includes title', 'bluesky-connector'); ?>
|
||
|
</label>
|
||
|
<p class="description">
|
||
|
<?php _e('When enabled, the post title will be included at the beginning of the post text.', 'bluesky-connector'); ?>
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<?php submit_button(__('Save Format Settings', 'bluesky-connector')); ?>
|
||
|
</form>
|
||
|
</div>
|
||
|
|
||
|
<div class="card" style="margin-top: 20px;">
|
||
|
<h2><?php _e('Queue Management', 'bluesky-connector'); ?></h2>
|
||
|
<?php
|
||
|
$queue = get_option('bluesky_post_queue', array());
|
||
|
$queue_count = count($queue);
|
||
|
?>
|
||
|
<p>
|
||
|
<?php printf(
|
||
|
_n(
|
||
|
'There is %s post in the queue.',
|
||
|
'There are %s posts in the queue.',
|
||
|
$queue_count,
|
||
|
'bluesky-connector'
|
||
|
),
|
||
|
number_format_i18n($queue_count)
|
||
|
); ?>
|
||
|
</p>
|
||
|
|
||
|
<?php if ($queue_count > 0) : ?>
|
||
|
<form method="post" style="margin-top: 10px;">
|
||
|
<?php wp_nonce_field('bluesky_process_queue'); ?>
|
||
|
<input type="submit" name="process_queue_now" class="button button-primary"
|
||
|
value="<?php esc_attr_e('Process Queue Now', 'bluesky-connector'); ?>">
|
||
|
</form>
|
||
|
<?php endif; ?>
|
||
|
</div>
|
||
|
|
||
|
<?php if (WP_DEBUG) : ?>
|
||
|
<div class="card" style="margin-top: 20px;">
|
||
|
<h2><?php _e('Connection Status', 'bluesky-connector'); ?></h2>
|
||
|
<table class="form-table" role="presentation">
|
||
|
<tr>
|
||
|
<th scope="row"><?php _e('DID', 'bluesky-connector'); ?></th>
|
||
|
<td><code><?php echo esc_html(get_option('bluesky_did')); ?></code></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th scope="row"><?php _e('Last Token Refresh', 'bluesky-connector'); ?></th>
|
||
|
<td><?php echo esc_html(get_option('bluesky_token_created') ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), get_option('bluesky_token_created')) : __('Never', 'bluesky-connector')); ?></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<?php endif; ?>
|
||
|
<?php endif; ?>
|
||
|
</div>
|