Make WordPress Core

Opened 21 years ago

Closed 19 years ago

Last modified 17 years ago

#2299 closed defect (bug) (wontfix)

plugin_basename doesn't return plugin_name within a fold in a correct way.

Reported by: nielshackius Owned by:
Priority: normal Milestone:
Component: Administration Version: 2.0
Severity: normal Keywords: plugin_basename, plugin, __FILE__, register_activation_hook
Cc: Focuses:

Description

to add an activation action for your plugin, internally add_action('activate_{pluginname}',$function) is used.

If your plugin is within a folder its name should be: "plugin/starthere.php" so it would be add_action('activate_plugin/starthere.php',$function). Currently, however not a slash, but a backslash is returned by plugin_basename, which breaks register_activation_hook.

Fix could be:

$file= preg_replace('!\\\\+|/+!', '/', $file); //replaces even multiple backlslashes or multiple slashes by a single slash
$file= preg_replace('!^.*wp-content/plugins/!', '', $file); //removes anything before the file name

See also attaced example skript.

Attachments (1)

preg_replace.php​ (1.1 KB ) - added by nielshackius 21 years ago.
ExampleSkript, with different kind of paths-names (even with errors)

Download all attachments as: .zip

Change History (2)

@nielshackius
21 years ago

ExampleSkript, with different kind of paths-names (even with errors)

#1 @Nazgul
19 years ago

  • Resolution → wontfix
  • Status new → closed

No traction in over a year, so closing as wontfix.

Feel free to reopen if you have patches/suggestions/...

Note: See TracTickets for help on using tickets.