Changeset 2927437
- Timestamp:
- 06/18/2023 01:32:40 AM (22 months ago)
- Location:
- subscription
- Files:
-
- 84 added
- 5 deleted
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
subscription/trunk/assets/css/status.css
r2797349 r2927437 1 1 span.subscrpt-pending { 2 3 4 5 2 background: #535050; 3 color: white; 4 text-transform: capitalize; 5 padding: 8px; 6 6 } 7 7 8 8 span.subscrpt-active { 9 10 11 12 9 background: green; 10 color: white; 11 text-transform: capitalize; 12 padding: 8px; 13 13 } 14 14 15 15 span.subscrpt-expired { 16 17 18 19 16 background: red; 17 color: white; 18 text-transform: capitalize; 19 padding: 8px; 20 20 } 21 21 22 22 span.subscrpt-cancelled { 23 24 25 26 23 background: #cecece; 24 color: white; 25 text-transform: capitalize; 26 padding: 8px; 27 27 } 28 29 span.subscrpt-pe_cancelled { 30 background: #ecb03e; 31 color: white; 32 text-transform: capitalize; 33 padding: 8px; 34 } -
subscription/trunk/assets/js/admin.js
r2685408 r2927437 1 1 jQuery(document).ready(() => { 2 let sdevs_enable_subscription = jQuery("input#subscrpt_enable"); 3 sdevs_enable_subscription.change(() => { 4 if (sdevs_enable_subscription.is(":checked")) { 5 jQuery(".show_if_subscription").show(); 6 } else { 7 jQuery(".show_if_subscription").hide(); 8 } 9 }); 2 let sdevs_enable_subscription = jQuery("input#subscrpt_enable"); 3 sdevs_enable_subscription.change(() => { 10 4 if (sdevs_enable_subscription.is(":checked")) { 11 5 jQuery(".show_if_subscription").show(); 12 6 } else { 13 7 jQuery(".show_if_subscription").hide(); 14 8 } 9 }); 10 if (sdevs_enable_subscription.is(":checked")) { 11 jQuery(".show_if_subscription").show(); 12 } else { 13 jQuery(".show_if_subscription").hide(); 14 } 15 15 16 jQuery(document).on("woocommerce_variations_loaded", () => { 17 let total_variations = JSON.parse(jQuery(".woocommerce_variations").attr("data-total")); 18 for (let index = 0; index < total_variations; index++) { 19 let element = document.getElementById("subscrpt_enable[" + index + "]"); 20 if (element && element.checked) { 21 jQuery("div#show_if_subscription_" + index).show(); 22 } else { 23 jQuery("div#show_if_subscription_" + index).hide(); 24 } 25 } 26 }); 16 jQuery(document).on("woocommerce_variations_loaded", () => { 17 let total_variations = JSON.parse( 18 jQuery(".woocommerce_variations").attr("data-total") 19 ); 20 for (let index = 0; index < total_variations; index++) { 21 let element = document.getElementById("subscrpt_enable[" + index + "]"); 22 if (element && element.checked) { 23 jQuery("div#show_if_subscription_" + index).show(); 24 } else { 25 jQuery("div#show_if_subscription_" + index).hide(); 26 } 27 } 28 }); 29 30 let subscrpt_renewal_process = jQuery("#subscrpt_renewal_process"); 31 subscrpt_renewal_process.change(() => { 32 if (subscrpt_renewal_process.val() === "manual") { 33 jQuery("#sdevs_renewal_cart_tr").show(); 34 } else { 35 jQuery("#sdevs_renewal_cart_tr").hide(); 36 } 37 }); 38 if (subscrpt_renewal_process.val() === "manual") { 39 jQuery("#sdevs_renewal_cart_tr").show(); 40 } else { 41 jQuery("#sdevs_renewal_cart_tr").hide(); 42 } 27 43 }); 28 44 29 45 function hellochange(index) { 30 if (document.getElementById("subscrpt_enable[" + index + "]").checked) { 31 jQuery("div#show_if_subscription_" + index).show(); 46 if (document.getElementById("subscrpt_enable[" + index + "]").checked) { 47 jQuery("div#show_if_subscription_" + index).show(); 48 } else { 49 jQuery("div#show_if_subscription_" + index).hide(); 50 } 51 } 52 53 let subscrpt_product_type = jQuery("#product-type"); 54 let latest_value_of_subscrpt_product_type = subscrpt_product_type.val(); 55 56 subscrpt_product_type.change(() => { 57 if ( 58 "simple" === latest_value_of_subscrpt_product_type && 59 "simple" !== subscrpt_product_type.val() && 60 "variable" !== subscrpt_product_type.val() 61 ) { 62 const confirmTypeChange = confirm( 63 "Are you sure to change the product type ? If product type changed then You'll lose related subscriptions beacuse of they can't be renewed !" 64 ); 65 if (confirmTypeChange) { 66 latest_value_of_subscrpt_product_type = subscrpt_product_type.val(); 32 67 } else { 33 jQuery("div#show_if_subscription_" + index).hide();68 subscrpt_product_type.val("simple"); 34 69 } 35 } 70 } 71 }); -
subscription/trunk/includes/Admin.php
r2797349 r2927437 11 11 use SpringDevs\Subscription\Admin\Subscriptions; 12 12 use SpringDevs\Subscription\Illuminate\Comments; 13 use SpringDevs\Subscription\Illuminate\Cron;14 13 use SpringDevs\Subscription\Illuminate\Email; 15 14 use SpringDevs\Subscription\Illuminate\Order; 16 use SpringDevs\Subscription\Illuminate\RegisterPostStatus;17 use SpringDevs\Subscription\Illuminate\Subscriptions as IlluminateSubscriptions;18 15 19 16 /** 20 17 * The admin class 21 18 */ 22 class Admin { 19 class Admin 20 { 23 21 24 22 … … 26 24 * Initialize the class 27 25 */ 28 public function __construct() { 26 public function __construct() 27 { 29 28 $this->dispatch_actions(); 30 29 new Required(); 31 new IlluminateSubscriptions(); 32 new Cron(); 30 new Illuminate(); 33 31 new Menu(); 34 32 new Product(); 35 33 new Subscriptions(); 36 new RegisterPostStatus();37 34 new Order(); 38 35 new AdminOrder(); … … 48 45 * @return void 49 46 */ 50 public function dispatch_actions() { 47 public function dispatch_actions() 48 { 51 49 } 52 50 } -
subscription/trunk/includes/Admin/Links.php
r2797349 r2927437 12 12 class Links { 13 13 14 public function __construct() { 14 /** 15 * Initialize the class 16 */ 17 public function __construct() { 15 18 add_filter( 'plugin_action_links_' . plugin_basename( SUBSCRPT_FILE ), array( $this, 'plugin_action_links' ) ); 16 19 } 17 20 18 21 /** 19 22 * Add plugin action links 20 23 * 21 * @param array $links array24 * @param array $links Plugin Links. 22 25 */ 23 26 public function plugin_action_links( $links ) { -
subscription/trunk/includes/Admin/Menu.php
r2708268 r2927437 10 10 class Menu { 11 11 12 /** 13 * Initialize the class 14 */ 12 15 public function __construct() { 13 16 add_action( 'admin_menu', array( $this, 'create_admin_menu' ) ); 14 17 } 15 18 19 /** 20 * Create Subscriptions Menu. 21 */ 16 22 public function create_admin_menu() { 17 23 $parent_slug = 'edit.php?post_type=subscrpt_order'; -
subscription/trunk/includes/Admin/Order.php
r2708268 r2927437 2 2 3 3 namespace SpringDevs\Subscription\Admin; 4 5 use SpringDevs\Subscription\Illuminate\Helper; 4 6 5 7 /** … … 10 12 class Order { 11 13 14 /** 15 * Initialize the class 16 */ 12 17 public function __construct() { 13 18 add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); 14 19 } 15 20 21 /** 22 * Related Subscriptions meta box on Orders. 23 */ 16 24 public function add_meta_boxes() { 17 $order_id = get_the_ID(); 18 $order_meta = get_post_meta( $order_id, '_order_subscrpt_data', true ); 19 if ( ! empty( $order_meta ) && is_array( $order_meta ) && isset( $order_meta['status'] ) ) { 25 $order_id = get_the_ID(); 26 $histories = Helper::get_subscriptions_from_order( $order_id ); 27 if ( is_array( $histories ) ) { 28 $order = wc_get_order( $order_id ); 20 29 add_meta_box( 21 30 'subscrpt_order_related', … … 24 33 'shop_order', 25 34 'normal', 26 'default' 35 'default', 36 array( 37 'histories' => $histories, 38 'order' => $order, 39 ) 27 40 ); 28 41 } 29 42 } 30 43 31 public function subscrpt_order_related() { 32 $order_id = get_the_ID(); 33 $order_meta = get_post_meta( $order_id, '_order_subscrpt_data', true ); 34 if ( empty( $order_meta ) && ! is_array( $order_meta ) && ! isset( $order_meta['status'] ) ) { 35 return; 36 } 44 /** 45 * Display content related subscriptions. 46 * 47 * @param mixed $order_post Current Order. 48 * @param mixed $info Meta box Info. 49 */ 50 public function subscrpt_order_related( $order_post, $info ) { 51 $histories = $info['args']['histories']; 52 $order = $info['args']['order']; 37 53 38 54 include 'views/related-subscriptions.php'; -
subscription/trunk/includes/Admin/Product.php
r2797349 r2927437 10 10 class Product { 11 11 12 public function __construct() { 13 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); 14 add_filter( 'product_type_options', array( $this, 'add_product_type_options' ) ); 15 add_action( 'woocommerce_product_options_general_product_data', array( $this, 'subscription_forms' ) ); 16 add_action( 'save_post_product', array( $this, 'save_subscrpt_data' ) ); 17 } 12 /** 13 * Initialize the class 14 */ 15 public function __construct() { 16 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); 17 add_filter( 'product_type_options', array( $this, 'add_product_type_options' ) ); 18 add_action( 'woocommerce_product_options_general_product_data', array( $this, 'subscription_forms' ) ); 19 add_action( 'save_post_product', array( $this, 'save_subscrpt_data' ) ); 20 } 18 21 19 public function enqueue_assets() { 20 wp_enqueue_script( 'sdevs_subscription_admin' ); 21 } 22 /** 23 * Enqueue Assets. 24 */ 25 public function enqueue_assets() { 26 wp_enqueue_script( 'sdevs_subscription_admin' ); 27 } 22 28 23 public function add_product_type_options( $product_type_options ) { 24 $screen = get_current_screen(); 25 $value = 'no'; 26 if ( $screen->parent_base == 'edit' ) { 27 $post_meta = get_post_meta( get_the_ID(), 'subscrpt_general', true ); 28 $value = ! empty( $post_meta ) && $post_meta['enable'] ? 'yes' : 'no'; 29 } 29 /** 30 * Display Enable Subscription Checkbox on product data tab. 31 * 32 * @param array $product_type_options Product Type options on Data tab. 33 * 34 * @return array 35 */ 36 public function add_product_type_options( $product_type_options ) { 37 $screen = get_current_screen(); 38 $value = 'no'; 39 if ( 'edit' === $screen->parent_base ) { 40 $post_meta = get_post_meta( get_the_ID(), '_subscrpt_meta', true ); 41 $value = ! empty( $post_meta ) && $post_meta['enable'] ? 'yes' : 'no'; 42 } 30 43 31 32 33 34 35 36 37 38 44 $wrapper_class = apply_filters( 'subscrpt_simple_enable_checkbox_classes', 'show_if_simple' ); 45 $product_type_options['subscrpt_enable'] = array( 46 'id' => 'subscrpt_enable', 47 'wrapper_class' => $wrapper_class, 48 'label' => __( 'Subscription', 'sdevs_subscrpt' ), 49 'description' => __( 'Enable Subscriptions', 'sdevs_subscrpt' ), 50 'default' => $value, 51 ); 39 52 40 41 53 return $product_type_options; 54 } 42 55 43 public function subscription_forms() { 44 if ( function_exists( 'subscrpt_pro_activated' ) ) { 45 if ( subscrpt_pro_activated() ) { 46 do_action( 'subscrpt_simple_pro_fields', get_the_ID() ); 47 } else { 48 $timing_types = array( 49 'days' => 'Daily', 50 'weeks' => 'Weekly', 51 'months' => 'Monthly', 52 'years' => 'Yearly', 53 ); 54 $subscrpt_timing = null; 55 $subscrpt_cart_txt = 'subscribe'; 56 $subscrpt_user_cancell = 'yes'; 56 /** 57 * Display forms on product create/edit. 58 */ 59 public function subscription_forms() { 60 if ( function_exists( 'subscrpt_pro_activated' ) ) { 61 if ( subscrpt_pro_activated() ) { 62 do_action( 'subscrpt_simple_pro_fields', get_the_ID() ); 63 } else { 64 $timing_types = array( 65 'days' => __( 'Daily', 'sdevs_subscrpt' ), 66 'weeks' => __( 'Weekly', 'sdevs_subscrpt' ), 67 'months' => __( 'Monthly', 'sdevs_subscrpt' ), 68 'years' => __( 'Yearly', 'sdevs_subscrpt' ), 69 ); 70 $subscrpt_timing = null; 71 $subscrpt_cart_txt = 'subscribe'; 72 $subscrpt_user_cancell = 'yes'; 57 73 58 59 60 $post_meta = get_post_meta( get_the_ID(), 'subscrpt_general', true );61 62 63 64 65 66 67 68 69 70 74 $screen = get_current_screen(); 75 if ( $screen->parent_base == 'edit' ) { 76 $post_meta = get_post_meta( get_the_ID(), '_subscrpt_meta', true ); 77 if ( ! empty( $post_meta ) && is_array( $post_meta ) ) { 78 $subscrpt_timing = $post_meta['type']; 79 $subscrpt_cart_txt = $post_meta['cart_txt']; 80 $subscrpt_user_cancell = $post_meta['user_cancell']; 81 } 82 } 83 include 'views/product-form.php'; 84 } 85 } 86 } 71 87 72 public function save_subscrpt_data( $post_id ) { 73 if ( ! isset( $_POST['subscrpt_enable'] ) ) { 74 return; 75 } 76 if ( function_exists( 'subscrpt_pro_activated' ) ) { 77 if ( subscrpt_pro_activated() ) { 78 return; 79 } 80 } 81 $subscrpt_enable = (bool) $_POST['subscrpt_enable']; 82 $subscrpt_time = 1; 83 $subscrpt_timing = sanitize_text_field( $_POST['subscrpt_timing'] ); 84 $subscrpt_trial_time = null; 85 $subscrpt_trial_timing = null; 86 $subscrpt_cart_txt = sanitize_text_field( $_POST['subscrpt_cart_txt'] ); 87 $subscrpt_user_cancell = sanitize_text_field( $_POST['subscrpt_user_cancell'] ); 88 $data = array( 89 'enable' => $subscrpt_enable, 90 'time' => $subscrpt_time, 91 'type' => $subscrpt_timing, 92 'trial_time' => $subscrpt_trial_time, 93 'trial_type' => $subscrpt_trial_timing, 94 'cart_txt' => $subscrpt_cart_txt, 95 'user_cancell' => $subscrpt_user_cancell, 96 ); 97 update_post_meta( $post_id, 'subscrpt_general', $data ); 98 } 88 public function save_subscrpt_data( $post_id ) { 89 if ( ! isset( $_POST['subscrpt_enable'] ) ) { 90 return; 91 } 92 if ( function_exists( 'subscrpt_pro_activated' ) ) { 93 if ( subscrpt_pro_activated() ) { 94 return; 95 } 96 } 97 $subscrpt_enable = (bool) $_POST['subscrpt_enable']; 98 $subscrpt_time = 1; 99 $subscrpt_timing = sanitize_text_field( $_POST['subscrpt_timing'] ); 100 $subscrpt_trial_time = null; 101 $subscrpt_trial_timing = null; 102 $subscrpt_cart_txt = sanitize_text_field( $_POST['subscrpt_cart_txt'] ); 103 $subscrpt_user_cancell = sanitize_text_field( $_POST['subscrpt_user_cancell'] ); 104 $data = array( 105 'enable' => $subscrpt_enable, 106 'time' => $subscrpt_time, 107 'type' => $subscrpt_timing, 108 'trial_time' => $subscrpt_trial_time, 109 'trial_type' => $subscrpt_trial_timing, 110 'cart_txt' => $subscrpt_cart_txt, 111 'user_cancell' => $subscrpt_user_cancell, 112 ); 113 114 update_post_meta( $post_id, '_subscrpt_meta', $data ); 115 } 99 116 } -
subscription/trunk/includes/Admin/Settings.php
r2708268 r2927437 10 10 class Settings { 11 11 12 /** 13 * Initialize the class. 14 */ 12 15 public function __construct() { 13 16 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); … … 21 24 22 25 /** 23 * register settings options26 * Register settings options. 24 27 **/ 25 28 public function register_settings() { 29 register_setting( 'subscrpt_settings', 'subscrpt_renewal_process' ); 30 register_setting( 'subscrpt_settings', 'subscrpt_manual_renew_cart_notice' ); 26 31 register_setting( 'subscrpt_settings', 'subscrpt_active_role' ); 27 32 register_setting( 'subscrpt_settings', 'subscrpt_unactive_role' ); … … 29 34 } 30 35 36 /** 37 * Settings HTML. 38 */ 31 39 public function settings_content() { 32 40 include 'views/settings.php'; -
subscription/trunk/includes/Admin/Subscriptions.php
r2797349 r2927437 12 12 class Subscriptions { 13 13 14 /** 15 * Initialize the class. 16 */ 14 17 public function __construct() { 15 18 add_action( 'admin_enqueue_scripts', array( $this, 'custom_enqueue_scripts' ) ); … … 25 28 add_action( 'save_post', array( $this, 'save_subscrpt_order' ) ); 26 29 add_filter( 'woocommerce_order_item_get_formatted_meta_data', array( $this, 'remove_order_meta' ), 10, 1 ); 30 add_filter( 'bulk_actions-edit-subscrpt_order', array( $this, 'remove_bulk_actions' ) ); 31 } 32 33 public function remove_bulk_actions( $actions ) { 34 unset( $actions['edit'] ); 35 return $actions; 27 36 } 28 37 … … 65 74 $columns['subscrpt_status'] = __( 'Status', 'sdevs_subscrpt' ); 66 75 unset( $columns['date'] ); 76 unset( $columns['cb'] ); 67 77 return $columns; 68 78 } 69 79 70 80 public function add_custom_columns_data( $column, $post_id ) { 71 $post_meta = get_post_meta( $post_id, '_ subscrpt_order_general', true );81 $post_meta = get_post_meta( $post_id, '_order_subscrpt_meta', true ); 72 82 $order = wc_get_order( $post_meta['order_id'] ); 73 83 if ( $order ) { … … 85 95 echo date( 'F d, Y', $post_meta['next_date'] ); 86 96 } elseif ( $column == 'subscrpt_status' ) { 97 $status_obj = get_post_status_object( get_post_status( $post_id ) ); 87 98 ?> 88 <span class="subscrpt-<?php echo esc_html( get_post_status( $post_id ) ); ?>"><?php echo esc_html( get_post_status( $post_id )); ?></span>99 <span class="subscrpt-<?php echo esc_html( $status_obj->name ); ?>"><?php echo esc_html( $status_obj->label ); ?></span> 89 100 <?php 90 101 } … … 94 105 } 95 106 107 /** 108 * Create metaboxes for admin subscriptions. 109 */ 96 110 public function create_meta_boxes() { 97 111 remove_meta_box( 'submitdiv', 'subscrpt_order', 'side' ); 98 // Save Data99 112 add_meta_box( 100 113 'subscrpt_order_save_post', … … 144 157 145 158 public function subscrpt_order_history() { 146 $order_histories = get_post_meta( get_the_ID(), '_subscrpt_order_history', true ); 147 rsort( $order_histories ); 159 $subscription_id = get_the_ID(); 160 global $wpdb; 161 $table_name = $wpdb->prefix . 'subscrpt_order_relation'; 162 // @phpcs:ignore 163 $order_histories = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i WHERE subscription_id=%d', array( $table_name, $subscription_id ) ) ); 164 148 165 include 'views/order-history.php'; 149 166 } … … 163 180 } 164 181 182 /** 183 * Save subscription HTML. 184 */ 165 185 public function subscrpt_order_save_post() { 166 186 $actions = array( … … 178 198 ), 179 199 array( 200 'label' => __( 'Pending Cancel Subscription', 'sdevs_subscrpt' ), 201 'value' => 'pe_cancelled', 202 ), 203 array( 180 204 'label' => __( 'Cancel Subscription', 'sdevs_subscrpt' ), 181 205 'value' => 'cancelled', … … 187 211 188 212 public function subscrpt_customer_info() { 189 $post_meta = get_post_meta( get_the_ID(), '_ subscrpt_order_general', true );213 $post_meta = get_post_meta( get_the_ID(), '_order_subscrpt_meta', true ); 190 214 $order = wc_get_order( $post_meta['order_id'] ); 191 215 if ( ! $order ) { … … 196 220 197 221 public function subscrpt_order_info() { 198 $post_meta = get_post_meta( get_the_ID(), '_subscrpt_order_general', true ); 199 $order_item = null; 200 $order = wc_get_order( $post_meta['order_id'] ); 222 $post_meta = get_post_meta( get_the_ID(), '_order_subscrpt_meta', true ); 223 $order = wc_get_order( $post_meta['order_id'] ); 201 224 if ( ! $order ) { 202 225 return; 203 226 } 204 foreach ( $order->get_items() as $cart_item ) { 205 if ( $cart_item['product_id'] == $post_meta['product_id'] ) { 206 $order_item = $cart_item; 207 break; 208 } 209 } 227 $order_item = $order->get_item( $post_meta['order_item_id'] ); 210 228 include 'views/subscription-order-info.php'; 211 229 } … … 263 281 ); 264 282 265 $post_meta = get_post_meta( $post_id, '_ subscrpt_order_general', true );283 $post_meta = get_post_meta( $post_id, '_order_subscrpt_meta', true ); 266 284 if ( $action === 'active' ) { 267 285 $order = wc_get_order( $post_meta['order_id'] ); 268 286 $order->update_status( 'completed' ); 269 287 } 270 $data = array( 271 'post' => $post_id, 272 'product' => $post_meta['product_id'], 273 ); 274 if ( isset( $post_meta['variation_id'] ) ) { 275 $data['variation'] = $post_meta['variation_id']; 276 } 277 Action::status( $action, sanitize_text_field( $_POST['post_author'] ), $data ); 288 289 Action::status( $action, $post_id ); 278 290 } 279 291 } -
subscription/trunk/includes/Admin/views/order-history.php
r2708268 r2927437 2 2 <thead> 3 3 <tr> 4 <th><?php _e( 'Order', 'sdevs_subscrpt' ); ?></th> 4 <th><?php 5 6 use SpringDevs\Subscription\Illuminate\Helper; 7 8 _e( 'Order', 'sdevs_subscrpt' ); ?></th> 5 9 <th></th> 6 10 <th><?php _e( 'Date', 'sdevs_subscrpt' ); ?></th> … … 12 16 <?php foreach ( $order_histories as $order_history ) : ?> 13 17 <?php 14 $order = wc_get_order( $order_history['order_id'] ); 18 $order = wc_get_order( $order_history->order_id ); 19 $order_item = $order->get_item( $order_history->order_item_id ); 15 20 ?> 16 21 <tr> 17 <td><a href="<?php echo wp_kses_post( get_edit_post_link( $order_history ['order_id'] ) ); ?>" target="_blank"><?php echo wp_kses_post( $order_history['order_id']); ?></a></td>18 <td><?php echo wp_kses_post( $order_history['stats']); ?></td>22 <td><a href="<?php echo wp_kses_post( get_edit_post_link( $order_history->order_id ) ); ?>" target="_blank"><?php echo wp_kses_post( $order_history->order_id ); ?></a></td> 23 <td><?php echo wp_kses_post( order_relation_type_cast( $order_history->type ) ); ?></td> 19 24 <td> 20 25 <?php 21 26 if ( $order ) { 22 echo wp_kses_post( date( 'F d, Y', strtotime( $order->get_date_created() ) ) );}27 echo wp_kses_post( gmdate( 'F d, Y', strtotime( $order->get_date_created() ) ) );} 23 28 ?> 24 29 </td> … … 29 34 ?> 30 35 </td> 31 <td><?php echo wp_kses_post( $order_history['subtotal_price_html']); ?></td>36 <td><?php echo wp_kses_post( Helper::format_price_with_order_item( $order_item->get_total(), $order_item->get_id() ) ); ?></td> 32 37 </tr> 33 38 <?php endforeach; ?> -
subscription/trunk/includes/Admin/views/product-form.php
r2708268 r2927437 1 <div class="option_group sdevs-form sdevs_panel show_if_subscription hide" style="padding: 10px;"> 1 <div class="option_group sdevs-form sdevs_panel show_if_simple hide" style="padding: 10px;"> 2 <div class="show_if_subscription"> 3 <input name="_subscript_nonce" type="hidden" value="<?php echo esc_attr( wp_create_nonce( '_subscript_edit_product_nonce' ) ); ?>" /> 2 4 <strong style="margin: 10px;"><?php _e( 'Subscription Settings', 'sdevs_subscrpt' ); ?></strong> 3 5 <?php … … 40 42 ?> 41 43 </div> 44 </div> -
subscription/trunk/includes/Admin/views/related-subscriptions.php
r2708268 r2927437 3 3 <tr> 4 4 <th></th> 5 <th><?php _e( 'Started on', 'sdevs_subscrpt' ); ?></th> 5 <th><?php 6 7 use SpringDevs\Subscription\Illuminate\Helper; 8 9 _e( 'Started on', 'sdevs_subscrpt' ); ?></th> 6 10 <th><?php _e( 'Recurring', 'sdevs_subscrpt' ); ?></th> 7 11 <th><?php _e( 'Expiry date', 'sdevs_subscrpt' ); ?></th> … … 11 15 <tbody> 12 16 <?php 13 foreach ( $ order_meta['posts'] as $post) :14 if ( get_the_title( $post ) != '' ) :15 $ post_meta = get_post_meta( $post, '_subscrpt_order_general', true);16 17 foreach ( $histories as $history ) : 18 $post_meta = get_post_meta( $history->subscription_id, '_order_subscrpt_meta', true ); 19 $order_item = $order->get_item( $history->order_item_id ); 20 ?> 17 21 <tr> 18 22 <td> 19 <a href="<?php echo wp_kses_post( get_edit_post_link( $ post ) ); ?>" target="_blank">#<?php echo esc_html( $post ); ?> - <?php echo esc_html( get_the_title( $post_meta['product_id']) ); ?></a>23 <a href="<?php echo wp_kses_post( get_edit_post_link( $history->subscription_id ) ); ?>" target="_blank">#<?php echo esc_html( $history->subscription_id ); ?> - <?php echo esc_html( $order_item->get_name() ); ?></a> 20 24 </td> 21 25 <td> 22 26 <?php echo $post_meta['trial'] == null ? esc_html( date( 'F d, Y', $post_meta['start_date'] ) ) : '+' . esc_html( $post_meta['trial'] ) . ' ' . __( 'free trial', 'sdevs_subscrpt' ); ?> 23 27 </td> 24 <td><?php echo wp_kses_post( $post_meta['total_price_html']); ?></td>28 <td><?php echo wp_kses_post( Helper::format_price_with_order_item( $order_item->get_total(), $order_item->get_id() ) ); ?></td> 25 29 <td><?php echo esc_html( $post_meta['trial'] == null ? date( 'F d, Y', $post_meta['next_date'] ) : date( 'F d, Y', $post_meta['start_date'] ) ); ?></td> 26 <td><?php echo esc_html( get_post_status( $ post) ); ?></td>30 <td><?php echo esc_html( get_post_status( $history->subscription_id ) ); ?></td> 27 31 </tr> 28 32 <?php 29 endif;30 33 endforeach; 31 34 ?> -
subscription/trunk/includes/Admin/views/settings.php
r2708268 r2927437 1 1 <div class="wrap"> 2 2 <?php settings_errors(); ?> 3 <h1><?php _e( 'Subscription Settings', 'sdevs_subscrpt' ); ?></h1>4 <p><?php _e( 'These settings can effect Subscription', 'sdevs_subscrpt' ); ?></p>3 <h1><?php esc_html_e( 'Subscription Settings', 'sdevs_subscrpt' ); ?></h1> 4 <p><?php esc_html_e( 'These settings can effect Subscription', 'sdevs_subscrpt' ); ?></p> 5 5 <form method="post" action="options.php"> 6 6 <?php settings_fields( 'subscrpt_settings' ); ?> … … 10 10 <tr> 11 11 <th scope="row"> 12 <label for="subscrpt_renewal_process"> 13 <?php esc_html_e( 'Renewal Process', 'sdevs_subscrpt' ); ?> 14 </label> 15 </th> 16 <td> 17 <select name="subscrpt_renewal_process" id="subscrpt_renewal_process" 18 <?php 19 if ( ! subscrpt_pro_activated() ) { 20 echo esc_attr( 'disabled' );} 21 ?> 22 > 23 <option value="auto">Automatic</option> 24 <option value="manual" 25 <?php 26 if ( ! subscrpt_pro_activated() || 'manual' === get_option( 'subscrpt_renewal_process', 'auto' ) ) { 27 echo esc_attr( 'selected' ); 28 } 29 ?> 30 >Manual</option> 31 </select> 32 <?php if ( ! subscrpt_pro_activated() ) : ?> 33 <p style="color: red;" class="description"><?php echo wp_kses_post( '<b>Automatic</b> renewal is available for Pro version only !!' ); ?></p> 34 <?php else : ?> 35 <p class="description"><?php esc_html_e( 'How renewal process will be done after Subscription Expired !!', 'sdevs_subscrpt' ); ?></p> 36 <?php endif; ?> 37 </td> 38 </tr> 39 <tr id="sdevs_renewal_cart_tr"> 40 <th scope="row"> 41 <label for="subscrpt_manual_renew_cart_notice"> 42 <?php esc_html_e( 'Renewal Cart Notice', 'sdevs_subscrpt' ); ?> 43 </label> 44 </th> 45 <td> 46 <input id="subscrpt_manual_renew_cart_notice" name="subscrpt_manual_renew_cart_notice" class="large-text" value="<?php echo wp_kses_post( get_option( 'subscrpt_manual_renew_cart_notice' ) ); ?>" type="text"/> 47 <p class="description"><?php echo wp_kses_post( 'Display Notice when Renewal Subscription product add to cart !! It\'s only available for <b>Manual Renewal Process</b>.', 'sdevs_subscrpt' ); ?></p> 48 </td> 49 </tr> 50 <tr> 51 <th scope="row"> 12 52 <label for="subscrpt_active_role"> 13 <?php _e( 'Subscriber Default Role', 'sdevs_subscrpt' ); ?>53 <?php esc_html_e( 'Subscriber Default Role', 'sdevs_subscrpt' ); ?> 14 54 </label> 15 55 </th> … … 18 58 <?php wp_dropdown_roles( get_option( 'subscrpt_active_role', 'subscriber' ) ); ?> 19 59 </select> 20 <p class="description"><?php _e( 'When a subscription is activated, either manually or after a successful purchase, new users will be assigned this role.', 'sdevs_subscrpt' ); ?></p>60 <p class="description"><?php esc_html_e( 'When a subscription is activated, either manually or after a successful purchase, new users will be assigned this role.', 'sdevs_subscrpt' ); ?></p> 21 61 </td> 22 62 </tr> … … 24 64 <th scope="row"> 25 65 <label for="subscrpt_unactive_role"> 26 <?php _e( 'Subscriber Unactive Role', 'sdevs_subscrpt' ); ?>66 <?php esc_html_e( 'Subscriber Unactive Role', 'sdevs_subscrpt' ); ?> 27 67 </label> 28 68 </th> … … 31 71 <?php wp_dropdown_roles( get_option( 'subscrpt_unactive_role', 'customer' ) ); ?> 32 72 </select> 33 <p class="description"><?php _e( "If a subscriber's subscription is manually cancelled or expires, will be assigned this role.", 'sdevs_subscrpt' ); ?></p>73 <p class="description"><?php esc_html_e( "If a subscriber's subscription is manually cancelled or expires, will be assigned this role.", 'sdevs_subscrpt' ); ?></p> 34 74 </td> 35 75 </tr> -
subscription/trunk/includes/Admin/views/subscription-order-info.php
r2797349 r2927437 3 3 <tr> 4 4 <?php 5 $product_name = apply_filters( 'subscrpt_filter_product_name', get_the_title( $post_meta['product_id'] ), $post_meta ); 6 $product_link = apply_filters( 'subscrpt_filter_product_permalink', get_the_permalink( $post_meta['product_id'] ), $post_meta ); 5 6 use SpringDevs\Subscription\Illuminate\Helper; 7 8 $product_name = $order_item->get_name(); 9 $product_link = get_the_permalink( $order_item->get_product_id() ); 7 10 ?> 8 11 <th scope="row">Product : </th> … … 13 16 <tr> 14 17 <th scope="row">Cost : </th> 15 <td><?php echo wp_kses_post( wc_price( $order->get_item_subtotal( $order_item, false, true ), array( 'currency' => $order->get_currency()) ) ); ?></td>18 <td><?php echo wp_kses_post( Helper::format_price_with_order_item( $order_item->get_total(), $order_item->get_id() ) ); ?></td> 16 19 </tr> 17 20 <tr> 18 21 <th scope="row">Qty : </th> 19 <td>x<?php echo esc_html( $post_meta['qty'] ); ?></td> 20 </tr> 21 <tr> 22 <th scope="row">Amount : </th> 23 <td><strong><?php echo wp_kses_post( $post_meta['subtotal_price_html'] ); ?></strong></td> 22 <td>x<?php echo esc_html( $order_item->get_quantity() ); ?></td> 24 23 </tr> 25 24 <?php if ( ! empty( $post_meta['trial'] ) ) : ?> … … 43 42 <tr> 44 43 <th scope="row">Status:</th> 45 <td><span class="subscrpt-<?php echo get_post_status(); ?>"><?php echo get_post_status (); ?></span></td>44 <td><span class="subscrpt-<?php echo get_post_status(); ?>"><?php echo get_post_status_object( get_post_status() )->label; ?></span></td> 46 45 </tr> 47 46 <tr> -
subscription/trunk/includes/Admin/views/subscription-save-meta.php
r2708268 r2927437 1 1 <p class="subscrpt_sub_box"> 2 2 <select id="subscrpt_order_type" name="subscrpt_order_action"> 3 <option value=""><?php _e( 'choose action', 'sdevs_subscrpt' ); ?></option>3 <option value=""><?php esc_html_e( 'Choose Action', 'sdevs_subscrpt' ); ?></option> 4 4 <?php foreach ( $actions as $action ) : ?> 5 5 <option value="<?php echo esc_html( $action['value'] ); ?>" 6 6 <?php 7 7 if ( $action['value'] == $status ) { 8 8 echo 'selected';} -
subscription/trunk/includes/Ajax.php
r2797349 r2927437 17 17 } 18 18 19 /** 20 * Install the WooCommerce Plugin. 21 */ 19 22 public function install_woocommerce_plugin() { 20 23 include ABSPATH . 'wp-admin/includes/plugin-install.php'; … … 57 60 } 58 61 59 $title = sprintf( __( 'Installing Plugin: %s', "sdevs_subscrpt"), $api->name . ' ' . $api->version );62 $title = sprintf( __( 'Installing Plugin: %s', 'sdevs_subscrpt' ), $api->name . ' ' . $api->version ); 60 63 $nonce = 'install-plugin_' . $plugin; 61 64 $url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin ); … … 70 73 } 71 74 75 /** 76 * Active WooComerce Plugin. 77 */ 72 78 public function activate_woocommerce_plugin() { 73 79 activate_plugin( 'woocommerce/woocommerce.php' ); -
subscription/trunk/includes/Assets.php
r2797349 r2927437 75 75 'in_footer' => true, 76 76 ), 77 'sdevs_installer' => array(77 'sdevs_installer' => array( 78 78 'src' => $plugin_js_assets_path . 'installer.js', 79 79 'deps' => array( 'jquery' ), … … 94 94 95 95 $styles = array( 96 'subscrpt_admin_css' => array(96 'subscrpt_admin_css' => array( 97 97 'src' => $plugin_css_assets_path . 'admin.css', 98 98 ), … … 100 100 'src' => $plugin_css_assets_path . 'status.css', 101 101 ), 102 'sdevs_installer' => array(102 'sdevs_installer' => array( 103 103 'src' => $plugin_css_assets_path . 'installer.css', 104 104 ), -
subscription/trunk/includes/Frontend.php
r2708268 r2927437 6 6 use SpringDevs\Subscription\Frontend\Downloadable; 7 7 use SpringDevs\Subscription\Frontend\MyAccount; 8 use SpringDevs\Subscription\Frontend\Order as FrontendOrder; 8 9 use SpringDevs\Subscription\Frontend\Product; 9 use SpringDevs\Subscription\Frontend\Thankyou;10 use SpringDevs\Subscription\Illuminate\AutoRenewal;11 10 use SpringDevs\Subscription\Illuminate\Cron; 12 11 use SpringDevs\Subscription\Illuminate\Email; 13 12 use SpringDevs\Subscription\Illuminate\Order; 14 use SpringDevs\Subscription\Illuminate\RegisterPostStatus;15 use SpringDevs\Subscription\Illuminate\Subscriptions;16 13 17 14 /** 18 15 * Frontend handler class 19 16 */ 20 class Frontend { 17 class Frontend 18 { 21 19 22 20 /** 23 21 * Frontend constructor. 24 22 */ 25 public function __construct() { 26 new Subscriptions(); 27 new Cron(); 28 new RegisterPostStatus(); 23 public function __construct() 24 { 25 new Illuminate(); 29 26 new Product(); 30 new Thankyou();27 new FrontendOrder(); 31 28 new ActionController(); 32 29 new MyAccount(); … … 34 31 new Order(); 35 32 new Email(); 36 new AutoRenewal();37 33 } 38 34 } -
subscription/trunk/includes/Frontend/ActionController.php
r2708268 r2927437 5 5 6 6 use SpringDevs\Subscription\Illuminate\Action; 7 use SpringDevs\Subscription\Illuminate\AutoRenewal; 7 8 8 9 /** … … 14 15 15 16 17 /** 18 * Initialize the class 19 */ 16 20 public function __construct() { 17 21 add_action( 'before_single_subscrpt_content', array( $this, 'control_action_subscrpt' ) ); 18 22 } 19 23 24 /** 25 * Take Subscription Action. 26 */ 20 27 public function control_action_subscrpt() { 21 28 if ( ! ( isset( $_GET['subscrpt_id'] ) && isset( $_GET['action'] ) && isset( $_GET['wpnonce'] ) ) ) { 22 29 return; 23 30 } 24 $subscrpt_id = sanitize_text_field( $_GET['subscrpt_id']);25 $action = sanitize_text_field( $_GET['action']);26 $wpnonce = sanitize_text_field( $_GET['wpnonce']);31 $subscrpt_id = sanitize_text_field( wp_unslash( $_GET['subscrpt_id'] ) ); 32 $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); 33 $wpnonce = sanitize_text_field( wp_unslash( $_GET['wpnonce'] ) ); 27 34 if ( ! wp_verify_nonce( $wpnonce, 'subscrpt_nonce' ) ) { 28 wp_die( __( 'Sorry !! You cannot permit to access.', 'sdevs_subscrpt') );35 wp_die( esc_html( __( 'Sorry !! You cannot permit to access.', 'sdevs_subscrpt' ) ) ); 29 36 } 30 if ( $action == 'renew' ) { 31 $this->RenewProduct( $subscrpt_id ); 32 } elseif ( $action == 'early-renew' ) { 33 $post_meta = get_post_meta( $subscrpt_id, '_subscrpt_order_general', true ); 34 $data = array( 35 'post' => $subscrpt_id, 36 'product' => $post_meta['product_id'], 37 ); 38 if ( isset( $post_meta['variation_id'] ) ) { 39 $data['variation'] = $post_meta['variation_id']; 37 if ( 'renew' === $action && 'manual' === subscrpt_get_renewal_process() ) { 38 $this->manual_renew_product( $subscrpt_id ); 39 } elseif ( 'cancelled' === $action ) { 40 $status = get_post_status( $subscrpt_id ); 41 $user_cancel = get_post_meta( $subscrpt_id, '_subscrpt_user_cancel', true ); 42 if ( 'no' === $user_cancel ) { 43 return; 44 } elseif ( 'active' === $status ) { 45 Action::status( 'pe_cancelled', $subscrpt_id ); 46 } else { 47 Action::status( $action, $subscrpt_id ); 40 48 } 41 Action::status( 'renew', get_current_user_id(), $data ); 42 } elseif ( $action == 'renew-on' ) { 43 update_post_meta( $subscrpt_id, '_subscrpt_auto_renew', 1 ); 44 } elseif ( $action == 'renew-off' ) { 45 update_post_meta( $subscrpt_id, '_subscrpt_auto_renew', 0 ); 49 } elseif ( 'reactive' === $action ) { 50 Action::status( 'active', $subscrpt_id ); 46 51 } else { 47 $post_meta = get_post_meta( $subscrpt_id, '_subscrpt_order_general', true ); 48 if ( $action == 'cancelled' ) { 49 $product_meta = get_post_meta( $post_meta['product_id'], 'subscrpt_general', true ); 50 if ( $product_meta['user_cancell'] == 'no' ) { 51 return; 52 } 53 } 54 wp_update_post( 55 array( 56 'ID' => $subscrpt_id, 57 'post_status' => $action, 58 ) 59 ); 60 $data = array( 61 'post' => $subscrpt_id, 62 'product' => $post_meta['product_id'], 63 ); 64 if ( isset( $post_meta['variation_id'] ) ) { 65 $data['variation'] = $post_meta['variation_id']; 66 } 67 Action::status( $action, get_current_user_id(), $data ); 52 do_action( 'subscrpt_execute_actions', $subscrpt_id, $action ); 68 53 } 69 echo ( "<script>location.href = '" . get_permalink( wc_get_page_id( 'myaccount' ) ) . 'view-subscrpt/' . $subscrpt_id . "';</script>" ); 54 // phpcs:ignore 55 echo ( "<script>location.href = '" . wc_get_endpoint_url( 'view-subscription', $subscrpt_id, wc_get_page_permalink( 'myaccount' ) ) . "';</script>" ); 70 56 } 71 57 72 public function RenewProduct( $subscrpt_id ) { 73 $post_meta = get_post_meta( $subscrpt_id, '_subscrpt_order_general', true ); 58 /** 59 * Manually Renew Subscription. 60 * 61 * @param Int $subscrpt_id Subscription ID. 62 */ 63 public function manual_renew_product( $subscrpt_id ) { 64 $post_meta = get_post_meta( $subscrpt_id, '_order_subscrpt_meta', true ); 65 $product_id = get_post_meta( $subscrpt_id, '_subscrpt_product_id', true ); 66 74 67 $variation_id = 0; 75 68 if ( isset( $post_meta['variation_id'] ) ) { 76 69 $variation_id = $post_meta['variation_id']; 77 70 } 71 72 WC()->cart->empty_cart(); 73 78 74 WC()->cart->add_to_cart( 79 $p ost_meta['product_id'],75 $product_id, 80 76 1, 81 77 $variation_id, … … 83 79 array( 'renew_subscrpt' => true ) 84 80 ); 85 wc_add_notice( __( 'Product added to cart', 'sdevs_subscrpt' ), 'success' ); 81 82 wc_add_notice( get_option( 'subscrpt_manual_renew_cart_notice' ), 'success' ); 86 83 $this->redirect( wc_get_cart_url() ); 87 84 } 88 85 86 /** 87 * Redirect on URL. 88 * 89 * @param String $url URL. 90 */ 89 91 public function redirect( $url ) { 90 92 ?> -
subscription/trunk/includes/Frontend/Downloadable.php
r2709135 r2927437 2 2 3 3 namespace SpringDevs\Subscription\Frontend; 4 5 use SpringDevs\Subscription\Illuminate\Helper; 4 6 5 7 /** … … 15 17 16 18 public function check_download_items( $downloads ) { 17 $expired_items = get_user_meta( get_current_user_id(), '_subscrpt_expired_items', true ); 18 $pending_items = get_user_meta( get_current_user_id(), '_subscrpt_pending_items', true ); 19 $cancelled_items = get_user_meta( get_current_user_id(), '_subscrpt_cancelled_items', true ); 19 foreach ( $downloads as $key => $download ) { 20 $unactive_items = Helper::subscription_exists( $download['product_id'], array( 'expired', 'cancelled', 'pending' ) ); 20 21 21 if ( ! is_array( $expired_items ) ) { 22 $expired_items = array(); 23 } 24 if ( ! is_array( $pending_items ) ) { 25 $pending_items = array(); 26 } 27 if ( ! is_array( $cancelled_items ) ) { 28 $cancelled_items = array(); 29 } 30 31 $expired_products = array(); 32 foreach ( $expired_items as $expired_item ) { 33 $expired_products[] = $expired_item['product']; 34 } 35 36 $pending_products = array(); 37 foreach ( $pending_items as $pending_item ) { 38 $pending_products[] = $pending_item['product']; 39 } 40 41 $cancelled_products = array(); 42 foreach ( $cancelled_items as $cancelled_item ) { 43 $cancelled_products[] = $cancelled_item['product']; 44 } 45 46 foreach ( $downloads as $key => $download ) { 47 if ( in_array( $download['product_id'], $expired_products ) ) { 48 unset( $downloads[ $key ] ); 49 } 50 if ( in_array( $download['product_id'], $pending_products ) ) { 51 unset( $downloads[ $key ] ); 52 } 53 if ( in_array( $download['product_id'], $cancelled_products ) ) { 22 if ( $unactive_items ) { 54 23 unset( $downloads[ $key ] ); 55 24 } -
subscription/trunk/includes/Frontend/MyAccount.php
r2797349 r2927437 1 1 <?php 2 3 2 4 3 namespace SpringDevs\Subscription\Frontend; … … 9 8 * @package SpringDevs\Subscription\Frontend 10 9 */ 11 class MyAccount { 10 class MyAccount 11 { 12 12 13 public function __construct() { 14 add_action( 'init', array( $this, 'flush_rewrite_rules' ) ); 15 add_filter( 'woocommerce_account_menu_items', array( $this, 'custom_my_account_menu_items' ) ); 16 add_filter( 'the_title', array( $this, 'change_endpoint_title' ), 10, 2 ); 17 add_filter( 'woocommerce_get_query_vars', array( $this, 'custom_query_vars' ) ); 18 add_action( 'woocommerce_account_view-subscrpt_endpoint', array( $this, 'view_subscrpt_content' ) ); 19 add_action( 'woocommerce_account_subscrpt-endpoint_endpoint', array( $this, 'subscrpt_endpoint_content' ) ); 20 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); 13 /** 14 * Initialize the class 15 */ 16 public function __construct() 17 { 18 add_action('init', array($this, 'flush_rewrite_rules')); 19 add_filter('woocommerce_account_menu_items', array($this, 'custom_my_account_menu_items')); 20 add_filter('woocommerce_endpoint_view-subscription_title', array($this, 'change_single_title')); 21 add_filter('the_title', array($this, 'change_lists_title'), 10); 22 add_filter('woocommerce_get_query_vars', array($this, 'custom_query_vars')); 23 add_action('woocommerce_account_view-subscription_endpoint', array($this, 'view_subscrpt_content')); 24 add_action('woocommerce_account_subscriptions_endpoint', array($this, 'subscrpt_endpoint_content')); 25 add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); 21 26 } 22 27 23 public function custom_query_vars( $query_vars ) { 24 $query_vars['view-subscrpt'] = 'view-subscrpt'; 28 /** 29 * Add custom url on MyAccount. 30 * 31 * @param array $query_vars query_vars. 32 * 33 * @return array 34 */ 35 public function custom_query_vars(array $query_vars): array 36 { 37 $query_vars['view-subscription'] = 'view-subscription'; 25 38 return $query_vars; 26 39 } 27 40 28 public function view_subscrpt_content( $value ) { 29 wc_get_template( 'myaccount/single-subscrpt.php', array( 'id' => $value ), 'simple-subscription', SUBSCRPT_TEMPLATES ); 41 /** 42 * Display Subscription Content. 43 * 44 * @param Int $id Post ID. 45 */ 46 public function view_subscrpt_content(int $id) 47 { 48 $post_meta = get_post_meta($id, '_order_subscrpt_meta', true); 49 $order = wc_get_order($post_meta['order_id']); 50 $order_item = $order->get_item($post_meta['order_item_id']); 51 $status = get_post_status($id); 52 $user_cancel = get_post_meta($id, '_subscrpt_user_cancel', true); 53 54 $subscrpt_nonce = wp_create_nonce('subscrpt_nonce'); 55 $action_buttons = array(); 56 57 if ('cancelled' !== $status) { 58 if (in_array($status, array('pending', 'active', 'on_hold'), true) && 'yes' === $user_cancel) { 59 $action_buttons['cancel'] = array( 60 'url' => subscrpt_get_action_url('cancelled', $subscrpt_nonce, $id), 61 'label' => __('Cancel', 'sdevs_subscrpt'), 62 'class' => 'cancel', 63 ); 64 } elseif (trim($status) === trim('pe_cancelled')) { 65 $action_buttons['reactive'] = array( 66 'url' => subscrpt_get_action_url('reactive', $subscrpt_nonce, $id), 67 'label' => __('Reactive', 'sdevs_subscrpt'), 68 ); 69 } elseif ('expired' === $status && 'pending' !== $order->get_status()) { 70 $action_buttons['renew'] = array( 71 'url' => subscrpt_get_action_url('renew', $subscrpt_nonce, $id), 72 'label' => __('Renew', 'sdevs_subscrpt'), 73 ); 74 } 75 76 if ('pending' === $order->get_status()) { 77 $action_buttons['pay_now'] = array( 78 'url' => $order->get_checkout_payment_url(), 79 'label' => __('Pay now', 'sdevs_subscrpt'), 80 ); 81 } 82 } 83 84 $post_status_object = get_post_status_object($status); 85 $action_buttons = apply_filters('subscrpt_single_action_buttons', $action_buttons, $id, $subscrpt_nonce, $status); 86 87 wc_get_template( 88 'myaccount/single.php', 89 array( 90 'id' => $id, 91 'post_meta' => $post_meta, 92 'order' => $order, 93 'order_item' => $order_item, 94 'status' => $post_status_object, 95 'user_cancel' => $user_cancel, 96 'action_buttons' => $action_buttons, 97 'wp_button_class' => wc_wp_theme_get_element_class_name('button') ? ' ' . wc_wp_theme_get_element_class_name('button') : '', 98 ), 99 'subscription', 100 SUBSCRPT_TEMPLATES 101 ); 30 102 } 31 103 … … 33 105 * Re-write flush 34 106 */ 35 public function flush_rewrite_rules() { 36 add_rewrite_endpoint( 'subscrpt-endpoint', EP_ROOT | EP_PAGES ); 107 public function flush_rewrite_rules() 108 { 109 add_rewrite_endpoint('subscriptions', EP_ROOT | EP_PAGES); 37 110 flush_rewrite_rules(); 38 111 } 39 112 40 /** 41 * @param $title 42 * @param $endpoint 43 * 44 * @return string|void 45 */ 46 public function change_endpoint_title( $title, $endpoint ) { 113 /** 114 * Change View Subscription Title 115 * 116 * @param String $title Title. 117 * 118 * @return String 119 */ 120 public function change_single_title(string $title): string 121 { 122 /* translators: %s: Subscription ID */ 123 return sprintf(__('Subscription #%s', 'sdevs_subscrpt'), get_query_var('view-subscription')); 124 } 125 126 /** 127 * Change Subscription Lists Title 128 * 129 * @param String $title Title. 130 * 131 * @return String 132 */ 133 public function change_lists_title(string $title): string 134 { 47 135 global $wp_query; 48 $is_endpoint = isset( $wp_query->query_vars['subscrpt-endpoint'] ); 49 $is_single = isset( $wp_query->query_vars['view-subscrpt'] ); 50 if ( $is_endpoint && ! is_admin() && is_main_query() && in_the_loop() && is_account_page() ) { 51 $title = __( 'My Subscriptions', 'sdevs_subscrpt' ); 52 remove_filter( 'the_title', array( $this, 'change_endpoint_title' ) ); 53 } elseif ( $is_single && ! is_admin() && is_main_query() && in_the_loop() && is_account_page() ) { 54 $title = __( 'Subscription #' . get_query_var( 'view-subscrpt' ), 'sdevs_subscrpt' ); 55 remove_filter( 'the_title', array( $this, 'change_endpoint_title' ) ); 136 $is_endpoint = isset($wp_query->query_vars['subscriptions']); 137 if ($is_endpoint && !is_admin() && is_account_page()) { 138 $title = __('My Subscriptions', 'sdevs_subscrpt'); 56 139 } 57 140 return $title; … … 59 142 60 143 /** 61 * @param $items 62 * @return mixed 144 * Filter menu items. 145 * 146 * @param array $items MyAccount menu items. 147 * @return array 63 148 */ 64 public function custom_my_account_menu_items( $items ) { 149 public function custom_my_account_menu_items(array $items): array 150 { 65 151 $logout = $items['customer-logout']; 66 unset( $items['customer-logout']);67 $items['subscr pt-endpoint'] = __( 'Subscriptions', 'sdevs_subscrpt');68 $items['customer-logout'] 152 unset($items['customer-logout']); 153 $items['subscriptions'] = __('Subscriptions', 'sdevs_subscrpt'); 154 $items['customer-logout'] = $logout; 69 155 return $items; 70 156 } 71 157 72 158 /** 73 * Bookable EndPoint Content159 * Subscription Single EndPoint Content 74 160 */ 75 public function subscrpt_endpoint_content() { 76 wc_get_template( 'myaccount/subscriptions.php', array(), 'simple-subscription', SUBSCRPT_TEMPLATES ); 161 public function subscrpt_endpoint_content() 162 { 163 wc_get_template( 164 'myaccount/subscriptions.php', 165 array( 166 'wp_button_class' => wc_wp_theme_get_element_class_name('button') ? ' ' . wc_wp_theme_get_element_class_name('button') : '', 167 ), 168 'subscription', 169 SUBSCRPT_TEMPLATES 170 ); 77 171 } 78 172 173 /** 174 * Enqueue assets 175 */ 79 176 public function enqueue_styles() 80 177 { 81 wp_enqueue_style( 'subscrpt_status_css');178 wp_enqueue_style('subscrpt_status_css'); 82 179 } 83 180 } -
subscription/trunk/includes/Frontend/Product.php
r2797349 r2927437 11 11 class Product { 12 12 13 13 /** 14 * Initialize the class 15 */ 14 16 public function __construct() { 15 17 add_filter( 'woocommerce_product_single_add_to_cart_text', array( $this, 'change_single_add_to_cart_text' ) ); … … 23 25 add_action( 'woocommerce_before_cart_totals', array( $this, 'change_cart_calculates' ) ); 24 26 add_action( 'woocommerce_cart_calculate_fees', array( $this, 'add_cart_fee' ) ); 25 add_filter( 'woocommerce_add_cart_item_data', array( $this, 'add_to_cart_item_data' ), 10, 3);27 add_filter( 'woocommerce_add_cart_item_data', array( $this, 'add_to_cart_item_data' ), 10, 2 ); 26 28 add_filter( 'woocommerce_is_purchasable', array( $this, 'check_if_purchasable' ), 10, 2 ); 27 29 add_filter( 'woocommerce_loop_add_to_cart_link', array( $this, 'remove_button_active_products' ), 10, 2 ); 28 30 add_action( 'woocommerce_single_product_summary', array( $this, 'text_if_active' ) ); 29 add_action( 'woocommerce_checkout_create_order_line_item', array( $this, 'save_order_item_product_meta' ), 10, 4);31 add_action( 'woocommerce_checkout_create_order_line_item', array( $this, 'save_order_item_product_meta' ), 10, 3 ); 30 32 add_filter( 'woocommerce_cart_get_total', array( $this, 'calculates_cart_total' ) ); 31 33 } 32 34 35 /** 36 * Update Cart total 37 * 38 * @param mixed $total Cart total. 39 * 40 * @return mixed 41 */ 33 42 public function calculates_cart_total( $total ) { 34 43 $cart_items = WC()->cart->cart_contents; 35 44 foreach ( $cart_items as $cart_item ) { 36 45 $conditional_key = apply_filters( 'subscrpt_filter_checkout_conditional_key', $cart_item['product_id'], $cart_item ); 37 $post_meta = get_post_meta( $conditional_key, ' subscrpt_general', true );38 $has_trial = Helper:: Check_Trial( $conditional_key );46 $post_meta = get_post_meta( $conditional_key, '_subscrpt_meta', true ); 47 $has_trial = Helper::check_trial( $conditional_key ); 39 48 if ( is_array( $post_meta ) && $post_meta['enable'] ) { 40 49 if ( ! empty( $post_meta['trial_time'] ) && $post_meta['trial_time'] > 0 && $has_trial ) { … … 48 57 } 49 58 59 /** 60 * Add signup fee if available 61 * 62 * @param \WC_Cart $cart Cart. 63 */ 50 64 public function add_cart_fee( $cart ) { 51 65 $cart_items = WC()->cart->cart_contents; … … 53 67 foreach ( $cart_items as $cart_item ) { 54 68 $conditional_key = apply_filters( 'subscrpt_filter_checkout_conditional_key', $cart_item['product_id'], $cart_item ); 55 $post_meta = get_post_meta( $conditional_key, ' subscrpt_general', true );69 $post_meta = get_post_meta( $conditional_key, '_subscrpt_meta', true ); 56 70 if ( is_array( $post_meta ) && $post_meta['enable'] ) : 57 $has_trial = Helper:: Check_Trial( $conditional_key );71 $has_trial = Helper::check_trial( $conditional_key ); 58 72 if ( $has_trial && isset( $post_meta['signup_fee'] ) ) { 59 73 $signup_fee += (int) $post_meta['signup_fee']; … … 66 80 } 67 81 68 public function save_order_item_product_meta( $item, $cart_item_key, $cart_item, $order ) { 82 /** 83 * Save renew meta 84 * 85 * @param Object $item Item. 86 * @param String $cart_item_key Cart Item Key. 87 * @param Array $cart_item Cart Item. 88 */ 89 public function save_order_item_product_meta( $item, $cart_item_key, $cart_item ) { 69 90 if ( isset( $cart_item['renew_subscrpt'] ) ) { 70 91 $item->update_meta_data( '_renew_subscrpt', $cart_item['renew_subscrpt'] ); … … 72 93 } 73 94 95 /** 96 * Display notice if already purchased. 97 */ 74 98 public function text_if_active() { 75 99 global $product; … … 77 101 return; 78 102 } 79 $post_meta = get_post_meta( $product->get_id(), ' subscrpt_general', true );80 $unexpired = Helper:: Check_un_expired( $product->get_id() );103 $post_meta = get_post_meta( $product->get_id(), '_subscrpt_meta', true ); 104 $unexpired = Helper::subscription_exists( $product->get_id(), array( 'active', 'pending' ) ); 81 105 if ( is_array( $post_meta ) && isset( $post_meta['limit'] ) ) { 82 if ( $post_meta['limit'] == 'unlimited') {106 if ( 'unlimited' === $post_meta['limit'] ) { 83 107 return; 84 108 } 85 if ( $post_meta['limit'] == 'one') {109 if ( 'one' === $post_meta['limit'] ) { 86 110 if ( ! $unexpired ) { 87 return; 88 } 89 } 90 if ( $post_meta['limit'] == 'only_one' ) { 91 if ( ! subscrpt_check_trial( $product->get_id() ) ) { 92 echo '<strong>' . __( 'You Already Purchased These Product!', 'sdevs_subscrpt' ) . '</strong>'; 93 } 94 } 95 } 96 if ( $unexpired ) { 97 echo '<strong>' . __( 'You Already Purchased These Product!', 'sdevs_subscrpt' ) . '</strong>'; 98 } 99 } 100 111 return false; 112 } else { 113 echo '<strong>' . esc_html_e( 'You Already Subscribed These Product!', 'sdevs_subscrpt' ) . '</strong>'; 114 } 115 } 116 if ( 'only_one' === $post_meta['limit'] ) { 117 if ( ! Helper::check_trial( $product->get_id() ) ) { 118 echo '<strong>' . esc_html_e( 'You Already Subscribed These Product!', 'sdevs_subscrpt' ) . '</strong>'; 119 } 120 } 121 } 122 } 123 124 /** 125 * Remove button if product already subscribed. 126 * 127 * @param mixed $button Button. 128 * @param \Wc_Product $product Product. 129 * 130 * @return mixed 131 */ 101 132 public function remove_button_active_products( $button, $product ) { 102 133 if ( $product->is_type( 'variable' ) && ! subscrpt_pro_activated() ) { 103 134 return $button; 104 135 } 105 $unexpired = Helper:: Check_un_expired( $product->get_id() );136 $unexpired = Helper::subscription_exists( $product->get_id(), array( 'active', 'pending' ) ); 106 137 if ( $unexpired ) { 107 138 return; … … 110 141 } 111 142 143 /** 144 * Check if product pruchasable. 145 * 146 * @param Boolean $is_purchasable True\False. 147 * @param \WC_Product $product Product. 148 * 149 * @return Boolean 150 */ 112 151 public function check_if_purchasable( $is_purchasable, $product ) { 113 152 if ( $product->is_type( 'variable' ) ) { 114 153 return $is_purchasable; 115 154 } 116 $unexpired = Helper:: Check_un_expired( $product->get_id() );155 $unexpired = Helper::subscription_exists( $product->get_id(), array( 'active', 'pending' ) ); 117 156 if ( $unexpired ) { 118 157 return false; … … 121 160 } 122 161 123 public function add_to_cart_item_data( $cart_item_data, $product_id, $variation_id ) { 124 $expired = Helper::CheckExpired( $product_id ); 162 /** 163 * Add renew status. 164 * 165 * @param Array $cart_item_data cart_item_data. 166 * @param Int $product_id Product ID. 167 * 168 * @return Array 169 */ 170 public function add_to_cart_item_data( $cart_item_data, $product_id ) { 171 $expired = Helper::subscription_exists( $product_id, 'expired' ); 125 172 if ( $expired ) { 126 173 $cart_item_data['renew_subscrpt'] = true; … … 129 176 } 130 177 178 /** 179 * Set cart subtotal. 180 * 181 * @param \WC_Cart $cart Cart. 182 */ 131 183 public function change_cart_calculates( $cart ) { 132 184 $cart_items = WC()->cart->cart_contents; 133 185 foreach ( $cart_items as $cart_item ) { 134 186 $conditional_key = apply_filters( 'subscrpt_filter_checkout_conditional_key', $cart_item['product_id'], $cart_item ); 135 $post_meta = get_post_meta( $conditional_key, ' subscrpt_general', true );136 $has_trial = Helper:: Check_Trial( $conditional_key );187 $post_meta = get_post_meta( $conditional_key, '_subscrpt_meta', true ); 188 $has_trial = Helper::check_trial( $conditional_key ); 137 189 if ( is_array( $post_meta ) && $post_meta['enable'] ) { 138 190 if ( ! empty( $post_meta['trial_time'] ) && $post_meta['trial_time'] > 0 && $has_trial ) { 139 191 $subtotal = WC()->cart->get_subtotal() - $cart_item['line_subtotal']; 140 // $total = WC()->cart->total - $cart_item["line_subtotal"];141 192 WC()->cart->set_subtotal( $subtotal ); 142 // WC()->cart->set_total($total); 143 } 144 } 145 } 146 } 147 193 } 194 } 195 } 196 } 197 198 /** 199 * Change single product add-to-cart button text. 200 * 201 * @param String $text Add-to-cart button Text. 202 */ 148 203 public function change_single_add_to_cart_text( $text ) { 149 204 global $product; 150 if ( ! $product ) {205 if ( ! $product || $product->is_type( 'variable' ) || '' === $product->get_price() ) { 151 206 return $text; 152 207 } 153 if ( $product->is_type( 'variable' ) ) { 154 return $text; 155 } 156 $post_meta = get_post_meta( $product->get_id(), 'subscrpt_general', true ); 157 if ( is_array( $post_meta ) && isset( $post_meta['limit'] ) && $post_meta['limit'] == 'unlimited' ) { 158 return $post_meta['cart_txt']; 159 } 160 $expired = Helper::CheckExpired( $product->get_id() ); 208 $post_meta = get_post_meta( $product->get_id(), '_subscrpt_meta', true ); 209 $expired = Helper::subscription_exists( $product->get_id(), 'expired' ); 161 210 if ( $expired ) : 162 211 $text = __( 'renew', 'sdevs_subscrpt' ); 163 elseif ( is_array( $post_meta ) && $post_meta['enable'] ) :212 elseif ( is_array( $post_meta ) && $post_meta['enable'] && '' !== $post_meta['cart_txt'] ) : 164 213 $text = $post_meta['cart_txt']; 165 214 endif; … … 167 216 } 168 217 218 /** 219 * Add trial, signup fee etc. with product price. 220 * 221 * @param mixed $price Price. 222 * @param \WC_Product $product Product. 223 * 224 * @return mixed 225 */ 169 226 public function change_price_html( $price, $product ) { 170 if ( $product->is_type( 'variable' ) ) {227 if ( $product->is_type( 'variable' ) || '' === $price ) { 171 228 return $price; 172 229 } 173 $post_meta = get_post_meta( $product->get_id(), 'subscrpt_general', true ); 230 231 $post_meta = get_post_meta( $product->get_id(), '_subscrpt_meta', true ); 174 232 if ( is_array( $post_meta ) && $post_meta['enable'] ) : 175 $time = $post_meta['time'] == 1? null : $post_meta['time'];233 $time = '1' === $post_meta['time'] ? null : $post_meta['time']; 176 234 $type = Helper::get_typos( $post_meta['time'], $post_meta['type'] ); 177 $has_trial = Helper:: Check_Trial( $product->get_id() );235 $has_trial = Helper::check_trial( $product->get_id() ); 178 236 $trial = null; 179 237 $signup_fee_html = null; 180 238 if ( ! empty( $post_meta['trial_time'] ) && $post_meta['trial_time'] > 0 && $has_trial ) { 181 239 $trial = '<br/> + Get ' . $post_meta['trial_time'] . ' ' . Helper::get_typos( $post_meta['trial_time'], $post_meta['trial_type'] ) . ' free trial!'; 182 if ( isset( $post_meta['signup_fee'] ) ) {240 if ( isset( $post_meta['signup_fee'] ) && '' !== $post_meta['signup_fee'] ) { 183 241 $signup_fee_html = '<br/> + Signup fee of ' . wc_price( $post_meta['signup_fee'] ); 184 242 } … … 196 254 return $price; 197 255 } 198 $post_meta = get_post_meta( $cart_item['product_id'], ' subscrpt_general', true );256 $post_meta = get_post_meta( $cart_item['product_id'], '_subscrpt_meta', true ); 199 257 if ( is_array( $post_meta ) && $post_meta['enable'] ) : 200 258 $time = $post_meta['time'] == 1 ? null : $post_meta['time']; … … 203 261 $trial = null; 204 262 $signup_fee_html = null; 205 $has_trial = Helper:: Check_Trial( $cart_item['product_id'] );263 $has_trial = Helper::check_trial( $cart_item['product_id'] ); 206 264 if ( ! empty( $post_meta['trial_time'] ) && $post_meta['trial_time'] > 0 && $has_trial ) { 207 265 $trial = '<br/><small> + ' . $post_meta['trial_time'] . ' ' . Helper::get_typos( $post_meta['trial_time'], $post_meta['trial_type'] ) . ' free trial!</small>'; … … 221 279 $recurrs = array(); 222 280 foreach ( $cart_items as $cart_item ) { 223 $post_meta = get_post_meta( $cart_item['product_id'], ' subscrpt_general', true );281 $post_meta = get_post_meta( $cart_item['product_id'], '_subscrpt_meta', true ); 224 282 $product = wc_get_product( $cart_item['product_id'] ); 225 283 if ( ! $product->is_type( 'variable' ) && is_array( $post_meta ) && $post_meta['enable'] ) : … … 230 288 $trial = null; 231 289 $start_date = null; 232 $has_trial = Helper:: Check_Trial( $cart_item['product_id'] );290 $has_trial = Helper::check_trial( $cart_item['product_id'] ); 233 291 if ( ! empty( $post_meta['trial_time'] ) && $post_meta['trial_time'] > 0 && $has_trial ) { 234 $trial = $post_meta['trial_time'] . ' ' . Helper::get_typos( $post_meta['trial_time'], $post_meta['trial_type'] ); 292 $trial = $post_meta['trial_time'] . ' ' . Helper::get_typos( $post_meta['trial_time'], $post_meta['trial_type'] ); 293 $start_date = Helper::start_date( 294 $post_meta['time'] . ' ' . $type, 295 $trial 296 ); 235 297 } 236 298 $trial_status = $trial == null ? false : true; … … 239 301 $trial 240 302 ); 241 $next_date = apply_filters( 'subscrpt_next_date_single_cart', $next_date, $cart_item, $trial );242 $recurrs[] = array(243 244 245 246 247 303 $next_date = apply_filters( 'subscrpt_next_date_single_cart', $next_date, $cart_item, $trial ); 304 $recurrs[] = array( 305 'trial' => $trial_status, 306 'price_html' => $price_html, 307 'start_date' => $start_date, 308 'next_date' => $next_date, 309 ); 248 310 endif; 249 311 } 250 312 $recurrs = apply_filters( 'subscrpt_cart_recurring_items', $recurrs ); 251 if ( count( $recurrs ) == 0) {313 if ( 0 === count( $recurrs ) ) { 252 314 return; 253 315 } … … 260 322 <p> 261 323 <span><?php echo wp_kses_post( $recurr['price_html'] ); ?></span><br /> 262 <small><?php echo esc_html_e( 'First billing on', 'sdevs_subscrpt' ); ?>: <?php echo esc_html( date( 'F d, Y', $recurr['start_date']) ); ?></small>324 <small><?php echo esc_html_e( 'First billing on', 'sdevs_subscrpt' ); ?>: <?php echo esc_html( $recurr['start_date'] ?? wp_date( get_option( 'date_format' ) ) ); ?></small> 263 325 </p> 264 <?php else : ?>326 <?php else : ?> 265 327 <p> 266 328 <span><?php echo wp_kses_post( $recurr['price_html'] ); ?></span><br /> -
subscription/trunk/includes/Illuminate/Action.php
r2797349 r2927437 8 8 * @package SpringDevs\Subscription\Illuminate 9 9 */ 10 class Action { 10 class Action 11 { 11 12 12 private static $expired_items; 13 private static $active_items; 14 private static $pending_items; 15 private static $cancelled_items; 13 /** 14 * Did when status changes. 15 * 16 * @param string $status Status. 17 * @param Int $subscription_id Subscription ID. 18 */ 19 public static function status(string $status, int $subscription_id) 20 { 21 // if (current_user_can('edit_post', $subscription_id)) { 22 wp_update_post( 23 array( 24 'ID' => $subscription_id, 25 'post_status' => $status, 26 ) 27 ); 16 28 17 public static function status( $action, $author, $data = array() ) { 18 self::get( $author ); 19 self::edit( $action, $data ); 20 self::user( $author, $action ); 21 self::update( $author ); 29 self::write_comment($status, $subscription_id); 30 self::user($subscription_id); 31 // } 22 32 } 23 33 24 private static function get( $author ) { 25 $expired_items = get_user_meta( $author, '_subscrpt_expired_items', true ); 26 $active_items = get_user_meta( $author, '_subscrpt_active_items', true ); 27 $pending_items = get_user_meta( $author, '_subscrpt_pending_items', true ); 28 $cancelled_items = get_user_meta( $author, '_subscrpt_cancelled_items', true ); 29 30 self::$expired_items = is_array( $expired_items ) ? $expired_items : array(); 31 self::$active_items = is_array( $active_items ) ? $active_items : array(); 32 self::$pending_items = is_array( $pending_items ) ? $pending_items : array(); 33 self::$cancelled_items = is_array( $cancelled_items ) ? $cancelled_items : array(); 34 } 35 36 private static function edit( $action, $data ) { 37 switch ( $action ) { 34 /** 35 * Write Comment based on status. 36 * 37 * @param string $status Status. 38 * @param Int $subscription_id Subscription ID. 39 */ 40 public static function write_comment(string $status, int $subscription_id) 41 { 42 switch ($status) { 38 43 case 'expired': 39 self::expired( $data);44 self::expired($subscription_id); 40 45 break; 41 46 case 'active': 42 self::active( $data ); 43 break; 44 case 'renew': 45 self::renew( $data ); 47 self::active($subscription_id); 46 48 break; 47 49 case 'pending': 48 self::pending( $data);50 self::pending($subscription_id); 49 51 break; 50 52 case 'cancelled': 51 self::cancelled( $data ); 53 self::cancelled($subscription_id); 54 break; 55 case 'pe_cancelled': 56 self::pe_cancelled($subscription_id); 52 57 break; 53 58 } 54 59 } 55 60 56 private static function user( $author, $action ) { 57 $user = new \WP_User( $author ); 58 if ( ! empty( $user->roles ) && is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) { 59 return; 60 } 61 if ( $action == 'active' ) { 62 $user->set_role( get_option( 'subscrpt_active_role', 'subscriber' ) ); 63 } 64 if ( ( $action == 'cancelled' || $action == 'expired' ) && ( count( self::$active_items ) == 0 && count( self::$pending_items ) == 0 ) ) { 65 $user->set_role( get_option( 'subscrpt_unactive_role', 'customer' ) ); 66 } 67 } 68 69 private static function expired( $data ) { 70 if ( ! in_array( $data, self::$expired_items ) ) { 71 array_push( self::$expired_items, $data ); 72 } 73 74 if ( in_array( $data, self::$active_items ) ) { 75 $key = array_search( $data, self::$active_items ); 76 unset( self::$active_items[ $key ] ); 77 } 78 79 if ( in_array( $data, self::$pending_items ) ) { 80 $key = array_search( $data, self::$pending_items ); 81 unset( self::$pending_items[ $key ] ); 82 } 83 84 if ( in_array( $data, self::$cancelled_items ) ) { 85 $key = array_search( $data, self::$cancelled_items ); 86 unset( self::$cancelled_items[ $key ] ); 87 } 88 89 $post_meta = get_post_meta( $data['post'], '_subscrpt_order_general', true ); 90 if ( $post_meta['trial'] != null && time() >= $post_meta['start_date'] ) { 91 $post_meta['trial'] = null; 92 update_post_meta( $data['post'], '_subscrpt_order_general', $post_meta ); 93 } 94 61 /** 62 * Write Comment About expired Subscription. 63 * 64 * @param int $subscription_id Subscription ID. 65 */ 66 private static function expired(int $subscription_id) 67 { 95 68 $comment_id = wp_insert_comment( 96 69 array( 97 'comment_agent' => 'simple-subscriptions', 98 'comment_author' => 'simple-subscriptions', 99 'comment_content' => __( 'Subscription is Expired ', 'sdevs_subscrpt' ), 100 'comment_post_ID' => $data['post'], 70 'comment_author' => 'Subscription for WooCommerce', 71 'comment_content' => 'Subscription is Expired', 72 'comment_post_ID' => $subscription_id, 101 73 'comment_type' => 'order_note', 102 74 ) 103 75 ); 104 update_comment_meta( $comment_id, 'subscrpt_activity', __( 'Subscription Expired', 'sdevs_subscrpt' ) ); 105 do_action( 'subscrpt_when_product_expired', $data['post'], $data['product'], $data, false ); 76 update_comment_meta($comment_id, '_subscrpt_activity', 'Subscription Expired'); 77 78 do_action('subscrpt_subscription_expired', $subscription_id); 106 79 } 107 80 108 private static function active( $data ) { 109 if ( ! in_array( $data, self::$active_items ) ) { 110 array_push( self::$active_items, $data ); 111 } 112 113 if ( in_array( $data, self::$expired_items ) ) { 114 $key = array_search( $data, self::$expired_items ); 115 unset( self::$expired_items[ $key ] ); 116 } 117 118 if ( in_array( $data, self::$pending_items ) ) { 119 $key = array_search( $data, self::$pending_items ); 120 unset( self::$pending_items[ $key ] ); 121 } 122 123 if ( in_array( $data, self::$cancelled_items ) ) { 124 $key = array_search( $data, self::$cancelled_items ); 125 unset( self::$cancelled_items[ $key ] ); 126 } 127 81 /** 82 * Write Comment About Active Subscription. 83 * 84 * @param int $subscription_id Subscription ID. 85 */ 86 private static function active(int $subscription_id) 87 { 128 88 $comment_id = wp_insert_comment( 129 89 array( 130 'comment_agent' => 'simple-subscriptions', 131 'comment_author' => 'simple-subscriptions', 132 'comment_content' => __( 'Subscription activated.Next payment due date set. ', 'sdevs_subscrpt' ), 133 'comment_post_ID' => $data['post'], 90 'comment_author' => 'Subscription for WooCommerce', 91 'comment_content' => 'Subscription activated.Next payment due date set.', 92 'comment_post_ID' => $subscription_id, 134 93 'comment_type' => 'order_note', 135 94 ) 136 95 ); 137 update_comment_meta( $comment_id, 'subscrpt_activity', __( 'Subscription Activated', 'sdevs_subscrpt' ));96 update_comment_meta($comment_id, '_subscrpt_activity', 'Subscription Activated'); 138 97 139 do_action('subscrpt_subscription_activated', $data);98 do_action('subscrpt_subscription_activated', $subscription_id); 140 99 } 141 100 142 private static function renew( $data ) { 143 $post_meta = get_post_meta( $data['post'], '_subscrpt_order_general', true ); 144 if ( $post_meta['trial'] != null ) { 145 $post_meta['trial'] = null; 146 update_post_meta( $data['post'], '_subscrpt_order_general', $post_meta ); 147 } 148 do_action( 'subscrpt_when_product_expired', $data['post'], $data['product'], $data, true ); 149 } 150 151 private static function pending( $data ) { 152 if ( ! in_array( $data, self::$pending_items ) ) { 153 array_push( self::$pending_items, $data ); 154 } 155 156 if ( in_array( $data, self::$expired_items ) ) { 157 $key = array_search( $data, self::$expired_items ); 158 unset( self::$expired_items[ $key ] ); 159 } 160 161 if ( in_array( $data, self::$active_items ) ) { 162 $key = array_search( $data, self::$active_items ); 163 unset( self::$active_items[ $key ] ); 164 } 165 166 if ( in_array( $data, self::$cancelled_items ) ) { 167 $key = array_search( $data, self::$cancelled_items ); 168 unset( self::$cancelled_items[ $key ] ); 169 } 170 101 /** 102 * Write Comment About Subscription Pending. 103 * 104 * @param int $subscription_id Subscription ID. 105 */ 106 private static function pending(int $subscription_id) 107 { 171 108 $comment_id = wp_insert_comment( 172 109 array( 173 'comment_agent' => 'simple-subscriptions', 174 'comment_author' => 'simple-subscriptions', 175 'comment_content' => __( 'Subscription is pending.', 'sdevs_subscrpt' ), 176 'comment_post_ID' => $data['post'], 110 'comment_author' => 'Subscription for WooCommerce', 111 'comment_content' => 'Subscription is pending.', 112 'comment_post_ID' => $subscription_id, 177 113 'comment_type' => 'order_note', 178 114 ) 179 115 ); 180 update_comment_meta( $comment_id, 'subscrpt_activity', __( 'Subscription Pending', 'sdevs_subscrpt' ));116 update_comment_meta($comment_id, '_subscrpt_activity', 'Subscription Pending'); 181 117 } 182 118 183 private static function cancelled( $data ) { 184 if ( ! in_array( $data, self::$cancelled_items ) ) { 185 array_push( self::$cancelled_items, $data ); 186 } 187 188 if ( in_array( $data, self::$expired_items ) ) { 189 $key = array_search( $data, self::$expired_items ); 190 unset( self::$expired_items[ $key ] ); 191 } 192 193 if ( in_array( $data, self::$active_items ) ) { 194 $key = array_search( $data, self::$active_items ); 195 unset( self::$active_items[ $key ] ); 196 } 197 198 if ( in_array( $data, self::$pending_items ) ) { 199 $key = array_search( $data, self::$pending_items ); 200 unset( self::$pending_items[ $key ] ); 201 } 202 119 /** 120 * Write Comment About Subscription Cancelled. 121 * 122 * @param int $subscription_id Subscription ID. 123 */ 124 private static function cancelled(int $subscription_id) 125 { 203 126 $comment_id = wp_insert_comment( 204 127 array( 205 'comment_agent' => 'simple-subscriptions', 206 'comment_author' => 'simple-subscriptions', 207 'comment_content' => __( 'Subscription is Cancelled.', 'sdevs_subscrpt' ), 208 'comment_post_ID' => $data['post'], 128 'comment_author' => 'Subscription for WooCommerce', 129 'comment_content' => 'Subscription is Cancelled.', 130 'comment_post_ID' => $subscription_id, 209 131 'comment_type' => 'order_note', 210 132 ) 211 133 ); 212 update_comment_meta( $comment_id, 'subscrpt_activity', __( 'Subscription Cancelled', 'sdevs_subscrpt' ));134 update_comment_meta($comment_id, '_subscrpt_activity', 'Subscription Cancelled'); 213 135 } 214 136 215 private static function update( $author ) { 216 update_user_meta( $author, '_subscrpt_expired_items', self::$expired_items ); 217 update_user_meta( $author, '_subscrpt_active_items', self::$active_items ); 218 update_user_meta( $author, '_subscrpt_pending_items', self::$pending_items ); 219 update_user_meta( $author, '_subscrpt_cancelled_items', self::$cancelled_items ); 137 /** 138 * Write Comment About Pending Cancellation. 139 * 140 * @param int $subscription_id Subscription ID. 141 */ 142 private static function pe_cancelled(int $subscription_id) 143 { 144 $comment_id = wp_insert_comment( 145 array( 146 'comment_author' => 'Subscription for WooCommerce', 147 'comment_content' => 'Subscription is Pending Cancellation.', 148 'comment_post_ID' => $subscription_id, 149 'comment_type' => 'order_note', 150 ) 151 ); 152 update_comment_meta($comment_id, '_subscrpt_activity', 'Subscription Pending Cancellation'); 153 } 154 155 /** 156 * Update user role. 157 * 158 * @param Int $subscription_id Subscription ID. 159 */ 160 private static function user($subscription_id) 161 { 162 $user = new \WP_User(get_current_user_id()); 163 if (!empty($user->roles) && is_array($user->roles) && in_array('administrator', $user->roles, true)) { 164 return; 165 } 166 167 if (Helper::subscription_exists($subscription_id, 'active')) { 168 $user->set_role(get_option('subscrpt_active_role', 'subscriber')); 169 } elseif (Helper::subscription_exists($subscription_id, array('cancelled', 'expired'))) { 170 $user->set_role(get_option('subscrpt_unactive_role', 'customer')); 171 } 220 172 } 221 173 } -
subscription/trunk/includes/Illuminate/Cron.php
r2708268 r2927437 8 8 * @package SpringDevs\Subscription\Illuminate 9 9 */ 10 class Cron { 10 class Cron 11 { 11 12 12 public function __construct() { 13 add_action( 'subscrpt_daily_cron', array( $this, 'daily_cron_task' ) ); 13 /** 14 * Initialize the class. 15 */ 16 public function __construct() 17 { 18 add_action('subscrpt_daily_cron', array($this, 'daily_cron_task')); 14 19 } 15 20 16 public function daily_cron_task() { 17 $active_items = get_user_meta( get_current_user_id(), '_subscrpt_active_items', true ); 18 if ( ! is_array( $active_items ) ) { 19 $active_items = array(); 20 } 21 foreach ( $active_items as $active_item ) { 22 $post_meta = get_post_meta( $active_item['post'], '_subscrpt_order_general', true ); 23 if ( time() >= $post_meta['next_date'] || ( $post_meta['trial'] != null && time() >= $post_meta['start_date'] ) ) { 24 wp_update_post( 25 array( 26 'ID' => $post_meta['post'], 27 'post_type' => 'subscrpt_order', 28 'post_status' => 'expired', 29 ) 30 ); 31 Action::status( 'expired', get_current_user_id(), $active_item ); 32 do_action( 'subscrpt_cron_expired', $active_item ); 21 /** 22 * Run daily cron task to check if subscription expired. 23 */ 24 public function daily_cron_task() 25 { 26 $args = array( 27 'post_type' => 'subscrpt_order', 28 'post_status' => array('active', 'pe_cancelled'), 29 'fields' => 'ids', 30 'author' => get_current_user_id(), 31 ); 32 33 $active_subscriptions = get_posts($args); 34 35 if ($active_subscriptions && count($active_subscriptions) > 0) { 36 foreach ($active_subscriptions as $subscription) { 37 $post_meta = get_post_meta($subscription, '_order_subscrpt_meta', true); 38 39 if (time() >= $post_meta['next_date'] || (null !== $post_meta['trial'] && time() >= $post_meta['start_date'])) { 40 if ('pe_cancelled' === get_post_status($subscription)) { 41 Action::status('cancelled', $subscription); 42 } else { 43 Action::status('expired', $subscription); 44 } 45 } 33 46 } 34 47 } -
subscription/trunk/includes/Illuminate/Email.php
r2708268 r2927437 15 15 16 16 public function add_subscription_table( $order ) { 17 $post_meta = get_post_meta( 18 $order->get_id(), 19 '_order_subscrpt_full_data', 20 true 21 ); 22 if ( ! empty( $post_meta ) && is_array( $post_meta ) && count( $post_meta ) > 0 ) : 17 $histories = Helper::get_subscriptions_from_order( $order->get_id() ); 18 19 if ( count( $histories ) > 0 ) : 23 20 ?> 24 21 <div style="margin-bottom: 40px;"> … … 29 26 </tr> 30 27 <?php 31 foreach ( $post_meta as $subscrpt_meta ) : 32 if ( ! empty( $subscrpt_meta ) && is_array( $subscrpt_meta ) ) : 33 $post = $subscrpt_meta['post_id']; 34 $trial_status = $subscrpt_meta['trial'] == null ? false : true; 35 $product_name = apply_filters( 'subscrpt_filter_product_name', get_the_title( $subscrpt_meta['product_id'] ), $subscrpt_meta ); 36 $product_link = apply_filters( 'subscrpt_filter_product_permalink', get_the_permalink( $subscrpt_meta['product_id'] ), $subscrpt_meta ); 37 ?> 28 foreach ( $histories as $history ) : 29 $item = $order->get_item( $history->order_item_id ); 30 $item_meta = wc_get_order_item_meta( $history->order_item_id, '_subscrpt_meta', true ); 31 $subscription_id = $history->subscription_id; 32 $has_trial = isset( $item_meta['trial'] ) && strlen( $item_meta['trial'] ) > 2; 33 ?> 38 34 <tr> 39 <th class="td" scope="row" colspan="3" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: center;"><?php echo get_the_title( $ post); ?></th>35 <th class="td" scope="row" colspan="3" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: center;"><?php echo get_the_title( $subscription_id ); ?></th> 40 36 </tr> 41 37 <tr> 42 <th class="td" scope="row" colspan="3" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><a href="<?php echo $product_link; ?>"><?php echo $product_name; ?></a>43 <strong class="product-quantity">× <?php echo esc_html( $ subscrpt_meta['qty']); ?></strong>38 <th class="td" scope="row" colspan="3" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><a href="<?php echo get_permalink( $item->get_product_id() ); ?>"><?php echo $item->get_name(); ?></a> 39 <strong class="product-quantity">× <?php echo esc_html( $item->get_quantity() ); ?></strong> 44 40 </th> 45 41 </tr> 46 42 <tr> 47 43 <th class="td" scope="row" colspan="2" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php _e( 'Status:', 'sdevs_subscrpt' ); ?> </th> 48 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo get_post_status( $ post); ?></td>44 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo get_post_status( $subscription_id ); ?></td> 49 45 </tr> 50 46 <tr> 51 47 <th class="td" scope="row" colspan="2" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"> 52 48 <?php _e( 'Recurring amount:', 'sdevs_subscrpt' ); ?> </th> 53 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo wp_kses_post( $subscrpt_meta['subtotal_price_html']); ?></td>49 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo Helper::format_price_with_order_item( $item->get_total(), $item->get_id() ); ?></td> 54 50 </tr> 55 <?php if ( $trial_status == null ) { ?>51 <?php if ( ! $has_trial ) { ?> 56 52 <tr> 57 53 <th class="td" scope="row" colspan="2" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php _e( 'Next billing on', 'sdevs_subscrpt' ); ?>: </th> 58 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo date( 'F d, Y', $ subscrpt_meta['next_date'] ); ?></td>54 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo date( 'F d, Y', $item_meta['next_date'] ); ?></td> 59 55 </tr> 60 56 <?php } else { ?> 61 57 <tr> 62 58 <th class="td" scope="row" colspan="2" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php _e( 'Trial', 'sdevs_subscrpt' ); ?>: </th> 63 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo esc_html( $ subscrpt_meta['trial'] ); ?></td>59 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo esc_html( $item_meta['trial'] ); ?></td> 64 60 </tr> 65 61 <tr> 66 62 <th class="td" scope="row" colspan="2" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php _e( 'First billing on', 'sdevs_subscrpt' ); ?>: </th> 67 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo date( 'F d, Y', $ subscrpt_meta['start_date'] ); ?></td>63 <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;"><?php echo date( 'F d, Y', $item_meta['start_date'] ); ?></td> 68 64 </tr> 69 65 <?php } ?> … … 72 68 </tr> 73 69 <?php 74 endif;75 70 endforeach; 76 71 ?> -
subscription/trunk/includes/Illuminate/Helper.php
r2708268 r2927437 24 24 } 25 25 26 public static function next_date( $time, $trial = null ) { 27 if ( $trial == null ) { 26 /** 27 * Generate start date 28 * 29 * @param mixed $time Time. 30 * @param Null|String $trial Trial. 31 * 32 * @return String 33 */ 34 public static function start_date( $time, $trial = null ) { 35 if ( null === $trial ) { 28 36 $start_date = time(); 29 37 } else { 30 38 $start_date = strtotime( $trial ); 31 39 } 32 return date( 'F d, Y', strtotime( $time, $start_date ) ); 33 } 34 35 public static function CheckExpired( $product_id ) { 36 $user_meta = get_user_meta( get_current_user_id(), '_subscrpt_expired_items', true ); 37 $expired_items = array(); 38 if ( is_array( $user_meta ) ) { 39 foreach ( $user_meta as $usermeta ) { 40 array_push( $expired_items, $usermeta['product'] ); 40 return wp_date( get_option( 'date_format' ), $start_date ); 41 } 42 43 /** 44 * Generate next date 45 * 46 * @param mixed $time Time. 47 * @param Null|String $trial Trial. 48 * 49 * @return String 50 */ 51 public static function next_date( $time, $trial = null ) { 52 if ( null === $trial ) { 53 $start_date = time(); 54 } else { 55 $start_date = strtotime( $trial ); 56 } 57 return wp_date( get_option( 'date_format' ), strtotime( $time, $start_date ) ); 58 } 59 60 /** 61 * Check subscription exists by product ID. 62 * 63 * @param Int $product_id Product ID. 64 * @param String | array $status Status. 65 * 66 * @return \WP_Post | false 67 */ 68 public static function subscription_exists( int $product_id, $status ) { 69 $args = array( 70 'post_type' => 'subscrpt_order', 71 'post_status' => $status, 72 'fields' => 'ids', 73 'meta_query' => array( 74 array( 75 'key' => '_subscrpt_product_id', 76 'value' => $product_id, 77 ), 78 ), 79 'author' => get_current_user_id(), 80 ); 81 82 $posts = get_posts( $args ); 83 84 if ( count( $posts ) > 0 ) { 85 return $posts[0]; 86 } 87 88 return false; 89 } 90 91 /** 92 * Check if product trial exixts for an user. 93 * 94 * @param Int $product_id Product ID. 95 * 96 * @return Boolean 97 */ 98 public static function check_trial( int $product_id ): bool { 99 return ! self::subscription_exists( $product_id, array( 'expired', 'pending', 'active', 'on-hold', 'pe_cancelled', 'cancelled' ) ); 100 } 101 102 /** 103 * Rewew when expired. 104 * 105 * @param Int $subscription_id Subscription ID. 106 */ 107 public static function renew( int $subscription_id ) { 108 $post_meta = get_post_meta( $subscription_id, '_order_subscrpt_meta', true ); 109 if ( null !== $post_meta['trial'] ) { 110 $post_meta['trial'] = null; 111 update_post_meta( $subscription_id, '_order_subscrpt_meta', $post_meta ); 112 } 113 114 do_action( 'subscrpt_when_product_expired', $subscription_id, true ); 115 } 116 117 /** 118 * Get Subscriptions Histories 119 * 120 * @param Int $order_id Order ID. 121 */ 122 public static function get_subscriptions_from_order( $order_id ) { 123 global $wpdb; 124 $table_name = $wpdb->prefix . 'subscrpt_order_relation'; 125 $histories = $wpdb->get_results( 126 $wpdb->prepare( 127 // @phpcs:ignore 128 'SELECT * FROM %i WHERE order_id=%d', 129 array( $table_name, $order_id ) 130 ) 131 ); 132 133 return $histories; 134 } 135 136 /** 137 * Format price with Subscription 138 * 139 * @param mixed $price Price. 140 * @param Int $subscription_id Subscription ID. 141 * @param bool $display_trial True/False. 142 * 143 * @return mixed 144 */ 145 public static function format_price_with_subscription( $price, $subscription_id, $display_trial = false ) { 146 $subscription_meta = get_post_meta( $subscription_id, '_order_subscrpt_meta', true ); 147 $item_meta = wc_get_order_item_meta( $subscription_meta['order_item_id'], '_subscrpt_meta', true ); 148 149 $order = wc_get_order( $subscription_meta['order_id'] ); 150 $time = '1' === $item_meta['time'] ? null : $item_meta['time'] . ' '; 151 $type = self::get_typos( $item_meta['time'], $item_meta['type'] ); 152 153 $formatted_price = wc_price( 154 $price, 155 array( 156 'currency' => $order->get_currency(), 157 ) 158 ) . ' / ' . $time . $type; 159 160 if ( $display_trial ) { 161 $trial = $item_meta['trial']; 162 $has_trial = isset( $item_meta['trial'] ) && strlen( $item_meta['trial'] ) > 2; 163 164 if ( $has_trial ) { 165 $trial_html = '<br/><small> + Got ' . $trial . ' free trial!</small>'; 166 $formatted_price .= $trial_html; 41 167 } 42 168 } 43 return in_array( $product_id, $expired_items ); 44 } 45 46 public static function Check_un_expired( $product_id ) { 47 $author = get_current_user_id(); 48 $active_items = get_user_meta( $author, '_subscrpt_active_items', true ); 49 $pending_items = get_user_meta( $author, '_subscrpt_pending_items', true ); 50 51 if ( ! is_array( $active_items ) ) { 52 $active_items = array(); 53 } 54 if ( ! is_array( $pending_items ) ) { 55 $pending_items = array(); 56 } 57 58 foreach ( $active_items as $active_item ) { 59 if ( $active_item['product'] == $product_id ) { 60 return true; 169 170 return apply_filters( 'subscrpt_format_price_with_subscription', $formatted_price, $price, $subscription_id ); 171 } 172 173 public static function format_price_with_order_item( $price, $item_id, $display_trial = false ) { 174 $order_id = wc_get_order_id_by_order_item_id( $item_id ); 175 $order = wc_get_order( $order_id ); 176 177 $item_meta = wc_get_order_item_meta( $item_id, '_subscrpt_meta', true ); 178 179 if ( ! $item_meta || ! is_array( $item_meta ) ) { 180 return false; 181 } 182 183 $time = $item_meta['time'] == 1 ? null : $item_meta['time'] . ' '; 184 $type = self::get_typos( $item_meta['time'], $item_meta['type'] ); 185 186 $formatted_price = wc_price( 187 $price, 188 array( 189 'currency' => $order->get_currency(), 190 ) 191 ) . ' / ' . $time . $type; 192 193 if ( $display_trial ) { 194 $trial = $item_meta['trial']; 195 $has_trial = isset( $item_meta['trial'] ) && strlen( $item_meta['trial'] ) > 2; 196 197 if ( $has_trial ) { 198 $trial_html = '<br/><small> + Got ' . $trial . ' free trial!</small>'; 199 $formatted_price .= $trial_html; 61 200 } 62 201 } 63 202 64 foreach ( $pending_items as $pending_item ) { 65 if ( $pending_item['product'] == $product_id ) { 66 return true; 67 } 68 } 69 70 return false; 71 } 72 73 public static function Check_Trial( $product_id ) { 74 $result = true; 75 $author = get_current_user_id(); 76 $product = wc_get_product( $product_id ); 77 if ( ! $product ) { 78 return false; 79 } 80 $cancelled_items = get_user_meta( $author, '_subscrpt_cancelled_items', true ); 81 $expired_items = get_user_meta( $author, '_subscrpt_expired_items', true ); 82 $active_items = get_user_meta( $author, '_subscrpt_active_items', true ); 83 $pending_items = get_user_meta( $author, '_subscrpt_pending_items', true ); 84 85 if ( ! is_array( $cancelled_items ) ) { 86 $cancelled_items = array(); 87 } 88 if ( ! is_array( $expired_items ) ) { 89 $expired_items = array(); 90 } 91 if ( ! is_array( $active_items ) ) { 92 $active_items = array(); 93 } 94 if ( ! is_array( $pending_items ) ) { 95 $pending_items = array(); 96 } 97 98 foreach ( $cancelled_items as $cancelled_item ) { 99 if ( $cancelled_item['product'] == $product_id ) { 100 $result = false; 101 } 102 } 103 104 foreach ( $expired_items as $expired_item ) { 105 if ( $expired_item['product'] == $product_id ) { 106 $result = false; 107 } 108 } 109 110 foreach ( $active_items as $active_item ) { 111 if ( $active_item['product'] == $product_id ) { 112 $result = false; 113 } 114 } 115 116 foreach ( $pending_items as $pending_item ) { 117 if ( $pending_item['product'] == $product_id ) { 118 $result = false; 119 } 120 } 121 122 if ( ! $product->is_type( 'variable' ) ) { 123 return $result; 124 } 125 return apply_filters( 'subscrpt_filter_product_trial', $result, $product_id, $active_items, $pending_items, $cancelled_items, $expired_items ); 203 return apply_filters( 'subscrpt_format_price_with_subscription', $formatted_price, $price, $item_id ); 204 } 205 206 /** 207 * Get total subscriptions by product ID. 208 * 209 * @param Int $product_id Product ID. 210 * @param String | array $status Status. 211 * 212 * @return \WP_Post | false 213 */ 214 public static function get_total_subscriptions_from_product( int $product_id, $status = array( 'active', 'pending', 'expired', 'pe_cancelled', 'cancelled' ) ) { 215 $args = array( 216 'post_type' => 'subscrpt_order', 217 'post_status' => $status, 218 'fields' => 'ids', 219 'meta_query' => array( 220 array( 221 'key' => '_subscrpt_product_id', 222 'value' => $product_id, 223 ), 224 ), 225 ); 226 227 $posts = get_posts( $args ); 228 229 return count( $posts ); 126 230 } 127 231 } -
subscription/trunk/includes/Illuminate/Order.php
r2708268 r2927437 10 10 class Order { 11 11 12 /** 13 * Initialize the class. 14 */ 12 15 public function __construct() { 13 16 add_filter( 'woocommerce_order_formatted_line_subtotal', array( $this, 'format_order_price' ), 10, 3 ); … … 15 18 add_action( 'woocommerce_admin_order_item_values', array( $this, 'admin_order_item_value' ), 10, 2 ); 16 19 add_action( 'woocommerce_before_order_itemmeta', array( $this, 'add_order_item_data' ), 10, 3 ); 17 // add_filter('woocommerce_order_amount_item_subtotal', function ($subtotal, $order, $item) {18 // $product = wc_get_product($item['product_id']);19 // if (!$product->is_type('simple')) return $subtotal;20 // $post_meta = get_post_meta($item['product_id'], 'subscrpt_general', true);21 // if (is_array($post_meta) && $post_meta['enable']) :22 // $time = $post_meta['time'] == 1 ? null : $post_meta['time'];23 // $type = Helper::get_typos($post_meta['time'], $post_meta["type"]);24 // $trial = null;25 // $has_trial = Helper::Check_Trial($item['product_id']);26 // if (!empty($post_meta['trial_time']) && $post_meta['trial_time'] > 0 && $has_trial) {27 // $trial = "<br/><small> + Get " . $post_meta['trial_time'] . " " . Helper::get_typos($post_meta['trial_time'], $post_meta['trial_type']) . " free trial!</small>";28 // }29 // $price_html = $subtotal . " / " . $time . " " . $type . $trial;30 // return $price_html;31 // else :32 // return $subtotal;33 // endif;34 // }, 10, 3);35 20 add_action( 'woocommerce_order_status_changed', array( $this, 'order_status_changed' ) ); 36 // add_action('subscrpt_gateway_stripe_process_response', function ($response, $order) {37 // $order_meta = get_post_meta($order->get_id(), '_order_subscrpt_data', true);38 // if (empty($order_meta) || !is_array($order_meta) || !$order_meta['status']) return;39 // $post_id = $order_meta['posts'][0];40 // $post_meta = get_post_meta($post_id, '_subscrpt_order_general', true);41 // $product_meta = get_post_meta($post_meta['product_id'], 'subscrpt_general', true);42 // $type = Helper::get_typos($product_meta['time'], $product_meta["type"]);43 // if ('succeeded' === $response->status) {44 // $post_meta['start_date'] = time();45 // $post_meta['next_date'] = strtotime($product_meta['time'] . " " . $type);46 // update_post_meta($post_id, '_subscrpt_order_general', $post_meta);47 // $data = ["post" => $post_id, "product" => $post_meta['product_id']];48 // if (isset($post_meta['variation_id'])) $data['variation'] = $post_meta['variation_id'];49 // $order_history = get_post_meta($post_id, '_subscrpt_order_history', true);50 // if (!is_array($order_history)) $order_history = [];51 // array_push($order_history, $post_meta);52 // update_post_meta($post_id, '_subscrpt_order_history', $order_history);53 // }54 // }, 10, 2);55 21 } 56 22 57 23 public function format_order_price( $subtotal, $item, $order ) { 58 $product = wc_get_product( $item['product_id'] ); 59 if ( $product->is_type( 'variable' ) ) { 24 $price_html = Helper::format_price_with_order_item( 25 $item->get_subtotal(), 26 $item->get_id(), 27 true 28 ); 29 30 if ( ! $price_html ) { 60 31 return $subtotal; 61 32 } 62 $order_data = get_post_meta( $order->get_id(), '_order_subscrpt_full_data', true ); 63 if ( ! is_array( $order_data ) ) { 64 $order_data = array(); 65 } 66 foreach ( $order_data as $post_meta ) { 67 if ( is_array( $post_meta ) && isset( $post_meta['stats'] ) && $item['product_id'] == $post_meta['product_id'] ) : 68 $trial = null; 69 $has_trial = isset( $post_meta['trial'] ) && strlen( $post_meta['trial'] ) > 2; 70 $signup_fee_html = null; 71 if ( $has_trial ) { 72 $trial = '<br/><small> + Get ' . $post_meta['trial'] . ' ' . ' free trial!</small>'; 73 if ( isset( $post_meta['signup_fee'] ) && $post_meta['signup_fee'] > 0 ) { 74 $signup_fee_html = '<br/> + Signup fee of ' . wc_price( $post_meta['signup_fee'] ); 75 } 76 } 77 $price_html = $post_meta['subtotal_price_html'] . $signup_fee_html . $trial; 78 return $price_html; 79 endif; 80 } 81 return $subtotal; 33 34 return $price_html; 82 35 } 83 36 … … 89 42 90 43 public function admin_order_item_value( $product, $item ) { 91 $subtotal = '-'; 92 $order_data = get_post_meta( $item->get_order_id(), '_order_subscrpt_full_data', true ); 93 if ( ! is_array( $order_data ) ) { 94 $order_data = array(); 44 if ( ! method_exists( $item, 'get_id' ) || ! method_exists( $item, 'get_subtotal' ) ) { 45 return; 95 46 } 96 foreach ( $order_data as $post_meta ) { 97 if ( is_array( $post_meta ) && isset( $post_meta['stats'] ) && ! is_null( $product ) && $product->get_id() == $post_meta['product_id'] ) : 98 $subtotal = $post_meta['subtotal_price_html']; 99 endif; 100 } 47 48 $subtotal = '-'; 49 $item_id = $item->get_id(); 50 $subtotal = Helper::format_price_with_order_item( $item->get_subtotal(), $item_id ); 101 51 ?> 102 52 <td class="item_recurring" width="15%"> … … 112 62 return; 113 63 } 114 $order_data = get_post_meta( $item->get_order_id(), '_order_subscrpt_full_data', true ); 115 if ( ! is_array( $order_data ) ) { 116 $order_data = array(); 64 65 $item_meta = wc_get_order_item_meta( $item_id, '_subscrpt_meta', true ); 66 67 if ( ! $item_meta || ! is_array( $item_meta ) ) { 68 return false; 117 69 } 118 foreach ( $order_data as $post_meta ) { 119 if ( is_array( $post_meta ) && isset( $post_meta['stats'] ) && $product->get_id() == $post_meta['product_id'] ) : 120 $has_trial = isset( $post_meta['trial'] ) && strlen( $post_meta['trial'] ) > 2 ? true : false; 121 if ( $has_trial ) { 122 if ( isset( $post_meta['signup_fee'] ) && $post_meta['signup_fee'] > 0 ) { 123 echo '<small> + Signup fee of ' . wc_price( $post_meta['signup_fee'] ) . '</small><br/>'; 124 } 125 echo '<small> + Get ' . wp_kses_post( $post_meta['trial'] ) . ' ' . ' free trial!</small>'; 126 } 127 endif; 70 71 $trial = $item_meta['trial']; 72 $has_trial = isset( $item_meta['trial'] ) && strlen( $item_meta['trial'] ) > 2; 73 74 if ( $has_trial ) { 75 echo '<br/><small> + Got ' . $trial . ' free trial!</small>'; 128 76 } 129 77 } 130 78 79 /** 80 * Take some actions based on order status changed. 81 * 82 * @param int $order_id Order Id. 83 */ 131 84 public function order_status_changed( $order_id ) { 132 85 $order = new \WC_Order( $order_id ); … … 135 88 switch ( $order->get_status() ) { 136 89 case 'on-hold': 137 case 'pending' ;90 case 'pending': 138 91 $post_status = 'pending'; 139 92 break; … … 141 94 case 'refunded': 142 95 case 'failed': 143 case 'cancelled' ;96 case 'cancelled': 144 97 $post_status = 'cancelled'; 145 98 break; 146 99 147 default ;100 default: 148 101 $post_status = 'active'; 149 102 break; 150 103 } 151 $order_meta = get_post_meta( $order_id, '_order_subscrpt_data', true ); 152 if ( empty( $order_meta ) || ! is_array( $order_meta ) ) { 153 return; 154 } 155 if ( ! $order_meta['status'] ) { 156 return; 157 } 158 foreach ( $order_meta['posts'] as $post ) { 159 if ( get_the_title( $post ) != '' ) { 104 105 global $wpdb; 106 $table_name = $wpdb->prefix . 'subscrpt_order_relation'; 107 // @phpcs:ignore 108 $histories = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i WHERE order_id=%d', array( $table_name, $order_id ) ) ); 109 110 foreach ( $histories as $history ) { 111 if ( 'new' === $history->type || 'renew' === $history->type ) { 160 112 wp_update_post( 161 113 array( 162 'ID' => $ post,114 'ID' => $history->subscription_id, 163 115 'post_status' => $post_status, 164 116 ) 165 117 ); 166 $post_meta = get_post_meta( $post, '_subscrpt_order_general', true ); 167 $await_data = get_post_meta( $post, '_subscrpt_waiting_data', true ); 168 if ( $order->get_status() == 'completed' ) { 169 if ( $await_data && is_array( $await_data ) ) { 170 $post_meta['next_date'] = $await_data['next_date']; 171 update_post_meta( $post, '_subscrpt_order_general', $post_meta ); 172 } 173 } 174 $acdata = array( 175 'post' => $post, 176 'product' => $post_meta['product_id'], 177 ); 178 if ( isset( $post_meta['variation_id'] ) ) { 179 $acdata['variation'] = $post_meta['variation_id']; 180 } 181 Action::status( $post_status, $order->get_user_id(), $acdata ); 118 119 Action::write_comment( $post_status, $history->subscription_id ); 120 } else { 121 do_action( 'subscrpt_order_status_changed', $order, $history ); 182 122 } 183 123 } -
subscription/trunk/includes/Installer.php
r2709135 r2927437 35 35 wp_schedule_event( time(), 'daily', 'subscrpt_daily_cron' ); 36 36 } 37 38 update_option( 'subscrpt_manual_renew_cart_notice', 'Subscriptional product added to cart. Please complete the checkout to renew subscription.' ); 37 39 } 38 40 … … 46 48 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 47 49 } 50 51 $this->create_histories_table(); 52 } 53 54 /** 55 * Create histories table 56 * 57 * @return void 58 */ 59 public function create_histories_table() { 60 global $wpdb; 61 62 $charset_collate = $wpdb->get_charset_collate(); 63 $table_name = $wpdb->prefix . 'subscrpt_order_relation'; 64 65 $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` ( 66 `id` INT(255) NOT NULL AUTO_INCREMENT, 67 `subscription_id` INT(100) NOT NULL, 68 `order_id` INT(100) NOT NULL, 69 `order_item_id` INT(100) NOT NULL, 70 `type` VARCHAR(50) NOT NULL, 71 PRIMARY KEY (`id`) 72 ) $charset_collate"; 73 74 dbDelta( $schema ); 48 75 } 49 76 } -
subscription/trunk/includes/functions.php
r2797349 r2927437 1 1 <?php 2 2 3 function subscrpt_get_typos( $number, $typo ) { 4 if ( $number == 1 && $typo == 'days' ) { 5 return __( 'day', 'sdevs_subscrpt' ); 6 } elseif ( $number == 1 && $typo == 'weeks' ) { 7 return __( 'week', 'sdevs_subscrpt' ); 8 } elseif ( $number == 1 && $typo == 'months' ) { 9 return __( 'month', 'sdevs_subscrpt' ); 10 } elseif ( $number == 1 && $typo == 'years' ) { 11 return __( 'year', 'sdevs_subscrpt' ); 12 } else { 13 return $typo; 14 } 3 /** 4 * Generate Url for Subscription Action. 5 * 6 * @param String $action Action. 7 * @param String $nonce nonce. 8 * @param Int $subscription_id Subscription ID. 9 * 10 * @return String 11 */ 12 function subscrpt_get_action_url($action, $nonce, $subscription_id) 13 { 14 return add_query_arg( 15 array( 16 'subscrpt_id' => $subscription_id, 17 'action' => $action, 18 'wpnonce' => $nonce, 19 ), 20 wc_get_endpoint_url('view-subscription', $subscription_id, wc_get_page_permalink('myaccount')) 21 ); 15 22 } 16 23 17 function subscrpt_check_trial( $product_id ) {18 $result = true;19 $author = get_current_user_id();20 $product = wc_get_product( $product_id );21 $cancelled_items = get_user_meta( $author, '_subscrpt_cancelled_items', true );22 $expired_items = get_user_meta( $author, '_subscrpt_expired_items', true );23 $active_items = get_user_meta( $author, '_subscrpt_active_items', true );24 $pending_items = get_user_meta( $author, '_subscrpt_pending_items', true );25 24 26 if ( ! is_array( $cancelled_items ) ) { 27 $cancelled_items = array(); 28 } 29 if ( ! is_array( $expired_items ) ) { 30 $expired_items = array(); 31 } 32 if ( ! is_array( $active_items ) ) { 33 $active_items = array(); 34 } 35 if ( ! is_array( $pending_items ) ) { 36 $pending_items = array(); 37 } 38 39 foreach ( $cancelled_items as $cancelled_item ) { 40 if ( $cancelled_item['product'] == $product_id ) { 41 $result = false; 42 } 43 } 44 45 foreach ( $expired_items as $expired_item ) { 46 if ( $expired_item['product'] == $product_id ) { 47 $result = false; 48 } 49 } 50 51 foreach ( $active_items as $active_item ) { 52 if ( $active_item['product'] == $product_id ) { 53 $result = false; 54 } 55 } 56 57 foreach ( $pending_items as $pending_item ) { 58 if ( $pending_item['product'] == $product_id ) { 59 $result = false; 60 } 61 } 62 63 if ( $product->is_type( 'simple' ) ) { 64 return $result; 65 } 66 67 return apply_filters( 'subscrpt_filter_product_trial', $result, $product_id, $active_items, $pending_items, $cancelled_items, $expired_items ); 25 function subscrpt_get_typos($number, $typo) 26 { 27 if ($number == 1 && $typo == 'days') { 28 return __('day', 'sdevs_subscrpt'); 29 } elseif ($number == 1 && $typo == 'weeks') { 30 return __('week', 'sdevs_subscrpt'); 31 } elseif ($number == 1 && $typo == 'months') { 32 return __('month', 'sdevs_subscrpt'); 33 } elseif ($number == 1 && $typo == 'years') { 34 return __('year', 'sdevs_subscrpt'); 35 } else { 36 return $typo; 37 } 68 38 } 69 39 70 function subscrpt_next_date( $time, $trial = null ) { 71 if ( $trial == null ) { 72 $start_date = time(); 73 } else { 74 $start_date = strtotime( $trial ); 75 } 40 /** 41 * Format time with trial. 42 * 43 * @param mixed $time Time. 44 * @param null|string $trial Trial. 45 * 46 * @return string 47 */ 48 function subscrpt_next_date($time, $trial = null) 49 { 50 if (null === $trial) { 51 $start_date = time(); 52 } else { 53 $start_date = strtotime($trial); 54 } 76 55 77 return date( 'F d, Y', strtotime( $time, $start_date ));56 return gmdate('F d, Y', strtotime($time, $start_date)); 78 57 } 79 58 80 function subscrpt_check_unexpired( $product_id ) { 81 $author = get_current_user_id(); 82 $product = wc_get_product( $product_id ); 83 $active_items = get_user_meta( $author, '_subscrpt_active_items', true ); 84 $pending_items = get_user_meta( $author, '_subscrpt_pending_items', true ); 85 86 if ( ! is_array( $active_items ) ) { 87 $active_items = array(); 88 } 89 if ( ! is_array( $pending_items ) ) { 90 $pending_items = array(); 91 } 92 93 foreach ( $active_items as $active_item ) { 94 if ( $active_item['product'] == $product_id ) { 95 return true; 96 } 97 } 98 99 foreach ( $pending_items as $pending_item ) { 100 if ( $pending_item['product'] == $product_id ) { 101 return true; 102 } 103 } 104 105 if ( $product->is_type( 'simple' ) ) { 106 return false; 107 } 108 109 return apply_filters( 'subscrpt_filter_check_unexpired', false, $product_id, $active_items, $pending_items ); 59 /** 60 * Check if subscription-pro activated. 61 * 62 * @return bool 63 */ 64 function subscrpt_pro_activated(): bool 65 { 66 return class_exists('Sdevs_Wc_Subscription_Pro'); 110 67 } 111 68 112 function subscrpt_pro_activated(): bool { 113 return class_exists( 'Sdevs_Wc_Subscription_Pro' ); 69 /** 70 * Get renewal process settings. 71 * 72 * @return string 73 */ 74 function subscrpt_get_renewal_process() 75 { 76 if (!subscrpt_pro_activated()) { 77 return 'manual'; 78 } else { 79 return get_option('subscrpt_renewal_process', 'auto'); 80 } 114 81 } 82 83 /** 84 * Return Label against key. 85 * 86 * @param string $key Key to return cast Value. 87 * 88 * @return string 89 */ 90 function order_relation_type_cast(string $key) 91 { 92 $relational_type_keys = apply_filters( 93 'subscrpt_order_relational_types', 94 array( 95 'new' => __('New Subscription Order', 'sdevs_subscrpt'), 96 'renew' => __('Renewal Order', 'sdevs_subscrpt'), 97 ) 98 ); 99 100 return $relational_type_keys[$key]; 101 } -
subscription/trunk/readme.txt
r2802189 r2927437 5 5 Requires at least: 4.0 6 6 Tested up to: 5.9 7 Stable tag: 1. 0.37 Stable tag: 1.1 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 49 49 50 50 51 == Frequently Asked Questions ==52 53 = How to overwrite frontend templates ? =54 55 Just copy **myaccount** directory which is located in the **templates** folder & paste it to **yourtheme/subscription/**. Now you can customize templates under **myaccount** directory.56 57 = Is it compatible with all WordPress themes ? =58 59 Compatibility with all themes is impossible, because there are too many, but generally if themes are developed according to WordPress and WooCommerce guidelines, **Subscription for WooCommerce** is compatible with them.60 Sometimes, especially when new versions are released, it might only require some time for them to be all updated, but you can be sure that they will be tested and will be working in a few days.61 62 = Can I create subscriptions from the backend ? =63 64 **No** Currently this feature is not available.65 66 = Is it possible to set a minimum subscription time ? =67 68 **No** this is not possible, customers can cancel at any time.69 70 71 51 == Screenshots == 72 52 … … 86 66 87 67 == Changelog == 68 69 = 1.1 = 70 - **Update:** We rebuild our plugin from scratch to provide better & long terms supports 71 - **Fix:** Severals UI & compatibility issues 88 72 89 73 = 1.0.4 = -
subscription/trunk/subscription.php
r2797349 r2927437 4 4 Plugin URI: https://wordpress.org/plugins/subscription 5 5 Description: Allow your customers to order once and get their products and services every month/week. 6 Version: 1. 0.46 Version: 1.1 7 7 Author: SpringDevs 8 8 Author URI: https://springdevs.com/ … … 39 39 */ 40 40 41 // don't call the file directly 41 // don't call the file directly. 42 42 if ( ! defined( 'ABSPATH' ) ) { 43 43 exit; … … 58 58 * @var string 59 59 */ 60 const version = '1. 0.4';60 const version = '1.1'; 61 61 62 62 /** … … 103 103 * Magic getter to bypass referencing plugin. 104 104 * 105 * @param $prop105 * @param mixed $prop Prop. 106 106 * 107 107 * @return mixed … … 118 118 * Magic isset to bypass referencing plugin. 119 119 * 120 * @param $prop120 * @param mixed $prop Prop. 121 121 * 122 122 * @return bool 123 123 */ 124 124 public function __isset( $prop ) { 125 125 return isset( $this->{$prop} ) || isset( $this->container[ $prop ] ); … … 196 196 public function init_hooks() { 197 197 add_action( 'init', array( $this, 'init_classes' ) ); 198 199 // Localize our plugin200 198 add_action( 'init', array( $this, 'localization_setup' ) ); 199 add_action( 'init', array( $this, 'run_update' ) ); 200 } 201 202 /** 203 * Need to do some actions after update plugin 204 * 205 * @return void 206 */ 207 public function run_update() { 208 $upgrade = new \SpringDevs\Subscription\Upgrade(); 209 $upgrade->run(); 201 210 } 202 211 … … 208 217 public function init_classes() { 209 218 if ( $this->is_request( 'ajax' ) ) { 210 $this->container['ajax'] = 219 $this->container['ajax'] = new SpringDevs\Subscription\Ajax(); 211 220 } 212 221 … … 257 266 */ 258 267 function sdevs_subscription() { 259 268 return Sdevs_Subscription::init(); 260 269 } 261 270 -
subscription/trunk/templates/myaccount/subscriptions.php
r2797349 r2927437 7 7 */ 8 8 9 $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; 9 use SpringDevs\Subscription\Illuminate\Helper; 10 11 $page_num = (get_query_var('paged')) ? get_query_var('paged') : 1; 10 12 11 13 $args = array( 12 14 'author' => get_current_user_id(), 13 15 'posts_per_page' => 10, 14 'paged' => $page d,16 'paged' => $page_num, 15 17 'post_type' => 'subscrpt_order', 16 'post_status' => array( 'pending', 'active', 'on_hold', 'cancelled', 'expired', 'pe_cancelled'),18 'post_status' => array('pending', 'active', 'on_hold', 'cancelled', 'expired', 'pe_cancelled'), 17 19 ); 18 20 19 $postslist = new WP_Query( $args);21 $postslist = new WP_Query($args); 20 22 ?> 21 23 22 <table class=" shop_table my_account_subscrpt">24 <table class="woocommerce-orders-table woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table my_account_subscrpt"> 23 25 <thead> 24 26 <tr> 25 <th scope="col" class="subscrpt-id"><?php esc_html_e( 'Subscription', 'sdevs_subscrpt'); ?></th>26 <th scope="col" class="order-status"><?php esc_html_e( 'Status', 'sdevs_subscrpt'); ?></th>27 <th scope="col" class="order-product"><?php esc_html_e( 'Product', 'sdevs_subscrpt'); ?></th>28 <th scope="col" class="subscrpt-next-date"><?php esc_html_e( 'Next Payment', 'sdevs_subscrpt'); ?></th>29 <th scope="col" class="subscrpt-total"><?php esc_html_e( 'Total', 'sdevs_subscrpt'); ?></th>27 <th scope="col" class="subscrpt-id"><?php esc_html_e('Subscription', 'sdevs_subscrpt'); ?></th> 28 <th scope="col" class="order-status"><?php esc_html_e('Status', 'sdevs_subscrpt'); ?></th> 29 <th scope="col" class="order-product"><?php esc_html_e('Product', 'sdevs_subscrpt'); ?></th> 30 <th scope="col" class="subscrpt-next-date"><?php esc_html_e('Next Payment', 'sdevs_subscrpt'); ?></th> 31 <th scope="col" class="subscrpt-total"><?php esc_html_e('Total', 'sdevs_subscrpt'); ?></th> 30 32 <th scope="col" class="subscrpt-action"></th> 31 33 </tr> … … 33 35 <tbody> 34 36 <?php 35 if ( $postslist->have_posts()) :36 while ( $postslist->have_posts()) :37 if ($postslist->have_posts()) : 38 while ($postslist->have_posts()) : 37 39 $postslist->the_post(); 38 $post_meta = get_post_meta( get_the_ID(), '_subscrpt_order_general', true ); 39 $product = wc_get_product( $post_meta['product_id'] ); 40 if ( isset( $post_meta['variation_id'] ) ) { 41 $product_meta = get_post_meta( $post_meta['variation_id'], 'subscrpt_general', true ); 42 } else { 43 $product_meta = $product->get_meta( 'subscrpt_general', true ); 44 } 45 $product_name = get_the_title( $post_meta['product_id'] ); 46 $product_name = apply_filters( 'subscrpt_filter_product_name', $product_name, $post_meta ); 47 $product_link = get_the_permalink( $post_meta['product_id'] ); 48 $product_link = apply_filters( 'subscrpt_filter_product_permalink', $product_link, $post_meta ); 49 $time = $product_meta['time'] == 1 ? null : $product_meta['time']; 50 $type = subscrpt_get_typos( $product_meta['time'], $product_meta['type'] ); 51 $product_price_html = wc_price( $product->get_price() * $post_meta['qty'] ) . ' / ' . $time . ' ' . $type; 52 $product_price_html = apply_filters( 'subscrpt_price_recurring', $product_price_html, $product, wc_get_order( $post_meta['order_id'] ), $post_meta['qty'] ); 53 ?> 40 $post_meta = get_post_meta(get_the_ID(), '_order_subscrpt_meta', true); 41 $product_id = get_post_meta(get_the_ID(), '_subscrpt_product_id', true); 42 $order = wc_get_order($post_meta['order_id']); 43 $order_item = $order->get_item($post_meta['order_item_id']); 44 45 $post_status_object = get_post_status_object(get_post_status()); 46 $product_name = $order_item->get_name(); 47 $product_link = get_the_permalink($product_id); 48 $product_price_html = Helper::format_price_with_order_item($order_item->get_total(), $order_item->get_id()); 49 ?> 54 50 <tr> 55 51 <td><?php the_ID(); ?></td> 56 <td><span class="subscrpt-<?php echo get_post_status(); ?>"><?php echo get_post_status(); ?></span></td>57 <td><a href="<?php echo esc_html( $product_link ); ?>" target="_blank"><?php echo esc_html( $product_name); ?></a></td>58 <?php if ( $post_meta['trial'] == null) : ?>59 <td><?php echo date( 'F d, Y', $post_meta['next_date']); ?></td>52 <td><span class="subscrpt-<?php echo esc_attr($post_status_object->name); ?>"><?php echo esc_html(strlen($post_status_object->label) > 9 ? substr($post_status_object->label, 0, 6) . '...' : $post_status_object->label); ?></span></td> 53 <td><a href="<?php echo esc_html($product_link); ?>" target="_blank"><?php echo esc_html($product_name); ?></a></td> 54 <?php if ($post_meta['trial'] == null) : ?> 55 <td><?php echo date('F d, Y', $post_meta['next_date']); ?></td> 60 56 <?php else : ?> 61 <td><small>First Billing : </small><?php echo date( 'F d, Y', $post_meta['start_date']); ?></td>57 <td><small>First Billing : </small><?php echo date('F d, Y', $post_meta['start_date']); ?></td> 62 58 <?php endif; ?> 63 <td><?php echo wp_kses_post( $product_price_html); ?></td>59 <td><?php echo wp_kses_post($product_price_html); ?></td> 64 60 <td> 65 <a href="<?php echo get_permalink( wc_get_page_id( 'myaccount' ) ) . 'view-subscrpt/' . get_the_ID(); ?>" class="woocommerce-button button view">View</a>61 <a href="<?php echo esc_html(wc_get_endpoint_url('view-subscription', get_the_ID(), wc_get_page_permalink('myaccount'))); ?>" class="woocommerce-button <?php echo esc_attr($wp_button_class); ?> button view"><span class="dashicons dashicons-visibility"></span></a> 66 62 </td> 67 63 </tr> 68 64 <?php 69 65 endwhile; 70 next_posts_link( 'Older Entries', $postslist->max_num_pages);71 previous_posts_link( 'Next Entries »');66 next_posts_link('Older Entries', $postslist->max_num_pages); 67 previous_posts_link('Next Entries »'); 72 68 wp_reset_postdata(); 73 69 endif; -
subscription/trunk/vendor/autoload.php
r2797349 r2927437 3 3 // autoload.php @generated by Composer 4 4 5 if (PHP_VERSION_ID < 50600) { 6 if (!headers_sent()) { 7 header('HTTP/1.1 500 Internal Server Error'); 8 } 9 $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; 10 if (!ini_get('display_errors')) { 11 if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { 12 fwrite(STDERR, $err); 13 } elseif (!headers_sent()) { 14 echo $err; 15 } 16 } 17 trigger_error( 18 $err, 19 E_USER_ERROR 20 ); 21 } 22 5 23 require_once __DIR__ . '/composer/autoload_real.php'; 6 24 7 return ComposerAutoloaderInit 9fa6d4e77b41bba2a0a04174377f1ff7::getLoader();25 return ComposerAutoloaderInitea22a3b7d201ba553fedb2d49015d434::getLoader(); -
subscription/trunk/vendor/composer/ClassLoader.php
r2708268 r2927437 43 43 class ClassLoader 44 44 { 45 /** @var ?string */ 45 /** @var \Closure(string):void */ 46 private static $includeFile; 47 48 /** @var string|null */ 46 49 private $vendorDir; 47 50 48 51 // PSR-4 49 52 /** 50 * @var array[] 51 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 52 54 */ 53 55 private $prefixLengthsPsr4 = array(); 54 56 /** 55 * @var array[] 56 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 57 58 */ 58 59 private $prefixDirsPsr4 = array(); 59 60 /** 60 * @var array[] 61 * @psalm-var array<string, string> 61 * @var list<string> 62 62 */ 63 63 private $fallbackDirsPsr4 = array(); … … 65 65 // PSR-0 66 66 /** 67 * @var array[] 68 * @psalm-var array<string, array<string, string[]>> 67 * List of PSR-0 prefixes 68 * 69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) 70 * 71 * @var array<string, array<string, list<string>>> 69 72 */ 70 73 private $prefixesPsr0 = array(); 71 74 /** 72 * @var array[] 73 * @psalm-var array<string, string> 75 * @var list<string> 74 76 */ 75 77 private $fallbackDirsPsr0 = array(); … … 79 81 80 82 /** 81 * @var string[] 82 * @psalm-var array<string, string> 83 * @var array<string, string> 83 84 */ 84 85 private $classMap = array(); … … 88 89 89 90 /** 90 * @var bool[] 91 * @psalm-var array<string, bool> 91 * @var array<string, bool> 92 92 */ 93 93 private $missingClasses = array(); 94 94 95 /** @var ?string*/95 /** @var string|null */ 96 96 private $apcuPrefix; 97 97 98 98 /** 99 * @var self[]99 * @var array<string, self> 100 100 */ 101 101 private static $registeredLoaders = array(); 102 102 103 103 /** 104 * @param ?string$vendorDir104 * @param string|null $vendorDir 105 105 */ 106 106 public function __construct($vendorDir = null) 107 107 { 108 108 $this->vendorDir = $vendorDir; 109 } 110 111 /** 112 * @return string[] 109 self::initializeIncludeClosure(); 110 } 111 112 /** 113 * @return array<string, list<string>> 113 114 */ 114 115 public function getPrefixes() … … 122 123 123 124 /** 124 * @return array[] 125 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 126 126 */ 127 127 public function getPrefixesPsr4() … … 131 131 132 132 /** 133 * @return array[] 134 * @psalm-return array<string, string> 133 * @return list<string> 135 134 */ 136 135 public function getFallbackDirs() … … 140 139 141 140 /** 142 * @return array[] 143 * @psalm-return array<string, string> 141 * @return list<string> 144 142 */ 145 143 public function getFallbackDirsPsr4() … … 149 147 150 148 /** 151 * @return string[] Array of classname => path 152 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 153 150 */ 154 151 public function getClassMap() … … 158 155 159 156 /** 160 * @param string[] $classMap Class to filename map 161 * @psalm-param array<string, string> $classMap 157 * @param array<string, string> $classMap Class to filename map 162 158 * 163 159 * @return void … … 176 172 * appending or prepending to the ones previously set for this prefix. 177 173 * 178 * @param string $prefix The prefix179 * @param string[]|string $paths The PSR-0 root directories180 * @param bool $prepend Whether to prepend the directories174 * @param string $prefix The prefix 175 * @param list<string>|string $paths The PSR-0 root directories 176 * @param bool $prepend Whether to prepend the directories 181 177 * 182 178 * @return void … … 184 180 public function add($prefix, $paths, $prepend = false) 185 181 { 182 $paths = (array) $paths; 186 183 if (!$prefix) { 187 184 if ($prepend) { 188 185 $this->fallbackDirsPsr0 = array_merge( 189 (array)$paths,186 $paths, 190 187 $this->fallbackDirsPsr0 191 188 ); … … 193 190 $this->fallbackDirsPsr0 = array_merge( 194 191 $this->fallbackDirsPsr0, 195 (array)$paths192 $paths 196 193 ); 197 194 } … … 202 199 $first = $prefix[0]; 203 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 204 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 205 202 206 203 return; … … 208 205 if ($prepend) { 209 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 210 (array)$paths,207 $paths, 211 208 $this->prefixesPsr0[$first][$prefix] 212 209 ); … … 214 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 215 212 $this->prefixesPsr0[$first][$prefix], 216 (array)$paths213 $paths 217 214 ); 218 215 } … … 223 220 * appending or prepending to the ones previously set for this namespace. 224 221 * 225 * @param string $prefix The prefix/namespace, with trailing '\\'226 * @param string[]|string $paths The PSR-4 base directories227 * @param bool $prepend Whether to prepend the directories222 * @param string $prefix The prefix/namespace, with trailing '\\' 223 * @param list<string>|string $paths The PSR-4 base directories 224 * @param bool $prepend Whether to prepend the directories 228 225 * 229 226 * @throws \InvalidArgumentException … … 233 230 public function addPsr4($prefix, $paths, $prepend = false) 234 231 { 232 $paths = (array) $paths; 235 233 if (!$prefix) { 236 234 // Register directories for the root namespace. 237 235 if ($prepend) { 238 236 $this->fallbackDirsPsr4 = array_merge( 239 (array)$paths,237 $paths, 240 238 $this->fallbackDirsPsr4 241 239 ); … … 243 241 $this->fallbackDirsPsr4 = array_merge( 244 242 $this->fallbackDirsPsr4, 245 (array)$paths243 $paths 246 244 ); 247 245 } … … 253 251 } 254 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 255 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 256 254 } elseif ($prepend) { 257 255 // Prepend directories for an already registered namespace. 258 256 $this->prefixDirsPsr4[$prefix] = array_merge( 259 (array)$paths,257 $paths, 260 258 $this->prefixDirsPsr4[$prefix] 261 259 ); … … 264 262 $this->prefixDirsPsr4[$prefix] = array_merge( 265 263 $this->prefixDirsPsr4[$prefix], 266 (array)$paths264 $paths 267 265 ); 268 266 } … … 273 271 * replacing any others previously set for this prefix. 274 272 * 275 * @param string $prefix The prefix276 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param list<string>|string $paths The PSR-0 base directories 277 275 * 278 276 * @return void … … 291 289 * replacing any others previously set for this namespace. 292 290 * 293 * @param string $prefix The prefix/namespace, with trailing '\\'294 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param list<string>|string $paths The PSR-4 base directories 295 293 * 296 294 * @throws \InvalidArgumentException … … 426 424 { 427 425 if ($file = $this->findFile($class)) { 428 includeFile($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 429 428 430 429 return true; … … 477 476 478 477 /** 479 * Returns the currently registered loaders indexed by their corresponding vendor directories.480 * 481 * @return self[]478 * Returns the currently registered loaders keyed by their corresponding vendor directories. 479 * 480 * @return array<string, self> 482 481 */ 483 482 public static function getRegisteredLoaders() … … 556 555 return false; 557 556 } 557 558 /** 559 * @return void 560 */ 561 private static function initializeIncludeClosure() 562 { 563 if (self::$includeFile !== null) { 564 return; 565 } 566 567 /** 568 * Scope isolated include. 569 * 570 * Prevents access to $this/self from included files. 571 * 572 * @param string $file 573 * @return void 574 */ 575 self::$includeFile = \Closure::bind(static function($file) { 576 include $file; 577 }, null, null); 578 } 558 579 } 559 560 /**561 * Scope isolated include.562 *563 * Prevents access to $this/self from included files.564 *565 * @param string $file566 * @return void567 * @private568 */569 function includeFile($file)570 {571 include $file;572 } -
subscription/trunk/vendor/composer/InstalledVersions.php
r2708268 r2927437 22 22 * 23 23 * To require its presence, you can require `composer-runtime-api ^2.0` 24 * 25 * @final 24 26 */ 25 27 class InstalledVersions … … 27 29 /** 28 30 * @var mixed[]|null 29 * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null31 * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null 30 32 */ 31 33 private static $installed; … … 38 40 /** 39 41 * @var array[] 40 * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>42 * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> 41 43 */ 42 44 private static $installedByVendor = array(); … … 97 99 foreach (self::getInstalled() as $installed) { 98 100 if (isset($installed['versions'][$packageName])) { 99 return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);101 return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; 100 102 } 101 103 } … … 118 120 public static function satisfies(VersionParser $parser, $packageName, $constraint) 119 121 { 120 $constraint = $parser->parseConstraints( $constraint);122 $constraint = $parser->parseConstraints((string) $constraint); 121 123 $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); 122 124 … … 242 244 /** 243 245 * @return array 244 * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}246 * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} 245 247 */ 246 248 public static function getRootPackage() … … 256 258 * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. 257 259 * @return array[] 258 * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}260 * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} 259 261 */ 260 262 public static function getRawData() … … 279 281 * 280 282 * @return array[] 281 * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>283 * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> 282 284 */ 283 285 public static function getAllRawData() … … 302 304 * @return void 303 305 * 304 * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data306 * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data 305 307 */ 306 308 public static function reload($data) … … 312 314 /** 313 315 * @return array[] 314 * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>316 * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> 315 317 */ 316 318 private static function getInstalled() … … 327 329 $installed[] = self::$installedByVendor[$vendorDir]; 328 330 } elseif (is_file($vendorDir.'/composer/installed.php')) { 329 $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; 331 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 332 $required = require $vendorDir.'/composer/installed.php'; 333 $installed[] = self::$installedByVendor[$vendorDir] = $required; 330 334 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 331 335 self::$installed = $installed[count($installed) - 1]; … … 339 343 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 340 344 if (substr(__DIR__, -8, 1) !== 'C') { 341 self::$installed = require __DIR__ . '/installed.php'; 345 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 346 $required = require __DIR__ . '/installed.php'; 347 self::$installed = $required; 342 348 } else { 343 349 self::$installed = array(); 344 350 } 345 351 } 346 $installed[] = self::$installed; 352 353 if (self::$installed !== array()) { 354 $installed[] = self::$installed; 355 } 347 356 348 357 return $installed; -
subscription/trunk/vendor/composer/autoload_classmap.php
r2685408 r2927437 3 3 // autoload_classmap.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
subscription/trunk/vendor/composer/autoload_files.php
r2685408 r2927437 3 3 // autoload_files.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
subscription/trunk/vendor/composer/autoload_namespaces.php
r2685408 r2927437 3 3 // autoload_namespaces.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
subscription/trunk/vendor/composer/autoload_psr4.php
r2685408 r2927437 3 3 // autoload_psr4.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
subscription/trunk/vendor/composer/autoload_real.php
r2797349 r2927437 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 9fa6d4e77b41bba2a0a04174377f1ff75 class ComposerAutoloaderInitea22a3b7d201ba553fedb2d49015d434 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 9fa6d4e77b41bba2a0a04174377f1ff7', 'loadClassLoader'), true, true);26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname( \dirname(__FILE__)));27 spl_autoload_unregister(array('ComposerAutoloaderInit 9fa6d4e77b41bba2a0a04174377f1ff7', 'loadClassLoader'));25 spl_autoload_register(array('ComposerAutoloaderInitea22a3b7d201ba553fedb2d49015d434', 'loadClassLoader'), true, true); 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInitea22a3b7d201ba553fedb2d49015d434', 'loadClassLoader')); 28 28 29 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 30 if ($useStaticLoader) { 31 require __DIR__ . '/autoload_static.php'; 32 33 call_user_func(\Composer\Autoload\ComposerStaticInit9fa6d4e77b41bba2a0a04174377f1ff7::getInitializer($loader)); 34 } else { 35 $map = require __DIR__ . '/autoload_namespaces.php'; 36 foreach ($map as $namespace => $path) { 37 $loader->set($namespace, $path); 38 } 39 40 $map = require __DIR__ . '/autoload_psr4.php'; 41 foreach ($map as $namespace => $path) { 42 $loader->setPsr4($namespace, $path); 43 } 44 45 $classMap = require __DIR__ . '/autoload_classmap.php'; 46 if ($classMap) { 47 $loader->addClassMap($classMap); 48 } 49 } 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInitea22a3b7d201ba553fedb2d49015d434::getInitializer($loader)); 50 31 51 32 $loader->register(true); 52 33 53 if ($useStaticLoader) { 54 $includeFiles = Composer\Autoload\ComposerStaticInit9fa6d4e77b41bba2a0a04174377f1ff7::$files; 55 } else { 56 $includeFiles = require __DIR__ . '/autoload_files.php'; 57 } 58 foreach ($includeFiles as $fileIdentifier => $file) { 59 composerRequire9fa6d4e77b41bba2a0a04174377f1ff7($fileIdentifier, $file); 34 $filesToLoad = \Composer\Autoload\ComposerStaticInitea22a3b7d201ba553fedb2d49015d434::$files; 35 $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { 36 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { 37 $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; 38 39 require $file; 40 } 41 }, null, null); 42 foreach ($filesToLoad as $fileIdentifier => $file) { 43 $requireFile($fileIdentifier, $file); 60 44 } 61 45 … … 63 47 } 64 48 } 65 66 /**67 * @param string $fileIdentifier68 * @param string $file69 * @return void70 */71 function composerRequire9fa6d4e77b41bba2a0a04174377f1ff7($fileIdentifier, $file)72 {73 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {74 $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;75 76 require $file;77 }78 } -
subscription/trunk/vendor/composer/autoload_static.php
r2797349 r2927437 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 9fa6d4e77b41bba2a0a04174377f1ff77 class ComposerStaticInitea22a3b7d201ba553fedb2d49015d434 8 8 { 9 9 public static $files = array ( … … 32 32 { 33 33 return \Closure::bind(function () use ($loader) { 34 $loader->prefixLengthsPsr4 = ComposerStaticInit 9fa6d4e77b41bba2a0a04174377f1ff7::$prefixLengthsPsr4;35 $loader->prefixDirsPsr4 = ComposerStaticInit 9fa6d4e77b41bba2a0a04174377f1ff7::$prefixDirsPsr4;36 $loader->classMap = ComposerStaticInit 9fa6d4e77b41bba2a0a04174377f1ff7::$classMap;34 $loader->prefixLengthsPsr4 = ComposerStaticInitea22a3b7d201ba553fedb2d49015d434::$prefixLengthsPsr4; 35 $loader->prefixDirsPsr4 = ComposerStaticInitea22a3b7d201ba553fedb2d49015d434::$prefixDirsPsr4; 36 $loader->classMap = ComposerStaticInitea22a3b7d201ba553fedb2d49015d434::$classMap; 37 37 38 38 }, null, ClassLoader::class); -
subscription/trunk/vendor/composer/installed.php
r2797349 r2927437 1 1 <?php return array( 2 2 'root' => array( 3 'name' => 'springdevs/subscription', 3 4 'pretty_version' => 'dev-next', 4 5 'version' => 'dev-next', 6 'reference' => '3bbd57215d40baa7b374ad001eebf3a5b4fa9f3a', 5 7 'type' => 'wordpress-plugin', 6 8 'install_path' => __DIR__ . '/../../', 7 9 'aliases' => array(), 8 'reference' => 'b79b1432d9114652e0e8fc961f6fd038209499d3',9 'name' => 'springdevs/subscription',10 10 'dev' => false, 11 11 ), … … 14 14 'pretty_version' => 'dev-next', 15 15 'version' => 'dev-next', 16 'reference' => '3bbd57215d40baa7b374ad001eebf3a5b4fa9f3a', 16 17 'type' => 'wordpress-plugin', 17 18 'install_path' => __DIR__ . '/../../', 18 19 'aliases' => array(), 19 'reference' => 'b79b1432d9114652e0e8fc961f6fd038209499d3',20 20 'dev_requirement' => false, 21 21 ),
Note: See TracChangeset
for help on using the changeset viewer.