[ Index ]

MailPress 7.0.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/dashboard/widgets/ -> users_map.php (source)

   1  <?php
   2  class MP_Dashboard_users_map extends MP_WP_Dashboard_widget_
   3  {
   4      const option_name = 'MailPress_dashboard_mp_map';
   5  
   6      var $id = 'mp_users_map';
   7  
   8  	function widget()
   9      {
  10          global $wpdb, $wp_locale;
  11  
  12          if ( !$options = get_option( self::option_name ) )
  13          {
  14              $options['code'] = 'world';
  15              $options['title'] = __( 'Subscribers - World', 'MailPress' );
  16          }
  17  
  18          $chd = $chld = array();
  19  
  20          $where = 'status="active"';
  21          $where .= ( 'usa' == $options['code'] ) ? " AND created_country = 'US' AND created_US_state <> 'ZZ'" : " AND created_country <> 'ZZ'";
  22  
  23          $countalls = $wpdb->get_var( "SELECT count( * ) FROM $wpdb->mp_users WHERE $where ;" );
  24          $users = $wpdb->get_results( "SELECT created_US_state as toto, count( * ) as count FROM $wpdb->mp_users WHERE $where GROUP BY created_US_state;" );
  25  
  26          foreach( $users as $user )
  27          {
  28              $chld[] = ( 'UK' == $user->toto ) ? 'GB' : $user->toto;
  29              $chd[]  = round( 100 * $user->count/$countalls );
  30          }
  31  
  32          $args = array();
  33          $args['cht']  = 't';
  34          $args['chs']  = $this->widget_size( '440x200' );
  35          $args['chtm'] = $options['code'];
  36          $args['chf']  = 'bg,s,EAF7FE';
  37          if ( !empty( $chld ) ) $args['chld'] = join( '', $chld );
  38          $args['chco'] = 'ffffff,B5F8C2,294D30';
  39          $args['chd']  = ( empty( $chd ) ) ? 's:_' : 't:' . join( ',', $chd );
  40          $url = esc_url( add_query_arg( $args, $this->url ) );
  41  
  42          echo '<div style="text-align:center;"><img style="width:100%;" src="' . $url . '" alt="' . esc_attr( $options['title'] ) . '" /></div>' . "\r\n";
  43      }
  44  
  45  	function control()
  46      {
  47          $c= array (     'africa'         => __( 'Africa', 'MailPress' ),
  48                  'asia'        => __( 'Asia', 'MailPress' ),
  49                  'europe'        => __( 'Europe', 'MailPress' ),
  50                  'middle_east'    => __( 'Middle East', 'MailPress' ),
  51                  'south_america'    => __( 'South America', 'MailPress' ),
  52                  'usa'            => __( 'USA', 'MailPress' ),
  53                  'world'        => __( 'World', 'MailPress' ) );
  54  
  55          if ( !$options = get_option( self::option_name ) )
  56          {
  57              $options['code'] = 'world';
  58              $options['title'] = $c[$options['code']];
  59          }
  60          if ( $post_ = filter_input_array( INPUT_POST ) && isset( $post_['code'] ) ) 
  61          {    
  62              update_option( self::option_name, array( 'code' => $post_['code'] , 'title' => $c[$post_['code']] ) );
  63              return;
  64          }
  65  
  66          echo '<select name="code" id="code">' . MP_::select_option( $c, $options['code'], false ) . '</select>' . "\r\n";
  67      }
  68  }
  69  new MP_Dashboard_users_map( __( 'MailPress - Subscribers Map', 'MailPress' ) );


Generated: Mon Jan 28 00:07:10 2019 Cross-referenced by PHPXref 0.7.1