[ 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 Framework
  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 ) {
1183  
1184          $url = trailingslashit( PL_API . $type );
1185          $options = array(
1186              'body' => array(
1187                  'username'    =>    ( $this->username != '' ) ? $this->username : false,
1188                  'password'    =>    ( $this->password != '' ) ? $this->password : false,
1189                  'flush'        =>    $flush
1190              )
1191          );
1192  
1193          if ( false === ( $api_check = get_transient( 'pagelines_extend_' . $type ) ) ) {
1194  
1195              // ok no transient, we need an update...
1196  
1197              $response = pagelines_try_api( $url, $options );
1198  
1199              if ( $response !== false ) {
1200  
1201                  // ok we have the data parse and store it
1202  
1203                  $api = wp_remote_retrieve_body( $response );
1204                  set_transient( 'pagelines_extend_' . $type, true, 86400 );
1205                  update_option( 'pagelines_extend_' . $type, $api );
1206              }
1207  
1208          }
1209          $api = get_option( 'pagelines_extend_' . $type, false );
1210  
1211          if( ! $api )
1212              return __( '<h2>Unable to fetch from API</h2>', 'pagelines' );
1213  
1214          return json_decode( $api );
1215      }
1216  
1217      /**
1218       * Refresh the PageLines store cache
1219       *
1220       */
1221  	function launchpad_returns() {
1222  
1223          if (isset( $_GET['api_returned'] ) || isset( $_POST['reset_store'] ) )
1224              $this->flush_caches();
1225      }
1226  
1227      /**
1228       * Check if we have the extend plugin.
1229       *
1230       */
1231  
1232      /**
1233      *
1234      * @TODO document
1235      *
1236      */
1237  	function has_extend_plugin( $status = false ){
1238  
1239          if($status){
1240  
1241              if( is_file( PL_EXTEND_INIT ) && current( $this->plugin_check_status( PL_EXTEND_INIT ) ) == 'notactive' )
1242                  return 'notactive';
1243              elseif( !is_dir( PL_EXTEND_DIR ) || !is_file( PL_EXTEND_INIT ) )
1244                  return 'notinstalled';
1245              else
1246                  return 'active';
1247  
1248          } else {
1249              if ( !is_dir( PL_EXTEND_DIR ) || ( is_file( PL_EXTEND_INIT ) && current( $this->plugin_check_status( PL_EXTEND_INIT ) ) == 'notactive' ) )
1250                  return false;
1251              else
1252                  return true;
1253          }
1254      }
1255  
1256      /**
1257       * Get current status for a plugin.
1258       *
1259       */
1260  	function plugin_check_status( $file ) {
1261  
1262          if ( !is_file( $file ) )
1263              return ;
1264          $data = get_plugin_data( $file );
1265  
1266          if ( in_array( str_replace( '.php', '', basename( $file ) ), pagelines_register_plugins() ) )
1267              return array( 'status' => 'active', 'version' => $data['Version'], 'data' => $data );
1268          else
1269              return array( 'status' => 'notactive', 'version' => $data['Version'], 'data' => $data );
1270      }
1271  
1272  
1273      /**
1274      *
1275      * @TODO document
1276      *
1277      */
1278  	function get_the_tags( $type, $key, $ext, $tab ) {
1279  
1280          if ( isset( $ext['tags'] ) && ! empty( $ext['tags'] ) )
1281              return $ext['tags'];
1282          else
1283              return '';
1284      }
1285  
1286  
1287      /**
1288      *
1289      * @TODO document
1290      *
1291      */
1292  	function get_the_author( $type, $key, $ext, $tab ) {
1293  
1294          if ( isset( $ext['author'] ) && ! empty( $ext['author'] ) )
1295              return $ext['author'];
1296          else
1297              return '';
1298      }
1299  
1300  
1301      /**
1302      *
1303      * @TODO document
1304      *
1305      */
1306  	function get_the_author_uri( $type, $key, $ext, $tab ) {
1307  
1308          if ( isset( $ext['external'] ) && ! empty( $ext['external'] ) )
1309              return $ext['external'];
1310  
1311          if ( isset( $ext['author_url'] ) && ! empty( $ext['author_url'] ) )
1312              return $ext['author_url'];
1313          else
1314              return admin_url();
1315      }
1316  
1317  
1318      /**
1319      *
1320      * @TODO document
1321      *
1322      */
1323  	function get_the_name( $type, $key, $ext, $tab ) {
1324  
1325          if ( isset( $ext['name'] ) && ! empty( $ext['name'] ) )
1326              return $ext['name'];
1327          else
1328              return '';
1329      }
1330  
1331  
1332      /**
1333      *
1334      * @TODO document
1335      *
1336      */
1337  	function get_the_desc( $type, $key, $ext, $tab ) {
1338  
1339          if ( isset( $ext['text'] ) && ! empty( $ext['text'] ) )
1340              return $ext['text'];
1341  
1342          if ( isset( $ext['description'] ) )
1343              return wp_kses( $ext['description'], array() );
1344  
1345          return '';
1346      }
1347  
1348  
1349      /**
1350      *
1351      * @TODO document
1352      *
1353      */
1354  	function get_the_count( $type, $key, $ext, $tab ) {
1355  
1356          if ( isset( $ext['count'] ) && ! empty( $ext['count'] ) )
1357              return $ext['count'];
1358          else
1359              return '0';
1360      }
1361  
1362  
1363      /**
1364      *
1365      * @TODO document
1366      *
1367      */
1368  	function get_the_screen( $type, $key, $ext, $tab ) {
1369  
1370          if ( isset( $ext['screen'] ) && ! empty( $ext['screen'] ) )
1371              return $ext['screen'];
1372          else
1373              return false;
1374      }
1375  
1376  
1377      /**
1378      *
1379      * @TODO document
1380      *
1381      */
1382  	function get_the_object( $type, $key, $ext, $tab ) {
1383  
1384          if ( isset( $ext['class'] ) && ! empty( $ext['class'] ) )
1385              return $ext['class'];
1386          else
1387              return false;
1388      }
1389  
1390  
1391      /**
1392      *
1393      * @TODO document
1394      *
1395      */
1396  	function get_info_url( $type, $key, $ext, $tab ) {
1397  
1398          $slug = ( isset( $ext['slug'] ) ) ? $ext['slug'] : $key;
1399          return sprintf( '%s/%ss/%s/?product_ref=true', PL_STORE_URL, $type, $slug );
1400      }
1401  
1402  
1403      /**
1404      *
1405      * @TODO document
1406      *
1407      */
1408  	function get_demo_url( $type, $key, $ext, $tab ) {
1409  
1410          return ( isset( $ext['demo'] ) ) ? $ext['demo'] : '';
1411  
1412      }
1413  
1414  
1415      /**
1416      *
1417      * @TODO document
1418      *
1419      */
1420  	function get_external_url( $type, $key, $ext, $tab ) {
1421  
1422      if ( isset( $ext['external'] ) )
1423          return $ext['external'];
1424  
1425      if ( isset( $ext['authorurl'] ) )
1426          return $ext['authorurl'];
1427  
1428      }
1429  
1430  
1431      /**
1432      *
1433      * @TODO document
1434      *
1435      */
1436  	function depends_nice_name( $type, $key, $ext, $tab ) {
1437  
1438          if ( isset( $ext['depends'] ) ) {
1439  
1440              if ( $type == 'plugin' ) {
1441  
1442                  $plugins = $this->get_latest_cached( 'plugins' );
1443  
1444                  if ( isset($plugins->$ext['depends']) &&  isset( $plugins->$ext['depends']->name ) )
1445                      return $plugins->$ext['depends']->name;
1446              }
1447          }
1448      }
1449  
1450  
1451      /**
1452      *
1453      * @TODO document
1454      *
1455      */
1456  	function get_master_list( $extension, $type, $tab, $mode = '') {
1457  
1458          $list = array();
1459          foreach( (array) $extension as $key => $ext ) {
1460  
1461              $ext = (array) $ext;
1462  
1463              if( !$this->show_in_tab( $type, $key, $ext, $tab ) )
1464                  continue;
1465  
1466              if ( 'installed' == $mode )
1467                  $array_key = basename( $ext['base_dir'] );
1468              else
1469                  $array_key = $key;
1470  
1471              $list[$array_key] = $this->master_list( $type, $key, $ext, $tab );
1472          }
1473          return ( !empty( $list ) ) ? $list : '';
1474      }
1475  
1476  
1477      /**
1478      *
1479      * @TODO document
1480      *
1481      */
1482  	function get_the_tab( $type, $key, $ext, $tab ) {
1483  
1484          return $tab;
1485  
1486      }
1487  
1488  
1489      /**
1490      *
1491      * @TODO document
1492      *
1493      */
1494  	function master_list( $type, $key, $ext, $tab ) {
1495  
1496          $ext['apiversion'] = ( isset( $ext['apiversion'] ) ) ? $ext['apiversion'] : $ext['version'];
1497  
1498          if ( !isset( $ext['status'] ) )
1499              $ext['status'] = array( 'status' => '' );
1500  
1501          $list = array(
1502                  $type        => $ext,
1503                  'name'         => $this->get_the_name( $type, $key, $ext, $tab ),
1504                  'active'    => $this->is_active( $type, $key, $ext ),
1505                  'version'    => $this->get_the_version( $type, $key, $ext ),
1506                  'desc'        => $this->get_the_desc( $type, $key, $ext, $tab ),
1507                  'tags'        => $this->get_the_tags( $type, $key, $ext, $tab ),
1508                  'image'        => $this->image_path( $type, $key, $ext, $tab ),
1509                  'auth'        => $this->get_the_author( $type, $key, $ext, $tab ),
1510                  'auth_url'    => $this->get_the_author_uri( $type, $key, $ext, $tab ),
1511                  'key'        => $key,
1512                  'type'        => $type,
1513                  'infourl'    => $this->get_info_url( $type, $key, $ext, $tab ),
1514                  'object'    => $this->get_the_object( $type, $key, $ext, $tab ),
1515                  'count'        => $this->get_the_count( $type, $key, $ext, $tab ),
1516                  'screen'    => $this->get_the_screen( $type, $key, $ext, $tab ),
1517                  'actions'    => $this->master_array( $type, $key, $ext, $tab  ),
1518                  'demo'        => $this->get_demo_url( $type, $key, $ext, $tab ),
1519                  'external'    => $this->get_external_url( $type, $key, $ext, $tab ),
1520                  'tab'        => $this->get_the_tab( $type, $key, $ext, $tab )
1521          );
1522  
1523          return $list;
1524      }
1525  
1526  	function updates_list( $args ) {
1527  
1528          $updates = ( array ) get_theme_mod( 'available_updates' );
1529  
1530          $defaults = array(
1531              'list'    =>    array(),
1532              'type'    =>    'plugin'
1533              );
1534          $o = wp_parse_args( $args, $defaults );
1535  
1536          if ( ! is_array( $o['list'] ) )
1537              return;
1538  
1539          if ( 'section' == $o['type'] ) {
1540  
1541              $sections = array();
1542              foreach( $o['list'] as $a => $b ) {
1543  
1544                  if( isset( $b['pid'] ) && $b['pid'] )
1545                      $sections[$b['class']] = array( 'section'    =>    $b );
1546              }
1547              $o['list'] = $sections;
1548          }
1549  
1550          foreach( $o['list'] as $key => $d ) {
1551  
1552              $ext = $d[ $o['type'] ];
1553  
1554              $id = ( $this->is_installed( $o['type'], $key, $ext ) ) ? $this->get_product_id( $ext ) : false;
1555  
1556              if( $id ) {
1557                  $version = $this->get_the_version( $o['type'], $key, $ext );
1558  
1559                  if ( $id && $version )
1560                      $updates[$id] = $version;
1561              }
1562          }
1563      set_theme_mod( 'available_updates', $updates );
1564      }
1565  
1566  } // [END]


Generated: Sat Apr 6 23:00:27 2013 Cross-referenced by PHPXref 0.7.1