diff --git a/includes/class-wp-notify-aggregate-factory.php b/includes/class-aggregate-factory.php similarity index 96% rename from includes/class-wp-notify-aggregate-factory.php rename to includes/class-aggregate-factory.php index 22343a5e..8a23d541 100644 --- a/includes/class-wp-notify-aggregate-factory.php +++ b/includes/class-aggregate-factory.php @@ -1,6 +1,8 @@ sender; @@ -122,7 +120,7 @@ public function get_sender() { /** * Gets the recipients for the notification. * - * @return WP_Notify_Recipient_Collection Notification recipients. + * @return Recipients\Collection Notification recipients. */ public function get_recipients() { return $this->recipients; @@ -131,7 +129,7 @@ public function get_recipients() { /** * Gets the message for the notification. * - * @return WP_Notify_Message Notification message. + * @return Messages\Message Notification message. */ public function get_message() { return $this->message; diff --git a/includes/class-wp-notify-factory.php b/includes/class-factory.php similarity index 77% rename from includes/class-wp-notify-factory.php rename to includes/class-factory.php index 53e540e3..8774731c 100644 --- a/includes/class-wp-notify-factory.php +++ b/includes/class-factory.php @@ -1,6 +1,12 @@ message_factory = $message_factory; $this->recipient_factory = $recipient_factory; @@ -41,14 +47,14 @@ public function __construct( * * @param $args * - * @return WP_Notify_Base_Notification + * @return Base_Notification */ public function create( $args ) { list( $message_args, $recipients_args, $sender_args ) = $this->validate( $args ); $sender = $this->sender_factory->create( $sender_args ); - $recipients = new WP_Notify_Recipient_Collection(); + $recipients = new Recipients\Collection(); $message = $this->message_factory->create( $message_args ); foreach ( $recipients_args as $type => $value ) { @@ -57,7 +63,7 @@ public function create( $args ) { ); } - return new WP_Notify_Base_Notification( $sender, $recipients, $message ); + return new Base_Notification( $sender, $recipients, $message ); } private function validate( $args ) { diff --git a/includes/demo.php b/includes/demo.php index 9de24668..d28bc33f 100644 --- a/includes/demo.php +++ b/includes/demo.php @@ -5,12 +5,17 @@ * Development demo files **/ +namespace WP\Notifications; + +use WP_Admin_Bar; +use WP_List_Table; + /** * Adds WP Notify icon after the user avatar in the top admin bar in the "secondary" position * * @param WP_Admin_Bar $wp_admin_bar Toolbar instance. */ -function wp_admin_bar_wp_notify_item( WP_Admin_Bar $wp_admin_bar ) { +function admin_bar_item( WP_Admin_Bar $wp_admin_bar ) { if ( ! is_admin() ) { return; } @@ -36,27 +41,27 @@ function wp_admin_bar_wp_notify_item( WP_Admin_Bar $wp_admin_bar ) { ); $wp_admin_bar->add_node( $args ); } -add_action( 'admin_bar_menu', 'wp_admin_bar_wp_notify_item', 1 ); +add_action( 'admin_bar_menu', '\WP\Notifications\admin_bar_item', 1 ); /** * Adds WP Notify area at the top of the dashboard */ -function wp_notify_admin_notice() { +function admin_notice() { echo '
'; } -add_action( 'admin_notices', 'wp_notify_admin_notice' ); +add_action( 'admin_notices', '\WP\Notifications\admin_notice' ); /** * Register and enqueue a wp notify scripts and stylesheet in WordPress admin. */ -function wp_notify_enqueue_admin_assets() { +function enqueue_admin_assets() { /* Load styles */ - wp_register_style( 'wp_notify_css', WP_NOTIFICATION_CENTER_PLUGIN_DIR_URL . '/build/wp-notify.css', array(), WP_NOTIFICATION_CENTER_PLUGIN_VERSION ); + wp_register_style( 'wp_notify_css', WP_FEATURE_NOTIFICATION_PLUGIN_DIR_URL . '/build/wp-notify.css', array(), WP_FEATURE_NOTIFICATION_PLUGIN_VERSION ); wp_enqueue_style( 'wp_notify_css' ); /* Load scripts */ - $asset = include WP_NOTIFICATION_CENTER_PLUGIN_DIR . '/build/wp-notify.asset.php'; - wp_register_script( 'wp_notify_js', WP_NOTIFICATION_CENTER_PLUGIN_DIR_URL . '/build/wp-notify.js', $asset['dependencies'], WP_NOTIFICATION_CENTER_PLUGIN_VERSION, true ); + $asset = include WP_FEATURE_NOTIFICATION_PLUGIN_DIR . '/build/wp-notify.asset.php'; + wp_register_script( 'wp_notify_js', WP_FEATURE_NOTIFICATION_PLUGIN_DIR_URL . '/build/wp-notify.js', $asset['dependencies'], WP_FEATURE_NOTIFICATION_PLUGIN_VERSION, true ); wp_enqueue_script( 'wp_notify_js' ); wp_localize_script( 'wp_notify_js', @@ -67,7 +72,7 @@ function wp_notify_enqueue_admin_assets() { ); } -add_action( 'admin_enqueue_scripts', 'wp_notify_enqueue_admin_assets', 0 ); +add_action( 'admin_enqueue_scripts', '\WP\Notifications\enqueue_admin_assets', 0 ); /** @@ -75,17 +80,17 @@ function wp_notify_enqueue_admin_assets() { * * @return void */ -function wp_notify_add_admin_options_page() { - add_options_page( 'Notifications', 'Notifications', 'manage_options', 'wp-notify', 'wp_notify_render_admin_options_page' ); +function add_admin_options_page() { + add_options_page( 'Notifications', 'Notifications', 'manage_options', 'wp-notify', '\WP\Notifications\render_admin_options_page' ); } -add_action( 'admin_menu', 'wp_notify_add_admin_options_page' ); +add_action( 'admin_menu', '\WP\Notifications\add_admin_options_page' ); /** * Renders the options page. */ -function wp_notify_render_admin_options_page() { ?> +function render_admin_options_page() { ?> @@ -227,16 +232,16 @@ function init_table() { /** * Registers our dashboard widget. */ -function wp_notify_dashboard_widget() { - add_meta_box( 'wp_notify', __( 'WP Notify' ), 'wp_notify_render_dashboard_widget', 'dashboard', 'side', 'high' ); +function dashboard_widget() { + add_meta_box( 'wp_notify', __( 'WP Notify' ), '\WP\Notifications\render_dashboard_widget', 'dashboard', 'side', 'high' ); } -add_action( 'wp_dashboard_setup', 'wp_notify_dashboard_widget' ); +add_action( 'wp_dashboard_setup', '\WP\Notifications\dashboard_widget' ); /** * Renders our dashboard widget. */ -function wp_notify_render_dashboard_widget() { +function render_dashboard_widget() { ?>