PluginProbe
Clicky Analytics / trunk
Clicky Analytics vtrunk
trunk 1.1 1.1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5 1.5.1 1.5.2 1.6 1.6.1 All 40 releases
clicky-analytics / admin / widgets.php

widgets.php in Clicky Analytics trunk, at admin/widgets.php

57 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: http://www.gnu.org/licenses/gpl-2.0.html
8 */
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) )
12 exit();
13
14 if ( ! class_exists( 'CAWP_Backend_Widgets' ) ) {
15
16 class CAWP_Backend_Widgets {
17
18 private $cawp;
19
20 public function __construct() {
21 $this->cawp = CAWP();
22 if ( CAWP_Tools::check_roles( $this->cawp->config->options['access_back'] ) && ( 1 == $this->cawp->config->options['dashboard_widget'] ) ) {
23 add_action( 'wp_dashboard_setup', array( $this, 'add_widget' ) );
24 }
25 }
26
27 public function add_widget() {
28 wp_add_dashboard_widget( 'cawp-widget', __( "Clicky Analytics", 'clicky-analytics' ), array( $this, 'dashboard_widget' ), $control_callback = null );
29 }
30
31 public function dashboard_widget() {
32 $projectId = 0;
33
34 if ( empty( $this->cawp->config->options['sitekey'] ) ) {
35 echo '<p>' . __( "This plugin needs an authorization:", 'clicky-analytics' ) . '</p><form action="' . menu_page_url( 'cawp_setup', false ) . '" method="POST">' . get_submit_button( __( "Authorize Plugin", 'clicky-analytics' ), 'secondary' ) . '</form>';
36 return;
37 }
38
39 if ( $this->cawp->config->options['siteid'] ) {
40 $projectId = $this->cawp->config->options['siteid'];
41 } else {
42 echo '<p>' . __( "An admin should asign a default Clicky Analytics Site ID / Site Key.", 'clicky-analytics' ) . '</p><form action="' . menu_page_url( 'cawp_setup', false ) . '" method="POST">' . get_submit_button( __( "Add credentials", 'clicky-analytics' ), 'secondary' ) . '</form>';
43 return;
44 }
45
46 if ( ! ( $projectId ) ) {
47 echo '<p>' . __( "Something went wrong while retrieving property data. You need to create and properly configure a Clicky Analytics account:", 'clicky-analytics' ) . '</p> <form action="https://deconf.com/clicky-analytics-dashboard-wordpress/" method="POST">' . get_submit_button( __( "Find out more!", 'clicky-analytics' ), 'secondary' ) . '</form>';
48 return;
49 }
50
51 ?>
52 <div id="cawp-window-1"></div>
53 <?php
54 }
55 }
56 }
57