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