'active', // active|archived|new
'show_tabs' => '1', // 1/0
], $atts, 'aiaas_projects');
if (!is_user_logged_in()) {
$login_url = wp_login_url(self::current_url());
return '
';
echo '
';
self::render_app_header('Projects'); self::render_frontend_nav('projects');
// Page purpose banner (Projects) — must appear ABOVE Current Project row.
echo '
' . esc_html(self::t('page.projects.purpose','Create or import a new project for books or book series.')) . '
';
if (method_exists(__CLASS__, 'render_free_upgrade_icon_row')) { self::render_free_upgrade_icon_row('projects'); }
if (method_exists(__CLASS__, 'render_beginner_mode_banner')) { self::render_beginner_mode_banner('projects', (int) self::req('project_id', 0, 'int'), 0); }
// Top row: Current Project + Language
// Guard against partial/older class loads during plugin update or opcode cache.
// Never hard-fatal the portal if this helper is missing.
if (method_exists(__CLASS__, 'render_current_project_and_language_row')) {
// Projects page: hide Language dropdown (Dashboard keeps it).
// IMPORTANT: honor ?project_id=... so the Current Project switcher does not
// snap back to the previous meta-stored project.
$pid_for_top = (int) self::req('project_id', 0, 'int');
self::render_current_project_and_language_row($pid_for_top, false);
} else {
$pid_for_top = (int) self::req('project_id', 0, 'int');
self::render_current_project_and_language_row_fallback($pid_for_top, false);
}
self::render_notice_frontend();
// (moved above Current Project row)
// If an export was just generated, show a direct download button.
$dl_file_param = (string) \AIAAS\Request::get('aiaas_export_file', 'text', '');
$dl_pid = (int) \AIAAS\Request::get('project_id', 'int', 0);
if ($dl_file_param !== '' && $dl_pid > 0) {
$dl_file = self::sanitize_export_filename(rawurldecode($dl_file_param));
if ($dl_file && $dl_pid) {
$nonce_action = 'aiaas_download_export_' . $dl_pid . '_' . $dl_file;
$dl_url = add_query_arg([
'action' => 'aiaas_download_export',
'project_id' => $dl_pid,
'file' => $dl_file,
'_wpnonce' => wp_create_nonce($nonce_action),
], admin_url('admin-post.php')); echo '
';
}
}
echo '
';
echo '
';
// LEFT: Import Book
self::render_projects_import_section_frontend();
echo '
';
echo '
';
// RIGHT: New Project (when on New tab) above New Projects
if ($tab === 'new') { self::render_new_project_form_frontend(); }
// RIGHT: New Projects (Create New + Samples)
self::render_sample_projects_panel_frontend();
echo '
';
echo '
';
// Saved vs Archived (side-by-side, stable full width, single search/sort bar)
$project_id = intval(self::req('project_id', 0, 'int'));
echo '
';
echo '
';
echo '
';
// One shared search/sort bar applies to both lists (avoid duplicated UI)
echo '';
echo '
'; // bar
echo '
';
echo '
';
echo '
Saved Projects
';
self::render_projects_overview_frontend(0, ['show_active'=>false,'show_archived'=>false,'show_saved'=>true,'show_filters'=>false,'show_title'=>false]);
echo '';
echo '
';
echo '
Archived Projects
';
self::render_projects_overview_frontend(0, ['show_active'=>false,'show_archived'=>true,'show_saved'=>false,'show_filters'=>false,'show_title'=>false]);
echo '';
echo '
'; // two-col
echo '
'; // section
echo '
'; // projects-lists-wrap
// No project is selected on the Projects list screen.
$project_id = 0;
self::render_bottom_panels((int)$project_id, '');
echo '
';
return ob_get_clean();
}
/**
* FREE-user upgrade link row shared across AAS pages.
*
* Hosted/subscription installs use the subscription direct checkout URLs.
* Plugin/self-installed configurations use the plugin-user direct buy URLs.
*/
private static function render_free_upgrade_icon_row(string $context = 'projects'): void {
$uid = (int) get_current_user_id();
$plan_now = 'FREE';
if (class_exists('\AIAAS\Entitlements')) {
if (method_exists('\AIAAS\Entitlements', 'get_user_plan')) {
$plan_now = strtoupper((string) \AIAAS\Entitlements::get_user_plan($uid));
} elseif (method_exists('\AIAAS\Entitlements', 'current_plan_label')) {
$plan_now = strtoupper((string) \AIAAS\Entitlements::current_plan_label($uid));
}
} elseif (method_exists(__CLASS__, 'get_user_plan')) {
$plan_now = strtoupper((string) self::get_user_plan($uid));
}
if ($plan_now === '') { $plan_now = 'FREE'; }
if ($plan_now !== 'FREE') { return; }
$context = strtolower(trim($context));
$is_subscription_config = false;
if (method_exists(__CLASS__, 'is_hosted_instance')) {
try { $is_subscription_config = (bool) self::is_hosted_instance(); } catch (\Throwable $e) { $is_subscription_config = false; }
} elseif (class_exists('\AIAAS\Entitlements') && method_exists('\AIAAS\Entitlements', 'is_hosted_instance')) {
try { $is_subscription_config = (bool) \AIAAS\Entitlements::is_hosted_instance(); } catch (\Throwable $e) { $is_subscription_config = false; }
}
if ($is_subscription_config) {
$pro_url = 'https://aas.aiauthorsstudio.com/?aas_direct_checkout=2522';
$studio_url = 'https://aas.aiauthorsstudio.com/?aas_direct_checkout=17';
$income_url = 'https://aas.aiauthorsstudio.com/?aas_direct_checkout=19668';
$link_mode = 'subscription';
} else {
$pro_url = 'https://mobile.mkettingtonbooks.com/?aas_direct_checkout=17459';
$studio_url = 'https://mobile.mkettingtonbooks.com/?aas_direct_checkout=17458';
$income_url = 'https://mobile.mkettingtonbooks.com/?aas_direct_checkout=17862';
$link_mode = 'plugin';
}
$sets = [
'dashboard' => [
['label'=>self::t('upgrade.dashboard.projects','Projects'),'plan'=>'PRO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.dashboard.projects_tip','Pro lets you manage more active book projects beyond the free starter limit.')],
['label'=>self::t('upgrade.dashboard.organize','Organize'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.dashboard.organize_tip','Upgrade to organize front matter, back matter, people, places, ideas, and book components.')],
['label'=>self::t('upgrade.dashboard.publish','Publish'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.dashboard.publish_tip','Upgrade for stronger publish readiness, layout control, and manuscript preparation.')],
['label'=>self::t('upgrade.dashboard.income','Income'),'plan'=>'ADD-ON','icon'=>'$','url'=>$income_url,'tip'=>self::t('upgrade.dashboard.income_tip','Authors Income System helps turn your book work into a broader author income plan.')],
['label'=>self::t('upgrade.dashboard.files','Files'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.dashboard.files_tip','Studio keeps research files, images, notes, and project assets with the book.')],
['label'=>self::t('upgrade.dashboard.review','Review'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.dashboard.review_tip','Studio adds sharing, reviewer comments, and collaboration workflow.')],
['label'=>self::t('upgrade.dashboard.ai','AI'),'plan'=>'PRO/STUDIO','icon'=>'✦','url'=>$pro_url,'tip'=>self::t('upgrade.dashboard.ai_tip','Upgrade for AI help with book direction, outlines, writing, and next-step planning.')],
],
'projects' => [
['label'=>self::t('upgrade.projects.more_projects','Projects'),'plan'=>'PRO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.projects.more_projects_tip','Pro unlocks more active custom projects when one free project is not enough.')],
['label'=>self::t('upgrade.projects.organize_page','Organize'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.projects.organize_page_tip','Upgrade to use Organize page tools for front matter, back matter, components, people, places, and ideas.')],
['label'=>self::t('upgrade.projects.files','Files'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.projects.files_tip','Studio adds project files and attachments so research, images, and notes stay with the book.')],
['label'=>self::t('upgrade.projects.series','Series'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.projects.series_tip','Studio unlocks full book series features for related books, shared assets, and series publishing material.')],
['label'=>self::t('upgrade.projects.collaborate_page','Collab'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.projects.collaborate_page_tip','Studio opens the Collaborate page for sharing, review, reader comments, and outside feedback.')],
['label'=>self::t('upgrade.projects.ai_help','AI'),'plan'=>'PRO/STUDIO','icon'=>'✦','url'=>$pro_url,'tip'=>self::t('upgrade.projects.ai_help_tip','Upgrade for AI help with project descriptions, book premises, starter outlines, and next-step planning.')],
],
'outlines' => [
['label'=>self::t('upgrade.outlines.templates','Templates'),'plan'=>'PRO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.outlines.templates_tip','Pro adds more outline templates and structure options for different book types.')],
['label'=>self::t('upgrade.outlines.versions','Versions'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.outlines.versions_tip','Upgrade to keep stronger outline backups, versions, and structure changes.')],
['label'=>self::t('upgrade.outlines.background','Background'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.outlines.background_tip','Upgrade to use deeper background, timeline, people, places, and ideas while planning.')],
['label'=>self::t('upgrade.outlines.series','Series'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.outlines.series_tip','Studio helps connect related outlines across a full book series.')],
['label'=>self::t('upgrade.outlines.files','Files'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.outlines.files_tip','Studio keeps outline notes, source files, images, and planning material with the project.')],
['label'=>self::t('upgrade.outlines.ai','AI'),'plan'=>'PRO/STUDIO','icon'=>'✦','url'=>$pro_url,'tip'=>self::t('upgrade.outlines.ai_tip','Upgrade for AI help with chapters, sections, summaries, and structure improvement.')],
],
'write' => [
['label'=>self::t('upgrade.write.ai_draft','AI Draft'),'plan'=>'PRO/STUDIO','icon'=>'✦','url'=>$pro_url,'tip'=>self::t('upgrade.write.ai_draft_tip','Upgrade for AI help expanding chapters, continuing sections, and turning notes into draft text.')],
['label'=>self::t('upgrade.write.rewrite','Rewrite'),'plan'=>'PRO/STUDIO','icon'=>'✦','url'=>$pro_url,'tip'=>self::t('upgrade.write.rewrite_tip','Upgrade for rewrite, tone, clarity, and chapter improvement tools.')],
['label'=>self::t('upgrade.write.organize','Organize'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.write.organize_tip','Upgrade to use the Organize page for components, people, places, ideas, front matter, and back matter.')],
['label'=>self::t('upgrade.write.context','Context'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.write.context_tip','Upgrade to use background details, people, places, and ideas while drafting.')],
['label'=>self::t('upgrade.write.files','Files'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.write.files_tip','Studio stores research, images, chapter notes, and draft support files with the project.')],
],
'organize' => [
['label'=>self::t('upgrade.organize.components','Components'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.organize.components_tip','Upgrade for a fuller component library for front matter, back matter, and support sections.')],
['label'=>self::t('upgrade.organize.people','People'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.organize.people_tip','Upgrade to organize people, places, ideas, timeline, and book background details.')],
['label'=>self::t('upgrade.organize.files','Files'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.organize.files_tip','Studio keeps cover images, research, notes, and support files connected to the book.')],
['label'=>self::t('upgrade.organize.series','Series'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.organize.series_tip','Studio helps manage shared material across books in a series.')],
['label'=>self::t('upgrade.organize.review','Review'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.organize.review_tip','Studio helps organize larger projects before review or outside feedback.')],
['label'=>self::t('upgrade.organize.ai','AI'),'plan'=>'PRO/STUDIO','icon'=>'✦','url'=>$pro_url,'tip'=>self::t('upgrade.organize.ai_tip','Upgrade for AI help sorting ideas, improving components, and planning support sections.')],
],
'publish' => [
['label'=>self::t('upgrade.publish.readiness','Ready'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.publish.readiness_tip','Upgrade for stronger checks before exporting or preparing a manuscript for readers.')],
['label'=>self::t('upgrade.publish.formatting','Format'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.publish.formatting_tip','Upgrade for more layout, included section, and manuscript preparation controls.')],
['label'=>self::t('upgrade.publish.exports','Export'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.publish.exports_tip','Upgrade for better export preparation when the book moves beyond a rough draft.')],
['label'=>self::t('upgrade.publish.files','Files'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.publish.files_tip','Studio keeps covers, source files, notes, and publishing assets with the project.')],
['label'=>self::t('upgrade.publish.collaborate_page','Collab'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.projects.collaborate_page_tip','Studio opens the Collaborate page for sharing, review, reader comments, and outside feedback.')],
['label'=>self::t('upgrade.publish.income','Income'),'plan'=>'ADD-ON','icon'=>'$','url'=>$income_url,'tip'=>self::t('upgrade.publish.income_tip','Authors Income System helps connect publishing preparation to sales, offers, and author income planning.')],
['label'=>self::t('upgrade.publish.ai','AI'),'plan'=>'PRO/STUDIO','icon'=>'✦','url'=>$pro_url,'tip'=>self::t('upgrade.publish.ai_tip','Upgrade for AI help with back-cover copy, metadata, summaries, and publish readiness.')],
],
'help' => [
['label'=>self::t('upgrade.help.videos','Videos'),'plan'=>'PRO/STUDIO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.help.videos_tip','Upgrade guidance connects training videos with the feature you are trying to use.')],
['label'=>self::t('upgrade.help.quickstart','Start'),'plan'=>'PRO','icon'=>'↗','url'=>$pro_url,'tip'=>self::t('upgrade.help.quickstart_tip','Pro helps users move from a starter project into a fuller writing workflow.')],
['label'=>self::t('upgrade.help.files','Files'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.help.files_tip','Studio adds files, attachments, series features, review, and publishing workflow.')],
['label'=>self::t('upgrade.help.collab','Collab'),'plan'=>'STUDIO','icon'=>'★','url'=>$studio_url,'tip'=>self::t('upgrade.help.collab_tip','Studio is best when you need reviewers, comments, and outside feedback.')],
['label'=>self::t('upgrade.help.ai','AI'),'plan'=>'PRO/STUDIO','icon'=>'✦','url'=>$pro_url,'tip'=>self::t('upgrade.help.ai_tip','Upgrade for more AI choices across projects, outlines, writing, organizing, and publishing.')],
],
];
$items = $sets[$context] ?? $sets['projects'];
echo '
';
echo '
' . esc_html(self::t('upgrade.preview_title', 'Upgrade Links')) . '
';
echo '
';
echo '
';
}
private static function render_projects_upgrade_icon_preview(): void {
self::render_free_upgrade_icon_row('projects');
}
}
}