Skip to content

Commit

Permalink
Merge branch 'master' of github.com:graphpaperpress/Sell-Media
Browse files Browse the repository at this point in the history
  • Loading branch information
prazna committed Feb 4, 2022
2 parents 03113c1 + cec66fa commit e2b0a1e
Show file tree
Hide file tree
Showing 52 changed files with 1,401 additions and 871 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Contributors: endortrails, nhuja
Donate link: https://graphpaperpress.com/plugins/sell-media/
Tags: photography, photos, sell media, sell photos, sell videos, sell downloads, download, downloads, e-commerce, paypal, stock photos, photo gallery, photo cart
Requires at least: 5.8.3
Tested up to: 5.8.3
Stable tag: 2.5.7.2
Requires at least: 5.9
Tested up to: 5.9
Stable tag: 2.5.7.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -50,7 +50,7 @@ Take Sell Media to the next level with these powerful extensions:

= Server Requirements =

1. PHP 7.2 or higher
1. PHP 7.4 or higher
2. CURL PHP extension
3. GD PHP extension
4. Original file uploads are protected automatically on Apache servers using .htaccess. If you are using an NGINX server, you'll need to add this to your sites configuration file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ public function sell_media_items_gutenberg_shortcode( $atts ) {
$image_size = getimagesize($image_data);
$image_width = (isset($image_size[0])) ? esc_attr($image_size[0]) : 100;
$image_height = (isset($image_size[1])) ? esc_attr($image_size[1]) : 100;
$width = $image_width * 250 / $image_height;
$padding_bottom = $image_height / $image_width * 100;
$width = $image_width * 250 / max($image_height, 1);
$padding_bottom = $image_height / max($image_width, 1) * 100;
} else {
$image_data = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
$image_width = (isset($image_data[1])) ? $image_data[1] : 100;
$image_height = (isset($image_data[2])) ? $image_data[2] : 100;
$width = $image_width * 250 / $image_height;
$padding_bottom = $image_height / $image_width * 100;
$width = $image_width * 250 / max($image_height, 1);
$padding_bottom = $image_height / max($image_width, 1) * 100;
}

}
Expand Down
3 changes: 1 addition & 2 deletions gutenberg/sell-media-items.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
require plugin_dir_path( __FILE__ ) . 'blocks/sell-media-filters/sell-media-filters.php';
require plugin_dir_path( __FILE__ ) . 'blocks/sell-media-items-slider/sell-media-items-slider.php';
require plugin_dir_path( __FILE__ ) . 'blocks/sell-media-list-all-collections/sell-media-list-all-collections.php';
require plugin_dir_path( __FILE__ ) . 'blocks/sell-media-search-form/sell-media-search-form.php';
?>
require plugin_dir_path( __FILE__ ) . 'blocks/sell-media-search-form/sell-media-search-form.php';
9 changes: 9 additions & 0 deletions inc/admin-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;

/**
* Protocols for wp_kses()
*/
add_filter( 'kses_allowed_protocols', function ( $protocols ) {
$protocols[] = 'javascript';

return $protocols;
} );

/**
* Checks if the attached file is an image
* and runs functions that resizes and moves
Expand Down
163 changes: 112 additions & 51 deletions inc/admin-items.php

Large diffs are not rendered by default.

168 changes: 112 additions & 56 deletions inc/admin-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,68 @@ function sell_media_payment_purchase_details( $post ){

$payments = Sell_Media()->payments;

echo '<div class="sell-media-admin-payments">';
echo '<input type="hidden" name="sell_media_custom_meta_box_nonce" value="' . wp_create_nonce( basename( __FILE__ ) ) . '" />';

printf(
'<ul>
<li>%s: ' . $payments->get_meta_key( $post->ID, 'first_name' ) . ' ' . $payments->get_meta_key( $post->ID, 'last_name' ) . ' ' . '</li>
<li>%s: ' . $payments->get_meta_key( $post->ID, 'email' ) . ' ' . '</li>
<li>%s: ' . $payments->total( $post->ID ) . ' ' . '</li>
</ul>',
__( 'Name', 'sell_media' ),
__( 'Email', 'sell_media' ),
__( 'Total', 'sell_media' )
);
$gpp_tmp_nonce = wp_create_nonce( basename( __FILE__ ) );
?>
<div class="sell-media-admin-payments">
<input type="hidden" name="sell_media_custom_meta_box_nonce" value="<?php echo esc_attr( $gpp_tmp_nonce); ?>" />
<ul>
<li><?php echo esc_html( __( 'Name', 'sell_media' ) ); ?>: <?php echo esc_html( $payments->get_meta_key( $post->ID, 'first_name' ) . ' ' . $payments->get_meta_key( $post->ID, 'last_name' ) . ' ' )?> </li>
<li><?php echo esc_html( __( 'Email', 'sell_media' ) ); ?>: <?php echo esc_html( $payments->get_meta_key( $post->ID, 'email' ) . ' ' ) ?></li>
<li><?php echo esc_html( __( 'Total', 'sell_media' ) ); ?>: <?php echo esc_html( $payments->total( $post->ID ) . ' ') ?></li>
</ul>
<?php

do_action( 'sell_media_below_payment_contact_details', $post->ID );

echo $payments->payment_table( $post->ID );
$arr = array(
'table' => array(
'class' => true,
'cellpadding' => true,
),
'thead' => array(),
'tr' => array(
'class' => true,
'valign' => true,
),
'th' => array(
'scope' => true,
),
'tbody' => array(),
'td' => array(
'class' => true,
),
'script' => array(
'type' => true,
),
'a' => array(
'href' => true,
),
'img' => array(
'width' => true,
'height' => true,
'src' => true,
'data-*' => true,
'alt' => true,
'srcset' => true,
'loading' => true,
'class' => true,
'sizes' => true,
'style' => true,
),
'input' => array(
'type' => true,
'value' => true,
)

);

echo wp_kses( $payments->payment_table( $post->ID ), $arr );

do_action( 'sell_media_additional_customer_meta', $post->ID );

echo '</div>';

?>
</div>
<?php
}

/**
Expand All @@ -107,42 +147,42 @@ function sell_media_payment_additional_purchase_details( $post ){

?>

<p><?php esc_attr_e( 'This is the additional payment data stored with the purchase.', 'sell_media'); ?></p>
<p><?php echo esc_html__( 'This is the additional payment data stored with the purchase.', 'sell_media'); ?></p>
<table class="wp-list-table widefat" cellspacing="0">
<tbody>
<?php if ( $args ) : foreach( $args as $k => $v ) : ?>
<?php if ( ! is_array( $v ) ) : ?>
<tr>
<td><?php echo ucwords( str_replace('_', ' ', $k ) ); ?></td><td><?php echo $v; ?></td>
<td><?php echo esc_html( ucwords( str_replace('_', ' ', $k ) ) ); ?></td><td><?php echo esc_html( $v ); ?></td>
</tr>
<?php else : ?>
<?php $i = 0; ?>
<?php foreach( $v as $name => $value ) : $i++ ?>
<?php if ( ! is_array( $name ) ) : ?>
<tr>
<td><?php esc_attr_e( 'Product', 'sell_media' ); ?> <?php echo esc_attr( $i ); ?></td>
<td><?php echo esc_html__( 'Product', 'sell_media' ); ?> <?php echo esc_html( $i ); ?></td>
<td>
<ul>
<?php if ( $value['name'] ) : ?>
<li><?php esc_attr_e( 'Name', 'sell_media' ); ?>: <?php echo esc_attr($value['name']); ?></li>
<li><?php echo esc_html__( 'Name', 'sell_media' ); ?>: <?php echo esc_html($value['name']); ?></li>
<?php endif; ?>
<?php if ( $value['id'] ) : ?>
<li><?php esc_attr_e( 'ID', 'sell_media' ); ?>: <a href="<?php echo esc_url(admin_url()); ?>post.php?post=<?php echo esc_attr( $value['id'] ); ?>&amp;action=edit"><?php echo esc_attr($value['id']); ?></a></li>
<li><?php echo esc_html__( 'ID', 'sell_media' ); ?>: <a href="<?php echo esc_url(admin_url()); ?>post.php?post=<?php echo esc_attr( $value['id'] ); ?>&amp;action=edit"><?php echo esc_html($value['id']); ?></a></li>
<?php endif; ?>
<?php if ( $value['type'] ) : ?>
<li><?php esc_attr_e( 'Type', 'sell_media' ); ?>: <?php echo esc_attr($value['type']); ?></li>
<li><?php echo esc_html__( 'Type', 'sell_media' ); ?>: <?php echo esc_html($value['type']); ?></li>
<?php endif; ?>
<?php if ( $value['size']['name'] ) : ?>
<li><?php esc_attr_e( 'Size', 'sell_media' ); ?>: <?php echo esc_attr($value['size']['name']); ?></li>
<li><?php echo esc_html__( 'Size', 'sell_media' ); ?>: <?php echo esc_html($value['size']['name']); ?></li>
<?php endif; ?>
<?php if ( $value['license']['name'] ) : ?>
<li><?php esc_attr_e( 'License', 'sell_media' ); ?>: <?php echo esc_attr($value['license']['name']); ?></li>
<li><?php echo esc_html__( 'License', 'sell_media' ); ?>: <?php echo esc_html($value['license']['name']); ?></li>
<?php endif; ?>
<?php if ( $value['qty'] ) : ?>
<li><?php esc_attr_e( 'Qty', 'sell_media' ); ?>: <?php echo esc_attr($value['qty']); ?></li>
<li><?php echo esc_html__( 'Qty', 'sell_media' ); ?>: <?php echo esc_html($value['qty']); ?></li>
<?php endif; ?>
<?php if ( $value['total'] ) : ?>
<li><?php esc_attr_e( 'Subtotal', 'sell_media' ); ?>: <?php echo sell_media_get_currency_symbol(); ?><?php echo number_format( $value['total'], 2, '.', ',' ); ?></li>
<li><?php echo esc_html__( 'Subtotal', 'sell_media' ); ?>: <?php echo esc_html( sell_media_get_currency_symbol() ); ?><?php echo esc_html( number_format( $value['total'], 2, '.', ',' ) ); ?></li>
<?php endif; ?>
</ul>
</td>
Expand All @@ -152,7 +192,7 @@ function sell_media_payment_additional_purchase_details( $post ){
<?php endif; ?>
<?php endforeach; else : ?>
<tr>
<td><?php esc_attr_e( 'This payment has no additional payment details', 'sell_media' ); ?></td>
<td><?php echo esc_html__( 'This payment has no additional payment details', 'sell_media' ); ?></td>
</tr>
<?php endif; ?>
</tbody>
Expand Down Expand Up @@ -182,14 +222,22 @@ function sell_media_payment_gateway_details( $post ){
}

do_action('sell_media_payment_before_gateway_details', $post);

echo '<p>' . esc_attr__( 'This is the data that was sent from ', 'sell_media' ) . $gateway . esc_attr__( ' at time of purchase.', 'sell_media' ) . '</p>';
echo '<ul>';
if ( $arguments ) foreach ( $arguments as $k => $v ) {
echo '<li><strong>' . $k . ':</strong> ' . ( ( is_array( $v) || is_object( $v ) ) ? serialize( $v ) : $v ) . '</li>';
}
echo '</ul>';

?>
<p>
<?php
echo esc_html( __( 'This is the data that was sent from ', 'sell_media' ) . $gateway . __( ' at time of purchase.', 'sell_media' ) );
?>
</p>
<ul>
<?php
if ( $arguments ) foreach ( $arguments as $k => $v ) {
?>
<li><strong><?php echo esc_html( $k ); ?>: </strong><?php echo esc_html( ( is_array( $v) || is_object( $v ) ) ? serialize( $v ) : esc_attr( $v ) ); ?></li>
<?php
}
?>
</ul>
<?php
do_action('sell_media_payment_after_gateway_details', $post);
}

Expand All @@ -203,11 +251,11 @@ function sell_media_payment_gateway_details( $post ){
*/
function sell_media_reports_callback_fn(){

$current_page = admin_url('edit.php?post_type=download&page=sell_media_reports');?>
$current_page = admin_url('edit.php?post_type=download&page=sell_media_reports'); ?>
<div class="wrap">
<h2><?php esc_attr_e( 'Earnings Report', 'sell_media' ); ?></h2>
<h2><?php echo esc_html__( 'Earnings Report', 'sell_media' ); ?></h2>
<div class="tool-box total-revenue">
<h3 class="title"><?php esc_attr_e( 'Total Earnings To Date:', 'sell_media' ); ?>&nbsp;<strong><?php print sell_media_get_currency_symbol(); ?><?php print sell_media_total_revenue( $post_status='publish' ); ?></strong></h3>
<h3 class="title"><?php echo esc_html__( 'Total Earnings To Date:', 'sell_media' ); ?>&nbsp;<strong><?php echo esc_html ( sell_media_get_currency_symbol() ); ?><?php echo esc_html ( sell_media_total_revenue( $post_status='publish' ) ); ?></strong></h3>
<?php do_action( 'sell_media_payments_below_total_earning' ); ?>
</div>

Expand All @@ -219,8 +267,8 @@ function sell_media_reports_callback_fn(){
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', '<?php esc_attr_e("Day", "sell_media"); ?>');
data.addColumn('number', '<?php esc_attr_e("Earnings", "sell_media"); ?>');
data.addColumn('string', '<?php echo esc_js( __("Day", "sell_media") ); ?>');
data.addColumn('number', '<?php echo esc_js( __("Earnings", "sell_media") ); ?>');
data.addRows([
<?php
$num_of_days = apply_filters( 'sell_media_earnings_per_day_days', 30 ); // show payments for the last 30 days
Expand All @@ -231,16 +279,16 @@ function drawChart() {
$month = date( 'n', $day_time ) + 1;
$year = date( 'Y', $day_time );
?>
['<?php echo date( "n/d", mktime( 0, 0, 0, $month, $day, $year ) ); ?>',
<?php echo sell_media_get_sales_by_date( $day, $month, $year ); ?>,
['<?php echo esc_js( date( "n/d", mktime( 0, 0, 0, $month, $day, $year ) ) ); ?>',
<?php echo esc_js( sell_media_get_sales_by_date( $day, $month, $year ) ); ?>,
],
<?php $i--;
endwhile;
?>
]);

var options = {
title: "<?php esc_attr_e('Earnings per day', 'sell_media'); ?>",
title: "<?php echo esc_js('Earnings per day', 'sell_media'); ?>",
fontSize: "12"
};

Expand All @@ -257,21 +305,21 @@ function drawChart() {
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', '<?php esc_attr_e("Month", "sell_media"); ?>');
data.addColumn('number', '<?php esc_attr_e("Earnings", "sell_media"); ?>');
data.addColumn('string', '<?php echo esc_js( __("Month", "sell_media") ); ?>');
data.addColumn('number', '<?php echo esc_js( __("Earnings", "sell_media") ); ?>');
data.addRows([
<?php
$i = 1;
while($i <= 12) : ?>
['<?php echo sell_media_month_num_to_name($i) . ' ' . date("Y"); ?>', <?php echo sell_media_get_sales_by_date(null, $i, date('Y') ); ?>,
['<?php echo esc_js( sell_media_month_num_to_name($i) . ' ' . date("Y") ); ?>', <?php echo esc_js( sell_media_get_sales_by_date(null, $i, date('Y') ) ); ?>,
],
<?php
$i++;
endwhile;
?>
]);
var options = {
title: "<?php esc_attr_e('Earnings per month', 'sell_media'); ?>",
title: "<?php echo esc_js( __('Earnings per month', 'sell_media') ); ?>",
fontSize: "12"
};

Expand All @@ -288,15 +336,15 @@ function drawChart() {
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', '<?php esc_attr_e("Year", "sell_media"); ?>');
data.addColumn('number', '<?php esc_attr_e("Earnings", "sell_media"); ?>');
data.addColumn('string', '<?php echo esc_js( __("Year", "sell_media") ); ?>');
data.addColumn('number', '<?php echo esc_js( __("Earnings", "sell_media") ); ?>');
data.addRows([
<?php
$current = date('Y');
$i = $current - 12;
while($current >= $i) : ?>
['<?php echo esc_attr( $i ); ?>',
<?php echo sell_media_get_sales_by_date(null, null, $i ); ?>,
['<?php echo esc_js( $i ); ?>',
<?php echo esc_js( sell_media_get_sales_by_date(null, null, $i ) ); ?>,
],
<?php
$i++;
Expand All @@ -305,7 +353,7 @@ function drawChart() {
]);

var options = {
title: "<?php esc_attr_e('Earnings per year', 'sell_media'); ?>",
title: "<?php echo esc_js( __('Earnings per year', 'sell_media') ); ?>",
fontSize: "12"
};

Expand Down Expand Up @@ -396,25 +444,33 @@ function sell_media_payment_header( $columns ){
* @since 0.1
*/
function sell_media_payment_content( $column, $post_id ){
$arr = array(
'a' => array(
'href' => true,
),
'br' => array(),
);

switch( $column ) {
case "id":
$html = '<a href="' . site_url() . '/wp-admin/post.php?post=' . $post_id . '&action=edit">';
$html .= $post_id;
$html .= '</a>';
echo $html;

echo wp_kses( $html, $arr );
break;
case "products":
$products = Sell_Media()->payments->get_products( $post_id );
if ( $products ) foreach ( $products as $product ) {
$type = ( ! empty( $product['type'] ) ) ? ' (' . $product['type'] . ') ' : '';
echo apply_filters( 'sell_media_payment_products_column', $product['name'] . $type, $post_id ) . '<br />';
echo wp_kses( apply_filters( 'sell_media_payment_products_column', $product['name'] . $type, $post_id ) . '<br />', $arr);
}
break;
case "customer":
echo Sell_Media()->payments->get_buyer_name( $post_id );
echo esc_html( Sell_Media()->payments->get_buyer_name( $post_id ) );
break;
case "total":
echo sell_media_get_currency_symbol() . number_format( Sell_Media()->payments->get_meta_key( $post_id, 'total' ), 2, '.', '' );
echo esc_html( sell_media_get_currency_symbol() ) . number_format( Sell_Media()->payments->get_meta_key( $post_id, 'total' ), 2, '.', '' );
break;
default:
break;
Expand Down
7 changes: 2 additions & 5 deletions inc/admin-system-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
function sell_media_system_info_callback_fn() {
?>
<div class="wrap">
<h2><?php esc_attr_e( 'System Info', 'sell_media' ); ?></h2>
<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" style="width:100%;height:100%;min-height:450px;" name="sell-media-sysinfo" title="To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).">
<?php esc_attr_e(sell_media_get_system_info(),'sell_media'); ?>
</textarea>

<h2><?php esc_html_e( 'System Info', 'sell_media' ); ?></h2>
<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" style="width:100%;height:100%;min-height:450px;" name="sell-media-sysinfo" title="To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac)."><?php esc_textarea(__(sell_media_get_system_info(),'sell_media')); ?></textarea>
</div>
<?php }

Expand Down
Loading

0 comments on commit e2b0a1e

Please sign in to comment.