These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * WordPress Taxonomy |
||
4 | * |
||
5 | * A set of utility functions for taxonomies in WordPress. |
||
6 | * This is a component within the Amarkal framework. |
||
7 | * |
||
8 | * @package amarkal-taxonomy |
||
9 | * @depends amarkal-ui |
||
10 | * @author Askupa Software <[email protected]> |
||
11 | * @link https://github.com/askupasoftware/amarkal-taxonomy |
||
12 | * @copyright 2017 Askupa Software |
||
13 | */ |
||
14 | defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
||
15 | |||
16 | /** |
||
17 | * Prevent loading the library more than once |
||
18 | */ |
||
19 | if( defined( 'AMARKAL_TAXONOMY' ) ) return; |
||
20 | define( 'AMARKAL_TAXONOMY', true ); |
||
21 | |||
22 | /** |
||
23 | * Load required classes if not using composer |
||
24 | */ |
||
25 | if( !class_exists('Composer\\Autoload\\ClassLoader') ) |
||
26 | { |
||
27 | require_once 'Form.php'; |
||
28 | require_once 'AddField.php'; |
||
29 | require_once 'EditField.php'; |
||
30 | } |
||
31 | |||
32 | if(!function_exists('amarkal_taxonomy_add_field')) |
||
33 | { |
||
34 | /** |
||
35 | * Add a field to the add & edit forms of a given taxonomy. |
||
36 | * |
||
37 | * @param string $taxonomy_name The taxonomy name, e.g. 'category' |
||
38 | * @param string $field_name The name of the field to add. One of the core |
||
39 | * amarkal-ui components or a registered custom component. |
||
40 | * @param array $field_props The field's properties |
||
41 | */ |
||
42 | function amarkal_taxonomy_add_field( $taxonomy_name, $field_name, $field_props ) |
||
43 | { |
||
44 | $form = Amarkal\Taxonomy\Form::get_instance(); |
||
45 | $form->add_field( $taxonomy_name, $field_name, $field_props ); |
||
46 | } |
||
47 | } |
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.