1 | <?php namespace EmailLog\Core; |
||
8 | class EmailLog { |
||
9 | |||
10 | /** |
||
11 | * Version number. |
||
12 | * |
||
13 | * @since Genesis |
||
14 | * @var const VERSION |
||
15 | */ |
||
16 | const VERSION = '1.9.1'; |
||
17 | |||
18 | /** |
||
19 | * Flag to track if the plugin is loaded. |
||
20 | * |
||
21 | * @since 2.0 |
||
22 | * @var bool |
||
23 | */ |
||
24 | private $loaded; |
||
25 | |||
26 | /** |
||
27 | * Filesystem directory path where translations are stored. |
||
28 | * |
||
29 | * @since 2.0 |
||
30 | * @var string $translations_path |
||
31 | */ |
||
32 | public $translations_path; |
||
33 | |||
34 | /** |
||
35 | * Admin screen object. |
||
36 | * |
||
37 | * @since Genesis |
||
38 | * @access private |
||
39 | * @var string $include_path |
||
40 | */ |
||
41 | private $admin_screen; |
||
42 | |||
43 | /** |
||
44 | * Filter name. |
||
45 | * |
||
46 | * @since Genesis |
||
47 | * @var const FILTER_NAME |
||
48 | */ |
||
49 | const FILTER_NAME = 'wp_mail_log'; |
||
50 | |||
51 | /** |
||
52 | * Page slug to be used in admin dashboard hyperlinks. |
||
53 | * |
||
54 | * @since Genesis |
||
55 | * @var const PAGE_SLUG |
||
56 | */ |
||
57 | const PAGE_SLUG = 'email-log'; |
||
58 | |||
59 | /** |
||
60 | * String value to generate nonce. |
||
61 | * |
||
62 | * @since Genesis |
||
63 | * @var const DELETE_LOG_NONCE_FIELD |
||
64 | */ |
||
65 | const DELETE_LOG_NONCE_FIELD = 'sm-delete-email-log-nonce'; |
||
66 | |||
67 | /** |
||
68 | * String value to generate nonce. |
||
69 | * |
||
70 | * @since Genesis |
||
71 | * @var const DELETE_LOG_ACTION |
||
72 | */ |
||
73 | const DELETE_LOG_ACTION = 'sm-delete-email-log'; |
||
74 | |||
75 | // DB stuff |
||
76 | const TABLE_NAME = 'email_log'; /* Database table name */ |
||
77 | const DB_OPTION_NAME = 'email-log-db'; /* Database option name */ |
||
78 | const DB_VERSION = '0.1'; /* Database version */ |
||
79 | |||
80 | // JS Stuff |
||
81 | const JS_HANDLE = 'email-log'; |
||
82 | |||
83 | //hooks |
||
84 | const HOOK_LOG_COLUMNS = 'email_log_manage_log_columns'; |
||
85 | const HOOK_LOG_DISPLAY_COLUMNS = 'email_log_display_log_columns'; |
||
86 | |||
87 | /** |
||
88 | * Initialize the plugin. |
||
89 | */ |
||
90 | public function __construct( $file ) { |
||
93 | |||
94 | /** |
||
95 | * Load the plugin. |
||
96 | */ |
||
97 | public function load() { |
||
122 | |||
123 | /** |
||
124 | * Adds additional links in the plugin listing page. |
||
125 | * TODO: Move to UI namespace |
||
126 | * |
||
127 | * @since Genesis |
||
128 | * |
||
129 | * @see Additional links in the Plugin listing is based on |
||
130 | * @link http://zourbuth.com/archives/751/creating-additional-wordpress-plugin-links-row-meta/ |
||
131 | * |
||
132 | * @param array $links Array with default links to display in plugins page. |
||
133 | * @param string $file The name of the plugin file. |
||
134 | * @return array Array with links to display in plugins page. |
||
135 | */ |
||
136 | public function add_plugin_links( $links, $file ) { |
||
147 | |||
148 | /** |
||
149 | * Registers the settings page. |
||
150 | * TODO: Move to UI namespace |
||
151 | * |
||
152 | * @since Genesis |
||
153 | */ |
||
154 | public function register_settings_page() { |
||
160 | |||
161 | /** |
||
162 | * Displays the stored email log. |
||
163 | * TODO: Move to UI namespace |
||
164 | * |
||
165 | * @since Genesis |
||
166 | */ |
||
167 | public function display_logs() { |
||
212 | |||
213 | /** |
||
214 | * Adds settings panel for the plugin. |
||
215 | * TODO: Move to UI namespace |
||
216 | * |
||
217 | * @since Genesis |
||
218 | */ |
||
219 | public function create_settings_panel() { |
||
260 | |||
261 | /** |
||
262 | * AJAX callback for displaying email content. |
||
263 | * TODO: Move to UI namespace |
||
264 | * |
||
265 | * @since 1.6 |
||
266 | */ |
||
267 | public function display_content_callback() { |
||
282 | |||
283 | /** |
||
284 | * Saves Screen options. |
||
285 | * TODO: Move to UI namespace |
||
286 | * |
||
287 | * @since Genesis |
||
288 | * |
||
289 | * @param bool|int $status Screen option value. Default false to skip. |
||
290 | * @param string $option The option name. |
||
291 | * @param int $value The number of rows to use. |
||
292 | * @return bool|int |
||
293 | */ |
||
294 | function save_screen_options( $status, $option, $value ) { |
||
301 | |||
302 | /** |
||
303 | * Gets the per page option. |
||
304 | * TODO: Move to UI namespace |
||
305 | * |
||
306 | * @since Genesis |
||
307 | * |
||
308 | * @return int Number of logs a user wanted to be displayed in a page. |
||
309 | */ |
||
310 | public static function get_per_page() { |
||
322 | |||
323 | /** |
||
324 | * Adds additional links. |
||
325 | * TODO: Move to UI namespace |
||
326 | * |
||
327 | * @since Genesis |
||
328 | * |
||
329 | * @param array $links |
||
330 | * @return array |
||
331 | */ |
||
332 | public function add_action_links( $links ) { |
||
338 | |||
339 | /** |
||
340 | * Adds Footer links. |
||
341 | * TODO: Move to UI namespace |
||
342 | * |
||
343 | * @since Genesis |
||
344 | * |
||
345 | * @see Function relied on |
||
346 | * @link http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/ |
||
347 | */ |
||
348 | public function add_footer_links() { |
||
352 | |||
353 | /** |
||
354 | * Logs email to database. |
||
355 | * |
||
356 | * @since Genesis |
||
357 | * |
||
358 | * @global object $wpdb |
||
359 | * |
||
360 | * @param array $mail_info Information about email. |
||
361 | * @return array Information about email. |
||
362 | */ |
||
363 | public function log_email( $mail_info ) { |
||
396 | } |
||
397 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: