PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.3
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / admin / import / class-import-status.php

class-import-status.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at admin/import/class-import-status.php

132 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin\Import
6 */
7
8 /**
9 * Class WPSEO_ImportStatus.
10 *
11 * Holds the status of and message about imports.
12 */
13 class WPSEO_Import_Status {
14
15 /**
16 * The import status.
17 *
18 * @var bool
19 */
20 public $status = false;
21
22 /**
23 * The import message.
24 *
25 * @var string
26 */
27 private $msg = '';
28
29 /**
30 * The type of action performed.
31 *
32 * @var string
33 */
34 private $action;
35
36 /**
37 * WPSEO_Import_Status constructor.
38 *
39 * @param string $action The type of import action.
40 * @param bool $status The status of the import.
41 * @param string $msg Extra messages about the status.
42 */
43 public function __construct( $action, $status, $msg = '' ) {
44 $this->action = $action;
45 $this->status = $status;
46 $this->msg = $msg;
47 }
48
49 /**
50 * Get the import message.
51 *
52 * @return string Message about current status.
53 */
54 public function get_msg() {
55 if ( $this->msg !== '' ) {
56 return $this->msg;
57 }
58
59 if ( $this->status === false ) {
60 /* translators: %s is replaced with the name of the plugin we're trying to find data from. */
61 return __( '%s data not found.', 'wordpress-seo' );
62 }
63
64 return $this->get_default_success_message();
65 }
66
67 /**
68 * Get the import action.
69 *
70 * @return string Import action type.
71 */
72 public function get_action() {
73 return $this->action;
74 }
75
76 /**
77 * Set the import action, set status to false.
78 *
79 * @param string $action The type of action to set as import action.
80 *
81 * @return void
82 */
83 public function set_action( $action ) {
84 $this->action = $action;
85 $this->status = false;
86 }
87
88 /**
89 * Sets the importer status message.
90 *
91 * @param string $msg The message to set.
92 *
93 * @return void
94 */
95 public function set_msg( $msg ) {
96 $this->msg = $msg;
97 }
98
99 /**
100 * Sets the importer status.
101 *
102 * @param bool $status The status to set.
103 *
104 * @return WPSEO_Import_Status The current object.
105 */
106 public function set_status( $status ) {
107 $this->status = (bool) $status;
108
109 return $this;
110 }
111
112 /**
113 * Returns a success message depending on the action.
114 *
115 * @return string Returns a success message for the current action.
116 */
117 private function get_default_success_message() {
118 switch ( $this->action ) {
119 case 'import':
120 /* translators: %s is replaced with the name of the plugin we're importing data from. */
121 return __( '%s data successfully imported.', 'wordpress-seo' );
122 case 'cleanup':
123 /* translators: %s is replaced with the name of the plugin we're removing data from. */
124 return __( '%s data successfully removed.', 'wordpress-seo' );
125 case 'detect':
126 default:
127 /* translators: %s is replaced with the name of the plugin we've found data from. */
128 return __( '%s data found.', 'wordpress-seo' );
129 }
130 }
131 }
132