-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from strangerstudios/dev
Sitewide Sales Version 1.4 Release
- Loading branch information
Showing
28 changed files
with
4,385 additions
and
759 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Generate Translations | ||
on: workflow_dispatch | ||
jobs: | ||
generate-translations: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: WordPress POT/PO/MO Generator | ||
uses: strangerstudios/action-wp-pot-po-mo-generator@main | ||
with: | ||
generate_pot: 1 | ||
generate_po: 1 | ||
generate_mo: 1 | ||
generate_lang_packs: 1 | ||
merge_changes: 1 | ||
headers: '{"Report-Msgid-Bugs-To":"[email protected]","Last-Translator":"Stranger Studios <[email protected]>","Language-Team":"Stranger Studios <[email protected]>"}' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Sync labels | ||
on: | ||
# You can run this with every type of event, but it's better to run it only when you actually need it. | ||
workflow_dispatch: | ||
|
||
jobs: | ||
labels: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: strangerstudios/label-sync@v2 | ||
with: | ||
# If you want to use a source repo, you can put is name here (only the owner/repo format is accepted) | ||
source-repo: strangerstudios/paid-memberships-pro | ||
|
||
# If you want to delete any additional label, set this to true | ||
delete-other-labels: true | ||
|
||
#If you want the action just to show you the preview of the changes, without actually editing the labels, set this to tru | ||
dry-run: false | ||
|
||
# You can change the token used to change the labels, this is the default one | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?php | ||
//only admins can get this | ||
if ( ! function_exists( "current_user_can" ) || ( ! current_user_can( "manage_options" ) ) ) { | ||
die( __( "You do not have permissions to perform this action.", 'sitewide-sales' ) ); | ||
} | ||
|
||
//get values from form | ||
if(isset($_REQUEST['sitewide_sale'])) { | ||
$id = intval($_REQUEST['sitewide_sale']); | ||
$sitewide_sale = \Sitewide_Sales\classes\SWSales_Sitewide_Sale::get_sitewide_sale( $id ); | ||
$daily_revenue = $sitewide_sale->get_daily_sale_revenue(); | ||
$landing_page_post_id = $sitewide_sale->get_landing_page_post_id(); | ||
|
||
} | ||
|
||
$headers = array(); | ||
$headers[] = "Content-Type: text/csv"; | ||
$headers[] = "Cache-Control: max-age=0, no-cache, no-store"; | ||
$headers[] = "Pragma: no-cache"; | ||
$headers[] = "Connection: close"; | ||
|
||
// Generate a filename based on the params. | ||
$filename = $sitewide_sale->get_name() . "_" . date( "Y-m-d_H-i", current_time( 'timestamp' ) ) . ".csv"; | ||
$headers[] = "Content-Disposition: attachment; filename={$filename};"; | ||
|
||
$left_header= array ( | ||
"sale ID", | ||
"sale name", | ||
"landing page", | ||
"start date", | ||
"end date", | ||
"banner reach", | ||
"landing page visits", | ||
"checkouts using coupon " . $sitewide_sale->get_coupon(), | ||
"sale revenue", | ||
"other new revenue", | ||
"renewals", | ||
"total revenue in period" | ||
); | ||
|
||
$csv_file_header_array = array_merge( $left_header, array_keys( $daily_revenue ) ); | ||
|
||
$dateformat = get_option( 'date_format' ) . ' ' . get_option( 'time_format' ); | ||
|
||
// Generate a temporary file to store the data in. | ||
$tmp_dir = apply_filters( 'swsales_report_csv_export_tmp_dir', sys_get_temp_dir() ); | ||
|
||
$filename = tempnam( $tmp_dir, 'sws_reportcsv_' ); | ||
|
||
// open in append mode | ||
$csv_fh = fopen( $filename, 'a' ); | ||
|
||
//write the CSV header to the file | ||
fputcsv( $csv_fh, $csv_file_header_array); | ||
|
||
$csvoutput = array( | ||
$id, | ||
$sitewide_sale->get_name(), | ||
get_permalink( $landing_page_post_id ), | ||
$sitewide_sale->get_start_date(), | ||
$sitewide_sale->get_end_date(), | ||
$sitewide_sale->get_banner_impressions(), | ||
$sitewide_sale->get_landing_page_visits(), | ||
$sitewide_sale->get_checkout_conversions(), | ||
$sitewide_sale->get_sale_revenue(), | ||
$sitewide_sale->get_other_revenue(), | ||
$sitewide_sale->get_renewal_revenue(), | ||
$sitewide_sale->get_total_revenue() | ||
); | ||
|
||
$csvoutput = array_merge( $csvoutput, array_values( $daily_revenue ) ); | ||
|
||
fputcsv( $csv_fh, $csvoutput ); | ||
|
||
//flush the buffer | ||
wp_cache_flush(); | ||
|
||
swsales_transmit_report_data( $csv_fh, $filename, $headers ); | ||
|
||
|
||
function swsales_transmit_report_data( $csv_fh, $filename, $headers = array() ) { | ||
|
||
//close the temp file | ||
fclose( $csv_fh ); | ||
|
||
if ( version_compare( phpversion(), '5.3.0', '>' ) ) { | ||
|
||
//make sure we get the right file size | ||
clearstatcache( true, $filename ); | ||
} else { | ||
// for any PHP version prior to v5.3.0 | ||
clearstatcache(); | ||
} | ||
|
||
//did we accidentally send errors/warnings to browser? | ||
if ( headers_sent() ) { | ||
echo str_repeat( '-', 75 ) . "<br/>\n"; | ||
echo 'Please open a support case and paste in the warnings/errors you see above this text to\n '; | ||
echo '<a href="https://sitewidesales.com/support/?utm_source=plugin&utm_medium=swsales-report-csv&utm_campaign=support" target="_blank">Sitewide Sales support</a><br/>\n'; | ||
echo str_repeat( "=", 75 ) . "<br/>\n"; | ||
echo file_get_contents( $filename ); | ||
echo str_repeat( "=", 75 ) . "<br/>\n"; | ||
} | ||
|
||
//transmission | ||
if ( ! empty( $headers ) ) { | ||
//set the download size | ||
$headers[] = "Content-Length: " . filesize( $filename ); | ||
|
||
//set headers | ||
foreach ( $headers as $header ) { | ||
header( $header . "\r\n" ); | ||
} | ||
|
||
// disable compression for the duration of file download | ||
if ( ini_get( 'zlib.output_compression' ) ) { | ||
ini_set( 'zlib.output_compression', 'Off' ); | ||
} | ||
|
||
if( function_exists( 'fpassthru' ) ) { | ||
// use fpassthru to output the csv | ||
$csv_fh = fopen( $filename, 'rb' ); | ||
fpassthru( $csv_fh ); | ||
fclose( $csv_fh ); | ||
} else { | ||
// use readfile() if fpassthru() is disabled (like on Flywheel Hosted) | ||
readfile( $filename ); | ||
} | ||
|
||
// remove the temp file | ||
unlink( $filename ); | ||
} | ||
|
||
exit; | ||
} |
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
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
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
Oops, something went wrong.