Bitly’s WordPress Plugin Fix
As of January 8, 2025, wp-bitly has been closed for download pending a full review, but we have a quick and dirty fix, for those that can’t just deactivate it.

The wp-bitly plugin is used to integrate WordPress posts with Bitly by generating a Bitly shortlink for selected post types. It has been tested up to WordPress version 5.8, which isn’t saying much since WordPress is up to 6.7.x now.
Just into the new year 2025, the plugin was closed for downloading by WordPress.org pending a full review. That’s fine and all, unless your website depends on this plugin and you can’t just deactivate it and find a replacement. So, the web dev nerds at JDM Digital thought they’d come up with a little patch that’ll let you limp along a little longer.
Fix wp-bitly
At least in our experience, there are two issues (PHP fatal errors) with the plugin, both in the same file: /wp-bitly/includes/class-wp-bitly-metabox.php
.
NOTE: We never recommend editing Plugin code because it’ll get overwritten the next time the plugin owner updates it. However, in this case, who cares if the plugin is already broken and this is your last-ditch effort.
Issue 1: PHP Fatal error: Uncaught TypeError: “array_reverse()”
In that file, on or around line 126, the array_reverse()
function is receiving null
instead of an array. In your code, if the Bitly API response doesn’t return an array with a 'link_clicks'
key, then $clicks
remains null
and causes the fatal error.
To fix that, all we have to do is ensure that $clicks
is always an array.
// Ensure $clicks is always an array $clicks = array(); if (is_array($response) && isset($response['link_clicks'])) { $clicks = $response['link_clicks']; }
This way, even if the response is not as expected, $clicks will be an empty array rather than null, and array_reverse($clicks) will work without errors. That could be the case if you’re creating a new post–which obviously doesn’t have any clicks yet.
Issue 2: PHP Fatal error: Uncaught ValueError: max() must contain at least one element
The error occurs because the max()
function is being called on an empty array. If there are no click data (because it’s a new post or whatever), then max($data_arr)
throws a “ValueError.”
All we have to do is check if $data_arr
is empty before calling max()
, and providing a default value (such as 0) when it is empty. Look on or around line 132 in that same file.
foreach (array_reverse($clicks) as $click) {
$labels_arr[] = date('m/d', strtotime($click['date']));
$data_arr[] = $click['clicks'];
}
// Ensure $data_arr is not empty before calling max()
$highest_clicks = !empty($data_arr) ? max($data_arr) : 0;
By using the ternary operator, you ensure that if $data_arr
is empty, $highest_clicks
is set to 0 instead of calling max()
on an empty array. This prevents the fatal error and the sky from falling.
Prefer not to edit code?
If you’re not the code editing type, you could also head over to the fork on GitHub and download the latest release. Here’s what you do:
- Go to the repo: https://github.com/jdmdigital/wp-bitly
- Click on release: https://github.com/jdmdigital/wp-bitly/releases/tag/v2.5.3
- Click on the source code (zip) to download it: https://github.com/jdmdigital/wp-bitly/archive/refs/tags/v2.5.3.zip
- Extract the Zip
- Rename the “wp-bitly-2.5.3” folder to “wp-bitly”
- Upload and overwrite that folder to your
/wp-content/plugins/
subdirectory
Move on from wp-bitly?
Should you just abandon wp-bitly and find another plugin? You certainly could, but we only found one more on WordPress.org that works similarly: “Bitly URL Shortener.”
Otherwise, we hope our two little code fixes help you limp along until the developers figure their stuff out with the WordPress people. We did create our own fork of the GitHub repo. Maybe they’ll incorporate our updates into their own soon enough.
Still need a hand? Reach out to our web design nerds and just ask.
.
Get the Email
Join 1000+ other subscribers. Only 1 digest email per month. We'll never share your address. Unsubscribe anytime. It won't hurt our feelings (much).