PHPCS all the things

This commit is contained in:
Allen Snook 2018-09-26 16:35:01 -07:00
parent 677c205ad2
commit cb7a5b3607
3 changed files with 40 additions and 29 deletions

View File

@ -4,18 +4,23 @@
*
* The WooCommerce admin notes class gets admin notes data from storage and checks validity.
*
* @package WooCommerce Admin/Classes
*/
defined( 'ABSPATH' ) || exit;
/**
* WC_Admin_Note class.
*/
class WC_Admin_Note extends WC_Data {
// Note types
// Note types.
const E_WC_ADMIN_NOTE_ERROR = 'error';
const E_WC_ADMIN_NOTE_WARNING = 'warning';
const E_WC_ADMIN_NOTE_UPDATE = 'update'; // i.e. a new version is available
const E_WC_ADMIN_NOTE_UPDATE = 'update'; // i.e. a new version is available.
const E_WC_ADMIN_NOTE_INFORMATIONAL = 'info';
// Note status codes
// Note status codes.
const E_WC_ADMIN_NOTE_UNACTIONED = 'unactioned';
const E_WC_ADMIN_NOTE_ACTIONED = 'actioned';
@ -265,7 +270,7 @@ class WC_Admin_Note extends WC_Data {
* @param string $name Note name.
*/
public function set_name( $name ) {
// Don't allow empty names
// Don't allow empty names.
if ( empty( $name ) ) {
$this->error( 'admin_note_invalid_data', __( 'The admin note name prop cannot be empty.', 'woocommerce' ) );
}
@ -287,6 +292,7 @@ class WC_Admin_Note extends WC_Data {
$this->error(
'admin_note_invalid_data',
sprintf(
/* translators: %s: admin note type. */
__( 'The admin note type prop (%s) is not one of the supported types.', 'woocommerce' ),
$type
)
@ -359,12 +365,12 @@ class WC_Admin_Note extends WC_Data {
/**
* Set note data for potential re-localization.
*
* @param object $data Note data.
* @param object $content_data Note data.
*/
public function set_content_data( $content_data ) {
$allowed_type = false;
// Make sure $content_data is stdClass Object or an array
// Make sure $content_data is stdClass Object or an array.
if ( ! ( $content_data instanceof stdClass ) ) {
$this->error( 'admin_note_invalid_data', __( 'The admin note content_data prop must be an instance of stdClass.', 'woocommerce' ) );
}
@ -386,6 +392,7 @@ class WC_Admin_Note extends WC_Data {
$this->error(
'admin_note_invalid_data',
sprintf(
/* translators: %s: admin note status property. */
__( 'The admin note status prop (%s) is not one of the supported statuses.', 'woocommerce' ),
$status
)
@ -432,6 +439,10 @@ class WC_Admin_Note extends WC_Data {
/**
* Add an action to the note
*
* @param string $name Label name (not presented to user).
* @param string $label Note label (e.g. presented as button label).
* @param string $query Note query (for redirect).
*/
public function add_action( $name, $label, $query ) {
$name = wc_clean( $name );

View File

@ -2,6 +2,7 @@
/**
* Handles storage and retrieval of admin notes
*
* @package WooCommerce Admin/Classes
*/
if ( ! defined( 'ABSPATH' ) ) {

View File

@ -1,5 +1,4 @@
<?php
/**
* WC_Admin_Note_Data_Store class file.
*
@ -15,7 +14,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
/**
* Method to create a new note in the database.
*
* @param WC_Admin_Note
* @param WC_Admin_Note $note Admin note.
*/
public function create( &$note ) {
$date_created = current_time( 'timestamp', 1 );
@ -51,7 +50,8 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
/**
* Method to read a note.
*
* @param WC_Admin_Note
* @param WC_Admin_Note $note Admin note.
* @throws Exception Throws exception when invalid data is found.
*/
public function read( &$note ) {
global $wpdb;
@ -98,7 +98,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
/**
* Updates a note in the database.
*
* @param WC_Admin_Note
* @param WC_Admin_Note $note Admin note.
*/
public function update( &$note ) {
global $wpdb;
@ -130,7 +130,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
/**
* Deletes a note from the database.
*
* @param WC_Admin_Note
* @param WC_Admin_Note $note Admin note.
* @param array $args Array of args to pass to the delete method (not used).
*/
public function delete( &$note, $args = array() ) {
@ -147,8 +147,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
/**
* Read actions from the database.
*
* @param WC_Admin_Note $note Note object.
*
* @param WC_Admin_Note $note Admin note.
*/
private function read_actions( &$note ) {
global $wpdb;