refactor(Core): optimize admin panel and refactor

This commit is contained in:
2026-05-07 00:15:32 +03:30
parent dec4e67b9e
commit 7cc14b7439
25 changed files with 1162 additions and 282 deletions

View File

@@ -11,7 +11,8 @@ global $sodino_banner_service;
$bannerRepository = new BannerRepository();
$sodino_banner_service = new BannerService($bannerRepository);
add_action('wp_head', 'sodino_render_top_banner', 1);
add_action('wp_body_open', 'sodino_render_top_banner', 5);
add_action('wp_footer', 'sodino_render_top_banner_fallback', 5);
add_filter('the_content', 'sodino_render_middle_banner');
add_action('wp_footer', 'sodino_render_bottom_banner', 20);
add_action('woocommerce_after_single_product_summary', 'sodino_render_product_banner', 5);
@@ -101,13 +102,28 @@ function sodino_render_banner_position($position) {
}
function sodino_render_top_banner() {
static $rendered = false;
if (is_admin()) {
return;
}
if ($rendered) {
return;
}
$rendered = true;
echo sodino_render_banner_position('top');
}
function sodino_render_top_banner_fallback() {
if (did_action('wp_body_open')) {
return;
}
sodino_render_top_banner();
}
function sodino_render_middle_banner($content) {
if (is_admin() || !is_singular() || !in_the_loop() || is_feed()) {
return $content;
@@ -146,7 +162,8 @@ function sodino_render_cart_banner() {
}
function sodino_handle_banner_click() {
if (!isset($_POST['banner_id']) || !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'sodino_banner_click')) {
$nonce = $_POST['nonce'] ?? ($_POST['security'] ?? '');
if (!isset($_POST['banner_id']) || !wp_verify_nonce($nonce, 'sodino_banner_click')) {
wp_send_json_error();
}