Created
May 23, 2023 09:02
-
-
Save iamrealfarhanbd/fc27acb7fa6461da52b813331d56885a to your computer and use it in GitHub Desktop.
Adds PDF download buttons to FluentForm submissions widgets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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