plugin_slug = $config['plugin_slug']; $this->plugin_name = $config['plugin_name']; $this->plugin_url = $config['plugin_url']; $this->support_url = $config['support_url']; $this->review_url = $config['review_url']; $this->allowed_screens = $config['allowed_screens']; $this->stories_api_url = $config['stories_api_url']; $this->banners_api_url = $config['banners_api_url']; $this->base_plugins = isset($config['base_plugins']) ? $config['base_plugins'] : [$this->plugin_slug]; $this->pro_plugin_slug = isset($config['pro_plugin_slug']) ? $config['pro_plugin_slug'] : null; $this->pro_class = isset($config['pro_class']) ? $config['pro_class'] : null; $this->filter_string = isset($config['filter_string']) ? $config['filter_string'] : $this->generate_filter_string(); $this->api_url = $config['api_url']; } /** * Boot and render all available components (Notice, Stories, Banner, Rating). * * Should be called during the plugin's initialization phase. * * @return void */ public function boot() { // Initialize core notices Notice::init(); // Show stories from remote API Stories::instance($this->plugin_slug) ->set_filter($this->filter_string) ->set_plugin($this->plugin_name, $this->plugin_url) ->set_api_url($this->stories_api_url) ->call(); // Show banners from remote API Banner::instance($this->plugin_slug) ->set_filter(ltrim($this->filter_string, ',')) ->set_api_url($this->banners_api_url) ->set_plugin_screens($this->allowed_screens) ->call(); // Show rating prompt // Rating::instance($this->plugin_slug) // ->set_plugin($this->plugin_name, $this->review_url) // ->set_allowed_screens($this->allowed_screens) // ->set_priority(30) // ->set_first_appear_day(7) // ->set_condition(true) // ->set_api_url($this->api_url) // ->set_support_url($this->support_url) // ->call(); } /** * Generate a comma-separated plugin filter string. * * Adds the pro plugin slug if the corresponding class exists, * and removes `-free-only` suffix if pro is active. * * @return string */ protected function generate_filter_string() { $plugins = $this->base_plugins; if ( $this->pro_class && (class_exists($this->pro_class) || function_exists($this->pro_class)) && $this->pro_plugin_slug ) { $plugins[] = $this->pro_plugin_slug; // Remove potential 'free-only' entry if pro is active $plugins = array_filter($plugins, function ($plugin) { return $plugin !== $this->plugin_slug . '-free-only'; }); } return implode(',', $plugins); } }