From 51d2ab3aa757e13f934df3d7113225ff312e2810 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Aug 2026 19:48:22 +0800 Subject: [PATCH] fix(frontend): route post editing to frontend submit --- inc/helpers/aksrt-single-components.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/inc/helpers/aksrt-single-components.php b/inc/helpers/aksrt-single-components.php index e8b20205..d666e8fc 100644 --- a/inc/helpers/aksrt-single-components.php +++ b/inc/helpers/aksrt-single-components.php @@ -111,7 +111,21 @@ if (!function_exists('aksrt_get_single_meta_box')) : $meta = function_exists('aksrt_get_posts_meta_items_html') ? aksrt_get_posts_meta_items_html($post_id) : ''; $more = ''; - $edit_link = get_edit_post_link($post_id); + $edit_link = ''; + if (current_user_can('manage_options')) { + // Site administrators retain the native editor for full post maintenance. + $edit_link = get_edit_post_link($post_id); + } elseif (class_exists('\AKSRT\Core\FrontSubmit') && function_exists('aksrt_find_template_page')) { + $front_submit = \AKSRT\Core\FrontSubmit::get_instance(); + $submit_page = aksrt_find_template_page('templates/pages/page-submit.php'); + if ($submit_page instanceof WP_Post && $front_submit->can_edit_post($post_id)) { + // Do not fall back to /wp-admin or a guessed submit URL. A normal + // author sees this action only when the configured frontend editor exists. + $edit_link = function_exists('aksrt_get_new_post_url') + ? aksrt_get_new_post_url($post_id) + : ''; + } + } $permalink = get_permalink($post_id); $login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url($permalink ?: home_url('/')); @@ -119,7 +133,7 @@ if (!function_exists('aksrt_get_single_meta_box')) : $more .= ''; $more .= '