When you create a record through the Wordpress admin panel, the table does not appear, which is inserted through the template for the page (when you create it in the "Visually" and "Text" tabs, it doesn’t appear on the finished page and when you click "Publish", there is no Google Chrome DevTools tags with a table). Log Viewer writes this:
Undefined index: mytextarea
Type: PHP Notice Line: 296
File: /home/rocoscru/rocosclinic.ru/docs/wp-content/themes/rocosclinic/functions.php
Undefined variable: selectphysicianSide
Type: PHP Notice Line: 168
File: /home/rocoscru/rocosclinic.ru/docs/wp-content/themes/rocosclinic/page-services-side.php
functions.php file
<?php /* THEME SETUP ------------------------------------------------ */ //function my_scripts_method() { // wp_deregister_script('jquery'); // wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'); // wp_enqueue_script('jquery'); //} // //add_action('wp_enqueue_scripts', 'my_scripts_method'); add_filter('kdmfi_featured_images', function ($featured_images) { $args = array( 'id' => 'featured-image-2', 'desc' => '', 'label_name' => 'Изображение записи(Маленькое)', 'label_set' => 'Установить изображение записи(Маленькое)', 'label_remove' => 'Удалить изображение записи(Маленькое)', 'label_use' => 'Установить изображение записи(Маленькое)', 'post_type' => array('post'), ); $featured_images[] = $args; return $featured_images; }); add_action('add_meta_boxes', 'listing_image_add_metabox'); //Метабокс для комментариев (иницыализация) function listing_image_add_metabox() { add_meta_box('listingimagediv', __('Блок картинок для комментариев', 'text-domain'), 'listing_image_metabox', 'comment', 'normal', 'high'); } function listing_image_metabox($post) { global $content_width, $_wp_additional_image_sizes; //берем Картинки комментария // $image_id = get_post_meta($post->comment_ID, '_listing_image_id', true); $image_id = get_comment_meta($post->comment_ID, '_listing_image_id', true); // $image_id_work = get_post_meta($post->comment_ID, '_listing_image_id_work', true); $image_id_work = get_comment_meta($post->comment_ID, '_listing_image_id_work', true); //Берем размеры картинки $old_content_width = $content_width; //Картинки 120 $content_width = 120; $content_width2 = 400; if ($image_id && get_post($image_id)) { if (!isset($_wp_additional_image_sizes['post-thumbnail'])) { $thumbnail_html = wp_get_attachment_image($image_id, array($content_width, $content_width)); } else { $thumbnail_html = wp_get_attachment_image($image_id, 'post-thumbnail'); } } if (!empty($thumbnail_html2)) { $content_work = '<div id="content-full-work"><h3>Фото работы</h3>'; $content_work .= $thumbnail_html2; $content_work .= '<p class="hide-if-no-js"><a href="javascript:;" id="remove_listing_image_button2" >' . esc_html__('Удалить фото работы', 'text-domain') . '</a></p>'; $content_work .= '<input type="hidden" id="upload_listing_image2" name="_listing_cover_image_work" value="' . esc_attr($image_id_work) . '" />'; $content_work .= '</div>'; } $content_width2 = $old_content_width; } else { $content_work = '<div id="content-full-work"><h3>Фото работы</h3>'; $content_work .= '<img src="" style="width:' . esc_attr($content_width2) . 'px;height:auto;border:0;display:none;" />'; $content_work .= '<p class="hide-if-no-js"><a title="' . esc_attr__('Выберите фото работы', 'text-domain') . '" href="javascript:;" id="upload_listing_image_button2" data-uploader_title="' . esc_attr__('Choose an image', 'text-domain') . '" data-uploader_button_text="' . esc_attr__('Выберите фото работы', 'text-domain') . '">' . esc_html__('Выберите фото работы', 'text-domain') . '</a></p>'; $content_work .= '<input type="hidden" id="upload_listing_image2" name="_listing_cover_image_work" value="" />'; $content_work .= '</div>'; } echo $content_work; } add_action('edit_comment', 'listing_image_save', 10, 1); function listing_image_save($post_id) { if (isset($_POST['_listing_cover_image'])) { $image_id = (int) $_POST['_listing_cover_image']; update_comment_meta($post_id, '_listing_image_id', $image_id); } if (isset($_POST['_listing_cover_image_work'])) { $image_id = (int) $_POST['_listing_cover_image_work']; update_comment_meta($post_id, '_listing_image_id_work', $image_id); } } //Конец обработки функии метабокса //Запуск метабокса для Услуг function my_meta_box() { add_meta_box( 'my_meta_box', // Идентификатор(id) 'Шаблон для страницы (Услуг)', // Заголовок области с мета-полями(title) 'show_my_metabox', // Вызов(callback) 'post', // Где будет отображаться наше поле, в нашем случае в Записях 'normal', 'high' ); } add_action('add_meta_boxes', 'my_meta_box'); // Запускаем функцию function get_promotion_cat() { $promot_cat = array(); $args_promot = array( 'category' => 17, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса ); $promot = get_posts($args_promot); foreach ($promot as $item) { $promot_cat[$item->ID] = array([$item->post_title], [$item->ID]); } return $promot_cat; } $mypromot = get_promotion_cat(); //Взять категорию команды function get_team_cat() { $team_cat = array(); $args_team = array( 'category' => 9, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса ); $team = get_posts($args_team); foreach ($team as $item) { $team_cat[$item->ID] = array([$item->post_title], [$item->ID]); } return $team_cat; } $myteam = get_team_cat(); $meta_fields = array( array( 'label' => 'Выберите врачей', 'desc' => '', 'id' => 'selectphysician', 'type' => 'selectpr', 'options' => $myteam ), array( 'label' => 'Выберите врачей', 'desc' => '', 'id' => 'selectphysician2', 'type' => 'selectpr', 'options' => $myteam ), array( 'label' => 'Выберите врачей', 'desc' => '', 'id' => 'selectphysician3', 'type' => 'selectpr', 'options' => $myteam ), array( 'label' => 'Выберите врачей', 'desc' => '', 'id' => 'selectphysician4', 'type' => 'selectpr', 'options' => $myteam ), array( 'label' => 'Выберите врачей', 'desc' => '', 'id' => 'selectphysician5', 'type' => 'selectpr', 'options' => $myteam ), array( 'label' => 'Выберите Акцию', 'desc' => '', 'id' => 'selectpromo', 'type' => 'selectp-prom', 'options' => $mypromot ), array( 'label' => 'Выберите Акцию', 'desc' => '', 'id' => 'selectpromo1', 'type' => 'selectp-prom', 'options' => $mypromot ), array( 'label' => 'Поле цены', 'desc' => '', 'id' => 'mytextarea', // даем идентификатор. 'type' => 'textarea' // Указываем тип поля. ) ); // Вызов метаполей function show_my_metabox() { global $meta_fields; // Обозначим наш массив с полями глобальным global $post; // Глобальный $post для получения id создаваемого/редактируемого поста // Выводим скрытый input, для верификации. Безопасность прежде всего! echo '<input type="hidden" name="custom_meta_box_nonce" value="' . wp_create_nonce(basename(__FILE__)) . '" />'; // Начинаем выводить таблицу с полями через цикл echo '<table class="form-table">'; foreach ($meta_fields as $field) { // Получаем значение если оно есть для этого поля $meta = get_post_meta($post->ID, $field['id'], true); // Начинаем выводить таблицу echo '<tr> <th><label for="' . $field['id'] . '">' . $field['label'] . '</label></th> <td>'; switch ($field['type']) { case 'selectpr': echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">'; echo '<option value="">Выберите врачей...</option>'; foreach ($field['options'] as $option) { echo '<option', $meta == $option['1']['0'] ? ' selected="selected"' : '', ' value="' . $option['1']['0'] . '">' . $option['0']['0'] . '</option>'; } echo '</select><br /><span class="description">' . $field['desc'] . '</span>'; break; case 'selectp-prom': echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">'; echo '<option value="">Выберите Акцию...</option>'; foreach ($field['options'] as $option) { echo '<option', $meta == $option['1']['0'] ? ' selected="selected"' : '', ' value="' . $option['1']['0'] . '">' . $option['0']['0'] . '</option>'; } echo '</select><br /><span class="description">' . $field['desc'] . '</span>'; break; case 'textarea': wp_editor($meta, 'meta_content_editor', array( 'wpautop' => true, 'media_buttons' => false, 'textarea_name' => $field['id'], 'textarea_rows' => 10, 'teeny' => true )); echo '<br /><span class="description">' . $field['desc'] . '</span>'; break; } echo '</td></tr>'; } echo '</table>'; } // Пишем функцию для сохранения function save_my_meta_fields($post_id) { global $meta_fields; // Массив с нашими полями if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // Проверяем авто-сохранение if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // Проверяем права доступа if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($meta_fields as $field) { $old = get_post_meta($post_id, $field['id'], true); // Получаем старые данные (если они есть), для сверки $new = $_POST[$field['id']]; if ($new && $new != $old) { // Если данные новые update_post_meta($post_id, $field['id'], $new); // Обновляем данные } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); // Если данных нету, удаляем мету. } } // end foreach } add_action('save_post', 'save_my_meta_fields'); // Запускаем функцию сохранения add_action('admin_enqueue_scripts', 'wptuts53021_load_admin_script'); function wptuts53021_load_admin_script($hook) { wp_enqueue_script('admin', get_template_directory_uri() . '/assets/js/admin.js'); } function my_scripts_method() { wp_enqueue_script('main', get_template_directory_uri() . '/assets/js/main.js'); wp_enqueue_script('scrollbar', get_template_directory_uri() . '/assets/js/jquery.custom-scrollbar.js'); wp_enqueue_script('gridify', get_template_directory_uri() . '/assets/js/gridify.js'); wp_enqueue_script('slick', get_template_directory_uri() . '/assets/js/slick.min.js'); wp_enqueue_script('niceselect', get_template_directory_uri() . '/assets/js/jquery.nice-select.min.js'); // wp_enqueue_script('fancybox', '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js'); } add_action('wp_enqueue_scripts', 'my_scripts_method'); function my_css() { wp_enqueue_style('scrollbar', get_template_directory_uri() . '/assets/css/jquery.custom-scrollbar.css'); wp_enqueue_style('slick', get_template_directory_uri() . '/assets/css/slick.css'); wp_enqueue_style('slicktheme', get_template_directory_uri() . '/assets/css/slick-theme.css'); wp_enqueue_style('select', get_template_directory_uri() . '/assets/css/nice-select.css'); wp_enqueue_style('fancybox', 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css'); } add_action('wp_print_styles', 'my_css'); add_theme_support('custom-logo'); add_action('widgets_init', 'my_register_sidebars'); function my_register_sidebars() { register_sidebar( array( 'id' => 'leftsidewidgets', 'name' => __('Left Menu Widgets'), 'description' => __('A short description of the sidebar.'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); } add_action('widgets_init', 'contacts_left_register_sidebars'); function contacts_left_register_sidebars() { register_sidebar( array( 'id' => 'contactsleftsidewidgets', 'name' => __('Contacts leftside'), 'description' => __('A short description of the sidebar.'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); } add_action('widgets_init', 'contacts_right_register_sidebars'); function contacts_right_register_sidebars() { register_sidebar( array( 'id' => 'contactsrightsidewidgets', 'name' => __('Contacts rightside'), 'description' => __('A short description of the sidebar.'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); } function rocosclinic_setup() { // Automatic feed add_theme_support('automatic-feed-links'); // Set content-width global $content_width; if (!isset($content_width)) { $content_width = 560; } // Post thumbnail support add_theme_support('post-thumbnails'); // Post thumbnail size set_post_thumbnail_size(1200, 9999); // Custom image sizes add_image_size('rocosclinic_preview-image', 600, 9999); // Background color add_theme_support('custom-background', array( 'default-color' => 'ffffff', )); // Title tag support add_theme_support('title-tag'); // Add nav menu register_nav_menu('main-menu', __('Main menu', 'rocosclinic')); register_nav_menu('social-menu', __('Social links', 'rocosclinic')); // Add excerpts to pages add_post_type_support('page', array('excerpt')); // HTML5 semantic markup add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption')); // Make the theme translation ready load_theme_textdomain('rocosclinic', get_template_directory() . '/languages'); } add_action('after_setup_theme', 'rocosclinic_setup'); /* IN SEARCH, LIST RESULTS BY DATE ------------------------------------------------ */ function rocosclinic_sort_search_posts_by_date($query) { if (!is_admin() && $query->is_main_query() && $query->is_search()) { $query->set('orderby', 'date'); } } add_action('pre_get_posts', 'rocosclinic_sort_search_posts_by_date'); /* ENQUEUE STYLES ------------------------------------------------ */ function rocosclinic_load_style() { if (!is_admin()) { wp_register_style('rocosclinic-fonts', 'https://fonts.googleapis.com/css?family=Archivo:400,400i,600,600i,700,700i&subset=latin-ext', array(), null); wp_register_style('fontawesome', get_template_directory_uri() . '/assets/css/font-awesome.css', null); wp_enqueue_style('rocosclinic-style', get_template_directory_uri() . '/style.css', array('fontawesome', 'rocosclinic-fonts')); } } add_action('wp_enqueue_scripts', 'rocosclinic_load_style'); /* ADD EDITOR STYLES ------------------------------------------------ */ function rocosclinic_add_editor_styles() { add_editor_style(array( 'rocosclinic-editor-styles.css', 'https://fonts.googleapis.com/css?family=Archivo:400,400i,600,700,700i&subset=latin-ext' )); } add_action('init', 'rocosclinic_add_editor_styles'); /* DEACTIVATE DEFAULT WP GALLERY STYLES ------------------------------------------------ */ add_filter('use_default_gallery_style', '__return_false'); /* ENQUEUE SCRIPTS ------------------------------------------------ */ function rocosclinic_enqueue_scripts() { wp_enqueue_script('rocosclinic_global', get_template_directory_uri() . '/assets/js/global.js', array('jquery', 'imagesloaded', 'masonry'), '', true); global $wp_query; // AJAX PAGINATION wp_localize_script('rocosclinic_global', 'rocosclinic_ajaxpagination', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'query_vars' => json_encode($wp_query->query) )); } add_action('wp_enqueue_scripts', 'rocosclinic_enqueue_scripts'); /* POST CLASSES ------------------------------------------------ */ function rocosclinic_post_classes($classes) { // Class indicating presence/lack of post thumbnail $classes[] = (has_post_thumbnail() ? 'has-thumbnail' : 'missing-thumbnail'); return $classes; } add_action('post_class', 'rocosclinic_post_classes'); /* BODY CLASSES ------------------------------------------------ */ function rocosclinic_body_classes($classes) { // Check whether we're in the customizer preview if (is_customize_preview()) { $classes[] = 'customizer-preview'; } // Hide social buttons if (get_theme_mod('rocosclinic_hide_social')) { $classes[] = 'hide-social'; } // White bg class if (get_theme_mod('rocosclinic_accent_color') == '#ffffff' && (!get_background_color() || get_background_color() == 'ffffff')) { $classes[] = 'white-bg'; } // Check whether the custom backgrounds are both set to the same thing if (get_theme_mod('rocosclinic_accent_color') && get_background_color() && ltrim(get_theme_mod('rocosclinic_accent_color'), '#') == get_background_color()) { $classes[] = 'same-custom-bgs'; } // Dark sidebar text if (get_theme_mod('rocosclinic_dark_sidebar_text')) { $classes[] = 'dark'; } // Add short class for resume page template if (is_page_template('resume-page-template.php')) { $classes[] = 'resume-template'; } // Add short class for full width page template if (is_page_template('full-width-page-template.php')) { $classes[] = 'full-width-template'; } return $classes; } add_action('body_class', 'rocosclinic_body_classes'); /* MODIFY HTML CLASS TO INDICATE JS ------------------------------------------------ */ function rocosclinic_has_js() { ?> <script>jQuery('html').removeClass('no-js').addClass('js');</script> <?php } add_action('wp_head', 'rocosclinic_has_js'); /* ENQUEUE COMMENT-REPLY.JS ------------------------------------------------ */ function rocosclinic_load_scripts() { if ((!is_admin()) && is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } } add_action('wp_enqueue_scripts', 'rocosclinic_load_scripts'); /* GET AND OUTPUT ARCHIVE TYPE ------------------------------------------------ */ /* GET THE TYPE */ function rocosclinic_get_archive_type() { if (is_category()) { $type = __('Category', 'rocosclinic'); } elseif (is_tag()) { $type = __('Tag', 'rocosclinic'); } elseif (is_author()) { $type = __('Author', 'rocosclinic'); } elseif (is_year()) { $type = __('Year', 'rocosclinic'); } elseif (is_month()) { $type = __('Month', 'rocosclinic'); } elseif (is_day()) { $type = __('Date', 'rocosclinic'); } elseif (is_post_type_archive()) { $type = __('Post Type', 'rocosclinic'); } elseif (is_tax()) { $term = get_queried_object(); $taxonomy = $term->taxonomy; $taxonomy_labels = get_taxonomy_labels(get_taxonomy($taxonomy)); $type = $taxonomy_labels->name; } else { $type = __('Archives', 'rocosclinic'); } return $type; } /* OUTPUT THE TYPE */ function rocosclinic_the_archive_type() { $type = rocosclinic_get_archive_type(); echo $type; } /* --------------------------------------------------------------------------------------------- AJAX PAGINATION This function is called to load the next set of posts --------------------------------------------------------------------------------------------- */ function rocosclinic_ajax_results() { $string = json_decode(stripslashes($_POST['query_data']), true); if ($string) : $args = array( 's' => $string, 'posts_per_page' => 5, 'post_status' => 'publish', ); $ajax_query = new WP_Query($args); if ($ajax_query->have_posts()) { ?> <p class="results-title"><?php _e('Search Results', 'rocosclinic'); ?></p> <ul> <?php // Custom loop while ($ajax_query->have_posts()) : $ajax_query->the_post(); // Load the appropriate content template get_template_part('content-mobile-search'); // End the loop endwhile; ?> </ul> <?php if ($ajax_query->max_num_pages > 1) : ?> <a class="show-all" href="<?php echo esc_url(home_url('?s=' . $string)); ?>"><?php _e('Show all', 'rocosclinic'); ?></a> <?php endif; ?> <?php } else { echo '<p class="no-results-message">' . __('We could not find anything that matches your search query. Please try again.', 'rocosclinic') . '</p>'; } endif; // if string die(); } add_action('wp_ajax_nopriv_ajax_pagination', 'rocosclinic_ajax_results'); add_action('wp_ajax_ajax_pagination', 'rocosclinic_ajax_results'); /* REMOVE PREFIX BEFORE ARCHIVE TITLES ------------------------------------------------ */ function rocosclinic_remove_archive_title_prefix($title) { if (is_category()) { $title = single_cat_title('', false); } elseif (is_tag()) { $title = single_tag_title('#', false); } elseif (is_author()) { $title = '<span class="vcard">' . get_the_author() . '</span>'; } elseif (is_year()) { $title = get_the_date('Y'); } elseif (is_month()) { $title = get_the_date('F Y'); } elseif (is_day()) { $title = get_the_date(get_option('date_format')); } elseif (is_tax('post_format')) { if (is_tax('post_format', 'post-format-aside')) { $title = _x('Aside', 'post format archive title', 'rocosclinic'); } elseif (is_tax('post_format', 'post-format-gallery')) { $title = _x('Galleries', 'post format archive title', 'rocosclinic'); } elseif (is_tax('post_format', 'post-format-image')) { $title = _x('Images', 'post format archive title', 'rocosclinic'); } elseif (is_tax('post_format', 'post-format-video')) { $title = _x('Videos', 'post format archive title', 'rocosclinic'); } elseif (is_tax('post_format', 'post-format-quote')) { $title = _x('Quotes', 'post format archive title', 'rocosclinic'); } elseif (is_tax('post_format', 'post-format-link')) { $title = _x('Links', 'post format archive title', 'rocosclinic'); } elseif (is_tax('post_format', 'post-format-status')) { $title = _x('Statuses', 'post format archive title', 'rocosclinic'); } elseif (is_tax('post_format', 'post-format-audio')) { $title = _x('Audio', 'post format archive title', 'rocosclinic'); } elseif (is_tax('post_format', 'post-format-chat')) { $title = _x('Chats', 'post format archive title', 'rocosclinic'); } } elseif (is_post_type_archive()) { $title = single_term_title('', false); } elseif (is_tax()) { $title = single_term_title('', false); } else { $title = __('Archives', 'rocosclinic'); } return $title; } add_filter('get_the_archive_title', 'rocosclinic_remove_archive_title_prefix'); /* CUSTOM COMMENT OUTPUT ------------------------------------------------ */ if (!function_exists('rocosclinic_comment')) { function rocosclinic_comment($comment, $args, $depth) { switch ($comment->comment_type) : case 'pingback': case 'trackback': global $post; ?> <div <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> <?php _e('Pingback:', 'rocosclinic'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('Edit', 'rocosclinic')); ?> ?>