Skip to content

Commit

Permalink
release 4.5.11: php8+ improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 6, 2024
1 parent ea7a283 commit 36d57be
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 114 deletions.
7 changes: 5 additions & 2 deletions includes/api/class-api-v3-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ private function request( $method, $resource, array $args = array() ) {
case 'stats': case 'lists.stats': case 'lists.stats.member_count': case 'lists.stats.merge_field_count':
if (!property_exists($ret, 'stats')) $ret->stats = (object) array();
if ($f == 'stats' || $f == 'lists.stats' || $f == 'lists.stats.member_count') $ret->stats->member_count = service_user_count();
if ($f == 'stats' || $f == 'lists.stats' || $f == 'lists.stats.merge_field_count') $ret->stats->merge_field_count = count(service_user_profile_fields_list());
if ($f == 'stats' || $f == 'lists.stats' || $f == 'lists.stats.merge_field_count') {
$fc = service_user_profile_fields_list();
$ret->stats->merge_field_count = is_array($fc) ? count($fc) : 0;
}
break;
case 'web_id': case 'lists.web_id': $ret->web_id = '1'; break; // non applicabile
// fino a nl4wp 4.5.5 venivano chiesti, ma non utilizzati, quindi li popolo casualmente.
Expand Down Expand Up @@ -218,7 +221,7 @@ private function request( $method, $resource, array $args = array() ) {
return $v["visibility"] == "register"; //visibility register??
});
$ret = (object) array();
if (count($groups) > 0)
if (is_array($groups) && count($groups) > 0)
$ret->categories = array((object) array('id' => 1, 'title' => "Gruppi", 'type' => 'checkboxes'));

return $ret;
Expand Down
2 changes: 1 addition & 1 deletion includes/api/xmlrpc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2441,7 +2441,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
{
$val = explode('=', $val, 2);
$tag = trim($val[0]);
$val = trim(@$val[1]);
$val = isset($val[1]) && !empty($val[1]) ? trim($val[1]) : '';
/// @todo with version 1 cookies, we should strip leading and trailing " chars
if ($pos == 0)
{
Expand Down
210 changes: 104 additions & 106 deletions includes/class-container.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,123 +6,121 @@
* @access private
* @ignore
*/
class NL4WP_Container implements ArrayAccess
{
class NL4WP_Container implements ArrayAccess {

/**
* @var array
*/
protected $services = array();

/**
* @var array
*/
protected $resolved_services = array();
/**
* @var array
*/
protected $services = array();

/**
* @param $name
* @return boolean
*/
public function has($name)
{
return isset($this->services[ $name ]);
}
/**
* @var array
*/
protected $resolved_services = array();

/**
* @param $name
*
* @return mixed
* @throws Exception
*/
public function get($name)
{
if (! $this->has($name)) {
throw new Exception(sprintf('No service named %s was registered.', $name));
}
/**
* @param string $name
* @return boolean
*/
public function has( $name ) {
return isset( $this->services[ $name ] );
}

$service = $this->services[ $name ];
/**
* @param string $name
*
* @return mixed
* @throws Exception
*/
public function get( $name ) {
if ( ! $this->has( $name ) ) {
throw new Exception( sprintf( 'No service named %s was registered.', $name ) );
}

// is this a resolvable service?
if (is_callable($service)) {
$service = $this->services[ $name ];

// resolve service if it's not resolved yet
if (! isset($this->resolved_services[ $name ])) {
$this->resolved_services[ $name ] = call_user_func($service);
}
// is this a resolvable service?
if ( is_callable( $service ) ) {

return $this->resolved_services[ $name ];
}
// resolve service if it's not resolved yet
if ( ! isset( $this->resolved_services[ $name ] ) ) {
$this->resolved_services[ $name ] = call_user_func( $service );
}

return $this->services[ $name ];
}
return $this->resolved_services[ $name ];
}

/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Whether a offset exists
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
*
* @param mixed $offset <p>
* An offset to check for.
* </p>
*
* @return boolean true on success or false on failure.
* </p>
* <p>
* The return value will be casted to boolean if non-boolean was returned.
*/
public function offsetExists($offset)
{
return $this->has($offset);
}
return $this->services[ $name ];
}

/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Offset to retrieve
* @link http://php.net/manual/en/arrayaccess.offsetget.php
*
* @param mixed $offset <p>
* The offset to retrieve.
* </p>
*
* @return mixed Can return all value types.
*/
public function offsetGet($offset)
{
return $this->get($offset);
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Whether a offset exists
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
*
* @param mixed $offset <p>
* An offset to check for.
* </p>
*
* @return boolean true on success or false on failure.
* </p>
* <p>
* The return value will be casted to boolean if non-boolean was returned.
*/
#[\ReturnTypeWillChange]
public function offsetExists( $offset ) {
return $this->has( $offset );
}

/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Offset to set
* @link http://php.net/manual/en/arrayaccess.offsetset.php
*
* @param mixed $offset <p>
* The offset to assign the value to.
* </p>
* @param mixed $value <p>
* The value to set.
* </p>
*
* @return void
*/
public function offsetSet($offset, $value)
{
$this->services[ $offset ] = $value;
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Offset to retrieve
* @link http://php.net/manual/en/arrayaccess.offsetget.php
*
* @param mixed $offset <p>
* The offset to retrieve.
* </p>
*
* @return mixed Can return all value types.
*/
#[\ReturnTypeWillChange]
public function offsetGet( $offset ) {
return $this->get( $offset );
}

/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Offset to unset
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
*
* @param mixed $offset <p>
* The offset to unset.
* </p>
*
* @return void
*/
public function offsetUnset($offset)
{
unset($this->services[ $offset ]);
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Offset to set
* @link http://php.net/manual/en/arrayaccess.offsetset.php
*
* @param mixed $offset <p>
* The offset to assign the value to.
* </p>
* @param mixed $value <p>
* The value to set.
* </p>
*
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet( $offset, $value ) {
$this->services[ $offset ] = $value;
}

/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Offset to unset
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
*
* @param mixed $offset <p>
* The offset to unset.
* </p>
*
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset( $offset ) {
unset( $this->services[ $offset ] );
}
}
6 changes: 3 additions & 3 deletions newsletter-for-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Newsletter for WordPress
Plugin URI: https://github.com/mailrouter/Newsletter-for-Wordpress
Description: Newsletter for WordPress by mailrouter. Aggiunge vari metodi di iscrizione newsletter al tuo sito.
Version: 4.5.10
Version: 4.5.11
Author: mailrouter
Text Domain: newsletter-for-wp
Domain Path: /languages
Expand Down Expand Up @@ -57,11 +57,11 @@ function _nl4wp_load_plugin()
}

// bootstrap the core plugin
define( 'NL4WP_VERSION', '4.5.10');
define( 'NL4WP_VERSION', '4.5.11');
/* NL_CHANGED - start
* imposta la versione pro
*/
define ('NL4WP_PREMIUM_VERSION', '4.5.10');
define ('NL4WP_PREMIUM_VERSION', '4.5.11');
/* NL_CHANGED - end */
define('NL4WP_PLUGIN_DIR', dirname(__FILE__) . '/');
define('NL4WP_PLUGIN_URL', plugins_url('/', __FILE__));
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: Morloi, Bago
Tags: newsletter, nl4wp, email, marketing, newsletter, subscribe, widget, nl4wp, contact form 7, woocommerce, buddypress, ibericode, newsletter forms, newsletter integrations
Requires at least: 4.1
Tested up to: 6.2.2
Stable tag: 4.5.10
Tested up to: 6.5.2
Stable tag: 4.5.11
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Requires PHP: 5.3
Expand Down

0 comments on commit 36d57be

Please sign in to comment.