: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Class Advanced_Ads_Ad_Network_Ad_Unit
* This represents an external ad unit. Will be used for importing external ads from various ad networks.
class Advanced_Ads_Ad_Network_Ad_Unit {
* Contains the raw data (typically from a JSON response) for this ad unit
* The (external) id of this ad unit (e.g. pub-ca... for adsense)
* The display name of the ad
* The type of this ad unit (displayed in list)
* The size of this ad unit (displayed in list)
* In case of an AdSense ad, this is the id of the ad without the publisher id
* the value will be displayed in the ads list
* A bool that indicates whether an ad is active (inactives will be hidden by default)
* Advanced_Ads_Ad_Network_Ad_Unit constructor.
* @param string $raw raw ad data.
public function __construct( $raw ) {
* Sort multiple ad units.
* @param array $ad_units array of ad units.
* @param string $selected_id ID of the selected ad. Can be taken from the ad network and therefore also a string.
public static function sort_ad_units( array &$ad_units, $selected_id ) {
function ( $a, $b ) use ( $selected_id ) {
if ( $a->id == $selected_id ) {
if ( $b->id == $selected_id ) {
if ( $a->is_supported ) {
if ( ! $b->is_supported ) {
} elseif ( $b->is_supported ) {
return strcasecmp( $a->name, $b->name );