__construct(); } /** * PHP5 style contructor * * Hooks into all of the necessary WordPress actions and filters needed * for this plugin to function * * @since 1.0 * @return none */ function __construct() { AjaxPluginHelper::__construct(); add_action('admin_menu', array(&$this, 'add_options_page')) ; register_activation_hook($this->plugin_file, array(&$this, 'activation')); add_action('plugins_loaded', array(&$this, 'plugins_loaded')); } /** * Action hook callback for activation * * Initializes the plugin for first time use and notifies users of * any issues they may encounter. * * @since 1.0 * @return none */ function activation() { if ( !$this->can_modify_fs() ) { set_site_transient('ajax-plugin-helper-fs', true, 1); } } /** * Check if there are any messages to be displayed to the user * * @since 1.0 * @return none */ function plugins_loaded() { if ( ! current_user_can('update_plugins') ) return; if ( get_site_transient('ajax-plugin-helper-fs') == true ) { add_action('admin_notices', array(&$this, 'modify_fs_notice')); } load_plugin_textdomain('ajax-plugin-helper', false, $this->plugin_dir_basename . '/localization'); } /** * Action hook callback for displaying message letting * user know that ajax upgrade and delete functions * are not available due to not being able to perform * file system tasks without prompting for FTP/SSH/SFTP * credentials * * @sinec 1.0 * @return none */ function modify_fs_notice() { ?>
http://sivel.net/wordpress/ajax-plugin-helper/#faq
response[ $file ]) ) return false; $r = $current->response[ $file ]; $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); $details_url = admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&TB_iframe=true&width=600&height=800'); echo '
'; if ( ! current_user_can('update_plugins') ) printf( __('There is a new version of %1$s available. View version %4$s Details.', 'ajax-plugin-helper'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); else if ( empty($r->package) ) printf( __('There is a new version of %1$s available. View version %4$s Details automatic upgrade unavailable for this plugin.', 'ajax-plugin-helper'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); else if ( ! $this->can_modify_fs() || $file == $this->plugin_file_basename ) printf( __('There is a new version of %1$s available. View version %4$s Details or upgrade automatically.', 'ajax-plugin-helper'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $file, 'upgrade-plugin_' . $file) ); else printf( __('There is a new version of %1$s available. View version %4$s Details or Ajax Upgrade.', 'ajax-plugin-helper'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, str_replace(array('/','.'), '-', $file), $file ); do_action( "in_plugin_update_message-$file", $plugin_data, $r ); echo '
'; } /** * Filter hook callback to insert and modify plugin action links * * @since 1.0 * @param array $links array of current action links to be filtered * @param string $file plugin_basename of the current plugin the filter was called for * @return array array of plugin action links */ function filter_plugin_actions($links, $file) { global $wp_version; // Remove the core update message action callback and use a custom one if ( $file != $this->plugin_file_basename ) { if ( version_compare('2.9', preg_replace('/[a-z-]+/i', '', $wp_version), '<=') ) { remove_action("after_plugin_row_$file", 'wp_plugin_update_row', 10, 2); add_action("after_plugin_row_$file", array(&$this, 'wp_plugin_update_row'), 10, 2); } else { remove_action('after_plugin_row', 'wp_plugin_update_row', 10, 2); add_action('after_plugin_row', array(&$this, 'wp_plugin_update_row'), 10, 2); } } $update_plugins = get_site_transient('update_plugins'); if ( current_user_can('update_plugins') && $file != $this->plugin_file_basename ) { $class = str_replace(array('/','.'), '-', $file); $spin_act = ""; $spin_del = ""; // If plugin requires updating and php can make unquestioned file system changes add update link if ( isset($update_plugins->response[$file]) && $this->can_modify_fs() ) { $links['ajax_update'] = "" . __('Ajax Upgrade', 'ajax-plugin-helper') . ''; } foreach ( $links as $key => $link ) { if ( $key == 'activate' ) { // Replace activate link with new $links[$key] = "{$spin_act}" . __('Ajax Activate', 'ajax-plugin-helper') . "'; } else if ( $key == 'deactivate' ) { // Replace deactivate link with new $links[$key] = "{$spin_act}" . __('Ajax Deactivate', 'ajax-plugin-helper') . "'; } else if ( $key == 'delete' && $this->can_modify_fs() ) { // Modify delete link if exists and can modify fs $links[$key] = "{$spin_del}" . __('Ajax Delete', 'ajax-plugin-helper') . ""; } } if ( !isset($links['delete']) ) { $links['delete'] = "{$spin_del}"; } } return $links; } }