These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
1 ignored issue
–
show
|
|||
2 | /* |
||
3 | Plugin Name: Tabify Edit Screen |
||
4 | Description: Enables tabs in the edit screen and manage them from the back-end |
||
5 | Version: 0.9.6 |
||
6 | |||
7 | Plugin URI: https://codekitchen.eu/products/tabify-edit-screen/ |
||
8 | |||
9 | Author: Marko Heijnen |
||
10 | Author URI: https://codekitchen.eu |
||
11 | Donate link: https://codekitchen.eu/donate |
||
12 | |||
13 | Text Domain: tabify-edit-screen |
||
14 | Domain Path: /languages |
||
15 | */ |
||
16 | |||
17 | /* Copyright 2013-2016 Tabify Edit Screen (email : [email protected]) |
||
18 | |||
19 | This program is free software; you can redistribute it and/or modify |
||
20 | it under the terms of the GNU General Public License, version 2, as |
||
21 | published by the Free Software Foundation. |
||
22 | |||
23 | This program is distributed in the hope that it will be useful, |
||
24 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
26 | GNU General Public License for more details. |
||
27 | |||
28 | You should have received a copy of the GNU General Public License |
||
29 | along with this program; if not, write to the Free Software |
||
30 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||
31 | */ |
||
32 | |||
33 | class Tabify_Edit_Screen { |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
34 | |||
35 | public $version = '0.9.6'; |
||
36 | |||
37 | private $loaded_features = array(); |
||
38 | |||
39 | public function __construct() { |
||
40 | if ( is_admin() ) { |
||
41 | add_action( 'plugins_loaded', array( $this, 'load' ) ); |
||
42 | add_action( 'plugins_loaded', array( $this, 'load_translation' ) ); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | |||
47 | public function load() { |
||
48 | include 'inc/edit-screen.php'; |
||
49 | include 'inc/settings-page.php'; |
||
50 | |||
51 | new Tabify_Edit_Screen_Edit_Screen(); |
||
52 | new Tabify_Edit_Screen_Settings_Page(); |
||
53 | |||
54 | add_action( 'admin_init', array( $this, 'load_features' ), 1 ); |
||
55 | } |
||
56 | |||
57 | public function load_translation() { |
||
58 | load_plugin_textdomain( 'tabify-edit-screen', false, basename( dirname( __FILE__ ) ) . '/languages' ); |
||
59 | } |
||
60 | |||
61 | public function load_features( $screen ) { |
||
62 | $features = array( |
||
63 | 'detection', |
||
64 | 'permissions' |
||
65 | ); |
||
66 | |||
67 | if ( apply_filters( 'tabify_plugin_support', false ) ) { |
||
68 | $features[] = 'plugin-support'; |
||
69 | } |
||
70 | |||
71 | foreach ( $features as $feature ) { |
||
72 | $this->loaded_features[] = $feature; |
||
73 | |||
74 | $class_name = 'Tabify_Edit_Screen_Feature_' . str_replace( '-', '_', $feature ); |
||
75 | |||
76 | include 'features/' . $feature . '/' . $feature . '.php'; |
||
77 | new $class_name; |
||
78 | } |
||
79 | } |
||
80 | |||
81 | } |
||
82 | |||
83 | $GLOBALS['tabify_edit_screen'] = new Tabify_Edit_Screen(); |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.