 pronamic    /
                    wp-pronamic-ideal
                      pronamic    /
                    wp-pronamic-ideal
                
                            | 1 | <?php | ||||
| 2 | /** | ||||
| 3 | * Meta Box Subscription Info | ||||
| 4 | * | ||||
| 5 | * @author Pronamic <[email protected]> | ||||
| 6 | * @copyright 2005-2019 Pronamic | ||||
| 7 | * @license GPL-3.0-or-later | ||||
| 8 | * @package Pronamic\WordPress\Pay | ||||
| 9 | */ | ||||
| 10 | |||||
| 11 | use Pronamic\WordPress\Pay\Core\PaymentMethods; | ||||
| 12 | use Pronamic\WordPress\Pay\Core\Statuses; | ||||
| 13 | use Pronamic\WordPress\Pay\Util; | ||||
| 14 | |||||
| 15 | $post_id = get_the_ID(); | ||||
| 16 | |||||
| 17 | if ( empty( $post_id ) ) { | ||||
| 18 | return; | ||||
| 19 | } | ||||
| 20 | |||||
| 21 | $subscription = get_pronamic_subscription( $post_id ); | ||||
| 22 | |||||
| 23 | ?> | ||||
| 24 | <table class="form-table"> | ||||
| 25 | <tr> | ||||
| 26 | <th scope="row"> | ||||
| 27 | <?php esc_html_e( 'Date', 'pronamic_ideal' ); ?> | ||||
| 28 | </th> | ||||
| 29 | <td> | ||||
| 30 | <?php the_time( __( 'l jS \o\f F Y, h:ia', 'pronamic_ideal' ) ); ?> | ||||
| 31 | </td> | ||||
| 32 | </tr> | ||||
| 33 | <tr> | ||||
| 34 | <th scope="row"> | ||||
| 35 | <?php esc_html_e( 'ID', 'pronamic_ideal' ); ?> | ||||
| 36 | </th> | ||||
| 37 | <td> | ||||
| 38 | <?php echo esc_html( $post_id ); ?> | ||||
| 39 | </td> | ||||
| 40 | </tr> | ||||
| 41 | <tr> | ||||
| 42 | <th scope="row"> | ||||
| 43 | <?php esc_html_e( 'Status', 'pronamic_ideal' ); ?> | ||||
| 44 | </th> | ||||
| 45 | <td> | ||||
| 46 | <?php | ||||
| 47 | |||||
| 48 | $status_object = get_post_status_object( get_post_status( $post_id ) ); | ||||
| 0 ignored issues–
                            show             Bug
    
    
    
        introduced 
                            by  
  Loading history... | |||||
| 49 | |||||
| 50 | 			if ( isset( $status_object, $status_object->label ) ) { | ||||
| 51 | echo esc_html( $status_object->label ); | ||||
| 52 | 			} else { | ||||
| 53 | echo '—'; | ||||
| 54 | } | ||||
| 55 | |||||
| 56 | ?> | ||||
| 57 | </td> | ||||
| 58 | </tr> | ||||
| 59 | <tr> | ||||
| 60 | <th scope="row"> | ||||
| 61 | <?php esc_html_e( 'Description', 'pronamic_ideal' ); ?> | ||||
| 62 | </th> | ||||
| 63 | <td> | ||||
| 64 | <?php echo esc_html( $subscription->get_description() ); ?> | ||||
| 65 | </td> | ||||
| 66 | </tr> | ||||
| 67 | <tr> | ||||
| 68 | <th scope="row"> | ||||
| 69 | <?php esc_html_e( 'Gateway', 'pronamic_ideal' ); ?> | ||||
| 70 | </th> | ||||
| 71 | <td> | ||||
| 72 | <?php edit_post_link( get_the_title( $subscription->config_id ), '', '', $subscription->config_id ); ?> | ||||
| 73 | </td> | ||||
| 74 | </tr> | ||||
| 75 | <tr> | ||||
| 76 | <th scope="row"> | ||||
| 77 | <?php esc_html_e( 'Payment Method', 'pronamic_ideal' ); ?> | ||||
| 78 | </th> | ||||
| 79 | <td> | ||||
| 80 | <?php echo esc_html( PaymentMethods::get_name( $subscription->payment_method ) ); ?> | ||||
| 81 | </td> | ||||
| 82 | </tr> | ||||
| 83 | <tr> | ||||
| 84 | <th scope="row"> | ||||
| 85 | <?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?> | ||||
| 86 | </th> | ||||
| 87 | <td> | ||||
| 88 | <?php | ||||
| 89 | |||||
| 90 | 			if ( current_user_can( 'edit_post', $post_id ) && apply_filters( 'pronamic_pay_subscription_amount_editable_' . $subscription->get_source(), false ) ) { | ||||
| 91 | echo esc_html( $subscription->get_total_amount()->get_currency()->get_symbol() ); | ||||
| 92 | |||||
| 93 | $amount = $subscription->get_total_amount()->format_i18n( '%2$s' ); | ||||
| 94 | |||||
| 95 | printf( | ||||
| 96 | '<input type="text" name="pronamic_subscription_amount" value="%s" size="12" />', | ||||
| 97 | esc_attr( $amount ) | ||||
| 98 | ); | ||||
| 99 | 			} else { | ||||
| 100 | echo esc_html( $subscription->get_total_amount()->format_i18n() ); | ||||
| 101 | } | ||||
| 102 | |||||
| 103 | ?> | ||||
| 104 | </td> | ||||
| 105 | </tr> | ||||
| 106 | <tr> | ||||
| 107 | <th scope="row"> | ||||
| 108 | <?php echo esc_html_x( 'Interval', 'Recurring payment', 'pronamic_ideal' ); ?> | ||||
| 109 | </th> | ||||
| 110 | <td> | ||||
| 111 | <?php echo esc_html( Util::format_interval( $subscription->get_interval(), $subscription->get_interval_period() ) ); ?> | ||||
| 112 | </td> | ||||
| 113 | </tr> | ||||
| 114 | <tr> | ||||
| 115 | <th scope="row"> | ||||
| 116 | <?php echo esc_html_x( 'Frequency', 'Recurring payment', 'pronamic_ideal' ); ?> | ||||
| 117 | </th> | ||||
| 118 | <td> | ||||
| 119 | <?php echo esc_html( Util::format_frequency( $subscription->get_frequency() ) ); ?> | ||||
| 0 ignored issues–
                            show $subscription->get_frequency()of typestringis incompatible with the typeintegerexpected by parameter$frequencyofPronamic\WordPress\Pay\Util::format_frequency().
                                                                                                                                                                                           (
                                     Ignorable by Annotation
                                ) If this is a false-positive, you can also ignore this issue in your code via the  
  Loading history... | |||||
| 120 | </td> | ||||
| 121 | </tr> | ||||
| 122 | <tr> | ||||
| 123 | <th scope="row"> | ||||
| 124 | <?php esc_html_e( 'Start Date', 'pronamic_ideal' ); ?> | ||||
| 125 | </th> | ||||
| 126 | <td> | ||||
| 127 | <?php | ||||
| 128 | |||||
| 129 | $start_date = $subscription->get_start_date(); | ||||
| 130 | |||||
| 131 | echo empty( $start_date ) ? '—' : esc_html( $start_date->format_i18n() ); | ||||
| 132 | |||||
| 133 | ?> | ||||
| 134 | </td> | ||||
| 135 | </tr> | ||||
| 136 | |||||
| 137 | <?php | ||||
| 138 | |||||
| 139 | $frequency = $subscription->get_frequency(); | ||||
| 140 | |||||
| 141 | // Show end date if frequency is limited. | ||||
| 142 | if ( ! empty( $frequency ) ) : | ||||
| 143 | |||||
| 144 | ?> | ||||
| 145 | |||||
| 146 | <tr> | ||||
| 147 | <th scope="row"> | ||||
| 148 | <?php esc_html_e( 'End Date', 'pronamic_ideal' ); ?> | ||||
| 149 | </th> | ||||
| 150 | <td> | ||||
| 151 | <?php | ||||
| 152 | |||||
| 153 | $end_date = $subscription->get_end_date(); | ||||
| 154 | |||||
| 155 | echo empty( $end_date ) ? '—' : esc_html( $end_date->format_i18n() ); | ||||
| 156 | |||||
| 157 | ?> | ||||
| 158 | </td> | ||||
| 159 | </tr> | ||||
| 160 | |||||
| 161 | <?php endif; ?> | ||||
| 162 | |||||
| 163 | <?php | ||||
| 164 | |||||
| 165 | // Show next payment date if subscription is not cancelled or completed. | ||||
| 166 | if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) : | ||||
| 167 | |||||
| 168 | ?> | ||||
| 169 | |||||
| 170 | <tr> | ||||
| 171 | <th scope="row"> | ||||
| 172 | <?php esc_html_e( 'Next Payment Date', 'pronamic_ideal' ); ?> | ||||
| 173 | </th> | ||||
| 174 | <td> | ||||
| 175 | <?php | ||||
| 176 | |||||
| 177 | $next_payment = $subscription->get_next_payment_date(); | ||||
| 178 | |||||
| 179 | echo empty( $next_payment ) ? '—' : esc_html( $next_payment->format_i18n() ); | ||||
| 180 | |||||
| 181 | ?> | ||||
| 182 | </td> | ||||
| 183 | </tr> | ||||
| 184 | |||||
| 185 | <?php endif; ?> | ||||
| 186 | |||||
| 187 | <tr> | ||||
| 188 | <th scope="row"> | ||||
| 189 | <?php esc_html_e( 'Expiry Date', 'pronamic_ideal' ); ?> | ||||
| 190 | </th> | ||||
| 191 | <td> | ||||
| 192 | <?php | ||||
| 193 | |||||
| 194 | $expiry_date = $subscription->get_expiry_date(); | ||||
| 195 | |||||
| 196 | echo empty( $expiry_date ) ? '—' : esc_html( $expiry_date->format_i18n() ); | ||||
| 197 | |||||
| 198 | ?> | ||||
| 199 | </td> | ||||
| 200 | </tr> | ||||
| 201 | <tr> | ||||
| 202 | <th scope="row"> | ||||
| 203 | <?php esc_html_e( 'Consumer', 'pronamic_ideal' ); ?> | ||||
| 204 | </th> | ||||
| 205 | <td> | ||||
| 206 | <?php | ||||
| 207 | |||||
| 208 | echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_name', true ) ); | ||||
| 0 ignored issues–
                            show It seems like  get_post_meta($post_id, ...n_consumer_name', true)can also be of typefalse; however, parameter$textofesc_html()does only seem to acceptstring, maybe add an additional type check?
                                                                                                                                                                                           (
                                     Ignorable by Annotation
                                ) If this is a false-positive, you can also ignore this issue in your code via the  
  Loading history... | |||||
| 209 | echo '<br />'; | ||||
| 210 | echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_iban', true ) ); | ||||
| 211 | echo '<br />'; | ||||
| 212 | echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_bic', true ) ); | ||||
| 213 | |||||
| 214 | ?> | ||||
| 215 | </td> | ||||
| 216 | </tr> | ||||
| 217 | |||||
| 218 | <?php if ( ! empty( $subscription->user_id ) ) : ?> | ||||
| 219 | |||||
| 220 | <tr> | ||||
| 221 | <th scope="row"> | ||||
| 222 | <?php esc_html_e( 'User', 'pronamic_ideal' ); ?> | ||||
| 223 | </th> | ||||
| 224 | <td> | ||||
| 225 | <?php | ||||
| 226 | |||||
| 227 | $user_id = $subscription->user_id; | ||||
| 228 | |||||
| 229 | printf( | ||||
| 230 | '<a href="%s">%s</a>', | ||||
| 231 | esc_url( get_edit_user_link( $user_id ) ), | ||||
| 0 ignored issues–
                            show $user_idof typestringis incompatible with the typeintegerexpected by parameter$user_idofget_edit_user_link().
                                                                                                                                                                                           (
                                     Ignorable by Annotation
                                ) If this is a false-positive, you can also ignore this issue in your code via the  
  Loading history... | |||||
| 232 | esc_html( $user_id ) | ||||
| 233 | ); | ||||
| 234 | |||||
| 235 | ?> | ||||
| 236 | </td> | ||||
| 237 | </tr> | ||||
| 238 | |||||
| 239 | <?php endif; ?> | ||||
| 240 | |||||
| 241 | <tr> | ||||
| 242 | <th scope="row"> | ||||
| 243 | <?php esc_html_e( 'Source', 'pronamic_ideal' ); ?> | ||||
| 244 | </th> | ||||
| 245 | <td> | ||||
| 246 | <?php | ||||
| 247 | |||||
| 248 | echo $subscription->get_source_text(); // WPCS: XSS ok. | ||||
| 249 | |||||
| 250 | ?> | ||||
| 251 | </td> | ||||
| 252 | </tr> | ||||
| 253 | |||||
| 254 | <?php if ( 's2member' === $subscription->get_source() ) : ?> | ||||
| 255 | |||||
| 256 | <tr> | ||||
| 257 | <th scope="row"> | ||||
| 258 | <?php esc_html_e( 'Period', 'pronamic_ideal' ); ?> | ||||
| 259 | </th> | ||||
| 260 | <td> | ||||
| 261 | <?php echo esc_html( get_post_meta( $subscription->get_id(), '_pronamic_subscription_s2member_period', true ) ); ?> | ||||
| 262 | </td> | ||||
| 263 | </tr> | ||||
| 264 | <tr> | ||||
| 265 | <th scope="row"> | ||||
| 266 | <?php esc_html_e( 'Level', 'pronamic_ideal' ); ?> | ||||
| 267 | </th> | ||||
| 268 | <td> | ||||
| 269 | <?php echo esc_html( get_post_meta( $subscription->get_id(), '_pronamic_subscription_s2member_level', true ) ); ?> | ||||
| 270 | </td> | ||||
| 271 | </tr> | ||||
| 272 | |||||
| 273 | <?php endif; ?> | ||||
| 274 | |||||
| 275 | <tr> | ||||
| 276 | <th scope="row"> | ||||
| 277 | <?php esc_html_e( 'Cancel URL', 'pronamic_ideal' ); ?> | ||||
| 278 | </th> | ||||
| 279 | <td> | ||||
| 280 | <?php | ||||
| 281 | |||||
| 282 | $url = $subscription->get_cancel_url(); | ||||
| 283 | |||||
| 284 | printf( | ||||
| 285 | '<a href="%s">%s</a>', | ||||
| 286 | esc_attr( $url ), | ||||
| 287 | esc_html( $url ) | ||||
| 288 | ); | ||||
| 289 | |||||
| 290 | ?> | ||||
| 291 | </td> | ||||
| 292 | </tr> | ||||
| 293 | <tr> | ||||
| 294 | <th scope="row"> | ||||
| 295 | <?php esc_html_e( 'Renewal URL', 'pronamic_ideal' ); ?> | ||||
| 296 | </th> | ||||
| 297 | <td> | ||||
| 298 | <?php | ||||
| 299 | |||||
| 300 | $url = $subscription->get_renewal_url(); | ||||
| 301 | |||||
| 302 | printf( | ||||
| 303 | '<a href="%s">%s</a>', | ||||
| 304 | esc_attr( $url ), | ||||
| 305 | esc_html( $url ) | ||||
| 306 | ); | ||||
| 307 | |||||
| 308 | ?> | ||||
| 309 | </td> | ||||
| 310 | </tr> | ||||
| 311 | </table> | ||||
| 312 | 
