-if ( $plugin_dir and opendir PLUGINS, $plugin_dir ) {
- foreach my $plugin ( grep { /^\w+$/ && -f "$plugin_dir/$_" } sort readdir(PLUGINS) ) {
- my($plugin_name, $off) = $plugin =~ /^\d*(\w+?)(_?)$/;
- my $on_off = $off eq '_' ? -1 : 1;
- require "$plugin_dir/$plugin";
- $plugin_name->start() and ( $plugins{$plugin_name} = $on_off ) and push @plugins, $plugin_name;
+my $path_sep = $^O eq 'MSWin32' ? ';' : ':';
+my @plugin_dirs = split /$path_sep/, ($plugin_path || $plugin_dir);
+my @plugin_list = ();
+my %plugin_hash = ();
+
+# If $plugin_list is set, read plugins to use from that file
+$plugin_list = "$config_dir/$plugin_list"
+ if $plugin_list && $plugin_list !~ m!^\s*/!;
+if ( $plugin_list and -r $plugin_list and $fh->open("< $plugin_list") ) {
+ @plugin_list = map { chomp $_; $_ } grep { /\S/ && ! /^#/ } <$fh>;
+ $fh->close;
+}
+# Otherwise walk @plugin_dirs to get list of plugins to use
+elsif ( @plugin_dirs ) {
+ for my $plugin_dir ( @plugin_dirs ) {
+ next unless -d $plugin_dir;
+ if ( opendir PLUGINS, $plugin_dir ) {
+ for my $plugin ( grep { /^[\w:]+$/ && ! /~$/ && -f "$plugin_dir/$_" } readdir(PLUGINS) ) {
+ # Ignore duplicates
+ next if $plugin_hash{ $plugin };
+ # Add to @plugin_list and %plugin_hash
+ $plugin_hash{ $plugin } = "$plugin_dir/$plugin";
+ push @plugin_list, $plugin;
+ }
+ closedir PLUGINS;
+ }
+ }
+ @plugin_list = sort @plugin_list;
+}
+
+# Load all plugins in @plugin_list
+unshift @INC, @plugin_dirs;
+foreach my $plugin ( @plugin_list ) {
+ my($plugin_name, $off) = $plugin =~ /^\d*([\w:]+?)(_?)$/;
+ my $on_off = $off eq '_' ? -1 : 1;
+ # Allow perl module plugins
+ if ($plugin =~ m/::/ && -z $plugin_hash{ $plugin }) {
+ # For Blosxom::Plugin::Foo style plugins, we need to use a string require
+ eval "require $plugin_name";
+ }
+ else {
+ eval { require $plugin };