Title: Объединить 2 функции в одну
Last modified: 23.09.2018

---

# Объединить 2 функции в одну

 *  [dmitriy88](https://ru.wordpress.org/support/users/dmitriy88/)
 * (@dmitriy88)
 * [8 лет, 1 месяц назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/)
 * Есть 2 функции переименования типов записей. Возможно ли их объединить в одну,
   чтобы сразу 2 типа записей переименовать?
 *     ```
       <?php
       function rename_post_formats( $safe_text ) {
           if ( $safe_text == 'Заметка' )
               return 'Тип1';
   
           return $safe_text;
       }
       add_filter( 'esc_html', 'rename_post_formats' );
   
       //rename Aside in posts list table
       function live_rename_formats() { 
           global $current_screen;
   
           if ( $current_screen->id == 'edit-post' ) { ?>
               <script type="text/javascript">
               jQuery('document').ready(function() {
   
                   jQuery("span.post-state-format").each(function() { 
                       if ( jQuery(this).text() == "Заметка" )
                           jQuery(this).text("Тип1");             
                   });
   
               });      
               </script>
       <?php }
       }
       add_action('admin_head', 'live_rename_formats');
   
       function rename_post_formats2( $safe_text ) {
           if ( $safe_text == 'Статус' )
               return 'Тип2';
   
           return $safe_text;
       }
       add_filter( 'esc_html', 'rename_post_formats2' );
   
       //rename Aside in posts list table
       function live_rename_formats2() { 
           global $current_screen;
   
           if ( $current_screen->id == 'edit-post' ) { ?>
               <script type="text/javascript">
               jQuery('document').ready(function() {
   
                   jQuery("span.post-state-format").each(function() { 
                       if ( jQuery(this).text() == "Статус" )
                           jQuery(this).text("Тип2");             
                   });
   
               });      
               </script>
       <?php }
       }
       add_action('admin_head', 'live_rename_formats2');
       ```
   

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

 *  Автор [dmitriy88](https://ru.wordpress.org/support/users/dmitriy88/)
 * (@dmitriy88)
 * [8 лет, 1 месяц назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-297999)
 * Помогите)
 *  [wpgear](https://ru.wordpress.org/support/users/wpgear/)
 * (@wpgear)
 * [8 лет, 1 месяц назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-298075)
 *     ```
       <?php
       function rename_post_formats( $safe_text ) {
           if ( $safe_text == 'Заметка' ) {
       		return 'Тип1';
       	} else if ($safe_text == 'Статус') {
       		return 'Тип2';	
       	}
   
           return $safe_text;
       }
       add_filter( 'esc_html', 'rename_post_formats' );
   
       //rename Aside in posts list table
       function live_rename_formats() { 
           global $current_screen;
   
           if ( $current_screen->id == 'edit-post' ) { ?>
               <script type="text/javascript">
               jQuery('document').ready(function() {
   
                   jQuery("span.post-state-format").each(function() { 
                       if ( jQuery(this).text() == "Заметка" ) {
       					jQuery(this).text("Тип1");  
       				} else if ( jQuery(this).text() == "Статус" ) {
       					jQuery(this).text("Тип2");
       				}           
                   });
   
               });      
               </script>
       <?php }
       }
       add_action('admin_head', 'live_rename_formats');
       ```
   
 *  Автор [dmitriy88](https://ru.wordpress.org/support/users/dmitriy88/)
 * (@dmitriy88)
 * [8 лет, 1 месяц назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-298111)
 * Большое спасибо! Все получилось.
 *  Автор [dmitriy88](https://ru.wordpress.org/support/users/dmitriy88/)
 * (@dmitriy88)
 * [7 лет, 11 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-305814)
 * После обновления WordPress до версии 5.0 код перестал работать. Подскажите, что
   в нем нужно изменить.
 *  [wpgear](https://ru.wordpress.org/support/users/wpgear/)
 * (@wpgear)
 * [7 лет, 11 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-305879)
 * Надо смотреть логи. Наверняка, вы там найдете подсказку.
 *  Автор [dmitriy88](https://ru.wordpress.org/support/users/dmitriy88/)
 * (@dmitriy88)
 * [7 лет, 10 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-308677)
 * > Надо смотреть логи
 * А как это сделать?
 *  [O](https://ru.wordpress.org/support/users/perdyllo/)
 * (@perdyllo)
 * [7 лет, 10 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-308684)
 * > А как это сделать?
 *  На хостинге. Если не найдете сами — узнайте в службе поддержки где их найти
 *  Модератор [Sergey Biryukov](https://ru.wordpress.org/support/users/sergeybiryukov/)
 * (@sergeybiryukov)
 * Live and Learn
 * [7 лет, 10 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-308748)
 * Попробуйте так:
 *     ```
       function rename_post_format_labels( $translation, $text, $context, $domain ) {
       	if ( 'Post format' !== $context || 'default' !== $domain ) {
       		return $translation;
       	}
   
       	if ( 'Заметка' === $translation ) {
       		$translation = 'Тип1';
       	} elseif ( 'Статус' === $translation ) {
       		$translation = 'Тип2';
       	}
   
       	return $translation;
       }
       add_filter( 'gettext_with_context', 'rename_post_format_labels', 10, 4 );
   
       function rename_post_format_labels_js( $translations, $file, $handle, $domain ) {
       	if ( 'wp-editor' !== $handle || 'default' !== $domain ) {
       		return $translations;
       	}
   
       	$translations = json_decode( $translations );
       	$translations->locale_data->messages->{'Aside'}  = array( 'Тип1' );
       	$translations->locale_data->messages->{'Status'} = array( 'Тип2' );
       	$translations = json_encode( $translations );
   
       	return $translations;
       }
       add_filter( 'load_script_translations', 'rename_post_format_labels_js', 10, 4 );
       ```
   
 *  Автор [dmitriy88](https://ru.wordpress.org/support/users/dmitriy88/)
 * (@dmitriy88)
 * [7 лет, 10 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-308763)
 * > Попробуйте так
 * Не получилось. При использовании данной функции типы записей просто выводятся
   на английском языке вместо русского, но не переименовываются.
 *  Модератор [Sergey Biryukov](https://ru.wordpress.org/support/users/sergeybiryukov/)
 * (@sergeybiryukov)
 * Live and Learn
 * [7 лет, 10 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-308769)
 * > При использовании данной функции
 * Какой именно? Там их две: одна для списка записей, вторая — для редактора.
 * > типы записей просто выводятся на английском языке вместо русского
 * В списке записей или в редакторе? Используется новый редактор WP 5.0 (Gutenberg)
   или классический?
 *  Автор [dmitriy88](https://ru.wordpress.org/support/users/dmitriy88/)
 * (@dmitriy88)
 * [7 лет, 10 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-308773)
 * > Какой именно? Там их две: одна для списка записей, вторая — для редактора.
 * Добавлял сразу две.
 * > В списке записей или в редакторе? Используется новый редактор WP 5.0 (Gutenberg)
   > или классический?
 * Проверял в редакторе. Использую Gutenberg.

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

 Тема «Объединить 2 функции в одну» закрыта для новых ответов.

 * Форум: [Проблемы и решения](https://ru.wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 ответов
 * 4 участника
 * Последний ответ: [dmitriy88](https://ru.wordpress.org/support/users/dmitriy88/)
 * Последняя активность: [7 лет, 10 месяцев назад](https://ru.wordpress.org/support/topic/%d0%be%d0%b1%d1%8a%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%82%d1%8c-2-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-%d0%b2-%d0%be%d0%b4%d0%bd%d1%83/#post-308773)
 * Статус: нерешённая

## Темы

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

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

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

### Решённые

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

### Все темы
