include_once HW_HOANGWEB_CLASSES_PATH . '/admin/class-hw-upgrader.php'; //main wp update include_once ABSPATH . '/wp-admin/update.php'; if (isset($_request['action'])) { $plugin = isset($_request['module']) ? trim($_request['module']) : ''; $theme = isset($_request['theme']) ? urldecode($_request['theme']) : ''; $action = isset($_request['action']) ? $_request['action'] : ''; $modules_package = HW_HOANGWEB_PLUGINS . '/modules-package.xml'; //install hw module if ('install-module' == $action) { if (!current_user_can('install_plugins')) { wp_die(__('You do not have sufficient permissions to install plugins on this site.')); } include_once HW_HOANGWEB_UTILITIES . '/admin/module-install.php'; check_admin_referer('install-module_' . $plugin); $api = (object) modules_api('module_information', array('slug' => $plugin)); if (is_wp_error($api)) { wp_die($api); } $title = __('Module Install'); $parent_file = 'plugins.php'; $submenu_file = 'plugin-install.php'; $title = sprintf(__('Installing Module: %s'), $api->name . ' ' . $api->version); $nonce = 'install-plugin_' . $plugin; $url = 'hw-update.php?action=install-module&plugin=' . urlencode($plugin); if (isset($_data['from'])) { $url .= '&from=' . urlencode(stripslashes($_data['from'])); } $type = 'web'; //Install plugin type, From Web or an Upload. $upgrader = new HW_Module_Upgrader(new HW_Module_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')), new HW_Modules_Packages_Upgrader($modules_package));
/** * Display plugin information in dialog box form. * @hook install_plugins_pre_plugin-information */ function hw_install_module_information() { global $tab; if (empty($_REQUEST['module'])) { return; } $api = modules_api('module_information', array('slug' => wp_unslash($_REQUEST['module']), 'is_ssl' => is_ssl(), 'fields' => array('banners' => true, 'reviews' => true, 'downloaded' => false, 'active_installs' => true))); //for testing $api = (object) array('name' => 'HW YARPP', 'version' => '1.0', 'author' => 'hoangweb', 'slug' => 'hw-yarpp', 'last_updated' => time()); if (is_wp_error($api)) { wp_die($api); } $plugins_section_titles = array('description' => _x('Description', 'Plugin installer section title'), 'installation' => _x('Installation', 'Plugin installer section title')); $section = 'description'; // Default to the Description tab, $_tab = 'plugin-information'; //esc_attr( $tab ); because avaiable exists css for 'plugin-information' iframe_header(__('HW Module Install')); echo '<div id="plugin-information-scrollable">'; echo "<div id='{$_tab}-title' class=''><div class='vignette'></div><h2>{$api->name}</h2></div>"; //tabs echo "<div id='{$_tab}-tabs' class=''>\n"; echo "<a href='#' class=''>Tab</a>"; echo "<a href='#' class=''>Tab 1</a>"; echo "</div>\n"; $date_format = __('M j, Y @ H:i'); $last_updated_timestamp = strtotime($api->last_updated); ?> <div id="<?php echo $_tab; ?> -content" class='<?php ?> '> <!-- right info --> <div class="fyi"> <ul> <?php if (!empty($api->version)) { ?> <li><strong><?php _e('Version:'); ?> </strong> <?php echo $api->version; ?> </li> <?php } if (!empty($api->author)) { ?> <li><strong><?php _e('Author:'); ?> </strong> <?php echo links_add_target($api->author, '_blank'); ?> </li> <?php } if (!empty($api->last_updated)) { ?> <li><strong><?php _e('Last Updated:'); ?> </strong> <span title="<?php echo esc_attr(date_i18n($date_format, $last_updated_timestamp)); ?> "> <?php printf(__('%s ago'), human_time_diff($last_updated_timestamp)); ?> </span></li> <?php } if (!empty($api->slug) && empty($api->external)) { ?> <li><a target="_blank" href="https://develop.hoangweb.com/plugins/<?php echo $api->slug; ?> /"><?php _e('Hoangweb.com Plugin Page »'); ?> </a></li> <?php } ?> </ul> </div> <!-- tabs content --> <div id="section-holder" class="wrap"> <?php if (!empty($api->sections)) { foreach ((array) $api->sections as $section_name => $content) { $content = links_add_base_url($content, 'https://develop.hoangweb.com/modules/' . $api->slug . '/'); $content = links_add_target($content, '_blank'); $san_section = esc_attr($section_name); $display = $section_name === $section ? 'block' : 'none'; echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n"; echo $content; echo "\t</div>\n"; } } ?> </div> </div> <?php echo '</div>'; #plugin-information-scrollable echo "<div id='{$tab}-footer'>\n"; if (!empty($api->download_link) && (current_user_can('install_plugins') || current_user_can('update_plugins'))) { $status = _install_plugin_install_status($api); switch ($status['status']) { case 'install': if ($status['url']) { echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>'; } break; case 'update_available': if ($status['url']) { echo '<a data-slug="' . esc_attr($api->slug) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') . '</a>'; } break; } } echo "</div>\n"; iframe_footer(); exit; }