Esempio n. 1
0
 /**
  * initializes the static class
  * 
  * sets up the class autoloading, configuration values, hooks, filters and shortcodes
  * 
  * @global object $wpdb
  */
 public static function initialize()
 {
     // set the plugin version
     self::$plugin_version = self::_get_plugin_data('Version');
     // define some locations
     self::$default_options = self::$prefix . 'default_options';
     self::$plugin_page = self::PLUGIN_NAME;
     self::$plugin_path = plugin_dir_path(__FILE__);
     // this is relative to the WP install
     self::$uploads_path = 'wp-content/uploads/' . self::PLUGIN_NAME . '/';
     self::$last_record = self::$prefix . 'last_record';
     self::$css_prefix = self::$prefix;
     self::$session = new PDb_Session();
     /* 
      * set up data source names
      * 
      * these can be modified later with a filter hook
      */
     global $wpdb;
     $table_basename = $wpdb->prefix . str_replace('-', '_', self::PLUGIN_NAME);
     self::$participants_table = $table_basename;
     self::$fields_table = $table_basename . '_fields';
     self::$groups_table = $table_basename . '_groups';
     self::$participants_db_options = self::PLUGIN_NAME . '_options';
     // install/deactivate and uninstall methods are handled by the PDB_Init class
     register_activation_hook(__FILE__, array('PDb_Init', 'on_activate'));
     register_deactivation_hook(__FILE__, array('PDb_Init', 'on_deactivate'));
     register_uninstall_hook(__FILE__, array('PDb_Init', 'on_uninstall'));
     add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(__CLASS__, 'add_plugin_action_links'));
     add_filter('plugin_row_meta', array(__CLASS__, 'add_plugin_meta_links'), 10, 2);
     // set the WP hooks to finish setting up the plugin
     add_action('init', array(__CLASS__, 'init'));
     add_action('wp', array(__CLASS__, 'remove_rel_link'));
     add_action('wp', array(__CLASS__, 'reset_shortcode_session'));
     add_filter('admin_body_class', array(__CLASS__, 'add_admin_body_class'));
     add_filter('body_class', array(__CLASS__, 'add_body_class'));
     add_action('admin_menu', array(__CLASS__, 'plugin_menu'));
     add_action('admin_init', array(__CLASS__, 'admin_init'));
     add_action('wp_enqueue_scripts', array(__CLASS__, 'include_scripts'));
     add_action('admin_enqueue_scripts', array(__CLASS__, 'admin_includes'));
     add_filter('wp_headers', array(__CLASS__, 'control_caching'));
     add_filter(self::$prefix . 'translate_string', array(__CLASS__, 'string_static_translation'), 20);
     // handles ajax request from list filter
     add_action('wp_ajax_pdb_list_filter', array(__CLASS__, 'pdb_list_filter'));
     add_action('wp_ajax_nopriv_pdb_list_filter', array(__CLASS__, 'pdb_list_filter'));
     // define our shortcodes
     add_shortcode('pdb_record', array(__CLASS__, 'print_shortcode'));
     add_shortcode('pdb_signup', array(__CLASS__, 'print_shortcode'));
     add_shortcode('pdb_signup_thanks', array(__CLASS__, 'print_shortcode'));
     add_shortcode('pdb_request_link', array(__CLASS__, 'print_shortcode'));
     add_shortcode('pdb_list', array(__CLASS__, 'print_shortcode'));
     add_shortcode('pdb_single', array(__CLASS__, 'print_shortcode'));
     add_shortcode('pdb_search', array(__CLASS__, 'print_shortcode'));
     add_shortcode('pdb_total', array(__CLASS__, 'print_shortcode'));
     /*
      * sets up the update notification
      * 
      */
     new PDb_Update_Notices(__FILE__);
 }
 /**
  * initializes the static class
  * 
  * sets up the class autoloading, configuration values, hooks, filters and shortcodes
  * 
  * @global object $wpdb
  */
 public static function initialize()
 {
     // set the table names
     global $wpdb;
     self::$participants_table = $wpdb->prefix . str_replace('-', '_', self::PLUGIN_NAME);
     self::$fields_table = self::$participants_table . '_fields';
     self::$groups_table = self::$participants_table . '_groups';
     // set the plugin version
     self::$plugin_version = self::_get_plugin_data('Version');
     // define some locations
     self::$participants_db_options = self::PLUGIN_NAME . '_options';
     self::$default_options = self::$prefix . 'default_options';
     self::$plugin_page = self::PLUGIN_NAME;
     self::$plugin_path = dirname(__FILE__);
     self::$plugin_url = WP_PLUGIN_URL . '/' . self::PLUGIN_NAME;
     // this is relative to the WP install
     self::$uploads_path = 'wp-content/uploads/' . self::PLUGIN_NAME . '/';
     self::$last_record = self::$prefix . 'last_record';
     self::$css_prefix = self::$prefix;
     self::$session = new PDb_Session();
     // install/deactivate and uninstall methods are handled by the PDB_Init class
     register_activation_hook(__FILE__, array('PDb_Init', 'on_activate'));
     register_deactivation_hook(__FILE__, array('PDb_Init', 'on_deactivate'));
     register_uninstall_hook(__FILE__, array('PDb_Init', 'on_uninstall'));
     add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(__CLASS__, 'add_plugin_action_links'));
     add_filter('plugin_row_meta', array(__CLASS__, 'add_plugin_meta_links'), 10, 2);
     // set the WP hooks to finish setting up the plugin
     add_action('init', array(__CLASS__, 'init'));
     add_action('wp', array(__CLASS__, 'post_check_shortcode'));
     add_action('template_include', array(__CLASS__, 'template_check_shortcode'));
     add_filter('admin_body_class', array(__CLASS__, 'add_admin_body_class'));
     add_filter('body_class', array(__CLASS__, 'add_body_class'));
     add_action('admin_menu', array(__CLASS__, 'plugin_menu'));
     add_action('admin_init', array(__CLASS__, 'admin_init'));
     add_action('wp_enqueue_scripts', array(__CLASS__, 'include_scripts'));
     add_action('admin_enqueue_scripts', array(__CLASS__, 'admin_includes'));
     add_action('wp_footer', array(__CLASS__, 'add_scripts'));
     // handles ajax request from list filter
     add_action('wp_ajax_pdb_list_filter', array(__CLASS__, 'pdb_list_filter'));
     add_action('wp_ajax_nopriv_pdb_list_filter', array(__CLASS__, 'pdb_list_filter'));
     // define our shortcodes
     add_shortcode('pdb_record', array(__CLASS__, 'print_record_edit_form'));
     add_shortcode('pdb_signup', array(__CLASS__, 'print_signup_form'));
     add_shortcode('pdb_signup_thanks', array(__CLASS__, 'print_signup_thanks_form'));
     add_shortcode('pdb_request_link', array(__CLASS__, 'print_retrieval_form'));
     add_shortcode('pdb_list', array(__CLASS__, 'print_list'));
     add_shortcode('pdb_single', array(__CLASS__, 'print_single_record'));
     add_shortcode('pdb_search', array(__CLASS__, 'print_search_form'));
     add_shortcode('pdb_total', array(__CLASS__, 'print_total'));
     /*
      * sets up the update notification
      * 
      * in this case, we use this to simulate a new releaase for testing.
      * 
      * uncomment to enable
      */
     //add_filter('pre_set_site_transient_update_plugins', array(__CLASS__, 'check_for_plugin_update'));// for plugin update test
     /*
      * uncomment this to enable custom upgrade details window
      */
     //add_filter('plugins_api', array(__CLASS__, 'plugin_update_info'), 10, 3);
     /*
      * this adds a custom update message to the plugin list 
      */
     global $pagenow;
     if ('plugins.php' === $pagenow) {
         $plugin_path = plugin_basename(__FILE__);
         $hook = "in_plugin_update_message-" . $plugin_path;
         //add_action( $hook, array(__CLASS__, 'plugin_update_message'), 20, 2 );
     }
 }