/**
  * Validate & export data
  *
  * @return string | bool
  */
 public function validate_export_data($export_data)
 {
     if (empty($export_data)) {
         GW_GoPricing_AdminNotices::add('impex', 'error', __('There is nothing to export!', 'go_pricing_textdomain'));
         return false;
     } else {
         $export_data = $export_data[0] == 'all' ? array() : $export_data;
         $result = GW_GoPricing_Data::export($export_data);
         if ($result === false) {
             GW_GoPricing_AdminNotices::add('impex', 'error', __('Oops, something went wrong!', 'go_pricing_textdomain'));
             return false;
         }
     }
     if (empty($export_data)) {
         $export_data = 'all';
     }
     return $export_data;
 }
Example #2
0
<?php

$img_url = !empty($_POST['data']) ? $_POST['data'] : '';
$maxwidth = !empty($_POST['maxwidth']) && $_POST['maxwidth'] != 'auto' ? (int) $_POST['maxwidth'] : 700;
$export_table_ids = !empty($_POST['data']) ? explode(',', $_POST['data']) : array();
$export_data = !empty($export_table_ids) ? GW_GoPricing_Data::export($export_table_ids) : '';
?>
<div class="gwa-popup">
	<div class="gwa-popup-inner"<?php 
echo !empty($_POST['maxwidth']) && $_POST['maxwidth'] != 'auto' ? sprintf(' style="width:%dpx;"', (int) $_POST['maxwidth']) : '';
?>
>
		<div class="gwa-popup-header">
			<div class="gwa-popup-header-icon-export"></div>
			<div class="gwa-popup-title"><?php 
_e('Export', 'go_pricing_textdomain');
?>
<small><?php 
echo sprintf(__('Selected pricing table data (%d)', 'go_pricing_textdomain'), count($export_table_ids));
?>
</small></div>
			<a href="#" title="<?php 
_e('Close', 'go_pricing_textdomain');
?>
" class="gwa-popup-close"></a>
		</div>
		<div class="gwa-popup-content-wrap">
			<div class="gwa-popup-content">	
				<div class="gwa-abox">
					<div class="gwa-abox-content-wrap">
						<div class="gwa-abox-content">
<?php

$user_id = get_current_user_id();
$maxwidth = !empty($_POST['maxwidth']) && $_POST['maxwidth'] != 'auto' ? (int) $_POST['maxwidth'] : 700;
$export_data = !empty($_POST['data']) ? GW_GoPricing_Data::export($_POST['data']) : '';
?>
<div class="gwa-popup"<?php 
echo !empty($maxwidth) ? sprintf(' style="max-width:%dpx;"', $maxwidth) : '';
?>
>
	<div class="gwa-popup-inner"<?php 
echo !empty($_POST['maxwidth']) && $_POST['maxwidth'] != 'auto' ? sprintf(' style="width:%dpx;"', (int) $_POST['maxwidth']) : '';
?>
>
		<div class="gwa-popup-header">
			<div class="gwa-popup-header-icon-preview"></div>
			<div class="gwa-popup-title"><?php 
_e('Live Preview', 'go_pricing_textdomain');
?>
<small><?php 
echo !empty($_POST['subtitle']) ? $_POST['subtitle'] : '';
?>
</small></div>
			<a href="#" title="<?php 
_e('Close', 'go_pricing_textdomain');
?>
" class="gwa-popup-close"></a>
		</div>
		<div class="gwa-popup-content-wrap">
			<div class="gwa-popup-content">			
				<iframe class="gwa-popup-iframe" src="<?php 
Example #4
0
if (!class_exists('GW_GoPricing')) {
    die;
}
// Get current user id
$user_id = get_current_user_id();
// Get general settings
$general_settings = get_option(self::$plugin_prefix . '_table_settings');
// Get temporary postdata
$data = $this->get_temp_postdata();
$this->delete_temp_postdata();
// Get tables data
if ($data === false) {
    return;
}
$data = $data == 'all' ? array() : $data;
$db_data = GW_GoPricing_Data::export($data);
?>
<!-- Top Bar -->
<div class="gwa-ptopbar">
	<div class="gwa-ptopbar-icon"></div>
	<div class="gwa-ptopbar-title">Go Pricing</div>
	<div class="gwa-ptopbar-content"><label><span class="gwa-label"><?php 
_e('Help', 'go_pricing_textdomain');
?>
</span><select data-action="help" class="gwa-w80"><option value="1"<?php 
echo isset($_COOKIE['go_pricing']['settings']['help'][$user_id]) && $_COOKIE['go_pricing']['settings']['help'][$user_id] == 1 ? ' selected="selected"' : '';
?>
><?php 
_e('Tooltip', 'go_pricing_textdomain');
?>
</option><option value="2"<?php 
 /**
  * Export
  *
  * @return void | bool
  */
 public function export($export_data)
 {
     if (empty($export_data)) {
         GW_GoPricing_AdminNotices::add('impex', 'error', __('There is nothing to export!', 'go_pricing_textdomain'));
         return false;
     } else {
         $export_data = $export_data[0] == 'all' ? array() : $export_data;
         $result = GW_GoPricing_Data::export($export_data);
         if ($result === false) {
             GW_GoPricing_AdminNotices::add('impex', 'error', __('Oops, something went wrong!', 'go_pricing_textdomain'));
             return false;
         }
         $this->delete_temp_postdata();
         if ($result === false) {
             return;
         }
         ob_end_clean();
         header('Pragma: public');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Content-Description: File Transfer');
         header('Content-Transfer-Encoding: Binary');
         header('Content-type: text/plain');
         header('Content-Disposition: attachment; filename="export_' . date('d_m_Y_H_i_s') . '.txt"');
         header('Connection: close');
         echo $result;
         ob_end_flush();
         exit;
     }
 }