@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | 'getpaid-nonce', |
| 58 | 58 | 'getpaid-nonce' |
| 59 | 59 | ); |
| 60 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
| 61 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
| 60 | + $anchor = __( 'Deactivate', 'invoicing' ); |
|
| 61 | + $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
| 62 | 62 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 63 | 63 | |
| 64 | 64 | } else if( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | 'getpaid-nonce' |
| 76 | 76 | ) |
| 77 | 77 | ); |
| 78 | - $anchor = __( 'Activate', 'invoicing' ); |
|
| 79 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 78 | + $anchor = __( 'Activate', 'invoicing' ); |
|
| 79 | + $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 80 | 80 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 81 | 81 | |
| 82 | 82 | } |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | 'getpaid-nonce' |
| 94 | 94 | ) |
| 95 | 95 | ); |
| 96 | - $anchor = __( 'Delete', 'invoicing' ); |
|
| 97 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
| 96 | + $anchor = __( 'Delete', 'invoicing' ); |
|
| 97 | + $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
| 98 | 98 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 99 | 99 | |
| 100 | 100 | $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
@@ -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,31 +21,31 @@ 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', 90, 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', 90, 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_discount' ) { |
|
| 37 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
| 36 | + if ($post_type == 'wpi_discount') { |
|
| 37 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | return $actions; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
| 44 | - $row_actions = array(); |
|
| 45 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
| 46 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
| 43 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
| 44 | + $row_actions = array(); |
|
| 45 | + $edit_link = get_edit_post_link($discount->ID); |
|
| 46 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
| 47 | 47 | |
| 48 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
| 48 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
| 49 | 49 | |
| 50 | 50 | $url = wp_nonce_url( |
| 51 | 51 | add_query_arg( |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | 'getpaid-nonce', |
| 58 | 58 | 'getpaid-nonce' |
| 59 | 59 | ); |
| 60 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
| 61 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
| 60 | + $anchor = __('Deactivate', 'invoicing'); |
|
| 61 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
| 62 | 62 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 63 | 63 | |
| 64 | - } else if( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
| 64 | + } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
| 65 | 65 | |
| 66 | - $url = esc_url( |
|
| 66 | + $url = esc_url( |
|
| 67 | 67 | wp_nonce_url( |
| 68 | 68 | add_query_arg( |
| 69 | 69 | array( |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | 'getpaid-nonce' |
| 76 | 76 | ) |
| 77 | 77 | ); |
| 78 | - $anchor = __( 'Activate', 'invoicing' ); |
|
| 79 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 78 | + $anchor = __('Activate', 'invoicing'); |
|
| 79 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
| 80 | 80 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $url = esc_url( |
|
| 84 | + $url = esc_url( |
|
| 85 | 85 | wp_nonce_url( |
| 86 | 86 | add_query_arg( |
| 87 | 87 | array( |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | 'getpaid-nonce' |
| 94 | 94 | ) |
| 95 | 95 | ); |
| 96 | - $anchor = __( 'Delete', 'invoicing' ); |
|
| 97 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
| 96 | + $anchor = __('Delete', 'invoicing'); |
|
| 97 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
| 98 | 98 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 99 | 99 | |
| 100 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
| 100 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
| 101 | 101 | |
| 102 | 102 | return $row_actions; |
| 103 | 103 | } |
@@ -105,68 +105,68 @@ discard block |
||
| 105 | 105 | function wpinv_restrict_manage_posts() { |
| 106 | 106 | global $typenow; |
| 107 | 107 | |
| 108 | - if( 'wpi_discount' == $typenow ) { |
|
| 108 | + if ('wpi_discount' == $typenow) { |
|
| 109 | 109 | wpinv_discount_filters(); |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
| 112 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
| 113 | 113 | |
| 114 | 114 | function wpinv_discount_filters() { |
| 115 | 115 | |
| 116 | 116 | ?> |
| 117 | 117 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
| 118 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
| 118 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
| 119 | 119 | <?php |
| 120 | 120 | $types = wpinv_get_discount_types(); |
| 121 | 121 | |
| 122 | - foreach ( $types as $name => $type ) { |
|
| 123 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 122 | + foreach ($types as $name => $type) { |
|
| 123 | + echo '<option value="' . esc_attr($name) . '"'; |
|
| 124 | 124 | |
| 125 | - if ( isset( $_GET['discount_type'] ) ) |
|
| 126 | - selected( $name, $_GET['discount_type'] ); |
|
| 125 | + if (isset($_GET['discount_type'])) |
|
| 126 | + selected($name, $_GET['discount_type']); |
|
| 127 | 127 | |
| 128 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 128 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
| 129 | 129 | } |
| 130 | 130 | ?> |
| 131 | 131 | </select> |
| 132 | 132 | <?php |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -function wpinv_request( $vars ) { |
|
| 135 | +function wpinv_request($vars) { |
|
| 136 | 136 | global $typenow, $wp_post_statuses; |
| 137 | 137 | |
| 138 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
| 139 | - if ( ! isset( $vars['post_status'] ) ) { |
|
| 140 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
| 138 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
| 139 | + if (!isset($vars['post_status'])) { |
|
| 140 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
| 141 | 141 | |
| 142 | - foreach ( $post_statuses as $status => $value ) { |
|
| 143 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
| 144 | - unset( $post_statuses[ $status ] ); |
|
| 142 | + foreach ($post_statuses as $status => $value) { |
|
| 143 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
| 144 | + unset($post_statuses[$status]); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
| 148 | + $vars['post_status'] = array_keys($post_statuses); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - } else if ( 'wpi_discount' == $typenow ) { |
|
| 152 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 151 | + } else if ('wpi_discount' == $typenow) { |
|
| 152 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 153 | 153 | // Filter vat rule type |
| 154 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
| 154 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
| 155 | 155 | $meta_query[] = array( |
| 156 | 156 | 'key' => '_wpi_discount_type', |
| 157 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
| 157 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
| 158 | 158 | 'compare' => '=' |
| 159 | 159 | ); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( !empty( $meta_query ) ) { |
|
| 162 | + if (!empty($meta_query)) { |
|
| 163 | 163 | $vars['meta_query'] = $meta_query; |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | return $vars; |
| 168 | 168 | } |
| 169 | -add_filter( 'request', 'wpinv_request' ); |
|
| 169 | +add_filter('request', 'wpinv_request'); |
|
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Create a page and store the ID in an option. |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | * @param int $post_parent (default: 0) Parent for the new page |
| 179 | 179 | * @return int page ID |
| 180 | 180 | */ |
| 181 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
| 181 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
| 182 | 182 | global $wpdb; |
| 183 | 183 | |
| 184 | - $option_value = wpinv_get_option( $option ); |
|
| 184 | + $option_value = wpinv_get_option($option); |
|
| 185 | 185 | |
| 186 | - if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) { |
|
| 187 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
| 186 | + if (!empty($option_value) && ($page_object = get_post($option_value))) { |
|
| 187 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
| 188 | 188 | // Valid page is already in place |
| 189 | 189 | return $page_object->ID; |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if(!empty($post_parent)){ |
|
| 193 | + if (!empty($post_parent)) { |
|
| 194 | 194 | $page = get_page_by_path($post_parent); |
| 195 | 195 | if ($page) { |
| 196 | 196 | $post_parent = $page->ID; |
@@ -199,40 +199,40 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if ( strlen( $page_content ) > 0 ) { |
|
| 202 | + if (strlen($page_content) > 0) { |
|
| 203 | 203 | // Search for an existing page with the specified page content (typically a shortcode) |
| 204 | - $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}%" ) ); |
|
| 204 | + $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}%")); |
|
| 205 | 205 | } else { |
| 206 | 206 | // Search for an existing page with the specified page slug |
| 207 | - $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 ) ); |
|
| 207 | + $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)); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
| 210 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
| 211 | 211 | |
| 212 | - if ( $valid_page_found ) { |
|
| 213 | - if ( $option ) { |
|
| 214 | - wpinv_update_option( $option, $valid_page_found ); |
|
| 212 | + if ($valid_page_found) { |
|
| 213 | + if ($option) { |
|
| 214 | + wpinv_update_option($option, $valid_page_found); |
|
| 215 | 215 | } |
| 216 | 216 | return $valid_page_found; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Search for a matching valid trashed page |
| 220 | - if ( strlen( $page_content ) > 0 ) { |
|
| 220 | + if (strlen($page_content) > 0) { |
|
| 221 | 221 | // Search for an existing page with the specified page content (typically a shortcode) |
| 222 | - $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}%" ) ); |
|
| 222 | + $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}%")); |
|
| 223 | 223 | } else { |
| 224 | 224 | // Search for an existing page with the specified page slug |
| 225 | - $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 ) ); |
|
| 225 | + $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)); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if ( $trashed_page_found ) { |
|
| 228 | + if ($trashed_page_found) { |
|
| 229 | 229 | $page_id = $trashed_page_found; |
| 230 | 230 | $page_data = array( |
| 231 | 231 | 'ID' => $page_id, |
| 232 | 232 | 'post_status' => 'publish', |
| 233 | 233 | 'post_parent' => $post_parent, |
| 234 | 234 | ); |
| 235 | - wp_update_post( $page_data ); |
|
| 235 | + wp_update_post($page_data); |
|
| 236 | 236 | } else { |
| 237 | 237 | $page_data = array( |
| 238 | 238 | 'post_status' => 'publish', |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | 'post_parent' => $post_parent, |
| 245 | 245 | 'comment_status' => 'closed', |
| 246 | 246 | ); |
| 247 | - $page_id = wp_insert_post( $page_data ); |
|
| 247 | + $page_id = wp_insert_post($page_data); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - if ( $option ) { |
|
| 251 | - wpinv_update_option( $option, (int) $page_id ); |
|
| 250 | + if ($option) { |
|
| 251 | + wpinv_update_option($option, (int) $page_id); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $page_id; |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @return array |
| 263 | 263 | */ |
| 264 | -function wpinv_add_aui_screens($screen_ids){ |
|
| 264 | +function wpinv_add_aui_screens($screen_ids) { |
|
| 265 | 265 | |
| 266 | 266 | // load on these pages if set |
| 267 | - $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() ); |
|
| 267 | + $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids()); |
|
| 268 | 268 | |
| 269 | 269 | return $screen_ids; |
| 270 | 270 | } |
| 271 | -add_filter('aui_screen_ids','wpinv_add_aui_screens'); |
|
| 272 | 271 | \ No newline at end of file |
| 272 | +add_filter('aui_screen_ids', 'wpinv_add_aui_screens'); |
|
| 273 | 273 | \ No newline at end of file |