1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915: 916: 917: 918: 919: 920: 921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933: 934: 935: 936: 937: 938: 939: 940: 941: 942: 943: 944: 945: 946: 947: 948: 949: 950: 951: 952: 953: 954: 955: 956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970: 971:
<?php
class Inbound_Pro_Downloads {
static $management_mode;
static $items;
static $downloads;
static $download;
static $headline;
static $customer;
static $access_level;
public function __construct() {
self::add_hooks();
}
public static function add_hooks() {
add_action( 'admin_init' , array( __CLASS__ , 'run_management_actions' ) );
add_action( 'admin_enqueue_scripts' , array( __CLASS__ , 'enqueue_scripts' ) );
add_action( 'admin_footer' , array( __CLASS__ , 'load_inline_js_css' ) );
add_action( 'inbound-pro/check-for-updates' , array( __CLASS__ , 'cron_check_for_updates' ) );
add_action('admin_notices', array( __CLASS__ , 'check_open_base_dir' ) );
}
public static function enqueue_scripts() {
$screen = get_current_screen();
if ( ( isset($screen) && ( $screen->base != 'inbound-pro_page_inbound-manage-templates' && $screen->base != 'inbound-pro_page_inbound-manage-extensions' ) ) ){
return;
}
wp_enqueue_script('jquery');
wp_enqueue_script('underscore');
wp_enqueue_script('shuffle', INBOUND_PRO_URLPATH . 'assets/libraries/Shuffle/jquery.shuffle.modernizr.min.js' , array( 'jquery') );
wp_enqueue_script('bootstrap', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/BootStrap/js/bootstrap.min.js');
wp_enqueue_style('bootstrap', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/BootStrap/css/bootstrap.min.css');
wp_enqueue_style('manage-downloads', INBOUND_PRO_URLPATH . 'assets/css/admin/manage-downloads.css');
wp_enqueue_style('fontawesome', INBOUNDNOW_SHARED_URLPATH . 'assets/fonts/fontawesome/css/font-awesome.min.css');
wp_enqueue_script('manage-downloads', INBOUND_PRO_URLPATH . 'assets/js/admin/manage-downloads.js' );
$memory = Inbound_Options_API::get_option( 'inbound-pro' , 'memory' , array() );
$meta_filter = ( isset( $memory[ 'meta_filter'] ) ) ? $memory[ 'meta_filter'] : 'uninstalled' ;
self::build_main_dataset();
wp_localize_script( 'manage-downloads', 'downloads' , array( 'meta_filter' => $meta_filter , 'plugin_url_path' => INBOUND_PRO_URLPATH , 'dataset' => self::$downloads , 'current_page' => $_GET['page'] ) );
}
public static function run_management_actions() {
if (!isset($_REQUEST['action']) || !current_user_can('activate_plugins') ) {
return;
}
switch ($_REQUEST['action']):
case 'install':
self::run_installation();
break;
case 'upgrade':
break;
case 'uninstall':
self::run_uninstallation();
break;
endswitch;
}
public static function run_installation() {
global $download_name;
if ( ! current_user_can('delete_plugins') ) {
wp_die( __('You do not have sufficient permissions to delete plugins for this site.') );
}
$filename = ( isset($filename) && $filename ) ? $filename : $_REQUEST['filename'];
$download_type = ( isset($download_type) && $download_type ) ? $download_type : $_REQUEST['filename'];
self::build_main_dataset();
self::$download = self::$downloads[ $_REQUEST['download_name'] ];
self::$download['download_location'] = Inbound_API_Wrapper::get_download_zip( self::$download );
self::$download['extraction_path'] = self::get_upload_path( self::$download );
self::install_download( self::$download );
$download_name = self::$download[ 'post_title' ];
add_action( 'admin_notices', function( ) {
global $download_name;
?>
<br>
<div class="updated">
<p><?php _e( $download_name . ' has been installed!', 'inbound-pro' ); ?></p>
</div>
<?php
} );
self::update_configuration_memory('installed');
$memory = Inbound_Options_API::get_option( 'inbound-pro' , 'memory' , array() );
$memory['meta_filter'] = 'installed';
Inbound_Options_API::update_option( 'inbound-pro' , 'memory' , $memory );
}
public static function run_uninstallation() {
global $download_name;
if ( ! current_user_can('delete_plugins') ) {
wp_die( __('You do not have sufficient permissions to delete plugins for this site.') );
}
self::build_main_dataset();
self::$download = self::$downloads[ $_REQUEST['download_name'] ];
self::$download['extraction_path'] = self::get_upload_path( self::$download );
self::delete_download_folder( self::$download['extraction_path'] );
$download_name = self::$download[ 'post_title' ];
add_action( 'admin_notices', function() {
global $download_name;
?>
<br>
<div class="updated">
<p><?php _e( $download_name . ' has been uninstalled!', 'inbound-pro' ); ?></p>
</div>
<?php
} );
self::update_configuration_memory('uninstalled');
$memory = Inbound_Options_API::get_option( 'inbound-pro' , 'memory' , array() );
$memory['meta_filter'] = 'uninstalled';
Inbound_Options_API::update_option( 'inbound-pro' , 'memory' , $memory );
}
public static function install_download( $download ) {
include_once( ABSPATH . '/wp-admin/includes/class-pclzip.php');
self::delete_download_folder( $download['extraction_path'] );
$temp_file = tempnam(sys_get_temp_dir(), 'TEMPPLUGIN' );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $download['download_location'] );
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$file = curl_exec($ch);
curl_close($ch);
$handle = fopen($temp_file, "w");
fwrite($handle, $file);
fclose($handle);
if(!isset($download['filename']) || !$download['filename']) {
$download['filename'] = $download['post_name'];
} else {
$download['filename'] = str_replace('.zip' , '' , $download['filename']);
}
$archive = new PclZip($temp_file);
$result = $archive->extract( PCLZIP_OPT_REMOVE_PATH, $download['filename'] , PCLZIP_OPT_PATH, $download['extraction_path'] , PCLZIP_OPT_REPLACE_NEWER );
if ($result == 0) {
die("Error : ".$archive->errorInfo(true));
}
unlink($temp_file);
}
public static function delete_download_folder( $dirPath ) {
if ( !$dirPath || !is_dir($dirPath)) {
return;
}
$objects = scandir($dirPath);
if ( in_array( '.git' , $objects ) ) {
return;
}
foreach ($objects as $object) {
if ($object != "." && $object !="..") {
if (filetype($dirPath . DIRECTORY_SEPARATOR . $object) == "dir") {
self::delete_download_folder($dirPath . DIRECTORY_SEPARATOR . $object);
} else {
unlink($dirPath . DIRECTORY_SEPARATOR . $object);
}
}
}
reset($objects);
rmdir($dirPath);
}
public static function build_main_dataset() {
self::load_management_vars();
$configuration= Inbound_Options_API::get_option('inbound-pro', 'configuration', array());
$i=0;
foreach (self::$items as $key => $download ) {
self::$downloads[ $download['post_name'] ] = $download;
$download['plugins'][] = 'all';
self::$downloads[ $download['post_name'] ]['plugins'] = $download['plugins'];
self::$downloads[ $download['post_name'] ]['status'][] = ( isset($configuration[ $download['post_name'] ]['status'] ) ) ? $configuration[ $download['post_name'] ]['status'] : 'uninstalled' ;
self::$downloads[ $download['post_name'] ]['current_version'] = ( isset($configuration[ $download['post_name'] ]['current_version'] ) ) ? $configuration[ $download['post_name'] ]['current_version'] : '' ;
$prev = $i-1;
$next = $i+1;
self::$downloads[ $download['post_name'] ]['previous_post_name'] = (isset(self::$items[$prev]['post_name'])) ? self::$items[$prev]['post_name'] : self::$items[0]['post_name'];
self::$downloads[ $download['post_name'] ]['next_post_name'] = (isset(self::$items[$next]['post_name'])) ? self::$items[$next]['post_name'] : self::$items[0]['post_name'];
$i++;
}
return self::$downloads;
}
public static function update_configuration_memory( $status ) {
$configuration = Inbound_Options_API::get_option( 'inbound-pro' , 'configuration' , array() );
$configuration[ self::$download['post_name'] ]['status'] = $status;
if ($status == 'installed') {
$configuration[ self::$download['post_name'] ]['download_type'] = self::$download['download_type'];
$configuration[ self::$download['post_name'] ]['current_version'] = self::$download['server_version'];
$configuration[ self::$download['post_name'] ]['upload_path'] = self::get_upload_path( self::$download );
$configuration[ self::$download['post_name'] ]['filename'] = self::$download['filename'];
}
Inbound_Options_API::update_option( 'inbound-pro' , 'configuration' , $configuration , 'yes' );
}
public static function test_ui() {
self::build_main_dataset();
self::grid_container();
}
public static function grid_container() {
$showAll = true;
$showLP = false;
$showCTA = false;
$showLeads = false;
$showEmail = false;
$openTab = 0;
if (isset($_GET['show'])) {
$showAll = false;
if( $_GET['show'] === "landing-pages" ) {
$showLP = true;
$openTab = 1;
} else if( $_GET['show'] === "leads" ) {
$showLeads = true;
$openTab = 2;
} else if( $_GET['show'] === "cta" ) {
$showCTA = true;
$openTab = 3;
} else if( $_GET['show'] === "email" ) {
$showEmail = true;
$openTab = 4;
}
}
$AllTabClass = ($showAll) ? 'tab-current' : '';
$allClass = ($showAll) ? 'content-current' : '';
$leadsTabClass = ($showLeads) ? 'tab-current' : '';
$leadsClass = ($showLeads) ? 'content-current' : '';
$emailTabClass = ($showEmail) ? 'tab-current' : '';
$emailClass = ($showEmail) ? 'content-current' : '';
$ctaTabClass = ($showCTA) ? 'tab-current' : '';
$ctaClass = ($showCTA) ? 'content-current' : '';
$lpTabClass = ($showLP) ? 'tab-current' : '';
$lpClass = ($showLP) ? 'content-current' : '';
?>
<link rel='stylesheet' id='edd-styles-css' href='/wp-content/plugins/_inbound-pro/assets/css/store.css' type='text/css' media='all' />
<!--START -->
<div id="tabs" class="tabs">
<nav>
<ul>
<li class="<?php echo $AllTabClass; ?>"><a href="#section-1" ><span>All</span></a></li>
<li class="<?php echo $lpTabClass; ?>"><a href="#section-2" class="icon-article"><span>Landing Pages</span></a></li>
<li class="<?php echo $leadsTabClass; ?>"><a href="#section-3" class="icon-user"><span>Leads</span></a></li>
<li class="<?php echo $ctaTabClass; ?>"><a href="#section-4" class="icon-eye"><span>Calls to Action</span></a></li>
<li class="<?php echo $emailTabClass;?>"><a href="#section-5" class="fa fa-envelope-o"><span>Email</span></a></li>
</ul>
</nav>
<div class="content" id="market-content">
<section id="section-1" class="<?php echo $allClass;?>">
<div class="store-container">
<div class="main">
<span class="center-text area-desc">From email marketing to CRMs these add-ons will make your life easier</span>
<div id="cbp-vm" class="cbp-vm-switcher cbp-vm-view-grid">
<div class="cbp-vm-options">
<span>Change View</span>
<a href="#" class="cbp-vm-icon cbp-vm-grid cbp-vm-selected" data-view="cbp-vm-view-grid">Grid View</a>
<a href="#" class="cbp-vm-icon cbp-vm-list" data-view="cbp-vm-view-list">List View</a>
</div>
<?php self::store_listings();?>
</div>
</div><!-- /main -->
</div><!-- /store container -->
</section>
</div><!-- /content -->
</div>
<!-- END -->
<?php }
public static function store_listings($slug = 'default') {
?>
<ul>
<?php $count = 0;
foreach (self::$downloads as $download) {
$id = $download['ID'];
$title = $download['post_title'];
$title_class = (strlen($title) > 30 ) ? "long-title" : 'short-title';
$exerpt = $download['post_excerpt'];
$link = $download['permalink'];
$terms = get_the_terms( $id, 'download_category' ); ?>
<li class="">
<?php $img = $download['featured_image'];
if(!$img){
$img = '<img src="http://inboundnew.dev/wp-content/uploads/2014/08/medium_wype-1.jpg">';
}
?>
<a class="cbp-vm-image" href="<?php echo $link;?>"><img src="<?php echo $img;?>"/></a>
<!--<div class="cbp-vm-price">$19.90</div>-->
<div class="cbp-vm-details">
<h3 class="cbp-vm-title <?php echo $title_class;?>"><a href="<?php echo $link;?>"><?php echo $title;?></a></h3>
<span class='details-text'>
<?php
if( $exerpt != "" ) :
echo $exerpt;
else :
echo "short description This is the headline text. This is the headline text. more text here. Testing testing";
endif;
?>
</span>
</div>
<a class="cbp-vm-icon cbp-vm-add" href="<?php echo $link; ?>">Add to cart</a>
</li>
<?php $count++; ?>
<?php }
?>
<!--<div id="load_more">Load More</div> -->
</ul>
<?php
}
public static function check_open_base_dir() {
global $post , $inbound_settings;
if (!isset($_GET['page'])|| ( $_GET['page']!='inbound-manage-extensions' && $_GET['page']!='inbound-manage-templates' ) ){
return false;
}
if ( !ini_get('open_basedir') ) {
return;
}
?>
<div class="updated">
<p><?php _e( 'ATTENTION: open_basedir restriction in effect which will cause problems with installation.' , 'inbound-pro'); ?></p>
</div>
<?php
}
public static function display_ui() {
self::build_main_dataset();
self::display_filters( );
self::display_grid_items();
}
public static function display_filters() {
?>
<div class="filter-options row">
<div class="col-xs-12 col-md-12">
<div class="templates-filter-group left-group">
<h5 class="filter-label"><?php echo self::$headline; ?></h5>
<button class="btn btn-go" data-filter-value="all"><span class="visuallyhidden"><?php _e( 'All' , 'inbound-pro' ); ?></span></button>
<button class="btn btn-primary" data-filter-value="landing-pages"><span class="visuallyhidden"><?php _e( 'Landing Pages' , 'inbound-pro' ); ?></span></button>
<button class="btn btn-warning" data-filter-value="calls-to-action"><span class="visuallyhidden"><?php _e( 'Calls to Action' , 'inbound-pro' ); ?></span></button>
<?php
if ( self::$management_mode == 'extensions' ) {
?>
<button class="btn btn-success" data-filter-value="leads"><span class="visuallyhidden"><?php _e( 'Leads' , 'inbound-pro' ); ?></span></button>
<button class="btn btn-danger" data-filter-value="automation"><span class="visuallyhidden"><?php _e( 'Automation' , 'inbound-pro' ); ?></span></button>
<?php
}
?>
<button class="btn btn-info" data-filter-value="email"><span class="visuallyhidden"><?php _e( 'Email' , 'inbound-pro' ); ?></span></button>
</div>
</div>
<div class="col-xs-12 col-md-12 right-group">
<div class='templates-filter-group align-left '>
<input class="filter-search" type="search" placeholder="<?php _e(' Search... ' , 'inbound-pro' ); ?>">
<div class='radio-filters'>
<span class="ib">
<label class='filter-label' for="uninstalled"><input type="radio" name="meta" value="uninstalled" class='radio-filter'> <?php _e( 'Uninstalled' , 'inbound-pro' ); ?></label>
</span>
<span class="ib">
<label class='filter-label' for="installed"><input type="radio" name="meta" value="installed" class='radio-filter'> <?php _e( 'Installed' , 'inbound-pro' ); ?></label>
</span>
<span class="ib">
<label class='filter-label' for="needs-update"><input type="radio" name="meta" value="needs-update" class='radio-filter'> <?php _e( 'Needs Update' , 'inbound-pro' ); ?></label>
</span>
</div>
</div>
</div>
</div>
<?php
}
public static function display_grid_items() {
global $inbound_settings;
$page = sanitize_text_field($_GET['page']);
$inbound_settings['system']['counts']['needs-update'][self::$management_mode] = 0;
?>
<div class="wrap">
<?php
?>
<div id="grid" class="container-fluid">
<?php $count = 1;
$permitted = false;
if (INBOUND_ACCESS_LEVEL > 0 && INBOUND_ACCESS_LEVEL != 9 ) {
$permitted = true;
}
foreach (self::$downloads as $download) {
if ($count % 3 == 0) {
echo "<div></div>";
}
$count++;
if ( version_compare( $download['current_version'] , $download['server_version']) == -1 && !in_array('uninstalled', $download['status']) ) {
$download['status'][] = 'needs-update';
$inbound_settings['system']['counts']['needs-update'][self::$management_mode]++;
}
?>
<div class="row col-md-2 col-xs-2 download-item " data-plugins='<?php echo json_encode( $download['plugins'] ); ?>' data-meta='<?php echo json_encode( $download['status'] ); ?>' >
<?php
$ribbons = array();
if ( in_array( 'landing-pages' , $download['plugins'] ) ) {
$ribbons['landing-pages']['ribbon'] = 'lp-ribbon';
$ribbons['landing-pages']['fa'] = 'fa-file-text-o';
$ribbons['landing-pages']['title'] = __( 'Landing Page' , 'inbound-pro' );
}
if ( in_array( 'calls-to-action' , $download['plugins'] ) ) {
$ribbons['calls-to-action']['ribbon'] = 'cta-ribbon';
$ribbons['calls-to-action']['fa'] = 'fa-crosshairs';
$ribbons['calls-to-action']['title'] = __( 'Call to Action' , 'inbound-pro' );
}
if ( in_array( 'leads' , $download['plugins'] ) ) {
$ribbons['leads']['ribbon'] = 'leads-ribbon';
$ribbons['leads']['fa'] = 'fa-users';
$ribbons['leads']['title'] = __( 'Leads' , 'inbound-pro' );
}
if ( in_array( 'email' , $download['plugins'] ) ) {
$ribbons['email']['ribbon'] = 'mail-ribbon';
$ribbons['email']['fa'] = 'fa-envelope-o';
$ribbons['email']['title'] = __( 'Email' , 'inbound-pro' );
}
if ( in_array( 'automation' , $download['plugins'] ) ) {
$ribbons['automation']['ribbon'] = 'automation-ribbon';
$ribbons['automation']['fa'] = 'fa-cog';
$ribbons['automation']['title'] = __( 'Email' , 'inbound-pro' );
}
$i = 0;
foreach ($ribbons as $key => $ribbon) {
echo '<div class="download-ribbon '.$ribbon['ribbon'].' ribbon-'.$i.'" title="'.$ribbon['title'].'" data-toggle="tooltip" data-placement="left" >
<div class="border-ribbon"></div>
<a class="fa '.$ribbon['fa'].'"></a>
</div>';
$i++;
}
?>
<div class="download-image" style='background-image:url(<?php echo self::get_image_thumbnail($download); ?>);' >
</div>
<div class="col-template-content more-details" data-download='<?php echo $download['post_name']; ?>' data-toggle="tooltip" data-placement="top" data-original-title='<?php _e( 'View Details' , 'inbound-pro' ); ?>'>
<div class="col-template-info-title"><?php echo $download['post_title']; ?></div>
</div>
<div class="col-template-actions">
<?php
if ( in_array( 'uninstalled' , $download['status'] )&& $permitted ) {
?>
<div class="action-install">
<a href="admin.php?page=<?php echo $page; ?>&action=install&download_name=<?php echo $download['post_name']; ?>&download_type=<?php echo $download['download_type']; ?>&filename=<?php echo $download['filename']; ?>" class="power-toggle power-is-off fa fa-power-off" data-toggle="tooltip" id='<?php echo $download['post_name']; ?>' title='<?php _e( 'Turn On' , 'inbound-pro' ); ?>'></a>
</div>
<?php
}
if ( in_array( 'installed' , $download['status'] ) && $permitted ) {
?>
<div class="action-uninstall">
<a href="admin.php?page=<?php echo $page; ?>&action=uninstall&download_name=<?php echo $download['post_name']; ?>&filename=<?php echo $download['filename']; ?>" class="power-toggle power-is-on fa fa-power-off" data-toggle="tooltip" id='<?php echo $download['post_name']; ?>' title='<?php _e( 'Turn Off' , 'inbound-pro' ); ?>'></a>
</div>
<?php
if ( in_array( 'needs-update' , $download['status'] ) ) {
?>
<div class="action-update">
<a href="admin.php?page=<?php echo $page; ?>&action=install&download_name=<?php echo $download['post_name']; ?>&download_type=<?php echo $download['download_type']; ?>&filename=<?php echo $download['filename']; ?>" class="fa fa-floppy-o" data-toggle="tooltip" id='<?php echo $download['post_name']; ?>' title='<?php _e( 'Update' , 'inbound-pro' ); ?>'></a>
</div>
<?php
}
if ($download['download_type'] == 'extension' ) {
$settings_url = apply_filters(
'inbound-pro/download-setting-url' ,
add_query_arg( array( 'page'=>'inbound-pro' , 'tab' => 'inbound-pro-settings' , 'setting' => $download['filename'] ) , admin_url( 'admin.php' ) )
, $download );
?>
<div class="action-settings">
<a target="_blank" href="<?php echo $settings_url; ?>" class="fa fa-cog" data-toggle="tooltip" id='<?php echo $download['post_name']; ?>' title='<?php _e( 'View Settings' , 'inbound-pro' ); ?>'></a>
</div>
<?php
}
}
if (!$permitted) {
?>
<div class="action-locked">
<i class="fa fa-lock" data-toggle="tooltip" id='' title='<?php _e( 'Only available to subscribers.' , 'inbound-pro' ); ?>'></i>
</div>
<?php
}
?>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php
Inbound_Options_API::update_option('inbound-pro', 'settings', $inbound_settings);
}
public static function get_download_status() {
}
public static function get_upload_path( $download ) {
$folder_name = ( isset($download['filename']) ) ? $download['filename'] : $download['post_name'];
$folder_name = str_replace('.zip' , '' , $folder_name );
if ( $download['download_type'] == 'extension' ) {
return INBOUND_PRO_UPLOADS_PATH . 'extensions/'. $folder_name;
}
if ( in_array( 'calls-to-action' , $download[ 'plugins' ] ) ) {
return WP_CTA_UPLOADS_PATH . $folder_name . '/';
}
if ( in_array( 'landing-pages' , $download[ 'plugins' ] ) ) {
return LANDINGPAGES_UPLOADS_PATH . $folder_name . '/';
}
if ( in_array( 'email' , $download[ 'plugins' ] ) ) {
return INBOUND_EMAIL_UPLOADS_PATH . $folder_name . '/';
}
}
public static function get_image_thumbnail($download) {
global $inbound_paths_created;
$path = INBOUND_PRO_UPLOADS_PATH . 'assets/images/';
$url = INBOUND_PRO_UPLOADS_URLPATH . 'assets/images/';
if(strstr( $download['featured_image'] , '.png')){
$ext = '.png';
}else if(strstr( $download['featured_image'] , '.jpg')){
$ext = '.jpg';
}
if(file_exists( $path . $download['post_name'] . $ext)){
return $url . $download['post_name'] .$ext;
}
$image_path_location = $path . $download['post_name'] . $ext;
$image_url_location = $url . $download['post_name'] . $ext;
if (!$inbound_paths_created) {
$inbound_paths_created = true;
Inbound_Pro_Activation::create_upload_folders();
}
$image_path_location = $path . $download['post_name'] . $ext;
$image_url_location = $url . $download['post_name'] . $ext;
if (!$inbound_paths_created) {
$inbound_paths_created = true;
Inbound_Pro_Activation::create_upload_folders();
}
$file = wp_remote_get($download['featured_image']);
$image = wp_remote_retrieve_body($file);
$handle = fopen($image_path_location, "w");
fwrite($handle, $image);
fclose($handle);
return $image_url_location;
}
public static function load_management_vars( ) {
$page = (isset($_REQUEST['page'])) ? $_REQUEST['page'] : 'inbound-manage-extensions';
switch( $page ) {
case 'inbound-manage-templates':
self::$management_mode = 'templates';
self::$headline = __( 'Manage Templates' , 'inbound-pro' );
self::$items = Inbound_API_Wrapper::get_pro_templates();
break;
case 'inbound-manage-extensions':
self::$management_mode = 'extensions';
self::$headline = __( 'Manage Extensions' , 'inbound-pro' );
self::$items = Inbound_API_Wrapper::get_pro_extensions();
break;
default:
Inbound_API_Wrapper::get_downloads();
self::$items = array();
break;
}
}
public static function load_inline_js_css() {
$screen = get_current_screen();
if ( $screen->base != 'inbound-pro_page_inbound-manage-templates' && $screen->base != 'inbound-pro_page_inbound-manage-extensions' ) {
return;
}
$memory = Inbound_Options_API::get_option( 'inbound-pro' , 'memory' , array() );
$meta_filter = ( isset( $memory[ 'meta_filter'] ) ) ? $memory[ 'meta_filter'] : 'uninstalled' ;
?>
<script>
jQuery(document).ready(function() {
});
</script>
<?php
if ( intval(INBOUND_ACCESS_LEVEL) < 3) {
?>
<style type="text/css">
body .details-install {
display:none !important;
}
body .details-update {
display:none !important;
}
<?php
if ($screen->base == 'inbound-pro_page_inbound-manage-extensions') {
?>
body .details-preview {
display: none !important;
}
<?php
}
?>
</style>
<?php
}
}
public static function cron_check_for_updates() {
global $inbound_settings;
$configuration = Inbound_Options_API::get_option( 'inbound-pro' , 'configuration' , array() );
$inbound_settings['system']['counts']['needs-update']['extensions'] = 0;
$inbound_settings['system']['counts']['needs-update']['templates'] = 0;
$data = Inbound_API_Wrapper::get_downloads();
foreach ( $data as $key => $download ) {
if (!isset($download->post_name)) {
continue;
}
$status = ( isset($configuration[ $download->post_name ]['status'] ) ) ? $configuration[ $download->post_name ]['status'] : 'uninstalled' ;
if($status=='uninstalled') {
continue;
}
if ( isset($download->download_type) && $download->download_type == 'extension' ) {
$extensions[] = (array) $download;
}
if ( version_compare( $configuration[ $download->post_name ]['current_version'] , $download->server_version) == -1 ) {
$inbound_settings['system']['update-count'][self::$management_mode]++;
}
}
Inbound_Options_API::update_option('inbound-pro', 'settings', $inbound_settings);
}
}
function load_Inbound_Pro_Downloads() {
$Inbound_Pro_Downloads = new Inbound_Pro_Downloads;
}
add_action( 'init' , 'load_Inbound_Pro_Downloads' );