get_template(); } } return $block_template; } /** * Returns a custom template for the Subscribe Overlay. * * @return WP_Block_Template */ public function get_template() { $template = new WP_Block_Template(); $template->theme = get_stylesheet(); $template->slug = self::BLOCK_TEMPLATE_PART_SLUG; $template->id = self::get_block_template_part_id(); $template->area = 'uncategorized'; $template->content = $this->get_subscribe_overlay_template_content(); $template->source = 'plugin'; $template->type = 'wp_template_part'; $template->title = __( 'Jetpack Subscribe overlay', 'jetpack' ); $template->status = 'publish'; $template->has_theme_file = false; $template->is_custom = true; $template->description = __( 'An overlay that shows up when someone visits your site.', 'jetpack' ); return $template; } /** * Returns the initial content of the Subscribe Overlay template. * This can then be edited by the user. * * @return string */ public function get_subscribe_overlay_template_content() { $home_url = get_home_url(); $site_tagline = get_bloginfo( 'description' ); $default_tagline = __( 'Stay informed with curated content and the latest headlines, all delivered straight to your inbox. Subscribe now to stay ahead and never miss a beat!', 'jetpack' ); $tagline_block = empty( $site_tagline ) ? '

' . $default_tagline . '

' : ''; $skip_to_content = __( 'Skip to content', 'jetpack' ); $group_block_name = esc_attr__( 'Subscribe overlay container', 'jetpack' ); return <<
$tagline_block

$skip_to_content ↓

HTML; } /** * Enqueues JS to load overlay. * * @return void */ public function enqueue_assets() { if ( $this->should_user_see_overlay() ) { wp_enqueue_style( 'subscribe-overlay-css', plugins_url( 'subscribe-overlay.css', __FILE__ ), array(), JETPACK__VERSION ); wp_enqueue_script( 'subscribe-overlay-js', plugins_url( 'subscribe-overlay.js', __FILE__ ), array( 'wp-dom-ready' ), JETPACK__VERSION, true ); } } /** * Adds overlay with Subscribe Overlay content. * * @return void */ public function add_subscribe_overlay_to_frontend() { if ( $this->should_user_see_overlay() ) { ?>