Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Этот файл содержит базовые функции, а также хуки
- для вкючения дополнительного функционала вашей темы.
- %textdomain% - необходимо заменить на textdomain вашей темы
- */
- // данная функция включает дополнительные опции вашей темы
- function custom_theme_setup()
- {
- // включаем поддержку языков
- load_theme_textdomain( %textdomain%);
- // включаем авто добавление тега title в секцию HEAD
- add_theme_support( 'title-tag' );
- // включаем поддержку миниатюр для темы
- add_theme_support( 'post-thumbnails' );
- // set_post_thumbnail_size( 825, 510, true );
- // регистрируем меню
- register_nav_menus( array(
- 'primary' => __( 'Primary Menu',%textdomain%),
- 'bottom' => __( 'Bottom Menu',%textdomain%),
- ) );
- // включаем HTML5 разметку для некоторых видов контента
- add_theme_support( 'html5', array(
- 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
- ) );
- // включаем поддержку собственного логотипа
- add_theme_support( 'custom-logo', array(
- 'height' => 100,
- 'width' => 100,
- 'flex-height' => true,
- ) );
- // подключаем стили в визуальный редактор
- add_editor_style(array( 'style.css'));
- }
- add_action( 'after_setup_theme', 'custom_theme_setup' );
- /**
- * подключаем скрипты и стили в шаблон
- *
- * @param string $handle Script name
- * @param string $src Script url
- * @param array $deps (optional) Array of script names on which this script depends
- * @param string|bool $ver (optional) Script version (used for cache busting), set to null to disable
- * @param bool $in_footer (optional) Whether to enqueue the script before </head> or before </body>
- */
- function theme_scripts_and_styles() {
- // wp_enqueue_style( '$handle', '$src');
- // wp_enqueue_script( '$handle', '$src', array( 'jquery' ), false, false);
- }
- add_action( 'wp_enqueue_scripts', 'theme_scripts_and_styles' );
- /**
- * Функция помогает вывести определённое к-во символов из основного текста поста
- * будет полезна для автоматического получения анонса и более точной обрезки чем стандартная функция the_excerpt(). Не требует дополнительных действий, написания хуков как the_excerpt()
- * @param integer $args - к-во символов текста (!не слов)
- * @param string $end - окончание (по умолчанию многоточие) если размер симолов больше заданного в параметре $args
- * @return выводит правильно обрезанный текст записи
- */
- function text_substr($args=350,$end='…'){
- global $post;
- $text=strip_tags($post->post_excerpt);
- if (empty($text)) {
- $text=strip_tags($post->post_content);
- }
- if(strlen( $text)<=$args){
- $short_text=$text;
- }else{
- $text=mb_substr($text,0,$args);
- $short_text=substr($text,0,strrpos($text, ' ' ));
- $short_text=$short_text.$end;
- }
- echo $short_text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement