[ Index ]

PHP Cross Reference of PageLines Framework

title

Body

[close]

/admin/ -> class.account.php (source)

   1  <?php
   2  /**
   3   *
   4   *
   5   *  Account Handling In Admin
   6   *
   7   *
   8   *
   9   */
  10  
  11  
  12  class PageLinesAccount {
  13  
  14  	function __construct(){
  15  
  16          add_action( 'admin_init', array(&$this, 'update_lpinfo' ) );
  17          add_filter( 'pagelines_account_array', array( &$this, 'get_intro' ) );
  18      }
  19  
  20      /**
  21       * Save our credentials
  22       *
  23       */
  24  	function update_lpinfo() {
  25  
  26          if ( isset( $_POST['form_submitted'] ) && $_POST['form_submitted'] === 'plinfo' ) {
  27  
  28              if ( isset( $_POST['creds_reset'] ) )
  29                  update_option( 'pagelines_extend_creds', array( 'user' => '', 'pass' => '' ) );
  30              else
  31                  set_pagelines_credentials( $_POST['lp_username'], $_POST['lp_password'] );
  32  
  33              PagelinesExtensions::flush_caches();
  34  
  35              wp_redirect( PLAdminPaths::account( '&plinfo=true' ) );
  36  
  37              exit;
  38          }
  39      }
  40  
  41      /**
  42       *
  43       *  Returns Extension Array Config
  44       *
  45       */
  46  	function pagelines_account_array(){
  47  
  48          $dms_tools = new EditorAdmin;
  49  
  50          $d = array();
  51  
  52          $d['dashboard']    = $this->pl_add_dashboard();
  53                  
  54              // 
  55              // if(!pl_deprecate_v2())
  56              //     $d['Your_Account']    = array(
  57              //         'icon'            => PL_ADMIN_ICONS.'/user.png',
  58              //         'credentials'     => array(
  59              //             'type'        => 'updates_setup',
  60              //             'title'        => __( 'Configure PageLines Account &amp; Auto Updates', 'pagelines' ),
  61              //             'shortexp'    => __( 'Get your latest updates automatically, direct from PageLines.', 'pagelines' ),
  62              //             'layout'    => 'full',
  63              //         )
  64              //     );
  65              
  66          $d['DMS_tools']    = $dms_tools->admin_interface();
  67  
  68  
  69              
  70              
  71  
  72          if(!pl_deprecate_v2()){
  73                  
  74                  // $d['_plus_extensions'] = $this->pl_add_extensions_dash();
  75                  // 
  76                  // $d['_live_chat'] = $this->pl_add_live_chat_dash();
  77                  $d['_resources'] = $this->pl_add_support_dash();
  78                  
  79                  $d['_getting_started'] = $this->pl_add_welcome();
  80  
  81                  // $d['Import-Export']    = array(
  82                  //     'icon'            => PL_ADMIN_ICONS.'/extend-inout.png',
  83                  //     'import_set'    => array(
  84                  //         'default'    => '',
  85                  //         'type'        => 'import_export',
  86                  //         'layout'    => 'full',
  87                  //         'title'        => __( 'Import/Export PageLines Settings', 'pagelines' ),
  88                  //         'shortexp'    => __( 'Use this form to upload PageLines settings from another install.', 'pagelines' ),
  89                  //     )
  90                  // );
  91  
  92              }
  93  
  94  
  95          return apply_filters( 'pagelines_account_array', $d );
  96      }
  97  
  98      /**
  99       * Get Intro
 100       *
 101       * Includes the 'welcome.php' file from Child-Theme's root folder if it exists.
 102       *
 103       * @uses    default_headers
 104       *
 105       * @return  string
 106       */
 107  	function get_intro( $o ) {
 108  
 109          if ( is_file( get_stylesheet_directory() . '/welcome.php' ) ) {
 110  
 111              ob_start();
 112                  include( get_stylesheet_directory() . '/welcome.php' );
 113              $welcome =  ob_get_clean();
 114  
 115              $a = array();
 116  
 117              if ( is_file( get_stylesheet_directory() . '/welcome.png' ) )
 118                  $icon = get_stylesheet_directory_uri() . '/welcome.png';
 119              else
 120                  $icon =  PL_ADMIN_ICONS . '/welcome.png';
 121              $a['welcome'] = array(
 122                  'icon'            => $icon,
 123                  'hide_pagelines_introduction'    => array(
 124                      'type'            => 'text_content',
 125                      'flag'            => 'hide_option',
 126                      'exp'            => $welcome
 127                  )
 128              );
 129          $o = array_merge( $a, $o );
 130          }
 131      return $o;
 132      }
 133  
 134  	function pl_add_live_chat_dash(){
 135          $ext = new PageLinesSupportPanel();
 136  
 137          $a = array(
 138              'icon'            => PL_ADMIN_ICONS.'/balloon.png',
 139              'pagelines_dashboard'    => array(
 140                  'type'            => 'text_content',
 141                  'flag'            => 'hide_option',
 142                  'exp'            => $this->get_live_bill()
 143              ),
 144          );
 145  
 146          return $a;
 147      }
 148  
 149  	function get_live_bill(){
 150  
 151          $url = pagelines_check_credentials( 'vchat' );
 152  
 153          $iframe = ( $url ) ? sprintf( '<iframe class="live_chat_iframe" src="%s"></iframe>', $url ) : false;
 154          $rand =
 155          ob_start();
 156          ?>
 157  
 158          <div class="admin_billboard">
 159              <div class="admin_billboard_pad fix">
 160                      <h3 class="admin_header_main">
 161                       <?php _e( 'PageLines Live Chat (Beta)', 'pagelines'); ?>
 162                      </h3>
 163                      <div class='admin_billboard_text'>
 164                       <?php _e( 'A moderated live community chat room for discussing technical issues. (Plus Only)', 'pagelines' ); ?>
 165                      </div>
 166                      <?php if ( pagelines_check_credentials( 'plus' ) ) printf( '<div class="plus_chat_header">%s</div>', $this->pagelines_livechat_rules() ); ?>
 167              </div>
 168          </div>
 169          <div class="live_chat_wrap fix">
 170  
 171              <?php
 172  
 173              if($iframe):
 174                  echo $iframe;
 175              else:?>
 176  
 177                  <div class="live_chat_up_bill">
 178                      <h3><?php _e( 'Live Chat Requires an active PageLines Plus account', 'pagelines' ); ?></h3>
 179                      <?php
 180                      if ( !pagelines_check_credentials() )
 181                          printf( '<a class="button" href="%s">Login</a>', admin_url(PL_ACCOUNT_URL) );
 182  
 183                      else
 184                          if ( !VPLUS )
 185                              printf( '<a class="button" href="%s">%s</a>', pl_get_plus_link(), __( 'Upgrade to PageLines Plus', 'pagelines' ) );?>
 186                  </div>
 187              <?php endif;    ?>
 188          </div>
 189          <?php
 190  
 191          $bill = ob_get_clean();
 192  
 193          return apply_filters('pagelines_welcome_billboard', $bill);
 194      }
 195  
 196  	function pagelines_livechat_rules() {
 197  
 198          $url = 'api.pagelines.com/plus_latest';
 199          if( $welcome = get_transient( 'pagelines_pluschat' ) )
 200              return json_decode( $welcome );
 201  
 202          $response = pagelines_try_api( $url, false );
 203  
 204          if ( $response !== false ) {
 205              if( ! is_array( $response ) || ( is_array( $response ) && $response['response']['code'] != 200 ) ) {
 206                  $out = '';
 207              } else {
 208  
 209              $welcome = wp_remote_retrieve_body( $response );
 210              set_transient( 'pagelines_pluschat', $welcome, 86400 );
 211              $out = json_decode( $welcome );
 212              }
 213          }
 214      return $out;
 215      }
 216  
 217  	function pl_add_support_dash(){
 218  
 219          $ext = new PageLinesSupportPanel();
 220  
 221          $a = array(
 222              'icon'            => PL_ADMIN_ICONS.'/toolbox.png',
 223              'pagelines_dashboard'    => array(
 224                  'type'            => 'text_content',
 225                  'flag'            => 'hide_option',
 226                  'exp'            => $ext->draw()
 227              ),
 228          );
 229  
 230          return $a;
 231  
 232      }
 233  
 234  
 235  	function pl_add_extensions_dash(){
 236  
 237          $ext = new PageLinesCoreExtensions();
 238  
 239          $a = array(
 240              'icon'            => PL_ADMIN_ICONS.'/plusbtn.png',
 241              'pagelines_dashboard'    => array(
 242                  'type'            => 'text_content',
 243                  'flag'            => 'hide_option',
 244                  'exp'            => $ext->draw()
 245              ),
 246          );
 247  
 248          return $a;
 249      }
 250  
 251      /**
 252       * Welcome Message
 253       *
 254       * @since 2.0.0
 255       */
 256  	function pl_add_dashboard(){
 257  
 258          $dash = new PageLinesDashboard();
 259  
 260          $a = array(
 261              'icon'            => PL_ADMIN_ICONS.'/newspapers.png',
 262              'pagelines_dashboard'    => array(
 263                  'type'            => 'text_content',
 264                  'flag'            => 'hide_option',
 265                  'exp'            => $dash->draw()
 266              ),
 267          );
 268  
 269          return $a;
 270      }
 271  
 272      /**
 273       * Welcome Message
 274       *
 275       * @since 2.0.0
 276       */
 277  	function pl_add_welcome(){
 278  
 279          $welcome = new PageLinesWelcome();
 280  
 281          $a = array(
 282              'icon'            => PL_ADMIN_ICONS.'/book.png',
 283              'hide_pagelines_introduction'    => array(
 284                  'type'            => 'text_content',
 285                  'flag'            => 'hide_option',
 286                  'exp'            => $welcome->get_welcome()
 287              ),
 288          );
 289  
 290          return apply_filters('pagelines_options_welcome', $a);
 291      }
 292  }


Generated: Fri Aug 30 18:26:24 2013 Cross-referenced by PHPXref 0.7.1