PluginProbe
ShareThis Dashboard for Google Analytics / 3.4.1
ShareThis Dashboard for Google Analytics v3.4.1
3.4.1 3.4.0 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 All 45 releases
googleanalytics / class / core / class-ga-controller-core.php

class-ga-controller-core.php in ShareThis Dashboard for Google Analytics 3.4.1, at class/core/class-ga-controller-core.php

52 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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