: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Get LICENSE validation message.
* @param array $errors Validation errors.
* @param string $basename Plugin basename.
private function get_license_validation_message( array $errors, string $basename ): string {
if ( self::SHOW_LICENSE_NOTICE && in_array( self::LICENSE, $errors, true ) ) {
$license = $this->list_array(
array_map( 'ucfirst', $this->requirements[ $basename ][ self::LICENSE ] ),
/* translators: %s - license name(s). */
__( '%s license', 'wpforms-lite' ),
* Get ADDON validation message.
* @param array $errors Validation errors.
* @param string $basename Plugin basename.
private function get_addon_validation_message( array $errors, string $basename ): string {
if ( self::SHOW_ADDON_NOTICE && in_array( self::ADDON, $errors, true ) ) {
$self_version = $this->list_version( $this->requirements[ $basename ][ self::ADDON ] );
/* translators: %s - addon self version. */
__( 'self version %s', 'wpforms-lite' ),
* @param string $notice Message.
private function show_notice( string $notice ) {
echo '<div class="notice notice-error"><p>';
echo wp_kses_post( $notice );
* Init addon requirements.
* @param string $basename Addon basename.
private function init_addon_requirements( string $basename ) {
if ( ! array_key_exists( $basename, $this->requirements ) ) {
$this->requirements[ $basename ] = [];
// Set default addon version constant.
if ( array_key_exists( self::ADDON_VERSION_CONSTANT, $this->requirements[ $basename ] ) ) {
strtoupper( explode( '/', $basename, 2 )[0] ) . '_VERSION'
$this->requirements[ $basename ][ self::ADDON_VERSION_CONSTANT ] = $const;
* Get comma-separated list string from requirements' array.
* @param array $arr Array containing a list.
* @param bool $sep Separator of the last element.
private function list_array( array $arr, bool $sep = true ): string {
__( 'and', 'wpforms-lite' ) :
__( 'or', 'wpforms-lite' );
$last = array_slice( $arr, - 1 );
$first = implode( ', ', array_slice( $arr, 0, - 1 ) );
$both = array_filter( array_merge( [ $first ], $last ) );
return implode( ' ' . $separator . ' ', $both );
* Get version from requirements array.
* @param array $requirement Array containing a requirement.
public function list_version( array $requirement ): string {
$compare_arr = $this->get_compare_array( $requirement );
foreach ( $compare_arr as $version2 => $compare ) {
$list[] = $compare . $version2;
return implode( ', ', $list );
* Get a compare array in the following format: [ 'version' => 'compare', ... ].
* @param array $requirement Requirement.
public function get_compare_array( array $requirement ): array {
$versions = $requirement[ self::VERSION ];
$compares = $requirement[ self::COMPARE ];
return array_combine( $versions, $compares );
public function get_requirements(): array {
return $this->requirements;