123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- if ( ! defined( '_S_VERSION' ) ) {
- // Replace the version number of the theme on each release.
- define( '_S_VERSION', '1.0.0' );
- }
- function ggpromarket_init(){
- register_post_type( 'catalog', [
- 'label' => null,
- 'labels' => [
- 'name' => 'Каталог', // основное название для типа записи
- 'singular_name' => 'Каталог', // название для одной записи этого типа
- 'add_new' => 'Добавить новый шаблон', // для добавления новой записи
- 'add_new_item' => 'Добавление шаблона', // заголовка у вновь создаваемой записи в админ-панели.
- 'edit_item' => 'Редактирование шаблона', // для редактирования типа записи
- 'new_item' => 'Новый шаблон', // текст новой записи
- 'view_item' => 'Смотреть шаблон страницы', // для просмотра записи этого типа.
- 'search_items' => 'Искать шаблон в каталоге', // для поиска по этим типам записи
- 'not_found' => 'Не найдено', // если в результате поиска ничего не было найдено
- 'not_found_in_trash' => 'Не найдено в корзине', // если не было найдено в корзине
- 'parent_item_colon' => '', // для родителей (у древовидных типов)
- 'menu_name' => 'Каталог', // название меню
- ],
- 'description' => '',
- 'public' => true,
- 'menu_icon' => 'dashicons-beer',
- 'hierarchical' => false,
- 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'post-formats', 'revisions','page-attributes'], // 'title','editor','author','thumbnail','excerpt','trackbacks','custom-fields','comments','revisions','page-attributes','post-formats'
- 'taxonomies' => [],
- 'has_archive' => false,
- 'menu_position' => 4,
- ] );
- }
- function ggpromarket_setup() {
- /*
- * Make theme available for translation.
- * Translations can be filed in the /languages/ directory.
- * If you're building a theme based on GGPromarket, use a find and replace
- * to change 'ggpromarket' to the name of your theme in all the template files.
- */
- load_theme_textdomain( 'ggpromarket', get_template_directory() . '/languages' );
- // Add default posts and comments RSS feed links to head.
- add_theme_support( 'automatic-feed-links' );
- /*
- * Let WordPress manage the document title.
- * By adding theme support, we declare that this theme does not use a
- * hard-coded <title> tag in the document head, and expect WordPress to
- * provide it for us.
- */
- add_theme_support( 'title-tag' );
- /*
- * Enable support for Post Thumbnails on posts and pages.
- *
- * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
- */
- add_theme_support( 'post-thumbnails' );
- /*
- * Switch default core markup for search form, comment form, and comments
- * to output valid HTML5.
- */
- add_theme_support(
- 'html5',
- array(
- 'search-form',
- 'comment-form',
- 'comment-list',
- 'gallery',
- 'caption',
- 'style',
- 'script',
- )
- );
- // Set up the WordPress core custom background feature.
- add_theme_support(
- 'custom-background',
- apply_filters(
- 'ggpromarket_custom_background_args',
- array(
- 'default-color' => 'ffffff',
- 'default-image' => '',
- )
- )
- );
- // Add theme support for selective refresh for widgets.
- add_theme_support( 'customize-selective-refresh-widgets' );
- /**
- * Add support for core custom logo.
- *
- * @link https://codex.wordpress.org/Theme_Logo
- */
- add_theme_support(
- 'custom-logo',
- array(
- 'height' => 250,
- 'width' => 250,
- 'flex-width' => true,
- 'flex-height' => true,
- )
- );
- add_theme_support('post-formats',array('aside','gallery'));
- register_nav_menu('header-menu','Навигация в шапке сайта');
- }
- function ggpromarket_scripts() {
- $prefix_name = "ggpromarket";
- wp_enqueue_style( $prefix_name . '-style', get_template_directory_uri() . '/assets/css/Style.css', false, _S_VERSION );
- wp_enqueue_script( $prefix_name . '-form', get_template_directory_uri() . '/assets/js/Form.js', false, _S_VERSION, true );
- wp_enqueue_script( $prefix_name . '-script', get_template_directory_uri() . '/assets/js/Script.js', false, _S_VERSION, true );
- wp_enqueue_script( $prefix_name . '-map', get_template_directory_uri() . '/assets/js/Map.js', false, _S_VERSION, true );
- wp_enqueue_script( $prefix_name . '-modal', get_template_directory_uri() . '/assets/js/Modal.js', false, _S_VERSION, true );
- }
- /**
- * Fix pagination on archive pages
- * After adding a rewrite rule, go to Settings > Permalinks and click Save to flush the rules cache
- *
- * Прим разработчика:
- * Нельзя делать редирект нга ту же страницу, иначе пермалинки начигают захлебываться
- */
- function my_pagination_rewrite() {
- add_rewrite_rule('catalog/page/?([0-9]{1,})/?$', 'index.php?page_id=90&paged=$matches[1]', 'top');
- }
- add_action('init', 'my_pagination_rewrite',1);
- add_action( 'after_setup_theme', 'ggpromarket_setup' );
- add_action( 'wp_enqueue_scripts', 'ggpromarket_scripts' );
- add_action( 'init', 'ggpromarket_init',2);
|