. */ // TODO: Wrap hitman in a class to avoid potential name-collisions. function whack($fn) { $hitman = 'rename_function'; if (function_exists($fn) && function_exists($hitman)) { $hitman($fn, $fn . '_old'); $ret .= $fn . ' is KILLDED
'; } else { return false; } } function whack_em($funs, $revive = false) { $hitman = 'rename_function'; $ret = ''; if (!function_exists($hitman)) { $ret .= $hitman . ' Not found!!
You need the apd package for this plugin to work. Please install it by the command pecl install apd.'; return $ret; } foreach ($funs as $fn) { if ($revive) { $oldName = $fn . '_old'; $newName = $fn; } else { $oldName = $fn; $newName = $fn . '_old'; } if (function_exists($oldName)) { @$hitman($oldName, $newName); $ret .= "$oldName is renamed to $newName
"; } else { $ret .= $oldName . ' is not found
'; } } return $ret; } function test_one($fn) { if (function_exists($fn)) { $fnout = $fn(__FILE__); $ret = "Output of " . $fn . "(): is " . print_r($fnout, true) . "
"; } else { $ret = $fn . ' is not found
'; } return $ret; } function test_functions($funs) { $ret = ''; foreach ($funs as $fn) { $ret .= test_one($fn); $fnOld = $fn . "_old"; $ret .= test_one($fnOld); } return $ret; } function hitman_admin() { $mOptions = "hitman"; $hmOptions = get_option($mOptions); $funs = array('plugin_dir_url', 'plugins_url', 'plugin_basename'); $hmOptions['funList'] = $funs; // TODO: expose the list to the end-user if (isset($_POST['kill_functions'])) { $status = whack_em($funs); echo "

Function Tweaker activated: $status

"; $hmOptions['kill'] = true; update_option($mOptions, $hmOptions); } if (isset($_POST['save_functions'])) { $status = whack_em($funs, true); echo "

Function Tweaker revoked: $status

"; $hmOptions['kill'] = false; update_option($mOptions, $hmOptions); } if (isset($_POST['test_functions'])) { $status = test_functions($funs); echo "

Function output:
$status

"; } if (isset($_POST['set_wp_content_dir'])) { $hmOptions['wpPluginDir'] = $_POST['wpContentDir']; echo "

Function Tweaker will define WP_CONTENT_DIR as {$hmOptions['wpPluginDir']}

"; update_option($mOptions, $hmOptions); } if (isset($_POST['unset_wp_content_dir'])) { $wpContentDir = $hmOptions['wpPluginDir']; echo "

Function Tweaker will NOTdefine WP_CONTENT_DIR any more.

You may want to add this line to your wp_config.php
define('WP_CONTENT_DIR', $wpContentDir);

"; $hmOptions['wpPluginDir'] = ''; update_option($mOptions, $hmOptions); } echo ''; ?>

Function Tweaker


WP_CONTENT_DIR is defined as " . WP_CONTENT_DIR . ""; if ($wpContentDir != WP_CONTENT_DIR) { echo "
But it looks like it should be $wpContentDir"; echo "

You may want to add this line to your wp_config.php
define('WP_CONTENT_DIR', $wpContentDir);

"; } if (!empty($hmOptions['wpPluginDir'])) { echo "I defined it. Want to undefine it? (You should probably define it in your wp_config.php instead.) "; echo ""; } echo "

"; } else { echo "

WP_CONTENT_DIR is not defined.
Defining it may solve all your problems regarding functions like plugin_dir_url(), plugins_url() and plugin_basename()

"; echo "Ok to define WP_CONTENT_DIR as {$wpContentDir}? "; echo ""; echo ""; } ?>

Help/Information

  1. First hit the "Test Functions" button.
  2. Look at the output above. Especially the one against plugins_url()
  3. If it looks incorrect, you may be able to fix it in two ways.
    1. If the plugin is offering to define WP_CONTENT_DIR, please do so.
    2. If the plugin is advising you to define it in your wp_config.php, please do so.
  4. Hit the "Test Functions" button again. Does the output look fine?
  5. If the function output still does not look right, click on the "Kill Functions" button and then hit the "Test Functions" button again.
  6. The output should have the right values now.
  7. If not, sorry, I am out of ideas. You may look at the plugin code in redefinedFunctions*.php and may be able to fix your issues.
  8. If you do, please leave a comment here so that others can benefit from your efforts.