From 9423d3a89aa71dc5d3833a07b53fab24fa906ab3 Mon Sep 17 00:00:00 2001 From: maksim Date: Sat, 21 Jun 2025 13:58:05 +0300 Subject: [PATCH] =?UTF-8?q?Task=205453=20|=20wif:=20=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA=D0=B8=20=D0=B2=20=D0=BE?= =?UTF-8?q?=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wp-content/themes/cosmopet/functions.php | 1 + .../global-functions/core-functions.php | 72 ++++++------- .../custom-admin-panel-logic.php | 101 ++++++++++++++++++ .../temp-functions/woocommerce-logic.php | 77 ------------- 4 files changed, 134 insertions(+), 117 deletions(-) create mode 100644 wp-content/themes/cosmopet/temp-functions/custom-admin-panel-logic.php diff --git a/wp-content/themes/cosmopet/functions.php b/wp-content/themes/cosmopet/functions.php index ed584db..0832e2f 100644 --- a/wp-content/themes/cosmopet/functions.php +++ b/wp-content/themes/cosmopet/functions.php @@ -14,6 +14,7 @@ require_once __DIR__ . '/temp-functions/ajax-logic.php'; require_once __DIR__ . '/temp-functions/shortcodes-logic.php'; require_once __DIR__ . '/temp-functions/blog-logic.php'; require_once __DIR__ . '/temp-functions/filters-logic.php'; +require_once __DIR__ . '/temp-functions/custom-admin-panel-logic.php'; // include_module('forms'); // include_module('shop'); diff --git a/wp-content/themes/cosmopet/global-functions/core-functions.php b/wp-content/themes/cosmopet/global-functions/core-functions.php index def1230..bf7e684 100644 --- a/wp-content/themes/cosmopet/global-functions/core-functions.php +++ b/wp-content/themes/cosmopet/global-functions/core-functions.php @@ -3,14 +3,14 @@ add_action('template_redirect', 'redirect_non_logged_in_users'); function redirect_non_logged_in_users() { -// URL личного кабинета (замените 'your-account-page-slug' на ваш slug) -$account_page_slug = 'my-account-3'; -$account_page_slug__2 = 'my-account'; -// Проверяем, находится ли пользователь на странице личного кабинета -if (is_page($account_page_slug) && !is_user_logged_in() || is_page($account_page_slug__2) && !is_user_logged_in() ) { - wp_redirect(home_url()); // Перенаправляем на главную страницу - exit; -} + // URL личного кабинета (замените 'your-account-page-slug' на ваш slug) + $account_page_slug = 'my-account-3'; + $account_page_slug__2 = 'my-account'; + // Проверяем, находится ли пользователь на странице личного кабинета + if (is_page($account_page_slug) && !is_user_logged_in() || is_page($account_page_slug__2) && !is_user_logged_in() ) { + wp_redirect(home_url()); // Перенаправляем на главную страницу + exit; + } } add_action('init', 'register_pets'); @@ -135,40 +135,32 @@ case ('high'): -
-

:

-

-
- -
-

:

-

-
- -
-

- -
- -
- -
- - +

:

+

+ + +
+

:

+

+
+ +
+

+ +
+ +
+ +
+ + ID, '_composition', true); + echo '
'; + woocommerce_wp_textarea_input([ + 'id' => '_composition', + 'label' => 'Состав', + 'desc_tip' => true, + 'description' => 'Введите состав товара', + 'value' => $composition + ]); + echo '
'; +}); + +/* Вывод пользовательских табов */ +// add_action('woocommerce_product_data_panels', function () { +// global $post; +// $feeding = get_post_meta($post->ID, '_feeding_recommendations', true); +// echo '
'; +// woocommerce_wp_textarea_input([ +// 'id' => '_feeding_recommendations', +// 'label' => 'Рекомендации по кормлению', +// 'desc_tip' => true, +// 'description' => 'Введите рекомендации по кормлению', +// 'value' => $feeding +// ]); +// echo '
'; +// }); + + +// add_action('woocommerce_product_data_panels', function () { +// global $post; +// $important = get_post_meta($post->ID, '_important', true); +// echo '
'; +// woocommerce_wp_textarea_input([ +// 'id' => '_important', +// 'label' => 'Важно', +// 'desc_tip' => true, +// 'description' => 'Введите важную информацию', +// 'value' => $important +// ]); +// echo '
'; +// }); + +// woocommerce_product_options_inventory_product_data ] + +add_filter('woocommerce_product_data_tabs', function ($tabs) { + $tabs['composition_tab'] = array( + 'label' => 'Состав', + 'target' => 'composition_product_data', + 'class' => array('composition_tab'), + 'priority' => 60, + ); + // shipping_product_data + // shipping_options + // shipping_tab + + + // $tabs['feeding_tab'] = array( + // 'label' => 'Рекомендации по кормлению', + // 'target' => 'feeding_product_data', + // 'class' => array('feeding_tab'), + // 'priority' => 61, + // ); + // $tabs['important_tab'] = array( + // 'label' => 'Важно', + // 'target' => 'important_product_data', + // 'class' => array('important_tab'), + // 'priority' => 62, + // ); + return $tabs; +}); + +/* сохраненение кастомных полей */ +add_action('woocommerce_process_product_meta', function ($post_id) { + if (isset($_POST['_composition'])) { + update_post_meta($post_id, '_composition', sanitize_textarea_field($_POST['_composition'])); + } + // if (isset($_POST['_feeding_recommendations'])) { + // update_post_meta($post_id, '_feeding_recommendations', sanitize_textarea_field($_POST['_feeding_recommendations'])); + // } + // if (isset($_POST['_important'])) { + // update_post_meta($post_id, '_important', sanitize_textarea_field($_POST['_important'])); + // } +}); + +/** + * End: Добавление табов и полей в стандартной форме редактирования товара Woocommerce + */ \ No newline at end of file diff --git a/wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php b/wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php index 5d991d1..7392fde 100644 --- a/wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php +++ b/wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php @@ -148,84 +148,7 @@ function get_collection_siblings ($term) { add_filter( 'woocommerce_price_trim_zeros', '__return_true' ); -add_filter('woocommerce_product_data_tabs', function($tabs) { - $tabs['composition_tab'] = array( - 'label' => 'Состав', - 'target' => 'composition_product_data', - 'class' => array('composition_tab'), - 'priority' => 60, - ); - $tabs['feeding_tab'] = array( - 'label' => 'Рекомендации по кормлению', - 'target' => 'feeding_product_data', - 'class' => array('feeding_tab'), - 'priority' => 61, - ); - $tabs['important_tab'] = array( - 'label' => 'Важно', - 'target' => 'important_product_data', - 'class' => array('important_tab'), - 'priority' => 62, - ); - return $tabs; -}); - - -add_action('woocommerce_product_data_panels', function() { - global $post; - $composition = get_post_meta($post->ID, '_composition', true); - echo '
'; - woocommerce_wp_textarea_input([ - 'id' => '_composition', - 'label' => 'Состав', - 'desc_tip' => true, - 'description' => 'Введите состав товара', - 'value' => $composition - ]); - echo '
'; -}); - -add_action('woocommerce_product_data_panels', function() { - global $post; - $feeding = get_post_meta($post->ID, '_feeding_recommendations', true); - echo '
'; - woocommerce_wp_textarea_input([ - 'id' => '_feeding_recommendations', - 'label' => 'Рекомендации по кормлению', - 'desc_tip' => true, - 'description' => 'Введите рекомендации по кормлению', - 'value' => $feeding - ]); - echo '
'; -}); - - -add_action('woocommerce_product_data_panels', function() { - global $post; - $important = get_post_meta($post->ID, '_important', true); - echo '
'; - woocommerce_wp_textarea_input([ - 'id' => '_important', - 'label' => 'Важно', - 'desc_tip' => true, - 'description' => 'Введите важную информацию', - 'value' => $important - ]); - echo '
'; -}); - -add_action('woocommerce_process_product_meta', function($post_id) { - if (isset($_POST['_composition'])) { - update_post_meta($post_id, '_composition', sanitize_textarea_field($_POST['_composition'])); - } - if (isset($_POST['_feeding_recommendations'])) { - update_post_meta($post_id, '_feeding_recommendations', sanitize_textarea_field($_POST['_feeding_recommendations'])); - } - if (isset($_POST['_important'])) { - update_post_meta($post_id, '_important', sanitize_textarea_field($_POST['_important'])); - } -}); // Добавление поля для выбора рекомендуемых товаров function register_recommended_products_acf_field() { if (function_exists('acf_add_local_field_group')) {