<th><?php 
    _e('Latest (V)', 'wpdmpro');
    ?>
</th>
                            <th><?php 
    _e('Download', 'wpdmpro');
    ?>
</th>
                        </tr>
                        </thead>
                        <tbody>
                    <?php 
    foreach ($freeaddons->post_extra as $addon) {
        $file = $addon->pinfo->files[0];
        $plugin_name = str_replace(".zip", "", basename($file));
        $plugin_data = wpdm_plugin_data($plugin_name);
        ?>

                        <tr class="<?php 
        if (isset($latest[$plugin_name])) {
            echo version_compare($latest[$plugin_name], $plugin_data['Version'], '>') ? 'bg-warning' : (!$plugin_data ? '' : 'bg-success');
        }
        ?>
">
                            <td><a href="<?php 
        echo $addon->link;
        ?>
" target="_blank"><?php 
        echo $addon->title;
        ?>
</a></td>
Exemplo n.º 2
0
function wpdm_check_update()
{
    if (!current_user_can('manage_options')) {
        return;
    }
    $latest = '';
    //get_option('wpdm_latest');
    $latest_check = get_option('wpdm_latest_check');
    $time = time() - intval($latest_check);
    $plugins = get_plugins();
    $latest_v_url = 'http://www.wpdownloadmanager.com/versions.php';
    if ($latest == '' || $time > 86400) {
        $latest = remote_get($latest_v_url);
        update_option('wpdm_latest', $latest);
        update_option('wpdm_latest_check', time());
    }
    $latest = maybe_unserialize($latest);
    $page = isset($_REQUEST['page']) ? esc_attr($_REQUEST['page']) : '';
    $plugin_info_url = isset($_REQUEST['plugin_url']) ? $_REQUEST['plugin_url'] : 'http://www.wpdownloadmanager.com/purchases/';
    foreach ($latest as $plugin_dir => $latestv) {
        $plugin_data = wpdm_plugin_data($plugin_dir);
        if (version_compare($plugin_data['Version'], $latestv, '<') == true) {
            $plugin_name = $plugin_data['Name'];
            $plugin_info_url = $plugin_data['PluginURI'];
            $trid = sanitize_title($plugin_name);
            if ($trid != '') {
                if ($page == 'plugins') {
                    echo <<<NOTICE
     <script type="text/javascript">
      jQuery(function(){
        jQuery('tr#{$trid}').addClass('update').after('<tr class="plugin-update-tr"><td colspan=3 class="plugin-update colspanchange"><div style="background:#D54E21;border-top:0px;padding:5px 15px;color:#fff">There is a new version of {$plugin_name} available. <b><a href="{$plugin_info_url}#{$latestv}" style="color:#fff;float: right;background: rgba(0,0,0,0.2);padding: 5px 15px;margin-top:-5px;margin-right: -15px" target=_blank>Download v{$latestv}  <i class="fa fa-long-arrow-right"></i></a></b></div></td></tr>');
      });
      </script>
NOTICE;
                } else {
                    echo <<<NOTICE
     <script type="text/javascript">
      jQuery(function(){
        jQuery('.wrap > h2').after('<div class="updated error" style="margin:10px 0px;padding:10px;border:2px solid #dd3d36;border-radius:4px;background: #ffffff"><div style="float:left;"><b style="color:#dd3d36;">Important!</b><br/>There is a new version of <u>{$plugin_name}</u> available.</div> <a style="border-radius:2px;float:right;display:inline-table;color:#ffffff;background:#D54E21;padding:10px 15px" href="{$plugin_info_url}#{$latestv}"  target=_blank>Download v{$latestv}  <i class="fa fa-long-arrow-right"></i></a><div style="clear:both"></div></div>');
         });
         </script>
NOTICE;
                }
            }
        }
    }
    if (wpdm_is_ajax()) {
        die;
    }
}
 /**
  * @usage Single click add-on install
  */
 function installAddon()
 {
     if (isset($_POST['updateurl']) && current_user_can(WPDM_ADMIN_CAP)) {
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         $upgrader = new \Plugin_Upgrader(new \Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
         $downloadlink = $_POST['updateurl'] . '&preact=login&user='******'__wpdm_suname') . '&pass='******'__wpdm_supass');
         $upgrader->install($downloadlink);
         $plugininfo = wpdm_plugin_data($_POST['plugin']);
         if (file_exists(dirname(WPDM_BASE_DIR) . '/' . $plugininfo['plugin_index_file'])) {
             activate_plugin($plugininfo['plugin_index_file']);
         }
         die("Installed Successfully");
     } else {
         die("Only site admin is authorized to install add-on");
     }
 }
Exemplo n.º 4
0
function wpdm_check_update()
{
    if (!current_user_can(WPDM_ADMIN_CAP)) {
        return;
    }
    $latest = '';
    //get_option('wpdm_latest');
    $latest_check = get_option('wpdm_latest_check');
    $time = time() - intval($latest_check);
    $plugins = get_plugins();
    $latest_v_url = 'http://www.wpdownloadmanager.com/versions.php';
    if ($latest == '' || $time > 86400) {
        $latest = remote_get($latest_v_url);
        update_option('wpdm_latest', $latest);
        update_option('wpdm_latest_check', time());
    }
    $latest = maybe_unserialize($latest);
    $page = isset($_REQUEST['page']) ? esc_attr($_REQUEST['page']) : '';
    $plugin_info_url = isset($_REQUEST['plugin_url']) ? $_REQUEST['plugin_url'] : 'http://www.wpdownloadmanager.com/purchases/';
    if (is_array($latest)) {
        foreach ($latest as $plugin_dir => $latestv) {
            $plugin_data = wpdm_plugin_data($plugin_dir);
            $wpdmfree = $plugin_dir == 'download-manager' && version_compare($plugin_data['Version'], '3.0.0', '<');
            if (version_compare($plugin_data['Version'], $latestv, '<') == true && !$wpdmfree) {
                $plugin_name = $plugin_data['Name'];
                $plugin_info_url = $plugin_data['PluginURI'];
                $trid = sanitize_title($plugin_name);
                $plugin_update_url = admin_url('/edit.php?post_type=wpdmpro&page=settings&tab=plugin-update&plugin=' . $plugin_dir);
                //'http://www.wpdownloadmanager.com/purchases/?'; //
                if ($trid != '') {
                    if ($page == 'plugins') {
                        echo <<<NOTICE
     <script type="text/javascript">
      jQuery(function(){
        jQuery('tr#{$trid}').addClass('update').after('<tr class="plugin-update-tr"><td colspan=3 class="plugin-update colspanchange"><div class="update-message">There is a new version of <strong>{$plugin_name}</strong> available. <b><a href="{$plugin_update_url}&v={$latestv}" style="color: #D54E21;margin-left:10px" target=_blank>[ Update v{$latestv} ]</a></b></div></td></tr>');
      });
      </script>
NOTICE;
                    } else {
                        echo <<<NOTICE
     <script type="text/javascript">
      jQuery(function(){
        jQuery('.wrap > h2').after('<div class="updated error" style="margin:10px 0px;padding:10px;border:2px solid #dd3d36;border-radius:4px;background: #ffffff"><div style="float:left;"><b style="color:#dd3d36;">Important!</b><br/>There is a new version of <u>{$plugin_name}</u> available.</div> <a style="border-radius:2px; float:right;;color:#ffffff; background: #D54E21;padding:10px 15px" href="{$plugin_update_url}&v={$latestv}"  target=_blank>Update v{$latestv}  <i class="fa fa-long-arrow-right"></i></a><div style="clear:both"></div></div>');
         });
         </script>
NOTICE;
                    }
                }
            }
        }
    }
    if (wpdm_is_ajax()) {
        die;
    }
}