@@ -56,7 +56,7 @@ |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function wpinv_admin_messages() { |
| 59 | - settings_errors( 'wpinv-notices' ); |
|
| 59 | + settings_errors( 'wpinv-notices' ); |
|
| 60 | 60 | } |
| 61 | 61 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
| 62 | 62 | |
@@ -7,65 +7,65 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_bulk_actions( $actions ) { |
|
| 15 | - if ( isset( $actions['edit'] ) ) { |
|
| 16 | - unset( $actions['edit'] ); |
|
| 14 | +function wpinv_bulk_actions($actions) { |
|
| 15 | + if (isset($actions['edit'])) { |
|
| 16 | + unset($actions['edit']); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | return $actions; |
| 20 | 20 | } |
| 21 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
| 22 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
| 21 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
| 22 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
| 23 | 23 | |
| 24 | -function wpinv_admin_post_id( $id = 0 ) { |
|
| 24 | +function wpinv_admin_post_id($id = 0) { |
|
| 25 | 25 | global $post; |
| 26 | 26 | |
| 27 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
| 28 | - return (int)$id; |
|
| 29 | - } else if ( get_the_ID() ) { |
|
| 27 | + if (isset($id) && !empty($id)) { |
|
| 28 | + return (int) $id; |
|
| 29 | + } else if (get_the_ID()) { |
|
| 30 | 30 | return (int) get_the_ID(); |
| 31 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
| 31 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
| 32 | 32 | return (int) $post->ID; |
| 33 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
| 33 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
| 34 | 34 | return (int) $_GET['post']; |
| 35 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
| 35 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
| 36 | 36 | return (int) $_GET['id']; |
| 37 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
| 37 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
| 38 | 38 | return (int) $_POST['id']; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return null; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function wpinv_admin_post_type( $id = 0 ) { |
|
| 45 | - if ( !$id ) { |
|
| 44 | +function wpinv_admin_post_type($id = 0) { |
|
| 45 | + if (!$id) { |
|
| 46 | 46 | $id = wpinv_admin_post_id(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $type = get_post_type( $id ); |
|
| 49 | + $type = get_post_type($id); |
|
| 50 | 50 | |
| 51 | - if ( !$type ) { |
|
| 52 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
| 51 | + if (!$type) { |
|
| 52 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
| 55 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function wpinv_admin_messages() { |
| 59 | - settings_errors( 'wpinv-notices' ); |
|
| 59 | + settings_errors('wpinv-notices'); |
|
| 60 | 60 | } |
| 61 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
| 61 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
| 62 | 62 | |
| 63 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
| 64 | -function wpinv_show_test_payment_gateway_notice(){ |
|
| 65 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
| 63 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
| 64 | +function wpinv_show_test_payment_gateway_notice() { |
|
| 65 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -function wpinv_test_payment_gateway_messages(){ |
|
| 68 | +function wpinv_test_payment_gateway_messages() { |
|
| 69 | 69 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 70 | 70 | $name = array(); $test_gateways = ''; |
| 71 | 71 | if ($gateways) { |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | $test_gateways = implode(', ', $name); |
| 78 | 78 | } |
| 79 | - if(isset($test_gateways) && !empty($test_gateways)){ |
|
| 79 | + if (isset($test_gateways) && !empty($test_gateways)) { |
|
| 80 | 80 | $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
| 81 | - $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link ); |
|
| 81 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
| 82 | 82 | ?> |
| 83 | 83 | <div class="notice notice-warning is-dismissible"> |
| 84 | 84 | <p><?php echo $notice; ?></p> |
@@ -87,16 +87,16 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
| 91 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
| 90 | +function wpinv_send_invoice_after_save($invoice) { |
|
| 91 | + if (empty($_POST['wpi_save_send'])) { |
|
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
| 96 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
| 95 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
| 96 | + wpinv_user_invoice_notification($invoice->ID); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
| 99 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | add_action('admin_init', 'admin_init_example_type'); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | function admin_init_example_type() { |
| 108 | 108 | global $typenow; |
| 109 | 109 | |
| 110 | - if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
| 110 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
| 111 | 111 | add_filter('posts_search', 'posts_search_example_type', 10, 2); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | global $wpdb; |
| 123 | 123 | |
| 124 | 124 | if ($query->is_main_query() && !empty($query->query['s'])) { |
| 125 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
| 126 | - if ( ! empty( $search ) ) { |
|
| 127 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
| 125 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
| 126 | + if (!empty($search)) { |
|
| 127 | + $search = preg_replace('/^ AND /', '', $search); |
|
| 128 | 128 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
| 129 | 129 | } else { |
| 130 | 130 | $search = " AND ( {$conditions_str} )"; |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | return $search; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
| 138 | -function wpinv_reset_invoice_count(){ |
|
| 139 | - if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
| 137 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
| 138 | +function wpinv_reset_invoice_count() { |
|
| 139 | + if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
| 140 | 140 | wpinv_update_option('invoice_sequence_start', 1); |
| 141 | 141 | delete_option('wpinv_last_invoice_number'); |
| 142 | 142 | $url = add_query_arg(array('reset_invoice_done' => 1)); |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | add_action('admin_notices', 'wpinv_invoice_count_reset_message'); |
| 150 | -function wpinv_invoice_count_reset_message(){ |
|
| 151 | - if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
| 150 | +function wpinv_invoice_count_reset_message() { |
|
| 151 | + if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
| 152 | 152 | $notice = __('Invoice number sequence reset successfully.', 'invoicing'); |
| 153 | 153 | ?> |
| 154 | 154 | <div class="notice notice-success is-dismissible"> |
@@ -14,62 +14,62 @@ discard block |
||
| 14 | 14 | class GetPaid_Admin { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Local path to this plugins admin directory |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $admin_path; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Web path to this plugins admin directory |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 17 | + * Local path to this plugins admin directory |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $admin_path; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Web path to this plugins admin directory |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | 28 | public $admin_url; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * Class constructor. |
|
| 32 | - */ |
|
| 33 | - public function __construct(){ |
|
| 31 | + * Class constructor. |
|
| 32 | + */ |
|
| 33 | + public function __construct(){ |
|
| 34 | 34 | |
| 35 | 35 | $this->admin_path = plugin_dir_path( __FILE__ ); |
| 36 | 36 | $this->admin_url = plugins_url( '/', __FILE__ ); |
| 37 | 37 | |
| 38 | 38 | if ( is_admin() ) { |
| 39 | - $this->init_admin_hooks(); |
|
| 39 | + $this->init_admin_hooks(); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * Init action and filter hooks |
|
| 46 | - * |
|
| 47 | - */ |
|
| 48 | - private function init_admin_hooks() { |
|
| 45 | + * Init action and filter hooks |
|
| 46 | + * |
|
| 47 | + */ |
|
| 48 | + private function init_admin_hooks() { |
|
| 49 | 49 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
| 50 | 50 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
| 51 | 51 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
| 52 | 52 | add_action( 'admin_init', array( $this, 'activation_redirect') ); |
| 53 | 53 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
| 54 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 55 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 56 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 57 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 54 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 55 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 56 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 57 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | - * Register admin scripts |
|
| 63 | - * |
|
| 64 | - */ |
|
| 65 | - public function enqeue_scripts() { |
|
| 62 | + * Register admin scripts |
|
| 63 | + * |
|
| 64 | + */ |
|
| 65 | + public function enqeue_scripts() { |
|
| 66 | 66 | global $current_screen, $pagenow; |
| 67 | 67 | |
| 68 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 69 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
| 68 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 69 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
| 70 | 70 | |
| 71 | 71 | if ( ! empty( $current_screen->post_type ) ) { |
| 72 | - $page = $current_screen->post_type; |
|
| 72 | + $page = $current_screen->post_type; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // General styles. |
@@ -93,30 +93,30 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Payment form scripts. |
| 96 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 96 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 97 | 97 | $this->load_payment_form_scripts(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | if ( $page == 'wpinv-subscriptions' ) { |
| 101 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 102 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 103 | - } |
|
| 101 | + wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 102 | + wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - if ( $page == 'wpinv-reports' ) { |
|
| 106 | - wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
| 107 | - } |
|
| 105 | + if ( $page == 'wpinv-reports' ) { |
|
| 106 | + wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 110 | - wp_enqueue_script( 'postbox' ); |
|
| 111 | - } |
|
| 109 | + if ( $page == 'wpinv-subscriptions' ) { |
|
| 110 | + wp_enqueue_script( 'postbox' ); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | - * Returns admin js translations. |
|
| 117 | - * |
|
| 118 | - */ |
|
| 119 | - protected function get_admin_i18() { |
|
| 116 | + * Returns admin js translations. |
|
| 117 | + * |
|
| 118 | + */ |
|
| 119 | + protected function get_admin_i18() { |
|
| 120 | 120 | global $post; |
| 121 | 121 | |
| 122 | 122 | $i18n = array( |
@@ -152,50 +152,50 @@ discard block |
||
| 152 | 152 | 'searching' => __( 'Searching', 'invoicing' ), |
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 155 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 156 | 156 | |
| 157 | - $invoice = new WPInv_Invoice( $post ); |
|
| 158 | - $i18n['save_invoice'] = sprintf( |
|
| 159 | - __( 'Save %s', 'invoicing' ), |
|
| 160 | - ucfirst( $invoice->get_type() ) |
|
| 161 | - ); |
|
| 157 | + $invoice = new WPInv_Invoice( $post ); |
|
| 158 | + $i18n['save_invoice'] = sprintf( |
|
| 159 | + __( 'Save %s', 'invoicing' ), |
|
| 160 | + ucfirst( $invoice->get_type() ) |
|
| 161 | + ); |
|
| 162 | 162 | |
| 163 | - $i18n['invoice_description'] = sprintf( |
|
| 164 | - __( '%s Description', 'invoicing' ), |
|
| 165 | - ucfirst( $invoice->get_type() ) |
|
| 166 | - ); |
|
| 163 | + $i18n['invoice_description'] = sprintf( |
|
| 164 | + __( '%s Description', 'invoicing' ), |
|
| 165 | + ucfirst( $invoice->get_type() ) |
|
| 166 | + ); |
|
| 167 | 167 | |
| 168 | - } |
|
| 169 | - return $i18n; |
|
| 168 | + } |
|
| 169 | + return $i18n; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | - * Loads payment form js. |
|
| 174 | - * |
|
| 175 | - */ |
|
| 176 | - protected function load_payment_form_scripts() { |
|
| 173 | + * Loads payment form js. |
|
| 174 | + * |
|
| 175 | + */ |
|
| 176 | + protected function load_payment_form_scripts() { |
|
| 177 | 177 | global $post; |
| 178 | 178 | |
| 179 | 179 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
| 180 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 181 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 180 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 181 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 182 | 182 | |
| 183 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 184 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 183 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 184 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 185 | 185 | |
| 186 | - wp_localize_script( |
|
| 186 | + wp_localize_script( |
|
| 187 | 187 | 'wpinv-admin-payment-form-script', |
| 188 | 188 | 'wpinvPaymentFormAdmin', |
| 189 | 189 | array( |
| 190 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 191 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 192 | - 'currency' => wpinv_currency_symbol(), |
|
| 193 | - 'position' => wpinv_currency_position(), |
|
| 194 | - 'decimals' => (int) wpinv_decimals(), |
|
| 195 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
| 196 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
| 197 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 198 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
| 190 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 191 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 192 | + 'currency' => wpinv_currency_symbol(), |
|
| 193 | + 'position' => wpinv_currency_position(), |
|
| 194 | + 'decimals' => (int) wpinv_decimals(), |
|
| 195 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
| 196 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
| 197 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 198 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
| 199 | 199 | ) |
| 200 | 200 | ); |
| 201 | 201 | |
@@ -204,20 +204,20 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
| 207 | - * Add our classes to admin pages. |
|
| 207 | + * Add our classes to admin pages. |
|
| 208 | 208 | * |
| 209 | 209 | * @param string $classes |
| 210 | 210 | * @return string |
| 211 | - * |
|
| 212 | - */ |
|
| 211 | + * |
|
| 212 | + */ |
|
| 213 | 213 | public function admin_body_class( $classes ) { |
| 214 | - global $pagenow, $post, $current_screen; |
|
| 214 | + global $pagenow, $post, $current_screen; |
|
| 215 | 215 | |
| 216 | 216 | |
| 217 | 217 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
| 218 | 218 | |
| 219 | 219 | if ( ! empty( $current_screen->post_type ) ) { |
| 220 | - $page = $current_screen->post_type; |
|
| 220 | + $page = $current_screen->post_type; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -226,29 +226,29 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
| 228 | 228 | $classes .= ' wpinv-cpt wpinv'; |
| 229 | - } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 231 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 232 | 232 | $classes .= ' getpaid-is-invoice-cpt'; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - return $classes; |
|
| 235 | + return $classes; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
| 239 | - * Maybe show the AyeCode Connect Notice. |
|
| 240 | - */ |
|
| 241 | - public function init_ayecode_connect_helper(){ |
|
| 239 | + * Maybe show the AyeCode Connect Notice. |
|
| 240 | + */ |
|
| 241 | + public function init_ayecode_connect_helper(){ |
|
| 242 | 242 | |
| 243 | 243 | new AyeCode_Connect_Helper( |
| 244 | 244 | array( |
| 245 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 246 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 247 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 248 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 249 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 250 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 251 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 245 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 246 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 247 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 248 | + 'connect_button' => __("Connect Site","invoicing"), |
|
| 249 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
| 250 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 251 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 252 | 252 | ), |
| 253 | 253 | array( 'wpi-addons' ) |
| 254 | 254 | ); |
@@ -260,21 +260,21 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function activation_redirect() { |
| 262 | 262 | |
| 263 | - // Bail if no activation redirect. |
|
| 264 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
| 265 | - return; |
|
| 266 | - } |
|
| 263 | + // Bail if no activation redirect. |
|
| 264 | + if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - // Delete the redirect transient. |
|
| 269 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 268 | + // Delete the redirect transient. |
|
| 269 | + delete_transient( '_wpinv_activation_redirect' ); |
|
| 270 | 270 | |
| 271 | - // Bail if activating from network, or bulk |
|
| 272 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 273 | - return; |
|
| 274 | - } |
|
| 271 | + // Bail if activating from network, or bulk |
|
| 272 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 273 | + return; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 277 | - exit; |
|
| 276 | + wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 277 | + exit; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -289,150 +289,150 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - /** |
|
| 292 | + /** |
|
| 293 | 293 | * Sends a payment reminder to a customer. |
| 294 | - * |
|
| 295 | - * @param array $args |
|
| 294 | + * |
|
| 295 | + * @param array $args |
|
| 296 | 296 | */ |
| 297 | 297 | public function send_customer_invoice( $args ) { |
| 298 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 298 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 299 | 299 | |
| 300 | - if ( $sent ) { |
|
| 301 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 302 | - } else { |
|
| 303 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
| 304 | - } |
|
| 300 | + if ( $sent ) { |
|
| 301 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 302 | + } else { |
|
| 303 | + $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 307 | - exit; |
|
| 308 | - } |
|
| 306 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 307 | + exit; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - /** |
|
| 310 | + /** |
|
| 311 | 311 | * Sends a payment reminder to a customer. |
| 312 | - * |
|
| 313 | - * @param array $args |
|
| 312 | + * |
|
| 313 | + * @param array $args |
|
| 314 | 314 | */ |
| 315 | 315 | public function send_customer_payment_reminder( $args ) { |
| 316 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 316 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 317 | 317 | |
| 318 | - if ( $sent ) { |
|
| 319 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 320 | - } else { |
|
| 321 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 322 | - } |
|
| 318 | + if ( $sent ) { |
|
| 319 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 320 | + } else { |
|
| 321 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 325 | - exit; |
|
| 326 | - } |
|
| 324 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 325 | + exit; |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | - * Returns an array of admin notices. |
|
| 330 | - * |
|
| 331 | - * @since 1.0.19 |
|
| 329 | + * Returns an array of admin notices. |
|
| 330 | + * |
|
| 331 | + * @since 1.0.19 |
|
| 332 | 332 | * @return array |
| 333 | - */ |
|
| 334 | - public function get_notices() { |
|
| 335 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
| 333 | + */ |
|
| 334 | + public function get_notices() { |
|
| 335 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
| 336 | 336 | return is_array( $notices ) ? $notices : array(); |
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * Clears all admin notices |
|
| 341 | - * |
|
| 342 | - * @access public |
|
| 343 | - * @since 1.0.19 |
|
| 344 | - */ |
|
| 345 | - public function clear_notices() { |
|
| 346 | - delete_option( 'wpinv_admin_notices' ); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * Saves a new admin notice |
|
| 351 | - * |
|
| 352 | - * @access public |
|
| 353 | - * @since 1.0.19 |
|
| 354 | - */ |
|
| 355 | - public function save_notice( $type, $message ) { |
|
| 356 | - $notices = $this->get_notices(); |
|
| 357 | - |
|
| 358 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 359 | - $notices[ $type ] = array(); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - $notices[ $type ][] = $message; |
|
| 363 | - |
|
| 364 | - update_option( 'wpinv_admin_notices', $notices ); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Displays a success notice |
|
| 369 | - * |
|
| 370 | - * @param string $msg The message to qeue. |
|
| 371 | - * @access public |
|
| 372 | - * @since 1.0.19 |
|
| 373 | - */ |
|
| 374 | - public function show_success( $msg ) { |
|
| 375 | - $this->save_notice( 'success', $msg ); |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * Displays a error notice |
|
| 380 | - * |
|
| 381 | - * @access public |
|
| 382 | - * @param string $msg The message to qeue. |
|
| 383 | - * @since 1.0.19 |
|
| 384 | - */ |
|
| 385 | - public function show_error( $msg ) { |
|
| 386 | - $this->save_notice( 'error', $msg ); |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * Displays a warning notice |
|
| 391 | - * |
|
| 392 | - * @access public |
|
| 393 | - * @param string $msg The message to qeue. |
|
| 394 | - * @since 1.0.19 |
|
| 395 | - */ |
|
| 396 | - public function show_warning( $msg ) { |
|
| 397 | - $this->save_notice( 'warning', $msg ); |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * Displays a info notice |
|
| 402 | - * |
|
| 403 | - * @access public |
|
| 404 | - * @param string $msg The message to qeue. |
|
| 405 | - * @since 1.0.19 |
|
| 406 | - */ |
|
| 407 | - public function show_info( $msg ) { |
|
| 408 | - $this->save_notice( 'info', $msg ); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Show notices |
|
| 413 | - * |
|
| 414 | - * @access public |
|
| 415 | - * @since 1.0.19 |
|
| 416 | - */ |
|
| 417 | - public function show_notices() { |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * Clears all admin notices |
|
| 341 | + * |
|
| 342 | + * @access public |
|
| 343 | + * @since 1.0.19 |
|
| 344 | + */ |
|
| 345 | + public function clear_notices() { |
|
| 346 | + delete_option( 'wpinv_admin_notices' ); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * Saves a new admin notice |
|
| 351 | + * |
|
| 352 | + * @access public |
|
| 353 | + * @since 1.0.19 |
|
| 354 | + */ |
|
| 355 | + public function save_notice( $type, $message ) { |
|
| 356 | + $notices = $this->get_notices(); |
|
| 357 | + |
|
| 358 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 359 | + $notices[ $type ] = array(); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + $notices[ $type ][] = $message; |
|
| 363 | + |
|
| 364 | + update_option( 'wpinv_admin_notices', $notices ); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Displays a success notice |
|
| 369 | + * |
|
| 370 | + * @param string $msg The message to qeue. |
|
| 371 | + * @access public |
|
| 372 | + * @since 1.0.19 |
|
| 373 | + */ |
|
| 374 | + public function show_success( $msg ) { |
|
| 375 | + $this->save_notice( 'success', $msg ); |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * Displays a error notice |
|
| 380 | + * |
|
| 381 | + * @access public |
|
| 382 | + * @param string $msg The message to qeue. |
|
| 383 | + * @since 1.0.19 |
|
| 384 | + */ |
|
| 385 | + public function show_error( $msg ) { |
|
| 386 | + $this->save_notice( 'error', $msg ); |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * Displays a warning notice |
|
| 391 | + * |
|
| 392 | + * @access public |
|
| 393 | + * @param string $msg The message to qeue. |
|
| 394 | + * @since 1.0.19 |
|
| 395 | + */ |
|
| 396 | + public function show_warning( $msg ) { |
|
| 397 | + $this->save_notice( 'warning', $msg ); |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * Displays a info notice |
|
| 402 | + * |
|
| 403 | + * @access public |
|
| 404 | + * @param string $msg The message to qeue. |
|
| 405 | + * @since 1.0.19 |
|
| 406 | + */ |
|
| 407 | + public function show_info( $msg ) { |
|
| 408 | + $this->save_notice( 'info', $msg ); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * Show notices |
|
| 413 | + * |
|
| 414 | + * @access public |
|
| 415 | + * @since 1.0.19 |
|
| 416 | + */ |
|
| 417 | + public function show_notices() { |
|
| 418 | 418 | |
| 419 | 419 | $notices = $this->get_notices(); |
| 420 | 420 | $this->clear_notices(); |
| 421 | 421 | |
| 422 | - foreach ( $notices as $type => $messages ) { |
|
| 422 | + foreach ( $notices as $type => $messages ) { |
|
| 423 | 423 | |
| 424 | - if ( ! is_array( $messages ) ) { |
|
| 425 | - continue; |
|
| 426 | - } |
|
| 424 | + if ( ! is_array( $messages ) ) { |
|
| 425 | + continue; |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | 428 | $type = sanitize_key( $type ); |
| 429 | - foreach ( $messages as $message ) { |
|
| 429 | + foreach ( $messages as $message ) { |
|
| 430 | 430 | $message = wp_kses_post( $message ); |
| 431 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
| 431 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - } |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * The main admin class. |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * Class constructor. |
| 32 | 32 | */ |
| 33 | - public function __construct(){ |
|
| 33 | + public function __construct() { |
|
| 34 | 34 | |
| 35 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
| 36 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
| 35 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
| 36 | + $this->admin_url = plugins_url('/', __FILE__); |
|
| 37 | 37 | |
| 38 | - if ( is_admin() ) { |
|
| 38 | + if (is_admin()) { |
|
| 39 | 39 | $this->init_admin_hooks(); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | */ |
| 48 | 48 | private function init_admin_hooks() { |
| 49 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
|
| 50 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
| 51 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
| 52 | - add_action( 'admin_init', array( $this, 'activation_redirect') ); |
|
| 53 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
|
| 54 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 55 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 56 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 57 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 49 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts')); |
|
| 50 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
| 51 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
| 52 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
| 53 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
| 54 | + add_action('admin_notices', array($this, 'show_notices')); |
|
| 55 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
| 56 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
| 57 | + do_action('getpaid_init_admin_hooks', $this); |
|
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
@@ -65,49 +65,49 @@ discard block |
||
| 65 | 65 | public function enqeue_scripts() { |
| 66 | 66 | global $current_screen, $pagenow; |
| 67 | 67 | |
| 68 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 68 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
| 69 | 69 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
| 70 | 70 | |
| 71 | - if ( ! empty( $current_screen->post_type ) ) { |
|
| 71 | + if (!empty($current_screen->post_type)) { |
|
| 72 | 72 | $page = $current_screen->post_type; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // General styles. |
| 76 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
| 76 | + if (false !== stripos($page, 'wpi')) { |
|
| 77 | 77 | |
| 78 | 78 | // Styles. |
| 79 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
| 80 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
| 81 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
| 82 | - wp_enqueue_style( 'wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 83 | - wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' ); |
|
| 79 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
| 80 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
| 81 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
| 82 | + wp_enqueue_style('wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 83 | + wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16'); |
|
| 84 | 84 | |
| 85 | 85 | // Scripts. |
| 86 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true ); |
|
| 87 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 86 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true); |
|
| 87 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
| 88 | 88 | |
| 89 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
| 90 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ), $version ); |
|
| 91 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
| 89 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
| 90 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version); |
|
| 91 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
| 92 | 92 | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Payment form scripts. |
| 96 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 96 | + if ('wpi_payment_form' == $page && $editing) { |
|
| 97 | 97 | $this->load_payment_form_scripts(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 101 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 102 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 100 | + if ($page == 'wpinv-subscriptions') { |
|
| 101 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
| 102 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( $page == 'wpinv-reports' ) { |
|
| 106 | - wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
| 105 | + if ($page == 'wpinv-reports') { |
|
| 106 | + wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7'); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 110 | - wp_enqueue_script( 'postbox' ); |
|
| 109 | + if ($page == 'wpinv-subscriptions') { |
|
| 110 | + wp_enqueue_script('postbox'); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | } |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | global $post; |
| 121 | 121 | |
| 122 | 122 | $i18n = array( |
| 123 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 124 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
| 125 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
| 126 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
| 127 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
| 128 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
| 129 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
| 123 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 124 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
| 125 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
| 126 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
| 127 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
| 128 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
| 129 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
| 130 | 130 | 'tax' => wpinv_tax_amount(), |
| 131 | 131 | 'discount' => 0, |
| 132 | 132 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -134,35 +134,35 @@ discard block |
||
| 134 | 134 | 'thousand_sep' => wpinv_thousands_separator(), |
| 135 | 135 | 'decimal_sep' => wpinv_decimal_separator(), |
| 136 | 136 | 'decimals' => wpinv_decimals(), |
| 137 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
| 138 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
| 139 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
| 140 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
| 141 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
| 142 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
| 143 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
| 144 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
| 145 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
| 146 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
| 147 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
| 148 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
| 149 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
| 150 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
| 151 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
| 152 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
| 137 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
| 138 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
| 139 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
| 140 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
| 141 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
| 142 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
| 143 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
| 144 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
| 145 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
| 146 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
| 147 | + 'action_edit' => __('Edit', 'invoicing'), |
|
| 148 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
| 149 | + 'item_description' => __('Item Description', 'invoicing'), |
|
| 150 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
| 151 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
| 152 | + 'searching' => __('Searching', 'invoicing'), |
|
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 155 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
| 156 | 156 | |
| 157 | - $invoice = new WPInv_Invoice( $post ); |
|
| 157 | + $invoice = new WPInv_Invoice($post); |
|
| 158 | 158 | $i18n['save_invoice'] = sprintf( |
| 159 | - __( 'Save %s', 'invoicing' ), |
|
| 160 | - ucfirst( $invoice->get_type() ) |
|
| 159 | + __('Save %s', 'invoicing'), |
|
| 160 | + ucfirst($invoice->get_type()) |
|
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | 163 | $i18n['invoice_description'] = sprintf( |
| 164 | - __( '%s Description', 'invoicing' ), |
|
| 165 | - ucfirst( $invoice->get_type() ) |
|
| 164 | + __('%s Description', 'invoicing'), |
|
| 165 | + ucfirst($invoice->get_type()) |
|
| 166 | 166 | ); |
| 167 | 167 | |
| 168 | 168 | } |
@@ -176,30 +176,30 @@ discard block |
||
| 176 | 176 | protected function load_payment_form_scripts() { |
| 177 | 177 | global $post; |
| 178 | 178 | |
| 179 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
| 180 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 181 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 179 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
| 180 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
| 181 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
| 182 | 182 | |
| 183 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 184 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 183 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
| 184 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
| 185 | 185 | |
| 186 | 186 | wp_localize_script( |
| 187 | 187 | 'wpinv-admin-payment-form-script', |
| 188 | 188 | 'wpinvPaymentFormAdmin', |
| 189 | 189 | array( |
| 190 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 191 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 190 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
| 191 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
| 192 | 192 | 'currency' => wpinv_currency_symbol(), |
| 193 | 193 | 'position' => wpinv_currency_position(), |
| 194 | 194 | 'decimals' => (int) wpinv_decimals(), |
| 195 | 195 | 'thousands_sep' => wpinv_thousands_separator(), |
| 196 | 196 | 'decimals_sep' => wpinv_decimal_separator(), |
| 197 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 197 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
| 198 | 198 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
| 199 | 199 | ) |
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
| 202 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -210,25 +210,25 @@ discard block |
||
| 210 | 210 | * @return string |
| 211 | 211 | * |
| 212 | 212 | */ |
| 213 | - public function admin_body_class( $classes ) { |
|
| 213 | + public function admin_body_class($classes) { |
|
| 214 | 214 | global $pagenow, $post, $current_screen; |
| 215 | 215 | |
| 216 | 216 | |
| 217 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 217 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
| 218 | 218 | |
| 219 | - if ( ! empty( $current_screen->post_type ) ) { |
|
| 219 | + if (!empty($current_screen->post_type)) { |
|
| 220 | 220 | $page = $current_screen->post_type; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
| 224 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
| 223 | + if (false !== stripos($page, 'wpi')) { |
|
| 224 | + $classes .= ' wpi-' . sanitize_key($page); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
| 227 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
| 228 | 228 | $classes .= ' wpinv-cpt wpinv'; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 231 | + if (getpaid_is_invoice_post_type($page)) { |
|
| 232 | 232 | $classes .= ' getpaid-is-invoice-cpt'; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -238,19 +238,19 @@ discard block |
||
| 238 | 238 | /** |
| 239 | 239 | * Maybe show the AyeCode Connect Notice. |
| 240 | 240 | */ |
| 241 | - public function init_ayecode_connect_helper(){ |
|
| 241 | + public function init_ayecode_connect_helper() { |
|
| 242 | 242 | |
| 243 | 243 | new AyeCode_Connect_Helper( |
| 244 | 244 | array( |
| 245 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 246 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 247 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 248 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 249 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 250 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 251 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 245 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
| 246 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
| 247 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
| 248 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
| 249 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
| 250 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
| 251 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
| 252 | 252 | ), |
| 253 | - array( 'wpi-addons' ) |
|
| 253 | + array('wpi-addons') |
|
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | 256 | } |
@@ -261,19 +261,19 @@ discard block |
||
| 261 | 261 | public function activation_redirect() { |
| 262 | 262 | |
| 263 | 263 | // Bail if no activation redirect. |
| 264 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
| 264 | + if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) { |
|
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // Delete the redirect transient. |
| 269 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 269 | + delete_transient('_wpinv_activation_redirect'); |
|
| 270 | 270 | |
| 271 | 271 | // Bail if activating from network, or bulk |
| 272 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 272 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 276 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 277 | 277 | exit; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | public function maybe_do_admin_action() { |
| 284 | 284 | |
| 285 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 286 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
| 287 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
| 285 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
| 286 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
| 287 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | } |
@@ -294,16 +294,16 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @param array $args |
| 296 | 296 | */ |
| 297 | - public function send_customer_invoice( $args ) { |
|
| 298 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 297 | + public function send_customer_invoice($args) { |
|
| 298 | + $sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id'])); |
|
| 299 | 299 | |
| 300 | - if ( $sent ) { |
|
| 301 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 300 | + if ($sent) { |
|
| 301 | + $this->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
| 302 | 302 | } else { |
| 303 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
| 303 | + $this->show_error(__('Could not sent the invoice to the customer', 'invoicing')); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 306 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
| 307 | 307 | exit; |
| 308 | 308 | } |
| 309 | 309 | |
@@ -312,16 +312,16 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @param array $args |
| 314 | 314 | */ |
| 315 | - public function send_customer_payment_reminder( $args ) { |
|
| 316 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 315 | + public function send_customer_payment_reminder($args) { |
|
| 316 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
| 317 | 317 | |
| 318 | - if ( $sent ) { |
|
| 319 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 318 | + if ($sent) { |
|
| 319 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
| 320 | 320 | } else { |
| 321 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 321 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 324 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
| 325 | 325 | exit; |
| 326 | 326 | } |
| 327 | 327 | |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | * @return array |
| 333 | 333 | */ |
| 334 | 334 | public function get_notices() { |
| 335 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
| 336 | - return is_array( $notices ) ? $notices : array(); |
|
| 335 | + $notices = get_option('wpinv_admin_notices'); |
|
| 336 | + return is_array($notices) ? $notices : array(); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @since 1.0.19 |
| 344 | 344 | */ |
| 345 | 345 | public function clear_notices() { |
| 346 | - delete_option( 'wpinv_admin_notices' ); |
|
| 346 | + delete_option('wpinv_admin_notices'); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -352,16 +352,16 @@ discard block |
||
| 352 | 352 | * @access public |
| 353 | 353 | * @since 1.0.19 |
| 354 | 354 | */ |
| 355 | - public function save_notice( $type, $message ) { |
|
| 355 | + public function save_notice($type, $message) { |
|
| 356 | 356 | $notices = $this->get_notices(); |
| 357 | 357 | |
| 358 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 359 | - $notices[ $type ] = array(); |
|
| 358 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
| 359 | + $notices[$type] = array(); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $notices[ $type ][] = $message; |
|
| 362 | + $notices[$type][] = $message; |
|
| 363 | 363 | |
| 364 | - update_option( 'wpinv_admin_notices', $notices ); |
|
| 364 | + update_option('wpinv_admin_notices', $notices); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | * @access public |
| 372 | 372 | * @since 1.0.19 |
| 373 | 373 | */ |
| 374 | - public function show_success( $msg ) { |
|
| 375 | - $this->save_notice( 'success', $msg ); |
|
| 374 | + public function show_success($msg) { |
|
| 375 | + $this->save_notice('success', $msg); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | /** |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | * @param string $msg The message to qeue. |
| 383 | 383 | * @since 1.0.19 |
| 384 | 384 | */ |
| 385 | - public function show_error( $msg ) { |
|
| 386 | - $this->save_notice( 'error', $msg ); |
|
| 385 | + public function show_error($msg) { |
|
| 386 | + $this->save_notice('error', $msg); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -393,8 +393,8 @@ discard block |
||
| 393 | 393 | * @param string $msg The message to qeue. |
| 394 | 394 | * @since 1.0.19 |
| 395 | 395 | */ |
| 396 | - public function show_warning( $msg ) { |
|
| 397 | - $this->save_notice( 'warning', $msg ); |
|
| 396 | + public function show_warning($msg) { |
|
| 397 | + $this->save_notice('warning', $msg); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * @param string $msg The message to qeue. |
| 405 | 405 | * @since 1.0.19 |
| 406 | 406 | */ |
| 407 | - public function show_info( $msg ) { |
|
| 408 | - $this->save_notice( 'info', $msg ); |
|
| 407 | + public function show_info($msg) { |
|
| 408 | + $this->save_notice('info', $msg); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -419,15 +419,15 @@ discard block |
||
| 419 | 419 | $notices = $this->get_notices(); |
| 420 | 420 | $this->clear_notices(); |
| 421 | 421 | |
| 422 | - foreach ( $notices as $type => $messages ) { |
|
| 422 | + foreach ($notices as $type => $messages) { |
|
| 423 | 423 | |
| 424 | - if ( ! is_array( $messages ) ) { |
|
| 424 | + if (!is_array($messages)) { |
|
| 425 | 425 | continue; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - $type = sanitize_key( $type ); |
|
| 429 | - foreach ( $messages as $message ) { |
|
| 430 | - $message = wp_kses_post( $message ); |
|
| 428 | + $type = sanitize_key($type); |
|
| 429 | + foreach ($messages as $message) { |
|
| 430 | + $message = wp_kses_post($message); |
|
| 431 | 431 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
| 432 | 432 | } |
| 433 | 433 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param WP_Post $post |
| 23 | 23 | */ |
| 24 | - public static function output( $post ) { |
|
| 24 | + public static function output($post) { |
|
| 25 | 25 | |
| 26 | 26 | // Prepare the item. |
| 27 | - $item = new WPInv_Item( $post ); |
|
| 27 | + $item = new WPInv_Item($post); |
|
| 28 | 28 | |
| 29 | 29 | // Nonce field. |
| 30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
| 31 | 31 | |
| 32 | 32 | // Set the currency position. |
| 33 | 33 | $position = wpinv_currency_position(); |
| 34 | 34 | |
| 35 | - if ( $position == 'left_space' ) { |
|
| 35 | + if ($position == 'left_space') { |
|
| 36 | 36 | $position = 'left'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( $position == 'right_space' ) { |
|
| 39 | + if ($position == 'right_space') { |
|
| 40 | 40 | $position = 'right'; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | ?> |
| 44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
| 44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
| 45 | 45 | <style> |
| 46 | 46 | #poststuff .input-group-text, |
| 47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | </style> |
| 56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px; max-width: 820px;'> |
| 57 | 57 | |
| 58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
| 58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
| 59 | 59 | <div class="form-group row"> |
| 60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label> |
|
| 60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label> |
|
| 61 | 61 | <div class="col-sm-8"> |
| 62 | 62 | <div class="row"> |
| 63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
| 64 | 64 | <div class="input-group input-group-sm"> |
| 65 | - <?php if( 'left' == $position ) : ?> |
|
| 65 | + <?php if ('left' == $position) : ?> |
|
| 66 | 66 | <div class="input-group-prepend"> |
| 67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 68 | 68 | </div> |
| 69 | 69 | <?php endif; ?> |
| 70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
| 70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
| 71 | 71 | |
| 72 | - <?php if( 'left' != $position ) : ?> |
|
| 72 | + <?php if ('left' != $position) : ?> |
|
| 73 | 73 | <div class="input-group-append"> |
| 74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 75 | 75 | </div> |
@@ -83,25 +83,25 @@ discard block |
||
| 83 | 83 | array( |
| 84 | 84 | 'id' => 'wpinv_recurring_interval', |
| 85 | 85 | 'name' => 'wpinv_recurring_interval', |
| 86 | - 'label' => __( 'Interval', 'invoicing' ), |
|
| 87 | - 'placeholder' => __( 'Select Interval', 'invoicing' ), |
|
| 88 | - 'value' => $item->get_recurring_interval( 'edit' ), |
|
| 86 | + 'label' => __('Interval', 'invoicing'), |
|
| 87 | + 'placeholder' => __('Select Interval', 'invoicing'), |
|
| 88 | + 'value' => $item->get_recurring_interval('edit'), |
|
| 89 | 89 | 'select2' => true, |
| 90 | 90 | 'data-allow-clear' => 'false', |
| 91 | 91 | 'options' => array( |
| 92 | - '1' => __( 'every', 'invoicing' ), |
|
| 93 | - '2' => __( 'every 2nd', 'invoicing' ), |
|
| 94 | - '3' => __( 'every 3rd', 'invoicing' ), |
|
| 95 | - '4' => __( 'every 4th', 'invoicing' ), |
|
| 96 | - '5' => __( 'every 5th', 'invoicing' ), |
|
| 97 | - '6' => __( 'every 6th', 'invoicing' ), |
|
| 98 | - '8' => __( 'every 8th', 'invoicing' ), |
|
| 99 | - '9' => __( 'every 9th', 'invoicing' ), |
|
| 100 | - '10' => __( 'every 10th', 'invoicing' ), |
|
| 101 | - '11' => __( 'every 11th', 'invoicing' ), |
|
| 102 | - '12' => __( 'every 12th', 'invoicing' ), |
|
| 103 | - '13' => __( 'every 13th', 'invoicing' ), |
|
| 104 | - '14' => __( 'every 14th', 'invoicing' ), |
|
| 92 | + '1' => __('every', 'invoicing'), |
|
| 93 | + '2' => __('every 2nd', 'invoicing'), |
|
| 94 | + '3' => __('every 3rd', 'invoicing'), |
|
| 95 | + '4' => __('every 4th', 'invoicing'), |
|
| 96 | + '5' => __('every 5th', 'invoicing'), |
|
| 97 | + '6' => __('every 6th', 'invoicing'), |
|
| 98 | + '8' => __('every 8th', 'invoicing'), |
|
| 99 | + '9' => __('every 9th', 'invoicing'), |
|
| 100 | + '10' => __('every 10th', 'invoicing'), |
|
| 101 | + '11' => __('every 11th', 'invoicing'), |
|
| 102 | + '12' => __('every 12th', 'invoicing'), |
|
| 103 | + '13' => __('every 13th', 'invoicing'), |
|
| 104 | + '14' => __('every 14th', 'invoicing'), |
|
| 105 | 105 | ) |
| 106 | 106 | ) |
| 107 | 107 | ); |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | array( |
| 114 | 114 | 'id' => 'wpinv_recurring_period', |
| 115 | 115 | 'name' => 'wpinv_recurring_period', |
| 116 | - 'label' => __( 'Period', 'invoicing' ), |
|
| 117 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
| 118 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
| 116 | + 'label' => __('Period', 'invoicing'), |
|
| 117 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
| 118 | + 'value' => $item->get_recurring_period('edit'), |
|
| 119 | 119 | 'select2' => true, |
| 120 | 120 | 'data-allow-clear' => 'false', |
| 121 | 121 | 'options' => array( |
| 122 | - 'D' => __( 'day', 'invoicing' ), |
|
| 123 | - 'W' => __( 'week', 'invoicing' ), |
|
| 124 | - 'M' => __( 'month', 'invoicing' ), |
|
| 125 | - 'Y' => __( 'year', 'invoicing' ), |
|
| 122 | + 'D' => __('day', 'invoicing'), |
|
| 123 | + 'W' => __('week', 'invoicing'), |
|
| 124 | + 'M' => __('month', 'invoicing'), |
|
| 125 | + 'Y' => __('year', 'invoicing'), |
|
| 126 | 126 | ) |
| 127 | 127 | ) |
| 128 | 128 | ); |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | <?php |
| 135 | 135 | |
| 136 | 136 | // Dynamic pricing. |
| 137 | - if( $item->supports_dynamic_pricing() ) { |
|
| 137 | + if ($item->supports_dynamic_pricing()) { |
|
| 138 | 138 | |
| 139 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
| 139 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
| 140 | 140 | |
| 141 | 141 | // NYP toggle. |
| 142 | 142 | echo aui()->input( |
@@ -144,31 +144,31 @@ discard block |
||
| 144 | 144 | 'id' => 'wpinv_name_your_price', |
| 145 | 145 | 'name' => 'wpinv_name_your_price', |
| 146 | 146 | 'type' => 'checkbox', |
| 147 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
| 147 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
| 148 | 148 | 'value' => '1', |
| 149 | 149 | 'checked' => $item->user_can_set_their_price(), |
| 150 | 150 | 'no_wrap' => true, |
| 151 | 151 | ) |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
| 154 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
| 155 | 155 | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Subscriptions. |
| 159 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
| 159 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
| 160 | 160 | echo aui()->input( |
| 161 | 161 | array( |
| 162 | 162 | 'id' => 'wpinv_is_recurring', |
| 163 | 163 | 'name' => 'wpinv_is_recurring', |
| 164 | 164 | 'type' => 'checkbox', |
| 165 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
| 165 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
| 166 | 166 | 'value' => '1', |
| 167 | 167 | 'checked' => $item->is_recurring(), |
| 168 | 168 | 'no_wrap' => true, |
| 169 | 169 | ) |
| 170 | 170 | ); |
| 171 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
| 171 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
| 172 | 172 | |
| 173 | 173 | ?> |
| 174 | 174 | <div class="wpinv_show_if_recurring"> |
@@ -178,30 +178,30 @@ discard block |
||
| 178 | 178 | </div> |
| 179 | 179 | </div> |
| 180 | 180 | <div class="col-sm-1 pt-2 pl-0"> |
| 181 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
| 181 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
| 182 | 182 | </div> |
| 183 | 183 | </div> |
| 184 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
| 184 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
| 185 | 185 | |
| 186 | - <?php if( $item->supports_dynamic_pricing() ) : ?> |
|
| 187 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
| 186 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
| 187 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
| 188 | 188 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
| 189 | 189 | |
| 190 | 190 | <div class="form-group row"> |
| 191 | 191 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
| 192 | - <?php _e( 'Minimum Price', 'invoicing' );?> |
|
| 192 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
| 193 | 193 | </label> |
| 194 | 194 | <div class="col-sm-8"> |
| 195 | 195 | <div class="input-group input-group-sm"> |
| 196 | - <?php if( 'left' == $position ) : ?> |
|
| 196 | + <?php if ('left' == $position) : ?> |
|
| 197 | 197 | <div class="input-group-prepend"> |
| 198 | 198 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 199 | 199 | </div> |
| 200 | 200 | <?php endif; ?> |
| 201 | 201 | |
| 202 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
| 202 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
| 203 | 203 | |
| 204 | - <?php if( 'left' != $position ) : ?> |
|
| 204 | + <?php if ('left' != $position) : ?> |
|
| 205 | 205 | <div class="input-group-append"> |
| 206 | 206 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 207 | 207 | </div> |
@@ -210,45 +210,45 @@ discard block |
||
| 210 | 210 | </div> |
| 211 | 211 | |
| 212 | 212 | <div class="col-sm-1 pt-2 pl-0"> |
| 213 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
| 213 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
| 214 | 214 | </div> |
| 215 | 215 | </div> |
| 216 | 216 | |
| 217 | 217 | </div> |
| 218 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
| 218 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
| 219 | 219 | <?php endif; ?> |
| 220 | 220 | |
| 221 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
| 221 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
| 222 | 222 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
| 223 | 223 | |
| 224 | 224 | <div class="form-group row"> |
| 225 | 225 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
| 226 | - <?php _e( 'Maximum Renewals', 'invoicing' );?> |
|
| 226 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
| 227 | 227 | </label> |
| 228 | 228 | <div class="col-sm-8"> |
| 229 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
| 229 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
| 230 | 230 | </div> |
| 231 | 231 | <div class="col-sm-1 pt-2 pl-0"> |
| 232 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
| 232 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
| 233 | 233 | </div> |
| 234 | 234 | </div> |
| 235 | 235 | |
| 236 | 236 | </div> |
| 237 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
| 237 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
| 238 | 238 | |
| 239 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
| 239 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
| 240 | 240 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
| 241 | 241 | |
| 242 | 242 | <div class="form-group row"> |
| 243 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label> |
|
| 243 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label> |
|
| 244 | 244 | |
| 245 | 245 | <div class="col-sm-8"> |
| 246 | 246 | <div class="row"> |
| 247 | 247 | <div class="col-sm-6"> |
| 248 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?> |
|
| 248 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
| 249 | 249 | |
| 250 | 250 | <div> |
| 251 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
| 251 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
| 252 | 252 | </div> |
| 253 | 253 | </div> |
| 254 | 254 | <div class="col-sm-6"> |
@@ -257,17 +257,17 @@ discard block |
||
| 257 | 257 | array( |
| 258 | 258 | 'id' => 'wpinv_trial_period', |
| 259 | 259 | 'name' => 'wpinv_trial_period', |
| 260 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
| 261 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
| 262 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
| 260 | + 'label' => __('Trial Period', 'invoicing'), |
|
| 261 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
| 262 | + 'value' => $item->get_recurring_period('edit'), |
|
| 263 | 263 | 'select2' => true, |
| 264 | 264 | 'data-allow-clear' => 'false', |
| 265 | 265 | 'no_wrap' => true, |
| 266 | 266 | 'options' => array( |
| 267 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
| 268 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
| 269 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
| 270 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
| 267 | + 'D' => __('day(s)', 'invoicing'), |
|
| 268 | + 'W' => __('week(s)', 'invoicing'), |
|
| 269 | + 'M' => __('month(s)', 'invoicing'), |
|
| 270 | + 'Y' => __('year(s)', 'invoicing'), |
|
| 271 | 271 | ) |
| 272 | 272 | ) |
| 273 | 273 | ); |
@@ -278,15 +278,15 @@ discard block |
||
| 278 | 278 | </div> |
| 279 | 279 | |
| 280 | 280 | <div class="col-sm-1 pt-2 pl-0"> |
| 281 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
| 281 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
| 282 | 282 | </div> |
| 283 | 283 | |
| 284 | 284 | </div> |
| 285 | 285 | |
| 286 | 286 | </div> |
| 287 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
| 287 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
| 288 | 288 | |
| 289 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
| 289 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
| 290 | 290 | </div> |
| 291 | 291 | <?php |
| 292 | 292 | |
@@ -297,31 +297,31 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @param int $post_id |
| 299 | 299 | */ |
| 300 | - public static function save( $post_id ) { |
|
| 300 | + public static function save($post_id) { |
|
| 301 | 301 | |
| 302 | 302 | // Prepare the item. |
| 303 | - $item = new WPInv_Item( $post_id ); |
|
| 303 | + $item = new WPInv_Item($post_id); |
|
| 304 | 304 | |
| 305 | 305 | // Load new data. |
| 306 | 306 | $item->set_props( |
| 307 | 307 | array( |
| 308 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
| 309 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
| 310 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
| 311 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
| 312 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
| 313 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
| 314 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
| 315 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
| 316 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
| 317 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
| 318 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
| 319 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
| 320 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
| 308 | + 'price' => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null, |
|
| 309 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
| 310 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
| 311 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
| 312 | + 'is_dynamic_pricing' => isset($_POST['wpinv_name_your_price']), |
|
| 313 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
| 314 | + 'is_recurring' => isset($_POST['wpinv_is_recurring']), |
|
| 315 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
| 316 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
| 317 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
| 318 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
| 319 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
| 320 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
| 321 | 321 | ) |
| 322 | 322 | ); |
| 323 | 323 | |
| 324 | 324 | $item->save(); |
| 325 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
| 325 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
| 326 | 326 | } |
| 327 | 327 | } |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
| 8 | -function wpinv_discount_custom_column( $column ) { |
|
| 7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
| 8 | +function wpinv_discount_custom_column($column) { |
|
| 9 | 9 | global $post; |
| 10 | 10 | |
| 11 | - $discount = new WPInv_Discount( $post ); |
|
| 11 | + $discount = new WPInv_Discount($post); |
|
| 12 | 12 | |
| 13 | - switch ( $column ) { |
|
| 13 | + switch ($column) { |
|
| 14 | 14 | case 'code' : |
| 15 | 15 | echo $discount->get_code(); |
| 16 | 16 | break; |
@@ -21,37 +21,37 @@ discard block |
||
| 21 | 21 | echo $discount->get_usage(); |
| 22 | 22 | break; |
| 23 | 23 | case 'start_date' : |
| 24 | - echo getpaid_format_date_value( $discount->get_start_date() ); |
|
| 24 | + echo getpaid_format_date_value($discount->get_start_date()); |
|
| 25 | 25 | break; |
| 26 | 26 | case 'expiry_date' : |
| 27 | - echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ); |
|
| 27 | + echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')); |
|
| 28 | 28 | break; |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
| 33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
| 34 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
| 32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
| 33 | +function wpinv_post_row_actions($actions, $post) { |
|
| 34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
| 35 | 35 | |
| 36 | - if ( $post_type == 'wpi_invoice' ) { |
|
| 36 | + if ($post_type == 'wpi_invoice') { |
|
| 37 | 37 | $actions = array(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if ( $post_type == 'wpi_discount' ) { |
|
| 41 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
| 40 | + if ($post_type == 'wpi_discount') { |
|
| 41 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | return $actions; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
| 48 | - $row_actions = array(); |
|
| 49 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
| 50 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
| 47 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
| 48 | + $row_actions = array(); |
|
| 49 | + $edit_link = get_edit_post_link($discount->ID); |
|
| 50 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
| 51 | 51 | |
| 52 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
| 52 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
| 53 | 53 | |
| 54 | - $url = esc_url( |
|
| 54 | + $url = esc_url( |
|
| 55 | 55 | wp_nonce_url( |
| 56 | 56 | add_query_arg( |
| 57 | 57 | array( |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | 'getpaid-nonce' |
| 64 | 64 | ) |
| 65 | 65 | ); |
| 66 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
| 67 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
| 66 | + $anchor = __('Deactivate', 'invoicing'); |
|
| 67 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
| 68 | 68 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 69 | 69 | |
| 70 | - } else if( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
| 70 | + } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
| 71 | 71 | |
| 72 | - $url = esc_url( |
|
| 72 | + $url = esc_url( |
|
| 73 | 73 | wp_nonce_url( |
| 74 | 74 | add_query_arg( |
| 75 | 75 | array( |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | 'getpaid-nonce' |
| 82 | 82 | ) |
| 83 | 83 | ); |
| 84 | - $anchor = __( 'Activate', 'invoicing' ); |
|
| 85 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 84 | + $anchor = __('Activate', 'invoicing'); |
|
| 85 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
| 86 | 86 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 87 | 87 | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $url = esc_url( |
|
| 90 | + $url = esc_url( |
|
| 91 | 91 | wp_nonce_url( |
| 92 | 92 | add_query_arg( |
| 93 | 93 | array( |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | 'getpaid-nonce' |
| 100 | 100 | ) |
| 101 | 101 | ); |
| 102 | - $anchor = __( 'Delete', 'invoicing' ); |
|
| 103 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
| 102 | + $anchor = __('Delete', 'invoicing'); |
|
| 103 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
| 104 | 104 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 105 | 105 | |
| 106 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
| 106 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
| 107 | 107 | |
| 108 | 108 | return $row_actions; |
| 109 | 109 | } |
@@ -111,68 +111,68 @@ discard block |
||
| 111 | 111 | function wpinv_restrict_manage_posts() { |
| 112 | 112 | global $typenow; |
| 113 | 113 | |
| 114 | - if( 'wpi_discount' == $typenow ) { |
|
| 114 | + if ('wpi_discount' == $typenow) { |
|
| 115 | 115 | wpinv_discount_filters(); |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
| 118 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
| 119 | 119 | |
| 120 | 120 | function wpinv_discount_filters() { |
| 121 | 121 | |
| 122 | 122 | ?> |
| 123 | 123 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
| 124 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
| 124 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
| 125 | 125 | <?php |
| 126 | 126 | $types = wpinv_get_discount_types(); |
| 127 | 127 | |
| 128 | - foreach ( $types as $name => $type ) { |
|
| 129 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 128 | + foreach ($types as $name => $type) { |
|
| 129 | + echo '<option value="' . esc_attr($name) . '"'; |
|
| 130 | 130 | |
| 131 | - if ( isset( $_GET['discount_type'] ) ) |
|
| 132 | - selected( $name, $_GET['discount_type'] ); |
|
| 131 | + if (isset($_GET['discount_type'])) |
|
| 132 | + selected($name, $_GET['discount_type']); |
|
| 133 | 133 | |
| 134 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 134 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
| 135 | 135 | } |
| 136 | 136 | ?> |
| 137 | 137 | </select> |
| 138 | 138 | <?php |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | -function wpinv_request( $vars ) { |
|
| 141 | +function wpinv_request($vars) { |
|
| 142 | 142 | global $typenow, $wp_post_statuses; |
| 143 | 143 | |
| 144 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
| 145 | - if ( ! isset( $vars['post_status'] ) ) { |
|
| 146 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
| 144 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
| 145 | + if (!isset($vars['post_status'])) { |
|
| 146 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
| 147 | 147 | |
| 148 | - foreach ( $post_statuses as $status => $value ) { |
|
| 149 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
| 150 | - unset( $post_statuses[ $status ] ); |
|
| 148 | + foreach ($post_statuses as $status => $value) { |
|
| 149 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
| 150 | + unset($post_statuses[$status]); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
| 154 | + $vars['post_status'] = array_keys($post_statuses); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - } else if ( 'wpi_discount' == $typenow ) { |
|
| 158 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 157 | + } else if ('wpi_discount' == $typenow) { |
|
| 158 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 159 | 159 | // Filter vat rule type |
| 160 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
| 160 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
| 161 | 161 | $meta_query[] = array( |
| 162 | 162 | 'key' => '_wpi_discount_type', |
| 163 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
| 163 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
| 164 | 164 | 'compare' => '=' |
| 165 | 165 | ); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ( !empty( $meta_query ) ) { |
|
| 168 | + if (!empty($meta_query)) { |
|
| 169 | 169 | $vars['meta_query'] = $meta_query; |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return $vars; |
| 174 | 174 | } |
| 175 | -add_filter( 'request', 'wpinv_request' ); |
|
| 175 | +add_filter('request', 'wpinv_request'); |
|
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * Create a page and store the ID in an option. |
@@ -184,19 +184,19 @@ discard block |
||
| 184 | 184 | * @param int $post_parent (default: 0) Parent for the new page |
| 185 | 185 | * @return int page ID |
| 186 | 186 | */ |
| 187 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
| 187 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
| 188 | 188 | global $wpdb; |
| 189 | 189 | |
| 190 | - $option_value = wpinv_get_option( $option ); |
|
| 190 | + $option_value = wpinv_get_option($option); |
|
| 191 | 191 | |
| 192 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
| 193 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
| 192 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
| 193 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
| 194 | 194 | // Valid page is already in place |
| 195 | 195 | return $page_object->ID; |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if(!empty($post_parent)){ |
|
| 199 | + if (!empty($post_parent)) { |
|
| 200 | 200 | $page = get_page_by_path($post_parent); |
| 201 | 201 | if ($page) { |
| 202 | 202 | $post_parent = $page->ID; |
@@ -205,40 +205,40 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ( strlen( $page_content ) > 0 ) { |
|
| 208 | + if (strlen($page_content) > 0) { |
|
| 209 | 209 | // Search for an existing page with the specified page content (typically a shortcode) |
| 210 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
| 210 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
| 211 | 211 | } else { |
| 212 | 212 | // Search for an existing page with the specified page slug |
| 213 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
| 213 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
| 216 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
| 217 | 217 | |
| 218 | - if ( $valid_page_found ) { |
|
| 219 | - if ( $option ) { |
|
| 220 | - wpinv_update_option( $option, $valid_page_found ); |
|
| 218 | + if ($valid_page_found) { |
|
| 219 | + if ($option) { |
|
| 220 | + wpinv_update_option($option, $valid_page_found); |
|
| 221 | 221 | } |
| 222 | 222 | return $valid_page_found; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Search for a matching valid trashed page |
| 226 | - if ( strlen( $page_content ) > 0 ) { |
|
| 226 | + if (strlen($page_content) > 0) { |
|
| 227 | 227 | // Search for an existing page with the specified page content (typically a shortcode) |
| 228 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
| 228 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
| 229 | 229 | } else { |
| 230 | 230 | // Search for an existing page with the specified page slug |
| 231 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
| 231 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( $trashed_page_found ) { |
|
| 234 | + if ($trashed_page_found) { |
|
| 235 | 235 | $page_id = $trashed_page_found; |
| 236 | 236 | $page_data = array( |
| 237 | 237 | 'ID' => $page_id, |
| 238 | 238 | 'post_status' => 'publish', |
| 239 | 239 | 'post_parent' => $post_parent, |
| 240 | 240 | ); |
| 241 | - wp_update_post( $page_data ); |
|
| 241 | + wp_update_post($page_data); |
|
| 242 | 242 | } else { |
| 243 | 243 | $page_data = array( |
| 244 | 244 | 'post_status' => 'publish', |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | 'post_parent' => $post_parent, |
| 251 | 251 | 'comment_status' => 'closed', |
| 252 | 252 | ); |
| 253 | - $page_id = wp_insert_post( $page_data ); |
|
| 253 | + $page_id = wp_insert_post($page_data); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if ( $option ) { |
|
| 257 | - wpinv_update_option( $option, (int)$page_id ); |
|
| 256 | + if ($option) { |
|
| 257 | + wpinv_update_option($option, (int) $page_id); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return $page_id; |
@@ -13,233 +13,233 @@ |
||
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | - 'id' => array( |
|
| 17 | - 'description' => __( 'Unique identifier for the item.', 'invoicing' ), |
|
| 18 | - 'type' => 'integer', |
|
| 19 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 20 | - 'readonly' => true, |
|
| 21 | - ), |
|
| 22 | - |
|
| 23 | - 'parent_id' => array( |
|
| 24 | - 'description' => __( 'Parent item ID.', 'invoicing' ), |
|
| 25 | - 'type' => 'integer', |
|
| 26 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 27 | - 'default' => 0, |
|
| 28 | - ), |
|
| 29 | - |
|
| 30 | - 'status' => array( |
|
| 31 | - 'description' => __( 'A named status for the item.', 'invoicing' ), |
|
| 32 | - 'type' => 'string', |
|
| 33 | - 'enum' => array( 'draft', 'pending', 'publish' ), |
|
| 34 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 35 | - 'default' => 'draft', |
|
| 36 | - ), |
|
| 37 | - |
|
| 38 | - 'version' => array( |
|
| 39 | - 'description' => __( 'Plugin version when the item was created.', 'invoicing' ), |
|
| 40 | - 'type' => 'string', |
|
| 41 | - 'context' => array( 'view', 'edit' ), |
|
| 42 | - 'readonly' => true, |
|
| 43 | - ), |
|
| 44 | - |
|
| 45 | - 'date_created' => array( |
|
| 46 | - 'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ), |
|
| 47 | - 'type' => 'string', |
|
| 48 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 49 | - ), |
|
| 50 | - |
|
| 51 | - 'date_created_gmt' => array( |
|
| 52 | - 'description' => __( 'The GMT date the item was created.', 'invoicing' ), |
|
| 53 | - 'type' => 'string', |
|
| 54 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 55 | - 'readonly' => true, |
|
| 56 | - ), |
|
| 57 | - |
|
| 58 | - 'date_modified' => array( |
|
| 59 | - 'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ), |
|
| 60 | - 'type' => 'string', |
|
| 61 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 62 | - 'readonly' => true, |
|
| 63 | - ), |
|
| 64 | - |
|
| 65 | - 'date_modified_gmt' => array( |
|
| 66 | - 'description' => __( 'The GMT date the item was last modified.', 'invoicing' ), |
|
| 67 | - 'type' => 'string', |
|
| 68 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 69 | - 'readonly' => true, |
|
| 70 | - ), |
|
| 71 | - |
|
| 72 | - 'name' => array( |
|
| 73 | - 'description' => __( "The item's name.", 'invoicing' ), |
|
| 74 | - 'type' => 'string', |
|
| 75 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 76 | - 'required' => true, |
|
| 77 | - ), |
|
| 78 | - |
|
| 79 | - 'description' => array( |
|
| 80 | - 'description' => __( "The item's description.", 'invoicing' ), |
|
| 81 | - 'type' => 'string', |
|
| 82 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 83 | - ), |
|
| 84 | - |
|
| 85 | - 'owner' => array( |
|
| 86 | - 'description' => __( 'The owner of the item (user id).', 'invoicing' ), |
|
| 87 | - 'type' => 'integer', |
|
| 88 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 89 | - ), |
|
| 90 | - |
|
| 91 | - 'price' => array( |
|
| 92 | - 'description' => __( 'The price of the item.', 'invoicing' ), |
|
| 93 | - 'type' => 'number', |
|
| 94 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 95 | - 'required' => true, |
|
| 96 | - ), |
|
| 97 | - |
|
| 98 | - 'the_price' => array( |
|
| 99 | - 'description' => __( 'The formatted price of the item.', 'invoicing' ), |
|
| 100 | - 'type' => 'string', |
|
| 101 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 102 | - 'readonly' => true, |
|
| 103 | - ), |
|
| 104 | - |
|
| 105 | - 'type' => array( |
|
| 106 | - 'description' => __( 'The item type.', 'invoicing' ), |
|
| 107 | - 'type' => 'string', |
|
| 108 | - 'enum' => wpinv_item_types(), |
|
| 109 | - 'default' => 'custom', |
|
| 110 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 111 | - ), |
|
| 112 | - |
|
| 113 | - 'vat_rule' => array( |
|
| 114 | - 'description' => __( 'VAT rule applied to the item.', 'invoicing' ), |
|
| 115 | - 'type' => 'string', |
|
| 116 | - 'enum' => array_keys( getpaid_tax()->get_rules() ), |
|
| 117 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 118 | - ), |
|
| 119 | - |
|
| 120 | - 'vat_class' => array( |
|
| 121 | - 'description' => __( 'VAT class for the item.', 'invoicing' ), |
|
| 122 | - 'type' => 'string', |
|
| 123 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 124 | - 'enum' => array_keys( getpaid_tax()->get_vat_groups() ), |
|
| 125 | - ), |
|
| 126 | - |
|
| 127 | - 'custom_id' => array( |
|
| 128 | - 'description' => __( 'Custom id for the item.', 'invoicing' ), |
|
| 129 | - 'type' => 'string', |
|
| 130 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 131 | - ), |
|
| 16 | + 'id' => array( |
|
| 17 | + 'description' => __( 'Unique identifier for the item.', 'invoicing' ), |
|
| 18 | + 'type' => 'integer', |
|
| 19 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 20 | + 'readonly' => true, |
|
| 21 | + ), |
|
| 22 | + |
|
| 23 | + 'parent_id' => array( |
|
| 24 | + 'description' => __( 'Parent item ID.', 'invoicing' ), |
|
| 25 | + 'type' => 'integer', |
|
| 26 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 27 | + 'default' => 0, |
|
| 28 | + ), |
|
| 29 | + |
|
| 30 | + 'status' => array( |
|
| 31 | + 'description' => __( 'A named status for the item.', 'invoicing' ), |
|
| 32 | + 'type' => 'string', |
|
| 33 | + 'enum' => array( 'draft', 'pending', 'publish' ), |
|
| 34 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 35 | + 'default' => 'draft', |
|
| 36 | + ), |
|
| 37 | + |
|
| 38 | + 'version' => array( |
|
| 39 | + 'description' => __( 'Plugin version when the item was created.', 'invoicing' ), |
|
| 40 | + 'type' => 'string', |
|
| 41 | + 'context' => array( 'view', 'edit' ), |
|
| 42 | + 'readonly' => true, |
|
| 43 | + ), |
|
| 44 | + |
|
| 45 | + 'date_created' => array( |
|
| 46 | + 'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ), |
|
| 47 | + 'type' => 'string', |
|
| 48 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 49 | + ), |
|
| 50 | + |
|
| 51 | + 'date_created_gmt' => array( |
|
| 52 | + 'description' => __( 'The GMT date the item was created.', 'invoicing' ), |
|
| 53 | + 'type' => 'string', |
|
| 54 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 55 | + 'readonly' => true, |
|
| 56 | + ), |
|
| 57 | + |
|
| 58 | + 'date_modified' => array( |
|
| 59 | + 'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ), |
|
| 60 | + 'type' => 'string', |
|
| 61 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 62 | + 'readonly' => true, |
|
| 63 | + ), |
|
| 64 | + |
|
| 65 | + 'date_modified_gmt' => array( |
|
| 66 | + 'description' => __( 'The GMT date the item was last modified.', 'invoicing' ), |
|
| 67 | + 'type' => 'string', |
|
| 68 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 69 | + 'readonly' => true, |
|
| 70 | + ), |
|
| 71 | + |
|
| 72 | + 'name' => array( |
|
| 73 | + 'description' => __( "The item's name.", 'invoicing' ), |
|
| 74 | + 'type' => 'string', |
|
| 75 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 76 | + 'required' => true, |
|
| 77 | + ), |
|
| 78 | + |
|
| 79 | + 'description' => array( |
|
| 80 | + 'description' => __( "The item's description.", 'invoicing' ), |
|
| 81 | + 'type' => 'string', |
|
| 82 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 83 | + ), |
|
| 84 | + |
|
| 85 | + 'owner' => array( |
|
| 86 | + 'description' => __( 'The owner of the item (user id).', 'invoicing' ), |
|
| 87 | + 'type' => 'integer', |
|
| 88 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 89 | + ), |
|
| 90 | + |
|
| 91 | + 'price' => array( |
|
| 92 | + 'description' => __( 'The price of the item.', 'invoicing' ), |
|
| 93 | + 'type' => 'number', |
|
| 94 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 95 | + 'required' => true, |
|
| 96 | + ), |
|
| 97 | + |
|
| 98 | + 'the_price' => array( |
|
| 99 | + 'description' => __( 'The formatted price of the item.', 'invoicing' ), |
|
| 100 | + 'type' => 'string', |
|
| 101 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 102 | + 'readonly' => true, |
|
| 103 | + ), |
|
| 104 | + |
|
| 105 | + 'type' => array( |
|
| 106 | + 'description' => __( 'The item type.', 'invoicing' ), |
|
| 107 | + 'type' => 'string', |
|
| 108 | + 'enum' => wpinv_item_types(), |
|
| 109 | + 'default' => 'custom', |
|
| 110 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 111 | + ), |
|
| 112 | + |
|
| 113 | + 'vat_rule' => array( |
|
| 114 | + 'description' => __( 'VAT rule applied to the item.', 'invoicing' ), |
|
| 115 | + 'type' => 'string', |
|
| 116 | + 'enum' => array_keys( getpaid_tax()->get_rules() ), |
|
| 117 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 118 | + ), |
|
| 119 | + |
|
| 120 | + 'vat_class' => array( |
|
| 121 | + 'description' => __( 'VAT class for the item.', 'invoicing' ), |
|
| 122 | + 'type' => 'string', |
|
| 123 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 124 | + 'enum' => array_keys( getpaid_tax()->get_vat_groups() ), |
|
| 125 | + ), |
|
| 126 | + |
|
| 127 | + 'custom_id' => array( |
|
| 128 | + 'description' => __( 'Custom id for the item.', 'invoicing' ), |
|
| 129 | + 'type' => 'string', |
|
| 130 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 131 | + ), |
|
| 132 | 132 | |
| 133 | - 'custom_name' => array( |
|
| 134 | - 'description' => __( 'Custom name for the item.', 'invoicing' ), |
|
| 135 | - 'type' => 'string', |
|
| 136 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 137 | - ), |
|
| 138 | - |
|
| 139 | - 'custom_singular_name' => array( |
|
| 140 | - 'description' => __( 'Custom singular name for the item.', 'invoicing' ), |
|
| 141 | - 'type' => 'string', |
|
| 142 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 143 | - ), |
|
| 144 | - |
|
| 145 | - 'is_dynamic_pricing' => array( |
|
| 146 | - 'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ), |
|
| 147 | - 'type' => 'integer', |
|
| 148 | - 'enum' => array( 0, 1 ), |
|
| 149 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 150 | - ), |
|
| 151 | - |
|
| 152 | - 'minimum_price' => array( |
|
| 153 | - 'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ), |
|
| 154 | - 'type' => 'number', |
|
| 155 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 156 | - ), |
|
| 157 | - |
|
| 158 | - 'is_recurring' => array( |
|
| 159 | - 'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ), |
|
| 160 | - 'type' => 'integer', |
|
| 161 | - 'enum' => array( 0, 1 ), |
|
| 162 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 163 | - ), |
|
| 164 | - |
|
| 165 | - 'initial_price' => array( |
|
| 166 | - 'description' => __( 'The initial price of the item.', 'invoicing' ), |
|
| 167 | - 'type' => 'number', |
|
| 168 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 169 | - 'readonly' => true, |
|
| 170 | - ), |
|
| 171 | - |
|
| 172 | - 'the_initial_price' => array( |
|
| 173 | - 'description' => __( 'The formatted initial price of the item.', 'invoicing' ), |
|
| 174 | - 'type' => 'string', |
|
| 175 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 176 | - 'readonly' => true, |
|
| 177 | - ), |
|
| 178 | - |
|
| 179 | - 'recurring_price' => array( |
|
| 180 | - 'description' => __( 'The recurring price of the item.', 'invoicing' ), |
|
| 181 | - 'type' => 'number', |
|
| 182 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 183 | - 'readonly' => true, |
|
| 184 | - ), |
|
| 185 | - |
|
| 186 | - 'the_recurring_price' => array( |
|
| 187 | - 'description' => __( 'The formatted recurring price of the item.', 'invoicing' ), |
|
| 188 | - 'type' => 'string', |
|
| 189 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 190 | - 'readonly' => true, |
|
| 191 | - ), |
|
| 192 | - |
|
| 193 | - 'recurring_period' => array( |
|
| 194 | - 'description' => __( 'The recurring period for a recurring item.', 'invoicing' ), |
|
| 195 | - 'type' => 'string', |
|
| 196 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 197 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 198 | - ), |
|
| 199 | - |
|
| 200 | - 'recurring_interval' => array( |
|
| 201 | - 'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ), |
|
| 202 | - 'type' => 'integer', |
|
| 203 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 204 | - ), |
|
| 205 | - |
|
| 206 | - 'recurring_limit' => array( |
|
| 207 | - 'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ), |
|
| 208 | - 'type' => 'integer', |
|
| 209 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 210 | - ), |
|
| 211 | - |
|
| 212 | - 'is_free_trial' => array( |
|
| 213 | - 'description' => __( 'Whether the item has a free trial period.', 'invoicing' ), |
|
| 214 | - 'type' => 'integer', |
|
| 215 | - 'enum' => array( 0, 1 ), |
|
| 216 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 217 | - ), |
|
| 218 | - |
|
| 219 | - 'trial_period' => array( |
|
| 220 | - 'description' => __( 'The trial period.', 'invoicing' ), |
|
| 221 | - 'type' => 'string', |
|
| 222 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 223 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 224 | - ), |
|
| 225 | - |
|
| 226 | - 'trial_interval' => array( |
|
| 227 | - 'description' => __( 'The trial interval.', 'invoicing' ), |
|
| 228 | - 'type' => 'integer', |
|
| 229 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 230 | - ), |
|
| 231 | - |
|
| 232 | - 'first_renewal_date' => array( |
|
| 233 | - 'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ), |
|
| 234 | - 'type' => 'string', |
|
| 235 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 236 | - 'readonly' => true, |
|
| 237 | - ), |
|
| 238 | - |
|
| 239 | - 'edit_url' => array( |
|
| 240 | - 'description' => __( 'The URL to edit an item.', 'invoicing' ), |
|
| 241 | - 'type' => 'string', |
|
| 242 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 243 | - 'readonly' => true, |
|
| 244 | - ), |
|
| 133 | + 'custom_name' => array( |
|
| 134 | + 'description' => __( 'Custom name for the item.', 'invoicing' ), |
|
| 135 | + 'type' => 'string', |
|
| 136 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 137 | + ), |
|
| 138 | + |
|
| 139 | + 'custom_singular_name' => array( |
|
| 140 | + 'description' => __( 'Custom singular name for the item.', 'invoicing' ), |
|
| 141 | + 'type' => 'string', |
|
| 142 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 143 | + ), |
|
| 144 | + |
|
| 145 | + 'is_dynamic_pricing' => array( |
|
| 146 | + 'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ), |
|
| 147 | + 'type' => 'integer', |
|
| 148 | + 'enum' => array( 0, 1 ), |
|
| 149 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 150 | + ), |
|
| 151 | + |
|
| 152 | + 'minimum_price' => array( |
|
| 153 | + 'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ), |
|
| 154 | + 'type' => 'number', |
|
| 155 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 156 | + ), |
|
| 157 | + |
|
| 158 | + 'is_recurring' => array( |
|
| 159 | + 'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ), |
|
| 160 | + 'type' => 'integer', |
|
| 161 | + 'enum' => array( 0, 1 ), |
|
| 162 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 163 | + ), |
|
| 164 | + |
|
| 165 | + 'initial_price' => array( |
|
| 166 | + 'description' => __( 'The initial price of the item.', 'invoicing' ), |
|
| 167 | + 'type' => 'number', |
|
| 168 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 169 | + 'readonly' => true, |
|
| 170 | + ), |
|
| 171 | + |
|
| 172 | + 'the_initial_price' => array( |
|
| 173 | + 'description' => __( 'The formatted initial price of the item.', 'invoicing' ), |
|
| 174 | + 'type' => 'string', |
|
| 175 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 176 | + 'readonly' => true, |
|
| 177 | + ), |
|
| 178 | + |
|
| 179 | + 'recurring_price' => array( |
|
| 180 | + 'description' => __( 'The recurring price of the item.', 'invoicing' ), |
|
| 181 | + 'type' => 'number', |
|
| 182 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 183 | + 'readonly' => true, |
|
| 184 | + ), |
|
| 185 | + |
|
| 186 | + 'the_recurring_price' => array( |
|
| 187 | + 'description' => __( 'The formatted recurring price of the item.', 'invoicing' ), |
|
| 188 | + 'type' => 'string', |
|
| 189 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 190 | + 'readonly' => true, |
|
| 191 | + ), |
|
| 192 | + |
|
| 193 | + 'recurring_period' => array( |
|
| 194 | + 'description' => __( 'The recurring period for a recurring item.', 'invoicing' ), |
|
| 195 | + 'type' => 'string', |
|
| 196 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 197 | + 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 198 | + ), |
|
| 199 | + |
|
| 200 | + 'recurring_interval' => array( |
|
| 201 | + 'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ), |
|
| 202 | + 'type' => 'integer', |
|
| 203 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 204 | + ), |
|
| 205 | + |
|
| 206 | + 'recurring_limit' => array( |
|
| 207 | + 'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ), |
|
| 208 | + 'type' => 'integer', |
|
| 209 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 210 | + ), |
|
| 211 | + |
|
| 212 | + 'is_free_trial' => array( |
|
| 213 | + 'description' => __( 'Whether the item has a free trial period.', 'invoicing' ), |
|
| 214 | + 'type' => 'integer', |
|
| 215 | + 'enum' => array( 0, 1 ), |
|
| 216 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 217 | + ), |
|
| 218 | + |
|
| 219 | + 'trial_period' => array( |
|
| 220 | + 'description' => __( 'The trial period.', 'invoicing' ), |
|
| 221 | + 'type' => 'string', |
|
| 222 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 223 | + 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 224 | + ), |
|
| 225 | + |
|
| 226 | + 'trial_interval' => array( |
|
| 227 | + 'description' => __( 'The trial interval.', 'invoicing' ), |
|
| 228 | + 'type' => 'integer', |
|
| 229 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 230 | + ), |
|
| 231 | + |
|
| 232 | + 'first_renewal_date' => array( |
|
| 233 | + 'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ), |
|
| 234 | + 'type' => 'string', |
|
| 235 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 236 | + 'readonly' => true, |
|
| 237 | + ), |
|
| 238 | + |
|
| 239 | + 'edit_url' => array( |
|
| 240 | + 'description' => __( 'The URL to edit an item.', 'invoicing' ), |
|
| 241 | + 'type' => 'string', |
|
| 242 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 243 | + 'readonly' => true, |
|
| 244 | + ), |
|
| 245 | 245 | ); |
@@ -9,237 +9,237 @@ |
||
| 9 | 9 | * @version 1.0.19 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | 16 | 'id' => array( |
| 17 | - 'description' => __( 'Unique identifier for the item.', 'invoicing' ), |
|
| 17 | + 'description' => __('Unique identifier for the item.', 'invoicing'), |
|
| 18 | 18 | 'type' => 'integer', |
| 19 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 19 | + 'context' => array('view', 'edit', 'embed'), |
|
| 20 | 20 | 'readonly' => true, |
| 21 | 21 | ), |
| 22 | 22 | |
| 23 | 23 | 'parent_id' => array( |
| 24 | - 'description' => __( 'Parent item ID.', 'invoicing' ), |
|
| 24 | + 'description' => __('Parent item ID.', 'invoicing'), |
|
| 25 | 25 | 'type' => 'integer', |
| 26 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 26 | + 'context' => array('view', 'edit', 'embed'), |
|
| 27 | 27 | 'default' => 0, |
| 28 | 28 | ), |
| 29 | 29 | |
| 30 | 30 | 'status' => array( |
| 31 | - 'description' => __( 'A named status for the item.', 'invoicing' ), |
|
| 31 | + 'description' => __('A named status for the item.', 'invoicing'), |
|
| 32 | 32 | 'type' => 'string', |
| 33 | - 'enum' => array( 'draft', 'pending', 'publish' ), |
|
| 34 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 33 | + 'enum' => array('draft', 'pending', 'publish'), |
|
| 34 | + 'context' => array('view', 'edit', 'embed'), |
|
| 35 | 35 | 'default' => 'draft', |
| 36 | 36 | ), |
| 37 | 37 | |
| 38 | 38 | 'version' => array( |
| 39 | - 'description' => __( 'Plugin version when the item was created.', 'invoicing' ), |
|
| 39 | + 'description' => __('Plugin version when the item was created.', 'invoicing'), |
|
| 40 | 40 | 'type' => 'string', |
| 41 | - 'context' => array( 'view', 'edit' ), |
|
| 41 | + 'context' => array('view', 'edit'), |
|
| 42 | 42 | 'readonly' => true, |
| 43 | 43 | ), |
| 44 | 44 | |
| 45 | 45 | 'date_created' => array( |
| 46 | - 'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ), |
|
| 46 | + 'description' => __("The date the item was created, in the site's timezone.", 'invoicing'), |
|
| 47 | 47 | 'type' => 'string', |
| 48 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 48 | + 'context' => array('view', 'edit', 'embed'), |
|
| 49 | 49 | ), |
| 50 | 50 | |
| 51 | 51 | 'date_created_gmt' => array( |
| 52 | - 'description' => __( 'The GMT date the item was created.', 'invoicing' ), |
|
| 52 | + 'description' => __('The GMT date the item was created.', 'invoicing'), |
|
| 53 | 53 | 'type' => 'string', |
| 54 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 54 | + 'context' => array('view', 'edit', 'embed'), |
|
| 55 | 55 | 'readonly' => true, |
| 56 | 56 | ), |
| 57 | 57 | |
| 58 | 58 | 'date_modified' => array( |
| 59 | - 'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ), |
|
| 59 | + 'description' => __("The date the item was last modified, in the site's timezone.", 'invoicing'), |
|
| 60 | 60 | 'type' => 'string', |
| 61 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 61 | + 'context' => array('view', 'edit', 'embed'), |
|
| 62 | 62 | 'readonly' => true, |
| 63 | 63 | ), |
| 64 | 64 | |
| 65 | 65 | 'date_modified_gmt' => array( |
| 66 | - 'description' => __( 'The GMT date the item was last modified.', 'invoicing' ), |
|
| 66 | + 'description' => __('The GMT date the item was last modified.', 'invoicing'), |
|
| 67 | 67 | 'type' => 'string', |
| 68 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 68 | + 'context' => array('view', 'edit', 'embed'), |
|
| 69 | 69 | 'readonly' => true, |
| 70 | 70 | ), |
| 71 | 71 | |
| 72 | 72 | 'name' => array( |
| 73 | - 'description' => __( "The item's name.", 'invoicing' ), |
|
| 73 | + 'description' => __("The item's name.", 'invoicing'), |
|
| 74 | 74 | 'type' => 'string', |
| 75 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 75 | + 'context' => array('view', 'edit', 'embed'), |
|
| 76 | 76 | 'required' => true, |
| 77 | 77 | ), |
| 78 | 78 | |
| 79 | 79 | 'description' => array( |
| 80 | - 'description' => __( "The item's description.", 'invoicing' ), |
|
| 80 | + 'description' => __("The item's description.", 'invoicing'), |
|
| 81 | 81 | 'type' => 'string', |
| 82 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 82 | + 'context' => array('view', 'edit', 'embed'), |
|
| 83 | 83 | ), |
| 84 | 84 | |
| 85 | 85 | 'owner' => array( |
| 86 | - 'description' => __( 'The owner of the item (user id).', 'invoicing' ), |
|
| 86 | + 'description' => __('The owner of the item (user id).', 'invoicing'), |
|
| 87 | 87 | 'type' => 'integer', |
| 88 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 88 | + 'context' => array('view', 'edit', 'embed'), |
|
| 89 | 89 | ), |
| 90 | 90 | |
| 91 | 91 | 'price' => array( |
| 92 | - 'description' => __( 'The price of the item.', 'invoicing' ), |
|
| 92 | + 'description' => __('The price of the item.', 'invoicing'), |
|
| 93 | 93 | 'type' => 'number', |
| 94 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 94 | + 'context' => array('view', 'edit', 'embed'), |
|
| 95 | 95 | 'required' => true, |
| 96 | 96 | ), |
| 97 | 97 | |
| 98 | 98 | 'the_price' => array( |
| 99 | - 'description' => __( 'The formatted price of the item.', 'invoicing' ), |
|
| 99 | + 'description' => __('The formatted price of the item.', 'invoicing'), |
|
| 100 | 100 | 'type' => 'string', |
| 101 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 101 | + 'context' => array('view', 'edit', 'embed'), |
|
| 102 | 102 | 'readonly' => true, |
| 103 | 103 | ), |
| 104 | 104 | |
| 105 | 105 | 'type' => array( |
| 106 | - 'description' => __( 'The item type.', 'invoicing' ), |
|
| 106 | + 'description' => __('The item type.', 'invoicing'), |
|
| 107 | 107 | 'type' => 'string', |
| 108 | 108 | 'enum' => wpinv_item_types(), |
| 109 | 109 | 'default' => 'custom', |
| 110 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 110 | + 'context' => array('view', 'edit', 'embed'), |
|
| 111 | 111 | ), |
| 112 | 112 | |
| 113 | 113 | 'vat_rule' => array( |
| 114 | - 'description' => __( 'VAT rule applied to the item.', 'invoicing' ), |
|
| 114 | + 'description' => __('VAT rule applied to the item.', 'invoicing'), |
|
| 115 | 115 | 'type' => 'string', |
| 116 | - 'enum' => array_keys( getpaid_tax()->get_rules() ), |
|
| 117 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 116 | + 'enum' => array_keys(getpaid_tax()->get_rules()), |
|
| 117 | + 'context' => array('view', 'edit', 'embed'), |
|
| 118 | 118 | ), |
| 119 | 119 | |
| 120 | 120 | 'vat_class' => array( |
| 121 | - 'description' => __( 'VAT class for the item.', 'invoicing' ), |
|
| 121 | + 'description' => __('VAT class for the item.', 'invoicing'), |
|
| 122 | 122 | 'type' => 'string', |
| 123 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 124 | - 'enum' => array_keys( getpaid_tax()->get_vat_groups() ), |
|
| 123 | + 'context' => array('view', 'edit', 'embed'), |
|
| 124 | + 'enum' => array_keys(getpaid_tax()->get_vat_groups()), |
|
| 125 | 125 | ), |
| 126 | 126 | |
| 127 | 127 | 'custom_id' => array( |
| 128 | - 'description' => __( 'Custom id for the item.', 'invoicing' ), |
|
| 128 | + 'description' => __('Custom id for the item.', 'invoicing'), |
|
| 129 | 129 | 'type' => 'string', |
| 130 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 130 | + 'context' => array('view', 'edit', 'embed'), |
|
| 131 | 131 | ), |
| 132 | 132 | |
| 133 | 133 | 'custom_name' => array( |
| 134 | - 'description' => __( 'Custom name for the item.', 'invoicing' ), |
|
| 134 | + 'description' => __('Custom name for the item.', 'invoicing'), |
|
| 135 | 135 | 'type' => 'string', |
| 136 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 136 | + 'context' => array('view', 'edit', 'embed'), |
|
| 137 | 137 | ), |
| 138 | 138 | |
| 139 | 139 | 'custom_singular_name' => array( |
| 140 | - 'description' => __( 'Custom singular name for the item.', 'invoicing' ), |
|
| 140 | + 'description' => __('Custom singular name for the item.', 'invoicing'), |
|
| 141 | 141 | 'type' => 'string', |
| 142 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 142 | + 'context' => array('view', 'edit', 'embed'), |
|
| 143 | 143 | ), |
| 144 | 144 | |
| 145 | 145 | 'is_dynamic_pricing' => array( |
| 146 | - 'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ), |
|
| 146 | + 'description' => __('Whether or not customers can enter their own prices when checking out.', 'invoicing'), |
|
| 147 | 147 | 'type' => 'integer', |
| 148 | - 'enum' => array( 0, 1 ), |
|
| 149 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 148 | + 'enum' => array(0, 1), |
|
| 149 | + 'context' => array('view', 'edit', 'embed'), |
|
| 150 | 150 | ), |
| 151 | 151 | |
| 152 | 152 | 'minimum_price' => array( |
| 153 | - 'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ), |
|
| 153 | + 'description' => __('For dynamic prices, this is the minimum price that a user can set.', 'invoicing'), |
|
| 154 | 154 | 'type' => 'number', |
| 155 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 155 | + 'context' => array('view', 'edit', 'embed'), |
|
| 156 | 156 | ), |
| 157 | 157 | |
| 158 | 158 | 'is_recurring' => array( |
| 159 | - 'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ), |
|
| 159 | + 'description' => __('Whether or not this is a subscription item.', 'invoicing'), |
|
| 160 | 160 | 'type' => 'integer', |
| 161 | - 'enum' => array( 0, 1 ), |
|
| 162 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 161 | + 'enum' => array(0, 1), |
|
| 162 | + 'context' => array('view', 'edit', 'embed'), |
|
| 163 | 163 | ), |
| 164 | 164 | |
| 165 | 165 | 'initial_price' => array( |
| 166 | - 'description' => __( 'The initial price of the item.', 'invoicing' ), |
|
| 166 | + 'description' => __('The initial price of the item.', 'invoicing'), |
|
| 167 | 167 | 'type' => 'number', |
| 168 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 168 | + 'context' => array('view', 'edit', 'embed'), |
|
| 169 | 169 | 'readonly' => true, |
| 170 | 170 | ), |
| 171 | 171 | |
| 172 | 172 | 'the_initial_price' => array( |
| 173 | - 'description' => __( 'The formatted initial price of the item.', 'invoicing' ), |
|
| 173 | + 'description' => __('The formatted initial price of the item.', 'invoicing'), |
|
| 174 | 174 | 'type' => 'string', |
| 175 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 175 | + 'context' => array('view', 'edit', 'embed'), |
|
| 176 | 176 | 'readonly' => true, |
| 177 | 177 | ), |
| 178 | 178 | |
| 179 | 179 | 'recurring_price' => array( |
| 180 | - 'description' => __( 'The recurring price of the item.', 'invoicing' ), |
|
| 180 | + 'description' => __('The recurring price of the item.', 'invoicing'), |
|
| 181 | 181 | 'type' => 'number', |
| 182 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 182 | + 'context' => array('view', 'edit', 'embed'), |
|
| 183 | 183 | 'readonly' => true, |
| 184 | 184 | ), |
| 185 | 185 | |
| 186 | 186 | 'the_recurring_price' => array( |
| 187 | - 'description' => __( 'The formatted recurring price of the item.', 'invoicing' ), |
|
| 187 | + 'description' => __('The formatted recurring price of the item.', 'invoicing'), |
|
| 188 | 188 | 'type' => 'string', |
| 189 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 189 | + 'context' => array('view', 'edit', 'embed'), |
|
| 190 | 190 | 'readonly' => true, |
| 191 | 191 | ), |
| 192 | 192 | |
| 193 | 193 | 'recurring_period' => array( |
| 194 | - 'description' => __( 'The recurring period for a recurring item.', 'invoicing' ), |
|
| 194 | + 'description' => __('The recurring period for a recurring item.', 'invoicing'), |
|
| 195 | 195 | 'type' => 'string', |
| 196 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 197 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 196 | + 'context' => array('view', 'edit', 'embed'), |
|
| 197 | + 'enum' => array('D', 'W', 'M', 'Y'), |
|
| 198 | 198 | ), |
| 199 | 199 | |
| 200 | 200 | 'recurring_interval' => array( |
| 201 | - 'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ), |
|
| 201 | + 'description' => __('The recurring interval for a subscription item.', 'invoicing'), |
|
| 202 | 202 | 'type' => 'integer', |
| 203 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 203 | + 'context' => array('view', 'edit', 'embed'), |
|
| 204 | 204 | ), |
| 205 | 205 | |
| 206 | 206 | 'recurring_limit' => array( |
| 207 | - 'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ), |
|
| 207 | + 'description' => __('The maximum number of renewals for a subscription item.', 'invoicing'), |
|
| 208 | 208 | 'type' => 'integer', |
| 209 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 209 | + 'context' => array('view', 'edit', 'embed'), |
|
| 210 | 210 | ), |
| 211 | 211 | |
| 212 | 212 | 'is_free_trial' => array( |
| 213 | - 'description' => __( 'Whether the item has a free trial period.', 'invoicing' ), |
|
| 213 | + 'description' => __('Whether the item has a free trial period.', 'invoicing'), |
|
| 214 | 214 | 'type' => 'integer', |
| 215 | - 'enum' => array( 0, 1 ), |
|
| 216 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 215 | + 'enum' => array(0, 1), |
|
| 216 | + 'context' => array('view', 'edit', 'embed'), |
|
| 217 | 217 | ), |
| 218 | 218 | |
| 219 | 219 | 'trial_period' => array( |
| 220 | - 'description' => __( 'The trial period.', 'invoicing' ), |
|
| 220 | + 'description' => __('The trial period.', 'invoicing'), |
|
| 221 | 221 | 'type' => 'string', |
| 222 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 223 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 222 | + 'context' => array('view', 'edit', 'embed'), |
|
| 223 | + 'enum' => array('D', 'W', 'M', 'Y'), |
|
| 224 | 224 | ), |
| 225 | 225 | |
| 226 | 226 | 'trial_interval' => array( |
| 227 | - 'description' => __( 'The trial interval.', 'invoicing' ), |
|
| 227 | + 'description' => __('The trial interval.', 'invoicing'), |
|
| 228 | 228 | 'type' => 'integer', |
| 229 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 229 | + 'context' => array('view', 'edit', 'embed'), |
|
| 230 | 230 | ), |
| 231 | 231 | |
| 232 | 232 | 'first_renewal_date' => array( |
| 233 | - 'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ), |
|
| 233 | + 'description' => __('The first renewal date in case the item was to be bought today.', 'invoicing'), |
|
| 234 | 234 | 'type' => 'string', |
| 235 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 235 | + 'context' => array('view', 'edit', 'embed'), |
|
| 236 | 236 | 'readonly' => true, |
| 237 | 237 | ), |
| 238 | 238 | |
| 239 | 239 | 'edit_url' => array( |
| 240 | - 'description' => __( 'The URL to edit an item.', 'invoicing' ), |
|
| 240 | + 'description' => __('The URL to edit an item.', 'invoicing'), |
|
| 241 | 241 | 'type' => 'string', |
| 242 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 242 | + 'context' => array('view', 'edit', 'embed'), |
|
| 243 | 243 | 'readonly' => true, |
| 244 | 244 | ), |
| 245 | 245 | ); |