: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* The class is responsible for the one-click module workflow.
* @author Advanced Ads <info@wpadvancedads.com>
namespace AdvancedAds\Modules\OneClick;
use AdvancedAds\Modules\OneClick\Helpers;
use AdvancedAds\Modules\OneClick\Options;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
use AdvancedAds\Framework\Utilities\Params;
use AdvancedAds\Modules\OneClick\AdsTxt\AdsTxt;
use AdvancedAds\Modules\OneClick\Traffic_Cop;
defined( 'ABSPATH' ) || exit;
class Workflow implements Integration_Interface {
* Flush rules option key.
const FLUSH_KEY = 'pubguru_flush_rewrite_rules';
public function hooks(): void {
add_action( 'init', [ $this, 'flush_rewrite_rules' ], 999 );
add_action( 'pubguru_module_status_changed', [ $this, 'module_status_changed' ], 10, 1 );
add_action( 'advanced-ads-pghb-auto-ad-creation', [ $this, 'auto_ad_creation' ], 10, 0 );
if ( false !== Options::pubguru_config() && ! is_admin() ) {
add_action( 'wp', [ $this, 'init' ] );
if ( Helpers::is_module_enabled( 'ads_txt' ) ) {
( new AdsTxt() )->hooks();
public function init(): void {
$is_debugging = Params::get( 'aa-debug', false, FILTER_VALIDATE_BOOLEAN );
if ( ! $is_debugging && Helpers::is_ad_disabled() ) {
Page_Parser::get_instance();
if ( $is_debugging || Helpers::is_module_enabled( 'header_bidding' ) ) {
( new Header_Bidding() )->hooks();
if ( $is_debugging || Helpers::is_module_enabled( 'tag_conversion' ) ) {
( new Tags_Conversion() )->hooks();
if ( Helpers::is_module_enabled( 'traffic_cop' ) && Helpers::has_traffic_cop() ) {
if ( ! Helpers::is_module_enabled( 'header_bidding' ) ) {
( new Header_Bidding() )->hooks();
( new Traffic_Cop() )->hooks();
* Handle module status change
* @param string $module Module name.
public function module_status_changed( $module ): void {
if ( 'ads_txt' === $module ) {
update_option( self::FLUSH_KEY, 1 );
* Flush the rewrite rules once if the pubguru_flush_rewrite_rules option is set
public function flush_rewrite_rules(): void {
if ( get_option( self::FLUSH_KEY ) ) {
delete_option( self::FLUSH_KEY );
* Start auto ad creation process
public function auto_ad_creation(): void {
$ads = Helpers::get_ads_from_config();
// ( new Auto_Ads() )->run( $ads );