// show_admin_bar(false); add_filter( 'automatic_updater_disabled', '__return_true' ); add_theme_support('post-thumbnails'); add_action( 'after_setup_theme', function () { add_theme_support( 'woocommerce' ); } ); add_filter('wpseo_breadcrumb_single_link' , function ($link_output, $link) { if (is_singular('product')) { if( $link['text'] == 'Товары' ) { $link_output = ""; } } return $link_output; } , 10 ,2); if (!isset($_COOKIE['user_id'])) { $user_id = bin2hex(random_bytes(16)); setcookie('user_id', $user_id, time() + (86400 * 180), "/"); } require_once get_template_directory() . '/services/returnProductVariations.php'; require_once get_template_directory() . '/services/cart.php'; require_once get_template_directory() . '/services/comparison.php'; require_once get_template_directory() . '/api/routes.php'; add_filter('single_template', function ($single_template) { if (has_category('blog')) { $single_template = dirname(__FILE__) . '/single-blog.php'; } return $single_template; }, PHP_INT_MAX, 2); function phoneMask($str) { return preg_replace('/[\D+]/', '', $str); } add_action('woocommerce_update_product', function($product_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } $product = wc_get_product($product_id); if (!$product->is_type('variable')) { return; } $varID = getMinProductVariation($product_id); $productVar = wc_get_product($varID); $sale = $productVar->get_sale_price(); update_post_meta( $product_id, '_sale_price', $sale); }, 10, 3); add_action('woocommerce_update_product', function($product_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } $sale = get_post_meta($product_id, '_sale_price', true); $currentCategories = wp_get_post_terms($product_id, 'product_cat', ['fields' => 'ids']); if (!empty($sale)) { $newCategories = array_merge($currentCategories, [3994]); $newCategories = array_unique($newCategories); } else { $newCategories = $currentCategories; $key = array_search(3994, $newCategories); if ($key !== false) unset($newCategories[$key]); } wp_set_object_terms($product_id, $newCategories, 'product_cat', false); }, 12, 3); add_filter('get_terms', function ($terms) { if (is_admin()) return $terms; $exclude = get_field('skryt_kategorii', 'options') ?: []; foreach ($terms as $key => $term) { if (in_array($term->term_id, $exclude)) { unset($terms[$key]); } } return $terms; }, 10, 3); function getInstallmentPay(string|float $price): float|int { $installment = get_field('rassrochka', 'options'); return intval((float)$installment['proczent'] * (float)$price / (int)$installment['kol-vo_mesyaczev']); } function getVariationKey(int|string $productId, int|string $varId): int { $variations = wc_get_product($productId)->get_children(); return array_search($varId, $variations); } function getMinProductVariation(string $id) { $product = wc_get_product($id); if (!$product->is_type('variable')) return $id; return returnMinVariation($product->get_children() ?? []) ?? $id; } function returnMinVariation($children) { $variations = array_reduce($children, function ($array, $childrenId) { $variation = wc_get_product($childrenId); $variationAttr = $variation->get_attributes() ?? []; if (!in_array('esim', $variationAttr)) { $array[$childrenId] = $variation->get_price(); } return $array; }, []); return !empty($variations) ? array_search(min($variations), $variations) : null; } function returnFirstProductVariation(string $id) { $product = wc_get_product($id); return $product->get_children()[0]; } function getProductPrices($id) { $product = wc_get_product($id); return [$product->get_regular_price(), $product->get_sale_price()]; } function getRegexPrice($price) { return preg_replace('/(\d)(?=(\d{3})+$)/', '$1 ', $price); } function getTerms($parent) { $terms = get_terms([ 'taxonomy' => 'product_cat', 'parent' => $parent, 'orderby' => 'term_order', 'order' => 'ASC', 'hide_empty' => false, ]); return $terms; } function getTypeSort($sort) { $order = ''; $orderBy = ''; switch ($sort) { case 'increase': $order = 'ASC'; $orderBy = 'meta_value_num'; break; case 'decrease': $order = 'DESC'; $orderBy = 'meta_value_num'; break; default: $order = 'ASC'; $orderBy = 'menu_order'; break; } return [$order, $orderBy]; } function getTaxQuery($term_id, $get) { $tax = []; $taxQuery[] = [ 'taxonomy' => 'product_cat', 'terms' => $term_id, ]; foreach ($get as $key => $values) { if ($key == 'sort' || $key == 'page') continue; $tax[$key] = ['relation' => 'OR']; foreach ($values as $item) { $tax[$key][] = [ 'taxonomy' => $key, 'terms' => $item, ]; } } foreach ($tax as $value) { $taxQuery[] = $value; } return $taxQuery; } function getProductsWithFilters($term_id, $page, $get) { [$order, $orderBy] = getTypeSort($get['sort']); $taxQuery = getTaxQuery($term_id, $get); $meta_query = []; if (isset($get['sale'])) { $meta_query[] = [ [ 'key' => '_sale_price', 'value' => '', 'compare' => '!=', ] ]; } if (isset($get['min_price'])) { $meta_query[] = [ 'key' => '_price', 'value' => intval($get['min_price']), 'type' => 'numeric', 'compare' => '>=' ]; } if ($get['max_price']) { $meta_query[] = [ 'key' => '_price', 'value' => intval($get['max_price']), 'type' => 'numeric', 'compare' => '<=' ]; } $postsQuery = new WP_Query([ 'post_type' => 'product', 'tax_query' => $taxQuery, 'order' => $order, 'orderby' => $orderBy, 'meta_key' => '_price', 'meta_query' => $meta_query, 'posts_per_page' => -1, ]); $products = $postsQuery->posts; $maxCount = count($products); return [$maxCount, array_slice($products, ($page - 1) * 16,16)]; } function serviceForSearch($get, $products) { $prices = []; if (isset($get['sale'])) { $productsWithSale = array_reduce($products, function($carry, $product) { $sale = get_post_meta($product->ID, '_sale_price', true); if ($sale) $carry[] = $product; return $carry; }, []); $products = $productsWithSale; } if (isset($get['min_price'])) { $productsWithMinPrice = array_reduce($products, function($carry, $product) use ($get) { $price = get_post_meta($product->ID, '_price', true); if (intval($price) >= intval($get['min_price'])) $carry[] = $product; return $carry; }, []); $products = $productsWithMinPrice; } if (isset($get['max_price'])) { $productsWithMaxPrice = array_reduce($products, function($carry, $product) use ($get) { $price = get_post_meta($product->ID, '_price', true); if (intval($price) <= intval($get['max_price'])) $carry[] = $product; return $carry; }, []); $products = $productsWithMaxPrice; } $prices = array_reduce($products, function($carry, $product) { $price = get_post_meta($product->ID, '_price', true); $carry[] = $price; return $carry; }, []); if ($get['sort'] == 'increase') { usort($products, function($a, $b) { return intval(get_post_meta($a->ID, '_price', true)) - intval(get_post_meta($b->ID, '_price', true)); }); } if ($get['sort'] == 'decrease') { usort($products, function($a, $b) { return intval(get_post_meta($b->ID, '_price', true)) - intval(get_post_meta($a->ID, '_price', true)); }); } if ($prices == []) $prices[] = 0; return count($products) ? [min($prices), max($prices), $products] : [0, 0, []]; } function getSearchResult($get, $page) { global $wpdb; $search_term = '%' . $wpdb->esc_like($get['s']) . '%'; $sql = $wpdb->prepare("SELECT DISTINCT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) LEFT JOIN wp_terms ON (wp_term_taxonomy.term_id = wp_terms.term_id) WHERE wp_posts.post_type = 'product' AND wp_posts.post_status = 'publish' AND ( wp_posts.post_title LIKE %s OR (wp_term_taxonomy.taxonomy = 'product_tag' AND wp_terms.name LIKE %s) ) ", $search_term, $search_term); $post_ids = $wpdb->get_col($sql); $postsQuery = new WP_Query([ 'post_type' => 'product', 'post__in' => $post_ids, 'order' => 'ASC', 'posts_per_page' => -1, ]); $posts = $post_ids ? $postsQuery->posts : []; [$minPrice, $maxPrice, $products] = serviceForSearch($get, $posts); $countProducts = count($products); return [$minPrice, $maxPrice, $countProducts, array_slice($products, ($page - 1) * 16,16)]; } function checkExistAttrInGroup($currentProductAttr, $patternTax) { foreach ( $patternTax as $index => $tax ) { if ($currentProductAttr[$tax]) return 1; } return 0; } function getAttributesNameList() { $attr = []; $taxonomies = get_taxonomies(['public' => false], 'objects'); foreach ($taxonomies as $taxonomy) { if ( str_starts_with( $taxonomy->name, 'pa_' ) ) { $attr[$taxonomy->name] = []; } } return $attr; } function getNameAttribute($tax) { $names = []; $terms = $tax->get_terms(); if ($tax['data']['is_variation']) { $items[] = $terms[0]; } else { $items = $terms; } foreach ($items as $item) { $names[$item->term_id] = $item->name; } return $names; } function getCurrentFilterTaxes($category) { $attrGroupList = get_field('povtoritel_3', 'options'); // Добавляем проверки if (empty($attrGroupList) || !is_array($attrGroupList)) { return []; } foreach ($attrGroupList as $item) { // Проверяем существование и тип category_list if (!isset($item['category_list']) || !is_array($item['category_list'])) { continue; // Пропускаем некорректные элементы } if (in_array($category->term_id, $item['category_list'])) { $result = []; // Также проверяем taxonomies_list if (isset($item['taxonomies_list']) && is_array($item['taxonomies_list'])) { foreach ($item['taxonomies_list'] as $index => $value) { $result[$value] = []; } } return $result; } } return []; } function getFilters($category) { $currentTaxes = getCurrentFilterTaxes($category); $productQuery = new WP_Query([ 'post_type' => 'product', 'tax_query' => [ [ 'taxonomy' => 'product_cat', 'terms' => $category->term_id, ], ], 'posts_per_page' => -1, ]); $products = $productQuery->posts; $pricesArr = []; foreach ( $products as $productItem ) { $pricesArr[] = get_post_meta($productItem->ID, '_price', true); $prodAttrs = wc_get_product( $productItem->ID )->get_attributes(); if ($currentTaxes) { foreach ( $prodAttrs as $prodAttr ) { $value = getNameAttribute( $prodAttr ); foreach ( $value as $id => $name ) { if ($currentTaxes[ $prodAttr['name'] ] === NULL) continue; if ( ! in_array( $name, $currentTaxes[ $prodAttr['name'] ] ) ) { $currentTaxes[ $prodAttr['name'] ][ $id ] = $name; } } } } } if ($pricesArr == []) $pricesArr[] = 0; return [min($pricesArr), max($pricesArr), $currentTaxes]; } function buyOnClick($data) { $order = wc_create_order(); $address = array( 'phone' => $data['phone'], ); $order->set_address( $address, 'billing' ); $order->set_address( $address, 'shipping' ); $var = $data['variation_id']; $productID = $data['product_id']; $product = $var ? new WC_Product_Variation($var) : wc_get_product($productID); $data_price = $product->get_price(); $product->set_price($data_price); $order->add_product( $product, 1); $order->calculate_totals(); $order->set_status('processing'); $order->save(); $order->add_order_note('Купить в один клик'); return $order->get_id(); } add_action( 'pre_get_posts', function( $query ) { if( is_admin() || ! $query->is_main_query() ) return; if( $query->is_category('category_name') ){ $query->set( 'posts_per_page', 2 ); } } , 1 ); add_filter('acf/load_field/name=taxonomies_list', function ($field) { $taxonomies = get_taxonomies(['public' => false], 'objects'); $field['choices'] = array(); foreach ($taxonomies as $taxonomy) { if ( str_starts_with( $taxonomy->name, 'pa_' ) ) { // echo '
'; print_r($taxonomy->labels->singular_name); echo ''; $field['choices'][$taxonomy->name] = $taxonomy->labels->singular_name; } } return $field; }); add_filter('acf/load_field/name=categories_list', function ($field) { $categories = get_terms(['taxonomy' => 'product_cat', 'hide_empty' => false]); $field['choices'] = array(); foreach ($categories as $category) { $field['choices'][$category->term_id] = $category->name; } return $field; });
Fatal error: Uncaught Error: ftp_nlist(): Argument #1 ($ftp) must be of type FTP\Connection, null given
in /var/www/vhosts/app-room23.ru/public_html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 438
Call stack:
ftp_nlist()WP_Filesystem_FTPext::exists()WP_Filesystem_FTPext::is_file()Automattic\W\I\A\L\F\File::is_writable()Automattic\W\I\A\L\F\File::write()Automattic\W\I\A\L\F\FileController::write_to_file()Automattic\W\I\A\L\LogHandlerFileV2::handle()WC_Logger::log()WC_Logger::warning()Automattic\W\B\BlockPatterns::register_ptk_patterns()WP_Hook::apply_filters()WP_Hook::do_action()do_action()require_once()require_once()require_once()require()