admin-actions.php ➔ gmb_process_actions()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 0
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 22 and the first side effect is on line 13.

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.

Loading history...
2
/**
3
 * Admin Actions
4
 *
5
 * @package     GMB
6
 * @subpackage  Admin/Actions
7
 * @copyright   Copyright (c) 2015, WordImpress
8
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
 * @since       2.0
10
 */
11
12
// Exit if accessed directly
13
if ( ! defined( 'ABSPATH' ) ) exit;
14
15
/**
16
 * Processes all GMB actions sent via POST and GET by looking for the 'gmb-action'
17
 * request and running do_action() to call the function
18
 *
19
 * @since 2.0
20
 * @return void
21
 */
22
function gmb_process_actions() {
23
	if ( isset( $_POST['gmb_action'] ) ) {
24
		do_action( 'gmb_' . $_POST['gmb_action'], $_POST );
25
	}
26
27
	if ( isset( $_GET['gmb_action'] ) ) {
28
		do_action( 'gmb_' . $_GET['gmb_action'], $_GET );
29
	}
30
}
31
add_action( 'admin_init', 'gmb_process_actions' );
32