plugin udpates

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-01 09:47:38 +00:00
parent f860a20fa0
commit 7631a77822
2 changed files with 114 additions and 54 deletions

View File

@@ -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']);