コード例 #1
0
ファイル: participants-database.php プロジェクト: raj-rk/Raj
 /**
  * initializes the plugin in the WP environment, fired on the 'init' hook
  * 
  * @return null
  */
 public static function init()
 {
     // set the table names
     global $wpdb;
     /*
      * this filter allows a plugin to determine which db tables to use
      * 
      * this allows things like multilingual field definitions or possibly even multiple databases
      */
     self::$participants_table = self::set_filter('select_database_table', self::$participants_table);
     self::$fields_table = self::set_filter('select_database_table', self::$fields_table);
     self::$groups_table = self::set_filter('select_database_table', self::$groups_table);
     // also filter the name of the settings to use
     self::$participants_db_options = self::set_filter('select_database_table', self::$participants_db_options);
     /*
      * set up the base reference object arrays
      * 
      * this is to reduce the number of db queries
      */
     self::_setup_columns();
     self::load_plugin_textdomain(__FILE__);
     self::$plugin_title = __('Participants Database', 'participants-database');
     self::_set_i18n();
     /**
      * @version 1.6 filter pdb-private_id_length
      */
     self::$private_id_length = self::set_filter('private_id_length', self::$private_id_length);
     /*
      * checks for the need to update the DB
      * 
      * this is to allow for updates to occur in many different ways
      */
     if (false === get_option(self::$db_version_option) || get_option(self::$db_version_option) != self::$db_version) {
         PDb_Init::on_update();
     }
     /*
      * instantiate the settings class; this only sets up the settings definitions, 
      * the WP Settings API may not be available at this point, so we register the 
      * settings on the 'admin_menu' hook
      */
     self::$Settings = new PDb_Settings();
     // get the plugin options array
     if (!is_array(self::$plugin_options)) {
         $default_options = get_option(self::$default_options);
         if (!is_array($default_options)) {
             $default_options = self::$Settings->get_default_options();
             add_option(self::$default_options, $default_options, '', false);
         }
         self::$plugin_options = array_merge($default_options, (array) get_option(self::$participants_db_options));
     }
     /*
      * normally, the custom CSS is written to a static css file, but on some systems, 
      * that doesn't work, so the fallback is to load the dynamic CSS file
      */
     if (self::_set_custom_css()) {
         $custom_css_file = 'PDb-custom.css';
     } else {
         $custom_css_file = 'custom_css.php';
     }
     /*
      * set the plugin date display format; uses the blog setting, which is localized
      * 
      * since version 1.5.5 we have not used the "strict date format" becuase that 
      * is for input purposes only. This format is used to display dates.
      * 
      * this property can be changed in a template if desired
      */
     self::$date_format = get_option('date_format');
     if (self::plugin_setting_is_true('html_email')) {
         $type = 'text/html; charset="' . get_option('blog_charset') . '"';
     } else {
         $type = 'text/plain; charset=us-ascii';
     }
     $email_headers = "From: " . self::$plugin_options['receipt_from_name'] . " <" . self::$plugin_options['receipt_from_address'] . ">\n" . "Content-Type: " . $type . "\n";
     self::$email_headers = self::set_filter('email_headers', $email_headers);
     // this processes form submits before any output so that redirects can be used
     self::process_page_request();
     //    if (!is_object(self::$Settings)) {
     //      self::$Settings = new PDb_Settings();
     //    }
     //    self::$Settings->initialize();
     $option_version = self::$Settings->option_version();
     /*
      * register frontend scripts and stylesheets
      */
     wp_register_style('pdb-frontend', plugins_url('/css/participants-database.css', __FILE__), array('dashicons'));
     wp_register_style('custom_plugin_css', plugins_url('/css/' . $custom_css_file, __FILE__), null, $option_version);
     wp_register_script(self::$prefix . 'shortcode', plugins_url('js/shortcodes.js', __FILE__), array('jquery'));
     wp_register_script(self::$prefix . 'list-filter', plugins_url('js/list-filter.js', __FILE__), array('jquery'));
     wp_register_script(self::$prefix . 'jq-placeholder', plugins_url('js/jquery.placeholder.min.js', __FILE__), array('jquery'));
     wp_register_script(self::$prefix . 'otherselect', plugins_url('js/otherselect.js', __FILE__), array('jquery'));
     /*
      * register admin scripts and stylesheets
      */
     wp_register_script(self::$prefix . 'cookie', plugins_url('js/jquery_cookie.js', __FILE__));
     wp_register_script(self::$prefix . 'manage_fields', plugins_url('js/manage_fields.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-tabs', 'jquery-ui-sortable', 'jquery-ui-dialog', self::$prefix . 'cookie'), false, true);
     wp_register_script(self::$prefix . 'settings_script', plugins_url('js/settings.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-tabs', self::$prefix . 'cookie'), false, true);
     wp_register_script(self::$prefix . 'record_edit_script', plugins_url('js/record_edit.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-tabs', self::$prefix . 'cookie'), false, true);
     wp_register_script(self::$prefix . 'jq-placeholder', plugins_url('js/jquery.placeholder.min.js', __FILE__), array('jquery'));
     wp_register_script('jq-doublescroll', plugins_url('js/jquery.doubleScroll.js', __FILE__), array('jquery', 'jquery-ui-widget'));
     wp_register_script(self::$prefix . 'admin', plugins_url('js/admin.js', __FILE__), array('jquery', 'jq-doublescroll'));
     wp_register_script(self::$prefix . 'otherselect', plugins_url('js/otherselect.js', __FILE__), array('jquery'));
     wp_register_script(self::$prefix . 'list-admin', plugins_url('js/list_admin.js', __FILE__), array('jquery'));
     wp_register_script(self::$prefix . 'debounce', plugins_url('js/jq_debounce.js', __FILE__), array('jquery'));
     //wp_register_script( 'datepicker', plugins_url( 'js/jquery.datepicker.js', __FILE__ ) );
     //wp_register_script( 'edit_record', plugins_url( 'js/edit.js', __FILE__ ) );
     wp_register_style('pdb-utility', plugins_url('/css/xnau-utility.css', __FILE__));
     wp_register_style('pdb-global-admin', plugins_url('/css/PDb-admin-global.css', __FILE__), false, false);
     wp_register_style('pdb-frontend', plugins_url('/css/participants-database.css', __FILE__));
     wp_register_style('pdb-admin', plugins_url('/css/PDb-admin.css', __FILE__));
 }