: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Display list of Ad Health notices
public function ad_health_notice_display() {
check_ajax_referer( 'advanced-ads-admin-ajax-nonce', 'nonce' );
if ( ! WordPress::user_can( 'advanced_ads_manage_options' ) ) {
Advanced_Ads_Ad_Health_Notices::get_instance()->render_widget();
* Push an Ad Health notice to the queue
public function ad_health_notice_push() {
check_ajax_referer( 'advanced-ads-admin-ajax-nonce', 'nonce' );
if ( ! WordPress::user_can( 'advanced_ads_manage_options' ) ) {
$key = ( ! empty( $_REQUEST['key'] ) ) ? esc_attr( $_REQUEST['key'] ) : false;
$attr = ( ! empty( $_REQUEST['attr'] ) && is_array( $_REQUEST['attr'] ) ) ? $_REQUEST['attr'] : [];
if ( isset( $attr['mode'] ) && 'update' === $attr['mode'] ) {
Advanced_Ads_Ad_Health_Notices::get_instance()->update( $key, $attr );
Advanced_Ads_Ad_Health_Notices::get_instance()->add( $key, $attr );
public function ad_health_notice_hide() {
check_ajax_referer( 'advanced-ads-admin-ajax-nonce', 'nonce' );
if ( ! WordPress::user_can( 'advanced_ads_manage_options' ) ) {
$notice_key = ( ! empty( $_REQUEST['notice'] ) ) ? esc_attr( $_REQUEST['notice'] ) : false;
Advanced_Ads_Ad_Health_Notices::get_instance()->hide( $notice_key );
* Show all ignored notices of a given type
public function ad_health_notice_unignore() {
check_ajax_referer( 'advanced-ads-admin-ajax-nonce', 'nonce' );
if ( ! WordPress::user_can( 'advanced_ads_manage_options' ) ) {
Advanced_Ads_Ad_Health_Notices::get_instance()->unignore();
* After the user has selected a new frontend element, update the corresponding placement.
public function update_frontend_element() {
check_ajax_referer( 'advanced-ads-admin-ajax-nonce', 'nonce' );
if ( ! WordPress::user_can( 'advanced_ads_manage_placements' ) ) {
if ( isset( $_POST['advads']['placements'] ) ) {
Advanced_Ads_Placements::save_placements( $_POST['advads']['placements'] );
* Get hints related to the Gutenberg block.
public function get_block_hints() {
check_ajax_referer( 'advanced-ads-admin-ajax-nonce', 'nonce' );
! isset( $_POST['itemID'] )
|| ! WordPress::user_can( 'advanced_ads_edit_ads' )
$item = explode( '_', $_POST['itemID'] );
if ( ! isset( $item[0] ) || $item[0] !== 'group' ) {
$hints = Advanced_Ads_Group::get_hints( new Advanced_Ads_Group( (int) $item[1] ) );
wp_send_json_success( $hints );
* Get allowed ads per placement.
public function get_allowed_ads_for_placement_type() {
check_ajax_referer( sanitize_text_field( $_POST['action'] ) );
Advanced_Ads_Placements::get_items_for_placement( sanitize_text_field( $_POST['placement_type'] ) ),
static function( $items_group ) {
return ! empty( $items_group['items'] );