Не срабатывает хук в wordpress, почему?

Здравствуйте!
Сделал плагин, вот код:
class RegAuthor
{
    // method
    // public function __construct() {
    //
    // }

    public function register() {
        // register out type
        add_action('init', [$this,'custom_post_type']);

        // enqueue admin
        add_action('admin_enqueue_scripts', [$this,'enqueue_admin']);
        add_action('wp_enqueue_scripts', [$this,'enqueue_front']);

        // load template
        add_filter('template_include', [$this,'regauth_template']);

        add_action('check_first_form', [$this,'first_form_check']);
    }

    static function activation() {
        //update rewrite rules
        flush_rewrite_rules();
    }

    static function deactivation() {
        //update rewrite rules
        flush_rewrite_rules();
    }

    // Custom template for rooms
    public function regauth_template($template) {

        if (is_post_type_archive('author')) {
            $theme_files = ['reg-author.php','reg_author/reg-author.php'];
            $exist = locate_template($theme_files, false);
            if ($exist != '') {
                return $exist;
            } else {
                return plugin_dir_path(__FILE__).'templates/reg-author.php';
            }
        }
        return $template;
    }

    //Enqueue admin
    public function enqueue_admin() {
        wp_enqueue_style('regAuthorStyle', plugins_url('/assets/admin/styles.css', __FILE__));
        wp_enqueue_script('regAuthorStcript', plugins_url('/assets/admin/scripts.js', __FILE__));
    }

    //Enqueue front
    public function enqueue_front() {
        wp_enqueue_style('regAuthorStyle', plugins_url('/assets/front/styles.css', __FILE__));
        wp_enqueue_script('regAuthorStcript', plugins_url('/assets/front/scripts.js', __FILE__));
    }

    public function first_form_check() {
        if (isset($_POST['proj_send'])) {
            var_dump($_POST);
        }
    }

    // Register CPT
    public function custom_post_type() {
        register_post_type('author',
        [
            'public' => true,
            'has_archive' => true,
            'rewrite' => ['slug'=>'authors'],
            'label' => esc_html__('Author', 'regauthor'),
            'supports' => ['title','editor','thumbnail']
        ]);


    }
}

if (class_exists('RegAuthor')) {
    $regauthor = new RegAuthor();
    $regauthor->register();
}

Ловлю POST данные в функции first_form_check, но ничего не приходит.

Вот код файла reg-author.php:
<?php
get_header();
?>

<div class="wraper">
    <h2>Создание проекта</h2>
    <?php
        if (have_posts()) {
            // load posts loop
            while (have_posts()) {
                the_post();
                ?>
                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    <?php the_excerpt(); ?>
                </article>
                <?php
            }

            echo paginate_links();
        } else {
            // If no content, include yhe "No posts found" template
            echo esc_html__('No posts','alebooking');
        }
    ?>
    <form action="<?php echo get_post_type_archive_link('author'); ?>" method="post">
        <label for="projectTitle">
            <span>Название</span><br>
            <input type="text" id="projectTitle" name="project_title">
        </label>
        <hr>
        <label for="projectDescription">
            <span>Описание</span><br>
            <textarea name="project_description" id="projectDescription" rows="8" cols="80"></textarea>
        </label>
        <hr>
        <input type="submit" name="proj_send">
    </form>
</div>

<?php
get_footer();
?>


И почему он не видит POST ?
  • Вопрос задан
  • 86 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы