| @@ -60,16 +60,30 @@ | ||
| 60 | 60 | add_action('admin_init', array($this, 'reset')); |
| 61 | 61 | add_action('admin_menu', array($this, 'add_tools_menu')); |
| 62 | 62 | add_action('admin_action_install_wpr', array($this, 'install_wpr')); |
| 63 | 63 | |
| 64 | - add_filter('install_plugins_table_api_args_featured', array($this, 'featured_plugins_tab')); | |
| 65 | - add_filter('install_plugins_table_api_args_recommended', array($this, 'featured_plugins_tab')); | |
| 66 | 64 | add_filter('plugin_action_links_' . plugin_basename(DB_RESET_FILE), array($this, 'plugin_action_links')); |
| 67 | 65 | add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2); |
| 68 | 66 | add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
| 67 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); | |
| 69 | 68 | } |
| 70 | 69 | |
| 70 | + public function admin_enqueue_scripts() { | |
| 71 | + $current_screen = get_current_screen(); | |
| 72 | + if ($current_screen->id != 'plugins') { | |
| 73 | + return; | |
| 74 | + } | |
| 71 | 75 | |
| 76 | + wp_enqueue_script('db-reset', plugins_url('assets/js/database-reset-plugins.js', __FILE__), array('jquery'), $this->version, true); | |
| 77 | + | |
| 78 | + $vars = array(); | |
| 79 | + $vars['info_link'] = admin_url('plugin-install.php?tab=plugin-information&plugin=wp-reset&TB_iframe=true&width=600&height=800'); | |
| 80 | + $vars['install_link'] = wp_nonce_url(add_query_arg(array('action' => 'install-plugin', 'plugin' => 'wp-reset'), admin_url('update.php')), 'install-plugin_wp-reset'); | |
| 81 | + | |
| 82 | + wp_localize_script('db-reset', 'db_reset', $vars); | |
| 83 | + } // admin_enqueue | |
| 84 | + | |
| 85 | + | |
| 72 | 86 | // additional powered by text in admin footer; only on plugin's page |
| 73 | 87 | static function admin_footer_text($text) |
| 74 | 88 | { |
| 75 | 89 | $current_screen = get_current_screen(); |
| @@ -106,69 +120,8 @@ | ||
| 106 | 120 | } |
| 107 | 121 | |
| 108 | 122 | return $links; |
| 109 | 123 | } // plugin_meta_links |
| 110 | - | |
| 111 | - | |
| 112 | - // helper function for adding plugins to fav list | |
| 113 | - function featured_plugins_tab($args) | |
| 114 | - { | |
| 115 | - add_filter('plugins_api_result', array($this, 'plugins_api_result'), 10, 3); | |
| 116 | - | |
| 117 | - return $args; | |
| 118 | - } // featured_plugins_tab | |
| 119 | - | |
| 120 | - | |
| 121 | - // add our plugins to recommended list | |
| 122 | - function plugins_api_result($res, $action, $args) | |
| 123 | - { | |
| 124 | - remove_filter('plugins_api_result', array($this, 'plugins_api_result'), 10, 3); | |
| 125 | - | |
| 126 | - $res = $this->add_plugin_favs('under-construction-page', $res); | |
| 127 | - $res = $this->add_plugin_favs('simple-author-box', $res); | |
| 128 | - $res = $this->add_plugin_favs('eps-301-redirects', $res); | |
| 129 | - | |
| 130 | - return $res; | |
| 131 | - } // plugins_api_result | |
| 132 | - | |
| 133 | - | |
| 134 | - function add_plugin_favs($plugin_slug, $res) | |
| 135 | - { | |
| 136 | - // check if plugin is already on the list | |
| 137 | - if (!empty($res->plugins) && is_array($res->plugins)) { | |
| 138 | - foreach ($res->plugins as $plugin) { | |
| 139 | - if (is_object($plugin) && !empty($plugin->slug) && $plugin->slug == $plugin_slug) { | |
| 140 | - return $res; | |
| 141 | - } | |
| 142 | - } // foreach | |
| 143 | - } | |
| 144 | - | |
| 145 | - $plugin_info = get_transient('wf-plugin-info-' . $plugin_slug); | |
| 146 | - | |
| 147 | - if (!$plugin_info) { | |
| 148 | - $plugin_info = plugins_api('plugin_information', array( | |
| 149 | - 'slug' => $plugin_slug, | |
| 150 | - 'is_ssl' => is_ssl(), | |
| 151 | - 'fields' => array( | |
| 152 | - 'banners' => true, | |
| 153 | - 'reviews' => true, | |
| 154 | - 'downloaded' => true, | |
| 155 | - 'active_installs' => true, | |
| 156 | - 'icons' => true, | |
| 157 | - 'short_description' => true, | |
| 158 | - ) | |
| 159 | - )); | |
| 160 | - if (!is_wp_error($plugin_info)) { | |
| 161 | - set_transient('wf-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7); | |
| 162 | - } | |
| 163 | - } | |
| 164 | - | |
| 165 | - if (!empty($res->plugins) && is_array($res->plugins) && $plugin_info && is_object($plugin_info)) { | |
| 166 | - array_unshift($res->plugins, $plugin_info); | |
| 167 | - } | |
| 168 | - | |
| 169 | - return $res; | |
| 170 | - } // add_plugin_featured | |
| 171 | 124 | |
| 172 | 125 | |
| 173 | 126 | // auto download / install / activate WPR plugin |
| 174 | 127 | function install_wpr() |