: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// write errors to the log
if ( $error_messages = $this->error_messages->get_error_messages() ) {
foreach ( $error_messages as $error_message ) {
Advanced_Ads::log( __METHOD__ . ': ' . $error_message );
* @param array $haystack array to check, that the returned string does not exist in this array
* @param string $extension Extension to append to the name.
* @return string unique name
function generate_unique_name( $haystack = false, $extension = '' ) {
$extension = $extension ? '.' . $extension : '';
$rand = (string) mt_rand( 1, 999 );
$needle = (string) $rand . $extension;
$needle = (string) $rand . '_' . $i . $extension;
} while( in_array( $needle, $haystack ) );
$needle = (string) mt_rand( 1, 999 ) . $extension;
* Clear assets (on uninstall)
function clear_assets() {
$advads_options = Advanced_Ads::get_instance()->options();
if ( ! empty( $this->options['folder_name'] )
&& ! empty( $this->options['module_can_work'] )
&& class_exists( 'WP_Filesystem_Direct', false )
$wp_filesystem = new WP_Filesystem_Direct( new StdClass() );
$path = trailingslashit( $this->upload_dir['basedir'] ) . trailingslashit( $this->options['folder_name'] );
$wp_filesystem->rmdir( $path, true );