: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
public function sanitize_frontend_prefix( $prefix, $fallback = '' ) {
$prefix = sanitize_html_class( $prefix );
$nonascii = '[^\0-\177]';
$unicode = '\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?';
$escape = sprintf( '%s|\\[^\n\r\f0-9a-f]', $unicode );
$nmstart = sprintf( '[_a-z]|%s|%s', $nonascii, $escape );
$nmchar = sprintf( '[_a-z0-9-]|%s|%s', $nonascii, $escape );
if ( ! preg_match( sprintf( '/-?(?:%s)(?:%s)*/i', $nmstart, $nmchar ), $prefix, $matches ) ) {
* Get priority used for injection inside content
public function get_content_injection_priority() {
$options = $this->options();
return isset( $options['content-injection-priority'] ) ? (int) $options['content-injection-priority'] : 100;
* Returns the capability needed to perform an action
* @param string $capability a capability to check, can be internal to Advanced Ads.
* @return string $capability a valid WordPress capability.
public static function user_cap( $capability = 'manage_options' ) {
_deprecated_function( __METHOD__, '1.47.0', '\AdvancedAds\Utilities\WordPress::user_cap()' );
return WordPress::user_cap( $capability );
* Create roles and capabilities
public function create_capabilities() {
_deprecated_function( __METHOD__, '1.47.0', 'AdvancedAds\Installation\Capabilities::create_capabilities()' );
( new Capabilities() )->create_capabilities();
* Remove roles and capabilities
public function remove_capabilities() {
_deprecated_function( __METHOD__, '1.47.0', 'AdvancedAds\Installation\Capabilities::remove_capabilities()' );
( new Capabilities() )->remove_capabilities();
* Check if any add-on is activated
* @return bool true if there is any add-on activated
public static function any_activated_add_on() {
return ( defined( 'AAP_VERSION' ) // Advanced Ads Pro.
|| defined( 'AAGAM_VERSION' ) // Google Ad Manager.
|| defined( 'AASA_VERSION' ) // Selling Ads.
|| defined( 'AAT_VERSION' ) // Tracking.
|| defined( 'AASADS_VERSION' ) // Sticky Ads.
|| defined( 'AAR_VERSION' ) // Responsive Ads.
|| defined( 'AAPLDS_VERSION' ) // PopUp and Layer Ads.
* Get the correct support URL: wp.org for free users and website for those with any add-on installed
* @param string $utm add UTM parameter to the link leading to https://wpadvancedads.com, if given.
public static function support_url( $utm = '' ) {
$utm = empty( $utm ) ? '?utm_source=advanced-ads&utm_medium=link&utm_campaign=support' : $utm;
if ( self::any_activated_add_on() ) {
$url = 'https://wpadvancedads.com/support/' . $utm . '-with-addons';
$url = 'https://wpadvancedads.com/support/' . $utm . '-free-user';
* @param string $url optional parameter.
* @param string $ex group.
public static function get_group_by_url( $url = '', $ex = 'a' ) {
$url = self::get_short_url( $url );
$code = (int)substr( md5( $url ), - 1 );
return ( $code & 2 ) >> 1; // returns 1 or 0.
return ( $code & 4 ) >> 2; // returns 1 or 0.
return ( $code & 8 ) >> 3; // returns 1 or 0.
return $code & 1; // returns 1 or 0.
* Check if user started after a given date
* @param integer $timestamp time stamp.
* @return bool true if user is added after timestamp.
public static function is_new_user( $timestamp = 0 ) {
// allow admins to see version for new users in any case.
if ( WordPress::user_can( 'advanced_ads_manage_options' ) && isset( $_REQUEST['advads-ignore-timestamp'] ) ) {
$timestamp = absint( $timestamp );
$options = self::get_instance()->internal_options();
$installed = isset( $options['installed'] ) ? $options['installed'] : 0;
return ( $installed >= $timestamp );
* Show stuff to new users only.
* @param integer $timestamp time after which to show whatever.
* @param string $group optional group.
* @return bool true if user enabled after given timestamp.
public static function show_to_new_users( $timestamp, $group = 'a' ) {
return ( self::get_group_by_url( null, $group ) && self::is_new_user( $timestamp ) );
* Get short version of home_url()
* remove protocol and www
* @param string $url URL to be shortened.
public static function get_short_url( $url = '' ) {
$url = empty( $url ) ? home_url() : $url;
if ( preg_match( '/^(\w[\w\d]*:\/\/)?(www\.)?(.*)$/', trim( $url ), $matches ) ) {
$url = trim( $url, '/' );
* Fires when a post is transitioned from one status to another.
* @param string $new_status New post status.
* @param string $old_status Old post status.
* @param WP_Post $post Post object.
public function transition_ad_status( $new_status, $old_status, $post ) {
if ( ! isset( $post->post_type ) || Entities::POST_TYPE_AD !== $post->post_type || ! isset( $post->ID ) ) {
$ad = \Advanced_Ads\Ad_Repository::get( $post->ID );
if ( $old_status !== $new_status ) {
* Fires when an ad has transitioned from one status to another.
* @param Advanced_Ads_Ad $ad Ad object.
do_action( "advanced-ads-ad-status-{$old_status}-to-{$new_status}", $ad );
if ( 'publish' === $new_status && 'publish' !== $old_status ) {
* Fires when an ad has transitioned from any other status to `publish`.
* @param Advanced_Ads_Ad $ad Ad object.
do_action( 'advanced-ads-ad-status-published', $ad );
if ( 'publish' === $old_status && 'publish' !== $new_status ) {
* Fires when an ad has transitioned from `publish` to any other status.
* @param Advanced_Ads_Ad $ad Ad object.
do_action( 'advanced-ads-ad-status-unpublished', $ad );
if ( $old_status === 'publish' && $new_status === Advanced_Ads_Ad_Expiration::POST_STATUS ) {
* Fires when an ad is expired.
* @param Advanced_Ads_Ad $ad
do_action( 'advanced-ads-ad-expired', $ad->id, $ad );