Exemple #1
0
/**
 * Retrieve the renewal label for a notice
 *
 * @since 3.0
 * @return String
 */
function edd_sl_get_renewal_notice_period_label($notice_id = 0)
{
    $notice = edd_sl_get_renewal_notice($notice_id);
    $periods = edd_sl_get_renewal_notice_periods();
    $label = $periods[$notice['send_period']];
    return apply_filters('edd_sl_get_renewal_notice_period_label', $label, $notice_id);
}
 public function send_renewal_reminder($license_id = 0, $notice_id = 0)
 {
     global $edd_options;
     if (empty($license_id)) {
         return;
     }
     $send = true;
     $license = get_post($license_id);
     $send = apply_filters('edd_sl_send_renewal_reminder', $send, $license_id, $notice_id);
     if (!$license || 'edd_license' != $license->post_type || !$send || !empty($license->post_parent)) {
         return;
     }
     $customer = false;
     if (class_exists('EDD_Customer')) {
         $payment_id = get_post_meta($license->ID, '_edd_sl_payment_id', true);
         $customer_id = edd_get_payment_customer_id($payment_id);
         $customer = new EDD_Customer($customer_id);
     }
     if (empty($customer->id)) {
         // Remove the post title to get just the email
         $title = $license->post_title;
         $title_pos = strpos($title, '-') + 1;
         $length = strlen($title);
         $email_to = substr($title, $title_pos, $length);
     }
     $email_to = !empty($customer->id) ? $customer->email : $email_to;
     $notice = edd_sl_get_renewal_notice($notice_id);
     $message = !empty($notice['message']) ? $notice['message'] : __("Hello {name},\n\nYour license key for {product_name} is about to expire.\n\nIf you wish to renew your license, simply click the link below and follow the instructions.\n\nYour license expires on: {expiration}.\n\nYour expiring license key is: {license_key}.\n\nRenew now: {renewal_link}.", "edd_sl");
     $message = $this->filter_reminder_template_tags($message, $license_id);
     $subject = !empty($notice['subject']) ? $notice['subject'] : __('Your License Key is About to Expire', 'edd_sl');
     $subject = $this->filter_reminder_template_tags($subject, $license_id);
     $message = stripslashes($message);
     $subject = stripslashes($subject);
     if (class_exists('EDD_Emails')) {
         $sent = EDD()->emails->send($email_to, $subject, $message);
     } else {
         $from_name = get_bloginfo('name');
         $from_email = get_bloginfo('admin_email');
         $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
         $headers .= "Reply-To: " . $from_email . "\r\n";
         $sent = wp_mail($email_to, $subject, $message, $headers);
     }
     if ($sent) {
         $log_id = wp_insert_post(array('post_title' => __('LOG - Renewal Notice Sent', 'edd_sl'), 'post_name' => 'log-notice-sent-' . $license_id . '-' . md5(time()), 'post_type' => 'edd_license_log', 'post_status' => 'publish'));
         add_post_meta($log_id, '_edd_sl_log_license_id', $license_id);
         add_post_meta($log_id, '_edd_sl_renewal_notice_id', (int) $notice_id);
         wp_set_object_terms($log_id, 'renewal_notice', 'edd_log_type', false);
         add_post_meta($license_id, sanitize_key('_edd_sl_renewal_sent_' . $notice['send_period']), time());
         // Prevent renewal notices from being sent more than once
     }
 }
 * Edit Renewal Notice
 *
 * @package     EDD Software Licensing
 * @copyright   Copyright (c) 2014, Pippin Williamson
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       3.0
 */
// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
if (!isset($_GET['notice']) || !is_numeric($_GET['notice'])) {
    //wp_die( __( 'Something went wrong.', 'edd_sl' ), __( 'Error', 'edd_sl' ) );
}
$notice_id = absint($_GET['notice']);
$notice = edd_sl_get_renewal_notice($notice_id);
?>
<h2><?php 
_e('Edit Renewal Notice', 'edd_sl');
?>
 - <a href="<?php 
echo admin_url('edit.php?post_type=download&page=edd-settings&tab=extensions');
?>
" class="add-new-h2"><?php 
_e('Go Back', 'edd_sl');
?>
</a></h2>
<form id="edd-edit-renewal-notice" action="" method="post">
	<table class="form-table">
		<tbody>
			<tr>
Exemple #4
0
/**
 * Displays the renewal notices options
 *
 * @access      public
 * @since       3.0
 * @param 		$args array option arguments
 * @return      void
*/
function edd_sl_renewal_notices_settings($args)
{
    $notices = edd_sl_get_renewal_notices();
    //echo '<pre>'; print_r( $notices ); echo '</pre>';
    ob_start();
    ?>
	<table id="edd_sl_renewal_notices" class="wp-list-table widefat fixed posts">
		<thead>
			<tr>
				<th class="edd-sl-renewal-subject-col" scope="col"><?php 
    _e('Subject', 'edd_sl');
    ?>
</th>
				<th class="edd-sl-renewal-period-col" scope="col"><?php 
    _e('Send Period', 'edd_sl');
    ?>
</th>
				<th scope="col"><?php 
    _e('Actions', 'edd_sl');
    ?>
</th>
			</tr>
		</thead>
		<?php 
    if (!empty($notices)) {
        $i = 1;
        ?>
			<?php 
        foreach ($notices as $key => $notice) {
            $notice = edd_sl_get_renewal_notice($key);
            ?>
			<tr <?php 
            if ($i % 2 == 0) {
                echo 'class="alternate"';
            }
            ?>
>
				<td><?php 
            echo esc_html(stripslashes($notice['subject']));
            ?>
</td>
				<td><?php 
            echo esc_html(edd_sl_get_renewal_notice_period_label($key));
            ?>
</td>
				<td>
					<a href="<?php 
            echo esc_url(admin_url('edit.php?post_type=download&page=edd-license-renewal-notice&edd_sl_action=edit-renewal-notice&notice=' . $key));
            ?>
" class="edd-sl-edit-renewal-notice" data-key="<?php 
            echo esc_attr($key);
            ?>
"><?php 
            _e('Edit', 'edd_sl');
            ?>
</a>&nbsp;|
					<a href="<?php 
            echo esc_url(wp_nonce_url(admin_url('edit.php?post_type=download&page=edd-license-renewal-notice&edd_action=delete_renewal_notice&notice-id=' . $key)));
            ?>
" class="edd-delete"><?php 
            _e('Delete', 'edd_sl');
            ?>
</a>
				</td>
			</tr>
			<?php 
            $i++;
        }
        ?>
		<?php 
    }
    ?>
	</table>
	<p>
		<a href="<?php 
    echo esc_url(admin_url('edit.php?post_type=download&page=edd-license-renewal-notice&edd_sl_action=add-renewal-notice'));
    ?>
" class="button-secondary" id="edd_sl_add_renewal_notice"><?php 
    _e('Add Renewal Notice', 'edd_sl');
    ?>
</a>
	</p>
	<?php 
    echo ob_get_clean();
}
 /**
  * Output the subject column
  *
  * @access      public
  * @since       3.0
  * @return      void
  */
 function column_subject($item)
 {
     $notice_id = get_post_meta($item->ID, '_edd_sl_renewal_notice_id', true);
     $notice = edd_sl_get_renewal_notice($notice_id);
     return $notice['subject'];
 }