private function update_check() { global $wpdb; $plugin_lookup = $wpdb->get_results("SELECT * FROM `" . $wpdb->base_prefix . "hplugin_root` WHERE `plugin_name` = '" . $this->plugin_name . "';"); if ($plugin_lookup) { $this->plugin_old_version = $plugin_lookup[0]->plugin_version; if (version_compare($this->plugin_old_version, $this->plugin_version, '<')) { $update = new hmenu_update_plugin($this->plugin_name, $this->plugin_version, $this->plugin_old_version, $this->plugin_dir); $update->update_plugin(); } } }
public function __construct() { //define plugin vars $this->plugin_dir = dirname(__FILE__); $this->plugin_basename = plugin_basename(__FILE__); $this->plugin_url = plugins_url($this->plugin_name) . '/'; //instantiate helper class global $hmenu_helper; $hmenu_helper = new hmenu_helper($this->plugin_prefix); //register management hooks register_activation_hook(__FILE__, array(new hmenu_activate($this->plugin_name, $this->plugin_version, $this->plugin_dir), 'setup_plugin')); //activate register_deactivation_hook(__FILE__, array(new hmenu_deactivate($this->plugin_name), 'teardown_plugin')); //deactivate //detect if update required global $wpdb; if ($this->plugin_old_version == NULL && $hmenu_helper->onAdmin()) { //only make the DB call if required $plugin_lookup = $wpdb->get_results("SELECT * FROM `" . $wpdb->base_prefix . "hplugin_root` WHERE `plugin_name` = '" . $this->plugin_name . "';"); if ($plugin_lookup) { $this->plugin_old_version = $plugin_lookup[0]->plugin_version; $this->plugin_uuid = $plugin_lookup[0]->plugin_uuid; //define plugin uuid for check-in } if (version_compare($this->plugin_old_version, $this->plugin_version, '<')) { $update = new hmenu_update_plugin($this->plugin_name, $this->plugin_version, $this->plugin_old_version, $this->plugin_dir); $update->update_plugin(); } } //instantiate plugin setup new hmenu_setup($this->plugin_name, $this->plugin_dir, $this->plugin_url, $this->plugin_friendly_name, $this->plugin_version, $this->plugin_prefix, $this->first_release, $this->last_update, $this->plugin_friendly_description); //queue update check $checkin = new hmenu_checkin($this->plugin_basename, $this->plugin_name, $this->plugin_friendly_name, $this->api_version); add_filter('pre_set_site_transient_update_plugins', array(&$checkin, 'check_in')); //instantiate promotions class $promo = new hmenu_promo($this->plugin_basename, $this->plugin_name, $this->api_version); //instantiate admin class $backend = new hmenu_backend($this->plugin_dir); //this instance can be used by WP for ajax implementations //instantiate the frame security class $frame_sec = new hmenu_frame_sec($this->plugin_dir); //instantiate custom classes $class_update = new hmenu_class_update($this->plugin_dir); $insert_update = new hmenu_class_insert($this->plugin_dir); $get_update = new hmenu_class_get($this->plugin_dir); //instantiate the generate class $class_generate = new hmenu_class_generate($this->plugin_dir); //instantiate front-end class $frontend = new hmenu_frontend($this->plugin_dir, $this->plugin_url); //this instance can be used by WP for ajax implementations //instantiate custom classes $file_processor = new hmenu_class_file_processor($this->plugin_dir, $backend); //bind admin ajax listeners add_action('wp_ajax_hmenu_getPromotion', array(&$promo, 'get_promotion')); //admin: get plugin rating add_action('wp_ajax_hmenu_get_security_code', array(&$frame_sec, 'get_security_code')); //admin: get frame security code add_action('wp_ajax_hmenu_process_file', array(&$file_processor, 'process_file')); //admin: get frame security code //instantiate registrations class (register all ajax hooks) new hmenu_registration($this->plugin_prefix, $backend, $frontend, $class_update, $insert_update, $get_update, $class_generate); //configure auto-generation class and hooks $autogenerate = new hmenu_autogenerate($this->plugin_dir); add_action('wp_ajax_hmenu_autoGenerateViews', array(&$autogenerate, 'create_views')); //admin: get plugin rating }