'enabled'] ); // Поле: URL видео add_settings_field( 'video_url', 'URL видео (mp4)', 'est_field_text_cb', 'est-floating-video', 'est_main_section', ['id' => 'video_url', 'type' => 'url', 'placeholder' => 'https://.../video.mp4'] ); // Поле: ширина мини-плеера add_settings_field( 'width', 'Ширина мини-видео (px)', 'est_field_number_cb', 'est-floating-video', 'est_main_section', ['id' => 'width', 'min' => 80, 'max' => 300] ); // Поле: высота мини-плеера add_settings_field( 'height', 'Высота мини-видео (px)', 'est_field_number_cb', 'est-floating-video', 'est_main_section', ['id' => 'height', 'min' => 120, 'max' => 500] ); // Поле: отступ снизу (bottom) add_settings_field( 'bottom_offset', 'Отступ снизу (px) — полезно над чатом/кнопками', 'est_field_number_cb', 'est-floating-video', 'est_main_section', ['id' => 'bottom_offset', 'min' => 10, 'max' => 300] ); // Поле: показывать на мобильных add_settings_field( 'show_on_mobile', 'Показывать на мобильных устройствах', 'est_field_checkbox_cb', 'est-floating-video', 'est_main_section', ['id' => 'show_on_mobile'] ); } add_action('admin_init', 'est_floating_video_settings_init'); // Колбэки для полей function est_main_section_callback() { echo '
Настройте отображение плавающего промо-видео.
'; } function est_field_checkbox_cb($args) { $options = get_option('est_floating_video_options', []); $value = isset($options[$args['id']]) ? $options[$args['id']] : '1'; ?> /> px!empty($options['enabled']), ]); } add_action('wp_enqueue_scripts', 'est_floating_video_enqueue'); function est_floating_video_output() { $options = get_option('est_floating_video_options', []); // Глобальные настройки по умолчанию $global_enabled = !empty($options['enabled']); $show_on_mobile = isset($options['show_on_mobile']) ? (bool)$options['show_on_mobile'] : true; $global_video_url = !empty($options['video_url']) ? $options['video_url'] : ''; // Определяем, нужно ли вообще показывать if (!$global_enabled) { return; } // Проверка мобильного устройства if (wp_is_mobile() && !$show_on_mobile) { return; } // Определяем видео: сначала индивидуальное, потом глобальное $video_url = $global_video_url; if (is_singular()) { $custom_url = get_post_meta(get_the_ID(), 'est_floating_video_url', true); if (!empty($custom_url)) { $video_url = $custom_url; } } // Если в итоге нет видео — выходим if (empty($video_url)) { return; } $width = $options['width'] ?? 120; $height = $options['height'] ?? 180; $bottom = $options['bottom_offset'] ?? 20; $video_url = esc_url($video_url); ?>