__( 'Insert an ad unit wherever you can place a widget.', 'jetpack' ), 'customize_selective_refresh' => true, ) ); add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) ); } /** * Remove the Ad widget from the Legacy Widget block * * @param array $widget_types List of widgets that are currently removed from the Legacy Widget block. * * @return array $widget_types New list of widgets that will be removed. */ public function hide_widget_in_block_editor( $widget_types ) { $widget_types[] = 'wordads_sidebar_widget'; return $widget_types; } /** * The Widget outputter. * * @param array $args Widget args. * @param array $instance The Widget instance. * * @return bool|void */ public function widget( $args, $instance ) { global $wordads; if ( $wordads->should_bail() ) { return false; } if ( ! isset( $instance['unit'] ) ) { $instance['unit'] = 'mrec'; } ++self::$num_widgets; $about = __( 'Advertisements', 'jetpack' ); $width = WordAds::$ad_tag_ids[ $instance['unit'] ]['width']; $height = WordAds::$ad_tag_ids[ $instance['unit'] ]['height']; $unit_id = 1 === self::$num_widgets ? 3 : self::$num_widgets + 3; // 2nd belowpost is '4' $section_id = 0 === $wordads->params->blog_id ? WORDADS_API_TEST_ID : $wordads->params->blog_id . $unit_id; $snippet = ''; if ( $wordads->option( 'wordads_house', true ) ) { $unit = 'mrec'; if ( 'leaderboard' === $instance['unit'] && ! $this->params->mobile_device ) { $unit = 'leaderboard'; } elseif ( 'wideskyscraper' === $instance['unit'] ) { $unit = 'widesky'; } $snippet = $wordads->get_house_ad( $unit ); } else { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $wordads->get_ad_snippet( $section_id, $height, $width, 'widget' ); return; } ?>