[ Index ]

PHP Cross Reference of PageLines Framework

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Plugin/theme installer class and section control.
   4   *
   5   * TODO add enable all to sections.
   6   * TODO Make some use of the tags system
   7   *
   8   * Install PageLines plugins and looks after them.
   9   *
  10   * @author PageLines
  11   * @package PageLines DMS
  12   * @since 2.0
  13   */
  14  
  15   class PagelinesExtensions {
  16  
  17   	function __construct() {
  18  
  19          $this->username = get_pagelines_credentials( 'user' );
  20          $this->password = get_pagelines_credentials( 'pass' );
  21  
  22          $this->ui = new PageLinesExtendUI;
  23          $this->fileactions = new PageLinesExtendActions;
  24          add_action( 'admin_init', array(&$this, 'launchpad_returns' ) );
  25  
  26       }
  27  
  28      /*
  29       *
  30       * Cache cleaner.
  31       * Flush all our transients ( Makes this save button a sort of reset button. )
  32       *
  33       */
  34  	 function flush_caches() {
  35  
  36          delete_transient( EXTEND_UPDATE );
  37          delete_transient( 'pagelines_extend_themes' );
  38          delete_transient( 'pagelines_extend_sections' );
  39          delete_transient( 'pagelines_extend_plugins' );
  40          delete_transient( 'pagelines_extend_integrations' );
  41          delete_transient( 'pagelines_sections_cache' );
  42          remove_theme_mod( 'available_updates' );
  43          remove_theme_mod( 'pending_updates' );
  44      }
  45  
  46  
  47      /**
  48      *
  49      * @TODO document
  50      *
  51      */
  52  	function extension_engine( $type, $set = ''){
  53  
  54              switch ( $type ){
  55  
  56                  case 'section_added' :
  57                      $out = ExtensionSections::extension_sections( $set, 'installed' );
  58                      break;
  59                  case 'section_extend' :
  60                      $out = ExtensionSections::extension_sections( $set, 'install' );
  61                      break;
  62                  case 'theme' :
  63                      $out = ExtensionThemes::extension_themes( $set );
  64                      break;
  65                  case 'plugin' :
  66                      $out = ExtensionPlugins::extension_plugins( $set );
  67                      break;
  68                  case 'integration' :
  69                      $out = ExtensionIntegrations::extension_integrations( $set );
  70                      break;
  71              }
  72              return $out;
  73      }
  74  
  75  
  76       /**
  77       *
  78       * @TODO document
  79       *
  80       */
  81  	 function master_array( $type, $key, $ext, $tab ){
  82  
  83          $a = array(
  84              'plversion'        =>    PL_CORE_VERSION,
  85              'price'        =>    'free',
  86              'featured'    =>    'false',
  87              'type'        =>    'internal',
  88              'depends'    =>    false
  89              );
  90  
  91          $ext = wp_parse_args( $ext, $a );
  92  
  93          $actions = array(
  94              'install'    => array(
  95                  'mode'        => 'install',
  96                  'text'        => __( 'Install', 'pagelines' ),
  97                  'dtext'        => __( 'Installing', 'pagelines' ),
  98                  'case'        => $type.'_install',
  99                  'type'        => $type,
 100                  'file'        => $this->get_the_file( 'install', $type, $key, $ext, $tab ),
 101                  'condition'    => $this->show_install_button( $type, $key, $ext, $tab ),
 102                  'path'        => $this->get_the_path( 'install', $type, $key, $ext, $tab ),
 103              ),
 104              'redirect'    => array(
 105                  'mode'        => 'redirect',
 106                  'case'        => 'redirect',
 107                  'text'        => __( 'Install &darr;', 'pagelines' ),
 108                  'type'        => $type,
 109                  'condition'    => $this->do_redirect( $type, $key, $ext, $tab ),
 110                  'file'        => $this->get_the_file( 'redirect', $type, $key, $ext, $tab ),
 111                  'path'        => $this->get_the_path( 'redirect', $type, $key, $ext, $tab ),
 112              ),
 113              'login'    => array(
 114                  'mode'        => 'login',
 115                  'case'        => 'login',
 116                  'condition'    => $this->show_login_button( $type, $key, $ext, $tab ),
 117                  'type'        => $type,
 118                  'file'        => $this->get_the_file( 'login', $type, $key, $ext, $tab ),
 119                  'text'        => __( 'Login to install or purchase &rarr;', 'pagelines' ),
 120                  'dtext'        => __( 'Redirecting', 'pagelines' ),
 121              ),
 122              'purchase'    => array(
 123                  'mode'        => 'purchase',
 124                  'case'        => 'purchase',
 125                  'text'        => $this->purchase_text( $type, $key, $ext, $tab ),
 126                  'dtext'        => __( 'Redirecting', 'pagelines' ),
 127                  'type'        => $type,
 128                  'condition'    => $this->show_purchase_button( $type, $key, $ext, $tab ),
 129                  'file'        => $this->paypal_link( $type, $key, $ext, $tab ),
 130              ),
 131              'plus'    => array(
 132                  'mode'        => 'install',
 133                  'case'        => $type.'_install',
 134                  'text'        => $this->plus_text( $type, $key, $ext, $tab ),
 135                  'dtext'        => __( 'Installing', 'pagelines' ),
 136                  'type'        => $type,
 137                  'file'        => $this->get_the_file( 'install', $type, $key, $ext, $tab ),
 138                  'condition'    => $this->show_plus_button( $type, $key, $ext, $tab ),
 139                  'path'        => $this->get_the_path( 'install', $type, $key, $ext, $tab ),
 140              ),
 141              'activate'    => array(
 142                  'mode'        => 'activate',
 143                  'condition'    => $this->show_activate_button( $type, $key, $ext, $tab ),
 144                  'case'        => $type.'_activate',
 145                  'type'        => $type,
 146                  'path'        => $this->get_the_path( 'activate', $type, $key, $ext, $tab ),
 147                  'file'        => $this->get_the_file( 'activate', $type, $key, $ext, $tab ),
 148                  'text'        => __( 'Activate', 'pagelines' ),
 149                  'dtext'        => __( 'Activating', 'pagelines' ),
 150              ) ,
 151              'deactivate'=> array(
 152                  'mode'        => 'deactivate',
 153                  'condition'    => $this->show_deactivate_button( $type, $key, $ext, $tab ),
 154                  'case'        => $type.'_deactivate',
 155                  'type'        => $type,
 156                  'path'        => $this->get_the_path( 'deactivate', $type, $key, $ext, $tab ),
 157                  'file'        => $this->get_the_file( 'deactivate', $type, $key, $ext, $tab ),
 158                  'text'        => __( 'Deactivate', 'pagelines' ),
 159                  'dtext'        => __( 'Deactivating', 'pagelines' ),
 160              ),
 161              'upgrade'    => array(
 162                  'mode'        => 'upgrade',
 163                  'condition'    => $this->show_upgrade_available( $type, $key, $ext, $tab ),
 164                  'case'        => $type.'_upgrade',
 165                  'type'        => $type,
 166                  'file'        => $this->get_the_file( 'upgrade', $type, $key, $ext, $tab ),
 167                  'path'        => $key,
 168                  'text'        => sprintf( __( 'Upgrade to %s', 'pagelines' ), $ext['apiversion'] ),
 169                  'dtext'        => sprintf( __( 'Upgrading to version %s', 'pagelines' ), $ext['apiversion'] ),
 170              ),
 171              'delete'    => array(
 172                  'mode'        => 'delete',
 173                  'condition'    => $this->show_delete_button( $type, $key, $ext, $tab ),
 174                  'case'        => $type.'_delete',
 175                  'type'        => $type,
 176                  'file'        => $this->get_the_file( 'delete', $type, $key, $ext, $tab ),
 177                  'text'        => __( 'Delete', 'pagelines' ),
 178                  'dtext'        => __( 'Deleting', 'pagelines' ),
 179                  'confirm'    => true
 180              ),
 181              'installed'    =>    array(
 182                  'mode'        => 'installed',
 183                  'condition'    => $this->show_installed_button( $type, $key, $ext, $tab ),
 184                  'text'        => __( 'Installed', 'pagelines' ),
 185                  ),
 186              'version_fail'    =>    array(
 187                  'case'        => 'version_fail',
 188                  'file'        =>    $ext['plversion'],
 189                  'path'        =>    $type,
 190                  'condition'    => $this->version_fail( $ext['plversion'] ),
 191                  'text'        => sprintf( __( '%s is required', 'pagelines' ), $ext['plversion'] ),
 192                  ),
 193              'dependancy'    =>    array(
 194                  'case'        => 'depends_fail',
 195                  'file'        =>    $this->depends_nice_name( $type, $key, $ext, $tab ),
 196                  'path'        =>    $type,
 197                  'condition'    => $this->depends_check( $type, $key, $ext, $tab ),
 198                  'text'        => __( 'Install', 'pagelines' ),
 199                  ),
 200              'pro_fail'    =>    array(
 201                  'case'        => 'pro_fail',
 202                  'mode'        =>    'pro_fail',
 203                  'path'        =>    $type,
 204                  'condition'    => $this->is_pro_only( $type, $key, $ext, $tab ),
 205                  'text'        => __( 'Upgrade to Pro', 'pagelines' ),
 206                  ),
 207  
 208              'download'    => array(
 209                  'mode'        => 'download',
 210                  'condition'    => $this->show_download_button( $type, $key, $ext, $tab ),
 211                  'case'        => $type . '_download',
 212                  'type'        => 'integration',
 213                  'file'        => $key,
 214                  'text'        => __( 'Download <strong>&darr;</strong>', 'pagelines' ),
 215                  'dtext'        => __( 'Downloading', 'pagelines' )
 216                  ),
 217              'unsubscribe'    =>    array(
 218                      'mode'        => 'unsubscribe',
 219                      'case'        => 'unsubscribe',
 220                      'path'        => sprintf( '%s|%s|%s', $this->username, $this->get_product_id( $ext ), $this->get_the_version($type, $key, $ext) ),
 221                      'type'        => $type,
 222                      'condition'    => $this->show_unsubscribe_button( $type, $key, $ext, $tab ),
 223                      'text'        => __( 'Unsubscribe', 'pagelines' ),
 224                  ),
 225              'subscribe'    =>    array(
 226                      'mode'        => 'subscribe',
 227                      'case'        => 'subscribe',
 228                      'type'        => $type,
 229                      'path'        => sprintf( '%s|%s|%s', $this->username, $this->get_product_id( $ext ), $this->get_the_version($type, $key, $ext) ),
 230                      'condition'    => $this->show_subscribe_button( $type, $key, $ext, $tab ),
 231                      'text'        => __( 'Subscribe', 'pagelines' ),
 232                  ),
 233  
 234  
 235          );
 236          return $actions;
 237      }
 238  
 239  // ======================
 240  // = Main button logic. =
 241  // ======================
 242  
 243  
 244       /**
 245       *
 246       * @TODO document
 247       *
 248       */
 249  	 function show_in_tab( $type, $key, $ext, $tab ){
 250  
 251          $a = array(
 252              'plversion'            =>    PL_CORE_VERSION,
 253              'price'                =>    'free',
 254              'featured'            =>    'false',
 255              'loaded'             => ( isset( $ext['status']['status'] ) ) ? true : false,
 256              'sections-plugin'    => ( isset( $ext['file']) && PL_EXTEND_SECTIONS_PLUGIN === basename( $ext['file'] ) ) ? true : false,
 257              'type'                => 'internal'
 258              );
 259  
 260          $ext = wp_parse_args( $ext, $a );
 261  
 262          if($type == 'section'){
 263  
 264              $ext = (array) $ext;
 265  
 266              if ( $tab === 'user' && ( $ext['type'] === 'custom' || $ext['type'] === 'parent' ) )
 267                  return false;
 268              if ( $tab === 'user' && ( $ext['type'] != 'parent' && $ext['type'] != 'custom' ) )
 269                  return true;
 270              elseif ( $tab === 'internal' && ( $ext['type'] === 'custom' || $ext['type'] === 'child' ) )
 271                  return false;
 272              elseif ( $tab === 'internal' && ( ! VPRO && $ext['edition'] === 'pro' ) )
 273                  return false;
 274              elseif ( $tab === 'child' && $ext['type'] != 'custom' )
 275                  return false;
 276              elseif ( $ext['type'] == 'parent' && $ext['class_exists'] )
 277                  return false;
 278              elseif( isset($ext['price']) && $ext['price'] != 'free' && $tab == 'free' )
 279                  return false;
 280              elseif( $tab == 'premium' && $ext['price'] == 'free' )
 281                  return false;
 282              elseif( $tab == 'featured' && $ext['featured'] == 'false' )
 283                  return false;
 284              else
 285                  return true;
 286  
 287          } elseif($type == 'plugin'){
 288  
 289              if ( $tab == 'featured' && $ext['featured'] == 'false' )
 290                  return false;
 291  
 292              if ( $tab === 'installed' && (!$ext['loaded'] || $ext['sections-plugin']) )
 293                  return false;
 294  
 295              elseif ( ( $tab === 'premium' ) && $ext['price'] === 'free' )
 296                  return false;
 297  
 298              elseif ( $tab === 'free' && $ext['price'] != 'free' )
 299                  return false;
 300  
 301              else
 302                  return true;
 303  
 304          } elseif($type == 'theme'){
 305  
 306              $featured     = ( isset( $ext['featured'] ) ) ? (bool) $ext['featured'] : false;
 307              $ext['exists'] = $this->is_installed('theme', $key, $ext);
 308  
 309              if ( is_file( sprintf( '%s/themes/%s/style.css', WP_CONTENT_DIR, $key ) ) )
 310                  $exists = true;
 311  
 312              if ( $tab === 'featured' && $ext['featured'] === 'true' )
 313                  return true;
 314              elseif ( $tab === 'featured' && $ext['featured'] === 'false' )
 315                  return false;
 316  
 317              elseif ( ( $tab == 'premium' || $tab == 'featured' )  && $ext['price'] == 'free' )
 318                  return false;
 319  
 320              elseif (  $tab == 'free' && $ext['price'] != 'free' )
 321                  return false;
 322  
 323              elseif ( $tab == 'installed' && !$ext['exists'] )
 324                  return false;
 325  
 326              else
 327                  return true;
 328          }
 329          return true;
 330      }
 331  
 332  
 333       /**
 334       *
 335       * @TODO document
 336       *
 337       */
 338  	 function version_check( $version ){
 339          return ( version_compare( PL_CORE_VERSION, $version ) >= 0 ) ? true : false;
 340      }
 341  
 342  
 343      /**
 344      *
 345      * @TODO document
 346      *
 347      */
 348  	function depends_check( $type, $key, $ext, $tab ) {
 349  
 350          if ( $type == 'plugin' ) {
 351  
 352              if (  !empty( $ext['depends']) ) {
 353                  $file = sprintf( '%s/%s/%s.php', WP_PLUGIN_DIR, $ext['depends'], $ext['depends'] );
 354                  if ( !is_file( $file ) )
 355                      return true;
 356              }
 357          return false;
 358          }
 359          return false;
 360      }
 361  
 362  
 363      /**
 364      *
 365      * @TODO document
 366      *
 367      */
 368  	function show_upgrade_available($type, $key, $ext, $tab){
 369  
 370          if ( EXTEND_NETWORK )
 371              return false;
 372  
 373          if ( $type == 'plugin' ) {
 374  
 375              if( $this->is_installed($type, $key, $ext)
 376                  && ! $this->in_the_store( $type, $key, $ext, $tab )
 377                  && $this->upgrade_available( $this->get_api_version($type, $key, $ext), $this->get_the_version($type, $key, $ext) )
 378              ){
 379                  return true;
 380              } else
 381                  return false;
 382          }
 383  
 384          if( $this->is_installed( $type, $key, $ext )
 385              && $this->upgrade_available( $this->get_api_version( $type, $key, $ext ), $ext['version'] )
 386          ){
 387              return true;
 388          } else
 389              return false;
 390  
 391      }
 392  
 393  
 394       /**
 395       *
 396       * @TODO document
 397       *
 398       */
 399  	 function upgrade_available( $api_version, $installed_version ){
 400  
 401          if ( $api_version > $installed_version )
 402              return $api_version;
 403          else
 404              return false;
 405      }
 406  
 407  
 408       /**
 409       *
 410       * @TODO document
 411       *
 412       */
 413  	 function show_download_button( $type, $key, $ext, $tab ){
 414  
 415          if( $type == 'integration' && $this->updates_configured() && VDEV && !EXTEND_NETWORK)
 416              return true;
 417          else
 418              return false;
 419      }
 420  
 421  
 422       /**
 423       *
 424       * @TODO document
 425       *
 426       */
 427  	 function show_login_button( $type, $key, $ext, $tab ){
 428  
 429  
 430          if( $this->updates_configured() )
 431              return false;
 432  
 433          if ( $type == 'integration' && !$this->updates_configured() && !EXTEND_NETWORK )
 434              return true;
 435  
 436          if( EXTEND_NETWORK && ! $this->updates_configured()
 437              && true === $this->is_premium( $type, $key, $ext )
 438              && 'user' == $tab || 'installed' == $tab
 439              && isset( $ext['price'] )
 440              && $ext['price']
 441              && $ext['price'] != 'free'
 442          ) return true;
 443  
 444          if( !EXTEND_NETWORK
 445              && !$this->is_purchased( $type, $key, $ext )
 446              && $this->in_the_store( $type, $key, $ext, $tab )
 447              && !$this->is_installed( $type, $key, $ext )
 448              && ! $this->version_fail( $ext['plversion'] )
 449          ) return true;
 450  
 451  
 452          return false;
 453      }
 454  
 455  
 456       /**
 457       *
 458       * @TODO document
 459       *
 460       */
 461  	 function show_install_button( $type, $key, $ext, $tab){
 462  
 463          if ( $type == 'integration' )
 464              return false;
 465  
 466          if( !$this->is_installed( $type, $key, $ext )
 467              && $this->is_purchased( $type, $key, $ext )
 468              && $this->in_the_store( $type, $key, $ext, $tab )
 469              && ! EXTEND_NETWORK
 470              && ! $this->version_fail( $ext['plversion'] )
 471              && ! $this->depends_check( $type, $key, $ext, $tab )
 472              && ! $this->is_pro_only( $type, $key, $ext, $tab )
 473          )
 474              return true;
 475          else
 476              return false;
 477      }
 478  
 479  
 480      /**
 481      *
 482      * @TODO document
 483      *
 484      */
 485  	function is_pro_only( $type, $key, $ext, $tab ) {
 486  
 487          if ( isset( $ext['edition']) && 'pro' == strtolower( $ext['edition'] ) && ! VPRO )
 488              return true;
 489          else
 490              return false;
 491      }
 492  
 493      /**
 494      *
 495      * @TODO document
 496      *
 497      */
 498  	function is_subscribed( $type, $key, $ext, $tab ) {
 499  
 500          if ( isset( $ext['subscribed'] ) )
 501              return true;
 502          else
 503              return false;
 504      }
 505  
 506      /**
 507      *
 508      * @TODO document
 509      *
 510      */
 511  	function show_subscribe_button( $type, $key, $ext, $tab ){
 512  
 513          if( ! EXTEND_NETWORK
 514              && $this->is_installed( $type, $key, $ext )
 515              && $this->subscription_enabled()
 516              && ! $this->in_the_store( $type, $key, $ext, $tab )
 517              && ! $this->is_subscribed( $type, $key, $ext, $tab )
 518              && $this->get_product_id( $ext )
 519              && $this->updates_configured()
 520          ){
 521              return true;
 522          } else
 523              return false;
 524      }
 525  
 526      /**
 527      *
 528      * @TODO document
 529      *
 530      */
 531  	function show_unsubscribe_button( $type, $key, $ext, $tab ){
 532  
 533          if( ! EXTEND_NETWORK
 534              && $this->is_installed( $type, $key, $ext )
 535              && $this->subscription_enabled()
 536              && $this->is_subscribed( $type, $key, $ext, $tab )
 537              && ! $this->in_the_store( $type, $key, $ext, $tab )
 538              && $this->updates_configured()
 539          ){
 540              return true;
 541          } else
 542              return false;
 543      }
 544  
 545  
 546  
 547      /**
 548      *
 549      * @TODO document
 550      *
 551      */
 552  	function show_installed_button( $type, $key, $ext, $tab ){
 553  
 554          if( $this->is_installed( $type, $key, $ext )
 555              && $this->in_the_store( $type, $key, $ext, $tab )
 556          ){
 557              return true;
 558          } else
 559              return false;
 560      }
 561  
 562  
 563      /**
 564      *
 565      * @TODO document
 566      *
 567      */
 568  	function subscription_enabled(){
 569  
 570          if( defined( 'STORE_SUBSRIPTIONS_DISABLE' ) || ! VPRO )
 571              return false;
 572          else
 573              return true;
 574      }
 575  
 576      /**
 577      *
 578      * @TODO document
 579      *
 580      */
 581  	function show_delete_button( $type, $key, $ext, $tab ){
 582  
 583          if ( $type == 'section' && ( $tab == 'child' || $tab == 'internal' ) )
 584              return false;
 585  
 586          if( !$this->is_active( $type, $key, $ext )
 587              && $this->is_installed( $type, $key, $ext )
 588              && !EXTEND_NETWORK
 589              && !$this->in_the_store( $type, $key, $ext, $tab )
 590          ){
 591              return true;
 592          } else
 593              return false;
 594  
 595      }
 596  
 597  
 598       /**
 599       *
 600       * @TODO document
 601       *
 602       */
 603  	 function is_installed( $type, $key, $ext, $tab = '' ){
 604  
 605          if( 'dash_rss' == $tab && 'plugin' == $type ) {
 606  
 607              if ( is_dir( sprintf( '%s/%s', WP_PLUGIN_DIR, $ext['slug'] ) ) && file_exists( sprintf( '%s/%s/%s.php', WP_PLUGIN_DIR, $ext['slug'], $ext['slug'] ) ) )
 608                  return true;
 609          }
 610  
 611          if( $type == 'section' ){
 612  
 613              $status = ( isset($ext['status'] ) ) ? true : false;
 614  
 615              if ( isset( $ext['base_file'] ) )
 616                  $path = $ext['base_file'];
 617              else
 618                  $path = sprintf( '%s/%s/section.php', PL_EXTEND_DIR, $ext['slug'] );
 619  
 620              if( is_file( $path ) )
 621                  return true;
 622              else
 623                  return false;
 624  
 625          } elseif( $type == 'plugin' ){
 626  
 627              if( isset( $ext['status']['status'] ) && $ext['status']['status'] != '' )
 628                  return true;
 629              else
 630                  return false;
 631  
 632          } elseif( $type == 'theme' ){
 633  
 634              $check_file = sprintf( '%s/themes/%s/style.css', WP_CONTENT_DIR, $key );
 635  
 636              if ( is_file( $check_file ) )
 637                  $exists = true;
 638  
 639              if( isset( $exists ) && $data = pl_get_theme_data( $key ) )
 640                  return true;
 641              else
 642                  return false;
 643          }
 644  
 645      }
 646  
 647  
 648      /**
 649      *
 650      * @TODO document
 651      *
 652      */
 653  	function show_purchase_button( $type, $key, $ext, $tab ){
 654  
 655          if ( !$this->updates_configured() )
 656              return false;
 657  
 658          if( EXTEND_NETWORK ) {
 659          if( ( 'user' == $tab || 'installed' == $tab )
 660              && ! $this->is_purchased( $type, $key, $ext )
 661              && $this->is_premium( $type, $key, $ext )
 662  
 663              && !($this->is_user_plus() && $this->is_plus_product( $type, $key, $ext, $tab ))
 664          ) return true;
 665          return false;
 666      }
 667  
 668          if( !EXTEND_NETWORK
 669              && $this->updates_configured()
 670              && $this->in_the_store( $type, $key, $ext, $tab )
 671              && !$this->is_purchased( $type, $key, $ext )
 672              && !$this->is_installed( $type, $key, $ext )
 673              && $this->is_premium( $type, $key, $ext )
 674              && ! $this->version_fail( $ext['plversion'] )
 675              && !($this->is_user_plus() && $this->is_plus_product( $type, $key, $ext, $tab ))
 676              && ! $this->is_pro_only( $type, $key, $ext, $tab )
 677          ){
 678              return true;
 679          } else
 680              return false;
 681      }
 682  
 683      /**
 684      *
 685      * @TODO document
 686      *
 687      */
 688  	function show_plus_button( $type, $key, $ext, $tab ){
 689  
 690          if( !EXTEND_NETWORK
 691              && $this->updates_configured()
 692              && $this->in_the_store( $type, $key, $ext, $tab )
 693              && !$this->is_purchased( $type, $key, $ext )
 694              && !$this->is_installed( $type, $key, $ext )
 695              && $this->is_premium( $type, $key, $ext )
 696              && ! $this->version_fail( $ext['plversion'] )
 697              && $this->is_user_plus()
 698              && $this->is_plus_product( $type, $key, $ext, $tab )
 699          ){
 700              return true;
 701          } else
 702              return false;
 703      }
 704  
 705  
 706      /**
 707      *
 708      * @TODO document
 709      *
 710      */
 711  	function is_premium( $type, $key, $ext ){
 712          $ext = (array) $ext;
 713  
 714          if( isset( $ext['price'] )
 715              && $ext['price'] != 'free'
 716              && (int) $ext['price'] >= 0
 717          ){
 718              return true;
 719          } else
 720              return false;
 721      }
 722  
 723  
 724       /**
 725       *
 726       * @TODO document
 727       *
 728       */
 729  	 function is_purchased( $type, $key, $ext ){
 730  
 731          if($type == 'section'){
 732  
 733              return ( isset( $ext['purchased'] ) && $ext['purchased'] == 'purchased' ) ? true : false;
 734  
 735          } else {
 736  
 737              if( isset( $ext['purchased'] ) )
 738                  return true;
 739              else
 740                  return false;
 741          }
 742      }
 743  
 744  
 745      /**
 746      *
 747      * @TODO document
 748      *
 749      */
 750  	function show_activate_button( $type, $key, $ext, $tab ){
 751  
 752          if( EXTEND_NETWORK ) {
 753  
 754          if( ! $this->in_the_store( $type, $key, $ext, $tab )
 755              && $this->is_installed( $type, $key, $ext, $tab )
 756              && ! $this->is_active( $type, $key, $ext )
 757      //        && ! $this->is_persistant( $type, $key, $ext, $tab )
 758              && ! $this->show_purchase_button( $type, $key, $ext, $tab )
 759          ) {
 760  
 761          if ( VPLUS && isset( $ext['plus_product'] ) )
 762              return true;
 763          if ( isset( $ext['loadme'] ) && $ext['loadme'] )
 764              return true;
 765          if ( isset( $ext['price'] ) && ( $ext['price'] == 'free' || ! $ext['price'] ) )
 766              return true;
 767          if ( isset( $ext['purchased']) && 'purchased' == $ext['purchased'] )
 768              return true;
 769          }
 770          return false;
 771      }
 772  
 773          if ( $type == 'integration' && VDEV && is_integration_active($key) == false )
 774              return true;
 775  
 776          if( ! $this->in_the_store( $type, $key, $ext, $tab )
 777              && $this->is_installed( $type, $key, $ext, $tab )
 778              && ! $this->is_active( $type, $key, $ext )
 779              && ! $this->is_persistant( $type, $key, $ext, $tab )
 780              && ! $this->is_pro_only( $type, $key, $ext, $tab )
 781          ){
 782              return true;
 783          } else
 784              return false;
 785      }
 786  
 787  
 788      /**
 789      *
 790      * @TODO document
 791      *
 792      */
 793  	function show_deactivate_button( $type, $key, $ext, $tab ){
 794  
 795          if ( $type == 'integration' && VDEV )
 796              return is_integration_active( $key );
 797  
 798          if( $this->is_active( $type, $key, $ext )
 799              && ! $this->in_the_store( $type, $key, $ext, $tab )
 800              && ! $this->is_persistant( $type, $key, $ext, $tab )
 801          ){
 802              return true;
 803          } else
 804              return false;
 805      }
 806  
 807  
 808      /**
 809      *
 810      * @TODO document
 811      *
 812      */
 813  	function is_persistant( $type, $key, $ext, $tab ) {
 814  
 815          if ( isset( $ext['persistant'] ) && true == $ext['persistant'] )
 816              return true;
 817          else
 818              return false;
 819      }
 820  
 821  
 822      /**
 823      *
 824      * @TODO document
 825      *
 826      */
 827  	function is_active( $type, $key, $ext ){
 828  
 829          if ( $type == 'integration' )
 830              return is_integration_active($key);
 831  
 832          elseif($type == 'plugin'){
 833              if( isset( $ext['status']['status'] ) && $ext['status']['status'] == 'active' )
 834                  return true;
 835              else
 836                  return false;
 837  
 838          }elseif( $type == 'section' ){
 839  
 840              if( isset( $ext['status'] ) && $ext['status'] == 'enabled' )
 841                  return true;
 842              else
 843                  return false;
 844  
 845          }    elseif( $type == 'theme' ){
 846  
 847                  if( $key  == basename( get_stylesheet_directory() ) )
 848                      return true;
 849                  else
 850                      return false;
 851              }
 852  
 853      }
 854  
 855  
 856       /**
 857       *
 858       * @TODO document
 859       *
 860       */
 861  	 function in_the_store( $type, $key, $ext, $tab ){
 862  
 863          if ( $type == 'integration' )
 864              return true;
 865  
 866          if( $tab == 'free' || $tab == 'premium' || $tab == 'featured' )
 867              return true;
 868          else
 869              return false;
 870  
 871      }
 872  
 873       /**
 874       *
 875       * @TODO document
 876       *
 877       */
 878  	 function is_plus_product( $type, $key, $ext, $tab ) {
 879          if(isset($ext['plus_product']) && $ext['plus_product']) {
 880              return true;
 881          }
 882  
 883          return false;
 884      }
 885  
 886       /**
 887       *
 888       * @TODO document
 889       *
 890       */
 891  	 function is_user_plus() {
 892          if(VPLUS) {
 893              return true;
 894          }
 895  
 896          return false;
 897       }
 898  
 899       /**
 900       *
 901       * @TODO document
 902       *
 903       */
 904  	 function purchase_button( $purchased = false, $store = true ){
 905          return ( $store && !EXTEND_NETWORK && !$purchased && !$this->login_button( $purchased ) ) ? true : false;
 906      }
 907  
 908  
 909       /**
 910       *
 911       * @TODO document
 912       *
 913       */
 914  	 function install_button( $installed = false, $purchased = false, $version = 0 ){
 915          return ( $this->version_check( $version ) && !EXTEND_NETWORK && $purchased && ! $installed) ? true : false;
 916      }
 917  
 918  
 919       /**
 920       *
 921       * @TODO document
 922       *
 923       */
 924  	 function version_fail( $version ){
 925          return ( ! $this->version_check( $version ) ) ? true : false;
 926      }
 927  
 928  
 929       /**
 930       *
 931       * @TODO document
 932       *
 933       */
 934  	 function updates_configured( ){
 935          return ( pagelines_check_credentials() ) ? true : false;
 936      }
 937  
 938  
 939       /**
 940       *
 941       * @TODO document
 942       *
 943       */
 944  	 function do_redirect( $type, $key, $ext, $tab ){
 945          if ( $tab == 'installed' || $tab == 'user' || $type == 'integration' || $type = 'internal' )
 946              return false;
 947          if ( $this->show_installed_button( $type, $key, $ext, $tab ) )
 948              return false;
 949          return ( EXTEND_NETWORK ) ? true : false;
 950      }
 951  
 952  // ===================================
 953  // = Images, files, links and paths. =
 954  // ===================================
 955  
 956       /**
 957       *
 958       * @TODO document
 959       *
 960       */
 961  	 function image_path( $type, $key, $ext, $tab ) {
 962  
 963          if( $type == 'integration' ) {
 964              if( isset( $ext['screen'] ) && $ext['screen'] )
 965                  return sprintf( '%s/files/integrations/img/%s-thumb.png',untrailingslashit( PL_API_CDN ), $key );
 966          }
 967  
 968          if ( $type == 'plugin' ) {
 969  
 970              if ( $this->is_installed( $type, $key, $ext, $tab ) ) {
 971  
 972                  if ( is_file( sprintf( '%s/%s/thumb.png', WP_PLUGIN_DIR, $ext['slug'] ) ) )
 973                      return sprintf( '%s/thumb.png', plugins_url( $ext['slug'] ) );
 974              } else {
 975  
 976                  if( isset( $ext['screen'] ) && $ext['screen'] )
 977                      return sprintf( '%s/files/%ss/img/%s-thumb.png', untrailingslashit( PL_API_CDN ), $type, $ext['slug'] );
 978              }
 979          }
 980  
 981          if ( $type == 'section' ) {
 982  
 983                  if ( isset( $ext['base_dir'] ) && is_file( sprintf( '%s/thumb.png', $ext['base_dir'] ) ) )
 984                      return sprintf( '%s/thumb.png', $ext['base_url'] );
 985  
 986                  if( isset( $ext['screen'] ) && $ext['screen'] )
 987                      return sprintf( '%s/files/%ss/img/%s-thumb.png', untrailingslashit( PL_API_CDN ), $type, $ext['slug'] );
 988          }
 989  
 990  
 991          if ( $type == 'theme' ) {
 992  
 993              if ( ( $this->show_install_button( $type, $key, $ext, $tab ) || $this->show_purchase_button( $type, $key, $ext, $tab ) || $this->show_login_button( $type, $key, $ext, $tab ) || EXTEND_NETWORK ) )
 994                  if ( isset( $ext['screen'] ) && $ext['screen'] )
 995                      return sprintf( '%s/files/themes/img/%s-thumb.png', untrailingslashit( PL_API_CDN ), $key );
 996  
 997              // theme installed or no screenshot...
 998  
 999              if ( is_file( sprintf( '%s/%s/thumb.png', get_theme_root(), $key ) ) )
1000                  return sprintf( '%s/%s/thumb.png', get_theme_root_uri(), $key );
1001  
1002              if ( is_file( sprintf( '%s/%s/screenshot.png', get_theme_root(), $key ) ) )
1003                  return sprintf( '%s/%s/screenshot.png', get_theme_root_uri(), $key );
1004  
1005          }
1006          return PL_ADMIN_IMAGES . '/thumb-default.png';
1007      }
1008  
1009  
1010      /**
1011       *
1012       *  @Todo make this a serialized array of all data.
1013       *
1014       */
1015  	 function get_the_path( $button, $type, $key, $ext, $tab ){
1016  
1017  
1018          // If Section >>>
1019          if ( ( $button == 'deactivate' || $button == 'activate' ) && $type == 'section' )
1020              return $ext['type'];
1021  
1022          if ( ( $button == 'install' || $button == 'delete' ) && $type == 'section' ) {
1023              return $key;
1024          }
1025  
1026          if( $type == 'integration' )
1027              return get_integration_path($ext);
1028  
1029      }
1030  
1031  
1032       /**
1033       *
1034       * @TODO document
1035       *
1036       */
1037  	 function get_the_file( $button, $type, $key, $ext, $tab ){
1038  
1039          if ( $button == 'delete' || $button == 'upgrade' ) {
1040              if ( $type == 'section'
1041                   && isset( $ext['base_dir'] )
1042                      ) {
1043                  return basename( $ext['base_dir'] );
1044              }
1045          }
1046  
1047  
1048          if ( $type == 'section' ) {
1049              return $ext['class'];
1050          } elseif( $type == 'plugin' ){
1051  
1052              if( $button == 'activate'
1053                  || $button == 'deactivate'
1054                  || $button == 'delete'
1055              ){
1056                  return $ext['file'];
1057              } else
1058                  return $key;
1059  
1060  
1061          }elseif( $type == 'theme' ){
1062              return $key;
1063  
1064          } else
1065              return $key;
1066  
1067      }
1068  
1069  
1070       /**
1071       *
1072       * @TODO document
1073       *
1074       */
1075  	 function paypal_link( $type, $key, $ext, $tab ){
1076          if( isset( $ext['pid'] ) )
1077              $p = $ext['pid'];
1078          elseif( isset( $ext['productid'] ) )
1079              $p = $ext['productid'];
1080  
1081          return ( isset( $p ) && isset( $ext['uid'] ) ) ? sprintf( '%s,%s|%s|%s', $p, $ext['uid'], $ext['price'], $ext['name'] ) : '';
1082      }
1083  
1084  
1085       /**
1086       *
1087       * @TODO document
1088       *
1089       */
1090  	 function purchase_text( $type, $key, $ext, $tab ){
1091  
1092          $ext = (array) $ext;
1093  
1094          $price = ( isset( $ext['price'] ) ) ? sprintf( ' <span class="prc">($%s)</span>', $ext['price'] ) : '';
1095  
1096          return sprintf( '%s%s', __( 'Purchase', 'pagelines' ), $price );
1097      }
1098  
1099  
1100      /**
1101       *
1102       * @TODO document
1103       *
1104       */
1105  	 function plus_text( $type, $key, $ext, $tab ){
1106  
1107          $ext = (array) $ext;
1108  
1109          $price = ( isset( $ext['price'] ) ) ? sprintf( ' <span class="prc">($%s)</span>', $ext['price'] ) : '';
1110  
1111          return sprintf( '%s%s', __( 'Free PageLines Plus', 'pagelines' ), '<del>' . $price . '</del>' );
1112      }
1113  
1114  
1115       /**
1116       *
1117       * @TODO document
1118       *
1119       */
1120  	 function get_the_version($type, $key, $ext){
1121  
1122          // has to be the installed version.
1123          if ( $this->is_installed( $type, $key, $ext ) ) {
1124  
1125              if ( $type == 'plugin' )
1126                  return $ext['status']['data']['Version'];
1127          }
1128          return $ext['version'];
1129      }
1130  
1131  
1132      /**
1133      *
1134      * @TODO document
1135      *
1136      */
1137  	function get_api_version( $type, $key, $ext ) {
1138  
1139          if ( isset( $ext['apiversion'] ) )
1140              return $ext['apiversion'];
1141  
1142          return false;
1143      }
1144  
1145      /**
1146      *
1147      * @TODO document
1148      *
1149      */
1150  	function get_product_id( $ext ) {
1151  
1152          if ( isset( $ext['pid'] ) )
1153              return $ext['pid'];
1154  
1155          if ( isset( $ext['productid'] ) )
1156              return $ext['productid'];
1157  
1158          return false;
1159      }
1160  
1161      /**
1162      *
1163      * @TODO document
1164      *
1165      */
1166  	function parse_buttons( $actions, $core_actions ){
1167  
1168          $actions = wp_parse_args( $actions, $core_actions );
1169  
1170          foreach( $actions as $action => $button ){
1171              if( isset( $core_actions[$action] ) ){
1172                  $actions[$action] = wp_parse_args( $button, $core_actions[$action] );
1173              }
1174          }
1175          return $actions;
1176      }
1177  
1178      /**
1179      * Simple cache.
1180      * @return object
1181      */
1182  	function get_latest_cached( $type, $flush = null, $timeout = 86400 ) {
1183  
1184          $url = trailingslashit( PL_API . $type );
1185          if( 'all' == $type )
1186              $url = 'www.pagelines.com/api/v5/store.json';
1187  
1188          $options = array(
1189              'body' => array(
1190                  'username'    =>    ( $this->username != '' ) ? $this->username : false,
1191                  'password'    =>    ( $this->password != '' ) ? $this->password : false,
1192                  'flush'        =>    $flush
1193              )
1194          );
1195          // if v4 all, we just want stuff, its cached on the server.
1196          if( 'all' == $type ) {
1197                  $options['method'] = 'GET';
1198                  $response = pagelines_try_api( $url, $options );
1199  
1200                  if ( $response !== false ) {
1201                      // ok we have the data parse and store it
1202                      $api = wp_remote_retrieve_body( $response );
1203                      return json_decode( $api );
1204                  }
1205              return false;
1206          }
1207  
1208          if ( false === ( $api_check = get_transient( 'pagelines_extend_' . $type ) ) ) {
1209  
1210              // ok no transient, we need an update...
1211  
1212              $response = pagelines_try_api( $url, $options );
1213  
1214              if ( $response !== false ) {
1215  
1216                  // ok we have the data parse and store it
1217  
1218                  $api = wp_remote_retrieve_body( $response );
1219                  set_transient( 'pagelines_extend_' . $type, true, $timeout );
1220                  update_option( 'pagelines_extend_' . $type, $api );
1221              }
1222  
1223          }
1224          $api = get_option( 'pagelines_extend_' . $type, false );
1225  
1226          if( ! $api )
1227              return __( '<h2>Unable to fetch from API</h2>', 'pagelines' );
1228  
1229          return json_decode( $api );
1230      }
1231  
1232      /**
1233       * Refresh the PageLines store cache
1234       *
1235       */
1236  	function launchpad_returns() {
1237  
1238          if (isset( $_GET['api_returned'] ) || isset( $_POST['reset_store'] ) )
1239              $this->flush_caches();
1240      }
1241  
1242      /**
1243       * Check if we have the extend plugin.
1244       *
1245       */
1246  
1247      /**
1248      *
1249      * @TODO document
1250      *
1251      */
1252  	function has_extend_plugin( $status = false ){
1253  
1254          if($status){
1255  
1256              if( is_file( PL_EXTEND_INIT ) && current( $this->plugin_check_status( PL_EXTEND_INIT ) ) == 'notactive' )
1257                  return 'notactive';
1258              elseif( !is_dir( PL_EXTEND_DIR ) || !is_file( PL_EXTEND_INIT ) )
1259                  return 'notinstalled';
1260              else
1261                  return 'active';
1262  
1263          } else {
1264              if ( !is_dir( PL_EXTEND_DIR ) || ( is_file( PL_EXTEND_INIT ) && current( $this->plugin_check_status( PL_EXTEND_INIT ) ) == 'notactive' ) )
1265                  return false;
1266              else
1267                  return true;
1268          }
1269      }
1270  
1271      /**
1272       * Get current status for a plugin.
1273       *
1274       */
1275  	function plugin_check_status( $file ) {
1276  
1277          if ( !is_file( $file ) )
1278              return ;
1279          $data = get_plugin_data( $file );
1280  
1281          if ( in_array( str_replace( '.php', '', basename( $file ) ), pagelines_register_plugins() ) )
1282              return array( 'status' => 'active', 'version' => $data['Version'], 'data' => $data );
1283          else
1284              return array( 'status' => 'notactive', 'version' => $data['Version'], 'data' => $data );
1285      }
1286  
1287  
1288      /**
1289      *
1290      * @TODO document
1291      *
1292      */
1293  	function get_the_tags( $type, $key, $ext, $tab ) {
1294  
1295          if ( isset( $ext['tags'] ) && ! empty( $ext['tags'] ) )
1296              return $ext['tags'];
1297          else
1298              return '';
1299      }
1300  
1301  
1302      /**
1303      *
1304      * @TODO document
1305      *
1306      */
1307  	function get_the_author( $type, $key, $ext, $tab ) {
1308  
1309          if ( isset( $ext['author'] ) && ! empty( $ext['author'] ) )
1310              return $ext['author'];
1311          else
1312              return '';
1313      }
1314  
1315  
1316      /**
1317      *
1318      * @TODO document
1319      *
1320      */
1321  	function get_the_author_uri( $type, $key, $ext, $tab ) {
1322  
1323          if ( isset( $ext['external'] ) && ! empty( $ext['external'] ) )
1324              return $ext['external'];
1325  
1326          if ( isset( $ext['author_url'] ) && ! empty( $ext['author_url'] ) )
1327              return $ext['author_url'];
1328          else
1329              return admin_url();
1330      }
1331  
1332  
1333      /**
1334      *
1335      * @TODO document
1336      *
1337      */
1338  	function get_the_name( $type, $key, $ext, $tab ) {
1339  
1340          if ( isset( $ext['name'] ) && ! empty( $ext['name'] ) )
1341              return $ext['name'];
1342          else
1343              return '';
1344      }
1345  
1346  
1347      /**
1348      *
1349      * @TODO document
1350      *
1351      */
1352  	function get_the_desc( $type, $key, $ext, $tab ) {
1353  
1354          if ( isset( $ext['text'] ) && ! empty( $ext['text'] ) )
1355              return $ext['text'];
1356  
1357          if ( isset( $ext['description'] ) )
1358              return wp_kses( $ext['description'], array() );
1359  
1360          return '';
1361      }
1362  
1363  
1364      /**
1365      *
1366      * @TODO document
1367      *
1368      */
1369  	function get_the_count( $type, $key, $ext, $tab ) {
1370  
1371          if ( isset( $ext['count'] ) && ! empty( $ext['count'] ) )
1372              return $ext['count'];
1373          else
1374              return '0';
1375      }
1376  
1377  
1378      /**
1379      *
1380      * @TODO document
1381      *
1382      */
1383  	function get_the_screen( $type, $key, $ext, $tab ) {
1384  
1385          if ( isset( $ext['screen'] ) && ! empty( $ext['screen'] ) )
1386              return $ext['screen'];
1387          else
1388              return false;
1389      }
1390  
1391  
1392      /**
1393      *
1394      * @TODO document
1395      *
1396      */
1397  	function get_the_object( $type, $key, $ext, $tab ) {
1398  
1399          if ( isset( $ext['class'] ) && ! empty( $ext['class'] ) )
1400              return $ext['class'];
1401          else
1402              return false;
1403      }
1404  
1405  
1406      /**
1407      *
1408      * @TODO document
1409      *
1410      */
1411  	function get_info_url( $type, $key, $ext, $tab ) {
1412  
1413          $slug = ( isset( $ext['slug'] ) ) ? $ext['slug'] : $key;
1414          return sprintf( '%s/%ss/%s/?product_ref=true', PL_STORE_URL, $type, $slug );
1415      }
1416  
1417  
1418      /**
1419      *
1420      * @TODO document
1421      *
1422      */
1423  	function get_demo_url( $type, $key, $ext, $tab ) {
1424  
1425          return ( isset( $ext['demo'] ) ) ? $ext['demo'] : '';
1426  
1427      }
1428  
1429  
1430      /**
1431      *
1432      * @TODO document
1433      *
1434      */
1435  	function get_external_url( $type, $key, $ext, $tab ) {
1436  
1437      if ( isset( $ext['external'] ) )
1438          return $ext['external'];
1439  
1440      if ( isset( $ext['authorurl'] ) )
1441          return $ext['authorurl'];
1442  
1443      }
1444  
1445  
1446      /**
1447      *
1448      * @TODO document
1449      *
1450      */
1451  	function depends_nice_name( $type, $key, $ext, $tab ) {
1452  
1453          if ( isset( $ext['depends'] ) ) {
1454  
1455              if ( $type == 'plugin' ) {
1456  
1457                  $plugins = $this->get_latest_cached( 'plugins' );
1458  
1459                  if ( isset($plugins->$ext['depends']) &&  isset( $plugins->$ext['depends']->name ) )
1460                      return $plugins->$ext['depends']->name;
1461              }
1462          }
1463      }
1464  
1465  
1466      /**
1467      *
1468      * @TODO document
1469      *
1470      */
1471  	function get_master_list( $extension, $type, $tab, $mode = '') {
1472  
1473          $list = array();
1474          foreach( (array) $extension as $key => $ext ) {
1475  
1476              $ext = (array) $ext;
1477  
1478              if( !$this->show_in_tab( $type, $key, $ext, $tab ) )
1479                  continue;
1480  
1481              if ( 'installed' == $mode )
1482                  $array_key = basename( $ext['base_dir'] );
1483              else
1484                  $array_key = $key;
1485  
1486              $list[$array_key] = $this->master_list( $type, $key, $ext, $tab );
1487          }
1488          return ( !empty( $list ) ) ? $list : '';
1489      }
1490  
1491  
1492      /**
1493      *
1494      * @TODO document
1495      *
1496      */
1497  	function get_the_tab( $type, $key, $ext, $tab ) {
1498  
1499          return $tab;
1500  
1501      }
1502  
1503  
1504      /**
1505      *
1506      * @TODO document
1507      *
1508      */
1509  	function master_list( $type, $key, $ext, $tab ) {
1510  
1511          $ext['apiversion'] = ( isset( $ext['apiversion'] ) ) ? $ext['apiversion'] : $ext['version'];
1512  
1513          if ( !isset( $ext['status'] ) )
1514              $ext['status'] = array( 'status' => '' );
1515  
1516          $list = array(
1517                  $type        => $ext,
1518                  'name'         => $this->get_the_name( $type, $key, $ext, $tab ),
1519                  'active'    => $this->is_active( $type, $key, $ext ),
1520                  'version'    => $this->get_the_version( $type, $key, $ext ),
1521                  'desc'        => $this->get_the_desc( $type, $key, $ext, $tab ),
1522                  'tags'        => $this->get_the_tags( $type, $key, $ext, $tab ),
1523                  'image'        => $this->image_path( $type, $key, $ext, $tab ),
1524                  'auth'        => $this->get_the_author( $type, $key, $ext, $tab ),
1525                  'auth_url'    => $this->get_the_author_uri( $type, $key, $ext, $tab ),
1526                  'key'        => $key,
1527                  'type'        => $type,
1528                  'infourl'    => $this->get_info_url( $type, $key, $ext, $tab ),
1529                  'object'    => $this->get_the_object( $type, $key, $ext, $tab ),
1530                  'count'        => $this->get_the_count( $type, $key, $ext, $tab ),
1531                  'screen'    => $this->get_the_screen( $type, $key, $ext, $tab ),
1532                  'actions'    => $this->master_array( $type, $key, $ext, $tab  ),
1533                  'demo'        => $this->get_demo_url( $type, $key, $ext, $tab ),
1534                  'external'    => $this->get_external_url( $type, $key, $ext, $tab ),
1535                  'tab'        => $this->get_the_tab( $type, $key, $ext, $tab )
1536          );
1537  
1538          return $list;
1539      }
1540  
1541  	function updates_list( $args ) {
1542  
1543          $updates = ( array ) get_theme_mod( 'available_updates' );
1544  
1545          $defaults = array(
1546              'list'    =>    array(),
1547              'type'    =>    'plugin'
1548              );
1549          $o = wp_parse_args( $args, $defaults );
1550  
1551          if ( ! is_array( $o['list'] ) )
1552              return;
1553  
1554          if ( 'section' == $o['type'] ) {
1555  
1556              $sections = array();
1557              foreach( $o['list'] as $a => $b ) {
1558  
1559                  if( isset( $b['pid'] ) && $b['pid'] )
1560                      $sections[$b['class']] = array( 'section'    =>    $b );
1561              }
1562              $o['list'] = $sections;
1563          }
1564  
1565          foreach( $o['list'] as $key => $d ) {
1566  
1567              $ext = $d[ $o['type'] ];
1568  
1569              $id = ( $this->is_installed( $o['type'], $key, $ext ) ) ? $this->get_product_id( $ext ) : false;
1570  
1571              if( $id ) {
1572                  $version = $this->get_the_version( $o['type'], $key, $ext );
1573  
1574                  if ( $id && $version )
1575                      $updates[$id] = $version;
1576              }
1577          }
1578      set_theme_mod( 'available_updates', $updates );
1579      }
1580  
1581  } // [END]


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