plugin udpates
This commit is contained in:
@@ -30,17 +30,7 @@ class IGNY8_Post_Meta_Boxes {
|
||||
// Only add meta boxes for posts that have IGNY8 content ID
|
||||
$screen = get_current_screen();
|
||||
if ($screen && $screen->post_type === 'post') {
|
||||
// Keywords meta box
|
||||
add_meta_box(
|
||||
'igny8_keywords',
|
||||
__('IGNY8 Keywords', 'igny8-bridge'),
|
||||
array($this, 'render_keywords_meta_box'),
|
||||
'post',
|
||||
'side',
|
||||
'high'
|
||||
);
|
||||
|
||||
// SEO meta box
|
||||
// SEO meta box (includes keywords now)
|
||||
add_meta_box(
|
||||
'igny8_seo',
|
||||
__('IGNY8 SEO', 'igny8-bridge'),
|
||||
@@ -50,6 +40,16 @@ class IGNY8_Post_Meta_Boxes {
|
||||
'high'
|
||||
);
|
||||
|
||||
// Images meta box
|
||||
add_meta_box(
|
||||
'igny8_images',
|
||||
__('IGNY8 Images', 'igny8-bridge'),
|
||||
array($this, 'render_images_meta_box'),
|
||||
'post',
|
||||
'side',
|
||||
'default'
|
||||
);
|
||||
|
||||
// Sync data meta box (read-only info)
|
||||
add_meta_box(
|
||||
'igny8_sync_data',
|
||||
@@ -63,18 +63,86 @@ class IGNY8_Post_Meta_Boxes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Keywords meta box
|
||||
* Render Images meta box
|
||||
*/
|
||||
public function render_keywords_meta_box($post) {
|
||||
wp_nonce_field('igny8_keywords_nonce', 'igny8_keywords_nonce');
|
||||
public function render_images_meta_box($post) {
|
||||
$featured_image_id = get_post_thumbnail_id($post->ID);
|
||||
$gallery_images = get_post_meta($post->ID, '_igny8_gallery_images', true);
|
||||
$in_article_images = get_post_meta($post->ID, '_igny8_imported_images', true);
|
||||
|
||||
?>
|
||||
<div class="igny8-images-info">
|
||||
<?php if ($featured_image_id): ?>
|
||||
<p>
|
||||
<strong><?php _e('Featured Image:', 'igny8-bridge'); ?></strong><br>
|
||||
<?php echo wp_get_attachment_image($featured_image_id, 'thumbnail'); ?>
|
||||
</p>
|
||||
<?php else: ?>
|
||||
<p class="description"><?php _e('No featured image set', 'igny8-bridge'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($gallery_images) && is_array($gallery_images)): ?>
|
||||
<p>
|
||||
<strong><?php _e('Gallery Images:', 'igny8-bridge'); ?> (<?php echo count($gallery_images); ?>)</strong><br>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px;">
|
||||
<?php foreach (array_slice($gallery_images, 0, 4) as $img_id): ?>
|
||||
<?php echo wp_get_attachment_image($img_id, 'thumbnail', false, array('style' => 'max-width: 60px; height: auto;')); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if (count($gallery_images) > 4): ?>
|
||||
<span style="align-self: center; color: #666;">+<?php echo count($gallery_images) - 4; ?> more</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($in_article_images) && is_array($in_article_images)): ?>
|
||||
<p>
|
||||
<strong><?php _e('In-Article Images:', 'igny8-bridge'); ?></strong><br>
|
||||
<span class="description"><?php echo count($in_article_images); ?> images embedded in content</span>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$featured_image_id && empty($gallery_images) && empty($in_article_images)): ?>
|
||||
<p class="description"><?php _e('No images published yet', 'igny8-bridge'); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.igny8-images-info img {
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
padding: 2px;
|
||||
}
|
||||
.igny8-images-info p {
|
||||
margin: 10px 0;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render SEO meta box
|
||||
*/
|
||||
public function render_seo_meta_box($post) {
|
||||
wp_nonce_field('igny8_seo_nonce', 'igny8_seo_nonce');
|
||||
|
||||
$cluster_name = get_post_meta($post->ID, '_igny8_cluster_name', true);
|
||||
$primary_keyword = get_post_meta($post->ID, '_igny8_primary_keyword', true);
|
||||
$secondary_keywords = get_post_meta($post->ID, '_igny8_secondary_keywords', true);
|
||||
$meta_title = get_post_meta($post->ID, '_igny8_meta_title', true);
|
||||
$meta_description = get_post_meta($post->ID, '_igny8_meta_description', true);
|
||||
|
||||
// Convert comma-separated string to array for display
|
||||
$secondary_keywords_array = !empty($secondary_keywords) ? explode(',', $secondary_keywords) : array();
|
||||
|
||||
?>
|
||||
<div class="igny8-keywords-fields">
|
||||
<div class="igny8-seo-fields">
|
||||
<?php if ($cluster_name): ?>
|
||||
<p style="margin-bottom: 15px;">
|
||||
<strong style="font-size: 14px;"><?php echo esc_html($cluster_name); ?></strong>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p>
|
||||
<label for="igny8_primary_keyword"><strong><?php _e('Primary Keyword:', 'igny8-bridge'); ?></strong></label><br>
|
||||
<input type="text" id="igny8_primary_keyword" name="igny8_primary_keyword"
|
||||
@@ -92,34 +160,7 @@ class IGNY8_Post_Meta_Boxes {
|
||||
?></textarea>
|
||||
<span class="description"><?php _e('Enter one keyword per line', 'igny8-bridge'); ?></span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.igny8-keywords-fields input[type="text"],
|
||||
.igny8-keywords-fields textarea {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.igny8-keywords-fields .description {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
font-style: italic;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render SEO meta box
|
||||
*/
|
||||
public function render_seo_meta_box($post) {
|
||||
wp_nonce_field('igny8_seo_nonce', 'igny8_seo_nonce');
|
||||
|
||||
$meta_title = get_post_meta($post->ID, '_igny8_meta_title', true);
|
||||
$meta_description = get_post_meta($post->ID, '_igny8_meta_description', true);
|
||||
|
||||
?>
|
||||
<div class="igny8-seo-fields">
|
||||
|
||||
<p>
|
||||
<label for="igny8_meta_title"><strong><?php _e('SEO Title:', 'igny8-bridge'); ?></strong></label><br>
|
||||
<input type="text" id="igny8_meta_title" name="igny8_meta_title"
|
||||
@@ -156,6 +197,16 @@ class IGNY8_Post_Meta_Boxes {
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Max width when shown below editor */
|
||||
#igny8_seo.postbox {
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
/* Full width when in sidebar */
|
||||
.inner-sidebar #igny8_seo.postbox {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.igny8-seo-fields input[type="text"],
|
||||
.igny8-seo-fields textarea {
|
||||
margin-top: 5px;
|
||||
@@ -284,8 +335,8 @@ class IGNY8_Post_Meta_Boxes {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save keywords
|
||||
if (isset($_POST['igny8_keywords_nonce']) && wp_verify_nonce($_POST['igny8_keywords_nonce'], 'igny8_keywords_nonce')) {
|
||||
// Save SEO fields (includes keywords now)
|
||||
if (isset($_POST['igny8_seo_nonce']) && wp_verify_nonce($_POST['igny8_seo_nonce'], 'igny8_seo_nonce')) {
|
||||
// Save primary keyword
|
||||
if (isset($_POST['igny8_primary_keyword'])) {
|
||||
$primary_keyword = sanitize_text_field($_POST['igny8_primary_keyword']);
|
||||
@@ -300,10 +351,7 @@ class IGNY8_Post_Meta_Boxes {
|
||||
$secondary_keywords = implode(',', $secondary_keywords_array);
|
||||
update_post_meta($post_id, '_igny8_secondary_keywords', $secondary_keywords);
|
||||
}
|
||||
}
|
||||
|
||||
// Save SEO fields
|
||||
if (isset($_POST['igny8_seo_nonce']) && wp_verify_nonce($_POST['igny8_seo_nonce'], 'igny8_seo_nonce')) {
|
||||
|
||||
// Save meta title
|
||||
if (isset($_POST['igny8_meta_title'])) {
|
||||
$meta_title = sanitize_text_field($_POST['igny8_meta_title']);
|
||||
|
||||
@@ -156,15 +156,20 @@ function igny8_create_wordpress_post_from_task($content_data, $allowed_post_type
|
||||
}
|
||||
|
||||
if (!empty($content_data['secondary_keywords'])) {
|
||||
// Store as JSON for editing in meta box
|
||||
// Store as comma-separated for easy editing
|
||||
$keywords = is_array($content_data['secondary_keywords'])
|
||||
? $content_data['secondary_keywords']
|
||||
: json_decode($content_data['secondary_keywords'], true);
|
||||
if (is_array($keywords)) {
|
||||
$post_data['meta_input']['_igny8_secondary_keywords'] = json_encode($keywords);
|
||||
$post_data['meta_input']['_igny8_secondary_keywords'] = implode(',', $keywords);
|
||||
}
|
||||
}
|
||||
|
||||
// Store cluster name for display in meta box
|
||||
if (!empty($content_data['cluster_name'])) {
|
||||
$post_data['meta_input']['_igny8_cluster_name'] = $content_data['cluster_name'];
|
||||
}
|
||||
|
||||
// Create post
|
||||
$post_id = wp_insert_post($post_data);
|
||||
|
||||
@@ -322,8 +327,12 @@ function igny8_create_wordpress_post_from_task($content_data, $allowed_post_type
|
||||
|
||||
// Handle gallery images
|
||||
if (!empty($content_data['gallery_images'])) {
|
||||
Igny8_Logger::info("{$log_prefix} STEP: Setting gallery with " . count($content_data['gallery_images']) . " images");
|
||||
igny8_set_image_gallery($post_id, $content_data['gallery_images']);
|
||||
$gallery_count = count($content_data['gallery_images']);
|
||||
Igny8_Logger::info("{$log_prefix} STEP: Setting gallery with {$gallery_count} images");
|
||||
$gallery_ids = igny8_set_image_gallery($post_id, $content_data['gallery_images']);
|
||||
if (!empty($gallery_ids)) {
|
||||
Igny8_Logger::info("{$log_prefix} ✅ Attached {$gallery_count} gallery images (IDs: " . implode(', ', $gallery_ids) . ")");
|
||||
}
|
||||
}
|
||||
|
||||
// Get the actual WordPress post status (after creation)
|
||||
@@ -1167,7 +1176,10 @@ function igny8_import_content_images($post_id, $content_html) {
|
||||
update_post_meta($post_id, '_igny8_imported_images', $imported_images);
|
||||
update_post_meta($post_id, '_igny8_images_imported_at', current_time('mysql'));
|
||||
|
||||
error_log("IGNY8: Imported " . count($imported_images) . " content images for post {$post_id}");
|
||||
$log_prefix = "[" . get_option('igny8_site_id', 'N/A') . "-" . parse_url(site_url(), PHP_URL_HOST) . "]";
|
||||
$image_count = count($imported_images);
|
||||
Igny8_Logger::info("{$log_prefix} STEP: Imported {$image_count} in-article images");
|
||||
Igny8_Logger::info("{$log_prefix} ✅ In-article image IDs: " . implode(', ', $imported_images));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user