PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / trunk
ShareThis Dashboard for Google Analytics vtrunk
3.3.2 trunk 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.5 2.3.5 2.3.6 2.3.7 2.3.8 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.3.1
googleanalytics / class / core / class-ga-controller-core.php
googleanalytics / class / core Last commit date
class-ga-controller-core.php 1 year ago class-ga-view-core.php 4 years ago
class-ga-controller-core.php
52 lines
1 <?php
2 /**
3 * GoogleAnalytics Controller Core.
4 *
5 * @package GoogleAnalytics
6 */
7
8 /**
9 * Core Controller.
10 */
11 class Ga_Controller_Core {
12
13 const GA_NONCE_FIELD_NAME = '_gawpnonce';
14 const ACTION_PARAM_NAME = 'ga_action';
15
16 /**
17 * Runs particular action.
18 */
19 public function handle_actions() {
20 if ( false === current_user_can( 'manage_options' ) ) {
21 return;
22 }
23
24 // Nonce verification happens in verify_nonce function.
25 $action = false === empty( $_REQUEST[ self::ACTION_PARAM_NAME ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ self::ACTION_PARAM_NAME ] ) ) : null; // phpcs:ignore
26
27 if ( $action ) {
28 $class = get_class( $this );
29 if ( is_callable(
30 array(
31 $class,
32 $action,
33 )
34 ) ) {
35 call_user_func( $class . '::' . $action );
36 }
37 }
38 }
39
40 /**
41 * Verifies nonce for given action.
42 *
43 * @param string $action Action.
44 * @return bool
45 */
46 public static function verify_nonce( $action ) {
47 $nonce = filter_input( INPUT_POST, self::GA_NONCE_FIELD_NAME, FILTER_SANITIZE_STRING );
48
49 return false !== wp_verify_nonce( $nonce, $action );
50 }
51 }
52