In case it helps others, here’s the fix that worked for me.
First, pop this modified version of the Plugin Info plugin into your functions.php file:
function getplugininfo( $slug = null ) {
if ( !$slug )
return false;
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
$info = array();
$slug = sanitize_title( $slug );
$plugin = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
if ( !$plugin or is_wp_error( $plugin ) )
return false;
$attributes = array(
'name' => 'name',
'slug' => 'slug',
'version' => 'version',
'author' => 'author',
'profile_url' => 'author_profile',
'contributors' => 'contributors',
'requires' => 'requires',
'tested' => 'tested',
'compatibility' => 'compatibility',
'rating_raw' => 'rating',
'num_ratings' => 'num_ratings',
'downloaded_raw' => 'downloaded',
'updated_raw' => 'last_updated',
'homepage_url' => 'homepage',
'description' => array( 'sections', 'description' ),
'installation' => array( 'sections', 'installation' ),
'screenshots' => array( 'sections', 'screenshots' ),
'changelog' => array( 'sections', 'changelog' ),
'faq' => array( 'sections', 'faq' ),
'other_notes' => array( 'sections', 'other_notes' ),
'download_url' => 'download_link',
'tags' => 'tags'
);
foreach ( $attributes as $name => $key ) {
if ( is_array( $key ) ) {
$_key = $plugin->$key[0];
if ( isset( $_key[$key[1]] ) )
$info[$name] = $_key[$key[1]];
} else {
if ( isset( $plugin->$key ) )
$info[$name] = $plugin->$key;
}
}
if ( is_array( $info['compatibility'] ) and !empty( $info['compatibility'][$GLOBALS['wp_version']] ) )
$info['compatibility'] = $info['compatibility'][$GLOBALS['wp_version']][$info['version']][0] . '%';
else
$info['compatibility'] = __( 'Unknown', 'plugin_info' );
$info['compat_with'] = $GLOBALS['wp_version'];
$info['downloaded'] = number_format( $info['downloaded_raw'] );
$info['rating'] = ceil( 0.05 * $info['rating_raw'] );
$info['link_url'] = "https://www.ads-software.com/extend/plugins/{$info['slug']}/";
$info['updated'] = date( get_option('date_format'), strtotime( $info['updated_raw'] ) );
$info['updated_ago'] = sprintf( __('%s ago'), human_time_diff( strtotime( $info['updated_raw'] ) ) );
$info['download'] = '<a href="' . $info['download_url'] . '">%s</a>';
$info['homepage'] = '<a href="' . $info['homepage_url'] . '">%s</a>';
$info['link'] = '<a href="' . $info['link_url'] . '">%s</a>';
$info['profile'] = '<a href="' . $info['profile_url'] . '">%s</a>';
if ( isset( $info['contributors'] ) ) {
foreach ( (array) $info['contributors'] as $name => $link )
$info['contributors'][$name] = '<a href="' . $link . '">' . $name . '</a>';
$info['contributors'] = implode( ', ', $info['contributors'] );
}
if ( isset( $info['tags'] ) )
$info['tags'] = implode( ', ', (array) $info['tags'] );
if ( isset( $info['screenshots'] ) )
$info['screenshots'] = preg_replace( "|src='[^http]([^\']+)'|i","src='{$info['link_url']}$1'", $info['screenshots'] );
if ( preg_match( '|href="([^"]+)"|i', $info['author'], $matches ) )
$info['author_url'] = $matches[1];
if ( preg_match( '|>([^<]+)<|i', $info['author'], $matches ) )
$info['author_name'] = $matches[1];
else
$info['author_name'] = $info['author'];
if ( isset( $info['changelog'] ) and preg_match( "#<h4>{$info['version']}[^<]*</h4>(.*?)(<h4>|$)#is", $info['changelog'], $matches ) )
$info['latest_change'] = trim( $matches[1] );
if ( isset( $info['other_notes'] ) and preg_match_all( '|<h3>([^<]+)</h3>|i', $info['other_notes'], $matches, PREG_SET_ORDER ) ) {
for ( $i = 0; isset( $matches[$i] ); $i++ ) {
$end = isset( $matches[$i+1][0] ) ? $matches[$i+1][0] : '$';
preg_match( '|' . $matches[$i][0] . '(.*)' . $end . '|si', $info['other_notes'], $match );
$info[sanitize_title( $matches[$i][1] )] = $match[1];
}
}
$info['download_link'] = $info['download_url'];
$info['tags_list'] = $info['tags'];
$info['extend'] = $info['link_url'];
$info['last_updated_nice'] = $info['updated'];
$info['last_updated'] = $info['updated'];
$info['last_updated_ago'] = $info['updated_ago'];
$info['last_updated_raw'] = $info['updated_raw'];
return apply_filters( 'plugin_info', $info );
}
function formula($atts)
{
$downloaded = getplugininfo( $atts["slug"], 'download' );
$downloads=$downloaded["downloaded_raw"];
if($atts["number"]!="")
{
$total = $atts["number"] - $downloads;
}
else
{
$total = $downloads;
}
// echo number_format("$total"); - To return as variable (appears at the top of the page/post)
return number_format("$total"); // To return as a string (appears inline)
}
add_shortcode('downloads', 'formula');
Then, use this modified shortcode where the slug = the plugin’s WP plugin directory slug, in this case “page-links-single-page-option”: Studio Hyperset’s “Page-Links Plus” plugin.
This will display the number of downloads:
[downloads slug="page-links-single-page-option"]
This will display the number of downloads subtracted from an arbitrary number, in this case 3,000:
[downloads number="30000" slug="page-links-single-page-option"]