Title: Function create_function() is deprecated
Last modified: 24.01.2021

---

# Function create_function() is deprecated

 *  [fluffypaws](https://ru.wordpress.org/support/users/fluffypaws/)
 * (@fluffypaws)
 * [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/)
 * Здравствуйте,
    Получил задачу перенести сайт и после переноса встретил проблему
   с сайтом.
 * 1) Обнаружена активная PHP сессия
    Производительность Сессия PHP была создана
   вызовом функции session_start(). Это препятствует работе REST API и петлевым 
   запросам. Сессия должна быть закрыта функцией session_write_close() перед выполнением
   любых HTTP-запросов.
 * 2) REST API выдал ошибку
    Производительность REST API — один из способов коммуникации
   WordPress и других приложений с сервером. К примеру, экран редактора блоков использует
   его для отображения и сохранения ваших записей и страниц.
 * Запрос к REST API неудачен из-за ошибки.
    Ошибка: cURL error 28: Operation timed
   out after 10001 milliseconds with 0 out of -1 bytes received (http_request_failed)
 * 3) Ваш сайт не смог выполнить петлевой запрос
    Производительность Петлевые запросы
   используются для запуска запланированных заданий, а также используются встроенным
   редактором кода плагинов и тем для проверки корректности кода.
 * Петлевой запрос к вашему сайту не удался. Возможности, зависящие от его работоспособности,
   не могут работать так, как должны.
    Ошибка: cURL error 28: Operation timed out
   after 10001 milliseconds with 0 out of -1 bytes received (http_request_failed)
 * Установил плагин дебага и там ошибка звучит, как
    Deprecated Function create_function()
   is deprecated wp-content/themes/vks/functions.php:12 wp-settings.php:514
 * В 12 строке вот такой код — add_filter( ‘jpeg_quality’, create_function( », ‘
   return 100;’ ) );
 * Как можно решить эту проблему?
    Поиск не дал особых результатов. Видел решение,
   что нужно поменять на function custom_jpeg_quality() { return 100; } add_filter(‘
   jpeg_quality’, ‘custom_jpeg_quality’, 10, 2 ); или add_filter( ‘jpeg_quality’,
   function ( $quality ) { return 100; } );
 * Но не помогло.
 * Заранее спасибо, если кто-то сможет помочь и объяснить.
 * Страница, с которой нужна помощь: _[[войдите](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fru.wordpress.org%2Fsupport%2Ftopic%2Ffunction-create_function-is-deprecated-2%2F%3Foutput_format%3Dmd&locale=ru_RU),
   чтобы увидеть ссылку]_

Просмотр 7 ответов — с 1 по 7 (всего 7)

 *  Модератор [Юрій](https://ru.wordpress.org/support/users/yube/)
 * (@yube)
 * [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/#post-12204626)
 * 1. Найти, где используется session_start(), и либо заменить плагин/тему на современное
   и адекватное, либо, если это невозможно, переделать под другой механизм временного
   хранения.
 * 2. Разбираться на пару с сисадмином сервера в причинах проблемы.
 * 3. `add_filter( 'jpeg_quality', function ( $quality ) { return 100; } );`
    должно
   помочь. Но только с Deprecated, разумеется.
 *  Автор [fluffypaws](https://ru.wordpress.org/support/users/fluffypaws/)
 * (@fluffypaws)
 * [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/#post-12204628)
 * 1) Он в самом начале файла functions.php.
    __________________________________________________
   <?php session_start();
 * acf_add_options_page();
    acf_add_options_sub_page( ‘Settings’ );
 * include_once( get_template_directory() . ‘/inc/breadcrumbs.php’ );
    include_once(
   get_template_directory() . ‘/inc/sat.php’ ); include_once( get_template_directory().‘/
   shortcodes/handler.php’ ); include_once( get_template_directory() . ‘/inc/post_types.
   php’ );
 * add_filter( ‘jpeg_quality’, function ( $quality ) { return 100; } );
    add_filter(‘
   wp_editor_set_quality’, function($arg){ return 100; } );
 * add_theme_support( ‘post-thumbnails’ );
    add_theme_support( ‘menus’ );
 * register_nav_menus( array(
    ‘header_menu’ => ‘Меню в шапке’, ‘footer_menu’ =>‘
   Меню в подвале’ ) );
 * add_image_size( ‘client_logo’, 270, 150, true );
    add_image_size( ‘about_banner’,
   1170, 540, true ); add_image_size( ‘about_banner_second’, 570, 340, true ); add_image_size(’
   employee_photo’, 270, 345, true );
 * if( isset( $_GET[‘city’] ) ) {
    $_SESSION[‘selected_city’] = $_GET[‘city’]; }
 * if( !isset( $_SESSION[‘selected_city’] ) ) {
    $cities = get_field( ‘city’, ‘options’);
   $city = current( $cities );
 *  $_SESSION[‘selected_city’] = $city[‘code’];
    }
 * function get_current_city_data() {
    $cities = get_field( ‘city’, ‘options’ );
   $current_city = $_SESSION[‘selected_city’];
 *  foreach( $cities as $city ) {
    if( $city[‘code’] != $current_city ) continue;
 *  return $city;
    } }
 * function delete_p_tag( $str ) {
    $str = str_replace( ‘<p>’, », wpautop( $str ));
   return str_replace( ‘</p>’, », $str ); }
 * function get_all_cities_employees( $cities ) {
    $employees = [];
 *  foreach( $cities as $city ) {
    if( !$city[’employees’] || !count( $city[’employees’])){
   continue; }
 *  $employees = array_merge( $employees, $city[’employees’] );
    }
 *  return $employees;
    } ___________________________________________________ 2.
   Я смотрел настройки php.ini. Вы про них же? Как понимаю проблема не в разрешённых
   размерах. На что стоит посмотреть? ___________________________________________________
   3. Поменял, ошибка пропала, но теперь GET [https://koopwork.ru/wp-json/wp/v2/types/post](https://koopwork.ru/wp-json/wp/v2/types/post)?
   context=edit cURL error 28: Operation timed out after 10001 milliseconds with
   0 out of -1 bytes received
 * WP_Site_Health->get_test_rest_availability()
    wp-admin/includes/class-wp-site-
   health.php:1941 WP_Site_Health->perform_test() wp-admin/includes/class-wp-site-
   health.php:175 WP_Site_Health->enqueue_scripts() wp-admin/includes/class-wp-site-
   health.php:122 do_action(‘admin_enqueue_scripts’)
 *  Автор [fluffypaws](https://ru.wordpress.org/support/users/fluffypaws/)
 * (@fluffypaws)
 * [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/#post-12204630)
 * Благодарю за Ваш скорый ответ.
    Надеюсь получится это решить, не я автор сайта.
   Но мне необходимо решить это, потому что это заставляет висеть загрузку страницы
   по 10 секунд.
 *  Автор [fluffypaws](https://ru.wordpress.org/support/users/fluffypaws/)
 * (@fluffypaws)
 * [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/#post-12204631)
 * А, нет.
    Предупреждения count(): Parameter must be an array or an object that
   implements Countable 1 ошибка wp-content/themes/vks/shortcodes/testimonials.php:
   20 WPBakeryShortCode_testimonials->content() wp-content/plugins/js_composer/include/
   classes/shortcodes/core/class-wpbakeryshortcode.php:362 WPBakeryShortCode->output()
   wp-content/plugins/js_composer/include/helpers/helpers.php:1316 vc_do_shortcode()
   wp-includes/shortcodes.php:343 do_shortcode_tag() Неизвестное расположение preg_replace_callback()
   wp-includes/shortcodes.php:218 do_shortcode() wp-content/plugins/js_composer/
   include/helpers/helpers.php:240 wpb_js_remove_wpautop() wp-content/plugins/js_composer/
   include/templates/shortcodes/vc_column.php:94 WPBakeryShortCode->loadTemplate()
   wp-content/plugins/js_composer/include/classes/shortcodes/core/class-wpbakeryshortcode.
   php:244 WPBakeryShortCode->content() wp-content/plugins/js_composer/include/classes/
   shortcodes/core/class-wpbakeryshortcode.php:362 WPBakeryShortCode->output() wp-
   content/plugins/js_composer/include/helpers/helpers.php:1316 vc_do_shortcode()
   wp-includes/shortcodes.php:343 do_shortcode_tag() Неизвестное расположение preg_replace_callback()
   wp-includes/shortcodes.php:218 do_shortcode() wp-content/plugins/js_composer/
   include/helpers/helpers.php:240 wpb_js_remove_wpautop() wp-content/plugins/js_composer/
   include/templates/shortcodes/vc_row.php:156 WPBakeryShortCode->loadTemplate()
   wp-content/plugins/js_composer/include/classes/shortcodes/vc-row.php:40 WPBakeryShortCode_Vc_Row-
   >content() wp-content/plugins/js_composer/include/classes/shortcodes/core/class-
   wpbakeryshortcode.php:362 WPBakeryShortCode->output() wp-content/plugins/js_composer/
   include/helpers/helpers.php:1316 vc_do_shortcode() wp-includes/shortcodes.php:
   343 do_shortcode_tag() Неизвестное расположение preg_replace_callback() wp-includes/
   shortcodes.php:218 do_shortcode() wp-includes/class-wp-hook.php:287 apply_filters(‘
   the_content’) wp-includes/post-template.php:253 the_content() wp-content/themes/
   vks/front-page.php:4 Плагин: js_composer
 * Уведомления Trying to access array offset on value of type null 18 ошибок
    wp-
   content/plugins/js_composer/include/autoload/vc-shortcode-autoloader.php:64 VcShortcodeAutoloader::
   includeClass() wp-content/plugins/js_composer/include/classes/shortcodes/core/
   class-vc-shortcodes-manager.php:107 Vc_Shortcodes_Manager->getElementClass() 
   wp-content/plugins/js_composer/include/helpers/helpers.php:1316 vc_do_shortcode()
   wp-includes/shortcodes.php:343 do_shortcode_tag() Неизвестное расположение preg_replace_callback()
   wp-includes/shortcodes.php:218 do_shortcode() wp-includes/class-wp-hook.php:287
   apply_filters(‘the_content’) wp-includes/post-template.php:253 the_content() 
   wp-content/themes/vks/front-page.php:4
    -  Ответ изменён 5 лет, 5 месяцев назад пользователем [fluffypaws](https://ru.wordpress.org/support/users/fluffypaws/).
 *  Модератор [Юрій](https://ru.wordpress.org/support/users/yube/)
 * (@yube)
 * [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/#post-12204633)
 * > Он в самом начале файла functions.php.
 * Темы или чего? Если темы, и если не знаете, как изменить php-сессии на, скажем,
   wp-сессии, придется менять тему (правда при этом умрет и этот самопальный механизм).
   Или нанимать платных специалистов.
 * > Я смотрел настройки php.ini. Вы про них же?
 * Нет. Я про работоспособность cURL на сервере вообще и из-под PHP в частности.
   Это задачка для Сисадмина.
 *  Автор [fluffypaws](https://ru.wordpress.org/support/users/fluffypaws/)
 * (@fluffypaws)
 * [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/#post-12204651)
 * Да, темы.
    Хорошо, попробую проверить cURL. Если не поможет, буду искать тех,
   кто сможет этот самопал исправить. Спасибо.
 *  Автор [fluffypaws](https://ru.wordpress.org/support/users/fluffypaws/)
 * (@fluffypaws)
 * [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/#post-12204700)
 * Не подскажете, где лучше искать людей, кто сможет помочь с этой проблемой?

Просмотр 7 ответов — с 1 по 7 (всего 7)

Тема «Function create_function() is deprecated» закрыта для новых ответов.

 * Форум: [Темы и шаблоны](https://ru.wordpress.org/support/forum/themes-and-templates/)
 * 7 ответов
 * 2 участника
 * Последний ответ: [fluffypaws](https://ru.wordpress.org/support/users/fluffypaws/)
 * Последняя активность: [5 лет, 5 месяцев назад](https://ru.wordpress.org/support/topic/function-create_function-is-deprecated-2/#post-12204700)
 * Статус: нерешённая

## Темы

### Самые популярные темы

### Темы без ответов

### Без вопроса

### Решённые

### Нерешённые

### Все темы
