Declare the note constants on the deprecated class. (https://github.com/woocommerce/woocommerce-admin/pull/5215)
* Declare the note constants on the deprecated class. This avoids triggering PHP errors when third party code references the old class constants. * Remove deprecation notices and return the call result * Restore deprecated notices. * Avoid magic strings. * Pass WC_Admin_Note constructor argument to migrated class. * Allow subclasses to access the facade class instance. Co-authored-by: Rebecca Scott <me@becdetat.com>
This commit is contained in:
parent
1bdd2ea0e1
commit
2358f022ef
|
@ -30,7 +30,7 @@ class DeprecatedClassFacade {
|
|||
*
|
||||
* @var object
|
||||
*/
|
||||
private $instance;
|
||||
protected $instance;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -50,7 +50,7 @@ class DeprecatedClassFacade {
|
|||
static::$facade_over_classname . '::' . $name,
|
||||
static::$deprecated_in_version
|
||||
);
|
||||
call_user_func_array(
|
||||
return call_user_func_array(
|
||||
array(
|
||||
$this->instance,
|
||||
$name,
|
||||
|
@ -70,7 +70,7 @@ class DeprecatedClassFacade {
|
|||
static::$facade_over_classname . '::' . $name,
|
||||
static::$deprecated_in_version
|
||||
);
|
||||
call_user_func_array(
|
||||
return call_user_func_array(
|
||||
array(
|
||||
static::$facade_over_classname,
|
||||
$name,
|
||||
|
|
|
@ -16,6 +16,18 @@ use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
|
|||
* WC_Admin_Note (deprecated, use Note instead).
|
||||
*/
|
||||
class WC_Admin_Note extends DeprecatedClassFacade {
|
||||
// These constants must be redeclared as to not break plugins that use them.
|
||||
const E_WC_ADMIN_NOTE_ERROR = Note::E_WC_ADMIN_NOTE_ERROR;
|
||||
const E_WC_ADMIN_NOTE_WARNING = Note::E_WC_ADMIN_NOTE_WARNING;
|
||||
const E_WC_ADMIN_NOTE_UPDATE = Note::E_WC_ADMIN_NOTE_UPDATE;
|
||||
const E_WC_ADMIN_NOTE_INFORMATIONAL = Note::E_WC_ADMIN_NOTE_INFORMATIONAL;
|
||||
const E_WC_ADMIN_NOTE_MARKETING = Note::E_WC_ADMIN_NOTE_MARKETING;
|
||||
const E_WC_ADMIN_NOTE_SURVEY = Note::E_WC_ADMIN_NOTE_SURVEY;
|
||||
const E_WC_ADMIN_NOTE_PENDING = Note::E_WC_ADMIN_NOTE_PENDING;
|
||||
const E_WC_ADMIN_NOTE_UNACTIONED = Note::E_WC_ADMIN_NOTE_UNACTIONED;
|
||||
const E_WC_ADMIN_NOTE_ACTIONED = Note::E_WC_ADMIN_NOTE_ACTIONED;
|
||||
const E_WC_ADMIN_NOTE_SNOOZED = Note::E_WC_ADMIN_NOTE_SNOOZED;
|
||||
|
||||
/**
|
||||
* The name of the non-deprecated class that this facade covers.
|
||||
*
|
||||
|
@ -29,6 +41,15 @@ class WC_Admin_Note extends DeprecatedClassFacade {
|
|||
* @var string
|
||||
*/
|
||||
protected static $deprecated_in_version = '1.6.0';
|
||||
|
||||
/**
|
||||
* Note constructor. Loads note data.
|
||||
*
|
||||
* @param mixed $data Note data, object, or ID.
|
||||
*/
|
||||
public function __construct( $data = '' ) {
|
||||
$this->instance = new static::$facade_over_classname( $data );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue