Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Adds a multitude of data variables from the WP Download Manager plugin to the Post to Google My Business plugin
This code snippet adds various info about downloads from the WP Download Manager plugin to Post to Google My Business
class PGMB_WP_Download_Manager_Variables implements \PGMB\Placeholders\VariableInterface {
private $download_id;
public function __construct($download_id){
$this->download_id = $download_id;
* @return array Variable => Replacement
public function variables(){
if(!function_exists('wpdm_get_package')){ return []; }
$package_details = wpdm_get_package($this->download_id);
$variables = [];
foreach($package_details as $key => $data){
$variables["%wpdm_{$key}%"] = $data;
return $variables;
function pgmb_wpdm_variables($decorators, $parent_post_id, $location){
$decorators[] = new PGMB_WP_Download_Manager_Variables($parent_post_id);
return $decorators;
add_filter('mbp_placeholder_decorators', 'pgmb_wpdm_variables', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment