' . esc_html(__('Update failed:', 'ai-webmaster-studio')) . ' ' . esc_html($result->get_error_message()) . '

'; } else { $summary = isset($result['summary']) ? $result['summary'] : __('The content has been updated.', 'ai-webmaster-studio'); $notice = '

' . esc_html(__('The content has been updated.', 'ai-webmaster-studio')) . ' ' . esc_html($summary) . ' ' . esc_html(__('Edit', 'ai-webmaster-studio')) . ' | ' . esc_html(__('Preview', 'ai-webmaster-studio')) . '

'; } } if ($action === 'links') { $result = class_exists('AIWEST_Internal_Links') ? AIWEST_Internal_Links::link_post($post_id, 10) : new WP_Error('aiwest_links_missing', __('The internal linking module is not available.', 'ai-webmaster-studio')); if (is_wp_error($result)) { $notice = '

' . esc_html(__('Could not add links:', 'ai-webmaster-studio')) . ' ' . esc_html($result->get_error_message()) . '

'; } elseif (!empty($result['changed'])) { $notice = '

' . esc_html(__('Internal links have been added.', 'ai-webmaster-studio')) . ' ' . esc_html(__('Edit', 'ai-webmaster-studio')) . ' | ' . esc_html(__('View', 'ai-webmaster-studio')) . '

'; } else { $notice = '

' . esc_html($result['message'] ?? __('No new links were added.', 'ai-webmaster-studio')) . '

'; } } if ($action === 'undo') { $result = class_exists('AIWEST_Undo') ? AIWEST_Undo::restore_last($post_id) : new WP_Error('aiwest_undo_missing', __('The undo module is not available.', 'ai-webmaster-studio')); if (is_wp_error($result)) { $notice = '

' . esc_html(__('Could not undo changes:', 'ai-webmaster-studio')) . ' ' . esc_html($result->get_error_message()) . '

'; } else { $notice = '

' . esc_html(__('The latest AI changes have been undone.', 'ai-webmaster-studio')) . ' ' . esc_html(__('Edit', 'ai-webmaster-studio')) . ' | ' . esc_html(__('Preview', 'ai-webmaster-studio')) . '

'; } } if ($action === 'image') { $source = class_exists('AIWEST_Image_Generator') ? AIWEST_Image_Generator::automatic_source() : 'none'; if ($source === 'library' && class_exists('AIWEST_Content_Engine')) { $result = AIWEST_Content_Engine::handle_media_for_existing_post($post_id, ['action' => 'library', 'placement' => 'featured', 'auto_select_library' => 'yes'], get_the_title($post_id)); if (is_wp_error($result) || empty($result['attachment_id'])) { $message = is_wp_error($result) ? $result->get_error_message() : ($result['message'] ?? __('No available image was found in the Media Library.', 'ai-webmaster-studio')); $notice = '

' . esc_html(__('The image was not added:', 'ai-webmaster-studio')) . ' ' . esc_html($message) . '

'; } else { $notice = '

' . esc_html(__('The featured image from the Media Library has been assigned.', 'ai-webmaster-studio')) . ' ' . esc_html(__('Attachment ID:', 'ai-webmaster-studio')) . ' ' . intval($result['attachment_id']) . '. ' . esc_html(__('Edit content', 'ai-webmaster-studio')) . '

'; } } else { $result = AIWEST_Image_Generator::generate_for_post($post_id); if (is_wp_error($result)) { $notice = '

' . esc_html(__('The image was not added:', 'ai-webmaster-studio')) . ' ' . esc_html($result->get_error_message()) . '

'; } else { $notice = '

' . esc_html(__('The AI featured image has been generated and assigned.', 'ai-webmaster-studio')) . ' ' . esc_html(__('Attachment ID:', 'ai-webmaster-studio')) . ' ' . intval($result) . '. ' . esc_html(__('Edit content', 'ai-webmaster-studio')) . '

'; } } } } $orderby = AIWEST_Security::get_key('orderby', 'modified'); $order = strtoupper(AIWEST_Security::get_key('order', 'DESC')); if (!in_array($order, ['ASC','DESC'], true)) $order = 'DESC'; $allowed_orderby = ['ID'=>'ID','type'=>'type','title'=>'title','status'=>'status','modified'=>'modified']; if (!isset($allowed_orderby[$orderby])) $orderby = 'modified'; $posts = get_posts([ 'numberposts' => 120, 's' => $aiwest_content_search, 'post_type' => ['page', 'post'], 'post_status' => ['publish', 'draft', 'pending', 'private'], 'orderby' => $allowed_orderby[$orderby], 'order' => $order, ]); $sort_link = function($key, $label) use ($orderby, $order) { $next = ($orderby === $key && $order === 'ASC') ? 'DESC' : 'ASC'; $arrow = $orderby === $key ? ($order === 'ASC' ? ' ▲' : ' ▼') : ''; return '' . esc_html($label . $arrow) . ''; }; ?>

' . esc_html(__('AI — enabled', 'ai-webmaster-studio')) . ''; } elseif ($aiwest_graphics_source === 'library') { echo '' . esc_html(__('Media Library — enabled', 'ai-webmaster-studio')) . ''; } else { echo '' . esc_html(__('Disabled — enable in Settings', 'ai-webmaster-studio')) . ''; } ?>

ID); ?>
ID); ?> post_type)); ?> post_title); ?>
|
post_status)); ?> post_modified); ?> ' . esc_html(__('Available', 'ai-webmaster-studio')) . '' : '' . esc_html(__('Missing', 'ai-webmaster-studio')) . ''; ?> ID); ?> __('Preserve content and improve layout', 'ai-webmaster-studio'), 'improve' => __('Expand', 'ai-webmaster-studio'), 'seo' => __('Improve SEO', 'ai-webmaster-studio'), 'faq' => __('Add FAQ', 'ai-webmaster-studio'), 'cta' => __('Add CTA', 'ai-webmaster-studio'), 'image' => __('Add image', 'ai-webmaster-studio'), 'links' => __('Add links', 'ai-webmaster-studio'), 'rewrite' => __('Rewrite content', 'ai-webmaster-studio'), 'undo' => __('Undo changes', 'ai-webmaster-studio') ] as $act => $label): ?>
data-aiwest-confirm="">