Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamrealfarhanbd/fc27acb7fa6461da52b813331d56885a to your computer and use it in GitHub Desktop.
Save iamrealfarhanbd/fc27acb7fa6461da52b813331d56885a to your computer and use it in GitHub Desktop.
Adds PDF download buttons to FluentForm submissions widgets.
add_filter('fluentform/submissions_widgets', array($this, 'pushPdfButtons'), 10, 3);
public function pushPdfButtons($widgets, $data, $submission)
{
$formId = $submission->form->id;
$feeds = $this->getFeeds($formId);
if (!$feeds) {
return $widgets;
}
$widgetData = [
'title' => __('PDF Downloads', 'fluentform-pdf'),
'type' => 'html_content'
];
$fluent_forms_admin_nonce = wp_create_nonce('fluent_forms_admin_nonce');
$contents = '<ul class="ff_list_items">';
foreach ($feeds as $feed) {
$contents .= '<li><a href="' . admin_url('admin-ajax.php?action=fluentform_pdf_admin_ajax_actions&fluent_forms_admin_nonce='.$fluent_forms_admin_nonce.'&$fluent_forms_admin_nonce=&route=download_pdf&submission_id=' . $submission->id . '&id=' . $feed['id']) . '" target="_blank"><span style="font-size: 12px;" class="dashicons dashicons-arrow-down-alt"></span>' . $feed['name'] . '</a></li>';
}
$contents .= '</ul>';
$widgetData['content'] = $contents;
$widgets['pdf_feeds'] = $widgetData;
return $widgets;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment