PluginProbe
Analytics Insights – Google Analytics Dashboard for WordPress / trunk
Analytics Insights – Google Analytics Dashboard for WordPress vtrunk
6.3.6 6.3.7 6.3.8 6.3.9 trunk 5.4.1 5.4.2 5.4.2.1 5.4.3 5.4.4 5.4.5 5.4.6 5.4.7 5.5.2 5.5.3 5.5.4 5.5.5 5.5.6 5.6 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 All 61 releases
analytics-insights / admin / widgets.php

widgets.php in Analytics Insights – Google Analytics Dashboard for WordPress trunk, at admin/widgets.php

51 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Author: Alin Marcu
4 * Author URI: https://deconf.com
5 * Copyright 2013 Alin Marcu
6 * License: GPLv2 or later
7 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
8 */
9 // Exit if accessed directly
10 if ( ! defined( 'ABSPATH' ) )
11 exit();
12 if ( ! class_exists( 'AIWP_Backend_Widgets' ) ) {
13
14 class AIWP_Backend_Widgets {
15
16 private $aiwp;
17
18 public function __construct() {
19 $this->aiwp = AIWP();
20 if ( AIWP_Tools::check_roles( $this->aiwp->config->options['access_back'] ) && ( 1 == $this->aiwp->config->options['dashboard_widget'] ) ) {
21 add_action( 'wp_dashboard_setup', array( $this, 'add_widget' ) );
22 }
23 }
24
25 public function add_widget() {
26 wp_add_dashboard_widget( 'aiwp-widget', __( "Analytics Insights", 'analytics-insights' ), array( $this, 'dashboard_widget' ), $control_callback = null );
27 }
28
29 public function dashboard_widget() {
30 $projectId = 0;
31 if ( empty( $this->aiwp->config->options['token'] ) ) {
32 echo '<p>' . __( "This plugin needs an authorization:", 'analytics-insights' ) . '</p><form action="' . menu_page_url( 'aiwp_settings', false ) . '" method="POST">' . get_submit_button( __( "Authorize Plugin", 'analytics-insights' ), 'secondary' ) . '</form>';
33 return;
34 }
35 if ( $this->aiwp->config->options['webstream_jail'] ) {
36 $projectId = $this->aiwp->config->options['webstream_jail'];
37 } else {
38 echo '<p>' . __( "An admin should asign a default Google Analytics property.", 'analytics-insights' ) . '</p><form action="' . menu_page_url( 'aiwp_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'analytics-insights' ), 'secondary' ) . '</form>';
39 return;
40 }
41 if ( ! ( $projectId ) ) {
42 echo '<p>' . __( "Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'analytics-insights' ) . '</p> <form action="https://deconf.com/how-to-add-google-analytics-to-wordpress-easy-way/" method="POST">' . get_submit_button( __( "Find out more!", 'analytics-insights' ), 'secondary' ) . '</form>';
43 return;
44 }
45 ?>
46 <div id="aiwp-window-1"></div>
47 <?php
48 }
49 }
50 }
51