ay( 'status' => $status ) ); } /** * Changes the domain's block list status if it differs from the current status. * * @param string $current_status The current status to compare against. * * @return void */ public function change_status( $current_status ): void { $status = get_site_transient( self::CACHE_BLACKLIST_STATUS ); if ( false === $status ) { $status = $this->domain_status(); } // Check changes. if ( $status !== $current_status ) { if ( '1' === $current_status ) { $this->make_wpmu_request( WPMUDEV::API_BLACKLIST, array(), array( 'method' => 'POST' ) ); $status = $this->domain_status(); } else { $this->reset_blocklist_monitor(); $status = - 1; } set_site_transient( self::CACHE_BLACKLIST_STATUS, $status, self::CACHE_TIME ); } } /** * Get domain status. Variants: * '1' -> 'good' */ public function get_status() { $status = get_site_transient( self::CACHE_BLACKLIST_STATUS ); if ( false === $status ) { $status = $this->domain_status(); } if ( is_wp_error( $status ) ) { return $status->get_error_message(); } return $status; } /** * Exports strings. * * @return array An array of strings. */ public function export_strings(): array { if ( ! $this->is_pro() ) { return array( sprintf( /* translators: %s: Html for Pro-tag. */ esc_html__( 'Inactive %s', 'defender-security' ), 'Pro' ), ); } if ( '1' === (string) $this->get_status() ) { $strings = array( esc_html__( 'Active', 'defender-security' ) ); } else { $strings = array( esc_html__( 'Inactive', 'defender-security' ) ); } return $strings; } /** * Configures strings based on the provided configuration and subscription status. * * @param array $config Configuration array. * @param bool $is_pro Indicates whether the subscription is Pro. * * @return array An array of configuration strings. */ public function config_strings( $config, $is_pro ): array { if ( $is_pro ) { $strings = $config['enabled'] ? array( esc_html__( 'Active', 'defender-security' ) ) : array( esc_html__( 'Inactive', 'defender-security' ), ); } else { $strings = array( sprintf( /* translators: %s: Html for Pro-tag. */ esc_html__( 'Inactive %s', 'defender-security' ), 'Pro' ), ); } return $strings; } /** * Define settings labels. * * @return array */ public function labels(): array { return array( 'enabled' => esc_html__( 'Blocklist Monitor', 'defender-security' ), 'status' => esc_html__( 'Status', 'defender-security' ), ); } }