This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Функция для ресайза блоков к одному общему размеру | |
| $.fn.equivalent = function() { | |
| var $blocks = $(this), | |
| maxH = $blocks.eq(0).height(); | |
| $blocks.each(function() { | |
| maxH = ($(this).height() > maxH ) ? $(this).height() : maxH; | |
| }); | |
| $blocks.height(maxH); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ((firstArgument.value % 1) === 0 && (secondArgument.value % 1) === 0) { | |
| } else { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```bash | |
| git tag <tag name> <tag name>^{} -f -m "<new message>" | |
| ``` | |
| Пример: имеем тег 0.3 с сообщением тест, хотим поменять сообщение на новое сообщение. | |
| ```bash | |
| git tag 0.3 0.3^{} -f -m "Новое сообщение" | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // инвертируем строки | |
| $revers = iconv('windows-1251', 'utf-8', strrev(iconv('utf-8', 'windows-1251', $preg_replace))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Этот код был в функции обработки данных из БД для последующей передачи в JSON (эти данные кормились скрипту). | |
| $terms = get_the_terms($item->post_id, 'cal2eve_calendars'); | |
| $terms_array = []; | |
| if ($terms && !is_wp_error($terms)) { | |
| foreach ($terms as $term) { | |
| $terms_array[] = '<a href="' . get_term_link($term) . '" target="_blank">' . $term->name . '</a>'; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Получим текущее время и разобьем его на составляющие (дни, часы, минуты): | |
| <?php | |
| $blogtime = current_time('mysql'); // вернет: 2005-08-05 10:41:13 | |
| list( $year, $month, $day, $hour, $minute, $second ) = preg_split( '([^0-9])', $blogtime ); | |
| // Теперь у нас переменные: | |
| // $year - текущий год | |
| // $month - текущий месяц | |
| // т.д. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Создание | |
| function create_custom_table() | |
| { | |
| global $wpdb; | |
| require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| $table_name = $wpdb->prefix . 'test_table'; | |
| $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset} COLLATE {$wpdb->collate}"; | |
| $sql = "CREATE TABLE {$table_name} ( | |
| id bigint(20) unsigned NOT NULL auto_increment, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Цикл в WordPress выглядит так: | |
| <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> | |
| <!-- Цикл WordPress --> | |
| <p>Выводим данные записи. Здесь работают функции для цикла, например, the_title() </p> | |
| <h2><?php the_title() ?></h2> | |
| <?php endwhile; else : ?> | |
| <p>Записей нет.</p> | |
| <?php endif; ?> | |
| Или можно записать так: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <span class="timer">3</span> | |
| let _Seconds = $('.timer').text(), | |
| int; | |
| int = setInterval(function() { // запускаем интервал | |
| if (_Seconds > 0) { | |
| _Seconds--; // вычитаем 1 | |
| $('.timer').text(_Seconds); // выводим получившееся значение в блок | |
| } else { | |
| clearInterval(int); // очищаем интервал, чтобы он не продолжал работу при _Seconds = 0 |