| @@ -9,9 +9,8 @@ | ||
| 9 | 9 | |
| 10 | 10 | namespace Packetery\Module; |
| 11 | 11 | |
| 12 | 12 | use Packetery\Latte\Engine; |
| 13 | -use Packetery\Module\Framework\WpAdapter; | |
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * Class Message_Manager |
| 17 | 16 | * |
| @@ -35,13 +34,8 @@ | ||
| 35 | 34 | */ |
| 36 | 35 | private $latteEngine; |
| 37 | 36 | |
| 38 | 37 | /** |
| 39 | - * @var WpAdapter | |
| 40 | - */ | |
| 41 | - private $wpAdapter; | |
| 42 | - | |
| 43 | - /** | |
| 44 | 38 | * Messages to be displayed. |
| 45 | 39 | * |
| 46 | 40 | * @var array<array<string, string>> |
| 47 | 41 | */ |
| @@ -46,14 +40,15 @@ | ||
| 46 | 40 | * @var array<array<string, string>> |
| 47 | 41 | */ |
| 48 | 42 | private $messages = []; |
| 49 | 43 | |
| 50 | - public function __construct( | |
| 51 | - Engine $latteEngine, | |
| 52 | - WpAdapter $wpAdapter | |
| 53 | - ) { | |
| 44 | + /** | |
| 45 | + * Message_Manager constructor. | |
| 46 | + * | |
| 47 | + * @param Engine $latteEngine PacketeryLatte engine. | |
| 48 | + */ | |
| 49 | + public function __construct( Engine $latteEngine ) { | |
| 54 | 50 | $this->latteEngine = $latteEngine; |
| 55 | - $this->wpAdapter = $wpAdapter; | |
| 56 | 51 | } |
| 57 | 52 | |
| 58 | 53 | /** |
| 59 | 54 | * Inits manager on plugin load. |
| @@ -58,9 +53,9 @@ | ||
| 58 | 53 | /** |
| 59 | 54 | * Inits manager on plugin load. |
| 60 | 55 | */ |
| 61 | 56 | public function init(): void { |
| 62 | - $messages = $this->wpAdapter->getTransient( $this->getTransientName() ); | |
| 57 | + $messages = get_transient( $this->getTransientName() ); | |
| 63 | 58 | if ( $messages === false ) { |
| 64 | 59 | $messages = []; |
| 65 | 60 | } |
| 66 | 61 | |
| @@ -70,9 +65,9 @@ | ||
| 70 | 65 | /** |
| 71 | 66 | * Gets transient name. |
| 72 | 67 | */ |
| 73 | 68 | private function getTransientName(): string { |
| 74 | - return Transients::MESSAGE_MANAGER_MESSAGES_PREFIX . $this->wpAdapter->getSessionToken(); | |
| 69 | + return 'packetery_message_manager_messages_' . wp_get_session_token(); | |
| 75 | 70 | } |
| 76 | 71 | |
| 77 | 72 | /** |
| 78 | 73 | * Flashes messages to end user. |
| @@ -113,9 +108,9 @@ | ||
| 113 | 108 | */ |
| 114 | 109 | private function flashMessageArray( array $message ): void { |
| 115 | 110 | $this->messages[] = $message; |
| 116 | 111 | |
| 117 | - $this->wpAdapter->setTransient( $this->getTransientName(), $this->messages, self::EXPIRATION ); | |
| 112 | + set_transient( $this->getTransientName(), $this->messages, self::EXPIRATION ); | |
| 118 | 113 | } |
| 119 | 114 | |
| 120 | 115 | /** |
| 121 | 116 | * Renders messages. |
| @@ -156,9 +151,9 @@ | ||
| 156 | 151 | |
| 157 | 152 | unset( $this->messages[ $key ] ); |
| 158 | 153 | } |
| 159 | 154 | |
| 160 | - $this->wpAdapter->setTransient( $this->getTransientName(), $this->messages, self::EXPIRATION ); | |
| 155 | + set_transient( $this->getTransientName(), $this->messages, self::EXPIRATION ); | |
| 161 | 156 | |
| 162 | 157 | return $output; |
| 163 | 158 | } |
| 164 | 159 | } |