@@ -12,478 +12,478 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Paypal_Gateway_IPN_Handler { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Payment method id. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - protected $id = 'paypal'; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Payment method object. |
|
| 24 | - * |
|
| 25 | - * @var GetPaid_Paypal_Gateway |
|
| 26 | - */ |
|
| 27 | - protected $gateway; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Class constructor. |
|
| 31 | - * |
|
| 32 | - * @param GetPaid_Paypal_Gateway $gateway |
|
| 33 | - */ |
|
| 34 | - public function __construct( $gateway ) { |
|
| 35 | - $this->gateway = $gateway; |
|
| 36 | - $this->verify_ipn(); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Processes ipns and marks payments as complete. |
|
| 41 | - * |
|
| 42 | - * @return void |
|
| 43 | - */ |
|
| 44 | - public function verify_ipn() { |
|
| 45 | - |
|
| 46 | - wpinv_error_log( 'GetPaid PayPal IPN Handler', false ); |
|
| 47 | - |
|
| 48 | - // Validate the IPN. |
|
| 49 | - if ( empty( $_POST ) || ! $this->validate_ipn() ) { |
|
| 50 | - wp_die( 'PayPal IPN Request Failure', 500 ); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - // Process the IPN. |
|
| 54 | - $posted = wp_unslash( $_POST ); |
|
| 55 | - $invoice = $this->get_ipn_invoice( $posted ); |
|
| 56 | - |
|
| 57 | - // Abort if it was not paid by our gateway. |
|
| 58 | - if ( $this->id != $invoice->get_gateway() ) { |
|
| 59 | - wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false ); |
|
| 60 | - wp_die( 'Invoice not paid via PayPal', 200 ); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : ''; |
|
| 64 | - $posted['txn_type'] = sanitize_key( strtolower( $posted['txn_type'] ) ); |
|
| 65 | - |
|
| 66 | - wpinv_error_log( 'Payment status:' . $posted['payment_status'], false ); |
|
| 67 | - wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false ); |
|
| 68 | - |
|
| 69 | - if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) { |
|
| 70 | - call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted ); |
|
| 71 | - wpinv_error_log( 'Done processing IPN', false ); |
|
| 72 | - wp_die( 'Processed', 200 ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false ); |
|
| 76 | - wp_die( 'Unsupported IPN type', 200 ); |
|
| 77 | - |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Retrieves IPN Invoice. |
|
| 82 | - * |
|
| 83 | - * @param array $posted |
|
| 84 | - * @return WPInv_Invoice |
|
| 85 | - */ |
|
| 86 | - protected function get_ipn_invoice( $posted ) { |
|
| 87 | - |
|
| 88 | - wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false ); |
|
| 89 | - |
|
| 90 | - if ( ! empty( $posted['custom'] ) ) { |
|
| 91 | - $invoice = new WPInv_Invoice( $posted['custom'] ); |
|
| 92 | - |
|
| 93 | - if ( $invoice->exists() ) { |
|
| 94 | - wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false ); |
|
| 95 | - return $invoice; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - wpinv_error_log( 'Could not retrieve the associated invoice.', false ); |
|
| 100 | - wp_die( 'Could not retrieve the associated invoice.', 200 ); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Check PayPal IPN validity. |
|
| 105 | - */ |
|
| 106 | - protected function validate_ipn() { |
|
| 107 | - |
|
| 108 | - wpinv_error_log( 'Validating PayPal IPN response', false ); |
|
| 109 | - |
|
| 110 | - // Retrieve the associated invoice. |
|
| 111 | - $posted = wp_unslash( $_POST ); |
|
| 112 | - $invoice = $this->get_ipn_invoice( $posted ); |
|
| 113 | - |
|
| 114 | - if ( $this->gateway->is_sandbox( $invoice ) ) { |
|
| 115 | - wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false ); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // Validate the IPN. |
|
| 119 | - $posted['cmd'] = '_notify-validate'; |
|
| 120 | - |
|
| 121 | - // Send back post vars to paypal. |
|
| 122 | - $params = array( |
|
| 123 | - 'body' => $posted, |
|
| 124 | - 'timeout' => 60, |
|
| 125 | - 'httpversion' => '1.1', |
|
| 126 | - 'compress' => false, |
|
| 127 | - 'decompress' => false, |
|
| 128 | - 'user-agent' => 'GetPaid/' . WPINV_VERSION, |
|
| 129 | - ); |
|
| 130 | - |
|
| 131 | - // Post back to get a response. |
|
| 132 | - $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
| 133 | - |
|
| 134 | - // Check to see if the request was valid. |
|
| 135 | - if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) { |
|
| 136 | - $invoice->add_note( 'Received valid response from PayPal IPN: ' . $response['body'], false, false, true ); |
|
| 137 | - wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false ); |
|
| 138 | - return true; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - $invoice->add_note( 'IPN message:' . wp_json_encode( $posted ), false, false, true ); |
|
| 142 | - |
|
| 143 | - if ( is_wp_error( $response ) ) { |
|
| 144 | - $invoice->add_note( 'Received invalid response from PayPal IPN: ' . $response->get_error_message(), false, false, true ); |
|
| 145 | - wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' ); |
|
| 146 | - return false; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - $invoice->add_note( 'Received invalid response from PayPal IPN: ' . $response['body'], false, false, true ); |
|
| 150 | - wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' ); |
|
| 151 | - return false; |
|
| 152 | - |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Check currency from IPN matches the invoice. |
|
| 157 | - * |
|
| 158 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 159 | - * @param string $currency currency to validate. |
|
| 160 | - */ |
|
| 161 | - protected function validate_ipn_currency( $invoice, $currency ) { |
|
| 15 | + /** |
|
| 16 | + * Payment method id. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + protected $id = 'paypal'; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Payment method object. |
|
| 24 | + * |
|
| 25 | + * @var GetPaid_Paypal_Gateway |
|
| 26 | + */ |
|
| 27 | + protected $gateway; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Class constructor. |
|
| 31 | + * |
|
| 32 | + * @param GetPaid_Paypal_Gateway $gateway |
|
| 33 | + */ |
|
| 34 | + public function __construct( $gateway ) { |
|
| 35 | + $this->gateway = $gateway; |
|
| 36 | + $this->verify_ipn(); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Processes ipns and marks payments as complete. |
|
| 41 | + * |
|
| 42 | + * @return void |
|
| 43 | + */ |
|
| 44 | + public function verify_ipn() { |
|
| 45 | + |
|
| 46 | + wpinv_error_log( 'GetPaid PayPal IPN Handler', false ); |
|
| 47 | + |
|
| 48 | + // Validate the IPN. |
|
| 49 | + if ( empty( $_POST ) || ! $this->validate_ipn() ) { |
|
| 50 | + wp_die( 'PayPal IPN Request Failure', 500 ); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + // Process the IPN. |
|
| 54 | + $posted = wp_unslash( $_POST ); |
|
| 55 | + $invoice = $this->get_ipn_invoice( $posted ); |
|
| 56 | + |
|
| 57 | + // Abort if it was not paid by our gateway. |
|
| 58 | + if ( $this->id != $invoice->get_gateway() ) { |
|
| 59 | + wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false ); |
|
| 60 | + wp_die( 'Invoice not paid via PayPal', 200 ); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : ''; |
|
| 64 | + $posted['txn_type'] = sanitize_key( strtolower( $posted['txn_type'] ) ); |
|
| 65 | + |
|
| 66 | + wpinv_error_log( 'Payment status:' . $posted['payment_status'], false ); |
|
| 67 | + wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false ); |
|
| 68 | + |
|
| 69 | + if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) { |
|
| 70 | + call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted ); |
|
| 71 | + wpinv_error_log( 'Done processing IPN', false ); |
|
| 72 | + wp_die( 'Processed', 200 ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false ); |
|
| 76 | + wp_die( 'Unsupported IPN type', 200 ); |
|
| 77 | + |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Retrieves IPN Invoice. |
|
| 82 | + * |
|
| 83 | + * @param array $posted |
|
| 84 | + * @return WPInv_Invoice |
|
| 85 | + */ |
|
| 86 | + protected function get_ipn_invoice( $posted ) { |
|
| 87 | + |
|
| 88 | + wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false ); |
|
| 89 | + |
|
| 90 | + if ( ! empty( $posted['custom'] ) ) { |
|
| 91 | + $invoice = new WPInv_Invoice( $posted['custom'] ); |
|
| 92 | + |
|
| 93 | + if ( $invoice->exists() ) { |
|
| 94 | + wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false ); |
|
| 95 | + return $invoice; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + wpinv_error_log( 'Could not retrieve the associated invoice.', false ); |
|
| 100 | + wp_die( 'Could not retrieve the associated invoice.', 200 ); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Check PayPal IPN validity. |
|
| 105 | + */ |
|
| 106 | + protected function validate_ipn() { |
|
| 107 | + |
|
| 108 | + wpinv_error_log( 'Validating PayPal IPN response', false ); |
|
| 109 | + |
|
| 110 | + // Retrieve the associated invoice. |
|
| 111 | + $posted = wp_unslash( $_POST ); |
|
| 112 | + $invoice = $this->get_ipn_invoice( $posted ); |
|
| 113 | + |
|
| 114 | + if ( $this->gateway->is_sandbox( $invoice ) ) { |
|
| 115 | + wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false ); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // Validate the IPN. |
|
| 119 | + $posted['cmd'] = '_notify-validate'; |
|
| 120 | + |
|
| 121 | + // Send back post vars to paypal. |
|
| 122 | + $params = array( |
|
| 123 | + 'body' => $posted, |
|
| 124 | + 'timeout' => 60, |
|
| 125 | + 'httpversion' => '1.1', |
|
| 126 | + 'compress' => false, |
|
| 127 | + 'decompress' => false, |
|
| 128 | + 'user-agent' => 'GetPaid/' . WPINV_VERSION, |
|
| 129 | + ); |
|
| 130 | + |
|
| 131 | + // Post back to get a response. |
|
| 132 | + $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
| 133 | + |
|
| 134 | + // Check to see if the request was valid. |
|
| 135 | + if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) { |
|
| 136 | + $invoice->add_note( 'Received valid response from PayPal IPN: ' . $response['body'], false, false, true ); |
|
| 137 | + wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false ); |
|
| 138 | + return true; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + $invoice->add_note( 'IPN message:' . wp_json_encode( $posted ), false, false, true ); |
|
| 142 | + |
|
| 143 | + if ( is_wp_error( $response ) ) { |
|
| 144 | + $invoice->add_note( 'Received invalid response from PayPal IPN: ' . $response->get_error_message(), false, false, true ); |
|
| 145 | + wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' ); |
|
| 146 | + return false; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + $invoice->add_note( 'Received invalid response from PayPal IPN: ' . $response['body'], false, false, true ); |
|
| 150 | + wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' ); |
|
| 151 | + return false; |
|
| 152 | + |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Check currency from IPN matches the invoice. |
|
| 157 | + * |
|
| 158 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 159 | + * @param string $currency currency to validate. |
|
| 160 | + */ |
|
| 161 | + protected function validate_ipn_currency( $invoice, $currency ) { |
|
| 162 | 162 | |
| 163 | - if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) { |
|
| 163 | + if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) { |
|
| 164 | 164 | |
| 165 | - /* translators: %s: currency code. */ |
|
| 166 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) ); |
|
| 165 | + /* translators: %s: currency code. */ |
|
| 166 | + $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) ); |
|
| 167 | 167 | |
| 168 | - wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true ); |
|
| 169 | - } |
|
| 168 | + wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true ); |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - wpinv_error_log( $currency, 'Validated IPN Currency', false ); |
|
| 172 | - } |
|
| 171 | + wpinv_error_log( $currency, 'Validated IPN Currency', false ); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - /** |
|
| 175 | - * Check payment amount from IPN matches the invoice. |
|
| 176 | - * |
|
| 177 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 178 | - * @param float $amount amount to validate. |
|
| 179 | - */ |
|
| 180 | - protected function validate_ipn_amount( $invoice, $amount ) { |
|
| 181 | - if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) { |
|
| 174 | + /** |
|
| 175 | + * Check payment amount from IPN matches the invoice. |
|
| 176 | + * |
|
| 177 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 178 | + * @param float $amount amount to validate. |
|
| 179 | + */ |
|
| 180 | + protected function validate_ipn_amount( $invoice, $amount ) { |
|
| 181 | + if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) { |
|
| 182 | 182 | |
| 183 | - /* translators: %s: Amount. */ |
|
| 184 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) ); |
|
| 183 | + /* translators: %s: Amount. */ |
|
| 184 | + $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) ); |
|
| 185 | 185 | |
| 186 | - wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true ); |
|
| 187 | - } |
|
| 186 | + wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true ); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - wpinv_error_log( $amount, 'Validated IPN Amount', false ); |
|
| 190 | - } |
|
| 189 | + wpinv_error_log( $amount, 'Validated IPN Amount', false ); |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Verify receiver email from PayPal. |
|
| 194 | - * |
|
| 195 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 196 | - * @param string $receiver_email Email to validate. |
|
| 197 | - */ |
|
| 198 | - protected function validate_ipn_receiver_email( $invoice, $receiver_email ) { |
|
| 199 | - $paypal_email = wpinv_get_option( 'paypal_email' ); |
|
| 192 | + /** |
|
| 193 | + * Verify receiver email from PayPal. |
|
| 194 | + * |
|
| 195 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 196 | + * @param string $receiver_email Email to validate. |
|
| 197 | + */ |
|
| 198 | + protected function validate_ipn_receiver_email( $invoice, $receiver_email ) { |
|
| 199 | + $paypal_email = wpinv_get_option( 'paypal_email' ); |
|
| 200 | 200 | |
| 201 | - if ( $receiver_email && strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) { |
|
| 202 | - wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" ); |
|
| 201 | + if ( $receiver_email && strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) { |
|
| 202 | + wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" ); |
|
| 203 | 203 | |
| 204 | - /* translators: %s: email address . */ |
|
| 205 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) ); |
|
| 204 | + /* translators: %s: email address . */ |
|
| 205 | + $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) ); |
|
| 206 | 206 | |
| 207 | - return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true ); |
|
| 208 | - } |
|
| 207 | + return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true ); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - wpinv_error_log( 'Validated PayPal Email', false ); |
|
| 211 | - } |
|
| 210 | + wpinv_error_log( 'Validated PayPal Email', false ); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Handles one time payments. |
|
| 215 | - * |
|
| 216 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 217 | - * @param array $posted Posted data. |
|
| 218 | - */ |
|
| 219 | - protected function ipn_txn_web_accept( $invoice, $posted ) { |
|
| 213 | + /** |
|
| 214 | + * Handles one time payments. |
|
| 215 | + * |
|
| 216 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 217 | + * @param array $posted Posted data. |
|
| 218 | + */ |
|
| 219 | + protected function ipn_txn_web_accept( $invoice, $posted ) { |
|
| 220 | 220 | |
| 221 | - // Collect payment details |
|
| 222 | - $payment_status = strtolower( $posted['payment_status'] ); |
|
| 223 | - $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] ); |
|
| 221 | + // Collect payment details |
|
| 222 | + $payment_status = strtolower( $posted['payment_status'] ); |
|
| 223 | + $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] ); |
|
| 224 | 224 | |
| 225 | - $this->validate_ipn_receiver_email( $invoice, $business_email ); |
|
| 226 | - $this->validate_ipn_currency( $invoice, $posted['mc_currency'] ); |
|
| 225 | + $this->validate_ipn_receiver_email( $invoice, $business_email ); |
|
| 226 | + $this->validate_ipn_currency( $invoice, $posted['mc_currency'] ); |
|
| 227 | 227 | |
| 228 | - // Update the transaction id. |
|
| 229 | - if ( ! empty( $posted['txn_id'] ) ) { |
|
| 230 | - $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) ); |
|
| 231 | - $invoice->save(); |
|
| 232 | - } |
|
| 228 | + // Update the transaction id. |
|
| 229 | + if ( ! empty( $posted['txn_id'] ) ) { |
|
| 230 | + $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) ); |
|
| 231 | + $invoice->save(); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - $invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) ); |
|
| 234 | + $invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) ); |
|
| 235 | 235 | |
| 236 | - // Process a refund. |
|
| 237 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
| 236 | + // Process a refund. |
|
| 237 | + if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
| 238 | 238 | |
| 239 | - update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 ); |
|
| 239 | + update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 ); |
|
| 240 | 240 | |
| 241 | - if ( ! $invoice->is_refunded() ) { |
|
| 242 | - $invoice->update_status( 'wpi-refunded', $posted['reason_code'] ); |
|
| 243 | - } |
|
| 241 | + if ( ! $invoice->is_refunded() ) { |
|
| 242 | + $invoice->update_status( 'wpi-refunded', $posted['reason_code'] ); |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - return wpinv_error_log( $posted['reason_code'], false ); |
|
| 246 | - } |
|
| 245 | + return wpinv_error_log( $posted['reason_code'], false ); |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - // Process payments. |
|
| 249 | - if ( 'completed' === $payment_status ) { |
|
| 248 | + // Process payments. |
|
| 249 | + if ( 'completed' === $payment_status ) { |
|
| 250 | 250 | |
| 251 | - if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) { |
|
| 252 | - return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false ); |
|
| 253 | - } |
|
| 251 | + if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) { |
|
| 252 | + return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false ); |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - $this->validate_ipn_amount( $invoice, $posted['mc_gross'] ); |
|
| 255 | + $this->validate_ipn_amount( $invoice, $posted['mc_gross'] ); |
|
| 256 | 256 | |
| 257 | - $note = ''; |
|
| 257 | + $note = ''; |
|
| 258 | 258 | |
| 259 | - if ( ! empty( $posted['mc_fee'] ) ) { |
|
| 260 | - $note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) ); |
|
| 261 | - } |
|
| 259 | + if ( ! empty( $posted['mc_fee'] ) ) { |
|
| 260 | + $note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) ); |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - if ( ! empty( $posted['payer_status'] ) ) { |
|
| 264 | - $note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) ); |
|
| 265 | - } |
|
| 263 | + if ( ! empty( $posted['payer_status'] ) ) { |
|
| 264 | + $note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) ); |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) ); |
|
| 268 | - return wpinv_error_log( 'Invoice marked as paid.', false ); |
|
| 267 | + $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) ); |
|
| 268 | + return wpinv_error_log( 'Invoice marked as paid.', false ); |
|
| 269 | 269 | |
| 270 | - } |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - // Pending payments. |
|
| 273 | - if ( 'pending' === $payment_status ) { |
|
| 272 | + // Pending payments. |
|
| 273 | + if ( 'pending' === $payment_status ) { |
|
| 274 | 274 | |
| 275 | - /* translators: %s: pending reason. */ |
|
| 276 | - $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) ); |
|
| 275 | + /* translators: %s: pending reason. */ |
|
| 276 | + $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) ); |
|
| 277 | 277 | |
| 278 | - return wpinv_error_log( 'Invoice marked as "payment held".', false ); |
|
| 279 | - } |
|
| 278 | + return wpinv_error_log( 'Invoice marked as "payment held".', false ); |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - /* translators: %s: payment status. */ |
|
| 282 | - $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) ); |
|
| 281 | + /* translators: %s: payment status. */ |
|
| 282 | + $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) ); |
|
| 283 | 283 | |
| 284 | - } |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * Handles one time payments. |
|
| 288 | - * |
|
| 289 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 290 | - * @param array $posted Posted data. |
|
| 291 | - */ |
|
| 292 | - protected function ipn_txn_cart( $invoice, $posted ) { |
|
| 293 | - $this->ipn_txn_web_accept( $invoice, $posted ); |
|
| 294 | - } |
|
| 286 | + /** |
|
| 287 | + * Handles one time payments. |
|
| 288 | + * |
|
| 289 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 290 | + * @param array $posted Posted data. |
|
| 291 | + */ |
|
| 292 | + protected function ipn_txn_cart( $invoice, $posted ) { |
|
| 293 | + $this->ipn_txn_web_accept( $invoice, $posted ); |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - /** |
|
| 297 | - * Handles subscription sign ups. |
|
| 298 | - * |
|
| 299 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 300 | - * @param array $posted Posted data. |
|
| 301 | - */ |
|
| 302 | - protected function ipn_txn_subscr_signup( $invoice, $posted ) { |
|
| 296 | + /** |
|
| 297 | + * Handles subscription sign ups. |
|
| 298 | + * |
|
| 299 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 300 | + * @param array $posted Posted data. |
|
| 301 | + */ |
|
| 302 | + protected function ipn_txn_subscr_signup( $invoice, $posted ) { |
|
| 303 | 303 | |
| 304 | - wpinv_error_log( 'Processing subscription signup', false ); |
|
| 304 | + wpinv_error_log( 'Processing subscription signup', false ); |
|
| 305 | 305 | |
| 306 | - // Make sure the invoice has a subscription. |
|
| 307 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 306 | + // Make sure the invoice has a subscription. |
|
| 307 | + $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 308 | 308 | |
| 309 | - if ( empty( $subscription ) ) { |
|
| 310 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 311 | - } |
|
| 309 | + if ( empty( $subscription ) ) { |
|
| 310 | + return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false ); |
|
| 313 | + wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false ); |
|
| 314 | 314 | |
| 315 | - // Validate the IPN. |
|
| 316 | - $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] ); |
|
| 317 | - $this->validate_ipn_receiver_email( $invoice, $business_email ); |
|
| 318 | - $this->validate_ipn_currency( $invoice, $posted['mc_currency'] ); |
|
| 315 | + // Validate the IPN. |
|
| 316 | + $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] ); |
|
| 317 | + $this->validate_ipn_receiver_email( $invoice, $business_email ); |
|
| 318 | + $this->validate_ipn_currency( $invoice, $posted['mc_currency'] ); |
|
| 319 | 319 | |
| 320 | - // Activate the subscription. |
|
| 321 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
| 322 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 323 | - $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) ); |
|
| 324 | - $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) ); |
|
| 325 | - $subscription->activate(); |
|
| 320 | + // Activate the subscription. |
|
| 321 | + $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
| 322 | + $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 323 | + $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) ); |
|
| 324 | + $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) ); |
|
| 325 | + $subscription->activate(); |
|
| 326 | 326 | |
| 327 | - // Set the transaction id. |
|
| 328 | - if ( ! empty( $posted['txn_id'] ) ) { |
|
| 329 | - $invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true ); |
|
| 330 | - $invoice->set_transaction_id( $posted['txn_id'] ); |
|
| 331 | - } |
|
| 327 | + // Set the transaction id. |
|
| 328 | + if ( ! empty( $posted['txn_id'] ) ) { |
|
| 329 | + $invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true ); |
|
| 330 | + $invoice->set_transaction_id( $posted['txn_id'] ); |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - // Update the payment status. |
|
| 334 | - $invoice->mark_paid(); |
|
| 333 | + // Update the payment status. |
|
| 334 | + $invoice->mark_paid(); |
|
| 335 | 335 | |
| 336 | - $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true ); |
|
| 336 | + $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true ); |
|
| 337 | 337 | |
| 338 | - wpinv_error_log( 'Subscription started.', false ); |
|
| 339 | - } |
|
| 338 | + wpinv_error_log( 'Subscription started.', false ); |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - /** |
|
| 342 | - * Handles subscription renewals. |
|
| 343 | - * |
|
| 344 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 345 | - * @param array $posted Posted data. |
|
| 346 | - */ |
|
| 347 | - protected function ipn_txn_subscr_payment( $invoice, $posted ) { |
|
| 341 | + /** |
|
| 342 | + * Handles subscription renewals. |
|
| 343 | + * |
|
| 344 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 345 | + * @param array $posted Posted data. |
|
| 346 | + */ |
|
| 347 | + protected function ipn_txn_subscr_payment( $invoice, $posted ) { |
|
| 348 | 348 | |
| 349 | - // Make sure the invoice has a subscription. |
|
| 350 | - $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 349 | + // Make sure the invoice has a subscription. |
|
| 350 | + $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 351 | 351 | |
| 352 | - if ( empty( $subscription ) ) { |
|
| 353 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 354 | - } |
|
| 352 | + if ( empty( $subscription ) ) { |
|
| 353 | + return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false ); |
|
| 356 | + wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false ); |
|
| 357 | 357 | |
| 358 | - // PayPal sends a subscr_payment for the first payment too. |
|
| 359 | - $date_completed = getpaid_format_date( $invoice->get_date_completed() ); |
|
| 360 | - $date_created = getpaid_format_date( $invoice->get_date_created() ); |
|
| 361 | - $today_date = getpaid_format_date( current_time( 'mysql' ) ); |
|
| 362 | - $payment_date = getpaid_format_date( $posted['payment_date'] ); |
|
| 363 | - $subscribe_date = getpaid_format_date( $subscription->get_date_created() ); |
|
| 364 | - $dates = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) ); |
|
| 358 | + // PayPal sends a subscr_payment for the first payment too. |
|
| 359 | + $date_completed = getpaid_format_date( $invoice->get_date_completed() ); |
|
| 360 | + $date_created = getpaid_format_date( $invoice->get_date_created() ); |
|
| 361 | + $today_date = getpaid_format_date( current_time( 'mysql' ) ); |
|
| 362 | + $payment_date = getpaid_format_date( $posted['payment_date'] ); |
|
| 363 | + $subscribe_date = getpaid_format_date( $subscription->get_date_created() ); |
|
| 364 | + $dates = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) ); |
|
| 365 | 365 | |
| 366 | - foreach ( $dates as $date ) { |
|
| 366 | + foreach ( $dates as $date ) { |
|
| 367 | 367 | |
| 368 | - if ( $date !== $today_date && $date !== $payment_date ) { |
|
| 369 | - continue; |
|
| 370 | - } |
|
| 368 | + if ( $date !== $today_date && $date !== $payment_date ) { |
|
| 369 | + continue; |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - if ( ! empty( $posted['txn_id'] ) ) { |
|
| 373 | - $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) ); |
|
| 374 | - $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true ); |
|
| 375 | - } |
|
| 372 | + if ( ! empty( $posted['txn_id'] ) ) { |
|
| 373 | + $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) ); |
|
| 374 | + $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true ); |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - return $invoice->mark_paid(); |
|
| 378 | - |
|
| 379 | - } |
|
| 377 | + return $invoice->mark_paid(); |
|
| 378 | + |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false ); |
|
| 382 | - |
|
| 383 | - // Abort if the payment is already recorded. |
|
| 384 | - if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) { |
|
| 385 | - return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false ); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - $args = array( |
|
| 389 | - 'transaction_id' => $posted['txn_id'], |
|
| 390 | - 'gateway' => $this->id, |
|
| 391 | - ); |
|
| 392 | - |
|
| 393 | - $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) ); |
|
| 381 | + wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false ); |
|
| 382 | + |
|
| 383 | + // Abort if the payment is already recorded. |
|
| 384 | + if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) { |
|
| 385 | + return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false ); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + $args = array( |
|
| 389 | + 'transaction_id' => $posted['txn_id'], |
|
| 390 | + 'gateway' => $this->id, |
|
| 391 | + ); |
|
| 392 | + |
|
| 393 | + $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) ); |
|
| 394 | 394 | |
| 395 | - if ( empty( $invoice ) ) { |
|
| 396 | - return; |
|
| 397 | - } |
|
| 395 | + if ( empty( $invoice ) ) { |
|
| 396 | + return; |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true ); |
|
| 400 | - $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true ); |
|
| 399 | + $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true ); |
|
| 400 | + $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true ); |
|
| 401 | 401 | |
| 402 | - $subscription->renew(); |
|
| 403 | - wpinv_error_log( 'Subscription renewed.', false ); |
|
| 402 | + $subscription->renew(); |
|
| 403 | + wpinv_error_log( 'Subscription renewed.', false ); |
|
| 404 | 404 | |
| 405 | - } |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | - /** |
|
| 408 | - * Handles subscription cancelations. |
|
| 409 | - * |
|
| 410 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 411 | - */ |
|
| 412 | - protected function ipn_txn_subscr_cancel( $invoice ) { |
|
| 407 | + /** |
|
| 408 | + * Handles subscription cancelations. |
|
| 409 | + * |
|
| 410 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 411 | + */ |
|
| 412 | + protected function ipn_txn_subscr_cancel( $invoice ) { |
|
| 413 | 413 | |
| 414 | - // Make sure the invoice has a subscription. |
|
| 415 | - $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 416 | - |
|
| 417 | - if ( empty( $subscription ) ) { |
|
| 418 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false ); |
|
| 422 | - $subscription->cancel(); |
|
| 423 | - wpinv_error_log( 'Subscription cancelled.', false ); |
|
| 414 | + // Make sure the invoice has a subscription. |
|
| 415 | + $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 416 | + |
|
| 417 | + if ( empty( $subscription ) ) { |
|
| 418 | + return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false ); |
|
| 422 | + $subscription->cancel(); |
|
| 423 | + wpinv_error_log( 'Subscription cancelled.', false ); |
|
| 424 | 424 | |
| 425 | - } |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | - /** |
|
| 428 | - * Handles subscription completions. |
|
| 429 | - * |
|
| 430 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 431 | - * @param array $posted Posted data. |
|
| 432 | - */ |
|
| 433 | - protected function ipn_txn_subscr_eot( $invoice ) { |
|
| 427 | + /** |
|
| 428 | + * Handles subscription completions. |
|
| 429 | + * |
|
| 430 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 431 | + * @param array $posted Posted data. |
|
| 432 | + */ |
|
| 433 | + protected function ipn_txn_subscr_eot( $invoice ) { |
|
| 434 | 434 | |
| 435 | - // Make sure the invoice has a subscription. |
|
| 436 | - $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 435 | + // Make sure the invoice has a subscription. |
|
| 436 | + $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 437 | 437 | |
| 438 | - if ( empty( $subscription ) ) { |
|
| 439 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 440 | - } |
|
| 438 | + if ( empty( $subscription ) ) { |
|
| 439 | + return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false ); |
|
| 443 | - $subscription->complete(); |
|
| 444 | - wpinv_error_log( 'Subscription completed.', false ); |
|
| 442 | + wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false ); |
|
| 443 | + $subscription->complete(); |
|
| 444 | + wpinv_error_log( 'Subscription completed.', false ); |
|
| 445 | 445 | |
| 446 | - } |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | - /** |
|
| 449 | - * Handles subscription fails. |
|
| 450 | - * |
|
| 451 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 452 | - * @param array $posted Posted data. |
|
| 453 | - */ |
|
| 454 | - protected function ipn_txn_subscr_failed( $invoice ) { |
|
| 448 | + /** |
|
| 449 | + * Handles subscription fails. |
|
| 450 | + * |
|
| 451 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 452 | + * @param array $posted Posted data. |
|
| 453 | + */ |
|
| 454 | + protected function ipn_txn_subscr_failed( $invoice ) { |
|
| 455 | 455 | |
| 456 | - // Make sure the invoice has a subscription. |
|
| 457 | - $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 456 | + // Make sure the invoice has a subscription. |
|
| 457 | + $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 458 | 458 | |
| 459 | - if ( empty( $subscription ) ) { |
|
| 460 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 461 | - } |
|
| 459 | + if ( empty( $subscription ) ) { |
|
| 460 | + return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false ); |
|
| 464 | - $subscription->failing(); |
|
| 465 | - wpinv_error_log( 'Subscription marked as failing.', false ); |
|
| 463 | + wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false ); |
|
| 464 | + $subscription->failing(); |
|
| 465 | + wpinv_error_log( 'Subscription marked as failing.', false ); |
|
| 466 | 466 | |
| 467 | - } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - /** |
|
| 470 | - * Handles subscription suspensions. |
|
| 471 | - * |
|
| 472 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 473 | - * @param array $posted Posted data. |
|
| 474 | - */ |
|
| 475 | - protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) { |
|
| 469 | + /** |
|
| 470 | + * Handles subscription suspensions. |
|
| 471 | + * |
|
| 472 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 473 | + * @param array $posted Posted data. |
|
| 474 | + */ |
|
| 475 | + protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) { |
|
| 476 | 476 | |
| 477 | - // Make sure the invoice has a subscription. |
|
| 478 | - $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 477 | + // Make sure the invoice has a subscription. |
|
| 478 | + $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 479 | 479 | |
| 480 | - if ( empty( $subscription ) ) { |
|
| 481 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false ); |
|
| 485 | - $subscription->cancel(); |
|
| 486 | - wpinv_error_log( 'Subscription cancelled.', false ); |
|
| 487 | - } |
|
| 480 | + if ( empty( $subscription ) ) { |
|
| 481 | + return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false ); |
|
| 485 | + $subscription->cancel(); |
|
| 486 | + wpinv_error_log( 'Subscription cancelled.', false ); |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | 489 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | - exit; // Exit if accessed directly |
|
| 11 | + exit; // Exit if accessed directly |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
@@ -16,85 +16,85 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class GetPaid_Meta_Box_Invoice_Address { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Output the metabox. |
|
| 21 | - * |
|
| 22 | - * @param WP_Post $post |
|
| 23 | - */ |
|
| 24 | - public static function output( $post ) { |
|
| 25 | - |
|
| 26 | - // Prepare the invoice. |
|
| 27 | - $invoice = new WPInv_Invoice( $post ); |
|
| 28 | - $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
| 29 | - $customer = new WP_User( $customer ); |
|
| 30 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
| 31 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 32 | - |
|
| 33 | - // Address fields. |
|
| 34 | - $address_fields = array( |
|
| 35 | - 'first_name' => array( |
|
| 36 | - 'label' => __( 'First Name', 'invoicing' ), |
|
| 37 | - 'type' => 'text', |
|
| 38 | - ), |
|
| 39 | - 'last_name' => array( |
|
| 40 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
| 41 | - 'type' => 'text', |
|
| 42 | - ), |
|
| 43 | - 'company' => array( |
|
| 44 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 45 | - 'type' => 'text', |
|
| 46 | - 'class' => 'getpaid-recalculate-prices-on-change', |
|
| 47 | - ), |
|
| 48 | - 'vat_number' => array( |
|
| 49 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 50 | - 'type' => 'text', |
|
| 51 | - 'class' => 'getpaid-recalculate-prices-on-change', |
|
| 52 | - ), |
|
| 53 | - 'address' => array( |
|
| 54 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 55 | - 'type' => 'text', |
|
| 56 | - ), |
|
| 57 | - 'city' => array( |
|
| 58 | - 'label' => __( 'City', 'invoicing' ), |
|
| 59 | - 'type' => 'text', |
|
| 60 | - ), |
|
| 61 | - 'country' => array( |
|
| 62 | - 'label' => __( 'Country', 'invoicing' ), |
|
| 63 | - 'type' => 'select', |
|
| 64 | - 'class' => 'getpaid-recalculate-prices-on-change', |
|
| 65 | - 'options' => wpinv_get_country_list(), |
|
| 66 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 67 | - ), |
|
| 68 | - 'state' => array( |
|
| 69 | - 'label' => __( 'State', 'invoicing' ), |
|
| 70 | - 'type' => 'text', |
|
| 71 | - 'class' => 'getpaid-recalculate-prices-on-change', |
|
| 72 | - ), |
|
| 73 | - 'zip' => array( |
|
| 74 | - 'label' => __( 'Zip', 'invoicing' ), |
|
| 75 | - 'type' => 'text', |
|
| 76 | - ), |
|
| 77 | - 'phone' => array( |
|
| 78 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 79 | - 'type' => 'text', |
|
| 80 | - ), |
|
| 81 | - ); |
|
| 82 | - |
|
| 83 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
| 84 | - |
|
| 85 | - if ( ! empty( $states ) ) { |
|
| 86 | - $address_fields['state']['type'] = 'select'; |
|
| 87 | - $address_fields['state']['options'] = $states; |
|
| 88 | - $address_fields['state']['placeholder'] = __( 'Choose a state', 'invoicing' ); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - // Maybe remove the VAT field. |
|
| 92 | - if ( ! wpinv_use_taxes() ) { |
|
| 93 | - unset( $address_fields['vat_number'] ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $address_fields = apply_filters( 'getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice ); |
|
| 97 | - ?> |
|
| 19 | + /** |
|
| 20 | + * Output the metabox. |
|
| 21 | + * |
|
| 22 | + * @param WP_Post $post |
|
| 23 | + */ |
|
| 24 | + public static function output( $post ) { |
|
| 25 | + |
|
| 26 | + // Prepare the invoice. |
|
| 27 | + $invoice = new WPInv_Invoice( $post ); |
|
| 28 | + $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
| 29 | + $customer = new WP_User( $customer ); |
|
| 30 | + $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
| 31 | + wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 32 | + |
|
| 33 | + // Address fields. |
|
| 34 | + $address_fields = array( |
|
| 35 | + 'first_name' => array( |
|
| 36 | + 'label' => __( 'First Name', 'invoicing' ), |
|
| 37 | + 'type' => 'text', |
|
| 38 | + ), |
|
| 39 | + 'last_name' => array( |
|
| 40 | + 'label' => __( 'Last Name', 'invoicing' ), |
|
| 41 | + 'type' => 'text', |
|
| 42 | + ), |
|
| 43 | + 'company' => array( |
|
| 44 | + 'label' => __( 'Company', 'invoicing' ), |
|
| 45 | + 'type' => 'text', |
|
| 46 | + 'class' => 'getpaid-recalculate-prices-on-change', |
|
| 47 | + ), |
|
| 48 | + 'vat_number' => array( |
|
| 49 | + 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 50 | + 'type' => 'text', |
|
| 51 | + 'class' => 'getpaid-recalculate-prices-on-change', |
|
| 52 | + ), |
|
| 53 | + 'address' => array( |
|
| 54 | + 'label' => __( 'Address', 'invoicing' ), |
|
| 55 | + 'type' => 'text', |
|
| 56 | + ), |
|
| 57 | + 'city' => array( |
|
| 58 | + 'label' => __( 'City', 'invoicing' ), |
|
| 59 | + 'type' => 'text', |
|
| 60 | + ), |
|
| 61 | + 'country' => array( |
|
| 62 | + 'label' => __( 'Country', 'invoicing' ), |
|
| 63 | + 'type' => 'select', |
|
| 64 | + 'class' => 'getpaid-recalculate-prices-on-change', |
|
| 65 | + 'options' => wpinv_get_country_list(), |
|
| 66 | + 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 67 | + ), |
|
| 68 | + 'state' => array( |
|
| 69 | + 'label' => __( 'State', 'invoicing' ), |
|
| 70 | + 'type' => 'text', |
|
| 71 | + 'class' => 'getpaid-recalculate-prices-on-change', |
|
| 72 | + ), |
|
| 73 | + 'zip' => array( |
|
| 74 | + 'label' => __( 'Zip', 'invoicing' ), |
|
| 75 | + 'type' => 'text', |
|
| 76 | + ), |
|
| 77 | + 'phone' => array( |
|
| 78 | + 'label' => __( 'Phone', 'invoicing' ), |
|
| 79 | + 'type' => 'text', |
|
| 80 | + ), |
|
| 81 | + ); |
|
| 82 | + |
|
| 83 | + $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
| 84 | + |
|
| 85 | + if ( ! empty( $states ) ) { |
|
| 86 | + $address_fields['state']['type'] = 'select'; |
|
| 87 | + $address_fields['state']['options'] = $states; |
|
| 88 | + $address_fields['state']['placeholder'] = __( 'Choose a state', 'invoicing' ); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + // Maybe remove the VAT field. |
|
| 92 | + if ( ! wpinv_use_taxes() ) { |
|
| 93 | + unset( $address_fields['vat_number'] ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $address_fields = apply_filters( 'getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice ); |
|
| 97 | + ?> |
|
| 98 | 98 | |
| 99 | 99 | <style> |
| 100 | 100 | #wpinv-address label { |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | <div id="getpaid-invoice-email-wrapper" class="d-none"> |
| 120 | 120 | <input type="hidden" id="getpaid-invoice-create-new-user" name="wpinv_new_user" value="" /> |
| 121 | 121 | <?php |
| 122 | - aui()->input( |
|
| 123 | - array( |
|
| 124 | - 'type' => 'text', |
|
| 125 | - 'id' => 'getpaid-invoice-new-user-email', |
|
| 126 | - 'name' => 'wpinv_email', |
|
| 127 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
| 128 | - 'label_type' => 'vertical', |
|
| 129 | - 'placeholder' => '[email protected]', |
|
| 130 | - 'class' => 'form-control-sm', |
|
| 131 | - ), |
|
| 132 | - true |
|
| 133 | - ); |
|
| 134 | - ?> |
|
| 122 | + aui()->input( |
|
| 123 | + array( |
|
| 124 | + 'type' => 'text', |
|
| 125 | + 'id' => 'getpaid-invoice-new-user-email', |
|
| 126 | + 'name' => 'wpinv_email', |
|
| 127 | + 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
| 128 | + 'label_type' => 'vertical', |
|
| 129 | + 'placeholder' => '[email protected]', |
|
| 130 | + 'class' => 'form-control-sm', |
|
| 131 | + ), |
|
| 132 | + true |
|
| 133 | + ); |
|
| 134 | + ?> |
|
| 135 | 135 | </div> |
| 136 | 136 | </div> |
| 137 | 137 | <div class="col-12 col-sm-6 form-group mb-3 mt-sm-4"> |
@@ -155,39 +155,39 @@ discard block |
||
| 155 | 155 | <div class="col-12 col-sm-6 getpaid-invoice-address-field__<?php echo esc_attr( $key ); ?>--wrapper"> |
| 156 | 156 | <?php |
| 157 | 157 | |
| 158 | - if ( 'select' === $field['type'] ) { |
|
| 159 | - aui()->select( |
|
| 160 | - array( |
|
| 161 | - 'id' => 'wpinv_' . $key, |
|
| 162 | - 'name' => 'wpinv_' . $key, |
|
| 163 | - 'label' => $field['label'], |
|
| 164 | - 'label_type' => 'vertical', |
|
| 165 | - 'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '', |
|
| 166 | - 'class' => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ), |
|
| 167 | - 'value' => $invoice->get( $key, 'edit' ), |
|
| 168 | - 'options' => $field['options'], |
|
| 169 | - 'data-allow-clear' => 'false', |
|
| 170 | - 'select2' => true, |
|
| 171 | - ), |
|
| 172 | - true |
|
| 173 | - ); |
|
| 174 | - } else { |
|
| 175 | - aui()->input( |
|
| 176 | - array( |
|
| 177 | - 'type' => $field['type'], |
|
| 178 | - 'id' => 'wpinv_' . $key, |
|
| 179 | - 'name' => 'wpinv_' . $key, |
|
| 180 | - 'label' => $field['label'], |
|
| 181 | - 'label_type' => 'vertical', |
|
| 182 | - 'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '', |
|
| 183 | - 'class' => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ), |
|
| 184 | - 'value' => $invoice->get( $key, 'edit' ), |
|
| 185 | - ), |
|
| 186 | - true |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - ?> |
|
| 158 | + if ( 'select' === $field['type'] ) { |
|
| 159 | + aui()->select( |
|
| 160 | + array( |
|
| 161 | + 'id' => 'wpinv_' . $key, |
|
| 162 | + 'name' => 'wpinv_' . $key, |
|
| 163 | + 'label' => $field['label'], |
|
| 164 | + 'label_type' => 'vertical', |
|
| 165 | + 'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '', |
|
| 166 | + 'class' => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ), |
|
| 167 | + 'value' => $invoice->get( $key, 'edit' ), |
|
| 168 | + 'options' => $field['options'], |
|
| 169 | + 'data-allow-clear' => 'false', |
|
| 170 | + 'select2' => true, |
|
| 171 | + ), |
|
| 172 | + true |
|
| 173 | + ); |
|
| 174 | + } else { |
|
| 175 | + aui()->input( |
|
| 176 | + array( |
|
| 177 | + 'type' => $field['type'], |
|
| 178 | + 'id' => 'wpinv_' . $key, |
|
| 179 | + 'name' => 'wpinv_' . $key, |
|
| 180 | + 'label' => $field['label'], |
|
| 181 | + 'label_type' => 'vertical', |
|
| 182 | + 'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '', |
|
| 183 | + 'class' => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ), |
|
| 184 | + 'value' => $invoice->get( $key, 'edit' ), |
|
| 185 | + ), |
|
| 186 | + true |
|
| 187 | + ); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + ?> |
|
| 191 | 191 | </div> |
| 192 | 192 | <?php endforeach; ?> |
| 193 | 193 | </div> |
@@ -198,48 +198,48 @@ discard block |
||
| 198 | 198 | <div class="row"> |
| 199 | 199 | <div class="col-12 col-sm-6"> |
| 200 | 200 | <?php |
| 201 | - aui()->select( |
|
| 202 | - array( |
|
| 203 | - 'id' => 'wpinv_template', |
|
| 204 | - 'name' => 'wpinv_template', |
|
| 205 | - 'label' => __( 'Template', 'invoicing' ), |
|
| 206 | - 'label_type' => 'vertical', |
|
| 207 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
| 208 | - 'class' => 'form-control-sm', |
|
| 209 | - 'value' => $invoice->get_template( 'edit' ), |
|
| 210 | - 'options' => array( |
|
| 211 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 212 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
| 213 | - ), |
|
| 214 | - 'data-allow-clear' => 'false', |
|
| 215 | - 'select2' => true, |
|
| 216 | - ), |
|
| 217 | - true |
|
| 218 | - ); |
|
| 219 | - ?> |
|
| 201 | + aui()->select( |
|
| 202 | + array( |
|
| 203 | + 'id' => 'wpinv_template', |
|
| 204 | + 'name' => 'wpinv_template', |
|
| 205 | + 'label' => __( 'Template', 'invoicing' ), |
|
| 206 | + 'label_type' => 'vertical', |
|
| 207 | + 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
| 208 | + 'class' => 'form-control-sm', |
|
| 209 | + 'value' => $invoice->get_template( 'edit' ), |
|
| 210 | + 'options' => array( |
|
| 211 | + 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 212 | + 'hours' => __( 'Hours', 'invoicing' ), |
|
| 213 | + ), |
|
| 214 | + 'data-allow-clear' => 'false', |
|
| 215 | + 'select2' => true, |
|
| 216 | + ), |
|
| 217 | + true |
|
| 218 | + ); |
|
| 219 | + ?> |
|
| 220 | 220 | </div> |
| 221 | 221 | <div class="col-12 col-sm-6"> |
| 222 | 222 | <?php |
| 223 | 223 | |
| 224 | - // Set currency. |
|
| 225 | - aui()->select( |
|
| 226 | - array( |
|
| 227 | - 'id' => 'wpinv_currency', |
|
| 228 | - 'name' => 'wpinv_currency', |
|
| 229 | - 'label' => __( 'Currency', 'invoicing' ), |
|
| 230 | - 'label_type' => 'vertical', |
|
| 231 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
| 232 | - 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
|
| 233 | - 'value' => $invoice->get_currency( 'edit' ), |
|
| 234 | - 'required' => false, |
|
| 235 | - 'data-allow-clear' => 'false', |
|
| 236 | - 'select2' => true, |
|
| 237 | - 'options' => wpinv_get_currencies(), |
|
| 238 | - ), |
|
| 239 | - true |
|
| 240 | - ); |
|
| 241 | - |
|
| 242 | - ?> |
|
| 224 | + // Set currency. |
|
| 225 | + aui()->select( |
|
| 226 | + array( |
|
| 227 | + 'id' => 'wpinv_currency', |
|
| 228 | + 'name' => 'wpinv_currency', |
|
| 229 | + 'label' => __( 'Currency', 'invoicing' ), |
|
| 230 | + 'label_type' => 'vertical', |
|
| 231 | + 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
| 232 | + 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
|
| 233 | + 'value' => $invoice->get_currency( 'edit' ), |
|
| 234 | + 'required' => false, |
|
| 235 | + 'data-allow-clear' => 'false', |
|
| 236 | + 'select2' => true, |
|
| 237 | + 'options' => wpinv_get_currencies(), |
|
| 238 | + ), |
|
| 239 | + true |
|
| 240 | + ); |
|
| 241 | + |
|
| 242 | + ?> |
|
| 243 | 243 | </div> |
| 244 | 244 | </div> |
| 245 | 245 | |
@@ -249,123 +249,123 @@ discard block |
||
| 249 | 249 | <div class="row"> |
| 250 | 250 | <div class="col-12 col-sm-6"> |
| 251 | 251 | <?php |
| 252 | - aui()->input( |
|
| 253 | - array( |
|
| 254 | - 'type' => 'text', |
|
| 255 | - 'id' => 'wpinv_company_id', |
|
| 256 | - 'name' => 'wpinv_company_id', |
|
| 257 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
| 258 | - 'label_type' => 'vertical', |
|
| 259 | - 'placeholder' => '', |
|
| 260 | - 'class' => 'form-control-sm', |
|
| 261 | - 'value' => $invoice->get_company_id( 'edit' ), |
|
| 262 | - ), |
|
| 263 | - true |
|
| 264 | - ); |
|
| 265 | - ?> |
|
| 252 | + aui()->input( |
|
| 253 | + array( |
|
| 254 | + 'type' => 'text', |
|
| 255 | + 'id' => 'wpinv_company_id', |
|
| 256 | + 'name' => 'wpinv_company_id', |
|
| 257 | + 'label' => __( 'Company ID', 'invoicing' ), |
|
| 258 | + 'label_type' => 'vertical', |
|
| 259 | + 'placeholder' => '', |
|
| 260 | + 'class' => 'form-control-sm', |
|
| 261 | + 'value' => $invoice->get_company_id( 'edit' ), |
|
| 262 | + ), |
|
| 263 | + true |
|
| 264 | + ); |
|
| 265 | + ?> |
|
| 266 | 266 | </div> |
| 267 | 267 | </div> |
| 268 | 268 | |
| 269 | 269 | <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?> |
| 270 | 270 | </div> |
| 271 | 271 | <?php |
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Save meta box data. |
|
| 276 | - * |
|
| 277 | - * @param int $post_id |
|
| 278 | - * @param array $posted the posted data. |
|
| 279 | - */ |
|
| 280 | - public static function save( $post_id, $posted ) { |
|
| 281 | - |
|
| 282 | - // Prepare the invoice. |
|
| 283 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 284 | - |
|
| 285 | - // Load new data. |
|
| 286 | - $invoice->set_props( |
|
| 287 | - array( |
|
| 288 | - 'template' => isset( $posted['wpinv_template'] ) ? wpinv_clean( $posted['wpinv_template'] ) : null, |
|
| 289 | - 'email_cc' => isset( $posted['wpinv_cc'] ) ? wpinv_clean( $posted['wpinv_cc'] ) : null, |
|
| 290 | - 'disable_taxes' => ! empty( $posted['disable_taxes'] ), |
|
| 291 | - 'currency' => isset( $posted['wpinv_currency'] ) ? wpinv_clean( $posted['wpinv_currency'] ) : null, |
|
| 292 | - 'gateway' => ( $invoice->needs_payment() && isset( $posted['wpinv_gateway'] ) ) ? wpinv_clean( $posted['wpinv_gateway'] ) : null, |
|
| 293 | - 'address' => isset( $posted['wpinv_address'] ) ? wpinv_clean( $posted['wpinv_address'] ) : null, |
|
| 294 | - 'vat_number' => isset( $posted['wpinv_vat_number'] ) ? wpinv_clean( $posted['wpinv_vat_number'] ) : null, |
|
| 295 | - 'company' => isset( $posted['wpinv_company'] ) ? wpinv_clean( $posted['wpinv_company'] ) : null, |
|
| 296 | - 'company_id' => isset( $posted['wpinv_company_id'] ) ? wpinv_clean( $posted['wpinv_company_id'] ) : null, |
|
| 297 | - 'zip' => isset( $posted['wpinv_zip'] ) ? wpinv_clean( $posted['wpinv_zip'] ) : null, |
|
| 298 | - 'state' => isset( $posted['wpinv_state'] ) ? wpinv_clean( $posted['wpinv_state'] ) : null, |
|
| 299 | - 'city' => isset( $posted['wpinv_city'] ) ? wpinv_clean( $posted['wpinv_city'] ) : null, |
|
| 300 | - 'country' => isset( $posted['wpinv_country'] ) ? wpinv_clean( $posted['wpinv_country'] ) : null, |
|
| 301 | - 'phone' => isset( $posted['wpinv_phone'] ) ? wpinv_clean( $posted['wpinv_phone'] ) : null, |
|
| 302 | - 'first_name' => isset( $posted['wpinv_first_name'] ) ? wpinv_clean( $posted['wpinv_first_name'] ) : null, |
|
| 303 | - 'last_name' => isset( $posted['wpinv_last_name'] ) ? wpinv_clean( $posted['wpinv_last_name'] ) : null, |
|
| 304 | - 'author' => isset( $posted['post_author_override'] ) ? wpinv_clean( $posted['post_author_override'] ) : null, |
|
| 305 | - 'date_created' => isset( $posted['date_created'] ) ? wpinv_clean( $posted['date_created'] ) : null, |
|
| 306 | - 'date_completed' => isset( $posted['wpinv_date_completed'] ) ? wpinv_clean( $posted['wpinv_date_completed'] ) : null, |
|
| 307 | - 'due_date' => isset( $posted['wpinv_due_date'] ) ? wpinv_clean( $posted['wpinv_due_date'] ) : null, |
|
| 308 | - 'number' => isset( $posted['wpinv_number'] ) ? wpinv_clean( $posted['wpinv_number'] ) : null, |
|
| 309 | - 'status' => isset( $posted['wpinv_status'] ) ? wpinv_clean( $posted['wpinv_status'] ) : null, |
|
| 310 | - ) |
|
| 311 | - ); |
|
| 312 | - |
|
| 313 | - // Discount code. |
|
| 314 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 315 | - |
|
| 316 | - if ( isset( $posted['wpinv_discount_code'] ) ) { |
|
| 317 | - $invoice->set_discount_code( wpinv_clean( $posted['wpinv_discount_code'] ) ); |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 321 | - if ( $discount->exists() ) { |
|
| 322 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 323 | - } else { |
|
| 324 | - $invoice->remove_discount( 'discount_code' ); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - // Recalculate totals. |
|
| 328 | - $invoice->recalculate_total(); |
|
| 329 | - |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - // If we're creating a new user... |
|
| 333 | - if ( ! empty( $posted['wpinv_new_user'] ) && is_email( stripslashes( $posted['wpinv_email'] ) ) ) { |
|
| 334 | - |
|
| 335 | - // Attempt to create the user. |
|
| 336 | - $user = wpinv_create_user( sanitize_email( stripslashes( $posted['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() ); |
|
| 337 | - |
|
| 338 | - // If successful, update the invoice author. |
|
| 339 | - if ( is_numeric( $user ) ) { |
|
| 340 | - $invoice->set_author( $user ); |
|
| 341 | - } else { |
|
| 342 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
| 343 | - } |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - // Do not send new invoice notifications. |
|
| 347 | - $GLOBALS['wpinv_skip_invoice_notification'] = true; |
|
| 348 | - |
|
| 349 | - // Save the invoice. |
|
| 350 | - $invoice->save(); |
|
| 351 | - |
|
| 352 | - // Save the user address. |
|
| 353 | - getpaid_save_invoice_user_address( $invoice ); |
|
| 354 | - |
|
| 355 | - // Undo do not send new invoice notifications. |
|
| 356 | - $GLOBALS['wpinv_skip_invoice_notification'] = false; |
|
| 357 | - |
|
| 358 | - // (Maybe) send new user notification. |
|
| 359 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
| 360 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
| 361 | - wp_send_new_user_notifications( $user, 'user' ); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - if ( ! empty( $posted['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
| 365 | - getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - // Fires after an invoice is saved. |
|
| 369 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
| 370 | - } |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Save meta box data. |
|
| 276 | + * |
|
| 277 | + * @param int $post_id |
|
| 278 | + * @param array $posted the posted data. |
|
| 279 | + */ |
|
| 280 | + public static function save( $post_id, $posted ) { |
|
| 281 | + |
|
| 282 | + // Prepare the invoice. |
|
| 283 | + $invoice = new WPInv_Invoice( $post_id ); |
|
| 284 | + |
|
| 285 | + // Load new data. |
|
| 286 | + $invoice->set_props( |
|
| 287 | + array( |
|
| 288 | + 'template' => isset( $posted['wpinv_template'] ) ? wpinv_clean( $posted['wpinv_template'] ) : null, |
|
| 289 | + 'email_cc' => isset( $posted['wpinv_cc'] ) ? wpinv_clean( $posted['wpinv_cc'] ) : null, |
|
| 290 | + 'disable_taxes' => ! empty( $posted['disable_taxes'] ), |
|
| 291 | + 'currency' => isset( $posted['wpinv_currency'] ) ? wpinv_clean( $posted['wpinv_currency'] ) : null, |
|
| 292 | + 'gateway' => ( $invoice->needs_payment() && isset( $posted['wpinv_gateway'] ) ) ? wpinv_clean( $posted['wpinv_gateway'] ) : null, |
|
| 293 | + 'address' => isset( $posted['wpinv_address'] ) ? wpinv_clean( $posted['wpinv_address'] ) : null, |
|
| 294 | + 'vat_number' => isset( $posted['wpinv_vat_number'] ) ? wpinv_clean( $posted['wpinv_vat_number'] ) : null, |
|
| 295 | + 'company' => isset( $posted['wpinv_company'] ) ? wpinv_clean( $posted['wpinv_company'] ) : null, |
|
| 296 | + 'company_id' => isset( $posted['wpinv_company_id'] ) ? wpinv_clean( $posted['wpinv_company_id'] ) : null, |
|
| 297 | + 'zip' => isset( $posted['wpinv_zip'] ) ? wpinv_clean( $posted['wpinv_zip'] ) : null, |
|
| 298 | + 'state' => isset( $posted['wpinv_state'] ) ? wpinv_clean( $posted['wpinv_state'] ) : null, |
|
| 299 | + 'city' => isset( $posted['wpinv_city'] ) ? wpinv_clean( $posted['wpinv_city'] ) : null, |
|
| 300 | + 'country' => isset( $posted['wpinv_country'] ) ? wpinv_clean( $posted['wpinv_country'] ) : null, |
|
| 301 | + 'phone' => isset( $posted['wpinv_phone'] ) ? wpinv_clean( $posted['wpinv_phone'] ) : null, |
|
| 302 | + 'first_name' => isset( $posted['wpinv_first_name'] ) ? wpinv_clean( $posted['wpinv_first_name'] ) : null, |
|
| 303 | + 'last_name' => isset( $posted['wpinv_last_name'] ) ? wpinv_clean( $posted['wpinv_last_name'] ) : null, |
|
| 304 | + 'author' => isset( $posted['post_author_override'] ) ? wpinv_clean( $posted['post_author_override'] ) : null, |
|
| 305 | + 'date_created' => isset( $posted['date_created'] ) ? wpinv_clean( $posted['date_created'] ) : null, |
|
| 306 | + 'date_completed' => isset( $posted['wpinv_date_completed'] ) ? wpinv_clean( $posted['wpinv_date_completed'] ) : null, |
|
| 307 | + 'due_date' => isset( $posted['wpinv_due_date'] ) ? wpinv_clean( $posted['wpinv_due_date'] ) : null, |
|
| 308 | + 'number' => isset( $posted['wpinv_number'] ) ? wpinv_clean( $posted['wpinv_number'] ) : null, |
|
| 309 | + 'status' => isset( $posted['wpinv_status'] ) ? wpinv_clean( $posted['wpinv_status'] ) : null, |
|
| 310 | + ) |
|
| 311 | + ); |
|
| 312 | + |
|
| 313 | + // Discount code. |
|
| 314 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 315 | + |
|
| 316 | + if ( isset( $posted['wpinv_discount_code'] ) ) { |
|
| 317 | + $invoice->set_discount_code( wpinv_clean( $posted['wpinv_discount_code'] ) ); |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 321 | + if ( $discount->exists() ) { |
|
| 322 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 323 | + } else { |
|
| 324 | + $invoice->remove_discount( 'discount_code' ); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + // Recalculate totals. |
|
| 328 | + $invoice->recalculate_total(); |
|
| 329 | + |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + // If we're creating a new user... |
|
| 333 | + if ( ! empty( $posted['wpinv_new_user'] ) && is_email( stripslashes( $posted['wpinv_email'] ) ) ) { |
|
| 334 | + |
|
| 335 | + // Attempt to create the user. |
|
| 336 | + $user = wpinv_create_user( sanitize_email( stripslashes( $posted['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() ); |
|
| 337 | + |
|
| 338 | + // If successful, update the invoice author. |
|
| 339 | + if ( is_numeric( $user ) ) { |
|
| 340 | + $invoice->set_author( $user ); |
|
| 341 | + } else { |
|
| 342 | + wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + // Do not send new invoice notifications. |
|
| 347 | + $GLOBALS['wpinv_skip_invoice_notification'] = true; |
|
| 348 | + |
|
| 349 | + // Save the invoice. |
|
| 350 | + $invoice->save(); |
|
| 351 | + |
|
| 352 | + // Save the user address. |
|
| 353 | + getpaid_save_invoice_user_address( $invoice ); |
|
| 354 | + |
|
| 355 | + // Undo do not send new invoice notifications. |
|
| 356 | + $GLOBALS['wpinv_skip_invoice_notification'] = false; |
|
| 357 | + |
|
| 358 | + // (Maybe) send new user notification. |
|
| 359 | + $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
| 360 | + if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
| 361 | + wp_send_new_user_notifications( $user, 'user' ); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + if ( ! empty( $posted['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
| 365 | + getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + // Fires after an invoice is saved. |
|
| 369 | + do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
| 370 | + } |
|
| 371 | 371 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function wpinv_subscriptions_page() { |
| 16 | 16 | |
| 17 | - ?> |
|
| 17 | + ?> |
|
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,28 +22,28 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | - // Verify user permissions. |
|
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 25 | + // Verify user permissions. |
|
| 26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 27 | 27 | |
| 28 | - aui()->alert( |
|
| 28 | + aui()->alert( |
|
| 29 | 29 | array( |
| 30 | - 'type' => 'danger', |
|
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | - ), |
|
| 33 | - true |
|
| 30 | + 'type' => 'danger', |
|
| 31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | + ), |
|
| 33 | + true |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | + } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 37 | 37 | |
| 38 | - // Display a single subscription. |
|
| 39 | - wpinv_recurring_subscription_details(); |
|
| 40 | - } else { |
|
| 38 | + // Display a single subscription. |
|
| 39 | + wpinv_recurring_subscription_details(); |
|
| 40 | + } else { |
|
| 41 | 41 | |
| 42 | - // Display a list of available subscriptions. |
|
| 43 | - getpaid_print_subscriptions_list(); |
|
| 44 | - } |
|
| 42 | + // Display a list of available subscriptions. |
|
| 43 | + getpaid_print_subscriptions_list(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - ?> |
|
| 46 | + ?> |
|
| 47 | 47 | |
| 48 | 48 | </div> |
| 49 | 49 | </div> |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function getpaid_print_subscriptions_list() { |
| 62 | 62 | |
| 63 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 64 | - $subscribers_table->prepare_items(); |
|
| 63 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 64 | + $subscribers_table->prepare_items(); |
|
| 65 | 65 | |
| 66 | - ?> |
|
| 66 | + ?> |
|
| 67 | 67 | <?php $subscribers_table->views(); ?> |
| 68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
| 69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -82,42 +82,42 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function wpinv_recurring_subscription_details() { |
| 84 | 84 | |
| 85 | - // Fetch the subscription. |
|
| 86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | - if ( ! $sub->exists() ) { |
|
| 85 | + // Fetch the subscription. |
|
| 86 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | + if ( ! $sub->exists() ) { |
|
| 88 | 88 | |
| 89 | - aui()->alert( |
|
| 90 | - array( |
|
| 91 | - 'type' => 'danger', |
|
| 92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 93 | - ), |
|
| 94 | - true |
|
| 95 | - ); |
|
| 89 | + aui()->alert( |
|
| 90 | + array( |
|
| 91 | + 'type' => 'danger', |
|
| 92 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 93 | + ), |
|
| 94 | + true |
|
| 95 | + ); |
|
| 96 | 96 | |
| 97 | - return; |
|
| 98 | - } |
|
| 97 | + return; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - // Use metaboxes to display the subscription details. |
|
| 101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 100 | + // Use metaboxes to display the subscription details. |
|
| 101 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 103 | 103 | |
| 104 | - $subscription_id = $sub->get_id(); |
|
| 105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 104 | + $subscription_id = $sub->get_id(); |
|
| 105 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 107 | 107 | |
| 108 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 110 | - } |
|
| 108 | + if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - if ( ! empty( $subscription_group ) ) { |
|
| 113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 114 | - } |
|
| 112 | + if ( ! empty( $subscription_group ) ) { |
|
| 113 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 116 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 117 | 117 | |
| 118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 118 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 119 | 119 | |
| 120 | - ?> |
|
| 120 | + ?> |
|
| 121 | 121 | |
| 122 | 122 | <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
| 123 | 123 | |
@@ -157,49 +157,49 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | function getpaid_admin_subscription_details_metabox( $sub ) { |
| 159 | 159 | |
| 160 | - // Subscription items. |
|
| 161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 163 | - |
|
| 164 | - // Prepare subscription detail columns. |
|
| 165 | - $fields = apply_filters( |
|
| 166 | - 'getpaid_subscription_admin_page_fields', |
|
| 167 | - array( |
|
| 168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | - 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
| 174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 178 | - ) |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - if ( ! $sub->is_active() ) { |
|
| 182 | - |
|
| 183 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | - unset( $fields['renews_on'] ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - if ( isset( $fields['gateway'] ) ) { |
|
| 188 | - unset( $fields['gateway'] ); |
|
| 189 | - } |
|
| 190 | - } elseif ( $sub->is_last_renewal() ) { |
|
| 191 | - |
|
| 192 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 193 | - $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $profile_id = $sub->get_profile_id(); |
|
| 198 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 199 | - unset( $fields['profile_id'] ); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - ?> |
|
| 160 | + // Subscription items. |
|
| 161 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 163 | + |
|
| 164 | + // Prepare subscription detail columns. |
|
| 165 | + $fields = apply_filters( |
|
| 166 | + 'getpaid_subscription_admin_page_fields', |
|
| 167 | + array( |
|
| 168 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | + 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
| 174 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 175 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 178 | + ) |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + if ( ! $sub->is_active() ) { |
|
| 182 | + |
|
| 183 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | + unset( $fields['renews_on'] ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + if ( isset( $fields['gateway'] ) ) { |
|
| 188 | + unset( $fields['gateway'] ); |
|
| 189 | + } |
|
| 190 | + } elseif ( $sub->is_last_renewal() ) { |
|
| 191 | + |
|
| 192 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 193 | + $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $profile_id = $sub->get_profile_id(); |
|
| 198 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 199 | + unset( $fields['profile_id'] ); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + ?> |
|
| 203 | 203 | |
| 204 | 204 | <table class="table table-borderless" style="font-size: 14px;"> |
| 205 | 205 | <tbody> |
@@ -233,20 +233,20 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
| 235 | 235 | |
| 236 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 236 | + $username = __( '(Missing User)', 'invoicing' ); |
|
| 237 | 237 | |
| 238 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 239 | - if ( $user ) { |
|
| 238 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
| 239 | + if ( $user ) { |
|
| 240 | 240 | |
| 241 | - $username = sprintf( |
|
| 242 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 243 | - absint( $user->ID ), |
|
| 244 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 245 | - ); |
|
| 241 | + $username = sprintf( |
|
| 242 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 243 | + absint( $user->ID ), |
|
| 244 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 245 | + ); |
|
| 246 | 246 | |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - echo wp_kses_post( $username ); |
|
| 249 | + echo wp_kses_post( $username ); |
|
| 250 | 250 | } |
| 251 | 251 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
| 252 | 252 | |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | * @param WPInv_Subscription $subscription |
| 257 | 257 | */ |
| 258 | 258 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
| 259 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 260 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
| 259 | + $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 260 | + echo wp_kses_post( "<span>$amount</span>" ); |
|
| 261 | 261 | } |
| 262 | 262 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
| 263 | 263 | |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
| 270 | 270 | |
| 271 | - printf( |
|
| 272 | - '<a href="%s">#%s</a>', |
|
| 273 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 274 | - absint( $subscription->get_id() ) |
|
| 275 | - ); |
|
| 271 | + printf( |
|
| 272 | + '<a href="%s">#%s</a>', |
|
| 273 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 274 | + absint( $subscription->get_id() ) |
|
| 275 | + ); |
|
| 276 | 276 | |
| 277 | 277 | } |
| 278 | 278 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -284,24 +284,24 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
| 286 | 286 | |
| 287 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 288 | - aui()->input( |
|
| 289 | - array( |
|
| 290 | - 'type' => 'text', |
|
| 291 | - 'id' => 'wpinv_subscription_date_created', |
|
| 292 | - 'name' => 'wpinv_subscription_date_created', |
|
| 293 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 294 | - 'label_type' => 'hidden', |
|
| 295 | - 'placeholder' => 'YYYY-MM-DD', |
|
| 296 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 297 | - 'no_wrap' => true, |
|
| 298 | - 'size' => 'sm', |
|
| 299 | - ), |
|
| 300 | - true |
|
| 301 | - ); |
|
| 302 | - } else { |
|
| 303 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 304 | - } |
|
| 287 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 288 | + aui()->input( |
|
| 289 | + array( |
|
| 290 | + 'type' => 'text', |
|
| 291 | + 'id' => 'wpinv_subscription_date_created', |
|
| 292 | + 'name' => 'wpinv_subscription_date_created', |
|
| 293 | + 'label' => __( 'Start Date', 'invoicing' ), |
|
| 294 | + 'label_type' => 'hidden', |
|
| 295 | + 'placeholder' => 'YYYY-MM-DD', |
|
| 296 | + 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 297 | + 'no_wrap' => true, |
|
| 298 | + 'size' => 'sm', |
|
| 299 | + ), |
|
| 300 | + true |
|
| 301 | + ); |
|
| 302 | + } else { |
|
| 303 | + echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | 306 | } |
| 307 | 307 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
@@ -313,24 +313,24 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
| 315 | 315 | |
| 316 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 317 | - aui()->input( |
|
| 318 | - array( |
|
| 319 | - 'type' => 'text', |
|
| 320 | - 'id' => 'wpinv_subscription_expiration', |
|
| 321 | - 'name' => 'wpinv_subscription_expiration', |
|
| 322 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 323 | - 'label_type' => 'hidden', |
|
| 324 | - 'placeholder' => 'YYYY-MM-DD', |
|
| 325 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 326 | - 'no_wrap' => true, |
|
| 327 | - 'size' => 'sm', |
|
| 328 | - ), |
|
| 329 | - true |
|
| 330 | - ); |
|
| 331 | - } else { |
|
| 332 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 333 | - } |
|
| 316 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 317 | + aui()->input( |
|
| 318 | + array( |
|
| 319 | + 'type' => 'text', |
|
| 320 | + 'id' => 'wpinv_subscription_expiration', |
|
| 321 | + 'name' => 'wpinv_subscription_expiration', |
|
| 322 | + 'label' => __( 'Renews On', 'invoicing' ), |
|
| 323 | + 'label_type' => 'hidden', |
|
| 324 | + 'placeholder' => 'YYYY-MM-DD', |
|
| 325 | + 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 326 | + 'no_wrap' => true, |
|
| 327 | + 'size' => 'sm', |
|
| 328 | + ), |
|
| 329 | + true |
|
| 330 | + ); |
|
| 331 | + } else { |
|
| 332 | + echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 333 | + } |
|
| 334 | 334 | } |
| 335 | 335 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
| 336 | 336 | |
@@ -341,32 +341,32 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
| 343 | 343 | |
| 344 | - $max_bills = $subscription->get_bill_times(); |
|
| 345 | - $times_billed = (int) $subscription->get_times_billed(); |
|
| 346 | - |
|
| 347 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
| 348 | - aui()->input( |
|
| 349 | - array( |
|
| 350 | - 'type' => 'number', |
|
| 351 | - 'id' => 'wpinv_subscription_max_bill_times', |
|
| 352 | - 'name' => 'wpinv_subscription_max_bill_times', |
|
| 353 | - 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
| 354 | - 'label_type' => 'hidden', |
|
| 355 | - 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
| 356 | - 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
| 357 | - 'no_wrap' => true, |
|
| 358 | - 'size' => 'sm', |
|
| 359 | - 'input_group_left' => sprintf( |
|
| 360 | - // translators: %d: Number of times billed |
|
| 361 | - __( '%d of', 'invoicing' ), |
|
| 362 | - $times_billed |
|
| 363 | - ), |
|
| 364 | - ), |
|
| 365 | - true |
|
| 366 | - ); |
|
| 367 | - } else { |
|
| 368 | - echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 369 | - } |
|
| 344 | + $max_bills = $subscription->get_bill_times(); |
|
| 345 | + $times_billed = (int) $subscription->get_times_billed(); |
|
| 346 | + |
|
| 347 | + if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
| 348 | + aui()->input( |
|
| 349 | + array( |
|
| 350 | + 'type' => 'number', |
|
| 351 | + 'id' => 'wpinv_subscription_max_bill_times', |
|
| 352 | + 'name' => 'wpinv_subscription_max_bill_times', |
|
| 353 | + 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
| 354 | + 'label_type' => 'hidden', |
|
| 355 | + 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
| 356 | + 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
| 357 | + 'no_wrap' => true, |
|
| 358 | + 'size' => 'sm', |
|
| 359 | + 'input_group_left' => sprintf( |
|
| 360 | + // translators: %d: Number of times billed |
|
| 361 | + __( '%d of', 'invoicing' ), |
|
| 362 | + $times_billed |
|
| 363 | + ), |
|
| 364 | + ), |
|
| 365 | + true |
|
| 366 | + ); |
|
| 367 | + } else { |
|
| 368 | + echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
| 372 | 372 | |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
| 380 | 380 | |
| 381 | - if ( empty( $subscription_group ) ) { |
|
| 382 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 383 | - return; |
|
| 384 | - } |
|
| 381 | + if ( empty( $subscription_group ) ) { |
|
| 382 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 383 | + return; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 387 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 386 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 387 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 388 | 388 | |
| 389 | 389 | } |
| 390 | 390 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -396,13 +396,13 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
| 398 | 398 | |
| 399 | - $gateway = $subscription->get_gateway(); |
|
| 399 | + $gateway = $subscription->get_gateway(); |
|
| 400 | 400 | |
| 401 | - if ( ! empty( $gateway ) ) { |
|
| 402 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 403 | - } else { |
|
| 404 | - echo '—'; |
|
| 405 | - } |
|
| 401 | + if ( ! empty( $gateway ) ) { |
|
| 402 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 403 | + } else { |
|
| 404 | + echo '—'; |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | 407 | } |
| 408 | 408 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @param WPInv_Subscription $subscription |
| 414 | 414 | */ |
| 415 | 415 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
| 416 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 416 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 417 | 417 | } |
| 418 | 418 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
| 419 | 419 | |
@@ -424,28 +424,28 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
| 426 | 426 | |
| 427 | - $profile_id = $subscription->get_profile_id(); |
|
| 428 | - |
|
| 429 | - aui()->input( |
|
| 430 | - array( |
|
| 431 | - 'type' => 'text', |
|
| 432 | - 'id' => 'wpinv_subscription_profile_id', |
|
| 433 | - 'name' => 'wpinv_subscription_profile_id', |
|
| 434 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 435 | - 'label_type' => 'hidden', |
|
| 436 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 437 | - 'value' => esc_attr( $profile_id ), |
|
| 438 | - 'input_group_right' => '', |
|
| 439 | - 'no_wrap' => true, |
|
| 440 | - 'size' => 'sm', |
|
| 441 | - ), |
|
| 442 | - true |
|
| 443 | - ); |
|
| 444 | - |
|
| 445 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 446 | - if ( ! empty( $url ) ) { |
|
| 447 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 448 | - } |
|
| 427 | + $profile_id = $subscription->get_profile_id(); |
|
| 428 | + |
|
| 429 | + aui()->input( |
|
| 430 | + array( |
|
| 431 | + 'type' => 'text', |
|
| 432 | + 'id' => 'wpinv_subscription_profile_id', |
|
| 433 | + 'name' => 'wpinv_subscription_profile_id', |
|
| 434 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 435 | + 'label_type' => 'hidden', |
|
| 436 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 437 | + 'value' => esc_attr( $profile_id ), |
|
| 438 | + 'input_group_right' => '', |
|
| 439 | + 'no_wrap' => true, |
|
| 440 | + 'size' => 'sm', |
|
| 441 | + ), |
|
| 442 | + true |
|
| 443 | + ); |
|
| 444 | + |
|
| 445 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 446 | + if ( ! empty( $url ) ) { |
|
| 447 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | } |
| 451 | 451 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -457,40 +457,40 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
| 459 | 459 | |
| 460 | - ?> |
|
| 460 | + ?> |
|
| 461 | 461 | <div class="mt-3"> |
| 462 | 462 | |
| 463 | 463 | <?php |
| 464 | - aui()->select( |
|
| 465 | - array( |
|
| 466 | - 'options' => getpaid_get_subscription_statuses(), |
|
| 467 | - 'name' => 'subscription_status', |
|
| 468 | - 'id' => 'subscription_status_update_select', |
|
| 469 | - 'required' => true, |
|
| 470 | - 'no_wrap' => false, |
|
| 471 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 472 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 473 | - 'select2' => true, |
|
| 474 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 475 | - ), |
|
| 476 | - true |
|
| 477 | - ); |
|
| 478 | - ?> |
|
| 464 | + aui()->select( |
|
| 465 | + array( |
|
| 466 | + 'options' => getpaid_get_subscription_statuses(), |
|
| 467 | + 'name' => 'subscription_status', |
|
| 468 | + 'id' => 'subscription_status_update_select', |
|
| 469 | + 'required' => true, |
|
| 470 | + 'no_wrap' => false, |
|
| 471 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 472 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 473 | + 'select2' => true, |
|
| 474 | + 'value' => $subscription->get_status( 'edit' ), |
|
| 475 | + ), |
|
| 476 | + true |
|
| 477 | + ); |
|
| 478 | + ?> |
|
| 479 | 479 | |
| 480 | 480 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 481 | 481 | |
| 482 | 482 | <?php |
| 483 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 483 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 484 | 484 | |
| 485 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 486 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 487 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 485 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 486 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 487 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 488 | 488 | |
| 489 | - if ( $subscription->is_active() ) { |
|
| 490 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 491 | - } |
|
| 489 | + if ( $subscription->is_active() ) { |
|
| 490 | + echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | - echo '</div></div>'; |
|
| 493 | + echo '</div></div>'; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
@@ -501,33 +501,33 @@ discard block |
||
| 501 | 501 | */ |
| 502 | 502 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
| 503 | 503 | |
| 504 | - $columns = apply_filters( |
|
| 505 | - 'getpaid_subscription_related_invoices_columns', |
|
| 506 | - array( |
|
| 507 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 508 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 509 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 510 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 511 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 512 | - ), |
|
| 513 | - $subscription |
|
| 514 | - ); |
|
| 515 | - |
|
| 516 | - // Prepare the invoices. |
|
| 517 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 518 | - $parent = $subscription->get_parent_invoice(); |
|
| 519 | - |
|
| 520 | - if ( $parent->exists() ) { |
|
| 521 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - $table_class = 'w-100 bg-white'; |
|
| 525 | - |
|
| 526 | - if ( ! is_admin() ) { |
|
| 527 | - $table_class = 'table table-bordered'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - ?> |
|
| 504 | + $columns = apply_filters( |
|
| 505 | + 'getpaid_subscription_related_invoices_columns', |
|
| 506 | + array( |
|
| 507 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 508 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 509 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 510 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 511 | + 'total' => __( 'Total', 'invoicing' ), |
|
| 512 | + ), |
|
| 513 | + $subscription |
|
| 514 | + ); |
|
| 515 | + |
|
| 516 | + // Prepare the invoices. |
|
| 517 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 518 | + $parent = $subscription->get_parent_invoice(); |
|
| 519 | + |
|
| 520 | + if ( $parent->exists() ) { |
|
| 521 | + $payments = array_merge( array( $parent ), $payments ); |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + $table_class = 'w-100 bg-white'; |
|
| 525 | + |
|
| 526 | + if ( ! is_admin() ) { |
|
| 527 | + $table_class = 'table table-bordered'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + ?> |
|
| 531 | 531 | <div class="m-0" style="overflow: auto;"> |
| 532 | 532 | |
| 533 | 533 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -535,10 +535,10 @@ discard block |
||
| 535 | 535 | <thead> |
| 536 | 536 | <tr> |
| 537 | 537 | <?php |
| 538 | - foreach ( $columns as $key => $label ) { |
|
| 539 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 540 | - } |
|
| 541 | - ?> |
|
| 538 | + foreach ( $columns as $key => $label ) { |
|
| 539 | + echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 540 | + } |
|
| 541 | + ?> |
|
| 542 | 542 | </tr> |
| 543 | 543 | </thead> |
| 544 | 544 | |
@@ -554,72 +554,72 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | <?php |
| 556 | 556 | |
| 557 | - foreach ( $payments as $payment ) : |
|
| 557 | + foreach ( $payments as $payment ) : |
|
| 558 | 558 | |
| 559 | - // Ensure that we have an invoice. |
|
| 560 | - $payment = new WPInv_Invoice( $payment ); |
|
| 559 | + // Ensure that we have an invoice. |
|
| 560 | + $payment = new WPInv_Invoice( $payment ); |
|
| 561 | 561 | |
| 562 | - // Abort if the invoice is invalid... |
|
| 563 | - if ( ! $payment->exists() ) { |
|
| 564 | - continue; |
|
| 565 | - } |
|
| 562 | + // Abort if the invoice is invalid... |
|
| 563 | + if ( ! $payment->exists() ) { |
|
| 564 | + continue; |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - // ... or belongs to a different subscription. |
|
| 568 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 569 | - continue; |
|
| 570 | - } |
|
| 567 | + // ... or belongs to a different subscription. |
|
| 568 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 569 | + continue; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - echo '<tr>'; |
|
| 572 | + echo '<tr>'; |
|
| 573 | 573 | |
| 574 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 574 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 575 | 575 | |
| 576 | - echo "<td class='p-2 text-left'>"; |
|
| 576 | + echo "<td class='p-2 text-left'>"; |
|
| 577 | 577 | |
| 578 | - switch ( $key ) { |
|
| 578 | + switch ( $key ) { |
|
| 579 | 579 | |
| 580 | - case 'total': |
|
| 581 | - echo '<strong>'; |
|
| 582 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 583 | - echo '</strong>'; |
|
| 584 | - break; |
|
| 580 | + case 'total': |
|
| 581 | + echo '<strong>'; |
|
| 582 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 583 | + echo '</strong>'; |
|
| 584 | + break; |
|
| 585 | 585 | |
| 586 | - case 'relationship': |
|
| 587 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 588 | - break; |
|
| 586 | + case 'relationship': |
|
| 587 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 588 | + break; |
|
| 589 | 589 | |
| 590 | - case 'date': |
|
| 591 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 592 | - break; |
|
| 590 | + case 'date': |
|
| 591 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 592 | + break; |
|
| 593 | 593 | |
| 594 | - case 'status': |
|
| 595 | - $status = $payment->get_status_nicename(); |
|
| 596 | - if ( is_admin() ) { |
|
| 597 | - $status = $payment->get_status_label_html(); |
|
| 598 | - } |
|
| 594 | + case 'status': |
|
| 595 | + $status = $payment->get_status_nicename(); |
|
| 596 | + if ( is_admin() ) { |
|
| 597 | + $status = $payment->get_status_label_html(); |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - echo wp_kses_post( $status ); |
|
| 601 | - break; |
|
| 600 | + echo wp_kses_post( $status ); |
|
| 601 | + break; |
|
| 602 | 602 | |
| 603 | - case 'invoice': |
|
| 604 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 603 | + case 'invoice': |
|
| 604 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 605 | 605 | |
| 606 | - if ( ! is_admin() ) { |
|
| 607 | - $link = esc_url( $payment->get_view_url() ); |
|
| 608 | - } |
|
| 606 | + if ( ! is_admin() ) { |
|
| 607 | + $link = esc_url( $payment->get_view_url() ); |
|
| 608 | + } |
|
| 609 | 609 | |
| 610 | - $invoice = esc_html( $payment->get_number() ); |
|
| 611 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 612 | - break; |
|
| 613 | - } |
|
| 610 | + $invoice = esc_html( $payment->get_number() ); |
|
| 611 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 612 | + break; |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - echo '</td>'; |
|
| 615 | + echo '</td>'; |
|
| 616 | 616 | |
| 617 | - } |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | - echo '</tr>'; |
|
| 619 | + echo '</tr>'; |
|
| 620 | 620 | |
| 621 | - endforeach; |
|
| 622 | - ?> |
|
| 621 | + endforeach; |
|
| 622 | + ?> |
|
| 623 | 623 | |
| 624 | 624 | </tbody> |
| 625 | 625 | |
@@ -637,42 +637,42 @@ discard block |
||
| 637 | 637 | */ |
| 638 | 638 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
| 639 | 639 | |
| 640 | - // Fetch the subscription group. |
|
| 641 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 640 | + // Fetch the subscription group. |
|
| 641 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 642 | 642 | |
| 643 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 644 | - return; |
|
| 645 | - } |
|
| 643 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 644 | + return; |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | - // Prepare table columns. |
|
| 648 | - $columns = apply_filters( |
|
| 649 | - 'getpaid_subscription_item_details_columns', |
|
| 650 | - array( |
|
| 651 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 652 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 653 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 654 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 655 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 656 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 657 | - ), |
|
| 658 | - $subscription |
|
| 659 | - ); |
|
| 647 | + // Prepare table columns. |
|
| 648 | + $columns = apply_filters( |
|
| 649 | + 'getpaid_subscription_item_details_columns', |
|
| 650 | + array( |
|
| 651 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
| 652 | + 'price' => __( 'Price', 'invoicing' ), |
|
| 653 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
| 654 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
| 655 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 656 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 657 | + ), |
|
| 658 | + $subscription |
|
| 659 | + ); |
|
| 660 | 660 | |
| 661 | - // Prepare the invoices. |
|
| 661 | + // Prepare the invoices. |
|
| 662 | 662 | |
| 663 | - $invoice = $subscription->get_parent_invoice(); |
|
| 663 | + $invoice = $subscription->get_parent_invoice(); |
|
| 664 | 664 | |
| 665 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 666 | - unset( $columns['tax'] ); |
|
| 667 | - } |
|
| 665 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 666 | + unset( $columns['tax'] ); |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | - $table_class = 'w-100 bg-white'; |
|
| 669 | + $table_class = 'w-100 bg-white'; |
|
| 670 | 670 | |
| 671 | - if ( ! is_admin() ) { |
|
| 672 | - $table_class = 'table table-bordered'; |
|
| 673 | - } |
|
| 671 | + if ( ! is_admin() ) { |
|
| 672 | + $table_class = 'table table-bordered'; |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - ?> |
|
| 675 | + ?> |
|
| 676 | 676 | <div class="m-0" style="overflow: auto;"> |
| 677 | 677 | |
| 678 | 678 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -681,10 +681,10 @@ discard block |
||
| 681 | 681 | <tr> |
| 682 | 682 | <?php |
| 683 | 683 | |
| 684 | - foreach ( $columns as $key => $label ) { |
|
| 685 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 686 | - } |
|
| 687 | - ?> |
|
| 684 | + foreach ( $columns as $key => $label ) { |
|
| 685 | + echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 686 | + } |
|
| 687 | + ?> |
|
| 688 | 688 | </tr> |
| 689 | 689 | </thead> |
| 690 | 690 | |
@@ -692,106 +692,106 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | <?php |
| 694 | 694 | |
| 695 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 695 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 696 | 696 | |
| 697 | - echo '<tr>'; |
|
| 697 | + echo '<tr>'; |
|
| 698 | 698 | |
| 699 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 699 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 700 | 700 | |
| 701 | - $class = 'text-left'; |
|
| 701 | + $class = 'text-left'; |
|
| 702 | 702 | |
| 703 | - echo "<td class='p-2 text-left'>"; |
|
| 703 | + echo "<td class='p-2 text-left'>"; |
|
| 704 | 704 | |
| 705 | - switch ( $key ) { |
|
| 705 | + switch ( $key ) { |
|
| 706 | 706 | |
| 707 | - case 'item_name': |
|
| 708 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 709 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 707 | + case 'item_name': |
|
| 708 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 709 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 710 | 710 | |
| 711 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 712 | - echo esc_html( $item_name ); |
|
| 713 | - } else { |
|
| 714 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 715 | - } |
|
| 711 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 712 | + echo esc_html( $item_name ); |
|
| 713 | + } else { |
|
| 714 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | - break; |
|
| 717 | + break; |
|
| 718 | 718 | |
| 719 | - case 'price': |
|
| 720 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 721 | - break; |
|
| 719 | + case 'price': |
|
| 720 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 721 | + break; |
|
| 722 | 722 | |
| 723 | - case 'tax': |
|
| 724 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 725 | - break; |
|
| 723 | + case 'tax': |
|
| 724 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 725 | + break; |
|
| 726 | 726 | |
| 727 | - case 'discount': |
|
| 728 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 729 | - break; |
|
| 727 | + case 'discount': |
|
| 728 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 729 | + break; |
|
| 730 | 730 | |
| 731 | - case 'initial': |
|
| 732 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 733 | - break; |
|
| 731 | + case 'initial': |
|
| 732 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 733 | + break; |
|
| 734 | 734 | |
| 735 | - case 'recurring': |
|
| 736 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 737 | - break; |
|
| 735 | + case 'recurring': |
|
| 736 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 737 | + break; |
|
| 738 | 738 | |
| 739 | - } |
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | - echo '</td>'; |
|
| 741 | + echo '</td>'; |
|
| 742 | 742 | |
| 743 | - } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - echo '</tr>'; |
|
| 745 | + echo '</tr>'; |
|
| 746 | 746 | |
| 747 | - endforeach; |
|
| 747 | + endforeach; |
|
| 748 | 748 | |
| 749 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 749 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 750 | 750 | |
| 751 | - echo '<tr>'; |
|
| 751 | + echo '<tr>'; |
|
| 752 | 752 | |
| 753 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 753 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 754 | 754 | |
| 755 | - $class = 'text-left'; |
|
| 755 | + $class = 'text-left'; |
|
| 756 | 756 | |
| 757 | - echo "<td class='p-2 text-left'>"; |
|
| 757 | + echo "<td class='p-2 text-left'>"; |
|
| 758 | 758 | |
| 759 | - switch ( $key ) { |
|
| 759 | + switch ( $key ) { |
|
| 760 | 760 | |
| 761 | - case 'item_name': |
|
| 762 | - echo esc_html( $subscription_group_fee['name'] ); |
|
| 763 | - break; |
|
| 761 | + case 'item_name': |
|
| 762 | + echo esc_html( $subscription_group_fee['name'] ); |
|
| 763 | + break; |
|
| 764 | 764 | |
| 765 | - case 'price': |
|
| 766 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 767 | - break; |
|
| 765 | + case 'price': |
|
| 766 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 767 | + break; |
|
| 768 | 768 | |
| 769 | - case 'tax': |
|
| 770 | - echo '—'; |
|
| 771 | - break; |
|
| 769 | + case 'tax': |
|
| 770 | + echo '—'; |
|
| 771 | + break; |
|
| 772 | 772 | |
| 773 | - case 'discount': |
|
| 774 | - echo '—'; |
|
| 775 | - break; |
|
| 773 | + case 'discount': |
|
| 774 | + echo '—'; |
|
| 775 | + break; |
|
| 776 | 776 | |
| 777 | - case 'initial': |
|
| 778 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 779 | - break; |
|
| 777 | + case 'initial': |
|
| 778 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 779 | + break; |
|
| 780 | 780 | |
| 781 | - case 'recurring': |
|
| 782 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 783 | - break; |
|
| 781 | + case 'recurring': |
|
| 782 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 783 | + break; |
|
| 784 | 784 | |
| 785 | - } |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | - echo '</td>'; |
|
| 787 | + echo '</td>'; |
|
| 788 | 788 | |
| 789 | - } |
|
| 789 | + } |
|
| 790 | 790 | |
| 791 | - echo '</tr>'; |
|
| 791 | + echo '</tr>'; |
|
| 792 | 792 | |
| 793 | - endforeach; |
|
| 794 | - ?> |
|
| 793 | + endforeach; |
|
| 794 | + ?> |
|
| 795 | 795 | |
| 796 | 796 | </tbody> |
| 797 | 797 | |
@@ -810,38 +810,38 @@ discard block |
||
| 810 | 810 | */ |
| 811 | 811 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
| 812 | 812 | |
| 813 | - // Fetch the subscription groups. |
|
| 814 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 815 | - |
|
| 816 | - if ( empty( $subscription_groups ) ) { |
|
| 817 | - return; |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - // Prepare table columns. |
|
| 821 | - $columns = apply_filters( |
|
| 822 | - 'getpaid_subscription_related_subscriptions_columns', |
|
| 823 | - array( |
|
| 824 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 825 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 826 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 827 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 828 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 829 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 830 | - ), |
|
| 831 | - $subscription |
|
| 832 | - ); |
|
| 833 | - |
|
| 834 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 835 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 836 | - } |
|
| 837 | - |
|
| 838 | - $table_class = 'w-100 bg-white'; |
|
| 839 | - |
|
| 840 | - if ( ! is_admin() ) { |
|
| 841 | - $table_class = 'table table-bordered'; |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - ?> |
|
| 813 | + // Fetch the subscription groups. |
|
| 814 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 815 | + |
|
| 816 | + if ( empty( $subscription_groups ) ) { |
|
| 817 | + return; |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + // Prepare table columns. |
|
| 821 | + $columns = apply_filters( |
|
| 822 | + 'getpaid_subscription_related_subscriptions_columns', |
|
| 823 | + array( |
|
| 824 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 825 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 826 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 827 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 828 | + 'item' => __( 'Items', 'invoicing' ), |
|
| 829 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 830 | + ), |
|
| 831 | + $subscription |
|
| 832 | + ); |
|
| 833 | + |
|
| 834 | + if ( $subscription->get_status() == 'pending' ) { |
|
| 835 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 836 | + } |
|
| 837 | + |
|
| 838 | + $table_class = 'w-100 bg-white'; |
|
| 839 | + |
|
| 840 | + if ( ! is_admin() ) { |
|
| 841 | + $table_class = 'table table-bordered'; |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + ?> |
|
| 845 | 845 | <div class="m-0" style="overflow: auto;"> |
| 846 | 846 | |
| 847 | 847 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -850,10 +850,10 @@ discard block |
||
| 850 | 850 | <tr> |
| 851 | 851 | <?php |
| 852 | 852 | |
| 853 | - foreach ( $columns as $key => $label ) { |
|
| 854 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 855 | - } |
|
| 856 | - ?> |
|
| 853 | + foreach ( $columns as $key => $label ) { |
|
| 854 | + echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 855 | + } |
|
| 856 | + ?> |
|
| 857 | 857 | </tr> |
| 858 | 858 | </thead> |
| 859 | 859 | |
@@ -861,74 +861,74 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | <?php |
| 863 | 863 | |
| 864 | - foreach ( $subscription_groups as $subscription_group ) : |
|
| 864 | + foreach ( $subscription_groups as $subscription_group ) : |
|
| 865 | 865 | |
| 866 | - // Do not list current subscription. |
|
| 867 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 868 | - continue; |
|
| 869 | - } |
|
| 866 | + // Do not list current subscription. |
|
| 867 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 868 | + continue; |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | - // Ensure the subscription exists. |
|
| 872 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 871 | + // Ensure the subscription exists. |
|
| 872 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 873 | 873 | |
| 874 | - if ( ! $_suscription->exists() ) { |
|
| 875 | - continue; |
|
| 876 | - } |
|
| 874 | + if ( ! $_suscription->exists() ) { |
|
| 875 | + continue; |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | - echo '<tr>'; |
|
| 878 | + echo '<tr>'; |
|
| 879 | 879 | |
| 880 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 880 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 881 | 881 | |
| 882 | - $class = 'text-left'; |
|
| 882 | + $class = 'text-left'; |
|
| 883 | 883 | |
| 884 | - echo "<td class='p-2 text-left'>"; |
|
| 884 | + echo "<td class='p-2 text-left'>"; |
|
| 885 | 885 | |
| 886 | - switch ( $key ) { |
|
| 886 | + switch ( $key ) { |
|
| 887 | 887 | |
| 888 | - case 'status': |
|
| 889 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 890 | - break; |
|
| 888 | + case 'status': |
|
| 889 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 890 | + break; |
|
| 891 | 891 | |
| 892 | - case 'item': |
|
| 893 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 894 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 895 | - break; |
|
| 892 | + case 'item': |
|
| 893 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 894 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 895 | + break; |
|
| 896 | 896 | |
| 897 | - case 'renewals': |
|
| 898 | - $max_bills = $_suscription->get_bill_times(); |
|
| 899 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 900 | - break; |
|
| 897 | + case 'renewals': |
|
| 898 | + $max_bills = $_suscription->get_bill_times(); |
|
| 899 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 900 | + break; |
|
| 901 | 901 | |
| 902 | - case 'renewal_date': |
|
| 903 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 904 | - break; |
|
| 902 | + case 'renewal_date': |
|
| 903 | + echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 904 | + break; |
|
| 905 | 905 | |
| 906 | - case 'start_date': |
|
| 907 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 908 | - break; |
|
| 906 | + case 'start_date': |
|
| 907 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 908 | + break; |
|
| 909 | 909 | |
| 910 | - case 'subscription': |
|
| 911 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 912 | - printf( |
|
| 910 | + case 'subscription': |
|
| 911 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 912 | + printf( |
|
| 913 | 913 | '%1$s#%2$s%3$s', |
| 914 | 914 | '<a href="' . esc_url( $url ) . '">', |
| 915 | 915 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
| 916 | - '</a>' |
|
| 916 | + '</a>' |
|
| 917 | 917 | ); |
| 918 | 918 | |
| 919 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 920 | - break; |
|
| 919 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 920 | + break; |
|
| 921 | 921 | |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | |
| 924 | - echo '</td>'; |
|
| 924 | + echo '</td>'; |
|
| 925 | 925 | |
| 926 | - } |
|
| 926 | + } |
|
| 927 | 927 | |
| 928 | - echo '</tr>'; |
|
| 928 | + echo '</tr>'; |
|
| 929 | 929 | |
| 930 | - endforeach; |
|
| 931 | - ?> |
|
| 930 | + endforeach; |
|
| 931 | + ?> |
|
| 932 | 932 | |
| 933 | 933 | </tbody> |
| 934 | 934 | |
@@ -13,17 +13,17 @@ discard block |
||
| 13 | 13 | class GetPaid_Manual_Gateway extends GetPaid_Payment_Gateway { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Payment method id. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 16 | + * Payment method id. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | 20 | public $id = 'manual'; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * An array of features that this gateway supports. |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 23 | + * An array of features that this gateway supports. |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | 27 | protected $supports = array( |
| 28 | 28 | 'subscription', |
| 29 | 29 | 'addons', |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Payment method order. |
|
| 38 | - * |
|
| 39 | - * @var int |
|
| 40 | - */ |
|
| 41 | - public $order = 11; |
|
| 37 | + * Payment method order. |
|
| 38 | + * |
|
| 39 | + * @var int |
|
| 40 | + */ |
|
| 41 | + public $order = 11; |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Class constructor. |
|
| 45 | - */ |
|
| 46 | - public function __construct() { |
|
| 44 | + * Class constructor. |
|
| 45 | + */ |
|
| 46 | + public function __construct() { |
|
| 47 | 47 | parent::__construct(); |
| 48 | 48 | |
| 49 | 49 | $this->title = __( 'Test Gateway', 'invoicing' ); |
@@ -53,15 +53,15 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | - * Process Payment. |
|
| 57 | - * |
|
| 58 | - * |
|
| 59 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 60 | - * @param array $submission_data Posted checkout fields. |
|
| 61 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 62 | - * @return array |
|
| 63 | - */ |
|
| 64 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 56 | + * Process Payment. |
|
| 57 | + * |
|
| 58 | + * |
|
| 59 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 60 | + * @param array $submission_data Posted checkout fields. |
|
| 61 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 62 | + * @return array |
|
| 63 | + */ |
|
| 64 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 65 | 65 | |
| 66 | 66 | // Mark it as paid. |
| 67 | 67 | $invoice->mark_paid(); |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * (Maybe) renews a manual subscription profile. |
|
| 95 | - * |
|
| 96 | - * |
|
| 94 | + * (Maybe) renews a manual subscription profile. |
|
| 95 | + * |
|
| 96 | + * |
|
| 97 | 97 | * @param WPInv_Subscription $subscription |
| 98 | - */ |
|
| 99 | - public function maybe_renew_subscription( $subscription ) { |
|
| 98 | + */ |
|
| 99 | + public function maybe_renew_subscription( $subscription ) { |
|
| 100 | 100 | |
| 101 | 101 | // Ensure its our subscription && it's active. |
| 102 | 102 | if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | - * Processes invoice addons. |
|
| 120 | - * |
|
| 121 | - * @param WPInv_Invoice $invoice |
|
| 122 | - * @param GetPaid_Form_Item[] $items |
|
| 123 | - * @return WPInv_Invoice |
|
| 124 | - */ |
|
| 125 | - public function process_addons( $invoice, $items ) { |
|
| 119 | + * Processes invoice addons. |
|
| 120 | + * |
|
| 121 | + * @param WPInv_Invoice $invoice |
|
| 122 | + * @param GetPaid_Form_Item[] $items |
|
| 123 | + * @return WPInv_Invoice |
|
| 124 | + */ |
|
| 125 | + public function process_addons( $invoice, $items ) { |
|
| 126 | 126 | |
| 127 | 127 | foreach ( $items as $item ) { |
| 128 | 128 | $invoice->add_item( $item ); |
@@ -13,47 +13,47 @@ discard block |
||
| 13 | 13 | class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Payment method id. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 16 | + * Payment method id. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | 20 | public $id = 'bank_transfer'; |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * An array of features that this gateway supports. |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 27 | - protected $supports = array( |
|
| 28 | - 'subscription', |
|
| 29 | - 'addons', |
|
| 30 | - 'single_subscription_group', |
|
| 31 | - 'multiple_subscription_groups', |
|
| 32 | - 'subscription_date_change', |
|
| 33 | - 'subscription_bill_times_change', |
|
| 34 | - ); |
|
| 22 | + /** |
|
| 23 | + * An array of features that this gateway supports. |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | + protected $supports = array( |
|
| 28 | + 'subscription', |
|
| 29 | + 'addons', |
|
| 30 | + 'single_subscription_group', |
|
| 31 | + 'multiple_subscription_groups', |
|
| 32 | + 'subscription_date_change', |
|
| 33 | + 'subscription_bill_times_change', |
|
| 34 | + ); |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Payment method order. |
|
| 38 | + * |
|
| 39 | + * @var int |
|
| 40 | + */ |
|
| 41 | + public $order = 8; |
|
| 35 | 42 | |
| 36 | 43 | /** |
| 37 | - * Payment method order. |
|
| 38 | - * |
|
| 39 | - * @var int |
|
| 40 | - */ |
|
| 41 | - public $order = 8; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Bank transfer instructions. |
|
| 45 | - */ |
|
| 46 | - public $instructions; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Locale array. |
|
| 50 | - */ |
|
| 51 | - public $locale; |
|
| 44 | + * Bank transfer instructions. |
|
| 45 | + */ |
|
| 46 | + public $instructions; |
|
| 52 | 47 | |
| 53 | 48 | /** |
| 54 | - * Class constructor. |
|
| 55 | - */ |
|
| 56 | - public function __construct() { |
|
| 49 | + * Locale array. |
|
| 50 | + */ |
|
| 51 | + public $locale; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Class constructor. |
|
| 55 | + */ |
|
| 56 | + public function __construct() { |
|
| 57 | 57 | parent::__construct(); |
| 58 | 58 | |
| 59 | 59 | $this->title = __( 'Direct bank transfer', 'invoicing' ); |
@@ -61,24 +61,24 @@ discard block |
||
| 61 | 61 | $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
| 62 | 62 | $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
| 63 | 63 | |
| 64 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
| 65 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
| 66 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
| 67 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
| 68 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
| 69 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
| 64 | + add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
| 65 | + add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
| 66 | + add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
| 67 | + add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
| 68 | + add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
| 69 | + add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Process Payment. |
|
| 75 | - * |
|
| 76 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 77 | - * @param array $submission_data Posted checkout fields. |
|
| 78 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 79 | - * @return array |
|
| 80 | - */ |
|
| 81 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 74 | + * Process Payment. |
|
| 75 | + * |
|
| 76 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 77 | + * @param array $submission_data Posted checkout fields. |
|
| 78 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 79 | + * @return array |
|
| 80 | + */ |
|
| 81 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 82 | 82 | |
| 83 | 83 | // Add a transaction id. |
| 84 | 84 | $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) ); |
@@ -99,66 +99,66 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | - * Output for the order received page. |
|
| 103 | - * |
|
| 104 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 105 | - */ |
|
| 106 | - public function thankyou_page( $invoice ) { |
|
| 102 | + * Output for the order received page. |
|
| 103 | + * |
|
| 104 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 105 | + */ |
|
| 106 | + public function thankyou_page( $invoice ) { |
|
| 107 | 107 | |
| 108 | 108 | if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
| 109 | 109 | |
| 110 | - echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
|
| 110 | + echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
|
| 111 | 111 | |
| 112 | 112 | if ( ! empty( $this->instructions ) ) { |
| 113 | 113 | echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); |
| 114 | - } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - $this->bank_details( $invoice ); |
|
| 116 | + $this->bank_details( $invoice ); |
|
| 117 | 117 | |
| 118 | - echo '</div>'; |
|
| 118 | + echo '</div>'; |
|
| 119 | 119 | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | - * Add content to the WPI emails. |
|
| 126 | - * |
|
| 127 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 128 | - * @param string $email_type Email format: plain text or HTML. |
|
| 129 | - * @param bool $sent_to_admin Sent to admin. |
|
| 130 | - */ |
|
| 131 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
| 125 | + * Add content to the WPI emails. |
|
| 126 | + * |
|
| 127 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 128 | + * @param string $email_type Email format: plain text or HTML. |
|
| 129 | + * @param bool $sent_to_admin Sent to admin. |
|
| 130 | + */ |
|
| 131 | + public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
| 132 | 132 | |
| 133 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
| 133 | + if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
| 134 | 134 | |
| 135 | - echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
|
| 135 | + echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
|
| 136 | 136 | |
| 137 | - if ( $this->instructions ) { |
|
| 138 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
| 137 | + if ( $this->instructions ) { |
|
| 138 | + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - $this->bank_details( $invoice ); |
|
| 141 | + $this->bank_details( $invoice ); |
|
| 142 | 142 | |
| 143 | - echo '</div>'; |
|
| 143 | + echo '</div>'; |
|
| 144 | 144 | |
| 145 | - } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * Get bank details and place into a list format. |
|
| 151 | - * |
|
| 152 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 153 | - */ |
|
| 154 | - protected function bank_details( $invoice ) { |
|
| 150 | + * Get bank details and place into a list format. |
|
| 151 | + * |
|
| 152 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 153 | + */ |
|
| 154 | + protected function bank_details( $invoice ) { |
|
| 155 | 155 | |
| 156 | - // Get the invoice country and country $locale. |
|
| 157 | - $country = $invoice->get_country(); |
|
| 158 | - $locale = $this->get_country_locale(); |
|
| 156 | + // Get the invoice country and country $locale. |
|
| 157 | + $country = $invoice->get_country(); |
|
| 158 | + $locale = $this->get_country_locale(); |
|
| 159 | 159 | |
| 160 | - // Get sortcode label in the $locale array and use appropriate one. |
|
| 161 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
| 160 | + // Get sortcode label in the $locale array and use appropriate one. |
|
| 161 | + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
| 162 | 162 | |
| 163 | 163 | $bank_fields = array( |
| 164 | 164 | 'ac_name' => __( 'Account Name', 'invoicing' ), |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | if ( ! empty( $value ) ) { |
| 179 | 179 | $bank_info[ $field ] = array( |
| 180 | - 'label' => $label, |
|
| 181 | - 'value' => $value, |
|
| 182 | - ); |
|
| 180 | + 'label' => $label, |
|
| 181 | + 'value' => $value, |
|
| 182 | + ); |
|
| 183 | 183 | } |
| 184 | - } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice ); |
| 187 | 187 | |
@@ -189,139 +189,139 @@ discard block |
||
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL; |
|
| 192 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL; |
|
| 193 | + |
|
| 194 | + echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
|
| 195 | + |
|
| 196 | + foreach ( $bank_info as $key => $data ) { |
|
| 197 | + echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + echo '</table>'; |
|
| 201 | + |
|
| 202 | + } |
|
| 193 | 203 | |
| 194 | - echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
|
| 204 | + /** |
|
| 205 | + * Get country locale if localized. |
|
| 206 | + * |
|
| 207 | + * @return array |
|
| 208 | + */ |
|
| 209 | + public function get_country_locale() { |
|
| 210 | + |
|
| 211 | + if ( empty( $this->locale ) ) { |
|
| 212 | + |
|
| 213 | + // Locale information to be used - only those that are not 'Sort Code'. |
|
| 214 | + $this->locale = apply_filters( |
|
| 215 | + 'getpaid_get_bank_transfer_locale', |
|
| 216 | + array( |
|
| 217 | + 'AU' => array( |
|
| 218 | + 'sortcode' => array( |
|
| 219 | + 'label' => __( 'BSB', 'invoicing' ), |
|
| 220 | + ), |
|
| 221 | + ), |
|
| 222 | + 'CA' => array( |
|
| 223 | + 'sortcode' => array( |
|
| 224 | + 'label' => __( 'Bank transit number', 'invoicing' ), |
|
| 225 | + ), |
|
| 226 | + ), |
|
| 227 | + 'IN' => array( |
|
| 228 | + 'sortcode' => array( |
|
| 229 | + 'label' => __( 'IFSC', 'invoicing' ), |
|
| 230 | + ), |
|
| 231 | + ), |
|
| 232 | + 'IT' => array( |
|
| 233 | + 'sortcode' => array( |
|
| 234 | + 'label' => __( 'Branch sort', 'invoicing' ), |
|
| 235 | + ), |
|
| 236 | + ), |
|
| 237 | + 'NZ' => array( |
|
| 238 | + 'sortcode' => array( |
|
| 239 | + 'label' => __( 'Bank code', 'invoicing' ), |
|
| 240 | + ), |
|
| 241 | + ), |
|
| 242 | + 'SE' => array( |
|
| 243 | + 'sortcode' => array( |
|
| 244 | + 'label' => __( 'Bank code', 'invoicing' ), |
|
| 245 | + ), |
|
| 246 | + ), |
|
| 247 | + 'US' => array( |
|
| 248 | + 'sortcode' => array( |
|
| 249 | + 'label' => __( 'Routing number', 'invoicing' ), |
|
| 250 | + ), |
|
| 251 | + ), |
|
| 252 | + 'ZA' => array( |
|
| 253 | + 'sortcode' => array( |
|
| 254 | + 'label' => __( 'Branch code', 'invoicing' ), |
|
| 255 | + ), |
|
| 256 | + ), |
|
| 257 | + ) |
|
| 258 | + ); |
|
| 195 | 259 | |
| 196 | - foreach ( $bank_info as $key => $data ) { |
|
| 197 | - echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL; |
|
| 198 | - } |
|
| 260 | + } |
|
| 199 | 261 | |
| 200 | - echo '</table>'; |
|
| 262 | + return $this->locale; |
|
| 201 | 263 | |
| 202 | 264 | } |
| 203 | 265 | |
| 204 | 266 | /** |
| 205 | - * Get country locale if localized. |
|
| 206 | - * |
|
| 207 | - * @return array |
|
| 208 | - */ |
|
| 209 | - public function get_country_locale() { |
|
| 210 | - |
|
| 211 | - if ( empty( $this->locale ) ) { |
|
| 212 | - |
|
| 213 | - // Locale information to be used - only those that are not 'Sort Code'. |
|
| 214 | - $this->locale = apply_filters( |
|
| 215 | - 'getpaid_get_bank_transfer_locale', |
|
| 216 | - array( |
|
| 217 | - 'AU' => array( |
|
| 218 | - 'sortcode' => array( |
|
| 219 | - 'label' => __( 'BSB', 'invoicing' ), |
|
| 220 | - ), |
|
| 221 | - ), |
|
| 222 | - 'CA' => array( |
|
| 223 | - 'sortcode' => array( |
|
| 224 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
| 225 | - ), |
|
| 226 | - ), |
|
| 227 | - 'IN' => array( |
|
| 228 | - 'sortcode' => array( |
|
| 229 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
| 230 | - ), |
|
| 231 | - ), |
|
| 232 | - 'IT' => array( |
|
| 233 | - 'sortcode' => array( |
|
| 234 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
| 235 | - ), |
|
| 236 | - ), |
|
| 237 | - 'NZ' => array( |
|
| 238 | - 'sortcode' => array( |
|
| 239 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
| 240 | - ), |
|
| 241 | - ), |
|
| 242 | - 'SE' => array( |
|
| 243 | - 'sortcode' => array( |
|
| 244 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
| 245 | - ), |
|
| 246 | - ), |
|
| 247 | - 'US' => array( |
|
| 248 | - 'sortcode' => array( |
|
| 249 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
| 250 | - ), |
|
| 251 | - ), |
|
| 252 | - 'ZA' => array( |
|
| 253 | - 'sortcode' => array( |
|
| 254 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
| 255 | - ), |
|
| 256 | - ), |
|
| 257 | - ) |
|
| 258 | - ); |
|
| 259 | - |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - return $this->locale; |
|
| 263 | - |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Filters the gateway settings. |
|
| 268 | - * |
|
| 269 | - * @param array $admin_settings |
|
| 270 | - */ |
|
| 271 | - public function admin_settings( $admin_settings ) { |
|
| 267 | + * Filters the gateway settings. |
|
| 268 | + * |
|
| 269 | + * @param array $admin_settings |
|
| 270 | + */ |
|
| 271 | + public function admin_settings( $admin_settings ) { |
|
| 272 | 272 | |
| 273 | 273 | $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
| 274 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
| 274 | + $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
| 275 | 275 | |
| 276 | - $locale = $this->get_country_locale(); |
|
| 276 | + $locale = $this->get_country_locale(); |
|
| 277 | 277 | |
| 278 | - // Get sortcode label in the $locale array and use appropriate one. |
|
| 279 | - $country = wpinv_default_billing_country(); |
|
| 280 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
| 278 | + // Get sortcode label in the $locale array and use appropriate one. |
|
| 279 | + $country = wpinv_default_billing_country(); |
|
| 280 | + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
| 281 | 281 | |
| 282 | - $admin_settings['bank_transfer_ac_name'] = array( |
|
| 282 | + $admin_settings['bank_transfer_ac_name'] = array( |
|
| 283 | 283 | 'type' => 'text', |
| 284 | 284 | 'id' => 'bank_transfer_ac_name', |
| 285 | 285 | 'name' => __( 'Account Name', 'invoicing' ), |
| 286 | - ); |
|
| 286 | + ); |
|
| 287 | 287 | |
| 288 | - $admin_settings['bank_transfer_ac_no'] = array( |
|
| 288 | + $admin_settings['bank_transfer_ac_no'] = array( |
|
| 289 | 289 | 'type' => 'text', |
| 290 | 290 | 'id' => 'bank_transfer_ac_no', |
| 291 | 291 | 'name' => __( 'Account Number', 'invoicing' ), |
| 292 | - ); |
|
| 292 | + ); |
|
| 293 | 293 | |
| 294 | - $admin_settings['bank_transfer_bank_name'] = array( |
|
| 294 | + $admin_settings['bank_transfer_bank_name'] = array( |
|
| 295 | 295 | 'type' => 'text', |
| 296 | 296 | 'id' => 'bank_transfer_bank_name', |
| 297 | 297 | 'name' => __( 'Bank Name', 'invoicing' ), |
| 298 | - ); |
|
| 298 | + ); |
|
| 299 | 299 | |
| 300 | - $admin_settings['bank_transfer_ifsc'] = array( |
|
| 300 | + $admin_settings['bank_transfer_ifsc'] = array( |
|
| 301 | 301 | 'type' => 'text', |
| 302 | 302 | 'id' => 'bank_transfer_ifsc', |
| 303 | 303 | 'name' => __( 'IFSC Code', 'invoicing' ), |
| 304 | - ); |
|
| 304 | + ); |
|
| 305 | 305 | |
| 306 | - $admin_settings['bank_transfer_iban'] = array( |
|
| 306 | + $admin_settings['bank_transfer_iban'] = array( |
|
| 307 | 307 | 'type' => 'text', |
| 308 | 308 | 'id' => 'bank_transfer_iban', |
| 309 | 309 | 'name' => __( 'IBAN', 'invoicing' ), |
| 310 | - ); |
|
| 310 | + ); |
|
| 311 | 311 | |
| 312 | - $admin_settings['bank_transfer_bic'] = array( |
|
| 312 | + $admin_settings['bank_transfer_bic'] = array( |
|
| 313 | 313 | 'type' => 'text', |
| 314 | 314 | 'id' => 'bank_transfer_bic', |
| 315 | 315 | 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
| 316 | - ); |
|
| 316 | + ); |
|
| 317 | 317 | |
| 318 | - $admin_settings['bank_transfer_sort_code'] = array( |
|
| 319 | - 'type' => 'text', |
|
| 320 | - 'id' => 'bank_transfer_sort_code', |
|
| 321 | - 'name' => $sortcode, |
|
| 322 | - ); |
|
| 318 | + $admin_settings['bank_transfer_sort_code'] = array( |
|
| 319 | + 'type' => 'text', |
|
| 320 | + 'id' => 'bank_transfer_sort_code', |
|
| 321 | + 'name' => $sortcode, |
|
| 322 | + ); |
|
| 323 | 323 | |
| 324 | - $admin_settings['bank_transfer_info'] = array( |
|
| 324 | + $admin_settings['bank_transfer_info'] = array( |
|
| 325 | 325 | 'id' => 'bank_transfer_info', |
| 326 | 326 | 'name' => __( 'Instructions', 'invoicing' ), |
| 327 | 327 | 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
@@ -331,17 +331,17 @@ discard block |
||
| 331 | 331 | 'rows' => 5, |
| 332 | 332 | ); |
| 333 | 333 | |
| 334 | - return $admin_settings; |
|
| 335 | - } |
|
| 334 | + return $admin_settings; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - /** |
|
| 338 | - * Processes invoice addons. |
|
| 339 | - * |
|
| 340 | - * @param WPInv_Invoice $invoice |
|
| 341 | - * @param GetPaid_Form_Item[] $items |
|
| 342 | - * @return WPInv_Invoice |
|
| 343 | - */ |
|
| 344 | - public function process_addons( $invoice, $items ) { |
|
| 337 | + /** |
|
| 338 | + * Processes invoice addons. |
|
| 339 | + * |
|
| 340 | + * @param WPInv_Invoice $invoice |
|
| 341 | + * @param GetPaid_Form_Item[] $items |
|
| 342 | + * @return WPInv_Invoice |
|
| 343 | + */ |
|
| 344 | + public function process_addons( $invoice, $items ) { |
|
| 345 | 345 | |
| 346 | 346 | foreach ( $items as $item ) { |
| 347 | 347 | $invoice->add_item( $item ); |
@@ -349,67 +349,67 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | $invoice->recalculate_total(); |
| 351 | 351 | $invoice->save(); |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - /** |
|
| 355 | - * (Maybe) renews a bank transfer subscription profile. |
|
| 356 | - * |
|
| 357 | - * |
|
| 354 | + /** |
|
| 355 | + * (Maybe) renews a bank transfer subscription profile. |
|
| 356 | + * |
|
| 357 | + * |
|
| 358 | 358 | * @param WPInv_Subscription $subscription |
| 359 | - */ |
|
| 360 | - public function maybe_renew_subscription( $subscription ) { |
|
| 359 | + */ |
|
| 360 | + public function maybe_renew_subscription( $subscription ) { |
|
| 361 | 361 | |
| 362 | 362 | // Ensure its our subscription && it's active. |
| 363 | 363 | if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
| 364 | - $subscription->create_payment(); |
|
| 364 | + $subscription->create_payment(); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - /** |
|
| 370 | - * Process a bank transfer payment. |
|
| 371 | - * |
|
| 372 | - * |
|
| 369 | + /** |
|
| 370 | + * Process a bank transfer payment. |
|
| 371 | + * |
|
| 372 | + * |
|
| 373 | 373 | * @param WPInv_Invoice $invoice |
| 374 | - */ |
|
| 375 | - public function invoice_paid( $invoice ) { |
|
| 376 | - |
|
| 377 | - // Abort if not paid by bank transfer. |
|
| 378 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
| 379 | - return; |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - // Is it a parent payment? |
|
| 383 | - if ( 0 == $invoice->get_parent_id() ) { |
|
| 384 | - |
|
| 385 | - // (Maybe) activate subscriptions. |
|
| 386 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 387 | - |
|
| 388 | - if ( ! empty( $subscriptions ) ) { |
|
| 389 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
| 390 | - |
|
| 391 | - foreach ( $subscriptions as $subscription ) { |
|
| 392 | - if ( $subscription->exists() ) { |
|
| 393 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
| 394 | - $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
| 395 | - |
|
| 396 | - $subscription->set_next_renewal_date( $expiry ); |
|
| 397 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 398 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
| 399 | - $subscription->activate(); |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - } else { |
|
| 404 | - |
|
| 405 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
| 406 | - |
|
| 407 | - // Renew the subscription. |
|
| 408 | - if ( $subscription && $subscription->exists() ) { |
|
| 409 | - $subscription->add_payment( array(), $invoice ); |
|
| 410 | - $subscription->renew( strtotime( $invoice->get_date_created() ) ); |
|
| 411 | - } |
|
| 412 | - } |
|
| 374 | + */ |
|
| 375 | + public function invoice_paid( $invoice ) { |
|
| 376 | + |
|
| 377 | + // Abort if not paid by bank transfer. |
|
| 378 | + if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
| 379 | + return; |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + // Is it a parent payment? |
|
| 383 | + if ( 0 == $invoice->get_parent_id() ) { |
|
| 384 | + |
|
| 385 | + // (Maybe) activate subscriptions. |
|
| 386 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 387 | + |
|
| 388 | + if ( ! empty( $subscriptions ) ) { |
|
| 389 | + $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
| 390 | + |
|
| 391 | + foreach ( $subscriptions as $subscription ) { |
|
| 392 | + if ( $subscription->exists() ) { |
|
| 393 | + $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
| 394 | + $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
| 395 | + |
|
| 396 | + $subscription->set_next_renewal_date( $expiry ); |
|
| 397 | + $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 398 | + $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
| 399 | + $subscription->activate(); |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + } else { |
|
| 404 | + |
|
| 405 | + $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
| 406 | + |
|
| 407 | + // Renew the subscription. |
|
| 408 | + if ( $subscription && $subscription->exists() ) { |
|
| 409 | + $subscription->add_payment( array(), $invoice ); |
|
| 410 | + $subscription->renew( strtotime( $invoice->get_date_created() ) ); |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | 414 | } |
| 415 | 415 | |
@@ -14,64 +14,64 @@ |
||
| 14 | 14 | * @return array|mixed|string|string[] |
| 15 | 15 | */ |
| 16 | 16 | function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) { |
| 17 | - global $aui_bs5; |
|
| 17 | + global $aui_bs5; |
|
| 18 | 18 | |
| 19 | - if ( $aui_bs5 ) { |
|
| 19 | + if ( $aui_bs5 ) { |
|
| 20 | 20 | |
| 21 | - $convert = array( |
|
| 22 | - 'ml-' => 'ms-', |
|
| 23 | - 'mr-' => 'me-', |
|
| 24 | - 'pl-' => 'ps-', |
|
| 25 | - 'pr-' => 'pe-', |
|
| 26 | - ' form-row' => ' row', |
|
| 27 | - ' embed-responsive-item' => '', |
|
| 28 | - ' embed-responsive' => ' ratio', |
|
| 29 | - '-1by1' => '-1x1', |
|
| 30 | - '-4by3' => '-4x3', |
|
| 31 | - '-16by9' => '-16x9', |
|
| 32 | - '-21by9' => '-21x9', |
|
| 33 | - 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
| 34 | - ' badge-' => ' text-bg-', |
|
| 35 | - 'form-group' => 'mb-3', |
|
| 36 | - 'custom-select' => 'form-select', |
|
| 37 | - 'float-left' => 'float-start', |
|
| 38 | - 'float-right' => 'float-end', |
|
| 39 | - 'text-left' => 'text-start', |
|
| 40 | - 'text-sm-left' => 'text-sm-start', |
|
| 41 | - 'text-md-left' => 'text-md-start', |
|
| 42 | - 'text-lg-left' => 'text-lg-start', |
|
| 43 | - 'text-right' => 'text-end', |
|
| 44 | - 'text-sm-right' => 'text-sm-end', |
|
| 45 | - 'text-md-right' => 'text-md-end', |
|
| 46 | - 'text-lg-right' => 'text-lg-end', |
|
| 47 | - 'border-right' => 'border-end', |
|
| 48 | - 'border-left' => 'border-start', |
|
| 49 | - 'font-weight-' => 'fw-', |
|
| 50 | - 'btn-block' => 'w-100', |
|
| 51 | - 'rounded-left' => 'rounded-start', |
|
| 52 | - 'rounded-right' => 'rounded-end', |
|
| 53 | - 'font-italic' => 'fst-italic', |
|
| 21 | + $convert = array( |
|
| 22 | + 'ml-' => 'ms-', |
|
| 23 | + 'mr-' => 'me-', |
|
| 24 | + 'pl-' => 'ps-', |
|
| 25 | + 'pr-' => 'pe-', |
|
| 26 | + ' form-row' => ' row', |
|
| 27 | + ' embed-responsive-item' => '', |
|
| 28 | + ' embed-responsive' => ' ratio', |
|
| 29 | + '-1by1' => '-1x1', |
|
| 30 | + '-4by3' => '-4x3', |
|
| 31 | + '-16by9' => '-16x9', |
|
| 32 | + '-21by9' => '-21x9', |
|
| 33 | + 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
| 34 | + ' badge-' => ' text-bg-', |
|
| 35 | + 'form-group' => 'mb-3', |
|
| 36 | + 'custom-select' => 'form-select', |
|
| 37 | + 'float-left' => 'float-start', |
|
| 38 | + 'float-right' => 'float-end', |
|
| 39 | + 'text-left' => 'text-start', |
|
| 40 | + 'text-sm-left' => 'text-sm-start', |
|
| 41 | + 'text-md-left' => 'text-md-start', |
|
| 42 | + 'text-lg-left' => 'text-lg-start', |
|
| 43 | + 'text-right' => 'text-end', |
|
| 44 | + 'text-sm-right' => 'text-sm-end', |
|
| 45 | + 'text-md-right' => 'text-md-end', |
|
| 46 | + 'text-lg-right' => 'text-lg-end', |
|
| 47 | + 'border-right' => 'border-end', |
|
| 48 | + 'border-left' => 'border-start', |
|
| 49 | + 'font-weight-' => 'fw-', |
|
| 50 | + 'btn-block' => 'w-100', |
|
| 51 | + 'rounded-left' => 'rounded-start', |
|
| 52 | + 'rounded-right' => 'rounded-end', |
|
| 53 | + 'font-italic' => 'fst-italic', |
|
| 54 | 54 | |
| 55 | 55 | // 'custom-control custom-checkbox' => 'form-check', |
| 56 | - // data |
|
| 57 | - ' data-toggle=' => ' data-bs-toggle=', |
|
| 58 | - 'data-ride=' => 'data-bs-ride=', |
|
| 59 | - 'data-controlnav=' => 'data-bs-controlnav=', |
|
| 60 | - 'data-slide=' => 'data-bs-slide=', |
|
| 61 | - 'data-slide-to=' => 'data-bs-slide-to=', |
|
| 62 | - 'data-target=' => 'data-bs-target=', |
|
| 63 | - 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
| 64 | - 'class="close"' => 'class="btn-close"', |
|
| 65 | - '<span aria-hidden="true">×</span>' => '', |
|
| 66 | - ); |
|
| 67 | - $output = str_replace( |
|
| 68 | - array_keys( $convert ), |
|
| 69 | - array_values( $convert ), |
|
| 70 | - $output |
|
| 71 | - ); |
|
| 72 | - } |
|
| 56 | + // data |
|
| 57 | + ' data-toggle=' => ' data-bs-toggle=', |
|
| 58 | + 'data-ride=' => 'data-bs-ride=', |
|
| 59 | + 'data-controlnav=' => 'data-bs-controlnav=', |
|
| 60 | + 'data-slide=' => 'data-bs-slide=', |
|
| 61 | + 'data-slide-to=' => 'data-bs-slide-to=', |
|
| 62 | + 'data-target=' => 'data-bs-target=', |
|
| 63 | + 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
| 64 | + 'class="close"' => 'class="btn-close"', |
|
| 65 | + '<span aria-hidden="true">×</span>' => '', |
|
| 66 | + ); |
|
| 67 | + $output = str_replace( |
|
| 68 | + array_keys( $convert ), |
|
| 69 | + array_values( $convert ), |
|
| 70 | + $output |
|
| 71 | + ); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - return $output; |
|
| 74 | + return $output; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this |
@@ -11,21 +11,21 @@ discard block |
||
| 11 | 11 | * @return mixed|void |
| 12 | 12 | */ |
| 13 | 13 | function sd_pagenow_exclude() { |
| 14 | - return apply_filters( |
|
| 15 | - 'sd_pagenow_exclude', |
|
| 16 | - array( |
|
| 17 | - 'upload.php', |
|
| 18 | - 'edit-comments.php', |
|
| 19 | - 'edit-tags.php', |
|
| 20 | - 'index.php', |
|
| 21 | - 'media-new.php', |
|
| 22 | - 'options-discussion.php', |
|
| 23 | - 'options-writing.php', |
|
| 24 | - 'edit.php', |
|
| 25 | - 'themes.php', |
|
| 26 | - 'users.php', |
|
| 27 | - ) |
|
| 28 | - ); |
|
| 14 | + return apply_filters( |
|
| 15 | + 'sd_pagenow_exclude', |
|
| 16 | + array( |
|
| 17 | + 'upload.php', |
|
| 18 | + 'edit-comments.php', |
|
| 19 | + 'edit-tags.php', |
|
| 20 | + 'index.php', |
|
| 21 | + 'media-new.php', |
|
| 22 | + 'options-discussion.php', |
|
| 23 | + 'options-writing.php', |
|
| 24 | + 'edit.php', |
|
| 25 | + 'themes.php', |
|
| 26 | + 'users.php', |
|
| 27 | + ) |
|
| 28 | + ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return mixed|void |
| 38 | 38 | */ |
| 39 | 39 | function sd_widget_exclude() { |
| 40 | - return apply_filters( 'sd_widget_exclude', array() ); |
|
| 40 | + return apply_filters( 'sd_widget_exclude', array() ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
@@ -50,83 +50,83 @@ discard block |
||
| 50 | 50 | * @return array |
| 51 | 51 | */ |
| 52 | 52 | function sd_get_margin_input( $type = 'mt', $overwrite = array(), $include_negatives = true ) { |
| 53 | - global $aui_bs5; |
|
| 54 | - $options = array( |
|
| 55 | - '' => __( 'None', 'super-duper' ), |
|
| 56 | - 'auto' => __( 'auto', 'super-duper' ), |
|
| 57 | - '0' => '0', |
|
| 58 | - '1' => '1', |
|
| 59 | - '2' => '2', |
|
| 60 | - '3' => '3', |
|
| 61 | - '4' => '4', |
|
| 62 | - '5' => '5', |
|
| 63 | - '6' => '6', |
|
| 64 | - '7' => '7', |
|
| 65 | - '8' => '8', |
|
| 66 | - '9' => '9', |
|
| 67 | - '10' => '10', |
|
| 68 | - '11' => '11', |
|
| 69 | - '12' => '12', |
|
| 70 | - ); |
|
| 71 | - |
|
| 72 | - if ( $include_negatives ) { |
|
| 73 | - $options['n1'] = '-1'; |
|
| 74 | - $options['n2'] = '-2'; |
|
| 75 | - $options['n3'] = '-3'; |
|
| 76 | - $options['n4'] = '-4'; |
|
| 77 | - $options['n5'] = '-5'; |
|
| 78 | - $options['n6'] = '-6'; |
|
| 79 | - $options['n7'] = '-7'; |
|
| 80 | - $options['n8'] = '-8'; |
|
| 81 | - $options['n9'] = '-9'; |
|
| 82 | - $options['n10'] = '-10'; |
|
| 83 | - $options['n11'] = '-11'; |
|
| 84 | - $options['n12'] = '-12'; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $defaults = array( |
|
| 88 | - 'type' => 'select', |
|
| 89 | - 'title' => __( 'Margin top', 'super-duper' ), |
|
| 90 | - 'options' => $options, |
|
| 91 | - 'default' => '', |
|
| 92 | - 'desc_tip' => true, |
|
| 93 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 94 | - ); |
|
| 95 | - |
|
| 96 | - // title |
|
| 97 | - if ( $type == 'mt' ) { |
|
| 98 | - $defaults['title'] = __( 'Margin top', 'super-duper' ); |
|
| 99 | - $defaults['icon'] = 'box-top'; |
|
| 100 | - $defaults['row'] = array( |
|
| 101 | - 'title' => __( 'Margins', 'super-duper' ), |
|
| 102 | - 'key' => 'wrapper-margins', |
|
| 103 | - 'open' => true, |
|
| 104 | - 'class' => 'text-center', |
|
| 105 | - ); |
|
| 106 | - } elseif ( $type == 'mr' ) { |
|
| 107 | - $defaults['title'] = __( 'Margin right', 'super-duper' ); |
|
| 108 | - $defaults['icon'] = 'box-right'; |
|
| 109 | - $defaults['row'] = array( |
|
| 110 | - 'key' => 'wrapper-margins', |
|
| 111 | - ); |
|
| 112 | - } elseif ( $type == 'mb' ) { |
|
| 113 | - $defaults['title'] = __( 'Margin bottom', 'super-duper' ); |
|
| 114 | - $defaults['icon'] = 'box-bottom'; |
|
| 115 | - $defaults['row'] = array( |
|
| 116 | - 'key' => 'wrapper-margins', |
|
| 117 | - ); |
|
| 118 | - } elseif ( $type == 'ml' ) { |
|
| 119 | - $defaults['title'] = __( 'Margin left', 'super-duper' ); |
|
| 120 | - $defaults['icon'] = 'box-left'; |
|
| 121 | - $defaults['row'] = array( |
|
| 122 | - 'key' => 'wrapper-margins', |
|
| 123 | - 'close' => true, |
|
| 124 | - ); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 128 | - |
|
| 129 | - return $input; |
|
| 53 | + global $aui_bs5; |
|
| 54 | + $options = array( |
|
| 55 | + '' => __( 'None', 'super-duper' ), |
|
| 56 | + 'auto' => __( 'auto', 'super-duper' ), |
|
| 57 | + '0' => '0', |
|
| 58 | + '1' => '1', |
|
| 59 | + '2' => '2', |
|
| 60 | + '3' => '3', |
|
| 61 | + '4' => '4', |
|
| 62 | + '5' => '5', |
|
| 63 | + '6' => '6', |
|
| 64 | + '7' => '7', |
|
| 65 | + '8' => '8', |
|
| 66 | + '9' => '9', |
|
| 67 | + '10' => '10', |
|
| 68 | + '11' => '11', |
|
| 69 | + '12' => '12', |
|
| 70 | + ); |
|
| 71 | + |
|
| 72 | + if ( $include_negatives ) { |
|
| 73 | + $options['n1'] = '-1'; |
|
| 74 | + $options['n2'] = '-2'; |
|
| 75 | + $options['n3'] = '-3'; |
|
| 76 | + $options['n4'] = '-4'; |
|
| 77 | + $options['n5'] = '-5'; |
|
| 78 | + $options['n6'] = '-6'; |
|
| 79 | + $options['n7'] = '-7'; |
|
| 80 | + $options['n8'] = '-8'; |
|
| 81 | + $options['n9'] = '-9'; |
|
| 82 | + $options['n10'] = '-10'; |
|
| 83 | + $options['n11'] = '-11'; |
|
| 84 | + $options['n12'] = '-12'; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $defaults = array( |
|
| 88 | + 'type' => 'select', |
|
| 89 | + 'title' => __( 'Margin top', 'super-duper' ), |
|
| 90 | + 'options' => $options, |
|
| 91 | + 'default' => '', |
|
| 92 | + 'desc_tip' => true, |
|
| 93 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 94 | + ); |
|
| 95 | + |
|
| 96 | + // title |
|
| 97 | + if ( $type == 'mt' ) { |
|
| 98 | + $defaults['title'] = __( 'Margin top', 'super-duper' ); |
|
| 99 | + $defaults['icon'] = 'box-top'; |
|
| 100 | + $defaults['row'] = array( |
|
| 101 | + 'title' => __( 'Margins', 'super-duper' ), |
|
| 102 | + 'key' => 'wrapper-margins', |
|
| 103 | + 'open' => true, |
|
| 104 | + 'class' => 'text-center', |
|
| 105 | + ); |
|
| 106 | + } elseif ( $type == 'mr' ) { |
|
| 107 | + $defaults['title'] = __( 'Margin right', 'super-duper' ); |
|
| 108 | + $defaults['icon'] = 'box-right'; |
|
| 109 | + $defaults['row'] = array( |
|
| 110 | + 'key' => 'wrapper-margins', |
|
| 111 | + ); |
|
| 112 | + } elseif ( $type == 'mb' ) { |
|
| 113 | + $defaults['title'] = __( 'Margin bottom', 'super-duper' ); |
|
| 114 | + $defaults['icon'] = 'box-bottom'; |
|
| 115 | + $defaults['row'] = array( |
|
| 116 | + 'key' => 'wrapper-margins', |
|
| 117 | + ); |
|
| 118 | + } elseif ( $type == 'ml' ) { |
|
| 119 | + $defaults['title'] = __( 'Margin left', 'super-duper' ); |
|
| 120 | + $defaults['icon'] = 'box-left'; |
|
| 121 | + $defaults['row'] = array( |
|
| 122 | + 'key' => 'wrapper-margins', |
|
| 123 | + 'close' => true, |
|
| 124 | + ); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 128 | + |
|
| 129 | + return $input; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -138,67 +138,67 @@ discard block |
||
| 138 | 138 | * @return array |
| 139 | 139 | */ |
| 140 | 140 | function sd_get_padding_input( $type = 'pt', $overwrite = array() ) { |
| 141 | - $options = array( |
|
| 142 | - '' => __( 'None', 'super-duper' ), |
|
| 143 | - '0' => '0', |
|
| 144 | - '1' => '1', |
|
| 145 | - '2' => '2', |
|
| 146 | - '3' => '3', |
|
| 147 | - '4' => '4', |
|
| 148 | - '5' => '5', |
|
| 149 | - '6' => '6', |
|
| 150 | - '7' => '7', |
|
| 151 | - '8' => '8', |
|
| 152 | - '9' => '9', |
|
| 153 | - '10' => '10', |
|
| 154 | - '11' => '11', |
|
| 155 | - '12' => '12', |
|
| 156 | - ); |
|
| 157 | - |
|
| 158 | - $defaults = array( |
|
| 159 | - 'type' => 'select', |
|
| 160 | - 'title' => __( 'Padding top', 'super-duper' ), |
|
| 161 | - 'options' => $options, |
|
| 162 | - 'default' => '', |
|
| 163 | - 'desc_tip' => true, |
|
| 164 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 165 | - ); |
|
| 166 | - |
|
| 167 | - // title |
|
| 168 | - if ( $type == 'pt' ) { |
|
| 169 | - $defaults['title'] = __( 'Padding top', 'super-duper' ); |
|
| 170 | - $defaults['icon'] = 'box-top'; |
|
| 171 | - $defaults['row'] = array( |
|
| 172 | - 'title' => __( 'Padding', 'super-duper' ), |
|
| 173 | - 'key' => 'wrapper-padding', |
|
| 174 | - 'open' => true, |
|
| 175 | - 'class' => 'text-center', |
|
| 176 | - ); |
|
| 177 | - } elseif ( $type == 'pr' ) { |
|
| 178 | - $defaults['title'] = __( 'Padding right', 'super-duper' ); |
|
| 179 | - $defaults['icon'] = 'box-right'; |
|
| 180 | - $defaults['row'] = array( |
|
| 181 | - 'key' => 'wrapper-padding', |
|
| 182 | - ); |
|
| 183 | - } elseif ( $type == 'pb' ) { |
|
| 184 | - $defaults['title'] = __( 'Padding bottom', 'super-duper' ); |
|
| 185 | - $defaults['icon'] = 'box-bottom'; |
|
| 186 | - $defaults['row'] = array( |
|
| 187 | - 'key' => 'wrapper-padding', |
|
| 188 | - ); |
|
| 189 | - } elseif ( $type == 'pl' ) { |
|
| 190 | - $defaults['title'] = __( 'Padding left', 'super-duper' ); |
|
| 191 | - $defaults['icon'] = 'box-left'; |
|
| 192 | - $defaults['row'] = array( |
|
| 193 | - 'key' => 'wrapper-padding', |
|
| 194 | - 'close' => true, |
|
| 195 | - |
|
| 196 | - ); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 200 | - |
|
| 201 | - return $input; |
|
| 141 | + $options = array( |
|
| 142 | + '' => __( 'None', 'super-duper' ), |
|
| 143 | + '0' => '0', |
|
| 144 | + '1' => '1', |
|
| 145 | + '2' => '2', |
|
| 146 | + '3' => '3', |
|
| 147 | + '4' => '4', |
|
| 148 | + '5' => '5', |
|
| 149 | + '6' => '6', |
|
| 150 | + '7' => '7', |
|
| 151 | + '8' => '8', |
|
| 152 | + '9' => '9', |
|
| 153 | + '10' => '10', |
|
| 154 | + '11' => '11', |
|
| 155 | + '12' => '12', |
|
| 156 | + ); |
|
| 157 | + |
|
| 158 | + $defaults = array( |
|
| 159 | + 'type' => 'select', |
|
| 160 | + 'title' => __( 'Padding top', 'super-duper' ), |
|
| 161 | + 'options' => $options, |
|
| 162 | + 'default' => '', |
|
| 163 | + 'desc_tip' => true, |
|
| 164 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 165 | + ); |
|
| 166 | + |
|
| 167 | + // title |
|
| 168 | + if ( $type == 'pt' ) { |
|
| 169 | + $defaults['title'] = __( 'Padding top', 'super-duper' ); |
|
| 170 | + $defaults['icon'] = 'box-top'; |
|
| 171 | + $defaults['row'] = array( |
|
| 172 | + 'title' => __( 'Padding', 'super-duper' ), |
|
| 173 | + 'key' => 'wrapper-padding', |
|
| 174 | + 'open' => true, |
|
| 175 | + 'class' => 'text-center', |
|
| 176 | + ); |
|
| 177 | + } elseif ( $type == 'pr' ) { |
|
| 178 | + $defaults['title'] = __( 'Padding right', 'super-duper' ); |
|
| 179 | + $defaults['icon'] = 'box-right'; |
|
| 180 | + $defaults['row'] = array( |
|
| 181 | + 'key' => 'wrapper-padding', |
|
| 182 | + ); |
|
| 183 | + } elseif ( $type == 'pb' ) { |
|
| 184 | + $defaults['title'] = __( 'Padding bottom', 'super-duper' ); |
|
| 185 | + $defaults['icon'] = 'box-bottom'; |
|
| 186 | + $defaults['row'] = array( |
|
| 187 | + 'key' => 'wrapper-padding', |
|
| 188 | + ); |
|
| 189 | + } elseif ( $type == 'pl' ) { |
|
| 190 | + $defaults['title'] = __( 'Padding left', 'super-duper' ); |
|
| 191 | + $defaults['icon'] = 'box-left'; |
|
| 192 | + $defaults['row'] = array( |
|
| 193 | + 'key' => 'wrapper-padding', |
|
| 194 | + 'close' => true, |
|
| 195 | + |
|
| 196 | + ); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 200 | + |
|
| 201 | + return $input; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -210,97 +210,97 @@ discard block |
||
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | 212 | function sd_get_border_input( $type = 'border', $overwrite = array() ) { |
| 213 | - global $aui_bs5; |
|
| 214 | - |
|
| 215 | - $defaults = array( |
|
| 216 | - 'type' => 'select', |
|
| 217 | - 'title' => __( 'Border', 'super-duper' ), |
|
| 218 | - 'options' => array(), |
|
| 219 | - 'default' => '', |
|
| 220 | - 'desc_tip' => true, |
|
| 221 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 222 | - ); |
|
| 223 | - |
|
| 224 | - // title |
|
| 225 | - if ( 'rounded' === $type ) { |
|
| 226 | - $defaults['title'] = __( 'Border radius type', 'super-duper' ); |
|
| 227 | - $defaults['options'] = array( |
|
| 228 | - '' => __( 'Default', 'super-duper' ), |
|
| 229 | - 'rounded' => 'rounded', |
|
| 230 | - 'rounded-top' => 'rounded-top', |
|
| 231 | - 'rounded-right' => 'rounded-right', |
|
| 232 | - 'rounded-bottom' => 'rounded-bottom', |
|
| 233 | - 'rounded-left' => 'rounded-left', |
|
| 234 | - ); |
|
| 235 | - $defaults['element_require'] = '[%border%]'; |
|
| 236 | - } elseif ( 'rounded_size' === $type ) { |
|
| 237 | - $defaults['title'] = __( 'Border radius size', 'super-duper' ); |
|
| 238 | - |
|
| 239 | - if ( $aui_bs5 ) { |
|
| 240 | - $defaults['options'] = array( |
|
| 241 | - '' => __( 'Default', 'super-duper' ), |
|
| 242 | - '0' => '0', |
|
| 243 | - '1' => '1', |
|
| 244 | - '2' => '2', |
|
| 245 | - '3' => '3', |
|
| 246 | - '4' => '4', |
|
| 247 | - 'circle' => 'circle', |
|
| 248 | - 'pill' => 'pill', |
|
| 249 | - ); |
|
| 250 | - } else { |
|
| 251 | - $defaults['options'] = array( |
|
| 252 | - '' => __( 'Default', 'super-duper' ), |
|
| 253 | - 'sm' => __( 'Small', 'super-duper' ), |
|
| 254 | - 'lg' => __( 'Large', 'super-duper' ), |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - $defaults['element_require'] = '[%border%]'; |
|
| 258 | - } elseif ( 'width' === $type ) { // BS% |
|
| 259 | - $defaults['title'] = __( 'Border width', 'super-duper' ); |
|
| 260 | - $defaults['options'] = array( |
|
| 261 | - '' => __( 'Default', 'super-duper' ), |
|
| 262 | - 'border-2' => '2', |
|
| 263 | - 'border-3' => '3', |
|
| 264 | - 'border-4' => '4', |
|
| 265 | - 'border-5' => '5', |
|
| 266 | - ); |
|
| 267 | - $defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2'; |
|
| 268 | - } elseif ( 'opacity' === $type ) { // BS% |
|
| 269 | - $defaults['title'] = __( 'Border opacity', 'super-duper' ); |
|
| 270 | - $defaults['options'] = array( |
|
| 271 | - '' => __( 'Default', 'super-duper' ), |
|
| 272 | - 'border-opacity-75' => '75%', |
|
| 273 | - 'border-opacity-50' => '50%', |
|
| 274 | - 'border-opacity-25' => '25%', |
|
| 275 | - 'border-opacity-10' => '10%', |
|
| 276 | - ); |
|
| 277 | - $defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2'; |
|
| 278 | - } elseif ( 'type' === $type ) { |
|
| 279 | - $defaults['title'] = __( 'Border show', 'super-duper' ); |
|
| 280 | - $defaults['options'] = array( |
|
| 281 | - 'border' => __( 'Full (set color to show)', 'super-duper' ), |
|
| 282 | - 'border-top' => __( 'Top', 'super-duper' ), |
|
| 283 | - 'border-bottom' => __( 'Bottom', 'super-duper' ), |
|
| 284 | - 'border-left' => __( 'Left', 'super-duper' ), |
|
| 285 | - 'border-right' => __( 'Right', 'super-duper' ), |
|
| 286 | - 'border-top-0' => __( '-Top', 'super-duper' ), |
|
| 287 | - 'border-bottom-0' => __( '-Bottom', 'super-duper' ), |
|
| 288 | - 'border-left-0' => __( '-Left', 'super-duper' ), |
|
| 289 | - 'border-right-0' => __( '-Right', 'super-duper' ), |
|
| 290 | - ); |
|
| 291 | - $defaults['element_require'] = '[%border%]'; |
|
| 292 | - |
|
| 293 | - } else { |
|
| 294 | - $defaults['title'] = __( 'Border color', 'super-duper' ); |
|
| 295 | - $defaults['options'] = array( |
|
| 296 | - '' => __( 'Default', 'super-duper' ), |
|
| 297 | - '0' => __( 'None', 'super-duper' ), |
|
| 298 | - ) + sd_aui_colors(); |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 302 | - |
|
| 303 | - return $input; |
|
| 213 | + global $aui_bs5; |
|
| 214 | + |
|
| 215 | + $defaults = array( |
|
| 216 | + 'type' => 'select', |
|
| 217 | + 'title' => __( 'Border', 'super-duper' ), |
|
| 218 | + 'options' => array(), |
|
| 219 | + 'default' => '', |
|
| 220 | + 'desc_tip' => true, |
|
| 221 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 222 | + ); |
|
| 223 | + |
|
| 224 | + // title |
|
| 225 | + if ( 'rounded' === $type ) { |
|
| 226 | + $defaults['title'] = __( 'Border radius type', 'super-duper' ); |
|
| 227 | + $defaults['options'] = array( |
|
| 228 | + '' => __( 'Default', 'super-duper' ), |
|
| 229 | + 'rounded' => 'rounded', |
|
| 230 | + 'rounded-top' => 'rounded-top', |
|
| 231 | + 'rounded-right' => 'rounded-right', |
|
| 232 | + 'rounded-bottom' => 'rounded-bottom', |
|
| 233 | + 'rounded-left' => 'rounded-left', |
|
| 234 | + ); |
|
| 235 | + $defaults['element_require'] = '[%border%]'; |
|
| 236 | + } elseif ( 'rounded_size' === $type ) { |
|
| 237 | + $defaults['title'] = __( 'Border radius size', 'super-duper' ); |
|
| 238 | + |
|
| 239 | + if ( $aui_bs5 ) { |
|
| 240 | + $defaults['options'] = array( |
|
| 241 | + '' => __( 'Default', 'super-duper' ), |
|
| 242 | + '0' => '0', |
|
| 243 | + '1' => '1', |
|
| 244 | + '2' => '2', |
|
| 245 | + '3' => '3', |
|
| 246 | + '4' => '4', |
|
| 247 | + 'circle' => 'circle', |
|
| 248 | + 'pill' => 'pill', |
|
| 249 | + ); |
|
| 250 | + } else { |
|
| 251 | + $defaults['options'] = array( |
|
| 252 | + '' => __( 'Default', 'super-duper' ), |
|
| 253 | + 'sm' => __( 'Small', 'super-duper' ), |
|
| 254 | + 'lg' => __( 'Large', 'super-duper' ), |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + $defaults['element_require'] = '[%border%]'; |
|
| 258 | + } elseif ( 'width' === $type ) { // BS% |
|
| 259 | + $defaults['title'] = __( 'Border width', 'super-duper' ); |
|
| 260 | + $defaults['options'] = array( |
|
| 261 | + '' => __( 'Default', 'super-duper' ), |
|
| 262 | + 'border-2' => '2', |
|
| 263 | + 'border-3' => '3', |
|
| 264 | + 'border-4' => '4', |
|
| 265 | + 'border-5' => '5', |
|
| 266 | + ); |
|
| 267 | + $defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2'; |
|
| 268 | + } elseif ( 'opacity' === $type ) { // BS% |
|
| 269 | + $defaults['title'] = __( 'Border opacity', 'super-duper' ); |
|
| 270 | + $defaults['options'] = array( |
|
| 271 | + '' => __( 'Default', 'super-duper' ), |
|
| 272 | + 'border-opacity-75' => '75%', |
|
| 273 | + 'border-opacity-50' => '50%', |
|
| 274 | + 'border-opacity-25' => '25%', |
|
| 275 | + 'border-opacity-10' => '10%', |
|
| 276 | + ); |
|
| 277 | + $defaults['element_require'] = $aui_bs5 ? '[%border%]' : '1==2'; |
|
| 278 | + } elseif ( 'type' === $type ) { |
|
| 279 | + $defaults['title'] = __( 'Border show', 'super-duper' ); |
|
| 280 | + $defaults['options'] = array( |
|
| 281 | + 'border' => __( 'Full (set color to show)', 'super-duper' ), |
|
| 282 | + 'border-top' => __( 'Top', 'super-duper' ), |
|
| 283 | + 'border-bottom' => __( 'Bottom', 'super-duper' ), |
|
| 284 | + 'border-left' => __( 'Left', 'super-duper' ), |
|
| 285 | + 'border-right' => __( 'Right', 'super-duper' ), |
|
| 286 | + 'border-top-0' => __( '-Top', 'super-duper' ), |
|
| 287 | + 'border-bottom-0' => __( '-Bottom', 'super-duper' ), |
|
| 288 | + 'border-left-0' => __( '-Left', 'super-duper' ), |
|
| 289 | + 'border-right-0' => __( '-Right', 'super-duper' ), |
|
| 290 | + ); |
|
| 291 | + $defaults['element_require'] = '[%border%]'; |
|
| 292 | + |
|
| 293 | + } else { |
|
| 294 | + $defaults['title'] = __( 'Border color', 'super-duper' ); |
|
| 295 | + $defaults['options'] = array( |
|
| 296 | + '' => __( 'Default', 'super-duper' ), |
|
| 297 | + '0' => __( 'None', 'super-duper' ), |
|
| 298 | + ) + sd_aui_colors(); |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 302 | + |
|
| 303 | + return $input; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -312,25 +312,25 @@ discard block |
||
| 312 | 312 | * @return array |
| 313 | 313 | */ |
| 314 | 314 | function sd_get_shadow_input( $type = 'shadow', $overwrite = array() ) { |
| 315 | - $options = array( |
|
| 316 | - '' => __( 'None', 'super-duper' ), |
|
| 317 | - 'shadow-sm' => __( 'Small', 'super-duper' ), |
|
| 318 | - 'shadow' => __( 'Regular', 'super-duper' ), |
|
| 319 | - 'shadow-lg' => __( 'Large', 'super-duper' ), |
|
| 320 | - ); |
|
| 315 | + $options = array( |
|
| 316 | + '' => __( 'None', 'super-duper' ), |
|
| 317 | + 'shadow-sm' => __( 'Small', 'super-duper' ), |
|
| 318 | + 'shadow' => __( 'Regular', 'super-duper' ), |
|
| 319 | + 'shadow-lg' => __( 'Large', 'super-duper' ), |
|
| 320 | + ); |
|
| 321 | 321 | |
| 322 | - $defaults = array( |
|
| 323 | - 'type' => 'select', |
|
| 324 | - 'title' => __( 'Shadow', 'super-duper' ), |
|
| 325 | - 'options' => $options, |
|
| 326 | - 'default' => '', |
|
| 327 | - 'desc_tip' => true, |
|
| 328 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 329 | - ); |
|
| 322 | + $defaults = array( |
|
| 323 | + 'type' => 'select', |
|
| 324 | + 'title' => __( 'Shadow', 'super-duper' ), |
|
| 325 | + 'options' => $options, |
|
| 326 | + 'default' => '', |
|
| 327 | + 'desc_tip' => true, |
|
| 328 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 329 | + ); |
|
| 330 | 330 | |
| 331 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 331 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 332 | 332 | |
| 333 | - return $input; |
|
| 333 | + return $input; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -342,23 +342,23 @@ discard block |
||
| 342 | 342 | * @return array |
| 343 | 343 | */ |
| 344 | 344 | function sd_get_background_input( $type = 'bg', $overwrite = array() ) { |
| 345 | - $options = array( |
|
| 346 | - '' => __( 'None', 'super-duper' ), |
|
| 347 | - 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 348 | - ) + sd_aui_colors(); |
|
| 345 | + $options = array( |
|
| 346 | + '' => __( 'None', 'super-duper' ), |
|
| 347 | + 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 348 | + ) + sd_aui_colors(); |
|
| 349 | 349 | |
| 350 | - $defaults = array( |
|
| 351 | - 'type' => 'select', |
|
| 352 | - 'title' => __( 'Background color', 'super-duper' ), |
|
| 353 | - 'options' => $options, |
|
| 354 | - 'default' => '', |
|
| 355 | - 'desc_tip' => true, |
|
| 356 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 357 | - ); |
|
| 350 | + $defaults = array( |
|
| 351 | + 'type' => 'select', |
|
| 352 | + 'title' => __( 'Background color', 'super-duper' ), |
|
| 353 | + 'options' => $options, |
|
| 354 | + 'default' => '', |
|
| 355 | + 'desc_tip' => true, |
|
| 356 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 357 | + ); |
|
| 358 | 358 | |
| 359 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 359 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 360 | 360 | |
| 361 | - return $input; |
|
| 361 | + return $input; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -370,35 +370,35 @@ discard block |
||
| 370 | 370 | * @return array |
| 371 | 371 | */ |
| 372 | 372 | function sd_get_opacity_input( $type = 'opacity', $overwrite = array() ) { |
| 373 | - $options = array( |
|
| 374 | - '' => __( 'Default', 'super-duper' ), |
|
| 375 | - 'opacity-10' => '10%', |
|
| 376 | - 'opacity-15' => '15%', |
|
| 377 | - 'opacity-25' => '25%', |
|
| 378 | - 'opacity-35' => '35%', |
|
| 379 | - 'opacity-40' => '40%', |
|
| 380 | - 'opacity-50' => '50%', |
|
| 381 | - 'opacity-60' => '60%', |
|
| 382 | - 'opacity-65' => '65%', |
|
| 383 | - 'opacity-70' => '70%', |
|
| 384 | - 'opacity-75' => '75%', |
|
| 385 | - 'opacity-80' => '80%', |
|
| 386 | - 'opacity-90' => '90%', |
|
| 387 | - 'opacity-100' => '100%', |
|
| 388 | - ); |
|
| 389 | - |
|
| 390 | - $defaults = array( |
|
| 391 | - 'type' => 'select', |
|
| 392 | - 'title' => __( 'Opacity', 'super-duper' ), |
|
| 393 | - 'options' => $options, |
|
| 394 | - 'default' => '', |
|
| 395 | - 'desc_tip' => true, |
|
| 396 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 397 | - ); |
|
| 398 | - |
|
| 399 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 400 | - |
|
| 401 | - return $input; |
|
| 373 | + $options = array( |
|
| 374 | + '' => __( 'Default', 'super-duper' ), |
|
| 375 | + 'opacity-10' => '10%', |
|
| 376 | + 'opacity-15' => '15%', |
|
| 377 | + 'opacity-25' => '25%', |
|
| 378 | + 'opacity-35' => '35%', |
|
| 379 | + 'opacity-40' => '40%', |
|
| 380 | + 'opacity-50' => '50%', |
|
| 381 | + 'opacity-60' => '60%', |
|
| 382 | + 'opacity-65' => '65%', |
|
| 383 | + 'opacity-70' => '70%', |
|
| 384 | + 'opacity-75' => '75%', |
|
| 385 | + 'opacity-80' => '80%', |
|
| 386 | + 'opacity-90' => '90%', |
|
| 387 | + 'opacity-100' => '100%', |
|
| 388 | + ); |
|
| 389 | + |
|
| 390 | + $defaults = array( |
|
| 391 | + 'type' => 'select', |
|
| 392 | + 'title' => __( 'Opacity', 'super-duper' ), |
|
| 393 | + 'options' => $options, |
|
| 394 | + 'default' => '', |
|
| 395 | + 'desc_tip' => true, |
|
| 396 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 397 | + ); |
|
| 398 | + |
|
| 399 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 400 | + |
|
| 401 | + return $input; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -411,124 +411,124 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | function sd_get_background_inputs( $type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array(), $include_button_colors = false ) { |
| 413 | 413 | |
| 414 | - $color_options = $include_button_colors ? sd_aui_colors( false, true, true, true ) : sd_aui_colors(); |
|
| 415 | - |
|
| 416 | - $options = array( |
|
| 417 | - '' => __( 'None', 'super-duper' ), |
|
| 418 | - 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 419 | - ) + $color_options; |
|
| 420 | - |
|
| 421 | - if ( false !== $overwrite_color ) { |
|
| 422 | - $options['custom-color'] = __( 'Custom Color', 'super-duper' ); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - if ( false !== $overwrite_gradient ) { |
|
| 426 | - $options['custom-gradient'] = __( 'Custom Gradient', 'super-duper' ); |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - $defaults = array( |
|
| 430 | - 'type' => 'select', |
|
| 431 | - 'title' => __( 'Background Color', 'super-duper' ), |
|
| 432 | - 'options' => $options, |
|
| 433 | - 'default' => '', |
|
| 434 | - 'desc_tip' => true, |
|
| 435 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 436 | - ); |
|
| 437 | - |
|
| 438 | - if ( $overwrite !== false ) { |
|
| 439 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - if ( $overwrite_color !== false ) { |
|
| 443 | - $input[ $type . '_color' ] = wp_parse_args( |
|
| 444 | - $overwrite_color, |
|
| 445 | - array( |
|
| 446 | - 'type' => 'color', |
|
| 447 | - 'title' => __( 'Custom color', 'super-duper' ), |
|
| 448 | - 'placeholder' => '', |
|
| 449 | - 'default' => '#0073aa', |
|
| 450 | - 'desc_tip' => true, |
|
| 451 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 452 | - 'element_require' => '[%' . $type . '%]=="custom-color"', |
|
| 453 | - ) |
|
| 454 | - ); |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - if ( $overwrite_gradient !== false ) { |
|
| 458 | - $input[ $type . '_gradient' ] = wp_parse_args( |
|
| 459 | - $overwrite_gradient, |
|
| 460 | - array( |
|
| 461 | - 'type' => 'gradient', |
|
| 462 | - 'title' => __( 'Custom gradient', 'super-duper' ), |
|
| 463 | - 'placeholder' => '', |
|
| 464 | - 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 465 | - 'desc_tip' => true, |
|
| 466 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 467 | - 'element_require' => '[%' . $type . '%]=="custom-gradient"', |
|
| 468 | - ) |
|
| 469 | - ); |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - if ( $overwrite_image !== false ) { |
|
| 473 | - |
|
| 474 | - $input[ $type . '_image_fixed' ] = array( |
|
| 475 | - 'type' => 'checkbox', |
|
| 476 | - 'title' => __( 'Fixed background', 'super-duper' ), |
|
| 477 | - 'default' => '', |
|
| 478 | - 'desc_tip' => true, |
|
| 479 | - 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'super-duper' ), |
|
| 480 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 481 | - |
|
| 482 | - ); |
|
| 483 | - |
|
| 484 | - $input[ $type . '_image_use_featured' ] = array( |
|
| 485 | - 'type' => 'checkbox', |
|
| 486 | - 'title' => __( 'Use featured image', 'super-duper' ), |
|
| 487 | - 'default' => '', |
|
| 488 | - 'desc_tip' => true, |
|
| 489 | - 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'super-duper' ), |
|
| 490 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 491 | - |
|
| 492 | - ); |
|
| 493 | - |
|
| 494 | - $input[ $type . '_image' ] = wp_parse_args( |
|
| 495 | - $overwrite_image, |
|
| 496 | - array( |
|
| 497 | - 'type' => 'image', |
|
| 498 | - 'title' => __( 'Custom image', 'super-duper' ), |
|
| 499 | - 'placeholder' => '', |
|
| 500 | - 'default' => '', |
|
| 501 | - 'desc_tip' => true, |
|
| 502 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 503 | - // 'element_require' => ' ![%' . $type . '_image_use_featured%] ' |
|
| 504 | - ) |
|
| 505 | - ); |
|
| 506 | - |
|
| 507 | - $input[ $type . '_image_id' ] = wp_parse_args( |
|
| 508 | - $overwrite_image, |
|
| 509 | - array( |
|
| 510 | - 'type' => 'hidden', |
|
| 511 | - 'hidden_type' => 'number', |
|
| 512 | - 'title' => '', |
|
| 513 | - 'placeholder' => '', |
|
| 514 | - 'default' => '', |
|
| 515 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 516 | - ) |
|
| 517 | - ); |
|
| 518 | - |
|
| 519 | - $input[ $type . '_image_xy' ] = wp_parse_args( |
|
| 520 | - $overwrite_image, |
|
| 521 | - array( |
|
| 522 | - 'type' => 'image_xy', |
|
| 523 | - 'title' => '', |
|
| 524 | - 'placeholder' => '', |
|
| 525 | - 'default' => '', |
|
| 526 | - 'group' => __( 'Background', 'super-duper' ), |
|
| 527 | - ) |
|
| 528 | - ); |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - return $input; |
|
| 414 | + $color_options = $include_button_colors ? sd_aui_colors( false, true, true, true ) : sd_aui_colors(); |
|
| 415 | + |
|
| 416 | + $options = array( |
|
| 417 | + '' => __( 'None', 'super-duper' ), |
|
| 418 | + 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 419 | + ) + $color_options; |
|
| 420 | + |
|
| 421 | + if ( false !== $overwrite_color ) { |
|
| 422 | + $options['custom-color'] = __( 'Custom Color', 'super-duper' ); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + if ( false !== $overwrite_gradient ) { |
|
| 426 | + $options['custom-gradient'] = __( 'Custom Gradient', 'super-duper' ); |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + $defaults = array( |
|
| 430 | + 'type' => 'select', |
|
| 431 | + 'title' => __( 'Background Color', 'super-duper' ), |
|
| 432 | + 'options' => $options, |
|
| 433 | + 'default' => '', |
|
| 434 | + 'desc_tip' => true, |
|
| 435 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 436 | + ); |
|
| 437 | + |
|
| 438 | + if ( $overwrite !== false ) { |
|
| 439 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + if ( $overwrite_color !== false ) { |
|
| 443 | + $input[ $type . '_color' ] = wp_parse_args( |
|
| 444 | + $overwrite_color, |
|
| 445 | + array( |
|
| 446 | + 'type' => 'color', |
|
| 447 | + 'title' => __( 'Custom color', 'super-duper' ), |
|
| 448 | + 'placeholder' => '', |
|
| 449 | + 'default' => '#0073aa', |
|
| 450 | + 'desc_tip' => true, |
|
| 451 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 452 | + 'element_require' => '[%' . $type . '%]=="custom-color"', |
|
| 453 | + ) |
|
| 454 | + ); |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + if ( $overwrite_gradient !== false ) { |
|
| 458 | + $input[ $type . '_gradient' ] = wp_parse_args( |
|
| 459 | + $overwrite_gradient, |
|
| 460 | + array( |
|
| 461 | + 'type' => 'gradient', |
|
| 462 | + 'title' => __( 'Custom gradient', 'super-duper' ), |
|
| 463 | + 'placeholder' => '', |
|
| 464 | + 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 465 | + 'desc_tip' => true, |
|
| 466 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 467 | + 'element_require' => '[%' . $type . '%]=="custom-gradient"', |
|
| 468 | + ) |
|
| 469 | + ); |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + if ( $overwrite_image !== false ) { |
|
| 473 | + |
|
| 474 | + $input[ $type . '_image_fixed' ] = array( |
|
| 475 | + 'type' => 'checkbox', |
|
| 476 | + 'title' => __( 'Fixed background', 'super-duper' ), |
|
| 477 | + 'default' => '', |
|
| 478 | + 'desc_tip' => true, |
|
| 479 | + 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'super-duper' ), |
|
| 480 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 481 | + |
|
| 482 | + ); |
|
| 483 | + |
|
| 484 | + $input[ $type . '_image_use_featured' ] = array( |
|
| 485 | + 'type' => 'checkbox', |
|
| 486 | + 'title' => __( 'Use featured image', 'super-duper' ), |
|
| 487 | + 'default' => '', |
|
| 488 | + 'desc_tip' => true, |
|
| 489 | + 'group' => ! empty( $overwrite_image['group'] ) ? $overwrite_image['group'] : __( 'Background', 'super-duper' ), |
|
| 490 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )', |
|
| 491 | + |
|
| 492 | + ); |
|
| 493 | + |
|
| 494 | + $input[ $type . '_image' ] = wp_parse_args( |
|
| 495 | + $overwrite_image, |
|
| 496 | + array( |
|
| 497 | + 'type' => 'image', |
|
| 498 | + 'title' => __( 'Custom image', 'super-duper' ), |
|
| 499 | + 'placeholder' => '', |
|
| 500 | + 'default' => '', |
|
| 501 | + 'desc_tip' => true, |
|
| 502 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 503 | + // 'element_require' => ' ![%' . $type . '_image_use_featured%] ' |
|
| 504 | + ) |
|
| 505 | + ); |
|
| 506 | + |
|
| 507 | + $input[ $type . '_image_id' ] = wp_parse_args( |
|
| 508 | + $overwrite_image, |
|
| 509 | + array( |
|
| 510 | + 'type' => 'hidden', |
|
| 511 | + 'hidden_type' => 'number', |
|
| 512 | + 'title' => '', |
|
| 513 | + 'placeholder' => '', |
|
| 514 | + 'default' => '', |
|
| 515 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 516 | + ) |
|
| 517 | + ); |
|
| 518 | + |
|
| 519 | + $input[ $type . '_image_xy' ] = wp_parse_args( |
|
| 520 | + $overwrite_image, |
|
| 521 | + array( |
|
| 522 | + 'type' => 'image_xy', |
|
| 523 | + 'title' => '', |
|
| 524 | + 'placeholder' => '', |
|
| 525 | + 'default' => '', |
|
| 526 | + 'group' => __( 'Background', 'super-duper' ), |
|
| 527 | + ) |
|
| 528 | + ); |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + return $input; |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
@@ -541,175 +541,175 @@ discard block |
||
| 541 | 541 | */ |
| 542 | 542 | function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
| 543 | 543 | |
| 544 | - $options = array( |
|
| 545 | - '' => __( 'None', 'super-duper' ), |
|
| 546 | - 'mountains' => __( 'Mountains', 'super-duper' ), |
|
| 547 | - 'drops' => __( 'Drops', 'super-duper' ), |
|
| 548 | - 'clouds' => __( 'Clouds', 'super-duper' ), |
|
| 549 | - 'zigzag' => __( 'Zigzag', 'super-duper' ), |
|
| 550 | - 'pyramids' => __( 'Pyramids', 'super-duper' ), |
|
| 551 | - 'triangle' => __( 'Triangle', 'super-duper' ), |
|
| 552 | - 'triangle-asymmetrical' => __( 'Triangle Asymmetrical', 'super-duper' ), |
|
| 553 | - 'tilt' => __( 'Tilt', 'super-duper' ), |
|
| 554 | - 'opacity-tilt' => __( 'Opacity Tilt', 'super-duper' ), |
|
| 555 | - 'opacity-fan' => __( 'Opacity Fan', 'super-duper' ), |
|
| 556 | - 'curve' => __( 'Curve', 'super-duper' ), |
|
| 557 | - 'curve-asymmetrical' => __( 'Curve Asymmetrical', 'super-duper' ), |
|
| 558 | - 'waves' => __( 'Waves', 'super-duper' ), |
|
| 559 | - 'wave-brush' => __( 'Wave Brush', 'super-duper' ), |
|
| 560 | - 'waves-pattern' => __( 'Waves Pattern', 'super-duper' ), |
|
| 561 | - 'arrow' => __( 'Arrow', 'super-duper' ), |
|
| 562 | - 'split' => __( 'Split', 'super-duper' ), |
|
| 563 | - 'book' => __( 'Book', 'super-duper' ), |
|
| 564 | - ); |
|
| 565 | - |
|
| 566 | - $defaults = array( |
|
| 567 | - 'type' => 'select', |
|
| 568 | - 'title' => __( 'Type', 'super-duper' ), |
|
| 569 | - 'options' => $options, |
|
| 570 | - 'default' => '', |
|
| 571 | - 'desc_tip' => true, |
|
| 572 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 573 | - ); |
|
| 574 | - |
|
| 575 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 576 | - |
|
| 577 | - $input[ $type . '_notice' ] = array( |
|
| 578 | - 'type' => 'notice', |
|
| 579 | - 'desc' => __( 'Parent element must be position `relative`', 'super-duper' ), |
|
| 580 | - 'status' => 'warning', |
|
| 581 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 582 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 583 | - ); |
|
| 584 | - |
|
| 585 | - $input[ $type . '_position' ] = wp_parse_args( |
|
| 586 | - $overwrite_color, |
|
| 587 | - array( |
|
| 588 | - 'type' => 'select', |
|
| 589 | - 'title' => __( 'Position', 'super-duper' ), |
|
| 590 | - 'options' => array( |
|
| 591 | - 'top' => __( 'Top', 'super-duper' ), |
|
| 592 | - 'bottom' => __( 'Bottom', 'super-duper' ), |
|
| 593 | - ), |
|
| 594 | - 'desc_tip' => true, |
|
| 595 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 596 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 597 | - ) |
|
| 598 | - ); |
|
| 599 | - |
|
| 600 | - $options = array( |
|
| 601 | - '' => __( 'None', 'super-duper' ), |
|
| 602 | - 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 603 | - ) + sd_aui_colors() |
|
| 604 | - + array( |
|
| 605 | - 'custom-color' => __( 'Custom Color', 'super-duper' ), |
|
| 606 | - ); |
|
| 607 | - |
|
| 608 | - $input[ $type . '_color' ] = wp_parse_args( |
|
| 609 | - $overwrite_color, |
|
| 610 | - array( |
|
| 611 | - 'type' => 'select', |
|
| 612 | - 'title' => __( 'Color', 'super-duper' ), |
|
| 613 | - 'options' => $options, |
|
| 614 | - 'desc_tip' => true, |
|
| 615 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 616 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 617 | - ) |
|
| 618 | - ); |
|
| 619 | - |
|
| 620 | - $input[ $type . '_custom_color' ] = wp_parse_args( |
|
| 621 | - $overwrite_color, |
|
| 622 | - array( |
|
| 623 | - 'type' => 'color', |
|
| 624 | - 'title' => __( 'Custom color', 'super-duper' ), |
|
| 625 | - 'placeholder' => '', |
|
| 626 | - 'default' => '#0073aa', |
|
| 627 | - 'desc_tip' => true, |
|
| 628 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 629 | - 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""', |
|
| 630 | - ) |
|
| 631 | - ); |
|
| 632 | - |
|
| 633 | - $input[ $type . '_width' ] = wp_parse_args( |
|
| 634 | - $overwrite_gradient, |
|
| 635 | - array( |
|
| 636 | - 'type' => 'range', |
|
| 637 | - 'title' => __( 'Width', 'super-duper' ), |
|
| 638 | - 'placeholder' => '', |
|
| 639 | - 'default' => '200', |
|
| 640 | - 'desc_tip' => true, |
|
| 641 | - 'custom_attributes' => array( |
|
| 642 | - 'min' => 100, |
|
| 643 | - 'max' => 300, |
|
| 644 | - ), |
|
| 645 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 646 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 647 | - ) |
|
| 648 | - ); |
|
| 649 | - |
|
| 650 | - $input[ $type . '_height' ] = array( |
|
| 651 | - 'type' => 'range', |
|
| 652 | - 'title' => __( 'Height', 'super-duper' ), |
|
| 653 | - 'default' => '100', |
|
| 654 | - 'desc_tip' => true, |
|
| 655 | - 'custom_attributes' => array( |
|
| 656 | - 'min' => 0, |
|
| 657 | - 'max' => 500, |
|
| 658 | - ), |
|
| 659 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 660 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 661 | - ); |
|
| 662 | - |
|
| 663 | - $requires = array( |
|
| 664 | - 'mountains' => array( 'flip' ), |
|
| 665 | - 'drops' => array( 'flip', 'invert' ), |
|
| 666 | - 'clouds' => array( 'flip', 'invert' ), |
|
| 667 | - 'zigzag' => array(), |
|
| 668 | - 'pyramids' => array( 'flip', 'invert' ), |
|
| 669 | - 'triangle' => array( 'invert' ), |
|
| 670 | - 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 671 | - 'tilt' => array( 'flip' ), |
|
| 672 | - 'opacity-tilt' => array( 'flip' ), |
|
| 673 | - 'opacity-fan' => array(), |
|
| 674 | - 'curve' => array( 'invert' ), |
|
| 675 | - 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 676 | - 'waves' => array( 'flip', 'invert' ), |
|
| 677 | - 'wave-brush' => array( 'flip' ), |
|
| 678 | - 'waves-pattern' => array( 'flip' ), |
|
| 679 | - 'arrow' => array( 'invert' ), |
|
| 680 | - 'split' => array( 'invert' ), |
|
| 681 | - 'book' => array( 'invert' ), |
|
| 682 | - ); |
|
| 683 | - |
|
| 684 | - $input[ $type . '_flip' ] = array( |
|
| 685 | - 'type' => 'checkbox', |
|
| 686 | - 'title' => __( 'Flip', 'super-duper' ), |
|
| 687 | - 'default' => '', |
|
| 688 | - 'desc_tip' => true, |
|
| 689 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 690 | - 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ), |
|
| 691 | - ); |
|
| 692 | - |
|
| 693 | - $input[ $type . '_invert' ] = array( |
|
| 694 | - 'type' => 'checkbox', |
|
| 695 | - 'title' => __( 'Invert', 'super-duper' ), |
|
| 696 | - 'default' => '', |
|
| 697 | - 'desc_tip' => true, |
|
| 698 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 699 | - 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ), |
|
| 700 | - ); |
|
| 701 | - |
|
| 702 | - $input[ $type . '_btf' ] = array( |
|
| 703 | - 'type' => 'checkbox', |
|
| 704 | - 'title' => __( 'Bring to front', 'super-duper' ), |
|
| 705 | - 'default' => '', |
|
| 706 | - 'desc_tip' => true, |
|
| 707 | - 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 708 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 709 | - |
|
| 710 | - ); |
|
| 711 | - |
|
| 712 | - return $input; |
|
| 544 | + $options = array( |
|
| 545 | + '' => __( 'None', 'super-duper' ), |
|
| 546 | + 'mountains' => __( 'Mountains', 'super-duper' ), |
|
| 547 | + 'drops' => __( 'Drops', 'super-duper' ), |
|
| 548 | + 'clouds' => __( 'Clouds', 'super-duper' ), |
|
| 549 | + 'zigzag' => __( 'Zigzag', 'super-duper' ), |
|
| 550 | + 'pyramids' => __( 'Pyramids', 'super-duper' ), |
|
| 551 | + 'triangle' => __( 'Triangle', 'super-duper' ), |
|
| 552 | + 'triangle-asymmetrical' => __( 'Triangle Asymmetrical', 'super-duper' ), |
|
| 553 | + 'tilt' => __( 'Tilt', 'super-duper' ), |
|
| 554 | + 'opacity-tilt' => __( 'Opacity Tilt', 'super-duper' ), |
|
| 555 | + 'opacity-fan' => __( 'Opacity Fan', 'super-duper' ), |
|
| 556 | + 'curve' => __( 'Curve', 'super-duper' ), |
|
| 557 | + 'curve-asymmetrical' => __( 'Curve Asymmetrical', 'super-duper' ), |
|
| 558 | + 'waves' => __( 'Waves', 'super-duper' ), |
|
| 559 | + 'wave-brush' => __( 'Wave Brush', 'super-duper' ), |
|
| 560 | + 'waves-pattern' => __( 'Waves Pattern', 'super-duper' ), |
|
| 561 | + 'arrow' => __( 'Arrow', 'super-duper' ), |
|
| 562 | + 'split' => __( 'Split', 'super-duper' ), |
|
| 563 | + 'book' => __( 'Book', 'super-duper' ), |
|
| 564 | + ); |
|
| 565 | + |
|
| 566 | + $defaults = array( |
|
| 567 | + 'type' => 'select', |
|
| 568 | + 'title' => __( 'Type', 'super-duper' ), |
|
| 569 | + 'options' => $options, |
|
| 570 | + 'default' => '', |
|
| 571 | + 'desc_tip' => true, |
|
| 572 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 573 | + ); |
|
| 574 | + |
|
| 575 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 576 | + |
|
| 577 | + $input[ $type . '_notice' ] = array( |
|
| 578 | + 'type' => 'notice', |
|
| 579 | + 'desc' => __( 'Parent element must be position `relative`', 'super-duper' ), |
|
| 580 | + 'status' => 'warning', |
|
| 581 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 582 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 583 | + ); |
|
| 584 | + |
|
| 585 | + $input[ $type . '_position' ] = wp_parse_args( |
|
| 586 | + $overwrite_color, |
|
| 587 | + array( |
|
| 588 | + 'type' => 'select', |
|
| 589 | + 'title' => __( 'Position', 'super-duper' ), |
|
| 590 | + 'options' => array( |
|
| 591 | + 'top' => __( 'Top', 'super-duper' ), |
|
| 592 | + 'bottom' => __( 'Bottom', 'super-duper' ), |
|
| 593 | + ), |
|
| 594 | + 'desc_tip' => true, |
|
| 595 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 596 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 597 | + ) |
|
| 598 | + ); |
|
| 599 | + |
|
| 600 | + $options = array( |
|
| 601 | + '' => __( 'None', 'super-duper' ), |
|
| 602 | + 'transparent' => __( 'Transparent', 'super-duper' ), |
|
| 603 | + ) + sd_aui_colors() |
|
| 604 | + + array( |
|
| 605 | + 'custom-color' => __( 'Custom Color', 'super-duper' ), |
|
| 606 | + ); |
|
| 607 | + |
|
| 608 | + $input[ $type . '_color' ] = wp_parse_args( |
|
| 609 | + $overwrite_color, |
|
| 610 | + array( |
|
| 611 | + 'type' => 'select', |
|
| 612 | + 'title' => __( 'Color', 'super-duper' ), |
|
| 613 | + 'options' => $options, |
|
| 614 | + 'desc_tip' => true, |
|
| 615 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 616 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 617 | + ) |
|
| 618 | + ); |
|
| 619 | + |
|
| 620 | + $input[ $type . '_custom_color' ] = wp_parse_args( |
|
| 621 | + $overwrite_color, |
|
| 622 | + array( |
|
| 623 | + 'type' => 'color', |
|
| 624 | + 'title' => __( 'Custom color', 'super-duper' ), |
|
| 625 | + 'placeholder' => '', |
|
| 626 | + 'default' => '#0073aa', |
|
| 627 | + 'desc_tip' => true, |
|
| 628 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 629 | + 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""', |
|
| 630 | + ) |
|
| 631 | + ); |
|
| 632 | + |
|
| 633 | + $input[ $type . '_width' ] = wp_parse_args( |
|
| 634 | + $overwrite_gradient, |
|
| 635 | + array( |
|
| 636 | + 'type' => 'range', |
|
| 637 | + 'title' => __( 'Width', 'super-duper' ), |
|
| 638 | + 'placeholder' => '', |
|
| 639 | + 'default' => '200', |
|
| 640 | + 'desc_tip' => true, |
|
| 641 | + 'custom_attributes' => array( |
|
| 642 | + 'min' => 100, |
|
| 643 | + 'max' => 300, |
|
| 644 | + ), |
|
| 645 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 646 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 647 | + ) |
|
| 648 | + ); |
|
| 649 | + |
|
| 650 | + $input[ $type . '_height' ] = array( |
|
| 651 | + 'type' => 'range', |
|
| 652 | + 'title' => __( 'Height', 'super-duper' ), |
|
| 653 | + 'default' => '100', |
|
| 654 | + 'desc_tip' => true, |
|
| 655 | + 'custom_attributes' => array( |
|
| 656 | + 'min' => 0, |
|
| 657 | + 'max' => 500, |
|
| 658 | + ), |
|
| 659 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 660 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 661 | + ); |
|
| 662 | + |
|
| 663 | + $requires = array( |
|
| 664 | + 'mountains' => array( 'flip' ), |
|
| 665 | + 'drops' => array( 'flip', 'invert' ), |
|
| 666 | + 'clouds' => array( 'flip', 'invert' ), |
|
| 667 | + 'zigzag' => array(), |
|
| 668 | + 'pyramids' => array( 'flip', 'invert' ), |
|
| 669 | + 'triangle' => array( 'invert' ), |
|
| 670 | + 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 671 | + 'tilt' => array( 'flip' ), |
|
| 672 | + 'opacity-tilt' => array( 'flip' ), |
|
| 673 | + 'opacity-fan' => array(), |
|
| 674 | + 'curve' => array( 'invert' ), |
|
| 675 | + 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 676 | + 'waves' => array( 'flip', 'invert' ), |
|
| 677 | + 'wave-brush' => array( 'flip' ), |
|
| 678 | + 'waves-pattern' => array( 'flip' ), |
|
| 679 | + 'arrow' => array( 'invert' ), |
|
| 680 | + 'split' => array( 'invert' ), |
|
| 681 | + 'book' => array( 'invert' ), |
|
| 682 | + ); |
|
| 683 | + |
|
| 684 | + $input[ $type . '_flip' ] = array( |
|
| 685 | + 'type' => 'checkbox', |
|
| 686 | + 'title' => __( 'Flip', 'super-duper' ), |
|
| 687 | + 'default' => '', |
|
| 688 | + 'desc_tip' => true, |
|
| 689 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 690 | + 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ), |
|
| 691 | + ); |
|
| 692 | + |
|
| 693 | + $input[ $type . '_invert' ] = array( |
|
| 694 | + 'type' => 'checkbox', |
|
| 695 | + 'title' => __( 'Invert', 'super-duper' ), |
|
| 696 | + 'default' => '', |
|
| 697 | + 'desc_tip' => true, |
|
| 698 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 699 | + 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ), |
|
| 700 | + ); |
|
| 701 | + |
|
| 702 | + $input[ $type . '_btf' ] = array( |
|
| 703 | + 'type' => 'checkbox', |
|
| 704 | + 'title' => __( 'Bring to front', 'super-duper' ), |
|
| 705 | + 'default' => '', |
|
| 706 | + 'desc_tip' => true, |
|
| 707 | + 'group' => __( 'Shape Divider', 'super-duper' ), |
|
| 708 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 709 | + |
|
| 710 | + ); |
|
| 711 | + |
|
| 712 | + return $input; |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | /** |
@@ -722,22 +722,22 @@ discard block |
||
| 722 | 722 | * @return string |
| 723 | 723 | */ |
| 724 | 724 | function sd_get_element_require_string( $args, $key, $type ) { |
| 725 | - $output = ''; |
|
| 726 | - $requires = array(); |
|
| 725 | + $output = ''; |
|
| 726 | + $requires = array(); |
|
| 727 | 727 | |
| 728 | - if ( ! empty( $args ) ) { |
|
| 729 | - foreach ( $args as $t => $k ) { |
|
| 730 | - if ( in_array( $key, $k ) ) { |
|
| 731 | - $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 732 | - } |
|
| 733 | - } |
|
| 728 | + if ( ! empty( $args ) ) { |
|
| 729 | + foreach ( $args as $t => $k ) { |
|
| 730 | + if ( in_array( $key, $k ) ) { |
|
| 731 | + $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 732 | + } |
|
| 733 | + } |
|
| 734 | 734 | |
| 735 | - if ( ! empty( $requires ) ) { |
|
| 736 | - $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 737 | - } |
|
| 738 | - } |
|
| 735 | + if ( ! empty( $requires ) ) { |
|
| 736 | + $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 737 | + } |
|
| 738 | + } |
|
| 739 | 739 | |
| 740 | - return $output; |
|
| 740 | + return $output; |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /** |
@@ -749,41 +749,41 @@ discard block |
||
| 749 | 749 | * @return array |
| 750 | 750 | */ |
| 751 | 751 | function sd_get_text_color_input( $type = 'text_color', $overwrite = array(), $has_custom = false ) { |
| 752 | - $options = array( |
|
| 753 | - '' => __( 'None', 'super-duper' ), |
|
| 754 | - ) + sd_aui_colors(); |
|
| 752 | + $options = array( |
|
| 753 | + '' => __( 'None', 'super-duper' ), |
|
| 754 | + ) + sd_aui_colors(); |
|
| 755 | 755 | |
| 756 | - if ( $has_custom ) { |
|
| 757 | - $options['custom'] = __( 'Custom color', 'super-duper' ); |
|
| 758 | - } |
|
| 756 | + if ( $has_custom ) { |
|
| 757 | + $options['custom'] = __( 'Custom color', 'super-duper' ); |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | - $defaults = array( |
|
| 761 | - 'type' => 'select', |
|
| 762 | - 'title' => __( 'Text color', 'super-duper' ), |
|
| 763 | - 'options' => $options, |
|
| 764 | - 'default' => '', |
|
| 765 | - 'desc_tip' => true, |
|
| 766 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 767 | - ); |
|
| 760 | + $defaults = array( |
|
| 761 | + 'type' => 'select', |
|
| 762 | + 'title' => __( 'Text color', 'super-duper' ), |
|
| 763 | + 'options' => $options, |
|
| 764 | + 'default' => '', |
|
| 765 | + 'desc_tip' => true, |
|
| 766 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 767 | + ); |
|
| 768 | 768 | |
| 769 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 769 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 770 | 770 | |
| 771 | - return $input; |
|
| 771 | + return $input; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | function sd_get_text_color_input_group( $type = 'text_color', $overwrite = array(), $overwrite_custom = array() ) { |
| 775 | - $inputs = array(); |
|
| 775 | + $inputs = array(); |
|
| 776 | 776 | |
| 777 | - if ( $overwrite !== false ) { |
|
| 778 | - $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 779 | - } |
|
| 777 | + if ( $overwrite !== false ) { |
|
| 778 | + $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 779 | + } |
|
| 780 | 780 | |
| 781 | - if ( $overwrite_custom !== false ) { |
|
| 782 | - $custom = $type . '_custom'; |
|
| 783 | - $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 784 | - } |
|
| 781 | + if ( $overwrite_custom !== false ) { |
|
| 782 | + $custom = $type . '_custom'; |
|
| 783 | + $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 784 | + } |
|
| 785 | 785 | |
| 786 | - return $inputs; |
|
| 786 | + return $inputs; |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /** |
@@ -796,22 +796,22 @@ discard block |
||
| 796 | 796 | */ |
| 797 | 797 | function sd_get_custom_color_input( $type = 'color_custom', $overwrite = array(), $parent_type = '' ) { |
| 798 | 798 | |
| 799 | - $defaults = array( |
|
| 800 | - 'type' => 'color', |
|
| 801 | - 'title' => __( 'Custom color', 'super-duper' ), |
|
| 802 | - 'default' => '', |
|
| 803 | - 'placeholder' => '', |
|
| 804 | - 'desc_tip' => true, |
|
| 805 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 806 | - ); |
|
| 799 | + $defaults = array( |
|
| 800 | + 'type' => 'color', |
|
| 801 | + 'title' => __( 'Custom color', 'super-duper' ), |
|
| 802 | + 'default' => '', |
|
| 803 | + 'placeholder' => '', |
|
| 804 | + 'desc_tip' => true, |
|
| 805 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 806 | + ); |
|
| 807 | 807 | |
| 808 | - if ( $parent_type ) { |
|
| 809 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 810 | - } |
|
| 808 | + if ( $parent_type ) { |
|
| 809 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 810 | + } |
|
| 811 | 811 | |
| 812 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 812 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 813 | 813 | |
| 814 | - return $input; |
|
| 814 | + return $input; |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /** |
@@ -824,44 +824,44 @@ discard block |
||
| 824 | 824 | */ |
| 825 | 825 | function sd_get_col_input( $type = 'col', $overwrite = array() ) { |
| 826 | 826 | |
| 827 | - $device_size = ''; |
|
| 828 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 829 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 830 | - $device_size = '-md'; |
|
| 831 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 832 | - $device_size = '-lg'; |
|
| 833 | - } |
|
| 834 | - } |
|
| 835 | - $options = array( |
|
| 836 | - '' => __( 'Default', 'super-duper' ), |
|
| 837 | - 'auto' => __( 'auto', 'super-duper' ), |
|
| 838 | - '1' => '1/12', |
|
| 839 | - '2' => '2/12', |
|
| 840 | - '3' => '3/12', |
|
| 841 | - '4' => '4/12', |
|
| 842 | - '5' => '5/12', |
|
| 843 | - '6' => '6/12', |
|
| 844 | - '7' => '7/12', |
|
| 845 | - '8' => '8/12', |
|
| 846 | - '9' => '9/12', |
|
| 847 | - '10' => '10/12', |
|
| 848 | - '11' => '11/12', |
|
| 849 | - '12' => '12/12', |
|
| 850 | - ); |
|
| 851 | - |
|
| 852 | - $defaults = array( |
|
| 853 | - 'type' => 'select', |
|
| 854 | - 'title' => __( 'Column width', 'super-duper' ), |
|
| 855 | - 'options' => $options, |
|
| 856 | - 'default' => '', |
|
| 857 | - 'desc_tip' => true, |
|
| 858 | - 'group' => __( 'Container', 'super-duper' ), |
|
| 859 | - 'element_require' => '[%container%]=="col"', |
|
| 860 | - ); |
|
| 861 | - |
|
| 862 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 863 | - |
|
| 864 | - return $input; |
|
| 827 | + $device_size = ''; |
|
| 828 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 829 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 830 | + $device_size = '-md'; |
|
| 831 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 832 | + $device_size = '-lg'; |
|
| 833 | + } |
|
| 834 | + } |
|
| 835 | + $options = array( |
|
| 836 | + '' => __( 'Default', 'super-duper' ), |
|
| 837 | + 'auto' => __( 'auto', 'super-duper' ), |
|
| 838 | + '1' => '1/12', |
|
| 839 | + '2' => '2/12', |
|
| 840 | + '3' => '3/12', |
|
| 841 | + '4' => '4/12', |
|
| 842 | + '5' => '5/12', |
|
| 843 | + '6' => '6/12', |
|
| 844 | + '7' => '7/12', |
|
| 845 | + '8' => '8/12', |
|
| 846 | + '9' => '9/12', |
|
| 847 | + '10' => '10/12', |
|
| 848 | + '11' => '11/12', |
|
| 849 | + '12' => '12/12', |
|
| 850 | + ); |
|
| 851 | + |
|
| 852 | + $defaults = array( |
|
| 853 | + 'type' => 'select', |
|
| 854 | + 'title' => __( 'Column width', 'super-duper' ), |
|
| 855 | + 'options' => $options, |
|
| 856 | + 'default' => '', |
|
| 857 | + 'desc_tip' => true, |
|
| 858 | + 'group' => __( 'Container', 'super-duper' ), |
|
| 859 | + 'element_require' => '[%container%]=="col"', |
|
| 860 | + ); |
|
| 861 | + |
|
| 862 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 863 | + |
|
| 864 | + return $input; |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | /** |
@@ -874,37 +874,37 @@ discard block |
||
| 874 | 874 | */ |
| 875 | 875 | function sd_get_row_cols_input( $type = 'row_cols', $overwrite = array() ) { |
| 876 | 876 | |
| 877 | - $device_size = ''; |
|
| 878 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 879 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 880 | - $device_size = '-md'; |
|
| 881 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 882 | - $device_size = '-lg'; |
|
| 883 | - } |
|
| 884 | - } |
|
| 885 | - $options = array( |
|
| 886 | - '' => __( 'auto', 'super-duper' ), |
|
| 887 | - '1' => '1', |
|
| 888 | - '2' => '2', |
|
| 889 | - '3' => '3', |
|
| 890 | - '4' => '4', |
|
| 891 | - '5' => '5', |
|
| 892 | - '6' => '6', |
|
| 893 | - ); |
|
| 894 | - |
|
| 895 | - $defaults = array( |
|
| 896 | - 'type' => 'select', |
|
| 897 | - 'title' => __( 'Row columns', 'super-duper' ), |
|
| 898 | - 'options' => $options, |
|
| 899 | - 'default' => '', |
|
| 900 | - 'desc_tip' => true, |
|
| 901 | - 'group' => __( 'Container', 'super-duper' ), |
|
| 902 | - 'element_require' => '[%container%]=="row"', |
|
| 903 | - ); |
|
| 904 | - |
|
| 905 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 906 | - |
|
| 907 | - return $input; |
|
| 877 | + $device_size = ''; |
|
| 878 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 879 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 880 | + $device_size = '-md'; |
|
| 881 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 882 | + $device_size = '-lg'; |
|
| 883 | + } |
|
| 884 | + } |
|
| 885 | + $options = array( |
|
| 886 | + '' => __( 'auto', 'super-duper' ), |
|
| 887 | + '1' => '1', |
|
| 888 | + '2' => '2', |
|
| 889 | + '3' => '3', |
|
| 890 | + '4' => '4', |
|
| 891 | + '5' => '5', |
|
| 892 | + '6' => '6', |
|
| 893 | + ); |
|
| 894 | + |
|
| 895 | + $defaults = array( |
|
| 896 | + 'type' => 'select', |
|
| 897 | + 'title' => __( 'Row columns', 'super-duper' ), |
|
| 898 | + 'options' => $options, |
|
| 899 | + 'default' => '', |
|
| 900 | + 'desc_tip' => true, |
|
| 901 | + 'group' => __( 'Container', 'super-duper' ), |
|
| 902 | + 'element_require' => '[%container%]=="row"', |
|
| 903 | + ); |
|
| 904 | + |
|
| 905 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 906 | + |
|
| 907 | + return $input; |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | /** |
@@ -917,33 +917,33 @@ discard block |
||
| 917 | 917 | */ |
| 918 | 918 | function sd_get_text_align_input( $type = 'text_align', $overwrite = array() ) { |
| 919 | 919 | |
| 920 | - $device_size = ''; |
|
| 921 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 922 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 923 | - $device_size = '-md'; |
|
| 924 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 925 | - $device_size = '-lg'; |
|
| 926 | - } |
|
| 927 | - } |
|
| 928 | - $options = array( |
|
| 929 | - '' => __( 'Default', 'super-duper' ), |
|
| 930 | - 'text' . $device_size . '-left' => __( 'Left', 'super-duper' ), |
|
| 931 | - 'text' . $device_size . '-right' => __( 'Right', 'super-duper' ), |
|
| 932 | - 'text' . $device_size . '-center' => __( 'Center', 'super-duper' ), |
|
| 933 | - ); |
|
| 934 | - |
|
| 935 | - $defaults = array( |
|
| 936 | - 'type' => 'select', |
|
| 937 | - 'title' => __( 'Text align', 'super-duper' ), |
|
| 938 | - 'options' => $options, |
|
| 939 | - 'default' => '', |
|
| 940 | - 'desc_tip' => true, |
|
| 941 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 942 | - ); |
|
| 943 | - |
|
| 944 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 945 | - |
|
| 946 | - return $input; |
|
| 920 | + $device_size = ''; |
|
| 921 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 922 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 923 | + $device_size = '-md'; |
|
| 924 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 925 | + $device_size = '-lg'; |
|
| 926 | + } |
|
| 927 | + } |
|
| 928 | + $options = array( |
|
| 929 | + '' => __( 'Default', 'super-duper' ), |
|
| 930 | + 'text' . $device_size . '-left' => __( 'Left', 'super-duper' ), |
|
| 931 | + 'text' . $device_size . '-right' => __( 'Right', 'super-duper' ), |
|
| 932 | + 'text' . $device_size . '-center' => __( 'Center', 'super-duper' ), |
|
| 933 | + ); |
|
| 934 | + |
|
| 935 | + $defaults = array( |
|
| 936 | + 'type' => 'select', |
|
| 937 | + 'title' => __( 'Text align', 'super-duper' ), |
|
| 938 | + 'options' => $options, |
|
| 939 | + 'default' => '', |
|
| 940 | + 'desc_tip' => true, |
|
| 941 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 942 | + ); |
|
| 943 | + |
|
| 944 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 945 | + |
|
| 946 | + return $input; |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | /** |
@@ -956,39 +956,39 @@ discard block |
||
| 956 | 956 | */ |
| 957 | 957 | function sd_get_display_input( $type = 'display', $overwrite = array() ) { |
| 958 | 958 | |
| 959 | - $device_size = ''; |
|
| 960 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 961 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 962 | - $device_size = '-md'; |
|
| 963 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 964 | - $device_size = '-lg'; |
|
| 965 | - } |
|
| 966 | - } |
|
| 967 | - $options = array( |
|
| 968 | - '' => __( 'Default', 'super-duper' ), |
|
| 969 | - 'd' . $device_size . '-none' => 'none', |
|
| 970 | - 'd' . $device_size . '-inline' => 'inline', |
|
| 971 | - 'd' . $device_size . '-inline-block' => 'inline-block', |
|
| 972 | - 'd' . $device_size . '-block' => 'block', |
|
| 973 | - 'd' . $device_size . '-table' => 'table', |
|
| 974 | - 'd' . $device_size . '-table-cell' => 'table-cell', |
|
| 975 | - 'd' . $device_size . '-table-row' => 'table-row', |
|
| 976 | - 'd' . $device_size . '-flex' => 'flex', |
|
| 977 | - 'd' . $device_size . '-inline-flex' => 'inline-flex', |
|
| 978 | - ); |
|
| 979 | - |
|
| 980 | - $defaults = array( |
|
| 981 | - 'type' => 'select', |
|
| 982 | - 'title' => __( 'Display', 'super-duper' ), |
|
| 983 | - 'options' => $options, |
|
| 984 | - 'default' => '', |
|
| 985 | - 'desc_tip' => true, |
|
| 986 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 987 | - ); |
|
| 988 | - |
|
| 989 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 990 | - |
|
| 991 | - return $input; |
|
| 959 | + $device_size = ''; |
|
| 960 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 961 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 962 | + $device_size = '-md'; |
|
| 963 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 964 | + $device_size = '-lg'; |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | + $options = array( |
|
| 968 | + '' => __( 'Default', 'super-duper' ), |
|
| 969 | + 'd' . $device_size . '-none' => 'none', |
|
| 970 | + 'd' . $device_size . '-inline' => 'inline', |
|
| 971 | + 'd' . $device_size . '-inline-block' => 'inline-block', |
|
| 972 | + 'd' . $device_size . '-block' => 'block', |
|
| 973 | + 'd' . $device_size . '-table' => 'table', |
|
| 974 | + 'd' . $device_size . '-table-cell' => 'table-cell', |
|
| 975 | + 'd' . $device_size . '-table-row' => 'table-row', |
|
| 976 | + 'd' . $device_size . '-flex' => 'flex', |
|
| 977 | + 'd' . $device_size . '-inline-flex' => 'inline-flex', |
|
| 978 | + ); |
|
| 979 | + |
|
| 980 | + $defaults = array( |
|
| 981 | + 'type' => 'select', |
|
| 982 | + 'title' => __( 'Display', 'super-duper' ), |
|
| 983 | + 'options' => $options, |
|
| 984 | + 'default' => '', |
|
| 985 | + 'desc_tip' => true, |
|
| 986 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 987 | + ); |
|
| 988 | + |
|
| 989 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 990 | + |
|
| 991 | + return $input; |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | /** |
@@ -1001,17 +1001,17 @@ discard block |
||
| 1001 | 1001 | */ |
| 1002 | 1002 | function sd_get_text_justify_input( $type = 'text_justify', $overwrite = array() ) { |
| 1003 | 1003 | |
| 1004 | - $defaults = array( |
|
| 1005 | - 'type' => 'checkbox', |
|
| 1006 | - 'title' => __( 'Text justify', 'super-duper' ), |
|
| 1007 | - 'default' => '', |
|
| 1008 | - 'desc_tip' => true, |
|
| 1009 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1010 | - ); |
|
| 1004 | + $defaults = array( |
|
| 1005 | + 'type' => 'checkbox', |
|
| 1006 | + 'title' => __( 'Text justify', 'super-duper' ), |
|
| 1007 | + 'default' => '', |
|
| 1008 | + 'desc_tip' => true, |
|
| 1009 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1010 | + ); |
|
| 1011 | 1011 | |
| 1012 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1012 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1013 | 1013 | |
| 1014 | - return $input; |
|
| 1014 | + return $input; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | /** |
@@ -1024,72 +1024,72 @@ discard block |
||
| 1024 | 1024 | * @return array |
| 1025 | 1025 | */ |
| 1026 | 1026 | function sd_aui_colors( $include_branding = false, $include_outlines = false, $outline_button_only_text = false, $include_translucent = false ) { |
| 1027 | - $theme_colors = array(); |
|
| 1028 | - |
|
| 1029 | - $theme_colors['primary'] = __( 'Primary', 'super-duper' ); |
|
| 1030 | - $theme_colors['secondary'] = __( 'Secondary', 'super-duper' ); |
|
| 1031 | - $theme_colors['success'] = __( 'Success', 'super-duper' ); |
|
| 1032 | - $theme_colors['danger'] = __( 'Danger', 'super-duper' ); |
|
| 1033 | - $theme_colors['warning'] = __( 'Warning', 'super-duper' ); |
|
| 1034 | - $theme_colors['info'] = __( 'Info', 'super-duper' ); |
|
| 1035 | - $theme_colors['light'] = __( 'Light', 'super-duper' ); |
|
| 1036 | - $theme_colors['dark'] = __( 'Dark', 'super-duper' ); |
|
| 1037 | - $theme_colors['black'] = __( 'Black', 'super-duper' ); |
|
| 1038 | - $theme_colors['white'] = __( 'White', 'super-duper' ); |
|
| 1039 | - $theme_colors['purple'] = __( 'Purple', 'super-duper' ); |
|
| 1040 | - $theme_colors['salmon'] = __( 'Salmon', 'super-duper' ); |
|
| 1041 | - $theme_colors['cyan'] = __( 'Cyan', 'super-duper' ); |
|
| 1042 | - $theme_colors['gray'] = __( 'Gray', 'super-duper' ); |
|
| 1043 | - $theme_colors['muted'] = __( 'Muted', 'super-duper' ); |
|
| 1044 | - $theme_colors['gray-dark'] = __( 'Gray dark', 'super-duper' ); |
|
| 1045 | - $theme_colors['indigo'] = __( 'Indigo', 'super-duper' ); |
|
| 1046 | - $theme_colors['orange'] = __( 'Orange', 'super-duper' ); |
|
| 1047 | - |
|
| 1048 | - if ( $include_outlines ) { |
|
| 1049 | - $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'super-duper' ) : ''; |
|
| 1050 | - $theme_colors['outline-primary'] = __( 'Primary outline', 'super-duper' ) . $button_only; |
|
| 1051 | - $theme_colors['outline-secondary'] = __( 'Secondary outline', 'super-duper' ) . $button_only; |
|
| 1052 | - $theme_colors['outline-success'] = __( 'Success outline', 'super-duper' ) . $button_only; |
|
| 1053 | - $theme_colors['outline-danger'] = __( 'Danger outline', 'super-duper' ) . $button_only; |
|
| 1054 | - $theme_colors['outline-warning'] = __( 'Warning outline', 'super-duper' ) . $button_only; |
|
| 1055 | - $theme_colors['outline-info'] = __( 'Info outline', 'super-duper' ) . $button_only; |
|
| 1056 | - $theme_colors['outline-light'] = __( 'Light outline', 'super-duper' ) . $button_only; |
|
| 1057 | - $theme_colors['outline-dark'] = __( 'Dark outline', 'super-duper' ) . $button_only; |
|
| 1058 | - $theme_colors['outline-white'] = __( 'White outline', 'super-duper' ) . $button_only; |
|
| 1059 | - $theme_colors['outline-purple'] = __( 'Purple outline', 'super-duper' ) . $button_only; |
|
| 1060 | - $theme_colors['outline-salmon'] = __( 'Salmon outline', 'super-duper' ) . $button_only; |
|
| 1061 | - $theme_colors['outline-cyan'] = __( 'Cyan outline', 'super-duper' ) . $button_only; |
|
| 1062 | - $theme_colors['outline-gray'] = __( 'Gray outline', 'super-duper' ) . $button_only; |
|
| 1063 | - $theme_colors['outline-gray-dark'] = __( 'Gray dark outline', 'super-duper' ) . $button_only; |
|
| 1064 | - $theme_colors['outline-indigo'] = __( 'Indigo outline', 'super-duper' ) . $button_only; |
|
| 1065 | - $theme_colors['outline-orange'] = __( 'Orange outline', 'super-duper' ) . $button_only; |
|
| 1066 | - } |
|
| 1067 | - |
|
| 1068 | - if ( $include_branding ) { |
|
| 1069 | - $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 1070 | - } |
|
| 1071 | - |
|
| 1072 | - if ( $include_translucent ) { |
|
| 1073 | - $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'super-duper' ) : ''; |
|
| 1074 | - $theme_colors['translucent-primary'] = __( 'Primary translucent', 'super-duper' ) . $button_only; |
|
| 1075 | - $theme_colors['translucent-secondary'] = __( 'Secondary translucent', 'super-duper' ) . $button_only; |
|
| 1076 | - $theme_colors['translucent-success'] = __( 'Success translucent', 'super-duper' ) . $button_only; |
|
| 1077 | - $theme_colors['translucent-danger'] = __( 'Danger translucent', 'super-duper' ) . $button_only; |
|
| 1078 | - $theme_colors['translucent-warning'] = __( 'Warning translucent', 'super-duper' ) . $button_only; |
|
| 1079 | - $theme_colors['translucent-info'] = __( 'Info translucent', 'super-duper' ) . $button_only; |
|
| 1080 | - $theme_colors['translucent-light'] = __( 'Light translucent', 'super-duper' ) . $button_only; |
|
| 1081 | - $theme_colors['translucent-dark'] = __( 'Dark translucent', 'super-duper' ) . $button_only; |
|
| 1082 | - $theme_colors['translucent-white'] = __( 'White translucent', 'super-duper' ) . $button_only; |
|
| 1083 | - $theme_colors['translucent-purple'] = __( 'Purple translucent', 'super-duper' ) . $button_only; |
|
| 1084 | - $theme_colors['translucent-salmon'] = __( 'Salmon translucent', 'super-duper' ) . $button_only; |
|
| 1085 | - $theme_colors['translucent-cyan'] = __( 'Cyan translucent', 'super-duper' ) . $button_only; |
|
| 1086 | - $theme_colors['translucent-gray'] = __( 'Gray translucent', 'super-duper' ) . $button_only; |
|
| 1087 | - $theme_colors['translucent-gray-dark'] = __( 'Gray dark translucent', 'super-duper' ) . $button_only; |
|
| 1088 | - $theme_colors['translucent-indigo'] = __( 'Indigo translucent', 'super-duper' ) . $button_only; |
|
| 1089 | - $theme_colors['translucent-orange'] = __( 'Orange translucent', 'super-duper' ) . $button_only; |
|
| 1090 | - } |
|
| 1091 | - |
|
| 1092 | - return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 1027 | + $theme_colors = array(); |
|
| 1028 | + |
|
| 1029 | + $theme_colors['primary'] = __( 'Primary', 'super-duper' ); |
|
| 1030 | + $theme_colors['secondary'] = __( 'Secondary', 'super-duper' ); |
|
| 1031 | + $theme_colors['success'] = __( 'Success', 'super-duper' ); |
|
| 1032 | + $theme_colors['danger'] = __( 'Danger', 'super-duper' ); |
|
| 1033 | + $theme_colors['warning'] = __( 'Warning', 'super-duper' ); |
|
| 1034 | + $theme_colors['info'] = __( 'Info', 'super-duper' ); |
|
| 1035 | + $theme_colors['light'] = __( 'Light', 'super-duper' ); |
|
| 1036 | + $theme_colors['dark'] = __( 'Dark', 'super-duper' ); |
|
| 1037 | + $theme_colors['black'] = __( 'Black', 'super-duper' ); |
|
| 1038 | + $theme_colors['white'] = __( 'White', 'super-duper' ); |
|
| 1039 | + $theme_colors['purple'] = __( 'Purple', 'super-duper' ); |
|
| 1040 | + $theme_colors['salmon'] = __( 'Salmon', 'super-duper' ); |
|
| 1041 | + $theme_colors['cyan'] = __( 'Cyan', 'super-duper' ); |
|
| 1042 | + $theme_colors['gray'] = __( 'Gray', 'super-duper' ); |
|
| 1043 | + $theme_colors['muted'] = __( 'Muted', 'super-duper' ); |
|
| 1044 | + $theme_colors['gray-dark'] = __( 'Gray dark', 'super-duper' ); |
|
| 1045 | + $theme_colors['indigo'] = __( 'Indigo', 'super-duper' ); |
|
| 1046 | + $theme_colors['orange'] = __( 'Orange', 'super-duper' ); |
|
| 1047 | + |
|
| 1048 | + if ( $include_outlines ) { |
|
| 1049 | + $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'super-duper' ) : ''; |
|
| 1050 | + $theme_colors['outline-primary'] = __( 'Primary outline', 'super-duper' ) . $button_only; |
|
| 1051 | + $theme_colors['outline-secondary'] = __( 'Secondary outline', 'super-duper' ) . $button_only; |
|
| 1052 | + $theme_colors['outline-success'] = __( 'Success outline', 'super-duper' ) . $button_only; |
|
| 1053 | + $theme_colors['outline-danger'] = __( 'Danger outline', 'super-duper' ) . $button_only; |
|
| 1054 | + $theme_colors['outline-warning'] = __( 'Warning outline', 'super-duper' ) . $button_only; |
|
| 1055 | + $theme_colors['outline-info'] = __( 'Info outline', 'super-duper' ) . $button_only; |
|
| 1056 | + $theme_colors['outline-light'] = __( 'Light outline', 'super-duper' ) . $button_only; |
|
| 1057 | + $theme_colors['outline-dark'] = __( 'Dark outline', 'super-duper' ) . $button_only; |
|
| 1058 | + $theme_colors['outline-white'] = __( 'White outline', 'super-duper' ) . $button_only; |
|
| 1059 | + $theme_colors['outline-purple'] = __( 'Purple outline', 'super-duper' ) . $button_only; |
|
| 1060 | + $theme_colors['outline-salmon'] = __( 'Salmon outline', 'super-duper' ) . $button_only; |
|
| 1061 | + $theme_colors['outline-cyan'] = __( 'Cyan outline', 'super-duper' ) . $button_only; |
|
| 1062 | + $theme_colors['outline-gray'] = __( 'Gray outline', 'super-duper' ) . $button_only; |
|
| 1063 | + $theme_colors['outline-gray-dark'] = __( 'Gray dark outline', 'super-duper' ) . $button_only; |
|
| 1064 | + $theme_colors['outline-indigo'] = __( 'Indigo outline', 'super-duper' ) . $button_only; |
|
| 1065 | + $theme_colors['outline-orange'] = __( 'Orange outline', 'super-duper' ) . $button_only; |
|
| 1066 | + } |
|
| 1067 | + |
|
| 1068 | + if ( $include_branding ) { |
|
| 1069 | + $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 1070 | + } |
|
| 1071 | + |
|
| 1072 | + if ( $include_translucent ) { |
|
| 1073 | + $button_only = $outline_button_only_text ? ' ' . __( '(button only)', 'super-duper' ) : ''; |
|
| 1074 | + $theme_colors['translucent-primary'] = __( 'Primary translucent', 'super-duper' ) . $button_only; |
|
| 1075 | + $theme_colors['translucent-secondary'] = __( 'Secondary translucent', 'super-duper' ) . $button_only; |
|
| 1076 | + $theme_colors['translucent-success'] = __( 'Success translucent', 'super-duper' ) . $button_only; |
|
| 1077 | + $theme_colors['translucent-danger'] = __( 'Danger translucent', 'super-duper' ) . $button_only; |
|
| 1078 | + $theme_colors['translucent-warning'] = __( 'Warning translucent', 'super-duper' ) . $button_only; |
|
| 1079 | + $theme_colors['translucent-info'] = __( 'Info translucent', 'super-duper' ) . $button_only; |
|
| 1080 | + $theme_colors['translucent-light'] = __( 'Light translucent', 'super-duper' ) . $button_only; |
|
| 1081 | + $theme_colors['translucent-dark'] = __( 'Dark translucent', 'super-duper' ) . $button_only; |
|
| 1082 | + $theme_colors['translucent-white'] = __( 'White translucent', 'super-duper' ) . $button_only; |
|
| 1083 | + $theme_colors['translucent-purple'] = __( 'Purple translucent', 'super-duper' ) . $button_only; |
|
| 1084 | + $theme_colors['translucent-salmon'] = __( 'Salmon translucent', 'super-duper' ) . $button_only; |
|
| 1085 | + $theme_colors['translucent-cyan'] = __( 'Cyan translucent', 'super-duper' ) . $button_only; |
|
| 1086 | + $theme_colors['translucent-gray'] = __( 'Gray translucent', 'super-duper' ) . $button_only; |
|
| 1087 | + $theme_colors['translucent-gray-dark'] = __( 'Gray dark translucent', 'super-duper' ) . $button_only; |
|
| 1088 | + $theme_colors['translucent-indigo'] = __( 'Indigo translucent', 'super-duper' ) . $button_only; |
|
| 1089 | + $theme_colors['translucent-orange'] = __( 'Orange translucent', 'super-duper' ) . $button_only; |
|
| 1090 | + } |
|
| 1091 | + |
|
| 1092 | + return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | 1095 | /** |
@@ -1098,19 +1098,19 @@ discard block |
||
| 1098 | 1098 | * @return array |
| 1099 | 1099 | */ |
| 1100 | 1100 | function sd_aui_branding_colors() { |
| 1101 | - return array( |
|
| 1102 | - 'facebook' => __( 'Facebook', 'super-duper' ), |
|
| 1103 | - 'twitter' => __( 'Twitter', 'super-duper' ), |
|
| 1104 | - 'instagram' => __( 'Instagram', 'super-duper' ), |
|
| 1105 | - 'linkedin' => __( 'Linkedin', 'super-duper' ), |
|
| 1106 | - 'flickr' => __( 'Flickr', 'super-duper' ), |
|
| 1107 | - 'github' => __( 'GitHub', 'super-duper' ), |
|
| 1108 | - 'youtube' => __( 'YouTube', 'super-duper' ), |
|
| 1109 | - 'wordpress' => __( 'WordPress', 'super-duper' ), |
|
| 1110 | - 'google' => __( 'Google', 'super-duper' ), |
|
| 1111 | - 'yahoo' => __( 'Yahoo', 'super-duper' ), |
|
| 1112 | - 'vkontakte' => __( 'Vkontakte', 'super-duper' ), |
|
| 1113 | - ); |
|
| 1101 | + return array( |
|
| 1102 | + 'facebook' => __( 'Facebook', 'super-duper' ), |
|
| 1103 | + 'twitter' => __( 'Twitter', 'super-duper' ), |
|
| 1104 | + 'instagram' => __( 'Instagram', 'super-duper' ), |
|
| 1105 | + 'linkedin' => __( 'Linkedin', 'super-duper' ), |
|
| 1106 | + 'flickr' => __( 'Flickr', 'super-duper' ), |
|
| 1107 | + 'github' => __( 'GitHub', 'super-duper' ), |
|
| 1108 | + 'youtube' => __( 'YouTube', 'super-duper' ), |
|
| 1109 | + 'wordpress' => __( 'WordPress', 'super-duper' ), |
|
| 1110 | + 'google' => __( 'Google', 'super-duper' ), |
|
| 1111 | + 'yahoo' => __( 'Yahoo', 'super-duper' ), |
|
| 1112 | + 'vkontakte' => __( 'Vkontakte', 'super-duper' ), |
|
| 1113 | + ); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | |
@@ -1124,38 +1124,38 @@ discard block |
||
| 1124 | 1124 | */ |
| 1125 | 1125 | function sd_get_container_class_input( $type = 'container', $overwrite = array() ) { |
| 1126 | 1126 | |
| 1127 | - $options = array( |
|
| 1128 | - 'container' => __( 'container (default)', 'super-duper' ), |
|
| 1129 | - 'container-sm' => 'container-sm', |
|
| 1130 | - 'container-md' => 'container-md', |
|
| 1131 | - 'container-lg' => 'container-lg', |
|
| 1132 | - 'container-xl' => 'container-xl', |
|
| 1133 | - 'container-xxl' => 'container-xxl', |
|
| 1134 | - 'container-fluid' => 'container-fluid', |
|
| 1135 | - 'row' => 'row', |
|
| 1136 | - 'col' => 'col', |
|
| 1137 | - 'card' => 'card', |
|
| 1138 | - 'card-header' => 'card-header', |
|
| 1139 | - 'card-img-top' => 'card-img-top', |
|
| 1140 | - 'card-body' => 'card-body', |
|
| 1141 | - 'card-footer' => 'card-footer', |
|
| 1142 | - 'list-group' => 'list-group', |
|
| 1143 | - 'list-group-item' => 'list-group-item', |
|
| 1144 | - '' => __( 'no container class', 'super-duper' ), |
|
| 1145 | - ); |
|
| 1146 | - |
|
| 1147 | - $defaults = array( |
|
| 1148 | - 'type' => 'select', |
|
| 1149 | - 'title' => __( 'Type', 'super-duper' ), |
|
| 1150 | - 'options' => $options, |
|
| 1151 | - 'default' => '', |
|
| 1152 | - 'desc_tip' => true, |
|
| 1153 | - 'group' => __( 'Container', 'super-duper' ), |
|
| 1154 | - ); |
|
| 1155 | - |
|
| 1156 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1157 | - |
|
| 1158 | - return $input; |
|
| 1127 | + $options = array( |
|
| 1128 | + 'container' => __( 'container (default)', 'super-duper' ), |
|
| 1129 | + 'container-sm' => 'container-sm', |
|
| 1130 | + 'container-md' => 'container-md', |
|
| 1131 | + 'container-lg' => 'container-lg', |
|
| 1132 | + 'container-xl' => 'container-xl', |
|
| 1133 | + 'container-xxl' => 'container-xxl', |
|
| 1134 | + 'container-fluid' => 'container-fluid', |
|
| 1135 | + 'row' => 'row', |
|
| 1136 | + 'col' => 'col', |
|
| 1137 | + 'card' => 'card', |
|
| 1138 | + 'card-header' => 'card-header', |
|
| 1139 | + 'card-img-top' => 'card-img-top', |
|
| 1140 | + 'card-body' => 'card-body', |
|
| 1141 | + 'card-footer' => 'card-footer', |
|
| 1142 | + 'list-group' => 'list-group', |
|
| 1143 | + 'list-group-item' => 'list-group-item', |
|
| 1144 | + '' => __( 'no container class', 'super-duper' ), |
|
| 1145 | + ); |
|
| 1146 | + |
|
| 1147 | + $defaults = array( |
|
| 1148 | + 'type' => 'select', |
|
| 1149 | + 'title' => __( 'Type', 'super-duper' ), |
|
| 1150 | + 'options' => $options, |
|
| 1151 | + 'default' => '', |
|
| 1152 | + 'desc_tip' => true, |
|
| 1153 | + 'group' => __( 'Container', 'super-duper' ), |
|
| 1154 | + ); |
|
| 1155 | + |
|
| 1156 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1157 | + |
|
| 1158 | + return $input; |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | /** |
@@ -1168,30 +1168,30 @@ discard block |
||
| 1168 | 1168 | */ |
| 1169 | 1169 | function sd_get_position_class_input( $type = 'position', $overwrite = array() ) { |
| 1170 | 1170 | |
| 1171 | - $options = array( |
|
| 1172 | - '' => __( 'Default', 'super-duper' ), |
|
| 1173 | - 'position-static' => 'static', |
|
| 1174 | - 'position-relative' => 'relative', |
|
| 1175 | - 'position-absolute' => 'absolute', |
|
| 1176 | - 'position-fixed' => 'fixed', |
|
| 1177 | - 'position-sticky' => 'sticky', |
|
| 1178 | - 'fixed-top' => 'fixed-top', |
|
| 1179 | - 'fixed-bottom' => 'fixed-bottom', |
|
| 1180 | - 'sticky-top' => 'sticky-top', |
|
| 1181 | - ); |
|
| 1171 | + $options = array( |
|
| 1172 | + '' => __( 'Default', 'super-duper' ), |
|
| 1173 | + 'position-static' => 'static', |
|
| 1174 | + 'position-relative' => 'relative', |
|
| 1175 | + 'position-absolute' => 'absolute', |
|
| 1176 | + 'position-fixed' => 'fixed', |
|
| 1177 | + 'position-sticky' => 'sticky', |
|
| 1178 | + 'fixed-top' => 'fixed-top', |
|
| 1179 | + 'fixed-bottom' => 'fixed-bottom', |
|
| 1180 | + 'sticky-top' => 'sticky-top', |
|
| 1181 | + ); |
|
| 1182 | 1182 | |
| 1183 | - $defaults = array( |
|
| 1184 | - 'type' => 'select', |
|
| 1185 | - 'title' => __( 'Position', 'super-duper' ), |
|
| 1186 | - 'options' => $options, |
|
| 1187 | - 'default' => '', |
|
| 1188 | - 'desc_tip' => true, |
|
| 1189 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1190 | - ); |
|
| 1183 | + $defaults = array( |
|
| 1184 | + 'type' => 'select', |
|
| 1185 | + 'title' => __( 'Position', 'super-duper' ), |
|
| 1186 | + 'options' => $options, |
|
| 1187 | + 'default' => '', |
|
| 1188 | + 'desc_tip' => true, |
|
| 1189 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1190 | + ); |
|
| 1191 | 1191 | |
| 1192 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1192 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1193 | 1193 | |
| 1194 | - return $input; |
|
| 1194 | + return $input; |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
@@ -1202,32 +1202,32 @@ discard block |
||
| 1202 | 1202 | */ |
| 1203 | 1203 | function sd_get_absolute_position_input( $type = 'absolute_position', $overwrite = array() ) { |
| 1204 | 1204 | |
| 1205 | - $options = array( |
|
| 1206 | - '' => __( 'Default', 'super-duper' ), |
|
| 1207 | - 'top-left' => 'top-left', |
|
| 1208 | - 'top-center' => 'top-center', |
|
| 1209 | - 'top-right' => 'top-right', |
|
| 1210 | - 'center-left' => 'middle-left', |
|
| 1211 | - 'center' => 'center', |
|
| 1212 | - 'center-right' => 'middle-right', |
|
| 1213 | - 'bottom-left' => 'bottom-left', |
|
| 1214 | - 'bottom-center' => 'bottom-center', |
|
| 1215 | - 'bottom-right' => 'bottom-right', |
|
| 1216 | - ); |
|
| 1217 | - |
|
| 1218 | - $defaults = array( |
|
| 1219 | - 'type' => 'select', |
|
| 1220 | - 'title' => __( 'Absolute Position', 'super-duper' ), |
|
| 1221 | - 'options' => $options, |
|
| 1222 | - 'default' => '', |
|
| 1223 | - 'desc_tip' => true, |
|
| 1224 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1225 | - 'element_require' => '[%position%]=="position-absolute"', |
|
| 1226 | - ); |
|
| 1227 | - |
|
| 1228 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1229 | - |
|
| 1230 | - return $input; |
|
| 1205 | + $options = array( |
|
| 1206 | + '' => __( 'Default', 'super-duper' ), |
|
| 1207 | + 'top-left' => 'top-left', |
|
| 1208 | + 'top-center' => 'top-center', |
|
| 1209 | + 'top-right' => 'top-right', |
|
| 1210 | + 'center-left' => 'middle-left', |
|
| 1211 | + 'center' => 'center', |
|
| 1212 | + 'center-right' => 'middle-right', |
|
| 1213 | + 'bottom-left' => 'bottom-left', |
|
| 1214 | + 'bottom-center' => 'bottom-center', |
|
| 1215 | + 'bottom-right' => 'bottom-right', |
|
| 1216 | + ); |
|
| 1217 | + |
|
| 1218 | + $defaults = array( |
|
| 1219 | + 'type' => 'select', |
|
| 1220 | + 'title' => __( 'Absolute Position', 'super-duper' ), |
|
| 1221 | + 'options' => $options, |
|
| 1222 | + 'default' => '', |
|
| 1223 | + 'desc_tip' => true, |
|
| 1224 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1225 | + 'element_require' => '[%position%]=="position-absolute"', |
|
| 1226 | + ); |
|
| 1227 | + |
|
| 1228 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1229 | + |
|
| 1230 | + return $input; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /** |
@@ -1240,38 +1240,38 @@ discard block |
||
| 1240 | 1240 | */ |
| 1241 | 1241 | function sd_get_sticky_offset_input( $type = 'top', $overwrite = array() ) { |
| 1242 | 1242 | |
| 1243 | - $defaults = array( |
|
| 1244 | - 'type' => 'number', |
|
| 1245 | - 'title' => __( 'Sticky offset', 'super-duper' ), |
|
| 1246 | - //'desc' => __( 'Sticky offset', 'super-duper' ), |
|
| 1247 | - 'default' => '', |
|
| 1248 | - 'desc_tip' => true, |
|
| 1249 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1250 | - 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"', |
|
| 1251 | - ); |
|
| 1252 | - |
|
| 1253 | - // title |
|
| 1254 | - if ( $type == 'top' ) { |
|
| 1255 | - $defaults['title'] = __( 'Top offset', 'super-duper' ); |
|
| 1256 | - $defaults['icon'] = 'box-top'; |
|
| 1257 | - $defaults['row'] = array( |
|
| 1258 | - 'title' => __( 'Sticky offset', 'super-duper' ), |
|
| 1259 | - 'key' => 'sticky-offset', |
|
| 1260 | - 'open' => true, |
|
| 1261 | - 'class' => 'text-center', |
|
| 1262 | - ); |
|
| 1263 | - } elseif ( $type == 'bottom' ) { |
|
| 1264 | - $defaults['title'] = __( 'Bottom offset', 'super-duper' ); |
|
| 1265 | - $defaults['icon'] = 'box-bottom'; |
|
| 1266 | - $defaults['row'] = array( |
|
| 1267 | - 'key' => 'sticky-offset', |
|
| 1268 | - 'close' => true, |
|
| 1269 | - ); |
|
| 1270 | - } |
|
| 1271 | - |
|
| 1272 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1273 | - |
|
| 1274 | - return $input; |
|
| 1243 | + $defaults = array( |
|
| 1244 | + 'type' => 'number', |
|
| 1245 | + 'title' => __( 'Sticky offset', 'super-duper' ), |
|
| 1246 | + //'desc' => __( 'Sticky offset', 'super-duper' ), |
|
| 1247 | + 'default' => '', |
|
| 1248 | + 'desc_tip' => true, |
|
| 1249 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1250 | + 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"', |
|
| 1251 | + ); |
|
| 1252 | + |
|
| 1253 | + // title |
|
| 1254 | + if ( $type == 'top' ) { |
|
| 1255 | + $defaults['title'] = __( 'Top offset', 'super-duper' ); |
|
| 1256 | + $defaults['icon'] = 'box-top'; |
|
| 1257 | + $defaults['row'] = array( |
|
| 1258 | + 'title' => __( 'Sticky offset', 'super-duper' ), |
|
| 1259 | + 'key' => 'sticky-offset', |
|
| 1260 | + 'open' => true, |
|
| 1261 | + 'class' => 'text-center', |
|
| 1262 | + ); |
|
| 1263 | + } elseif ( $type == 'bottom' ) { |
|
| 1264 | + $defaults['title'] = __( 'Bottom offset', 'super-duper' ); |
|
| 1265 | + $defaults['icon'] = 'box-bottom'; |
|
| 1266 | + $defaults['row'] = array( |
|
| 1267 | + 'key' => 'sticky-offset', |
|
| 1268 | + 'close' => true, |
|
| 1269 | + ); |
|
| 1270 | + } |
|
| 1271 | + |
|
| 1272 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1273 | + |
|
| 1274 | + return $input; |
|
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | 1277 | /** |
@@ -1283,61 +1283,61 @@ discard block |
||
| 1283 | 1283 | * @return array |
| 1284 | 1284 | */ |
| 1285 | 1285 | function sd_get_font_size_input( $type = 'font_size', $overwrite = array(), $has_custom = false ) { |
| 1286 | - global $aui_bs5; |
|
| 1287 | - |
|
| 1288 | - $options[] = __( 'Inherit from parent', 'super-duper' ); |
|
| 1289 | - if ( $aui_bs5 ) { |
|
| 1290 | - // responsive font sizes |
|
| 1291 | - $options['fs-base'] = 'fs-base (body default)'; |
|
| 1292 | - $options['fs-6'] = 'fs-6'; |
|
| 1293 | - $options['fs-5'] = 'fs-5'; |
|
| 1294 | - $options['fs-4'] = 'fs-4'; |
|
| 1295 | - $options['fs-3'] = 'fs-3'; |
|
| 1296 | - $options['fs-2'] = 'fs-2'; |
|
| 1297 | - $options['fs-1'] = 'fs-1'; |
|
| 1298 | - |
|
| 1299 | - // custom |
|
| 1300 | - $options['fs-lg'] = 'fs-lg'; |
|
| 1301 | - $options['fs-sm'] = 'fs-sm'; |
|
| 1302 | - $options['fs-xs'] = 'fs-xs'; |
|
| 1303 | - $options['fs-xxs'] = 'fs-xxs'; |
|
| 1304 | - |
|
| 1305 | - } |
|
| 1306 | - |
|
| 1307 | - $options = $options + array( |
|
| 1308 | - 'h6' => 'h6', |
|
| 1309 | - 'h5' => 'h5', |
|
| 1310 | - 'h4' => 'h4', |
|
| 1311 | - 'h3' => 'h3', |
|
| 1312 | - 'h2' => 'h2', |
|
| 1313 | - 'h1' => 'h1', |
|
| 1314 | - 'display-1' => 'display-1', |
|
| 1315 | - 'display-2' => 'display-2', |
|
| 1316 | - 'display-3' => 'display-3', |
|
| 1317 | - 'display-4' => 'display-4', |
|
| 1318 | - ); |
|
| 1319 | - |
|
| 1320 | - if ( $aui_bs5 ) { |
|
| 1321 | - $options['display-5'] = 'display-5'; |
|
| 1322 | - $options['display-6'] = 'display-6'; |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - if ( $has_custom ) { |
|
| 1326 | - $options['custom'] = __( 'Custom size', 'super-duper' ); |
|
| 1327 | - } |
|
| 1328 | - |
|
| 1329 | - $defaults = array( |
|
| 1330 | - 'type' => 'select', |
|
| 1331 | - 'title' => __( 'Font size', 'super-duper' ), |
|
| 1332 | - 'options' => $options, |
|
| 1333 | - 'default' => '', |
|
| 1334 | - 'desc_tip' => true, |
|
| 1335 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1336 | - ); |
|
| 1337 | - |
|
| 1338 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1339 | - |
|
| 1340 | - return $input; |
|
| 1286 | + global $aui_bs5; |
|
| 1287 | + |
|
| 1288 | + $options[] = __( 'Inherit from parent', 'super-duper' ); |
|
| 1289 | + if ( $aui_bs5 ) { |
|
| 1290 | + // responsive font sizes |
|
| 1291 | + $options['fs-base'] = 'fs-base (body default)'; |
|
| 1292 | + $options['fs-6'] = 'fs-6'; |
|
| 1293 | + $options['fs-5'] = 'fs-5'; |
|
| 1294 | + $options['fs-4'] = 'fs-4'; |
|
| 1295 | + $options['fs-3'] = 'fs-3'; |
|
| 1296 | + $options['fs-2'] = 'fs-2'; |
|
| 1297 | + $options['fs-1'] = 'fs-1'; |
|
| 1298 | + |
|
| 1299 | + // custom |
|
| 1300 | + $options['fs-lg'] = 'fs-lg'; |
|
| 1301 | + $options['fs-sm'] = 'fs-sm'; |
|
| 1302 | + $options['fs-xs'] = 'fs-xs'; |
|
| 1303 | + $options['fs-xxs'] = 'fs-xxs'; |
|
| 1304 | + |
|
| 1305 | + } |
|
| 1306 | + |
|
| 1307 | + $options = $options + array( |
|
| 1308 | + 'h6' => 'h6', |
|
| 1309 | + 'h5' => 'h5', |
|
| 1310 | + 'h4' => 'h4', |
|
| 1311 | + 'h3' => 'h3', |
|
| 1312 | + 'h2' => 'h2', |
|
| 1313 | + 'h1' => 'h1', |
|
| 1314 | + 'display-1' => 'display-1', |
|
| 1315 | + 'display-2' => 'display-2', |
|
| 1316 | + 'display-3' => 'display-3', |
|
| 1317 | + 'display-4' => 'display-4', |
|
| 1318 | + ); |
|
| 1319 | + |
|
| 1320 | + if ( $aui_bs5 ) { |
|
| 1321 | + $options['display-5'] = 'display-5'; |
|
| 1322 | + $options['display-6'] = 'display-6'; |
|
| 1323 | + } |
|
| 1324 | + |
|
| 1325 | + if ( $has_custom ) { |
|
| 1326 | + $options['custom'] = __( 'Custom size', 'super-duper' ); |
|
| 1327 | + } |
|
| 1328 | + |
|
| 1329 | + $defaults = array( |
|
| 1330 | + 'type' => 'select', |
|
| 1331 | + 'title' => __( 'Font size', 'super-duper' ), |
|
| 1332 | + 'options' => $options, |
|
| 1333 | + 'default' => '', |
|
| 1334 | + 'desc_tip' => true, |
|
| 1335 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1336 | + ); |
|
| 1337 | + |
|
| 1338 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1339 | + |
|
| 1340 | + return $input; |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | /** |
@@ -1350,27 +1350,27 @@ discard block |
||
| 1350 | 1350 | */ |
| 1351 | 1351 | function sd_get_font_custom_size_input( $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) { |
| 1352 | 1352 | |
| 1353 | - $defaults = array( |
|
| 1354 | - 'type' => 'number', |
|
| 1355 | - 'title' => __( 'Font size (rem)', 'super-duper' ), |
|
| 1356 | - 'default' => '', |
|
| 1357 | - 'placeholder' => '1.25', |
|
| 1358 | - 'custom_attributes' => array( |
|
| 1359 | - 'step' => '0.1', |
|
| 1360 | - 'min' => '0', |
|
| 1361 | - 'max' => '100', |
|
| 1362 | - ), |
|
| 1363 | - 'desc_tip' => true, |
|
| 1364 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1365 | - ); |
|
| 1353 | + $defaults = array( |
|
| 1354 | + 'type' => 'number', |
|
| 1355 | + 'title' => __( 'Font size (rem)', 'super-duper' ), |
|
| 1356 | + 'default' => '', |
|
| 1357 | + 'placeholder' => '1.25', |
|
| 1358 | + 'custom_attributes' => array( |
|
| 1359 | + 'step' => '0.1', |
|
| 1360 | + 'min' => '0', |
|
| 1361 | + 'max' => '100', |
|
| 1362 | + ), |
|
| 1363 | + 'desc_tip' => true, |
|
| 1364 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1365 | + ); |
|
| 1366 | 1366 | |
| 1367 | - if ( $parent_type ) { |
|
| 1368 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1369 | - } |
|
| 1367 | + if ( $parent_type ) { |
|
| 1368 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1369 | + } |
|
| 1370 | 1370 | |
| 1371 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1371 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1372 | 1372 | |
| 1373 | - return $input; |
|
| 1373 | + return $input; |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | /** |
@@ -1383,23 +1383,23 @@ discard block |
||
| 1383 | 1383 | */ |
| 1384 | 1384 | function sd_get_font_line_height_input( $type = 'font_line_height', $overwrite = array() ) { |
| 1385 | 1385 | |
| 1386 | - $defaults = array( |
|
| 1387 | - 'type' => 'number', |
|
| 1388 | - 'title' => __( 'Font Line Height', 'super-duper' ), |
|
| 1389 | - 'default' => '', |
|
| 1390 | - 'placeholder' => '1.75', |
|
| 1391 | - 'custom_attributes' => array( |
|
| 1392 | - 'step' => '0.1', |
|
| 1393 | - 'min' => '0', |
|
| 1394 | - 'max' => '100', |
|
| 1395 | - ), |
|
| 1396 | - 'desc_tip' => true, |
|
| 1397 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1398 | - ); |
|
| 1386 | + $defaults = array( |
|
| 1387 | + 'type' => 'number', |
|
| 1388 | + 'title' => __( 'Font Line Height', 'super-duper' ), |
|
| 1389 | + 'default' => '', |
|
| 1390 | + 'placeholder' => '1.75', |
|
| 1391 | + 'custom_attributes' => array( |
|
| 1392 | + 'step' => '0.1', |
|
| 1393 | + 'min' => '0', |
|
| 1394 | + 'max' => '100', |
|
| 1395 | + ), |
|
| 1396 | + 'desc_tip' => true, |
|
| 1397 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1398 | + ); |
|
| 1399 | 1399 | |
| 1400 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1400 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1401 | 1401 | |
| 1402 | - return $input; |
|
| 1402 | + return $input; |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | /** |
@@ -1412,18 +1412,18 @@ discard block |
||
| 1412 | 1412 | */ |
| 1413 | 1413 | function sd_get_font_size_input_group( $type = 'font_size', $overwrite = array(), $overwrite_custom = array() ) { |
| 1414 | 1414 | |
| 1415 | - $inputs = array(); |
|
| 1415 | + $inputs = array(); |
|
| 1416 | 1416 | |
| 1417 | - if ( $overwrite !== false ) { |
|
| 1418 | - $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1419 | - } |
|
| 1417 | + if ( $overwrite !== false ) { |
|
| 1418 | + $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1419 | + } |
|
| 1420 | 1420 | |
| 1421 | - if ( $overwrite_custom !== false ) { |
|
| 1422 | - $custom = $type . '_custom'; |
|
| 1423 | - $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1424 | - } |
|
| 1421 | + if ( $overwrite_custom !== false ) { |
|
| 1422 | + $custom = $type . '_custom'; |
|
| 1423 | + $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1424 | + } |
|
| 1425 | 1425 | |
| 1426 | - return $inputs; |
|
| 1426 | + return $inputs; |
|
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | 1429 | /** |
@@ -1436,33 +1436,33 @@ discard block |
||
| 1436 | 1436 | */ |
| 1437 | 1437 | function sd_get_font_weight_input( $type = 'font_weight', $overwrite = array() ) { |
| 1438 | 1438 | |
| 1439 | - $options = array( |
|
| 1440 | - '' => __( 'Inherit', 'super-duper' ), |
|
| 1441 | - 'font-weight-bold' => 'bold', |
|
| 1442 | - 'font-weight-bolder' => 'bolder', |
|
| 1443 | - 'font-weight-normal' => 'normal', |
|
| 1444 | - 'font-weight-light' => 'light', |
|
| 1445 | - 'font-weight-lighter' => 'lighter', |
|
| 1446 | - 'font-italic' => 'italic', |
|
| 1447 | - 'font-weight-bold font-italic' => 'bold italic', |
|
| 1448 | - 'font-weight-bolder font-italic' => 'bolder italic', |
|
| 1449 | - 'font-weight-normal font-italic' => 'normal italic', |
|
| 1450 | - 'font-weight-light font-italic' => 'light italic', |
|
| 1451 | - 'font-weight-lighter font-italic' => 'lighter italic', |
|
| 1452 | - ); |
|
| 1453 | - |
|
| 1454 | - $defaults = array( |
|
| 1455 | - 'type' => 'select', |
|
| 1456 | - 'title' => __( 'Appearance', 'super-duper' ), |
|
| 1457 | - 'options' => $options, |
|
| 1458 | - 'default' => '', |
|
| 1459 | - 'desc_tip' => true, |
|
| 1460 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1461 | - ); |
|
| 1462 | - |
|
| 1463 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1464 | - |
|
| 1465 | - return $input; |
|
| 1439 | + $options = array( |
|
| 1440 | + '' => __( 'Inherit', 'super-duper' ), |
|
| 1441 | + 'font-weight-bold' => 'bold', |
|
| 1442 | + 'font-weight-bolder' => 'bolder', |
|
| 1443 | + 'font-weight-normal' => 'normal', |
|
| 1444 | + 'font-weight-light' => 'light', |
|
| 1445 | + 'font-weight-lighter' => 'lighter', |
|
| 1446 | + 'font-italic' => 'italic', |
|
| 1447 | + 'font-weight-bold font-italic' => 'bold italic', |
|
| 1448 | + 'font-weight-bolder font-italic' => 'bolder italic', |
|
| 1449 | + 'font-weight-normal font-italic' => 'normal italic', |
|
| 1450 | + 'font-weight-light font-italic' => 'light italic', |
|
| 1451 | + 'font-weight-lighter font-italic' => 'lighter italic', |
|
| 1452 | + ); |
|
| 1453 | + |
|
| 1454 | + $defaults = array( |
|
| 1455 | + 'type' => 'select', |
|
| 1456 | + 'title' => __( 'Appearance', 'super-duper' ), |
|
| 1457 | + 'options' => $options, |
|
| 1458 | + 'default' => '', |
|
| 1459 | + 'desc_tip' => true, |
|
| 1460 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1461 | + ); |
|
| 1462 | + |
|
| 1463 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1464 | + |
|
| 1465 | + return $input; |
|
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | /** |
@@ -1475,25 +1475,25 @@ discard block |
||
| 1475 | 1475 | */ |
| 1476 | 1476 | function sd_get_font_case_input( $type = 'font_weight', $overwrite = array() ) { |
| 1477 | 1477 | |
| 1478 | - $options = array( |
|
| 1479 | - '' => __( 'Default', 'super-duper' ), |
|
| 1480 | - 'text-lowercase' => __( 'lowercase', 'super-duper' ), |
|
| 1481 | - 'text-uppercase' => __( 'UPPERCASE', 'super-duper' ), |
|
| 1482 | - 'text-capitalize' => __( 'Capitalize', 'super-duper' ), |
|
| 1483 | - ); |
|
| 1478 | + $options = array( |
|
| 1479 | + '' => __( 'Default', 'super-duper' ), |
|
| 1480 | + 'text-lowercase' => __( 'lowercase', 'super-duper' ), |
|
| 1481 | + 'text-uppercase' => __( 'UPPERCASE', 'super-duper' ), |
|
| 1482 | + 'text-capitalize' => __( 'Capitalize', 'super-duper' ), |
|
| 1483 | + ); |
|
| 1484 | 1484 | |
| 1485 | - $defaults = array( |
|
| 1486 | - 'type' => 'select', |
|
| 1487 | - 'title' => __( 'Letter case', 'super-duper' ), |
|
| 1488 | - 'options' => $options, |
|
| 1489 | - 'default' => '', |
|
| 1490 | - 'desc_tip' => true, |
|
| 1491 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1492 | - ); |
|
| 1485 | + $defaults = array( |
|
| 1486 | + 'type' => 'select', |
|
| 1487 | + 'title' => __( 'Letter case', 'super-duper' ), |
|
| 1488 | + 'options' => $options, |
|
| 1489 | + 'default' => '', |
|
| 1490 | + 'desc_tip' => true, |
|
| 1491 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1492 | + ); |
|
| 1493 | 1493 | |
| 1494 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1494 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1495 | 1495 | |
| 1496 | - return $input; |
|
| 1496 | + return $input; |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | /** |
@@ -1507,23 +1507,23 @@ discard block |
||
| 1507 | 1507 | */ |
| 1508 | 1508 | function sd_get_font_italic_input( $type = 'font_italic', $overwrite = array() ) { |
| 1509 | 1509 | |
| 1510 | - $options = array( |
|
| 1511 | - '' => __( 'No', 'super-duper' ), |
|
| 1512 | - 'font-italic' => __( 'Yes', 'super-duper' ), |
|
| 1513 | - ); |
|
| 1510 | + $options = array( |
|
| 1511 | + '' => __( 'No', 'super-duper' ), |
|
| 1512 | + 'font-italic' => __( 'Yes', 'super-duper' ), |
|
| 1513 | + ); |
|
| 1514 | 1514 | |
| 1515 | - $defaults = array( |
|
| 1516 | - 'type' => 'select', |
|
| 1517 | - 'title' => __( 'Font italic', 'super-duper' ), |
|
| 1518 | - 'options' => $options, |
|
| 1519 | - 'default' => '', |
|
| 1520 | - 'desc_tip' => true, |
|
| 1521 | - 'group' => __( 'Typography', 'super-duper' ), |
|
| 1522 | - ); |
|
| 1515 | + $defaults = array( |
|
| 1516 | + 'type' => 'select', |
|
| 1517 | + 'title' => __( 'Font italic', 'super-duper' ), |
|
| 1518 | + 'options' => $options, |
|
| 1519 | + 'default' => '', |
|
| 1520 | + 'desc_tip' => true, |
|
| 1521 | + 'group' => __( 'Typography', 'super-duper' ), |
|
| 1522 | + ); |
|
| 1523 | 1523 | |
| 1524 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1524 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1525 | 1525 | |
| 1526 | - return $input; |
|
| 1526 | + return $input; |
|
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | /** |
@@ -1536,18 +1536,18 @@ discard block |
||
| 1536 | 1536 | */ |
| 1537 | 1537 | function sd_get_anchor_input( $type = 'anchor', $overwrite = array() ) { |
| 1538 | 1538 | |
| 1539 | - $defaults = array( |
|
| 1540 | - 'type' => 'text', |
|
| 1541 | - 'title' => __( 'HTML anchor', 'super-duper' ), |
|
| 1542 | - 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.', 'super-duper' ), |
|
| 1543 | - 'default' => '', |
|
| 1544 | - 'desc_tip' => true, |
|
| 1545 | - 'group' => __( 'Advanced', 'super-duper' ), |
|
| 1546 | - ); |
|
| 1539 | + $defaults = array( |
|
| 1540 | + 'type' => 'text', |
|
| 1541 | + 'title' => __( 'HTML anchor', 'super-duper' ), |
|
| 1542 | + 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.', 'super-duper' ), |
|
| 1543 | + 'default' => '', |
|
| 1544 | + 'desc_tip' => true, |
|
| 1545 | + 'group' => __( 'Advanced', 'super-duper' ), |
|
| 1546 | + ); |
|
| 1547 | 1547 | |
| 1548 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1548 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1549 | 1549 | |
| 1550 | - return $input; |
|
| 1550 | + return $input; |
|
| 1551 | 1551 | } |
| 1552 | 1552 | |
| 1553 | 1553 | /** |
@@ -1560,18 +1560,18 @@ discard block |
||
| 1560 | 1560 | */ |
| 1561 | 1561 | function sd_get_class_input( $type = 'css_class', $overwrite = array() ) { |
| 1562 | 1562 | |
| 1563 | - $defaults = array( |
|
| 1564 | - 'type' => 'text', |
|
| 1565 | - 'title' => __( 'Additional CSS class(es)', 'super-duper' ), |
|
| 1566 | - 'desc' => __( 'Separate multiple classes with spaces.', 'super-duper' ), |
|
| 1567 | - 'default' => '', |
|
| 1568 | - 'desc_tip' => true, |
|
| 1569 | - 'group' => __( 'Advanced', 'super-duper' ), |
|
| 1570 | - ); |
|
| 1563 | + $defaults = array( |
|
| 1564 | + 'type' => 'text', |
|
| 1565 | + 'title' => __( 'Additional CSS class(es)', 'super-duper' ), |
|
| 1566 | + 'desc' => __( 'Separate multiple classes with spaces.', 'super-duper' ), |
|
| 1567 | + 'default' => '', |
|
| 1568 | + 'desc_tip' => true, |
|
| 1569 | + 'group' => __( 'Advanced', 'super-duper' ), |
|
| 1570 | + ); |
|
| 1571 | 1571 | |
| 1572 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1572 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1573 | 1573 | |
| 1574 | - return $input; |
|
| 1574 | + return $input; |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | /** |
@@ -1584,341 +1584,341 @@ discard block |
||
| 1584 | 1584 | */ |
| 1585 | 1585 | function sd_get_hover_animations_input( $type = 'hover_animations', $overwrite = array() ) { |
| 1586 | 1586 | |
| 1587 | - $options = array( |
|
| 1588 | - '' => __( 'none', 'super-duper' ), |
|
| 1589 | - 'hover-zoom' => __( 'Zoom', 'super-duper' ), |
|
| 1590 | - 'hover-shadow' => __( 'Shadow', 'super-duper' ), |
|
| 1591 | - 'hover-move-up' => __( 'Move up', 'super-duper' ), |
|
| 1592 | - 'hover-move-down' => __( 'Move down', 'super-duper' ), |
|
| 1593 | - 'hover-move-left' => __( 'Move left', 'super-duper' ), |
|
| 1594 | - 'hover-move-right' => __( 'Move right', 'super-duper' ), |
|
| 1595 | - ); |
|
| 1587 | + $options = array( |
|
| 1588 | + '' => __( 'none', 'super-duper' ), |
|
| 1589 | + 'hover-zoom' => __( 'Zoom', 'super-duper' ), |
|
| 1590 | + 'hover-shadow' => __( 'Shadow', 'super-duper' ), |
|
| 1591 | + 'hover-move-up' => __( 'Move up', 'super-duper' ), |
|
| 1592 | + 'hover-move-down' => __( 'Move down', 'super-duper' ), |
|
| 1593 | + 'hover-move-left' => __( 'Move left', 'super-duper' ), |
|
| 1594 | + 'hover-move-right' => __( 'Move right', 'super-duper' ), |
|
| 1595 | + ); |
|
| 1596 | 1596 | |
| 1597 | - $defaults = array( |
|
| 1598 | - 'type' => 'select', |
|
| 1599 | - 'multiple' => true, |
|
| 1600 | - 'title' => __( 'Hover Animations', 'super-duper' ), |
|
| 1601 | - 'options' => $options, |
|
| 1602 | - 'default' => '', |
|
| 1603 | - 'desc_tip' => true, |
|
| 1604 | - 'group' => __( 'Hover Animations', 'super-duper' ), |
|
| 1605 | - ); |
|
| 1597 | + $defaults = array( |
|
| 1598 | + 'type' => 'select', |
|
| 1599 | + 'multiple' => true, |
|
| 1600 | + 'title' => __( 'Hover Animations', 'super-duper' ), |
|
| 1601 | + 'options' => $options, |
|
| 1602 | + 'default' => '', |
|
| 1603 | + 'desc_tip' => true, |
|
| 1604 | + 'group' => __( 'Hover Animations', 'super-duper' ), |
|
| 1605 | + ); |
|
| 1606 | 1606 | |
| 1607 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1607 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1608 | 1608 | |
| 1609 | - return $input; |
|
| 1609 | + return $input; |
|
| 1610 | 1610 | } |
| 1611 | 1611 | |
| 1612 | 1612 | |
| 1613 | 1613 | function sd_get_flex_align_items_input( $type = 'align-items', $overwrite = array() ) { |
| 1614 | - $device_size = ''; |
|
| 1615 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1616 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1617 | - $device_size = '-md'; |
|
| 1618 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1619 | - $device_size = '-lg'; |
|
| 1620 | - } |
|
| 1621 | - } |
|
| 1622 | - $options = array( |
|
| 1623 | - '' => __( 'Default', 'super-duper' ), |
|
| 1624 | - 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1625 | - 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1626 | - 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1627 | - 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1628 | - 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1629 | - ); |
|
| 1630 | - |
|
| 1631 | - $defaults = array( |
|
| 1632 | - 'type' => 'select', |
|
| 1633 | - 'title' => __( 'Vertical Align Items', 'super-duper' ), |
|
| 1634 | - 'options' => $options, |
|
| 1635 | - 'default' => '', |
|
| 1636 | - 'desc_tip' => true, |
|
| 1637 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1638 | - 'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1639 | - |
|
| 1640 | - ); |
|
| 1641 | - |
|
| 1642 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1643 | - |
|
| 1644 | - return $input; |
|
| 1614 | + $device_size = ''; |
|
| 1615 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1616 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1617 | + $device_size = '-md'; |
|
| 1618 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1619 | + $device_size = '-lg'; |
|
| 1620 | + } |
|
| 1621 | + } |
|
| 1622 | + $options = array( |
|
| 1623 | + '' => __( 'Default', 'super-duper' ), |
|
| 1624 | + 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1625 | + 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1626 | + 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1627 | + 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1628 | + 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1629 | + ); |
|
| 1630 | + |
|
| 1631 | + $defaults = array( |
|
| 1632 | + 'type' => 'select', |
|
| 1633 | + 'title' => __( 'Vertical Align Items', 'super-duper' ), |
|
| 1634 | + 'options' => $options, |
|
| 1635 | + 'default' => '', |
|
| 1636 | + 'desc_tip' => true, |
|
| 1637 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1638 | + 'element_require' => ' ( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1639 | + |
|
| 1640 | + ); |
|
| 1641 | + |
|
| 1642 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1643 | + |
|
| 1644 | + return $input; |
|
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 1647 | 1647 | function sd_get_flex_align_items_input_group( $type = 'flex_align_items', $overwrite = array() ) { |
| 1648 | - $inputs = array(); |
|
| 1649 | - $sizes = array( |
|
| 1650 | - '' => 'Mobile', |
|
| 1651 | - '_md' => 'Tablet', |
|
| 1652 | - '_lg' => 'Desktop', |
|
| 1653 | - ); |
|
| 1648 | + $inputs = array(); |
|
| 1649 | + $sizes = array( |
|
| 1650 | + '' => 'Mobile', |
|
| 1651 | + '_md' => 'Tablet', |
|
| 1652 | + '_lg' => 'Desktop', |
|
| 1653 | + ); |
|
| 1654 | 1654 | |
| 1655 | - if ( $overwrite !== false ) { |
|
| 1655 | + if ( $overwrite !== false ) { |
|
| 1656 | 1656 | |
| 1657 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1658 | - $overwrite['device_type'] = $dt; |
|
| 1659 | - $inputs[ $type . $ds ] = sd_get_flex_align_items_input( $type, $overwrite ); |
|
| 1660 | - } |
|
| 1661 | - } |
|
| 1657 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1658 | + $overwrite['device_type'] = $dt; |
|
| 1659 | + $inputs[ $type . $ds ] = sd_get_flex_align_items_input( $type, $overwrite ); |
|
| 1660 | + } |
|
| 1661 | + } |
|
| 1662 | 1662 | |
| 1663 | - return $inputs; |
|
| 1663 | + return $inputs; |
|
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | 1666 | function sd_get_flex_justify_content_input( $type = 'flex_justify_content', $overwrite = array() ) { |
| 1667 | - $device_size = ''; |
|
| 1668 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1669 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1670 | - $device_size = '-md'; |
|
| 1671 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1672 | - $device_size = '-lg'; |
|
| 1673 | - } |
|
| 1674 | - } |
|
| 1675 | - $options = array( |
|
| 1676 | - '' => __( 'Default', 'super-duper' ), |
|
| 1677 | - 'justify-content' . $device_size . '-start' => 'justify-content-start', |
|
| 1678 | - 'justify-content' . $device_size . '-end' => 'justify-content-end', |
|
| 1679 | - 'justify-content' . $device_size . '-center' => 'justify-content-center', |
|
| 1680 | - 'justify-content' . $device_size . '-between' => 'justify-content-between', |
|
| 1681 | - 'justify-content' . $device_size . '-stretch' => 'justify-content-around', |
|
| 1682 | - ); |
|
| 1683 | - |
|
| 1684 | - $defaults = array( |
|
| 1685 | - 'type' => 'select', |
|
| 1686 | - 'title' => __( 'Justify content', 'super-duper' ), |
|
| 1687 | - 'options' => $options, |
|
| 1688 | - 'default' => '', |
|
| 1689 | - 'desc_tip' => true, |
|
| 1690 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1691 | - 'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1692 | - |
|
| 1693 | - ); |
|
| 1694 | - |
|
| 1695 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1696 | - |
|
| 1697 | - return $input; |
|
| 1667 | + $device_size = ''; |
|
| 1668 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1669 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1670 | + $device_size = '-md'; |
|
| 1671 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1672 | + $device_size = '-lg'; |
|
| 1673 | + } |
|
| 1674 | + } |
|
| 1675 | + $options = array( |
|
| 1676 | + '' => __( 'Default', 'super-duper' ), |
|
| 1677 | + 'justify-content' . $device_size . '-start' => 'justify-content-start', |
|
| 1678 | + 'justify-content' . $device_size . '-end' => 'justify-content-end', |
|
| 1679 | + 'justify-content' . $device_size . '-center' => 'justify-content-center', |
|
| 1680 | + 'justify-content' . $device_size . '-between' => 'justify-content-between', |
|
| 1681 | + 'justify-content' . $device_size . '-stretch' => 'justify-content-around', |
|
| 1682 | + ); |
|
| 1683 | + |
|
| 1684 | + $defaults = array( |
|
| 1685 | + 'type' => 'select', |
|
| 1686 | + 'title' => __( 'Justify content', 'super-duper' ), |
|
| 1687 | + 'options' => $options, |
|
| 1688 | + 'default' => '', |
|
| 1689 | + 'desc_tip' => true, |
|
| 1690 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1691 | + 'element_require' => '( ( [%container%]=="row" ) || ( [%display%]=="d-flex" || [%display_md%]=="d-md-flex" || [%display_lg%]=="d-lg-flex" ) ) ', |
|
| 1692 | + |
|
| 1693 | + ); |
|
| 1694 | + |
|
| 1695 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1696 | + |
|
| 1697 | + return $input; |
|
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | 1700 | function sd_get_flex_justify_content_input_group( $type = 'flex_justify_content', $overwrite = array() ) { |
| 1701 | - $inputs = array(); |
|
| 1702 | - $sizes = array( |
|
| 1703 | - '' => 'Mobile', |
|
| 1704 | - '_md' => 'Tablet', |
|
| 1705 | - '_lg' => 'Desktop', |
|
| 1706 | - ); |
|
| 1701 | + $inputs = array(); |
|
| 1702 | + $sizes = array( |
|
| 1703 | + '' => 'Mobile', |
|
| 1704 | + '_md' => 'Tablet', |
|
| 1705 | + '_lg' => 'Desktop', |
|
| 1706 | + ); |
|
| 1707 | 1707 | |
| 1708 | - if ( $overwrite !== false ) { |
|
| 1708 | + if ( $overwrite !== false ) { |
|
| 1709 | 1709 | |
| 1710 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1711 | - $overwrite['device_type'] = $dt; |
|
| 1712 | - $inputs[ $type . $ds ] = sd_get_flex_justify_content_input( $type, $overwrite ); |
|
| 1713 | - } |
|
| 1714 | - } |
|
| 1710 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1711 | + $overwrite['device_type'] = $dt; |
|
| 1712 | + $inputs[ $type . $ds ] = sd_get_flex_justify_content_input( $type, $overwrite ); |
|
| 1713 | + } |
|
| 1714 | + } |
|
| 1715 | 1715 | |
| 1716 | - return $inputs; |
|
| 1716 | + return $inputs; |
|
| 1717 | 1717 | } |
| 1718 | 1718 | |
| 1719 | 1719 | |
| 1720 | 1720 | function sd_get_flex_align_self_input( $type = 'flex_align_self', $overwrite = array() ) { |
| 1721 | - $device_size = ''; |
|
| 1722 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1723 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1724 | - $device_size = '-md'; |
|
| 1725 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1726 | - $device_size = '-lg'; |
|
| 1727 | - } |
|
| 1728 | - } |
|
| 1729 | - $options = array( |
|
| 1730 | - '' => __( 'Default', 'super-duper' ), |
|
| 1731 | - 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1732 | - 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1733 | - 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1734 | - 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1735 | - 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1736 | - ); |
|
| 1737 | - |
|
| 1738 | - $defaults = array( |
|
| 1739 | - 'type' => 'select', |
|
| 1740 | - 'title' => __( 'Align Self', 'super-duper' ), |
|
| 1741 | - 'options' => $options, |
|
| 1742 | - 'default' => '', |
|
| 1743 | - 'desc_tip' => true, |
|
| 1744 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1745 | - 'element_require' => ' [%container%]=="col" ', |
|
| 1746 | - |
|
| 1747 | - ); |
|
| 1748 | - |
|
| 1749 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1750 | - |
|
| 1751 | - return $input; |
|
| 1721 | + $device_size = ''; |
|
| 1722 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1723 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1724 | + $device_size = '-md'; |
|
| 1725 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1726 | + $device_size = '-lg'; |
|
| 1727 | + } |
|
| 1728 | + } |
|
| 1729 | + $options = array( |
|
| 1730 | + '' => __( 'Default', 'super-duper' ), |
|
| 1731 | + 'align-items' . $device_size . '-start' => 'align-items-start', |
|
| 1732 | + 'align-items' . $device_size . '-end' => 'align-items-end', |
|
| 1733 | + 'align-items' . $device_size . '-center' => 'align-items-center', |
|
| 1734 | + 'align-items' . $device_size . '-baseline' => 'align-items-baseline', |
|
| 1735 | + 'align-items' . $device_size . '-stretch' => 'align-items-stretch', |
|
| 1736 | + ); |
|
| 1737 | + |
|
| 1738 | + $defaults = array( |
|
| 1739 | + 'type' => 'select', |
|
| 1740 | + 'title' => __( 'Align Self', 'super-duper' ), |
|
| 1741 | + 'options' => $options, |
|
| 1742 | + 'default' => '', |
|
| 1743 | + 'desc_tip' => true, |
|
| 1744 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1745 | + 'element_require' => ' [%container%]=="col" ', |
|
| 1746 | + |
|
| 1747 | + ); |
|
| 1748 | + |
|
| 1749 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1750 | + |
|
| 1751 | + return $input; |
|
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | 1754 | function sd_get_flex_align_self_input_group( $type = 'flex_align_self', $overwrite = array() ) { |
| 1755 | - $inputs = array(); |
|
| 1756 | - $sizes = array( |
|
| 1757 | - '' => 'Mobile', |
|
| 1758 | - '_md' => 'Tablet', |
|
| 1759 | - '_lg' => 'Desktop', |
|
| 1760 | - ); |
|
| 1755 | + $inputs = array(); |
|
| 1756 | + $sizes = array( |
|
| 1757 | + '' => 'Mobile', |
|
| 1758 | + '_md' => 'Tablet', |
|
| 1759 | + '_lg' => 'Desktop', |
|
| 1760 | + ); |
|
| 1761 | 1761 | |
| 1762 | - if ( $overwrite !== false ) { |
|
| 1762 | + if ( $overwrite !== false ) { |
|
| 1763 | 1763 | |
| 1764 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1765 | - $overwrite['device_type'] = $dt; |
|
| 1766 | - $inputs[ $type . $ds ] = sd_get_flex_align_self_input( $type, $overwrite ); |
|
| 1767 | - } |
|
| 1768 | - } |
|
| 1764 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1765 | + $overwrite['device_type'] = $dt; |
|
| 1766 | + $inputs[ $type . $ds ] = sd_get_flex_align_self_input( $type, $overwrite ); |
|
| 1767 | + } |
|
| 1768 | + } |
|
| 1769 | 1769 | |
| 1770 | - return $inputs; |
|
| 1770 | + return $inputs; |
|
| 1771 | 1771 | } |
| 1772 | 1772 | |
| 1773 | 1773 | function sd_get_flex_order_input( $type = 'flex_order', $overwrite = array() ) { |
| 1774 | - $device_size = ''; |
|
| 1775 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1776 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1777 | - $device_size = '-md'; |
|
| 1778 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1779 | - $device_size = '-lg'; |
|
| 1780 | - } |
|
| 1781 | - } |
|
| 1782 | - $options = array( |
|
| 1783 | - '' => __( 'Default', 'super-duper' ), |
|
| 1784 | - ); |
|
| 1785 | - |
|
| 1786 | - $i = 0; |
|
| 1787 | - while ( $i <= 5 ) { |
|
| 1788 | - $options[ 'order' . $device_size . '-' . $i ] = $i; |
|
| 1789 | - $i++; |
|
| 1790 | - } |
|
| 1791 | - |
|
| 1792 | - $defaults = array( |
|
| 1793 | - 'type' => 'select', |
|
| 1794 | - 'title' => __( 'Flex Order', 'super-duper' ), |
|
| 1795 | - 'options' => $options, |
|
| 1796 | - 'default' => '', |
|
| 1797 | - 'desc_tip' => true, |
|
| 1798 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1799 | - 'element_require' => ' [%container%]=="col" ', |
|
| 1800 | - |
|
| 1801 | - ); |
|
| 1802 | - |
|
| 1803 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1804 | - |
|
| 1805 | - return $input; |
|
| 1774 | + $device_size = ''; |
|
| 1775 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1776 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1777 | + $device_size = '-md'; |
|
| 1778 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1779 | + $device_size = '-lg'; |
|
| 1780 | + } |
|
| 1781 | + } |
|
| 1782 | + $options = array( |
|
| 1783 | + '' => __( 'Default', 'super-duper' ), |
|
| 1784 | + ); |
|
| 1785 | + |
|
| 1786 | + $i = 0; |
|
| 1787 | + while ( $i <= 5 ) { |
|
| 1788 | + $options[ 'order' . $device_size . '-' . $i ] = $i; |
|
| 1789 | + $i++; |
|
| 1790 | + } |
|
| 1791 | + |
|
| 1792 | + $defaults = array( |
|
| 1793 | + 'type' => 'select', |
|
| 1794 | + 'title' => __( 'Flex Order', 'super-duper' ), |
|
| 1795 | + 'options' => $options, |
|
| 1796 | + 'default' => '', |
|
| 1797 | + 'desc_tip' => true, |
|
| 1798 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1799 | + 'element_require' => ' [%container%]=="col" ', |
|
| 1800 | + |
|
| 1801 | + ); |
|
| 1802 | + |
|
| 1803 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1804 | + |
|
| 1805 | + return $input; |
|
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | 1808 | function sd_get_flex_order_input_group( $type = 'flex_order', $overwrite = array() ) { |
| 1809 | - $inputs = array(); |
|
| 1810 | - $sizes = array( |
|
| 1811 | - '' => 'Mobile', |
|
| 1812 | - '_md' => 'Tablet', |
|
| 1813 | - '_lg' => 'Desktop', |
|
| 1814 | - ); |
|
| 1809 | + $inputs = array(); |
|
| 1810 | + $sizes = array( |
|
| 1811 | + '' => 'Mobile', |
|
| 1812 | + '_md' => 'Tablet', |
|
| 1813 | + '_lg' => 'Desktop', |
|
| 1814 | + ); |
|
| 1815 | 1815 | |
| 1816 | - if ( $overwrite !== false ) { |
|
| 1816 | + if ( $overwrite !== false ) { |
|
| 1817 | 1817 | |
| 1818 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1819 | - $overwrite['device_type'] = $dt; |
|
| 1820 | - $inputs[ $type . $ds ] = sd_get_flex_order_input( $type, $overwrite ); |
|
| 1821 | - } |
|
| 1822 | - } |
|
| 1818 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1819 | + $overwrite['device_type'] = $dt; |
|
| 1820 | + $inputs[ $type . $ds ] = sd_get_flex_order_input( $type, $overwrite ); |
|
| 1821 | + } |
|
| 1822 | + } |
|
| 1823 | 1823 | |
| 1824 | - return $inputs; |
|
| 1824 | + return $inputs; |
|
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | 1827 | function sd_get_flex_wrap_group( $type = 'flex_wrap', $overwrite = array() ) { |
| 1828 | - $inputs = array(); |
|
| 1829 | - $sizes = array( |
|
| 1830 | - '' => 'Mobile', |
|
| 1831 | - '_md' => 'Tablet', |
|
| 1832 | - '_lg' => 'Desktop', |
|
| 1833 | - ); |
|
| 1828 | + $inputs = array(); |
|
| 1829 | + $sizes = array( |
|
| 1830 | + '' => 'Mobile', |
|
| 1831 | + '_md' => 'Tablet', |
|
| 1832 | + '_lg' => 'Desktop', |
|
| 1833 | + ); |
|
| 1834 | 1834 | |
| 1835 | - if ( $overwrite !== false ) { |
|
| 1835 | + if ( $overwrite !== false ) { |
|
| 1836 | 1836 | |
| 1837 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1838 | - $overwrite['device_type'] = $dt; |
|
| 1839 | - $inputs[ $type . $ds ] = sd_get_flex_wrap_input( $type, $overwrite ); |
|
| 1840 | - } |
|
| 1841 | - } |
|
| 1837 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1838 | + $overwrite['device_type'] = $dt; |
|
| 1839 | + $inputs[ $type . $ds ] = sd_get_flex_wrap_input( $type, $overwrite ); |
|
| 1840 | + } |
|
| 1841 | + } |
|
| 1842 | 1842 | |
| 1843 | - return $inputs; |
|
| 1843 | + return $inputs; |
|
| 1844 | 1844 | } |
| 1845 | 1845 | |
| 1846 | 1846 | function sd_get_flex_wrap_input( $type = 'flex_wrap', $overwrite = array() ) { |
| 1847 | - $device_size = ''; |
|
| 1848 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1849 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1850 | - $device_size = '-md'; |
|
| 1851 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1852 | - $device_size = '-lg'; |
|
| 1853 | - } |
|
| 1854 | - } |
|
| 1855 | - $options = array( |
|
| 1856 | - '' => __( 'Default', 'super-duper' ), |
|
| 1857 | - 'flex' . $device_size . '-nowrap' => 'nowrap', |
|
| 1858 | - 'flex' . $device_size . '-wrap' => 'wrap', |
|
| 1859 | - 'flex' . $device_size . '-wrap-reverse' => 'wrap-reverse', |
|
| 1860 | - ); |
|
| 1861 | - |
|
| 1862 | - $defaults = array( |
|
| 1863 | - 'type' => 'select', |
|
| 1864 | - 'title' => __( 'Flex wrap', 'super-duper' ), |
|
| 1865 | - 'options' => $options, |
|
| 1866 | - 'default' => '', |
|
| 1867 | - 'desc_tip' => true, |
|
| 1868 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1869 | - ); |
|
| 1870 | - |
|
| 1871 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1872 | - |
|
| 1873 | - return $input; |
|
| 1847 | + $device_size = ''; |
|
| 1848 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1849 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1850 | + $device_size = '-md'; |
|
| 1851 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1852 | + $device_size = '-lg'; |
|
| 1853 | + } |
|
| 1854 | + } |
|
| 1855 | + $options = array( |
|
| 1856 | + '' => __( 'Default', 'super-duper' ), |
|
| 1857 | + 'flex' . $device_size . '-nowrap' => 'nowrap', |
|
| 1858 | + 'flex' . $device_size . '-wrap' => 'wrap', |
|
| 1859 | + 'flex' . $device_size . '-wrap-reverse' => 'wrap-reverse', |
|
| 1860 | + ); |
|
| 1861 | + |
|
| 1862 | + $defaults = array( |
|
| 1863 | + 'type' => 'select', |
|
| 1864 | + 'title' => __( 'Flex wrap', 'super-duper' ), |
|
| 1865 | + 'options' => $options, |
|
| 1866 | + 'default' => '', |
|
| 1867 | + 'desc_tip' => true, |
|
| 1868 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1869 | + ); |
|
| 1870 | + |
|
| 1871 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1872 | + |
|
| 1873 | + return $input; |
|
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | function sd_get_float_group( $type = 'float', $overwrite = array() ) { |
| 1877 | - $inputs = array(); |
|
| 1878 | - $sizes = array( |
|
| 1879 | - '' => 'Mobile', |
|
| 1880 | - '_md' => 'Tablet', |
|
| 1881 | - '_lg' => 'Desktop', |
|
| 1882 | - ); |
|
| 1877 | + $inputs = array(); |
|
| 1878 | + $sizes = array( |
|
| 1879 | + '' => 'Mobile', |
|
| 1880 | + '_md' => 'Tablet', |
|
| 1881 | + '_lg' => 'Desktop', |
|
| 1882 | + ); |
|
| 1883 | 1883 | |
| 1884 | - if ( $overwrite !== false ) { |
|
| 1884 | + if ( $overwrite !== false ) { |
|
| 1885 | 1885 | |
| 1886 | - foreach ( $sizes as $ds => $dt ) { |
|
| 1887 | - $overwrite['device_type'] = $dt; |
|
| 1888 | - $inputs[ $type . $ds ] = sd_get_float_input( $type, $overwrite ); |
|
| 1889 | - } |
|
| 1890 | - } |
|
| 1886 | + foreach ( $sizes as $ds => $dt ) { |
|
| 1887 | + $overwrite['device_type'] = $dt; |
|
| 1888 | + $inputs[ $type . $ds ] = sd_get_float_input( $type, $overwrite ); |
|
| 1889 | + } |
|
| 1890 | + } |
|
| 1891 | 1891 | |
| 1892 | - return $inputs; |
|
| 1892 | + return $inputs; |
|
| 1893 | 1893 | } |
| 1894 | 1894 | function sd_get_float_input( $type = 'float', $overwrite = array() ) { |
| 1895 | - $device_size = ''; |
|
| 1896 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1897 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1898 | - $device_size = '-md'; |
|
| 1899 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1900 | - $device_size = '-lg'; |
|
| 1901 | - } |
|
| 1902 | - } |
|
| 1903 | - $options = array( |
|
| 1904 | - '' => __( 'Default', 'super-duper' ), |
|
| 1905 | - 'float' . $device_size . '-start' => 'left', |
|
| 1906 | - 'float' . $device_size . '-end' => 'right', |
|
| 1907 | - 'float' . $device_size . '-none' => 'none', |
|
| 1908 | - ); |
|
| 1909 | - |
|
| 1910 | - $defaults = array( |
|
| 1911 | - 'type' => 'select', |
|
| 1912 | - 'title' => __( 'Float', 'super-duper' ), |
|
| 1913 | - 'options' => $options, |
|
| 1914 | - 'default' => '', |
|
| 1915 | - 'desc_tip' => true, |
|
| 1916 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1917 | - ); |
|
| 1918 | - |
|
| 1919 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1920 | - |
|
| 1921 | - return $input; |
|
| 1895 | + $device_size = ''; |
|
| 1896 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 1897 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 1898 | + $device_size = '-md'; |
|
| 1899 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 1900 | + $device_size = '-lg'; |
|
| 1901 | + } |
|
| 1902 | + } |
|
| 1903 | + $options = array( |
|
| 1904 | + '' => __( 'Default', 'super-duper' ), |
|
| 1905 | + 'float' . $device_size . '-start' => 'left', |
|
| 1906 | + 'float' . $device_size . '-end' => 'right', |
|
| 1907 | + 'float' . $device_size . '-none' => 'none', |
|
| 1908 | + ); |
|
| 1909 | + |
|
| 1910 | + $defaults = array( |
|
| 1911 | + 'type' => 'select', |
|
| 1912 | + 'title' => __( 'Float', 'super-duper' ), |
|
| 1913 | + 'options' => $options, |
|
| 1914 | + 'default' => '', |
|
| 1915 | + 'desc_tip' => true, |
|
| 1916 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1917 | + ); |
|
| 1918 | + |
|
| 1919 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1920 | + |
|
| 1921 | + return $input; |
|
| 1922 | 1922 | } |
| 1923 | 1923 | |
| 1924 | 1924 | /** |
@@ -1929,26 +1929,26 @@ discard block |
||
| 1929 | 1929 | */ |
| 1930 | 1930 | function sd_get_zindex_input( $type = 'zindex', $overwrite = array() ) { |
| 1931 | 1931 | |
| 1932 | - $options = array( |
|
| 1933 | - '' => __( 'Default', 'super-duper' ), |
|
| 1934 | - 'zindex-0' => '0', |
|
| 1935 | - 'zindex-1' => '1', |
|
| 1936 | - 'zindex-5' => '5', |
|
| 1937 | - 'zindex-10' => '10', |
|
| 1938 | - ); |
|
| 1932 | + $options = array( |
|
| 1933 | + '' => __( 'Default', 'super-duper' ), |
|
| 1934 | + 'zindex-0' => '0', |
|
| 1935 | + 'zindex-1' => '1', |
|
| 1936 | + 'zindex-5' => '5', |
|
| 1937 | + 'zindex-10' => '10', |
|
| 1938 | + ); |
|
| 1939 | 1939 | |
| 1940 | - $defaults = array( |
|
| 1941 | - 'type' => 'select', |
|
| 1942 | - 'title' => __( 'Z-index', 'super-duper' ), |
|
| 1943 | - 'options' => $options, |
|
| 1944 | - 'default' => '', |
|
| 1945 | - 'desc_tip' => true, |
|
| 1946 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1947 | - ); |
|
| 1940 | + $defaults = array( |
|
| 1941 | + 'type' => 'select', |
|
| 1942 | + 'title' => __( 'Z-index', 'super-duper' ), |
|
| 1943 | + 'options' => $options, |
|
| 1944 | + 'default' => '', |
|
| 1945 | + 'desc_tip' => true, |
|
| 1946 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1947 | + ); |
|
| 1948 | 1948 | |
| 1949 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1949 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1950 | 1950 | |
| 1951 | - return $input; |
|
| 1951 | + return $input; |
|
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | 1954 | /** |
@@ -1959,26 +1959,26 @@ discard block |
||
| 1959 | 1959 | */ |
| 1960 | 1960 | function sd_get_overflow_input( $type = 'overflow', $overwrite = array() ) { |
| 1961 | 1961 | |
| 1962 | - $options = array( |
|
| 1963 | - '' => __( 'Default', 'super-duper' ), |
|
| 1964 | - 'overflow-auto' => __( 'Auto', 'super-duper' ), |
|
| 1965 | - 'overflow-hidden' => __( 'Hidden', 'super-duper' ), |
|
| 1966 | - 'overflow-visible' => __( 'Visible', 'super-duper' ), |
|
| 1967 | - 'overflow-scroll' => __( 'Scroll', 'super-duper' ), |
|
| 1968 | - ); |
|
| 1962 | + $options = array( |
|
| 1963 | + '' => __( 'Default', 'super-duper' ), |
|
| 1964 | + 'overflow-auto' => __( 'Auto', 'super-duper' ), |
|
| 1965 | + 'overflow-hidden' => __( 'Hidden', 'super-duper' ), |
|
| 1966 | + 'overflow-visible' => __( 'Visible', 'super-duper' ), |
|
| 1967 | + 'overflow-scroll' => __( 'Scroll', 'super-duper' ), |
|
| 1968 | + ); |
|
| 1969 | 1969 | |
| 1970 | - $defaults = array( |
|
| 1971 | - 'type' => 'select', |
|
| 1972 | - 'title' => __( 'Overflow', 'super-duper' ), |
|
| 1973 | - 'options' => $options, |
|
| 1974 | - 'default' => '', |
|
| 1975 | - 'desc_tip' => true, |
|
| 1976 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1977 | - ); |
|
| 1970 | + $defaults = array( |
|
| 1971 | + 'type' => 'select', |
|
| 1972 | + 'title' => __( 'Overflow', 'super-duper' ), |
|
| 1973 | + 'options' => $options, |
|
| 1974 | + 'default' => '', |
|
| 1975 | + 'desc_tip' => true, |
|
| 1976 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 1977 | + ); |
|
| 1978 | 1978 | |
| 1979 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1979 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1980 | 1980 | |
| 1981 | - return $input; |
|
| 1981 | + return $input; |
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | 1984 | /** |
@@ -1989,19 +1989,19 @@ discard block |
||
| 1989 | 1989 | */ |
| 1990 | 1990 | function sd_get_max_height_input( $type = 'max_height', $overwrite = array() ) { |
| 1991 | 1991 | |
| 1992 | - $defaults = array( |
|
| 1993 | - 'type' => 'text', |
|
| 1994 | - 'title' => __( 'Max height', 'super-duper' ), |
|
| 1995 | - 'value' => '', |
|
| 1996 | - 'default' => '', |
|
| 1997 | - 'placeholder' => '', |
|
| 1998 | - 'desc_tip' => true, |
|
| 1999 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 2000 | - ); |
|
| 1992 | + $defaults = array( |
|
| 1993 | + 'type' => 'text', |
|
| 1994 | + 'title' => __( 'Max height', 'super-duper' ), |
|
| 1995 | + 'value' => '', |
|
| 1996 | + 'default' => '', |
|
| 1997 | + 'placeholder' => '', |
|
| 1998 | + 'desc_tip' => true, |
|
| 1999 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 2000 | + ); |
|
| 2001 | 2001 | |
| 2002 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2002 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2003 | 2003 | |
| 2004 | - return $input; |
|
| 2004 | + return $input; |
|
| 2005 | 2005 | } |
| 2006 | 2006 | |
| 2007 | 2007 | /** |
@@ -2012,23 +2012,23 @@ discard block |
||
| 2012 | 2012 | */ |
| 2013 | 2013 | function sd_get_scrollbars_input( $type = 'scrollbars', $overwrite = array() ) { |
| 2014 | 2014 | |
| 2015 | - $options = array( |
|
| 2016 | - '' => __( 'Default', 'super-duper' ), |
|
| 2017 | - 'scrollbars-ios' => __( 'IOS Style', 'super-duper' ), |
|
| 2018 | - ); |
|
| 2015 | + $options = array( |
|
| 2016 | + '' => __( 'Default', 'super-duper' ), |
|
| 2017 | + 'scrollbars-ios' => __( 'IOS Style', 'super-duper' ), |
|
| 2018 | + ); |
|
| 2019 | 2019 | |
| 2020 | - $defaults = array( |
|
| 2021 | - 'type' => 'select', |
|
| 2022 | - 'title' => __( 'Scrollbars', 'super-duper' ), |
|
| 2023 | - 'options' => $options, |
|
| 2024 | - 'default' => '', |
|
| 2025 | - 'desc_tip' => true, |
|
| 2026 | - 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 2027 | - ); |
|
| 2020 | + $defaults = array( |
|
| 2021 | + 'type' => 'select', |
|
| 2022 | + 'title' => __( 'Scrollbars', 'super-duper' ), |
|
| 2023 | + 'options' => $options, |
|
| 2024 | + 'default' => '', |
|
| 2025 | + 'desc_tip' => true, |
|
| 2026 | + 'group' => __( 'Wrapper Styles', 'super-duper' ), |
|
| 2027 | + ); |
|
| 2028 | 2028 | |
| 2029 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2029 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2030 | 2030 | |
| 2031 | - return $input; |
|
| 2031 | + return $input; |
|
| 2032 | 2032 | } |
| 2033 | 2033 | |
| 2034 | 2034 | /** |
@@ -2040,415 +2040,415 @@ discard block |
||
| 2040 | 2040 | * @todo find best way to use px- py- or general p- |
| 2041 | 2041 | */ |
| 2042 | 2042 | function sd_build_aui_class( $args ) { |
| 2043 | - global $aui_bs5; |
|
| 2044 | - |
|
| 2045 | - $classes = array(); |
|
| 2046 | - |
|
| 2047 | - if ( $aui_bs5 ) { |
|
| 2048 | - $p_ml = 'ms-'; |
|
| 2049 | - $p_mr = 'me-'; |
|
| 2050 | - |
|
| 2051 | - $p_pl = 'ps-'; |
|
| 2052 | - $p_pr = 'pe-'; |
|
| 2053 | - } else { |
|
| 2054 | - $p_ml = 'ml-'; |
|
| 2055 | - $p_mr = 'mr-'; |
|
| 2056 | - |
|
| 2057 | - $p_pl = 'pl-'; |
|
| 2058 | - $p_pr = 'pr-'; |
|
| 2059 | - } |
|
| 2060 | - |
|
| 2061 | - // margins. |
|
| 2062 | - if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 2063 | - $classes[] = 'mt-' . sanitize_html_class( $args['mt'] ); |
|
| 2064 | - $mt = $args['mt']; |
|
| 2065 | - } else { |
|
| 2066 | - $mt = null; |
|
| 2067 | - } |
|
| 2068 | - if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 2069 | - $classes[] = $p_mr . sanitize_html_class( $args['mr'] ); |
|
| 2070 | - $mr = $args['mr']; |
|
| 2071 | - } else { |
|
| 2072 | - $mr = null; |
|
| 2073 | - } |
|
| 2074 | - if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 2075 | - $classes[] = 'mb-' . sanitize_html_class( $args['mb'] ); |
|
| 2076 | - $mb = $args['mb']; |
|
| 2077 | - } else { |
|
| 2078 | - $mb = null; |
|
| 2079 | - } |
|
| 2080 | - if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 2081 | - $classes[] = $p_ml . sanitize_html_class( $args['ml'] ); |
|
| 2082 | - $ml = $args['ml']; |
|
| 2083 | - } else { |
|
| 2084 | - $ml = null; |
|
| 2085 | - } |
|
| 2086 | - |
|
| 2087 | - // margins tablet. |
|
| 2088 | - if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 2089 | - $classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] ); |
|
| 2090 | - $mt_md = $args['mt_md']; |
|
| 2091 | - } else { |
|
| 2092 | - $mt_md = null; |
|
| 2093 | - } |
|
| 2094 | - if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 2095 | - $classes[] = $p_mr . 'md-' . sanitize_html_class( $args['mr_md'] ); |
|
| 2096 | - $mt_md = $args['mr_md']; |
|
| 2097 | - } else { |
|
| 2098 | - $mr_md = null; |
|
| 2099 | - } |
|
| 2100 | - if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 2101 | - $classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] ); |
|
| 2102 | - $mt_md = $args['mb_md']; |
|
| 2103 | - } else { |
|
| 2104 | - $mb_md = null; |
|
| 2105 | - } |
|
| 2106 | - if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 2107 | - $classes[] = $p_ml . 'md-' . sanitize_html_class( $args['ml_md'] ); |
|
| 2108 | - $mt_md = $args['ml_md']; |
|
| 2109 | - } else { |
|
| 2110 | - $ml_md = null; |
|
| 2111 | - } |
|
| 2112 | - |
|
| 2113 | - // margins desktop. |
|
| 2114 | - if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 2115 | - if ( $mt == null && $mt_md == null ) { |
|
| 2116 | - $classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 2117 | - } else { |
|
| 2118 | - $classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 2119 | - } |
|
| 2120 | - } |
|
| 2121 | - if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 2122 | - if ( $mr == null && $mr_md == null ) { |
|
| 2123 | - $classes[] = $p_mr . sanitize_html_class( $args['mr_lg'] ); |
|
| 2124 | - } else { |
|
| 2125 | - $classes[] = $p_mr . 'lg-' . sanitize_html_class( $args['mr_lg'] ); |
|
| 2126 | - } |
|
| 2127 | - } |
|
| 2128 | - if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 2129 | - if ( $mb == null && $mb_md == null ) { |
|
| 2130 | - $classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 2131 | - } else { |
|
| 2132 | - $classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 2133 | - } |
|
| 2134 | - } |
|
| 2135 | - if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 2136 | - if ( $ml == null && $ml_md == null ) { |
|
| 2137 | - $classes[] = $p_ml . sanitize_html_class( $args['ml_lg'] ); |
|
| 2138 | - } else { |
|
| 2139 | - $classes[] = $p_ml . 'lg-' . sanitize_html_class( $args['ml_lg'] ); |
|
| 2140 | - } |
|
| 2141 | - } |
|
| 2142 | - |
|
| 2143 | - // padding. |
|
| 2144 | - if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 2145 | - $classes[] = 'pt-' . sanitize_html_class( $args['pt'] ); |
|
| 2146 | - $pt = $args['pt']; |
|
| 2147 | - } else { |
|
| 2148 | - $pt = null; |
|
| 2149 | - } |
|
| 2150 | - if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 2151 | - $classes[] = $p_pr . sanitize_html_class( $args['pr'] ); |
|
| 2152 | - $pr = $args['pr']; |
|
| 2153 | - } else { |
|
| 2154 | - $pr = null; |
|
| 2155 | - } |
|
| 2156 | - if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 2157 | - $classes[] = 'pb-' . sanitize_html_class( $args['pb'] ); |
|
| 2158 | - $pb = $args['pb']; |
|
| 2159 | - } else { |
|
| 2160 | - $pb = null; |
|
| 2161 | - } |
|
| 2162 | - if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 2163 | - $classes[] = $p_pl . sanitize_html_class( $args['pl'] ); |
|
| 2164 | - $pl = $args['pl']; |
|
| 2165 | - } else { |
|
| 2166 | - $pl = null; |
|
| 2167 | - } |
|
| 2168 | - |
|
| 2169 | - // padding tablet. |
|
| 2170 | - if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 2171 | - $classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] ); |
|
| 2172 | - $pt_md = $args['pt_md']; |
|
| 2173 | - } else { |
|
| 2174 | - $pt_md = null; |
|
| 2175 | - } |
|
| 2176 | - if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 2177 | - $classes[] = $p_pr . 'md-' . sanitize_html_class( $args['pr_md'] ); |
|
| 2178 | - $pr_md = $args['pr_md']; |
|
| 2179 | - } else { |
|
| 2180 | - $pr_md = null; |
|
| 2181 | - } |
|
| 2182 | - if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 2183 | - $classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] ); |
|
| 2184 | - $pb_md = $args['pb_md']; |
|
| 2185 | - } else { |
|
| 2186 | - $pb_md = null; |
|
| 2187 | - } |
|
| 2188 | - if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 2189 | - $classes[] = $p_pl . 'md-' . sanitize_html_class( $args['pl_md'] ); |
|
| 2190 | - $pl_md = $args['pl_md']; |
|
| 2191 | - } else { |
|
| 2192 | - $pl_md = null; |
|
| 2193 | - } |
|
| 2194 | - |
|
| 2195 | - // padding desktop. |
|
| 2196 | - if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 2197 | - if ( $pt == null && $pt_md == null ) { |
|
| 2198 | - $classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 2199 | - } else { |
|
| 2200 | - $classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 2201 | - } |
|
| 2202 | - } |
|
| 2203 | - if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 2204 | - if ( $pr == null && $pr_md == null ) { |
|
| 2205 | - $classes[] = $p_pr . sanitize_html_class( $args['pr_lg'] ); |
|
| 2206 | - } else { |
|
| 2207 | - $classes[] = $p_pr . 'lg-' . sanitize_html_class( $args['pr_lg'] ); |
|
| 2208 | - } |
|
| 2209 | - } |
|
| 2210 | - if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 2211 | - if ( $pb == null && $pb_md == null ) { |
|
| 2212 | - $classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 2213 | - } else { |
|
| 2214 | - $classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 2215 | - } |
|
| 2216 | - } |
|
| 2217 | - if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 2218 | - if ( $pl == null && $pl_md == null ) { |
|
| 2219 | - $classes[] = $p_pl . sanitize_html_class( $args['pl_lg'] ); |
|
| 2220 | - } else { |
|
| 2221 | - $classes[] = $p_pl . 'lg-' . sanitize_html_class( $args['pl_lg'] ); |
|
| 2222 | - } |
|
| 2223 | - } |
|
| 2224 | - |
|
| 2225 | - // row cols, mobile, tablet, desktop |
|
| 2226 | - if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 2227 | - $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] ); |
|
| 2228 | - $row_cols = $args['row_cols']; |
|
| 2229 | - } else { |
|
| 2230 | - $row_cols = null; |
|
| 2231 | - } |
|
| 2232 | - if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 2233 | - $classes[] = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] ); |
|
| 2234 | - $row_cols_md = $args['row_cols_md']; |
|
| 2235 | - } else { |
|
| 2236 | - $row_cols_md = null; |
|
| 2237 | - } |
|
| 2238 | - if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 2239 | - if ( $row_cols == null && $row_cols_md == null ) { |
|
| 2240 | - $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] ); |
|
| 2241 | - } else { |
|
| 2242 | - $classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] ); |
|
| 2243 | - } |
|
| 2244 | - } |
|
| 2245 | - |
|
| 2246 | - // columns , mobile, tablet, desktop |
|
| 2247 | - if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 2248 | - $classes[] = sanitize_html_class( 'col-' . $args['col'] ); |
|
| 2249 | - $col = $args['col']; |
|
| 2250 | - } else { |
|
| 2251 | - $col = null; |
|
| 2252 | - } |
|
| 2253 | - if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 2254 | - $classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] ); |
|
| 2255 | - $col_md = $args['col_md']; |
|
| 2256 | - } else { |
|
| 2257 | - $col_md = null; |
|
| 2258 | - } |
|
| 2259 | - if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 2260 | - if ( $col == null && $col_md == null ) { |
|
| 2261 | - $classes[] = sanitize_html_class( 'col-' . $args['col_lg'] ); |
|
| 2262 | - } else { |
|
| 2263 | - $classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] ); |
|
| 2264 | - } |
|
| 2265 | - } |
|
| 2266 | - |
|
| 2267 | - // border |
|
| 2268 | - if ( isset( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' || $args['border'] === 0 ) ) { |
|
| 2269 | - $classes[] = 'border-0'; |
|
| 2270 | - } elseif ( ! empty( $args['border'] ) ) { |
|
| 2271 | - $border_class = 'border'; |
|
| 2272 | - if ( ! empty( $args['border_type'] ) && strpos( $args['border_type'], '-0' ) === false ) { |
|
| 2273 | - $border_class = ''; |
|
| 2274 | - } |
|
| 2275 | - $classes[] = $border_class . ' border-' . sanitize_html_class( $args['border'] ); |
|
| 2276 | - } |
|
| 2277 | - |
|
| 2278 | - // border radius type |
|
| 2279 | - if ( ! empty( $args['rounded'] ) ) { |
|
| 2280 | - $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 2281 | - } |
|
| 2282 | - |
|
| 2283 | - // border radius size BS4 |
|
| 2284 | - if ( isset( $args['rounded_size'] ) && in_array( $args['rounded_size'], array( 'sm', 'lg' ) ) ) { |
|
| 2285 | - $classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] ); |
|
| 2286 | - // if we set a size then we need to remove "rounded" if set |
|
| 2287 | - if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) { |
|
| 2288 | - unset( $classes[ $key ] ); |
|
| 2289 | - } |
|
| 2290 | - } else { |
|
| 2291 | - |
|
| 2292 | - // border radius size , mobile, tablet, desktop |
|
| 2293 | - if ( isset( $args['rounded_size'] ) && $args['rounded_size'] !== '' ) { |
|
| 2294 | - $classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size'] ); |
|
| 2295 | - $rounded_size = $args['rounded_size']; |
|
| 2296 | - } else { |
|
| 2297 | - $rounded_size = null; |
|
| 2298 | - } |
|
| 2299 | - if ( isset( $args['rounded_size_md'] ) && $args['rounded_size_md'] !== '' ) { |
|
| 2300 | - $classes[] = sanitize_html_class( 'rounded-md-' . $args['rounded_size_md'] ); |
|
| 2301 | - $rounded_size_md = $args['rounded_size_md']; |
|
| 2302 | - } else { |
|
| 2303 | - $rounded_size_md = null; |
|
| 2304 | - } |
|
| 2305 | - if ( isset( $args['rounded_size_lg'] ) && $args['rounded_size_lg'] !== '' ) { |
|
| 2306 | - if ( $rounded_size == null && $rounded_size_md == null ) { |
|
| 2307 | - $classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size_lg'] ); |
|
| 2308 | - } else { |
|
| 2309 | - $classes[] = sanitize_html_class( 'rounded-lg-' . $args['rounded_size_lg'] ); |
|
| 2310 | - } |
|
| 2311 | - } |
|
| 2312 | - } |
|
| 2313 | - |
|
| 2314 | - // shadow |
|
| 2315 | - //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 2316 | - |
|
| 2317 | - // background |
|
| 2318 | - if ( ! empty( $args['bg'] ) ) { |
|
| 2319 | - $classes[] = 'bg-' . sanitize_html_class( $args['bg'] ); |
|
| 2320 | - } |
|
| 2321 | - |
|
| 2322 | - // text_color |
|
| 2323 | - if ( ! empty( $args['text_color'] ) ) { |
|
| 2324 | - $classes[] = 'text-' . sanitize_html_class( $args['text_color'] ); |
|
| 2325 | - } |
|
| 2326 | - |
|
| 2327 | - // text_align |
|
| 2328 | - if ( ! empty( $args['text_justify'] ) ) { |
|
| 2329 | - $classes[] = 'text-justify'; |
|
| 2330 | - } else { |
|
| 2331 | - if ( ! empty( $args['text_align'] ) ) { |
|
| 2332 | - $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 2333 | - $text_align = $args['text_align']; |
|
| 2334 | - } else { |
|
| 2335 | - $text_align = null; |
|
| 2336 | - } |
|
| 2337 | - if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 2338 | - $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 2339 | - $text_align_md = $args['text_align_md']; |
|
| 2340 | - } else { |
|
| 2341 | - $text_align_md = null; |
|
| 2342 | - } |
|
| 2343 | - if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 2344 | - if ( $text_align == null && $text_align_md == null ) { |
|
| 2345 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) ); |
|
| 2346 | - } else { |
|
| 2347 | - $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 2348 | - } |
|
| 2349 | - } |
|
| 2350 | - } |
|
| 2351 | - |
|
| 2352 | - // display |
|
| 2353 | - if ( ! empty( $args['display'] ) ) { |
|
| 2354 | - $classes[] = sanitize_html_class( $args['display'] ); |
|
| 2355 | - $display = $args['display']; |
|
| 2356 | - } else { |
|
| 2357 | - $display = null; |
|
| 2358 | - } |
|
| 2359 | - if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 2360 | - $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 2361 | - $display_md = $args['display_md']; |
|
| 2362 | - } else { |
|
| 2363 | - $display_md = null; |
|
| 2364 | - } |
|
| 2365 | - if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 2366 | - if ( $display == null && $display_md == null ) { |
|
| 2367 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) ); |
|
| 2368 | - } else { |
|
| 2369 | - $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 2370 | - } |
|
| 2371 | - } |
|
| 2372 | - |
|
| 2373 | - // bgtus - background transparent until scroll |
|
| 2374 | - if ( ! empty( $args['bgtus'] ) ) { |
|
| 2375 | - $classes[] = sanitize_html_class( 'bg-transparent-until-scroll' ); |
|
| 2376 | - } |
|
| 2377 | - |
|
| 2378 | - // cscos - change color scheme on scroll |
|
| 2379 | - if ( ! empty( $args['bgtus'] ) && ! empty( $args['cscos'] ) ) { |
|
| 2380 | - $classes[] = sanitize_html_class( 'color-scheme-flip-on-scroll' ); |
|
| 2381 | - } |
|
| 2382 | - |
|
| 2383 | - // hover animations |
|
| 2384 | - if ( ! empty( $args['hover_animations'] ) ) { |
|
| 2385 | - $classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) ); |
|
| 2386 | - } |
|
| 2387 | - |
|
| 2388 | - // absolute_position |
|
| 2389 | - if ( ! empty( $args['absolute_position'] ) ) { |
|
| 2390 | - if ( 'top-left' === $args['absolute_position'] ) { |
|
| 2391 | - $classes[] = 'start-0 top-0'; |
|
| 2392 | - } elseif ( 'top-center' === $args['absolute_position'] ) { |
|
| 2393 | - $classes[] = 'start-50 top-0 translate-middle'; |
|
| 2394 | - } elseif ( 'top-right' === $args['absolute_position'] ) { |
|
| 2395 | - $classes[] = 'end-0 top-0'; |
|
| 2396 | - } elseif ( 'center-left' === $args['absolute_position'] ) { |
|
| 2397 | - $classes[] = 'start-0 top-50'; |
|
| 2398 | - } elseif ( 'center' === $args['absolute_position'] ) { |
|
| 2399 | - $classes[] = 'start-50 top-50 translate-middle'; |
|
| 2400 | - } elseif ( 'center-right' === $args['absolute_position'] ) { |
|
| 2401 | - $classes[] = 'end-0 top-50'; |
|
| 2402 | - } elseif ( 'bottom-left' === $args['absolute_position'] ) { |
|
| 2403 | - $classes[] = 'start-0 bottom-0'; |
|
| 2404 | - } elseif ( 'bottom-center' === $args['absolute_position'] ) { |
|
| 2405 | - $classes[] = 'start-50 bottom-0 translate-middle'; |
|
| 2406 | - } elseif ( 'bottom-right' === $args['absolute_position'] ) { |
|
| 2407 | - $classes[] = 'end-0 bottom-0'; |
|
| 2408 | - } |
|
| 2409 | - } |
|
| 2410 | - |
|
| 2411 | - // build classes from build keys |
|
| 2412 | - $build_keys = sd_get_class_build_keys(); |
|
| 2413 | - if ( ! empty( $build_keys ) ) { |
|
| 2414 | - foreach ( $build_keys as $key ) { |
|
| 2415 | - |
|
| 2416 | - if ( substr( $key, -4 ) == '-MTD' ) { |
|
| 2417 | - |
|
| 2418 | - $k = str_replace( '-MTD', '', $key ); |
|
| 2419 | - |
|
| 2420 | - // Mobile, Tablet, Desktop |
|
| 2421 | - if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) { |
|
| 2422 | - $classes[] = sanitize_html_class( $args[ $k ] ); |
|
| 2423 | - $v = $args[ $k ]; |
|
| 2424 | - } else { |
|
| 2425 | - $v = null; |
|
| 2426 | - } |
|
| 2427 | - if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) { |
|
| 2428 | - $classes[] = sanitize_html_class( $args[ $k . '_md' ] ); |
|
| 2429 | - $v_md = $args[ $k . '_md' ]; |
|
| 2430 | - } else { |
|
| 2431 | - $v_md = null; |
|
| 2432 | - } |
|
| 2433 | - if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) { |
|
| 2434 | - if ( $v == null && $v_md == null ) { |
|
| 2435 | - $classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) ); |
|
| 2436 | - } else { |
|
| 2437 | - $classes[] = sanitize_html_class( $args[ $k . '_lg' ] ); |
|
| 2438 | - } |
|
| 2439 | - } |
|
| 2440 | - } else { |
|
| 2441 | - if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 2442 | - continue; |
|
| 2443 | - } |
|
| 2444 | - if ( ! empty( $args[ $key ] ) ) { |
|
| 2445 | - $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 2446 | - } |
|
| 2447 | - } |
|
| 2448 | - } |
|
| 2449 | - } |
|
| 2450 | - |
|
| 2451 | - return implode( ' ', $classes ); |
|
| 2043 | + global $aui_bs5; |
|
| 2044 | + |
|
| 2045 | + $classes = array(); |
|
| 2046 | + |
|
| 2047 | + if ( $aui_bs5 ) { |
|
| 2048 | + $p_ml = 'ms-'; |
|
| 2049 | + $p_mr = 'me-'; |
|
| 2050 | + |
|
| 2051 | + $p_pl = 'ps-'; |
|
| 2052 | + $p_pr = 'pe-'; |
|
| 2053 | + } else { |
|
| 2054 | + $p_ml = 'ml-'; |
|
| 2055 | + $p_mr = 'mr-'; |
|
| 2056 | + |
|
| 2057 | + $p_pl = 'pl-'; |
|
| 2058 | + $p_pr = 'pr-'; |
|
| 2059 | + } |
|
| 2060 | + |
|
| 2061 | + // margins. |
|
| 2062 | + if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 2063 | + $classes[] = 'mt-' . sanitize_html_class( $args['mt'] ); |
|
| 2064 | + $mt = $args['mt']; |
|
| 2065 | + } else { |
|
| 2066 | + $mt = null; |
|
| 2067 | + } |
|
| 2068 | + if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 2069 | + $classes[] = $p_mr . sanitize_html_class( $args['mr'] ); |
|
| 2070 | + $mr = $args['mr']; |
|
| 2071 | + } else { |
|
| 2072 | + $mr = null; |
|
| 2073 | + } |
|
| 2074 | + if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 2075 | + $classes[] = 'mb-' . sanitize_html_class( $args['mb'] ); |
|
| 2076 | + $mb = $args['mb']; |
|
| 2077 | + } else { |
|
| 2078 | + $mb = null; |
|
| 2079 | + } |
|
| 2080 | + if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 2081 | + $classes[] = $p_ml . sanitize_html_class( $args['ml'] ); |
|
| 2082 | + $ml = $args['ml']; |
|
| 2083 | + } else { |
|
| 2084 | + $ml = null; |
|
| 2085 | + } |
|
| 2086 | + |
|
| 2087 | + // margins tablet. |
|
| 2088 | + if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 2089 | + $classes[] = 'mt-md-' . sanitize_html_class( $args['mt_md'] ); |
|
| 2090 | + $mt_md = $args['mt_md']; |
|
| 2091 | + } else { |
|
| 2092 | + $mt_md = null; |
|
| 2093 | + } |
|
| 2094 | + if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 2095 | + $classes[] = $p_mr . 'md-' . sanitize_html_class( $args['mr_md'] ); |
|
| 2096 | + $mt_md = $args['mr_md']; |
|
| 2097 | + } else { |
|
| 2098 | + $mr_md = null; |
|
| 2099 | + } |
|
| 2100 | + if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 2101 | + $classes[] = 'mb-md-' . sanitize_html_class( $args['mb_md'] ); |
|
| 2102 | + $mt_md = $args['mb_md']; |
|
| 2103 | + } else { |
|
| 2104 | + $mb_md = null; |
|
| 2105 | + } |
|
| 2106 | + if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 2107 | + $classes[] = $p_ml . 'md-' . sanitize_html_class( $args['ml_md'] ); |
|
| 2108 | + $mt_md = $args['ml_md']; |
|
| 2109 | + } else { |
|
| 2110 | + $ml_md = null; |
|
| 2111 | + } |
|
| 2112 | + |
|
| 2113 | + // margins desktop. |
|
| 2114 | + if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 2115 | + if ( $mt == null && $mt_md == null ) { |
|
| 2116 | + $classes[] = 'mt-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 2117 | + } else { |
|
| 2118 | + $classes[] = 'mt-lg-' . sanitize_html_class( $args['mt_lg'] ); |
|
| 2119 | + } |
|
| 2120 | + } |
|
| 2121 | + if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 2122 | + if ( $mr == null && $mr_md == null ) { |
|
| 2123 | + $classes[] = $p_mr . sanitize_html_class( $args['mr_lg'] ); |
|
| 2124 | + } else { |
|
| 2125 | + $classes[] = $p_mr . 'lg-' . sanitize_html_class( $args['mr_lg'] ); |
|
| 2126 | + } |
|
| 2127 | + } |
|
| 2128 | + if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 2129 | + if ( $mb == null && $mb_md == null ) { |
|
| 2130 | + $classes[] = 'mb-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 2131 | + } else { |
|
| 2132 | + $classes[] = 'mb-lg-' . sanitize_html_class( $args['mb_lg'] ); |
|
| 2133 | + } |
|
| 2134 | + } |
|
| 2135 | + if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 2136 | + if ( $ml == null && $ml_md == null ) { |
|
| 2137 | + $classes[] = $p_ml . sanitize_html_class( $args['ml_lg'] ); |
|
| 2138 | + } else { |
|
| 2139 | + $classes[] = $p_ml . 'lg-' . sanitize_html_class( $args['ml_lg'] ); |
|
| 2140 | + } |
|
| 2141 | + } |
|
| 2142 | + |
|
| 2143 | + // padding. |
|
| 2144 | + if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 2145 | + $classes[] = 'pt-' . sanitize_html_class( $args['pt'] ); |
|
| 2146 | + $pt = $args['pt']; |
|
| 2147 | + } else { |
|
| 2148 | + $pt = null; |
|
| 2149 | + } |
|
| 2150 | + if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 2151 | + $classes[] = $p_pr . sanitize_html_class( $args['pr'] ); |
|
| 2152 | + $pr = $args['pr']; |
|
| 2153 | + } else { |
|
| 2154 | + $pr = null; |
|
| 2155 | + } |
|
| 2156 | + if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 2157 | + $classes[] = 'pb-' . sanitize_html_class( $args['pb'] ); |
|
| 2158 | + $pb = $args['pb']; |
|
| 2159 | + } else { |
|
| 2160 | + $pb = null; |
|
| 2161 | + } |
|
| 2162 | + if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 2163 | + $classes[] = $p_pl . sanitize_html_class( $args['pl'] ); |
|
| 2164 | + $pl = $args['pl']; |
|
| 2165 | + } else { |
|
| 2166 | + $pl = null; |
|
| 2167 | + } |
|
| 2168 | + |
|
| 2169 | + // padding tablet. |
|
| 2170 | + if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 2171 | + $classes[] = 'pt-md-' . sanitize_html_class( $args['pt_md'] ); |
|
| 2172 | + $pt_md = $args['pt_md']; |
|
| 2173 | + } else { |
|
| 2174 | + $pt_md = null; |
|
| 2175 | + } |
|
| 2176 | + if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 2177 | + $classes[] = $p_pr . 'md-' . sanitize_html_class( $args['pr_md'] ); |
|
| 2178 | + $pr_md = $args['pr_md']; |
|
| 2179 | + } else { |
|
| 2180 | + $pr_md = null; |
|
| 2181 | + } |
|
| 2182 | + if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 2183 | + $classes[] = 'pb-md-' . sanitize_html_class( $args['pb_md'] ); |
|
| 2184 | + $pb_md = $args['pb_md']; |
|
| 2185 | + } else { |
|
| 2186 | + $pb_md = null; |
|
| 2187 | + } |
|
| 2188 | + if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 2189 | + $classes[] = $p_pl . 'md-' . sanitize_html_class( $args['pl_md'] ); |
|
| 2190 | + $pl_md = $args['pl_md']; |
|
| 2191 | + } else { |
|
| 2192 | + $pl_md = null; |
|
| 2193 | + } |
|
| 2194 | + |
|
| 2195 | + // padding desktop. |
|
| 2196 | + if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 2197 | + if ( $pt == null && $pt_md == null ) { |
|
| 2198 | + $classes[] = 'pt-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 2199 | + } else { |
|
| 2200 | + $classes[] = 'pt-lg-' . sanitize_html_class( $args['pt_lg'] ); |
|
| 2201 | + } |
|
| 2202 | + } |
|
| 2203 | + if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 2204 | + if ( $pr == null && $pr_md == null ) { |
|
| 2205 | + $classes[] = $p_pr . sanitize_html_class( $args['pr_lg'] ); |
|
| 2206 | + } else { |
|
| 2207 | + $classes[] = $p_pr . 'lg-' . sanitize_html_class( $args['pr_lg'] ); |
|
| 2208 | + } |
|
| 2209 | + } |
|
| 2210 | + if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 2211 | + if ( $pb == null && $pb_md == null ) { |
|
| 2212 | + $classes[] = 'pb-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 2213 | + } else { |
|
| 2214 | + $classes[] = 'pb-lg-' . sanitize_html_class( $args['pb_lg'] ); |
|
| 2215 | + } |
|
| 2216 | + } |
|
| 2217 | + if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 2218 | + if ( $pl == null && $pl_md == null ) { |
|
| 2219 | + $classes[] = $p_pl . sanitize_html_class( $args['pl_lg'] ); |
|
| 2220 | + } else { |
|
| 2221 | + $classes[] = $p_pl . 'lg-' . sanitize_html_class( $args['pl_lg'] ); |
|
| 2222 | + } |
|
| 2223 | + } |
|
| 2224 | + |
|
| 2225 | + // row cols, mobile, tablet, desktop |
|
| 2226 | + if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 2227 | + $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols'] ); |
|
| 2228 | + $row_cols = $args['row_cols']; |
|
| 2229 | + } else { |
|
| 2230 | + $row_cols = null; |
|
| 2231 | + } |
|
| 2232 | + if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 2233 | + $classes[] = sanitize_html_class( 'row-cols-md-' . $args['row_cols_md'] ); |
|
| 2234 | + $row_cols_md = $args['row_cols_md']; |
|
| 2235 | + } else { |
|
| 2236 | + $row_cols_md = null; |
|
| 2237 | + } |
|
| 2238 | + if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 2239 | + if ( $row_cols == null && $row_cols_md == null ) { |
|
| 2240 | + $classes[] = sanitize_html_class( 'row-cols-' . $args['row_cols_lg'] ); |
|
| 2241 | + } else { |
|
| 2242 | + $classes[] = sanitize_html_class( 'row-cols-lg-' . $args['row_cols_lg'] ); |
|
| 2243 | + } |
|
| 2244 | + } |
|
| 2245 | + |
|
| 2246 | + // columns , mobile, tablet, desktop |
|
| 2247 | + if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 2248 | + $classes[] = sanitize_html_class( 'col-' . $args['col'] ); |
|
| 2249 | + $col = $args['col']; |
|
| 2250 | + } else { |
|
| 2251 | + $col = null; |
|
| 2252 | + } |
|
| 2253 | + if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 2254 | + $classes[] = sanitize_html_class( 'col-md-' . $args['col_md'] ); |
|
| 2255 | + $col_md = $args['col_md']; |
|
| 2256 | + } else { |
|
| 2257 | + $col_md = null; |
|
| 2258 | + } |
|
| 2259 | + if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 2260 | + if ( $col == null && $col_md == null ) { |
|
| 2261 | + $classes[] = sanitize_html_class( 'col-' . $args['col_lg'] ); |
|
| 2262 | + } else { |
|
| 2263 | + $classes[] = sanitize_html_class( 'col-lg-' . $args['col_lg'] ); |
|
| 2264 | + } |
|
| 2265 | + } |
|
| 2266 | + |
|
| 2267 | + // border |
|
| 2268 | + if ( isset( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' || $args['border'] === 0 ) ) { |
|
| 2269 | + $classes[] = 'border-0'; |
|
| 2270 | + } elseif ( ! empty( $args['border'] ) ) { |
|
| 2271 | + $border_class = 'border'; |
|
| 2272 | + if ( ! empty( $args['border_type'] ) && strpos( $args['border_type'], '-0' ) === false ) { |
|
| 2273 | + $border_class = ''; |
|
| 2274 | + } |
|
| 2275 | + $classes[] = $border_class . ' border-' . sanitize_html_class( $args['border'] ); |
|
| 2276 | + } |
|
| 2277 | + |
|
| 2278 | + // border radius type |
|
| 2279 | + if ( ! empty( $args['rounded'] ) ) { |
|
| 2280 | + $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 2281 | + } |
|
| 2282 | + |
|
| 2283 | + // border radius size BS4 |
|
| 2284 | + if ( isset( $args['rounded_size'] ) && in_array( $args['rounded_size'], array( 'sm', 'lg' ) ) ) { |
|
| 2285 | + $classes[] = 'rounded-' . sanitize_html_class( $args['rounded_size'] ); |
|
| 2286 | + // if we set a size then we need to remove "rounded" if set |
|
| 2287 | + if ( ( $key = array_search( 'rounded', $classes ) ) !== false ) { |
|
| 2288 | + unset( $classes[ $key ] ); |
|
| 2289 | + } |
|
| 2290 | + } else { |
|
| 2291 | + |
|
| 2292 | + // border radius size , mobile, tablet, desktop |
|
| 2293 | + if ( isset( $args['rounded_size'] ) && $args['rounded_size'] !== '' ) { |
|
| 2294 | + $classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size'] ); |
|
| 2295 | + $rounded_size = $args['rounded_size']; |
|
| 2296 | + } else { |
|
| 2297 | + $rounded_size = null; |
|
| 2298 | + } |
|
| 2299 | + if ( isset( $args['rounded_size_md'] ) && $args['rounded_size_md'] !== '' ) { |
|
| 2300 | + $classes[] = sanitize_html_class( 'rounded-md-' . $args['rounded_size_md'] ); |
|
| 2301 | + $rounded_size_md = $args['rounded_size_md']; |
|
| 2302 | + } else { |
|
| 2303 | + $rounded_size_md = null; |
|
| 2304 | + } |
|
| 2305 | + if ( isset( $args['rounded_size_lg'] ) && $args['rounded_size_lg'] !== '' ) { |
|
| 2306 | + if ( $rounded_size == null && $rounded_size_md == null ) { |
|
| 2307 | + $classes[] = sanitize_html_class( 'rounded-' . $args['rounded_size_lg'] ); |
|
| 2308 | + } else { |
|
| 2309 | + $classes[] = sanitize_html_class( 'rounded-lg-' . $args['rounded_size_lg'] ); |
|
| 2310 | + } |
|
| 2311 | + } |
|
| 2312 | + } |
|
| 2313 | + |
|
| 2314 | + // shadow |
|
| 2315 | + //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 2316 | + |
|
| 2317 | + // background |
|
| 2318 | + if ( ! empty( $args['bg'] ) ) { |
|
| 2319 | + $classes[] = 'bg-' . sanitize_html_class( $args['bg'] ); |
|
| 2320 | + } |
|
| 2321 | + |
|
| 2322 | + // text_color |
|
| 2323 | + if ( ! empty( $args['text_color'] ) ) { |
|
| 2324 | + $classes[] = 'text-' . sanitize_html_class( $args['text_color'] ); |
|
| 2325 | + } |
|
| 2326 | + |
|
| 2327 | + // text_align |
|
| 2328 | + if ( ! empty( $args['text_justify'] ) ) { |
|
| 2329 | + $classes[] = 'text-justify'; |
|
| 2330 | + } else { |
|
| 2331 | + if ( ! empty( $args['text_align'] ) ) { |
|
| 2332 | + $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 2333 | + $text_align = $args['text_align']; |
|
| 2334 | + } else { |
|
| 2335 | + $text_align = null; |
|
| 2336 | + } |
|
| 2337 | + if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 2338 | + $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 2339 | + $text_align_md = $args['text_align_md']; |
|
| 2340 | + } else { |
|
| 2341 | + $text_align_md = null; |
|
| 2342 | + } |
|
| 2343 | + if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 2344 | + if ( $text_align == null && $text_align_md == null ) { |
|
| 2345 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['text_align_lg'] ) ); |
|
| 2346 | + } else { |
|
| 2347 | + $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 2348 | + } |
|
| 2349 | + } |
|
| 2350 | + } |
|
| 2351 | + |
|
| 2352 | + // display |
|
| 2353 | + if ( ! empty( $args['display'] ) ) { |
|
| 2354 | + $classes[] = sanitize_html_class( $args['display'] ); |
|
| 2355 | + $display = $args['display']; |
|
| 2356 | + } else { |
|
| 2357 | + $display = null; |
|
| 2358 | + } |
|
| 2359 | + if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 2360 | + $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 2361 | + $display_md = $args['display_md']; |
|
| 2362 | + } else { |
|
| 2363 | + $display_md = null; |
|
| 2364 | + } |
|
| 2365 | + if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 2366 | + if ( $display == null && $display_md == null ) { |
|
| 2367 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args['display_lg'] ) ); |
|
| 2368 | + } else { |
|
| 2369 | + $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 2370 | + } |
|
| 2371 | + } |
|
| 2372 | + |
|
| 2373 | + // bgtus - background transparent until scroll |
|
| 2374 | + if ( ! empty( $args['bgtus'] ) ) { |
|
| 2375 | + $classes[] = sanitize_html_class( 'bg-transparent-until-scroll' ); |
|
| 2376 | + } |
|
| 2377 | + |
|
| 2378 | + // cscos - change color scheme on scroll |
|
| 2379 | + if ( ! empty( $args['bgtus'] ) && ! empty( $args['cscos'] ) ) { |
|
| 2380 | + $classes[] = sanitize_html_class( 'color-scheme-flip-on-scroll' ); |
|
| 2381 | + } |
|
| 2382 | + |
|
| 2383 | + // hover animations |
|
| 2384 | + if ( ! empty( $args['hover_animations'] ) ) { |
|
| 2385 | + $classes[] = sd_sanitize_html_classes( str_replace( ',', ' ', $args['hover_animations'] ) ); |
|
| 2386 | + } |
|
| 2387 | + |
|
| 2388 | + // absolute_position |
|
| 2389 | + if ( ! empty( $args['absolute_position'] ) ) { |
|
| 2390 | + if ( 'top-left' === $args['absolute_position'] ) { |
|
| 2391 | + $classes[] = 'start-0 top-0'; |
|
| 2392 | + } elseif ( 'top-center' === $args['absolute_position'] ) { |
|
| 2393 | + $classes[] = 'start-50 top-0 translate-middle'; |
|
| 2394 | + } elseif ( 'top-right' === $args['absolute_position'] ) { |
|
| 2395 | + $classes[] = 'end-0 top-0'; |
|
| 2396 | + } elseif ( 'center-left' === $args['absolute_position'] ) { |
|
| 2397 | + $classes[] = 'start-0 top-50'; |
|
| 2398 | + } elseif ( 'center' === $args['absolute_position'] ) { |
|
| 2399 | + $classes[] = 'start-50 top-50 translate-middle'; |
|
| 2400 | + } elseif ( 'center-right' === $args['absolute_position'] ) { |
|
| 2401 | + $classes[] = 'end-0 top-50'; |
|
| 2402 | + } elseif ( 'bottom-left' === $args['absolute_position'] ) { |
|
| 2403 | + $classes[] = 'start-0 bottom-0'; |
|
| 2404 | + } elseif ( 'bottom-center' === $args['absolute_position'] ) { |
|
| 2405 | + $classes[] = 'start-50 bottom-0 translate-middle'; |
|
| 2406 | + } elseif ( 'bottom-right' === $args['absolute_position'] ) { |
|
| 2407 | + $classes[] = 'end-0 bottom-0'; |
|
| 2408 | + } |
|
| 2409 | + } |
|
| 2410 | + |
|
| 2411 | + // build classes from build keys |
|
| 2412 | + $build_keys = sd_get_class_build_keys(); |
|
| 2413 | + if ( ! empty( $build_keys ) ) { |
|
| 2414 | + foreach ( $build_keys as $key ) { |
|
| 2415 | + |
|
| 2416 | + if ( substr( $key, -4 ) == '-MTD' ) { |
|
| 2417 | + |
|
| 2418 | + $k = str_replace( '-MTD', '', $key ); |
|
| 2419 | + |
|
| 2420 | + // Mobile, Tablet, Desktop |
|
| 2421 | + if ( ! empty( $args[ $k ] ) && $args[ $k ] !== '' ) { |
|
| 2422 | + $classes[] = sanitize_html_class( $args[ $k ] ); |
|
| 2423 | + $v = $args[ $k ]; |
|
| 2424 | + } else { |
|
| 2425 | + $v = null; |
|
| 2426 | + } |
|
| 2427 | + if ( ! empty( $args[ $k . '_md' ] ) && $args[ $k . '_md' ] !== '' ) { |
|
| 2428 | + $classes[] = sanitize_html_class( $args[ $k . '_md' ] ); |
|
| 2429 | + $v_md = $args[ $k . '_md' ]; |
|
| 2430 | + } else { |
|
| 2431 | + $v_md = null; |
|
| 2432 | + } |
|
| 2433 | + if ( ! empty( $args[ $k . '_lg' ] ) && $args[ $k . '_lg' ] !== '' ) { |
|
| 2434 | + if ( $v == null && $v_md == null ) { |
|
| 2435 | + $classes[] = sanitize_html_class( str_replace( '-lg', '', $args[ $k . '_lg' ] ) ); |
|
| 2436 | + } else { |
|
| 2437 | + $classes[] = sanitize_html_class( $args[ $k . '_lg' ] ); |
|
| 2438 | + } |
|
| 2439 | + } |
|
| 2440 | + } else { |
|
| 2441 | + if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 2442 | + continue; |
|
| 2443 | + } |
|
| 2444 | + if ( ! empty( $args[ $key ] ) ) { |
|
| 2445 | + $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 2446 | + } |
|
| 2447 | + } |
|
| 2448 | + } |
|
| 2449 | + } |
|
| 2450 | + |
|
| 2451 | + return implode( ' ', $classes ); |
|
| 2452 | 2452 | } |
| 2453 | 2453 | |
| 2454 | 2454 | /** |
@@ -2460,90 +2460,90 @@ discard block |
||
| 2460 | 2460 | */ |
| 2461 | 2461 | function sd_build_aui_styles( $args ) { |
| 2462 | 2462 | |
| 2463 | - $styles = array(); |
|
| 2464 | - |
|
| 2465 | - // background color |
|
| 2466 | - if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 2467 | - if ( $args['bg'] == 'custom-color' ) { |
|
| 2468 | - $styles['background-color'] = $args['bg_color']; |
|
| 2469 | - } elseif ( $args['bg'] == 'custom-gradient' ) { |
|
| 2470 | - $styles['background-image'] = $args['bg_gradient']; |
|
| 2471 | - |
|
| 2472 | - // use background on text. |
|
| 2473 | - if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 2474 | - $styles['background-clip'] = 'text'; |
|
| 2475 | - $styles['-webkit-background-clip'] = 'text'; |
|
| 2476 | - $styles['text-fill-color'] = 'transparent'; |
|
| 2477 | - $styles['-webkit-text-fill-color'] = 'transparent'; |
|
| 2478 | - } |
|
| 2479 | - } |
|
| 2480 | - } |
|
| 2481 | - |
|
| 2482 | - if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 2483 | - $hasImage = true; |
|
| 2484 | - if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) { |
|
| 2485 | - $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2486 | - $styles['background-blend-mode'] = 'overlay'; |
|
| 2487 | - } elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) { |
|
| 2488 | - $styles['background-image'] .= ',url(' . $args['bg_image'] . ')'; |
|
| 2489 | - } elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 2490 | - // do nothing as we alreay have a preset |
|
| 2491 | - $hasImage = false; |
|
| 2492 | - } else { |
|
| 2493 | - $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2494 | - } |
|
| 2495 | - |
|
| 2496 | - if ( $hasImage ) { |
|
| 2497 | - $styles['background-size'] = 'cover'; |
|
| 2498 | - |
|
| 2499 | - if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 2500 | - $styles['background-attachment'] = 'fixed'; |
|
| 2501 | - } |
|
| 2502 | - } |
|
| 2503 | - |
|
| 2504 | - if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) { |
|
| 2505 | - $styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%'; |
|
| 2506 | - } |
|
| 2507 | - } |
|
| 2508 | - |
|
| 2509 | - // sticky offset top |
|
| 2510 | - if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 2511 | - $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 2512 | - } |
|
| 2513 | - |
|
| 2514 | - // sticky offset bottom |
|
| 2515 | - if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 2516 | - $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 2517 | - } |
|
| 2518 | - |
|
| 2519 | - // font size |
|
| 2520 | - if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 2521 | - $styles['font-size'] = (float) $args['font_size_custom'] . 'rem'; |
|
| 2522 | - } |
|
| 2523 | - |
|
| 2524 | - // font color |
|
| 2525 | - if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 2526 | - $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 2527 | - } |
|
| 2528 | - |
|
| 2529 | - // font line height |
|
| 2530 | - if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) { |
|
| 2531 | - $styles['line-height'] = esc_attr( $args['font_line_height'] ); |
|
| 2532 | - } |
|
| 2533 | - |
|
| 2534 | - // max height |
|
| 2535 | - if ( ! empty( $args['max_height'] ) && $args['max_height'] !== '' ) { |
|
| 2536 | - $styles['max-height'] = esc_attr( $args['max_height'] ); |
|
| 2537 | - } |
|
| 2538 | - |
|
| 2539 | - $style_string = ''; |
|
| 2540 | - if ( ! empty( $styles ) ) { |
|
| 2541 | - foreach ( $styles as $key => $val ) { |
|
| 2542 | - $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 2543 | - } |
|
| 2544 | - } |
|
| 2545 | - |
|
| 2546 | - return $style_string; |
|
| 2463 | + $styles = array(); |
|
| 2464 | + |
|
| 2465 | + // background color |
|
| 2466 | + if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 2467 | + if ( $args['bg'] == 'custom-color' ) { |
|
| 2468 | + $styles['background-color'] = $args['bg_color']; |
|
| 2469 | + } elseif ( $args['bg'] == 'custom-gradient' ) { |
|
| 2470 | + $styles['background-image'] = $args['bg_gradient']; |
|
| 2471 | + |
|
| 2472 | + // use background on text. |
|
| 2473 | + if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 2474 | + $styles['background-clip'] = 'text'; |
|
| 2475 | + $styles['-webkit-background-clip'] = 'text'; |
|
| 2476 | + $styles['text-fill-color'] = 'transparent'; |
|
| 2477 | + $styles['-webkit-text-fill-color'] = 'transparent'; |
|
| 2478 | + } |
|
| 2479 | + } |
|
| 2480 | + } |
|
| 2481 | + |
|
| 2482 | + if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 2483 | + $hasImage = true; |
|
| 2484 | + if ( ! empty( $styles['background-color'] ) && $args['bg'] == 'custom-color' ) { |
|
| 2485 | + $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2486 | + $styles['background-blend-mode'] = 'overlay'; |
|
| 2487 | + } elseif ( ! empty( $styles['background-image'] ) && $args['bg'] == 'custom-gradient' ) { |
|
| 2488 | + $styles['background-image'] .= ',url(' . $args['bg_image'] . ')'; |
|
| 2489 | + } elseif ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 2490 | + // do nothing as we alreay have a preset |
|
| 2491 | + $hasImage = false; |
|
| 2492 | + } else { |
|
| 2493 | + $styles['background-image'] = 'url(' . $args['bg_image'] . ')'; |
|
| 2494 | + } |
|
| 2495 | + |
|
| 2496 | + if ( $hasImage ) { |
|
| 2497 | + $styles['background-size'] = 'cover'; |
|
| 2498 | + |
|
| 2499 | + if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 2500 | + $styles['background-attachment'] = 'fixed'; |
|
| 2501 | + } |
|
| 2502 | + } |
|
| 2503 | + |
|
| 2504 | + if ( $hasImage && ! empty( $args['bg_image_xy'] ) && ! empty( $args['bg_image_xy']['x'] ) ) { |
|
| 2505 | + $styles['background-position'] = ( $args['bg_image_xy']['x'] * 100 ) . '% ' . ( $args['bg_image_xy']['y'] * 100 ) . '%'; |
|
| 2506 | + } |
|
| 2507 | + } |
|
| 2508 | + |
|
| 2509 | + // sticky offset top |
|
| 2510 | + if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 2511 | + $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 2512 | + } |
|
| 2513 | + |
|
| 2514 | + // sticky offset bottom |
|
| 2515 | + if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 2516 | + $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 2517 | + } |
|
| 2518 | + |
|
| 2519 | + // font size |
|
| 2520 | + if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 2521 | + $styles['font-size'] = (float) $args['font_size_custom'] . 'rem'; |
|
| 2522 | + } |
|
| 2523 | + |
|
| 2524 | + // font color |
|
| 2525 | + if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 2526 | + $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 2527 | + } |
|
| 2528 | + |
|
| 2529 | + // font line height |
|
| 2530 | + if ( ! empty( $args['font_line_height'] ) && $args['font_line_height'] !== '' ) { |
|
| 2531 | + $styles['line-height'] = esc_attr( $args['font_line_height'] ); |
|
| 2532 | + } |
|
| 2533 | + |
|
| 2534 | + // max height |
|
| 2535 | + if ( ! empty( $args['max_height'] ) && $args['max_height'] !== '' ) { |
|
| 2536 | + $styles['max-height'] = esc_attr( $args['max_height'] ); |
|
| 2537 | + } |
|
| 2538 | + |
|
| 2539 | + $style_string = ''; |
|
| 2540 | + if ( ! empty( $styles ) ) { |
|
| 2541 | + foreach ( $styles as $key => $val ) { |
|
| 2542 | + $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 2543 | + } |
|
| 2544 | + } |
|
| 2545 | + |
|
| 2546 | + return $style_string; |
|
| 2547 | 2547 | |
| 2548 | 2548 | } |
| 2549 | 2549 | |
@@ -2556,34 +2556,34 @@ discard block |
||
| 2556 | 2556 | * @return string |
| 2557 | 2557 | */ |
| 2558 | 2558 | function sd_build_hover_styles( $args, $is_preview = false ) { |
| 2559 | - $rules = ''; |
|
| 2560 | - // text color |
|
| 2561 | - if ( ! empty( $args['styleid'] ) ) { |
|
| 2562 | - $styleid = $is_preview ? 'html .editor-styles-wrapper .' . esc_attr( $args['styleid'] ) : 'html .' . esc_attr( $args['styleid'] ); |
|
| 2563 | - |
|
| 2564 | - // text |
|
| 2565 | - if ( ! empty( $args['text_color_hover'] ) ) { |
|
| 2566 | - $key = 'custom' === $args['text_color_hover'] && ! empty( $args['text_color_hover_custom'] ) ? 'text_color_hover_custom' : 'text_color_hover'; |
|
| 2567 | - $color = sd_get_color_from_var( $args[ $key ] ); |
|
| 2568 | - $rules .= $styleid . ':hover {color: ' . $color . ' !important;} '; |
|
| 2569 | - } |
|
| 2570 | - |
|
| 2571 | - // bg |
|
| 2572 | - if ( ! empty( $args['bg_hover'] ) ) { |
|
| 2573 | - if ( 'custom-gradient' === $args['bg_hover'] ) { |
|
| 2574 | - $color = $args['bg_hover_gradient']; |
|
| 2575 | - $rules .= $styleid . ':hover {background-image: ' . $color . ' !important;} '; |
|
| 2576 | - $rules .= $styleid . '.btn:hover {border-color: transparent !important;} '; |
|
| 2577 | - } else { |
|
| 2578 | - $key = 'custom-color' === $args['bg_hover'] ? 'bg_hover_color' : 'bg_hover'; |
|
| 2579 | - $color = sd_get_color_from_var( $args[ $key ] ); |
|
| 2580 | - $rules .= $styleid . ':hover {background: ' . $color . ' !important;} '; |
|
| 2581 | - $rules .= $styleid . '.btn:hover {border-color: ' . $color . ' !important;} '; |
|
| 2582 | - } |
|
| 2583 | - } |
|
| 2584 | - } |
|
| 2585 | - |
|
| 2586 | - return $rules ? '<style>' . $rules . '</style>' : ''; |
|
| 2559 | + $rules = ''; |
|
| 2560 | + // text color |
|
| 2561 | + if ( ! empty( $args['styleid'] ) ) { |
|
| 2562 | + $styleid = $is_preview ? 'html .editor-styles-wrapper .' . esc_attr( $args['styleid'] ) : 'html .' . esc_attr( $args['styleid'] ); |
|
| 2563 | + |
|
| 2564 | + // text |
|
| 2565 | + if ( ! empty( $args['text_color_hover'] ) ) { |
|
| 2566 | + $key = 'custom' === $args['text_color_hover'] && ! empty( $args['text_color_hover_custom'] ) ? 'text_color_hover_custom' : 'text_color_hover'; |
|
| 2567 | + $color = sd_get_color_from_var( $args[ $key ] ); |
|
| 2568 | + $rules .= $styleid . ':hover {color: ' . $color . ' !important;} '; |
|
| 2569 | + } |
|
| 2570 | + |
|
| 2571 | + // bg |
|
| 2572 | + if ( ! empty( $args['bg_hover'] ) ) { |
|
| 2573 | + if ( 'custom-gradient' === $args['bg_hover'] ) { |
|
| 2574 | + $color = $args['bg_hover_gradient']; |
|
| 2575 | + $rules .= $styleid . ':hover {background-image: ' . $color . ' !important;} '; |
|
| 2576 | + $rules .= $styleid . '.btn:hover {border-color: transparent !important;} '; |
|
| 2577 | + } else { |
|
| 2578 | + $key = 'custom-color' === $args['bg_hover'] ? 'bg_hover_color' : 'bg_hover'; |
|
| 2579 | + $color = sd_get_color_from_var( $args[ $key ] ); |
|
| 2580 | + $rules .= $styleid . ':hover {background: ' . $color . ' !important;} '; |
|
| 2581 | + $rules .= $styleid . '.btn:hover {border-color: ' . $color . ' !important;} '; |
|
| 2582 | + } |
|
| 2583 | + } |
|
| 2584 | + } |
|
| 2585 | + |
|
| 2586 | + return $rules ? '<style>' . $rules . '</style>' : ''; |
|
| 2587 | 2587 | } |
| 2588 | 2588 | |
| 2589 | 2589 | /** |
@@ -2595,12 +2595,12 @@ discard block |
||
| 2595 | 2595 | */ |
| 2596 | 2596 | function sd_get_color_from_var( $var ) { |
| 2597 | 2597 | |
| 2598 | - //sanitize_hex_color() @todo this does not cover transparency |
|
| 2599 | - if ( strpos( $var, '#' ) === false ) { |
|
| 2600 | - $var = defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ? 'var(--wp--preset--color--' . esc_attr( $var ) . ')' : 'var(--' . esc_attr( $var ) . ')'; |
|
| 2601 | - } |
|
| 2598 | + //sanitize_hex_color() @todo this does not cover transparency |
|
| 2599 | + if ( strpos( $var, '#' ) === false ) { |
|
| 2600 | + $var = defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ? 'var(--wp--preset--color--' . esc_attr( $var ) . ')' : 'var(--' . esc_attr( $var ) . ')'; |
|
| 2601 | + } |
|
| 2602 | 2602 | |
| 2603 | - return $var; |
|
| 2603 | + return $var; |
|
| 2604 | 2604 | } |
| 2605 | 2605 | |
| 2606 | 2606 | /** |
@@ -2612,19 +2612,19 @@ discard block |
||
| 2612 | 2612 | * @return string |
| 2613 | 2613 | */ |
| 2614 | 2614 | function sd_sanitize_html_classes( $classes, $sep = ' ' ) { |
| 2615 | - $return = ''; |
|
| 2615 | + $return = ''; |
|
| 2616 | 2616 | |
| 2617 | - if ( ! is_array( $classes ) ) { |
|
| 2618 | - $classes = explode( $sep, $classes ); |
|
| 2619 | - } |
|
| 2617 | + if ( ! is_array( $classes ) ) { |
|
| 2618 | + $classes = explode( $sep, $classes ); |
|
| 2619 | + } |
|
| 2620 | 2620 | |
| 2621 | - if ( ! empty( $classes ) ) { |
|
| 2622 | - foreach ( $classes as $class ) { |
|
| 2623 | - $return .= sanitize_html_class( $class ) . ' '; |
|
| 2624 | - } |
|
| 2625 | - } |
|
| 2621 | + if ( ! empty( $classes ) ) { |
|
| 2622 | + foreach ( $classes as $class ) { |
|
| 2623 | + $return .= sanitize_html_class( $class ) . ' '; |
|
| 2624 | + } |
|
| 2625 | + } |
|
| 2626 | 2626 | |
| 2627 | - return $return; |
|
| 2627 | + return $return; |
|
| 2628 | 2628 | } |
| 2629 | 2629 | |
| 2630 | 2630 | |
@@ -2634,38 +2634,38 @@ discard block |
||
| 2634 | 2634 | * @return void |
| 2635 | 2635 | */ |
| 2636 | 2636 | function sd_get_class_build_keys() { |
| 2637 | - $keys = array( |
|
| 2638 | - 'container', |
|
| 2639 | - 'position', |
|
| 2640 | - 'flex_direction', |
|
| 2641 | - 'shadow', |
|
| 2642 | - 'rounded', |
|
| 2643 | - 'nav_style', |
|
| 2644 | - 'horizontal_alignment', |
|
| 2645 | - 'nav_fill', |
|
| 2646 | - 'width', |
|
| 2647 | - 'font_weight', |
|
| 2648 | - 'font_size', |
|
| 2649 | - 'font_case', |
|
| 2650 | - 'css_class', |
|
| 2651 | - 'flex_align_items-MTD', |
|
| 2652 | - 'flex_justify_content-MTD', |
|
| 2653 | - 'flex_align_self-MTD', |
|
| 2654 | - 'flex_order-MTD', |
|
| 2655 | - 'styleid', |
|
| 2656 | - 'border_opacity', |
|
| 2657 | - 'border_width', |
|
| 2658 | - 'border_type', |
|
| 2659 | - 'opacity', |
|
| 2660 | - 'zindex', |
|
| 2661 | - 'flex_wrap-MTD', |
|
| 2662 | - 'h100', |
|
| 2663 | - 'overflow', |
|
| 2664 | - 'scrollbars', |
|
| 2665 | - 'float-MTD' |
|
| 2666 | - ); |
|
| 2667 | - |
|
| 2668 | - return apply_filters( 'sd_class_build_keys', $keys ); |
|
| 2637 | + $keys = array( |
|
| 2638 | + 'container', |
|
| 2639 | + 'position', |
|
| 2640 | + 'flex_direction', |
|
| 2641 | + 'shadow', |
|
| 2642 | + 'rounded', |
|
| 2643 | + 'nav_style', |
|
| 2644 | + 'horizontal_alignment', |
|
| 2645 | + 'nav_fill', |
|
| 2646 | + 'width', |
|
| 2647 | + 'font_weight', |
|
| 2648 | + 'font_size', |
|
| 2649 | + 'font_case', |
|
| 2650 | + 'css_class', |
|
| 2651 | + 'flex_align_items-MTD', |
|
| 2652 | + 'flex_justify_content-MTD', |
|
| 2653 | + 'flex_align_self-MTD', |
|
| 2654 | + 'flex_order-MTD', |
|
| 2655 | + 'styleid', |
|
| 2656 | + 'border_opacity', |
|
| 2657 | + 'border_width', |
|
| 2658 | + 'border_type', |
|
| 2659 | + 'opacity', |
|
| 2660 | + 'zindex', |
|
| 2661 | + 'flex_wrap-MTD', |
|
| 2662 | + 'h100', |
|
| 2663 | + 'overflow', |
|
| 2664 | + 'scrollbars', |
|
| 2665 | + 'float-MTD' |
|
| 2666 | + ); |
|
| 2667 | + |
|
| 2668 | + return apply_filters( 'sd_class_build_keys', $keys ); |
|
| 2669 | 2669 | } |
| 2670 | 2670 | |
| 2671 | 2671 | /** |
@@ -2677,18 +2677,18 @@ discard block |
||
| 2677 | 2677 | * @return array |
| 2678 | 2678 | */ |
| 2679 | 2679 | function sd_get_visibility_conditions_input( $type = 'visibility_conditions', $overwrite = array() ) { |
| 2680 | - $defaults = array( |
|
| 2681 | - 'type' => 'visibility_conditions', |
|
| 2682 | - 'title' => __( 'Block Visibility', 'super-duper' ), |
|
| 2683 | - 'button_title' => __( 'Set Block Visibility', 'super-duper' ), |
|
| 2684 | - 'default' => '', |
|
| 2685 | - 'desc_tip' => true, |
|
| 2686 | - 'group' => __( 'Visibility Conditions', 'super-duper' ), |
|
| 2687 | - ); |
|
| 2680 | + $defaults = array( |
|
| 2681 | + 'type' => 'visibility_conditions', |
|
| 2682 | + 'title' => __( 'Block Visibility', 'super-duper' ), |
|
| 2683 | + 'button_title' => __( 'Set Block Visibility', 'super-duper' ), |
|
| 2684 | + 'default' => '', |
|
| 2685 | + 'desc_tip' => true, |
|
| 2686 | + 'group' => __( 'Visibility Conditions', 'super-duper' ), |
|
| 2687 | + ); |
|
| 2688 | 2688 | |
| 2689 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2689 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 2690 | 2690 | |
| 2691 | - return $input; |
|
| 2691 | + return $input; |
|
| 2692 | 2692 | } |
| 2693 | 2693 | |
| 2694 | 2694 | /** |
@@ -2700,21 +2700,21 @@ discard block |
||
| 2700 | 2700 | * @return array An array of roles. |
| 2701 | 2701 | */ |
| 2702 | 2702 | function sd_user_roles_options( $exclude = array() ) { |
| 2703 | - $user_roles = array(); |
|
| 2703 | + $user_roles = array(); |
|
| 2704 | 2704 | |
| 2705 | - if ( !function_exists('get_editable_roles') ) { |
|
| 2706 | - require_once( ABSPATH . '/wp-admin/includes/user.php' ); |
|
| 2707 | - } |
|
| 2705 | + if ( !function_exists('get_editable_roles') ) { |
|
| 2706 | + require_once( ABSPATH . '/wp-admin/includes/user.php' ); |
|
| 2707 | + } |
|
| 2708 | 2708 | |
| 2709 | - $roles = get_editable_roles(); |
|
| 2709 | + $roles = get_editable_roles(); |
|
| 2710 | 2710 | |
| 2711 | - foreach ( $roles as $role => $data ) { |
|
| 2712 | - if ( ! ( ! empty( $exclude ) && in_array( $role, $exclude ) ) ) { |
|
| 2713 | - $user_roles[ esc_attr( $role ) ] = translate_user_role( $data['name'] ); |
|
| 2714 | - } |
|
| 2715 | - } |
|
| 2711 | + foreach ( $roles as $role => $data ) { |
|
| 2712 | + if ( ! ( ! empty( $exclude ) && in_array( $role, $exclude ) ) ) { |
|
| 2713 | + $user_roles[ esc_attr( $role ) ] = translate_user_role( $data['name'] ); |
|
| 2714 | + } |
|
| 2715 | + } |
|
| 2716 | 2716 | |
| 2717 | - return apply_filters( 'sd_user_roles_options', $user_roles ); |
|
| 2717 | + return apply_filters( 'sd_user_roles_options', $user_roles ); |
|
| 2718 | 2718 | } |
| 2719 | 2719 | |
| 2720 | 2720 | /** |
@@ -2725,17 +2725,17 @@ discard block |
||
| 2725 | 2725 | * @return array Rule options. |
| 2726 | 2726 | */ |
| 2727 | 2727 | function sd_visibility_rules_options() { |
| 2728 | - $options = array( |
|
| 2729 | - 'logged_in' => __( 'Logged In', 'super-duper' ), |
|
| 2730 | - 'logged_out' => __( 'Logged Out', 'super-duper' ), |
|
| 2731 | - 'user_roles' => __( 'Specific User Roles', 'super-duper' ) |
|
| 2732 | - ); |
|
| 2728 | + $options = array( |
|
| 2729 | + 'logged_in' => __( 'Logged In', 'super-duper' ), |
|
| 2730 | + 'logged_out' => __( 'Logged Out', 'super-duper' ), |
|
| 2731 | + 'user_roles' => __( 'Specific User Roles', 'super-duper' ) |
|
| 2732 | + ); |
|
| 2733 | 2733 | |
| 2734 | - if ( class_exists( 'GeoDirectory' ) ) { |
|
| 2735 | - $options['gd_field'] = __( 'GD Field', 'super-duper' ); |
|
| 2736 | - } |
|
| 2734 | + if ( class_exists( 'GeoDirectory' ) ) { |
|
| 2735 | + $options['gd_field'] = __( 'GD Field', 'super-duper' ); |
|
| 2736 | + } |
|
| 2737 | 2737 | |
| 2738 | - return apply_filters( 'sd_visibility_rules_options', $options ); |
|
| 2738 | + return apply_filters( 'sd_visibility_rules_options', $options ); |
|
| 2739 | 2739 | } |
| 2740 | 2740 | |
| 2741 | 2741 | /** |
@@ -2744,37 +2744,37 @@ discard block |
||
| 2744 | 2744 | * @return array |
| 2745 | 2745 | */ |
| 2746 | 2746 | function sd_visibility_gd_field_options(){ |
| 2747 | - $fields = geodir_post_custom_fields( '', 'all', 'all', 'none' ); |
|
| 2747 | + $fields = geodir_post_custom_fields( '', 'all', 'all', 'none' ); |
|
| 2748 | 2748 | |
| 2749 | - $keys = array(); |
|
| 2750 | - if ( ! empty( $fields ) ) { |
|
| 2751 | - foreach( $fields as $field ) { |
|
| 2752 | - if ( apply_filters( 'geodir_badge_field_skip_key', false, $field ) ) { |
|
| 2753 | - continue; |
|
| 2754 | - } |
|
| 2749 | + $keys = array(); |
|
| 2750 | + if ( ! empty( $fields ) ) { |
|
| 2751 | + foreach( $fields as $field ) { |
|
| 2752 | + if ( apply_filters( 'geodir_badge_field_skip_key', false, $field ) ) { |
|
| 2753 | + continue; |
|
| 2754 | + } |
|
| 2755 | 2755 | |
| 2756 | - $keys[ $field['htmlvar_name'] ] = $field['htmlvar_name'] . ' ( ' . __( $field['admin_title'], 'geodirectory' ) . ' )'; |
|
| 2756 | + $keys[ $field['htmlvar_name'] ] = $field['htmlvar_name'] . ' ( ' . __( $field['admin_title'], 'geodirectory' ) . ' )'; |
|
| 2757 | 2757 | |
| 2758 | - // Extra address fields |
|
| 2759 | - if ( $field['htmlvar_name'] == 'address' && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
| 2760 | - foreach ( $address_fields as $_field => $args ) { |
|
| 2761 | - if ( $_field != 'map_directions' && $_field != 'street' ) { |
|
| 2762 | - $keys[ $_field ] = $_field . ' ( ' . $args['frontend_title'] . ' )'; |
|
| 2763 | - } |
|
| 2764 | - } |
|
| 2765 | - } |
|
| 2766 | - } |
|
| 2767 | - } |
|
| 2758 | + // Extra address fields |
|
| 2759 | + if ( $field['htmlvar_name'] == 'address' && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
| 2760 | + foreach ( $address_fields as $_field => $args ) { |
|
| 2761 | + if ( $_field != 'map_directions' && $_field != 'street' ) { |
|
| 2762 | + $keys[ $_field ] = $_field . ' ( ' . $args['frontend_title'] . ' )'; |
|
| 2763 | + } |
|
| 2764 | + } |
|
| 2765 | + } |
|
| 2766 | + } |
|
| 2767 | + } |
|
| 2768 | 2768 | |
| 2769 | - $keys['post_date'] = 'post_date ( ' . __( 'post date', 'geodirectory' ) . ' )'; |
|
| 2770 | - $keys['post_modified'] = 'post_modified ( ' . __( 'post modified', 'geodirectory' ) . ' )'; |
|
| 2771 | - $keys['default_category'] = 'default_category ( ' . __( 'Default Category', 'geodirectory' ) . ' )'; |
|
| 2772 | - $keys['post_id'] = 'post_id ( ' . __( 'post id', 'geodirectory' ) . ' )'; |
|
| 2773 | - $keys['post_status'] = 'post_status ( ' . __( 'Post Status', 'geodirectory' ) . ' )'; |
|
| 2769 | + $keys['post_date'] = 'post_date ( ' . __( 'post date', 'geodirectory' ) . ' )'; |
|
| 2770 | + $keys['post_modified'] = 'post_modified ( ' . __( 'post modified', 'geodirectory' ) . ' )'; |
|
| 2771 | + $keys['default_category'] = 'default_category ( ' . __( 'Default Category', 'geodirectory' ) . ' )'; |
|
| 2772 | + $keys['post_id'] = 'post_id ( ' . __( 'post id', 'geodirectory' ) . ' )'; |
|
| 2773 | + $keys['post_status'] = 'post_status ( ' . __( 'Post Status', 'geodirectory' ) . ' )'; |
|
| 2774 | 2774 | |
| 2775 | - $options = apply_filters( 'geodir_badge_field_keys', $keys ); |
|
| 2775 | + $options = apply_filters( 'geodir_badge_field_keys', $keys ); |
|
| 2776 | 2776 | |
| 2777 | - return apply_filters( 'sd_visibility_gd_field_options', $options ); |
|
| 2777 | + return apply_filters( 'sd_visibility_gd_field_options', $options ); |
|
| 2778 | 2778 | } |
| 2779 | 2779 | |
| 2780 | 2780 | /** |
@@ -2783,18 +2783,18 @@ discard block |
||
| 2783 | 2783 | * @return array |
| 2784 | 2784 | */ |
| 2785 | 2785 | function sd_visibility_field_condition_options(){ |
| 2786 | - $options = array( |
|
| 2787 | - 'is_empty' => __( 'is empty', 'super-duper' ), |
|
| 2788 | - 'is_not_empty' => __( 'is not empty', 'super-duper' ), |
|
| 2789 | - 'is_equal' => __( 'is equal', 'super-duper' ), |
|
| 2790 | - 'is_not_equal' => __( 'is not equal', 'super-duper' ), |
|
| 2791 | - 'is_greater_than' => __( 'is greater than', 'super-duper' ), |
|
| 2792 | - 'is_less_than' => __( 'is less than', 'super-duper' ), |
|
| 2793 | - 'is_contains' => __( 'is contains', 'super-duper' ), |
|
| 2794 | - 'is_not_contains' => __( 'is not contains', 'super-duper' ), |
|
| 2795 | - ); |
|
| 2786 | + $options = array( |
|
| 2787 | + 'is_empty' => __( 'is empty', 'super-duper' ), |
|
| 2788 | + 'is_not_empty' => __( 'is not empty', 'super-duper' ), |
|
| 2789 | + 'is_equal' => __( 'is equal', 'super-duper' ), |
|
| 2790 | + 'is_not_equal' => __( 'is not equal', 'super-duper' ), |
|
| 2791 | + 'is_greater_than' => __( 'is greater than', 'super-duper' ), |
|
| 2792 | + 'is_less_than' => __( 'is less than', 'super-duper' ), |
|
| 2793 | + 'is_contains' => __( 'is contains', 'super-duper' ), |
|
| 2794 | + 'is_not_contains' => __( 'is not contains', 'super-duper' ), |
|
| 2795 | + ); |
|
| 2796 | 2796 | |
| 2797 | - return apply_filters( 'sd_visibility_field_condition_options', $options ); |
|
| 2797 | + return apply_filters( 'sd_visibility_field_condition_options', $options ); |
|
| 2798 | 2798 | } |
| 2799 | 2799 | |
| 2800 | 2800 | /** |
@@ -2805,14 +2805,14 @@ discard block |
||
| 2805 | 2805 | * @return array Template type options. |
| 2806 | 2806 | */ |
| 2807 | 2807 | function sd_visibility_output_options() { |
| 2808 | - $options = array( |
|
| 2809 | - 'hide' => __( 'Hide Block', 'super-duper' ), |
|
| 2810 | - 'message' => __( 'Show Custom Message', 'super-duper' ), |
|
| 2811 | - 'page' => __( 'Show Page Content', 'super-duper' ), |
|
| 2812 | - 'template_part' => __( 'Show Template Part', 'super-duper' ), |
|
| 2813 | - ); |
|
| 2808 | + $options = array( |
|
| 2809 | + 'hide' => __( 'Hide Block', 'super-duper' ), |
|
| 2810 | + 'message' => __( 'Show Custom Message', 'super-duper' ), |
|
| 2811 | + 'page' => __( 'Show Page Content', 'super-duper' ), |
|
| 2812 | + 'template_part' => __( 'Show Template Part', 'super-duper' ), |
|
| 2813 | + ); |
|
| 2814 | 2814 | |
| 2815 | - return apply_filters( 'sd_visibility_output_options', $options ); |
|
| 2815 | + return apply_filters( 'sd_visibility_output_options', $options ); |
|
| 2816 | 2816 | } |
| 2817 | 2817 | |
| 2818 | 2818 | /** |
@@ -2824,45 +2824,45 @@ discard block |
||
| 2824 | 2824 | * @return array Template page options. |
| 2825 | 2825 | */ |
| 2826 | 2826 | function sd_template_page_options( $args = array() ) { |
| 2827 | - global $sd_tmpl_page_options; |
|
| 2827 | + global $sd_tmpl_page_options; |
|
| 2828 | 2828 | |
| 2829 | - if ( ! empty( $sd_tmpl_page_options ) ) { |
|
| 2830 | - return $sd_tmpl_page_options; |
|
| 2831 | - } |
|
| 2829 | + if ( ! empty( $sd_tmpl_page_options ) ) { |
|
| 2830 | + return $sd_tmpl_page_options; |
|
| 2831 | + } |
|
| 2832 | 2832 | |
| 2833 | - $args = wp_parse_args( $args, array( |
|
| 2834 | - 'child_of' => 0, |
|
| 2835 | - 'sort_column' => 'post_title', |
|
| 2836 | - 'sort_order' => 'ASC' |
|
| 2837 | - ) ); |
|
| 2833 | + $args = wp_parse_args( $args, array( |
|
| 2834 | + 'child_of' => 0, |
|
| 2835 | + 'sort_column' => 'post_title', |
|
| 2836 | + 'sort_order' => 'ASC' |
|
| 2837 | + ) ); |
|
| 2838 | 2838 | |
| 2839 | - $exclude_pages = array(); |
|
| 2840 | - if ( $page_on_front = get_option( 'page_on_front' ) ) { |
|
| 2841 | - $exclude_pages[] = $page_on_front; |
|
| 2842 | - } |
|
| 2839 | + $exclude_pages = array(); |
|
| 2840 | + if ( $page_on_front = get_option( 'page_on_front' ) ) { |
|
| 2841 | + $exclude_pages[] = $page_on_front; |
|
| 2842 | + } |
|
| 2843 | 2843 | |
| 2844 | - if ( $page_for_posts = get_option( 'page_for_posts' ) ) { |
|
| 2845 | - $exclude_pages[] = $page_for_posts; |
|
| 2846 | - } |
|
| 2844 | + if ( $page_for_posts = get_option( 'page_for_posts' ) ) { |
|
| 2845 | + $exclude_pages[] = $page_for_posts; |
|
| 2846 | + } |
|
| 2847 | 2847 | |
| 2848 | - if ( ! empty( $exclude_pages ) ) { |
|
| 2849 | - $args['exclude'] = $exclude_pages; |
|
| 2850 | - } |
|
| 2848 | + if ( ! empty( $exclude_pages ) ) { |
|
| 2849 | + $args['exclude'] = $exclude_pages; |
|
| 2850 | + } |
|
| 2851 | 2851 | |
| 2852 | - $pages = get_pages( $args ); |
|
| 2852 | + $pages = get_pages( $args ); |
|
| 2853 | 2853 | |
| 2854 | - $options = array( '' => __( 'Select Page...', 'super-duper' ) ); |
|
| 2855 | - if ( ! empty( $pages ) ) { |
|
| 2856 | - foreach ( $pages as $page ) { |
|
| 2857 | - if ( ! empty( $page->ID ) && ! empty( $page->post_title ) ) { |
|
| 2858 | - $options[ $page->ID ] = $page->post_title . ' (#' . $page->ID . ')'; |
|
| 2859 | - } |
|
| 2860 | - } |
|
| 2861 | - } |
|
| 2854 | + $options = array( '' => __( 'Select Page...', 'super-duper' ) ); |
|
| 2855 | + if ( ! empty( $pages ) ) { |
|
| 2856 | + foreach ( $pages as $page ) { |
|
| 2857 | + if ( ! empty( $page->ID ) && ! empty( $page->post_title ) ) { |
|
| 2858 | + $options[ $page->ID ] = $page->post_title . ' (#' . $page->ID . ')'; |
|
| 2859 | + } |
|
| 2860 | + } |
|
| 2861 | + } |
|
| 2862 | 2862 | |
| 2863 | - $sd_tmpl_page_options = $options; |
|
| 2863 | + $sd_tmpl_page_options = $options; |
|
| 2864 | 2864 | |
| 2865 | - return apply_filters( 'sd_template_page_options', $options ); |
|
| 2865 | + return apply_filters( 'sd_template_page_options', $options ); |
|
| 2866 | 2866 | } |
| 2867 | 2867 | |
| 2868 | 2868 | /** |
@@ -2874,25 +2874,25 @@ discard block |
||
| 2874 | 2874 | * @return array Template part options. |
| 2875 | 2875 | */ |
| 2876 | 2876 | function sd_template_part_options( $args = array() ) { |
| 2877 | - global $sd_tmpl_part_options; |
|
| 2877 | + global $sd_tmpl_part_options; |
|
| 2878 | 2878 | |
| 2879 | - if ( ! empty( $sd_tmpl_part_options ) ) { |
|
| 2880 | - return $sd_tmpl_part_options; |
|
| 2881 | - } |
|
| 2879 | + if ( ! empty( $sd_tmpl_part_options ) ) { |
|
| 2880 | + return $sd_tmpl_part_options; |
|
| 2881 | + } |
|
| 2882 | 2882 | |
| 2883 | - $options = array( '' => __( 'Select Template Part...', 'super-duper' ) ); |
|
| 2883 | + $options = array( '' => __( 'Select Template Part...', 'super-duper' ) ); |
|
| 2884 | 2884 | |
| 2885 | - $parts = get_block_templates( array(), 'wp_template_part' ); |
|
| 2885 | + $parts = get_block_templates( array(), 'wp_template_part' ); |
|
| 2886 | 2886 | |
| 2887 | - if ( ! empty( $parts ) ) { |
|
| 2888 | - foreach ( $parts as $part ) { |
|
| 2889 | - $options[ $part->slug ] = $part->title . ' (#' . $part->slug . ')'; |
|
| 2890 | - } |
|
| 2891 | - } |
|
| 2887 | + if ( ! empty( $parts ) ) { |
|
| 2888 | + foreach ( $parts as $part ) { |
|
| 2889 | + $options[ $part->slug ] = $part->title . ' (#' . $part->slug . ')'; |
|
| 2890 | + } |
|
| 2891 | + } |
|
| 2892 | 2892 | |
| 2893 | - $sd_tmpl_part_options = $options; |
|
| 2893 | + $sd_tmpl_part_options = $options; |
|
| 2894 | 2894 | |
| 2895 | - return apply_filters( 'sd_template_part_options', $options, $args ); |
|
| 2895 | + return apply_filters( 'sd_template_part_options', $options, $args ); |
|
| 2896 | 2896 | } |
| 2897 | 2897 | |
| 2898 | 2898 | /** |
@@ -2904,25 +2904,25 @@ discard block |
||
| 2904 | 2904 | * @return array Template part object. |
| 2905 | 2905 | */ |
| 2906 | 2906 | function sd_get_template_part_by_slug( $slug ) { |
| 2907 | - global $bs_tmpl_part_by_slug; |
|
| 2907 | + global $bs_tmpl_part_by_slug; |
|
| 2908 | 2908 | |
| 2909 | - if ( empty( $bs_tmpl_part_by_slug ) ) { |
|
| 2910 | - $bs_tmpl_part_by_slug = array(); |
|
| 2911 | - } |
|
| 2909 | + if ( empty( $bs_tmpl_part_by_slug ) ) { |
|
| 2910 | + $bs_tmpl_part_by_slug = array(); |
|
| 2911 | + } |
|
| 2912 | 2912 | |
| 2913 | - if ( isset( $bs_tmpl_part_by_slug[ $slug ] ) ) { |
|
| 2914 | - return $bs_tmpl_part_by_slug[ $slug ]; |
|
| 2915 | - } |
|
| 2913 | + if ( isset( $bs_tmpl_part_by_slug[ $slug ] ) ) { |
|
| 2914 | + return $bs_tmpl_part_by_slug[ $slug ]; |
|
| 2915 | + } |
|
| 2916 | 2916 | |
| 2917 | - $template_query = get_block_templates( array( 'slug__in' => array( $slug ) ), 'wp_template_part' ); |
|
| 2917 | + $template_query = get_block_templates( array( 'slug__in' => array( $slug ) ), 'wp_template_part' ); |
|
| 2918 | 2918 | |
| 2919 | - $query_post = ! empty( $template_query ) ? $template_query[0] : array(); |
|
| 2919 | + $query_post = ! empty( $template_query ) ? $template_query[0] : array(); |
|
| 2920 | 2920 | |
| 2921 | - $template_part = ! empty( $query_post ) && $query_post->status == 'publish' ? $query_post : array(); |
|
| 2921 | + $template_part = ! empty( $query_post ) && $query_post->status == 'publish' ? $query_post : array(); |
|
| 2922 | 2922 | |
| 2923 | - $bs_tmpl_part_by_slug[ $slug ] = $template_part; |
|
| 2923 | + $bs_tmpl_part_by_slug[ $slug ] = $template_part; |
|
| 2924 | 2924 | |
| 2925 | - return apply_filters( 'sd_get_template_part_by_slug', $template_part, $slug ); |
|
| 2925 | + return apply_filters( 'sd_get_template_part_by_slug', $template_part, $slug ); |
|
| 2926 | 2926 | } |
| 2927 | 2927 | |
| 2928 | 2928 | /** |
@@ -2935,364 +2935,364 @@ discard block |
||
| 2935 | 2935 | * @param WP_Block $instance The block instance. |
| 2936 | 2936 | */ |
| 2937 | 2937 | function sd_render_block( $block_content, $block, $instance = '' ) { |
| 2938 | - // No block visibility conditions set. |
|
| 2939 | - if ( empty( $block['attrs']['visibility_conditions'] ) ) { |
|
| 2940 | - return $block_content; |
|
| 2941 | - } |
|
| 2942 | - |
|
| 2943 | - $attributes = json_decode( $block['attrs']['visibility_conditions'], true ); |
|
| 2944 | - $rules = ! empty( $attributes ) ? sd_block_parse_rules( $attributes ) : array(); |
|
| 2945 | - |
|
| 2946 | - // No rules set. |
|
| 2947 | - if ( empty( $rules ) ) { |
|
| 2948 | - return $block_content; |
|
| 2949 | - } |
|
| 2950 | - |
|
| 2951 | - $_block_content = $block_content; |
|
| 2952 | - |
|
| 2953 | - if ( ! empty( $rules ) && sd_block_check_rules( $rules ) ) { |
|
| 2954 | - if ( ! empty( $attributes['output']['type'] ) ) { |
|
| 2955 | - switch ( $attributes['output']['type'] ) { |
|
| 2956 | - case 'hide': |
|
| 2957 | - $valid_type = true; |
|
| 2958 | - $content = ''; |
|
| 2959 | - |
|
| 2960 | - break; |
|
| 2961 | - case 'message': |
|
| 2962 | - $valid_type = true; |
|
| 2963 | - |
|
| 2964 | - if ( isset( $attributes['output']['message'] ) ) { |
|
| 2965 | - $content = $attributes['output']['message'] != '' ? __( stripslashes( $attributes['output']['message'] ), 'super-duper' ) : $attributes['output']['message']; |
|
| 2966 | - |
|
| 2967 | - if ( ! empty( $attributes['output']['message_type'] ) ) { |
|
| 2968 | - $content = aui()->alert( array( |
|
| 2969 | - 'type'=> $attributes['output']['message_type'], |
|
| 2970 | - 'content'=> $content |
|
| 2971 | - ) |
|
| 2972 | - ); |
|
| 2973 | - } |
|
| 2974 | - } |
|
| 2975 | - |
|
| 2976 | - break; |
|
| 2977 | - case 'page': |
|
| 2978 | - $valid_type = true; |
|
| 2979 | - |
|
| 2980 | - $page_id = ! empty( $attributes['output']['page'] ) ? absint( $attributes['output']['page'] ) : 0; |
|
| 2981 | - $content = sd_get_page_content( $page_id ); |
|
| 2982 | - |
|
| 2983 | - break; |
|
| 2984 | - case 'template_part': |
|
| 2985 | - $valid_type = true; |
|
| 2986 | - |
|
| 2987 | - $template_part = ! empty( $attributes['output']['template_part'] ) ? $attributes['output']['template_part'] : ''; |
|
| 2988 | - $content = sd_get_template_part_content( $template_part ); |
|
| 2989 | - |
|
| 2990 | - break; |
|
| 2991 | - default: |
|
| 2992 | - $valid_type = false; |
|
| 2993 | - break; |
|
| 2994 | - } |
|
| 2995 | - |
|
| 2996 | - if ( $valid_type ) { |
|
| 2997 | - $block_content = '<div class="' . esc_attr( wp_get_block_default_classname( $instance->name ) ) . ' sd-block-has-rule">' . $content . '</div>'; |
|
| 2998 | - } |
|
| 2999 | - } |
|
| 3000 | - } |
|
| 3001 | - |
|
| 3002 | - return apply_filters( 'sd_render_block_visibility_content', $block_content, $_block_content, $attributes, $block, $instance ); |
|
| 2938 | + // No block visibility conditions set. |
|
| 2939 | + if ( empty( $block['attrs']['visibility_conditions'] ) ) { |
|
| 2940 | + return $block_content; |
|
| 2941 | + } |
|
| 2942 | + |
|
| 2943 | + $attributes = json_decode( $block['attrs']['visibility_conditions'], true ); |
|
| 2944 | + $rules = ! empty( $attributes ) ? sd_block_parse_rules( $attributes ) : array(); |
|
| 2945 | + |
|
| 2946 | + // No rules set. |
|
| 2947 | + if ( empty( $rules ) ) { |
|
| 2948 | + return $block_content; |
|
| 2949 | + } |
|
| 2950 | + |
|
| 2951 | + $_block_content = $block_content; |
|
| 2952 | + |
|
| 2953 | + if ( ! empty( $rules ) && sd_block_check_rules( $rules ) ) { |
|
| 2954 | + if ( ! empty( $attributes['output']['type'] ) ) { |
|
| 2955 | + switch ( $attributes['output']['type'] ) { |
|
| 2956 | + case 'hide': |
|
| 2957 | + $valid_type = true; |
|
| 2958 | + $content = ''; |
|
| 2959 | + |
|
| 2960 | + break; |
|
| 2961 | + case 'message': |
|
| 2962 | + $valid_type = true; |
|
| 2963 | + |
|
| 2964 | + if ( isset( $attributes['output']['message'] ) ) { |
|
| 2965 | + $content = $attributes['output']['message'] != '' ? __( stripslashes( $attributes['output']['message'] ), 'super-duper' ) : $attributes['output']['message']; |
|
| 2966 | + |
|
| 2967 | + if ( ! empty( $attributes['output']['message_type'] ) ) { |
|
| 2968 | + $content = aui()->alert( array( |
|
| 2969 | + 'type'=> $attributes['output']['message_type'], |
|
| 2970 | + 'content'=> $content |
|
| 2971 | + ) |
|
| 2972 | + ); |
|
| 2973 | + } |
|
| 2974 | + } |
|
| 2975 | + |
|
| 2976 | + break; |
|
| 2977 | + case 'page': |
|
| 2978 | + $valid_type = true; |
|
| 2979 | + |
|
| 2980 | + $page_id = ! empty( $attributes['output']['page'] ) ? absint( $attributes['output']['page'] ) : 0; |
|
| 2981 | + $content = sd_get_page_content( $page_id ); |
|
| 2982 | + |
|
| 2983 | + break; |
|
| 2984 | + case 'template_part': |
|
| 2985 | + $valid_type = true; |
|
| 2986 | + |
|
| 2987 | + $template_part = ! empty( $attributes['output']['template_part'] ) ? $attributes['output']['template_part'] : ''; |
|
| 2988 | + $content = sd_get_template_part_content( $template_part ); |
|
| 2989 | + |
|
| 2990 | + break; |
|
| 2991 | + default: |
|
| 2992 | + $valid_type = false; |
|
| 2993 | + break; |
|
| 2994 | + } |
|
| 2995 | + |
|
| 2996 | + if ( $valid_type ) { |
|
| 2997 | + $block_content = '<div class="' . esc_attr( wp_get_block_default_classname( $instance->name ) ) . ' sd-block-has-rule">' . $content . '</div>'; |
|
| 2998 | + } |
|
| 2999 | + } |
|
| 3000 | + } |
|
| 3001 | + |
|
| 3002 | + return apply_filters( 'sd_render_block_visibility_content', $block_content, $_block_content, $attributes, $block, $instance ); |
|
| 3003 | 3003 | } |
| 3004 | 3004 | add_filter( 'render_block', 'sd_render_block', 9, 3 ); |
| 3005 | 3005 | |
| 3006 | 3006 | function sd_get_page_content( $page_id ) { |
| 3007 | - $content = $page_id > 0 ? get_post_field( 'post_content', (int) $page_id ) : ''; |
|
| 3007 | + $content = $page_id > 0 ? get_post_field( 'post_content', (int) $page_id ) : ''; |
|
| 3008 | 3008 | |
| 3009 | - // Maybe bypass content |
|
| 3010 | - $bypass_content = apply_filters( 'sd_bypass_page_content', '', $content, $page_id ); |
|
| 3011 | - if ( $bypass_content ) { |
|
| 3012 | - return $bypass_content; |
|
| 3013 | - } |
|
| 3009 | + // Maybe bypass content |
|
| 3010 | + $bypass_content = apply_filters( 'sd_bypass_page_content', '', $content, $page_id ); |
|
| 3011 | + if ( $bypass_content ) { |
|
| 3012 | + return $bypass_content; |
|
| 3013 | + } |
|
| 3014 | 3014 | |
| 3015 | - // Run the shortcodes on the content. |
|
| 3016 | - $content = do_shortcode( $content ); |
|
| 3015 | + // Run the shortcodes on the content. |
|
| 3016 | + $content = do_shortcode( $content ); |
|
| 3017 | 3017 | |
| 3018 | - // Run block content if its available. |
|
| 3019 | - if ( function_exists( 'do_blocks' ) ) { |
|
| 3020 | - $content = do_blocks( $content ); |
|
| 3021 | - } |
|
| 3018 | + // Run block content if its available. |
|
| 3019 | + if ( function_exists( 'do_blocks' ) ) { |
|
| 3020 | + $content = do_blocks( $content ); |
|
| 3021 | + } |
|
| 3022 | 3022 | |
| 3023 | - return apply_filters( 'sd_get_page_content', $content, $page_id ); |
|
| 3023 | + return apply_filters( 'sd_get_page_content', $content, $page_id ); |
|
| 3024 | 3024 | } |
| 3025 | 3025 | |
| 3026 | 3026 | function sd_get_template_part_content( $template_part ) { |
| 3027 | - $template_part_post = $template_part ? sd_get_template_part_by_slug( $template_part ) : array(); |
|
| 3028 | - $content = ! empty( $template_part_post ) ? $template_part_post->content : ''; |
|
| 3027 | + $template_part_post = $template_part ? sd_get_template_part_by_slug( $template_part ) : array(); |
|
| 3028 | + $content = ! empty( $template_part_post ) ? $template_part_post->content : ''; |
|
| 3029 | 3029 | |
| 3030 | - // Maybe bypass content |
|
| 3031 | - $bypass_content = apply_filters( 'sd_bypass_template_part_content', '', $content, $template_part ); |
|
| 3032 | - if ( $bypass_content ) { |
|
| 3033 | - return $bypass_content; |
|
| 3034 | - } |
|
| 3030 | + // Maybe bypass content |
|
| 3031 | + $bypass_content = apply_filters( 'sd_bypass_template_part_content', '', $content, $template_part ); |
|
| 3032 | + if ( $bypass_content ) { |
|
| 3033 | + return $bypass_content; |
|
| 3034 | + } |
|
| 3035 | 3035 | |
| 3036 | - // Run the shortcodes on the content. |
|
| 3037 | - $content = do_shortcode( $content ); |
|
| 3036 | + // Run the shortcodes on the content. |
|
| 3037 | + $content = do_shortcode( $content ); |
|
| 3038 | 3038 | |
| 3039 | - // Run block content if its available. |
|
| 3040 | - if ( function_exists( 'do_blocks' ) ) { |
|
| 3041 | - $content = do_blocks( $content ); |
|
| 3042 | - } |
|
| 3039 | + // Run block content if its available. |
|
| 3040 | + if ( function_exists( 'do_blocks' ) ) { |
|
| 3041 | + $content = do_blocks( $content ); |
|
| 3042 | + } |
|
| 3043 | 3043 | |
| 3044 | - return apply_filters( 'sd_get_template_part_content', $content, $template_part ); |
|
| 3044 | + return apply_filters( 'sd_get_template_part_content', $content, $template_part ); |
|
| 3045 | 3045 | } |
| 3046 | 3046 | |
| 3047 | 3047 | function sd_block_parse_rules( $attrs ) { |
| 3048 | - $rules = array(); |
|
| 3048 | + $rules = array(); |
|
| 3049 | 3049 | |
| 3050 | - if ( ! empty( $attrs ) && is_array( $attrs ) ) { |
|
| 3051 | - $attrs_keys = array_keys( $attrs ); |
|
| 3050 | + if ( ! empty( $attrs ) && is_array( $attrs ) ) { |
|
| 3051 | + $attrs_keys = array_keys( $attrs ); |
|
| 3052 | 3052 | |
| 3053 | - for ( $i = 1; $i <= count( $attrs_keys ); $i++ ) { |
|
| 3054 | - if ( ! empty( $attrs[ 'rule' . $i ] ) && is_array( $attrs[ 'rule' . $i ] ) ) { |
|
| 3055 | - $rules[] = $attrs[ 'rule' . $i ]; |
|
| 3056 | - } |
|
| 3057 | - } |
|
| 3058 | - } |
|
| 3053 | + for ( $i = 1; $i <= count( $attrs_keys ); $i++ ) { |
|
| 3054 | + if ( ! empty( $attrs[ 'rule' . $i ] ) && is_array( $attrs[ 'rule' . $i ] ) ) { |
|
| 3055 | + $rules[] = $attrs[ 'rule' . $i ]; |
|
| 3056 | + } |
|
| 3057 | + } |
|
| 3058 | + } |
|
| 3059 | 3059 | |
| 3060 | - return apply_filters( 'sd_block_parse_rules', $rules, $attrs ); |
|
| 3060 | + return apply_filters( 'sd_block_parse_rules', $rules, $attrs ); |
|
| 3061 | 3061 | } |
| 3062 | 3062 | |
| 3063 | 3063 | function sd_block_check_rules( $rules ) { |
| 3064 | - if ( ! ( is_array( $rules ) && ! empty( $rules ) ) ) { |
|
| 3065 | - return true; |
|
| 3066 | - } |
|
| 3064 | + if ( ! ( is_array( $rules ) && ! empty( $rules ) ) ) { |
|
| 3065 | + return true; |
|
| 3066 | + } |
|
| 3067 | 3067 | |
| 3068 | - foreach ( $rules as $key => $rule ) { |
|
| 3069 | - $match = apply_filters( 'sd_block_check_rule', true, $rule ); |
|
| 3068 | + foreach ( $rules as $key => $rule ) { |
|
| 3069 | + $match = apply_filters( 'sd_block_check_rule', true, $rule ); |
|
| 3070 | 3070 | |
| 3071 | - if ( ! $match ) { |
|
| 3072 | - break; |
|
| 3073 | - } |
|
| 3074 | - } |
|
| 3071 | + if ( ! $match ) { |
|
| 3072 | + break; |
|
| 3073 | + } |
|
| 3074 | + } |
|
| 3075 | 3075 | |
| 3076 | - return apply_filters( 'sd_block_check_rules', $match, $rules ); |
|
| 3076 | + return apply_filters( 'sd_block_check_rules', $match, $rules ); |
|
| 3077 | 3077 | } |
| 3078 | 3078 | |
| 3079 | 3079 | function sd_block_check_rule( $match, $rule ) { |
| 3080 | - if ( $match && ! empty( $rule['type'] ) ) { |
|
| 3081 | - switch ( $rule['type'] ) { |
|
| 3082 | - case 'logged_in': |
|
| 3083 | - $match = (bool) is_user_logged_in(); |
|
| 3080 | + if ( $match && ! empty( $rule['type'] ) ) { |
|
| 3081 | + switch ( $rule['type'] ) { |
|
| 3082 | + case 'logged_in': |
|
| 3083 | + $match = (bool) is_user_logged_in(); |
|
| 3084 | 3084 | |
| 3085 | - break; |
|
| 3086 | - case 'logged_out': |
|
| 3087 | - $match = ! is_user_logged_in(); |
|
| 3085 | + break; |
|
| 3086 | + case 'logged_out': |
|
| 3087 | + $match = ! is_user_logged_in(); |
|
| 3088 | 3088 | |
| 3089 | - break; |
|
| 3090 | - case 'user_roles': |
|
| 3091 | - $match = false; |
|
| 3089 | + break; |
|
| 3090 | + case 'user_roles': |
|
| 3091 | + $match = false; |
|
| 3092 | 3092 | |
| 3093 | - if ( ! empty( $rule['user_roles'] ) ) { |
|
| 3094 | - $user_roles = is_scalar( $rule['user_roles'] ) ? explode( ",", $rule['user_roles'] ) : $rule['user_roles']; |
|
| 3093 | + if ( ! empty( $rule['user_roles'] ) ) { |
|
| 3094 | + $user_roles = is_scalar( $rule['user_roles'] ) ? explode( ",", $rule['user_roles'] ) : $rule['user_roles']; |
|
| 3095 | 3095 | |
| 3096 | - if ( is_array( $user_roles ) ) { |
|
| 3097 | - $user_roles = array_filter( array_map( 'trim', $user_roles ) ); |
|
| 3098 | - } |
|
| 3096 | + if ( is_array( $user_roles ) ) { |
|
| 3097 | + $user_roles = array_filter( array_map( 'trim', $user_roles ) ); |
|
| 3098 | + } |
|
| 3099 | 3099 | |
| 3100 | - if ( ! empty( $user_roles ) && is_array( $user_roles ) && is_user_logged_in() && ( $current_user = wp_get_current_user() ) ) { |
|
| 3101 | - $current_user_roles = $current_user->roles; |
|
| 3100 | + if ( ! empty( $user_roles ) && is_array( $user_roles ) && is_user_logged_in() && ( $current_user = wp_get_current_user() ) ) { |
|
| 3101 | + $current_user_roles = $current_user->roles; |
|
| 3102 | 3102 | |
| 3103 | - foreach ( $user_roles as $role ) { |
|
| 3104 | - if ( in_array( $role, $current_user_roles ) ) { |
|
| 3105 | - $match = true; |
|
| 3106 | - } |
|
| 3107 | - } |
|
| 3108 | - } |
|
| 3109 | - } |
|
| 3103 | + foreach ( $user_roles as $role ) { |
|
| 3104 | + if ( in_array( $role, $current_user_roles ) ) { |
|
| 3105 | + $match = true; |
|
| 3106 | + } |
|
| 3107 | + } |
|
| 3108 | + } |
|
| 3109 | + } |
|
| 3110 | 3110 | |
| 3111 | - break; |
|
| 3112 | - case 'gd_field': |
|
| 3113 | - $match = sd_block_check_rule_gd_field( $rule ); |
|
| 3111 | + break; |
|
| 3112 | + case 'gd_field': |
|
| 3113 | + $match = sd_block_check_rule_gd_field( $rule ); |
|
| 3114 | 3114 | |
| 3115 | - break; |
|
| 3116 | - } |
|
| 3117 | - } |
|
| 3115 | + break; |
|
| 3116 | + } |
|
| 3117 | + } |
|
| 3118 | 3118 | |
| 3119 | - return $match; |
|
| 3119 | + return $match; |
|
| 3120 | 3120 | } |
| 3121 | 3121 | add_filter( 'sd_block_check_rule', 'sd_block_check_rule', 10, 2 ); |
| 3122 | 3122 | |
| 3123 | 3123 | function sd_block_check_rule_gd_field( $rule ) { |
| 3124 | - global $gd_post; |
|
| 3125 | - |
|
| 3126 | - $match_found = false; |
|
| 3127 | - |
|
| 3128 | - if ( class_exists( 'GeoDirectory' ) && ! empty( $gd_post->ID ) && ! empty( $rule['field'] ) && ! empty( $rule['condition'] ) ) { |
|
| 3129 | - $args['block_visibility'] = true; |
|
| 3130 | - $args['key'] = $rule['field']; |
|
| 3131 | - $args['condition'] = $rule['condition']; |
|
| 3132 | - $args['search'] = isset( $rule['search'] ) ? $rule['search'] : ''; |
|
| 3133 | - |
|
| 3134 | - if ( $args['key'] == 'street' ) { |
|
| 3135 | - $args['key'] = 'address'; |
|
| 3136 | - } |
|
| 3137 | - |
|
| 3138 | - $match_field = $_match_field = $args['key']; |
|
| 3139 | - |
|
| 3140 | - if ( $match_field == 'address' ) { |
|
| 3141 | - $match_field = 'street'; |
|
| 3142 | - } elseif ( $match_field == 'post_images' ) { |
|
| 3143 | - $match_field = 'featured_image'; |
|
| 3144 | - } |
|
| 3145 | - |
|
| 3146 | - $find_post = $gd_post; |
|
| 3147 | - $find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
|
| 3148 | - |
|
| 3149 | - if ( ! empty( $find_post->ID ) && ! in_array( 'post_category', $find_post_keys ) ) { |
|
| 3150 | - $find_post = geodir_get_post_info( (int) $find_post->ID ); |
|
| 3151 | - $find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
|
| 3152 | - } |
|
| 3153 | - |
|
| 3154 | - if ( $match_field === '' || ( ! empty( $find_post_keys ) && ( in_array( $match_field, $find_post_keys ) || in_array( $_match_field, $find_post_keys ) ) ) ) { |
|
| 3155 | - $address_fields = array( 'street2', 'neighbourhood', 'city', 'region', 'country', 'zip', 'latitude', 'longitude' ); // Address fields |
|
| 3156 | - $field = array(); |
|
| 3157 | - |
|
| 3158 | - if ( $match_field && ! in_array( $match_field, array( 'post_date', 'post_modified', 'default_category', 'post_id', 'post_status' ) ) && ! in_array( $match_field, $address_fields ) ) { |
|
| 3159 | - $package_id = geodir_get_post_package_id( $find_post->ID, $find_post->post_type ); |
|
| 3160 | - $fields = geodir_post_custom_fields( $package_id, 'all', $find_post->post_type, 'none' ); |
|
| 3161 | - |
|
| 3162 | - foreach ( $fields as $field_info ) { |
|
| 3163 | - if ( $match_field == $field_info['htmlvar_name'] ) { |
|
| 3164 | - $field = $field_info; |
|
| 3165 | - break; |
|
| 3166 | - } elseif( $_match_field == $field_info['htmlvar_name'] ) { |
|
| 3167 | - $field = $field_info; |
|
| 3168 | - break; |
|
| 3169 | - } |
|
| 3170 | - } |
|
| 3171 | - |
|
| 3172 | - if ( empty( $field ) ) { |
|
| 3173 | - return false; |
|
| 3174 | - } |
|
| 3175 | - } |
|
| 3176 | - |
|
| 3177 | - // Parse search. |
|
| 3178 | - $search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule ); |
|
| 3179 | - |
|
| 3180 | - // Address fields. |
|
| 3181 | - if ( in_array( $match_field, $address_fields ) && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
| 3182 | - if ( ! empty( $address_fields[ $match_field ] ) ) { |
|
| 3183 | - $field = $address_fields[ $match_field ]; |
|
| 3184 | - } |
|
| 3185 | - } |
|
| 3186 | - |
|
| 3187 | - $is_date = ( ! empty( $field['type'] ) && $field['type'] == 'datepicker' ) || in_array( $match_field, array( 'post_date', 'post_modified' ) ) ? true : false; |
|
| 3188 | - $is_date = apply_filters( 'geodir_post_badge_is_date', $is_date, $match_field, $field, $args, $find_post ); |
|
| 3189 | - |
|
| 3190 | - $match_value = isset($find_post->{$match_field}) ? esc_attr( trim( $find_post->{$match_field} ) ) : ''; |
|
| 3191 | - $match_found = $match_field === '' ? true : false; |
|
| 3192 | - |
|
| 3193 | - if ( ! $match_found ) { |
|
| 3194 | - if ( ( $match_field == 'post_date' || $match_field == 'post_modified' ) && ( empty( $args['condition'] ) || $args['condition'] == 'is_greater_than' || $args['condition'] == 'is_less_than' ) ) { |
|
| 3195 | - if ( strpos( $search, '+' ) === false && strpos( $search, '-' ) === false ) { |
|
| 3196 | - $search = '+' . $search; |
|
| 3197 | - } |
|
| 3198 | - $the_time = $match_field == 'post_modified' ? get_the_modified_date( 'Y-m-d', $find_post ) : get_the_time( 'Y-m-d', $find_post ); |
|
| 3199 | - $until_time = strtotime( $the_time . ' ' . $search . ' days' ); |
|
| 3200 | - $now_time = strtotime( date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) ); |
|
| 3201 | - if ( ( empty( $args['condition'] ) || $args['condition'] == 'is_less_than' ) && $until_time > $now_time ) { |
|
| 3202 | - $match_found = true; |
|
| 3203 | - } elseif ( $args['condition'] == 'is_greater_than' && $until_time < $now_time ) { |
|
| 3204 | - $match_found = true; |
|
| 3205 | - } |
|
| 3206 | - } else { |
|
| 3207 | - switch ( $args['condition'] ) { |
|
| 3208 | - case 'is_equal': |
|
| 3209 | - $match_found = (bool) ( $search != '' && $match_value == $search ); |
|
| 3210 | - break; |
|
| 3211 | - case 'is_not_equal': |
|
| 3212 | - $match_found = (bool) ( $search != '' && $match_value != $search ); |
|
| 3213 | - break; |
|
| 3214 | - case 'is_greater_than': |
|
| 3215 | - $match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value > $search ); |
|
| 3216 | - break; |
|
| 3217 | - case 'is_less_than': |
|
| 3218 | - $match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value < $search ); |
|
| 3219 | - break; |
|
| 3220 | - case 'is_empty': |
|
| 3221 | - $match_found = (bool) ( $match_value === '' || $match_value === false || $match_value === '0' || is_null( $match_value ) ); |
|
| 3222 | - break; |
|
| 3223 | - case 'is_not_empty': |
|
| 3224 | - $match_found = (bool) ( $match_value !== '' && $match_value !== false && $match_value !== '0' && ! is_null( $match_value ) ); |
|
| 3225 | - break; |
|
| 3226 | - case 'is_contains': |
|
| 3227 | - $match_found = (bool) ( $search != '' && stripos( $match_value, $search ) !== false ); |
|
| 3228 | - break; |
|
| 3229 | - case 'is_not_contains': |
|
| 3230 | - $match_found = (bool) ( $search != '' && stripos( $match_value, $search ) === false ); |
|
| 3231 | - break; |
|
| 3232 | - } |
|
| 3233 | - } |
|
| 3234 | - } |
|
| 3235 | - |
|
| 3236 | - $match_found = apply_filters( 'geodir_post_badge_check_match_found', $match_found, $args, $find_post ); |
|
| 3237 | - } |
|
| 3238 | - } |
|
| 3239 | - |
|
| 3240 | - return $match_found; |
|
| 3124 | + global $gd_post; |
|
| 3125 | + |
|
| 3126 | + $match_found = false; |
|
| 3127 | + |
|
| 3128 | + if ( class_exists( 'GeoDirectory' ) && ! empty( $gd_post->ID ) && ! empty( $rule['field'] ) && ! empty( $rule['condition'] ) ) { |
|
| 3129 | + $args['block_visibility'] = true; |
|
| 3130 | + $args['key'] = $rule['field']; |
|
| 3131 | + $args['condition'] = $rule['condition']; |
|
| 3132 | + $args['search'] = isset( $rule['search'] ) ? $rule['search'] : ''; |
|
| 3133 | + |
|
| 3134 | + if ( $args['key'] == 'street' ) { |
|
| 3135 | + $args['key'] = 'address'; |
|
| 3136 | + } |
|
| 3137 | + |
|
| 3138 | + $match_field = $_match_field = $args['key']; |
|
| 3139 | + |
|
| 3140 | + if ( $match_field == 'address' ) { |
|
| 3141 | + $match_field = 'street'; |
|
| 3142 | + } elseif ( $match_field == 'post_images' ) { |
|
| 3143 | + $match_field = 'featured_image'; |
|
| 3144 | + } |
|
| 3145 | + |
|
| 3146 | + $find_post = $gd_post; |
|
| 3147 | + $find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
|
| 3148 | + |
|
| 3149 | + if ( ! empty( $find_post->ID ) && ! in_array( 'post_category', $find_post_keys ) ) { |
|
| 3150 | + $find_post = geodir_get_post_info( (int) $find_post->ID ); |
|
| 3151 | + $find_post_keys = ! empty( $find_post ) ? array_keys( (array) $find_post ) : array(); |
|
| 3152 | + } |
|
| 3153 | + |
|
| 3154 | + if ( $match_field === '' || ( ! empty( $find_post_keys ) && ( in_array( $match_field, $find_post_keys ) || in_array( $_match_field, $find_post_keys ) ) ) ) { |
|
| 3155 | + $address_fields = array( 'street2', 'neighbourhood', 'city', 'region', 'country', 'zip', 'latitude', 'longitude' ); // Address fields |
|
| 3156 | + $field = array(); |
|
| 3157 | + |
|
| 3158 | + if ( $match_field && ! in_array( $match_field, array( 'post_date', 'post_modified', 'default_category', 'post_id', 'post_status' ) ) && ! in_array( $match_field, $address_fields ) ) { |
|
| 3159 | + $package_id = geodir_get_post_package_id( $find_post->ID, $find_post->post_type ); |
|
| 3160 | + $fields = geodir_post_custom_fields( $package_id, 'all', $find_post->post_type, 'none' ); |
|
| 3161 | + |
|
| 3162 | + foreach ( $fields as $field_info ) { |
|
| 3163 | + if ( $match_field == $field_info['htmlvar_name'] ) { |
|
| 3164 | + $field = $field_info; |
|
| 3165 | + break; |
|
| 3166 | + } elseif( $_match_field == $field_info['htmlvar_name'] ) { |
|
| 3167 | + $field = $field_info; |
|
| 3168 | + break; |
|
| 3169 | + } |
|
| 3170 | + } |
|
| 3171 | + |
|
| 3172 | + if ( empty( $field ) ) { |
|
| 3173 | + return false; |
|
| 3174 | + } |
|
| 3175 | + } |
|
| 3176 | + |
|
| 3177 | + // Parse search. |
|
| 3178 | + $search = sd_gd_field_rule_search( $args['search'], $find_post->post_type, $rule ); |
|
| 3179 | + |
|
| 3180 | + // Address fields. |
|
| 3181 | + if ( in_array( $match_field, $address_fields ) && ( $address_fields = geodir_post_meta_address_fields( '' ) ) ) { |
|
| 3182 | + if ( ! empty( $address_fields[ $match_field ] ) ) { |
|
| 3183 | + $field = $address_fields[ $match_field ]; |
|
| 3184 | + } |
|
| 3185 | + } |
|
| 3186 | + |
|
| 3187 | + $is_date = ( ! empty( $field['type'] ) && $field['type'] == 'datepicker' ) || in_array( $match_field, array( 'post_date', 'post_modified' ) ) ? true : false; |
|
| 3188 | + $is_date = apply_filters( 'geodir_post_badge_is_date', $is_date, $match_field, $field, $args, $find_post ); |
|
| 3189 | + |
|
| 3190 | + $match_value = isset($find_post->{$match_field}) ? esc_attr( trim( $find_post->{$match_field} ) ) : ''; |
|
| 3191 | + $match_found = $match_field === '' ? true : false; |
|
| 3192 | + |
|
| 3193 | + if ( ! $match_found ) { |
|
| 3194 | + if ( ( $match_field == 'post_date' || $match_field == 'post_modified' ) && ( empty( $args['condition'] ) || $args['condition'] == 'is_greater_than' || $args['condition'] == 'is_less_than' ) ) { |
|
| 3195 | + if ( strpos( $search, '+' ) === false && strpos( $search, '-' ) === false ) { |
|
| 3196 | + $search = '+' . $search; |
|
| 3197 | + } |
|
| 3198 | + $the_time = $match_field == 'post_modified' ? get_the_modified_date( 'Y-m-d', $find_post ) : get_the_time( 'Y-m-d', $find_post ); |
|
| 3199 | + $until_time = strtotime( $the_time . ' ' . $search . ' days' ); |
|
| 3200 | + $now_time = strtotime( date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) ); |
|
| 3201 | + if ( ( empty( $args['condition'] ) || $args['condition'] == 'is_less_than' ) && $until_time > $now_time ) { |
|
| 3202 | + $match_found = true; |
|
| 3203 | + } elseif ( $args['condition'] == 'is_greater_than' && $until_time < $now_time ) { |
|
| 3204 | + $match_found = true; |
|
| 3205 | + } |
|
| 3206 | + } else { |
|
| 3207 | + switch ( $args['condition'] ) { |
|
| 3208 | + case 'is_equal': |
|
| 3209 | + $match_found = (bool) ( $search != '' && $match_value == $search ); |
|
| 3210 | + break; |
|
| 3211 | + case 'is_not_equal': |
|
| 3212 | + $match_found = (bool) ( $search != '' && $match_value != $search ); |
|
| 3213 | + break; |
|
| 3214 | + case 'is_greater_than': |
|
| 3215 | + $match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value > $search ); |
|
| 3216 | + break; |
|
| 3217 | + case 'is_less_than': |
|
| 3218 | + $match_found = (bool) ( $search != '' && ( is_float( $search ) || is_numeric( $search ) ) && ( is_float( $match_value ) || is_numeric( $match_value ) ) && $match_value < $search ); |
|
| 3219 | + break; |
|
| 3220 | + case 'is_empty': |
|
| 3221 | + $match_found = (bool) ( $match_value === '' || $match_value === false || $match_value === '0' || is_null( $match_value ) ); |
|
| 3222 | + break; |
|
| 3223 | + case 'is_not_empty': |
|
| 3224 | + $match_found = (bool) ( $match_value !== '' && $match_value !== false && $match_value !== '0' && ! is_null( $match_value ) ); |
|
| 3225 | + break; |
|
| 3226 | + case 'is_contains': |
|
| 3227 | + $match_found = (bool) ( $search != '' && stripos( $match_value, $search ) !== false ); |
|
| 3228 | + break; |
|
| 3229 | + case 'is_not_contains': |
|
| 3230 | + $match_found = (bool) ( $search != '' && stripos( $match_value, $search ) === false ); |
|
| 3231 | + break; |
|
| 3232 | + } |
|
| 3233 | + } |
|
| 3234 | + } |
|
| 3235 | + |
|
| 3236 | + $match_found = apply_filters( 'geodir_post_badge_check_match_found', $match_found, $args, $find_post ); |
|
| 3237 | + } |
|
| 3238 | + } |
|
| 3239 | + |
|
| 3240 | + return $match_found; |
|
| 3241 | 3241 | } |
| 3242 | 3242 | |
| 3243 | 3243 | function sd_gd_field_rule_search( $search, $post_type, $rule ) { |
| 3244 | - if ( ! $search ) { |
|
| 3245 | - return $search; |
|
| 3246 | - } |
|
| 3247 | - |
|
| 3248 | - $orig_search = $search; |
|
| 3249 | - $_search = strtolower( $search ); |
|
| 3250 | - |
|
| 3251 | - if ( $_search == 'date_today' ) { |
|
| 3252 | - $search = date( 'Y-m-d' ); |
|
| 3253 | - } else if ( $_search == 'date_tomorrow' ) { |
|
| 3254 | - $search = date( 'Y-m-d', strtotime( "+1 day" ) ); |
|
| 3255 | - } else if ( $_search == 'date_yesterday' ) { |
|
| 3256 | - $search = date( 'Y-m-d', strtotime( "-1 day" ) ); |
|
| 3257 | - } else if ( $_search == 'time_his' ) { |
|
| 3258 | - $search = date( 'H:i:s' ); |
|
| 3259 | - } else if ( $_search == 'time_hi' ) { |
|
| 3260 | - $search = date( 'H:i' ); |
|
| 3261 | - } else if ( $_search == 'datetime_now' ) { |
|
| 3262 | - $search = date( 'Y-m-d H:i:s' ); |
|
| 3263 | - } else if ( strpos( $_search, 'datetime_after_' ) === 0 ) { |
|
| 3264 | - $_searches = explode( 'datetime_after_', $_search, 2 ); |
|
| 3265 | - |
|
| 3266 | - if ( ! empty( $_searches[1] ) ) { |
|
| 3267 | - $search = date( 'Y-m-d H:i:s', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3268 | - } else { |
|
| 3269 | - $search = date( 'Y-m-d H:i:s' ); |
|
| 3270 | - } |
|
| 3271 | - } else if ( strpos( $_search, 'datetime_before_' ) === 0 ) { |
|
| 3272 | - $_searches = explode( 'datetime_before_', $_search, 2 ); |
|
| 3273 | - |
|
| 3274 | - if ( ! empty( $_searches[1] ) ) { |
|
| 3275 | - $search = date( 'Y-m-d H:i:s', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3276 | - } else { |
|
| 3277 | - $search = date( 'Y-m-d H:i:s' ); |
|
| 3278 | - } |
|
| 3279 | - } else if ( strpos( $_search, 'date_after_' ) === 0 ) { |
|
| 3280 | - $_searches = explode( 'date_after_', $_search, 2 ); |
|
| 3281 | - |
|
| 3282 | - if ( ! empty( $_searches[1] ) ) { |
|
| 3283 | - $search = date( 'Y-m-d', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3284 | - } else { |
|
| 3285 | - $search = date( 'Y-m-d' ); |
|
| 3286 | - } |
|
| 3287 | - } else if ( strpos( $_search, 'date_before_' ) === 0 ) { |
|
| 3288 | - $_searches = explode( 'date_before_', $_search, 2 ); |
|
| 3289 | - |
|
| 3290 | - if ( ! empty( $_searches[1] ) ) { |
|
| 3291 | - $search = date( 'Y-m-d', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3292 | - } else { |
|
| 3293 | - $search = date( 'Y-m-d' ); |
|
| 3294 | - } |
|
| 3295 | - } |
|
| 3296 | - |
|
| 3297 | - return apply_filters( 'sd_gd_field_rule_search', $search, $post_type, $rule, $orig_search ); |
|
| 3244 | + if ( ! $search ) { |
|
| 3245 | + return $search; |
|
| 3246 | + } |
|
| 3247 | + |
|
| 3248 | + $orig_search = $search; |
|
| 3249 | + $_search = strtolower( $search ); |
|
| 3250 | + |
|
| 3251 | + if ( $_search == 'date_today' ) { |
|
| 3252 | + $search = date( 'Y-m-d' ); |
|
| 3253 | + } else if ( $_search == 'date_tomorrow' ) { |
|
| 3254 | + $search = date( 'Y-m-d', strtotime( "+1 day" ) ); |
|
| 3255 | + } else if ( $_search == 'date_yesterday' ) { |
|
| 3256 | + $search = date( 'Y-m-d', strtotime( "-1 day" ) ); |
|
| 3257 | + } else if ( $_search == 'time_his' ) { |
|
| 3258 | + $search = date( 'H:i:s' ); |
|
| 3259 | + } else if ( $_search == 'time_hi' ) { |
|
| 3260 | + $search = date( 'H:i' ); |
|
| 3261 | + } else if ( $_search == 'datetime_now' ) { |
|
| 3262 | + $search = date( 'Y-m-d H:i:s' ); |
|
| 3263 | + } else if ( strpos( $_search, 'datetime_after_' ) === 0 ) { |
|
| 3264 | + $_searches = explode( 'datetime_after_', $_search, 2 ); |
|
| 3265 | + |
|
| 3266 | + if ( ! empty( $_searches[1] ) ) { |
|
| 3267 | + $search = date( 'Y-m-d H:i:s', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3268 | + } else { |
|
| 3269 | + $search = date( 'Y-m-d H:i:s' ); |
|
| 3270 | + } |
|
| 3271 | + } else if ( strpos( $_search, 'datetime_before_' ) === 0 ) { |
|
| 3272 | + $_searches = explode( 'datetime_before_', $_search, 2 ); |
|
| 3273 | + |
|
| 3274 | + if ( ! empty( $_searches[1] ) ) { |
|
| 3275 | + $search = date( 'Y-m-d H:i:s', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3276 | + } else { |
|
| 3277 | + $search = date( 'Y-m-d H:i:s' ); |
|
| 3278 | + } |
|
| 3279 | + } else if ( strpos( $_search, 'date_after_' ) === 0 ) { |
|
| 3280 | + $_searches = explode( 'date_after_', $_search, 2 ); |
|
| 3281 | + |
|
| 3282 | + if ( ! empty( $_searches[1] ) ) { |
|
| 3283 | + $search = date( 'Y-m-d', strtotime( "+ " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3284 | + } else { |
|
| 3285 | + $search = date( 'Y-m-d' ); |
|
| 3286 | + } |
|
| 3287 | + } else if ( strpos( $_search, 'date_before_' ) === 0 ) { |
|
| 3288 | + $_searches = explode( 'date_before_', $_search, 2 ); |
|
| 3289 | + |
|
| 3290 | + if ( ! empty( $_searches[1] ) ) { |
|
| 3291 | + $search = date( 'Y-m-d', strtotime( "- " . str_replace( "_", " ", $_searches[1] ) ) ); |
|
| 3292 | + } else { |
|
| 3293 | + $search = date( 'Y-m-d' ); |
|
| 3294 | + } |
|
| 3295 | + } |
|
| 3296 | + |
|
| 3297 | + return apply_filters( 'sd_gd_field_rule_search', $search, $post_type, $rule, $orig_search ); |
|
| 3298 | 3298 | } |
| 3299 | 3299 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -21,416 +21,416 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * A Class to be able to change settings for Font Awesome. |
|
| 26 | - * |
|
| 27 | - * Class WP_Font_Awesome_Settings |
|
| 28 | - * @since 1.0.10 Now able to pass wp.org theme check. |
|
| 29 | - * @since 1.0.11 Font Awesome Pro now supported. |
|
| 30 | - * @since 1.0.11 Font Awesome Kits now supported. |
|
| 31 | - * @since 1.0.13 RTL language support added. |
|
| 32 | - * @since 1.0.14 Warning added for v6 pro requires kit and will now not work if official FA plugin installed. |
|
| 33 | - * @since 1.0.15 Font Awesome will now load in the FSE if enable din the backend. |
|
| 34 | - * @since 1.1.0 Option added to load FontAwesome locally. |
|
| 35 | - * @since 1.1.1 Requires to re-save settings to load locally when option does not exists - FIXED. |
|
| 36 | - * @since 1.1.2 Bumped the latest version to 6.3.0 - CHANGED. |
|
| 24 | + /** |
|
| 25 | + * A Class to be able to change settings for Font Awesome. |
|
| 26 | + * |
|
| 27 | + * Class WP_Font_Awesome_Settings |
|
| 28 | + * @since 1.0.10 Now able to pass wp.org theme check. |
|
| 29 | + * @since 1.0.11 Font Awesome Pro now supported. |
|
| 30 | + * @since 1.0.11 Font Awesome Kits now supported. |
|
| 31 | + * @since 1.0.13 RTL language support added. |
|
| 32 | + * @since 1.0.14 Warning added for v6 pro requires kit and will now not work if official FA plugin installed. |
|
| 33 | + * @since 1.0.15 Font Awesome will now load in the FSE if enable din the backend. |
|
| 34 | + * @since 1.1.0 Option added to load FontAwesome locally. |
|
| 35 | + * @since 1.1.1 Requires to re-save settings to load locally when option does not exists - FIXED. |
|
| 36 | + * @since 1.1.2 Bumped the latest version to 6.3.0 - CHANGED. |
|
| 37 | 37 | * @since 1.1.3 Added JS files for iconpicker and added constant for URL for AyeCode-UI - ADDED. |
| 38 | 38 | * @since 1.1.5 Added constant for when pro enabled - ADDED. |
| 39 | 39 | * @since 1.1.6 Calling FA in wp_footer can cause issues on frontend - REVERTED |
| 40 | - * @ver 1.1.6 |
|
| 41 | - * @todo decide how to implement textdomain |
|
| 42 | - */ |
|
| 43 | - class WP_Font_Awesome_Settings { |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Class version version. |
|
| 47 | - * |
|
| 48 | - * @var string |
|
| 49 | - */ |
|
| 50 | - public $version = '1.1.6'; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Class textdomain. |
|
| 54 | - * |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 57 | - public $textdomain = 'font-awesome-settings'; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Latest version of Font Awesome at time of publish published. |
|
| 61 | - * |
|
| 62 | - * @var string |
|
| 63 | - */ |
|
| 64 | - public $latest = "6.4.2"; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * The title. |
|
| 68 | - * |
|
| 69 | - * @var string |
|
| 70 | - */ |
|
| 71 | - public $name = 'Font Awesome'; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Holds the settings values. |
|
| 75 | - * |
|
| 76 | - * @var array |
|
| 77 | - */ |
|
| 78 | - private $settings; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * WP_Font_Awesome_Settings instance. |
|
| 82 | - * |
|
| 83 | - * @access private |
|
| 84 | - * @since 1.0.0 |
|
| 85 | - * @var WP_Font_Awesome_Settings There can be only one! |
|
| 86 | - */ |
|
| 87 | - private static $instance = null; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Main WP_Font_Awesome_Settings Instance. |
|
| 91 | - * |
|
| 92 | - * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded. |
|
| 93 | - * |
|
| 94 | - * @since 1.0.0 |
|
| 95 | - * @static |
|
| 96 | - * @return WP_Font_Awesome_Settings - Main instance. |
|
| 97 | - */ |
|
| 98 | - public static function instance() { |
|
| 99 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
| 100 | - self::$instance = new WP_Font_Awesome_Settings; |
|
| 101 | - |
|
| 102 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 103 | - |
|
| 104 | - if ( is_admin() ) { |
|
| 105 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 106 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 107 | - add_action( 'admin_init', array( self::$instance, 'constants' ) ); |
|
| 108 | - add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) ); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - do_action( 'wp_font_awesome_settings_loaded' ); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return self::$instance; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 40 | + * @ver 1.1.6 |
|
| 41 | + * @todo decide how to implement textdomain |
|
| 42 | + */ |
|
| 43 | + class WP_Font_Awesome_Settings { |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Class version version. |
|
| 47 | + * |
|
| 48 | + * @var string |
|
| 49 | + */ |
|
| 50 | + public $version = '1.1.6'; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Class textdomain. |
|
| 54 | + * |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | + public $textdomain = 'font-awesome-settings'; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Latest version of Font Awesome at time of publish published. |
|
| 61 | + * |
|
| 62 | + * @var string |
|
| 63 | + */ |
|
| 64 | + public $latest = "6.4.2"; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * The title. |
|
| 68 | + * |
|
| 69 | + * @var string |
|
| 70 | + */ |
|
| 71 | + public $name = 'Font Awesome'; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Holds the settings values. |
|
| 75 | + * |
|
| 76 | + * @var array |
|
| 77 | + */ |
|
| 78 | + private $settings; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * WP_Font_Awesome_Settings instance. |
|
| 82 | + * |
|
| 83 | + * @access private |
|
| 84 | + * @since 1.0.0 |
|
| 85 | + * @var WP_Font_Awesome_Settings There can be only one! |
|
| 86 | + */ |
|
| 87 | + private static $instance = null; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Main WP_Font_Awesome_Settings Instance. |
|
| 91 | + * |
|
| 92 | + * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded. |
|
| 93 | + * |
|
| 94 | + * @since 1.0.0 |
|
| 95 | + * @static |
|
| 96 | + * @return WP_Font_Awesome_Settings - Main instance. |
|
| 97 | + */ |
|
| 98 | + public static function instance() { |
|
| 99 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
| 100 | + self::$instance = new WP_Font_Awesome_Settings; |
|
| 101 | + |
|
| 102 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 103 | + |
|
| 104 | + if ( is_admin() ) { |
|
| 105 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 106 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 107 | + add_action( 'admin_init', array( self::$instance, 'constants' ) ); |
|
| 108 | + add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) ); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + do_action( 'wp_font_awesome_settings_loaded' ); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return self::$instance; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | 118 | * Define any constants that may be needed by other packages. |
| 119 | 119 | * |
| 120 | - * @return void |
|
| 121 | - */ |
|
| 122 | - public function constants(){ |
|
| 120 | + * @return void |
|
| 121 | + */ |
|
| 122 | + public function constants(){ |
|
| 123 | 123 | |
| 124 | - // register iconpicker constant |
|
| 125 | - if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
| 126 | - $url = $this->get_path_url(); |
|
| 127 | - $version = $this->settings['version']; |
|
| 124 | + // register iconpicker constant |
|
| 125 | + if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
| 126 | + $url = $this->get_path_url(); |
|
| 127 | + $version = $this->settings['version']; |
|
| 128 | 128 | |
| 129 | - if( !$version || version_compare($version,'5.999','>')){ |
|
| 130 | - $url .= 'assets/js/fa-iconpicker-v6.min.js'; |
|
| 131 | - }else{ |
|
| 132 | - $url .= 'assets/js/fa-iconpicker-v5.min.js'; |
|
| 133 | - } |
|
| 129 | + if( !$version || version_compare($version,'5.999','>')){ |
|
| 130 | + $url .= 'assets/js/fa-iconpicker-v6.min.js'; |
|
| 131 | + }else{ |
|
| 132 | + $url .= 'assets/js/fa-iconpicker-v5.min.js'; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - define( 'FAS_ICONPICKER_JS_URL', $url ); |
|
| 135 | + define( 'FAS_ICONPICKER_JS_URL', $url ); |
|
| 136 | 136 | |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | // Set a constant if pro enbaled |
| 140 | - if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) { |
|
| 141 | - define( 'FAS_PRO', true ); |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Get the url path to the current folder. |
|
| 147 | - * |
|
| 148 | - * @return string |
|
| 149 | - */ |
|
| 150 | - public function get_path_url() { |
|
| 151 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 152 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 153 | - |
|
| 154 | - // Replace http:// to https://. |
|
| 155 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 156 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - // Check if we are inside a plugin |
|
| 160 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 161 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 162 | - |
|
| 163 | - return trailingslashit( $url ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Initiate the settings and add the required action hooks. |
|
| 168 | - * |
|
| 169 | - * @since 1.0.8 Settings name wrong - FIXED |
|
| 170 | - */ |
|
| 171 | - public function init() { |
|
| 172 | - // Download fontawesome locally. |
|
| 173 | - add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 ); |
|
| 174 | - add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 ); |
|
| 175 | - |
|
| 176 | - $this->settings = $this->get_settings(); |
|
| 177 | - |
|
| 178 | - // check if the official plugin is active and use that instead if so. |
|
| 179 | - if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
| 180 | - |
|
| 181 | - if ( $this->settings['type'] == 'CSS' ) { |
|
| 182 | - |
|
| 183 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
| 184 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
| 140 | + if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) { |
|
| 141 | + define( 'FAS_PRO', true ); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Get the url path to the current folder. |
|
| 147 | + * |
|
| 148 | + * @return string |
|
| 149 | + */ |
|
| 150 | + public function get_path_url() { |
|
| 151 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 152 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 153 | + |
|
| 154 | + // Replace http:// to https://. |
|
| 155 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 156 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + // Check if we are inside a plugin |
|
| 160 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 161 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 162 | + |
|
| 163 | + return trailingslashit( $url ); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Initiate the settings and add the required action hooks. |
|
| 168 | + * |
|
| 169 | + * @since 1.0.8 Settings name wrong - FIXED |
|
| 170 | + */ |
|
| 171 | + public function init() { |
|
| 172 | + // Download fontawesome locally. |
|
| 173 | + add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 ); |
|
| 174 | + add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 ); |
|
| 175 | + |
|
| 176 | + $this->settings = $this->get_settings(); |
|
| 177 | + |
|
| 178 | + // check if the official plugin is active and use that instead if so. |
|
| 179 | + if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
| 180 | + |
|
| 181 | + if ( $this->settings['type'] == 'CSS' ) { |
|
| 182 | + |
|
| 183 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
| 184 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
| 185 | 185 | // add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend |
| 186 | - } |
|
| 187 | - |
|
| 188 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
| 189 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
| 190 | - add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 ); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - } else { |
|
| 194 | - |
|
| 195 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
| 196 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
| 200 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
| 201 | - add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 ); |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - // remove font awesome if set to do so |
|
| 206 | - if ( $this->settings['dequeue'] == '1' ) { |
|
| 207 | - add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Add FA to the FSE. |
|
| 215 | - * |
|
| 216 | - * @param $editor_settings |
|
| 217 | - * @param $block_editor_context |
|
| 218 | - * |
|
| 219 | - * @return array |
|
| 220 | - */ |
|
| 221 | - public function enqueue_editor_styles( $editor_settings, $block_editor_context ){ |
|
| 222 | - |
|
| 223 | - if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) { |
|
| 224 | - $url = $this->get_url(); |
|
| 225 | - $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css' href='$url' media='all' />"; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return $editor_settings; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Add FA to the FSE. |
|
| 233 | - * |
|
| 234 | - * @param $editor_settings |
|
| 235 | - * @param $block_editor_context |
|
| 236 | - * |
|
| 237 | - * @return array |
|
| 238 | - */ |
|
| 239 | - public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){ |
|
| 240 | - |
|
| 241 | - $url = $this->get_url(); |
|
| 242 | - $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>"; |
|
| 243 | - |
|
| 244 | - return $editor_settings; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Adds the Font Awesome styles. |
|
| 249 | - */ |
|
| 250 | - public function enqueue_style() { |
|
| 251 | - // build url |
|
| 252 | - $url = $this->get_url(); |
|
| 253 | - $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null; |
|
| 254 | - |
|
| 255 | - wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
| 256 | - wp_register_style( 'font-awesome', $url, array(), $version ); |
|
| 257 | - wp_enqueue_style( 'font-awesome' ); |
|
| 258 | - |
|
| 259 | - // RTL language support CSS. |
|
| 260 | - if ( is_rtl() ) { |
|
| 261 | - wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() ); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - if ( $this->settings['shims'] ) { |
|
| 265 | - $url = $this->get_url( true ); |
|
| 266 | - wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
| 267 | - wp_register_style( 'font-awesome-shims', $url, array(), $version ); |
|
| 268 | - wp_enqueue_style( 'font-awesome-shims' ); |
|
| 269 | - } |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * Adds the Font Awesome JS. |
|
| 274 | - */ |
|
| 275 | - public function enqueue_scripts() { |
|
| 276 | - // build url |
|
| 277 | - $url = $this->get_url(); |
|
| 278 | - |
|
| 279 | - $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
|
| 280 | - call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
| 281 | - wp_register_script( 'font-awesome', $url, array(), null ); |
|
| 282 | - wp_enqueue_script( 'font-awesome' ); |
|
| 283 | - |
|
| 284 | - if ( $this->settings['shims'] ) { |
|
| 285 | - $url = $this->get_url( true ); |
|
| 286 | - call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
| 287 | - wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
| 288 | - wp_enqueue_script( 'font-awesome-shims' ); |
|
| 289 | - } |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Get the url of the Font Awesome files. |
|
| 294 | - * |
|
| 295 | - * @param bool $shims If this is a shim file or not. |
|
| 296 | - * @param bool $local Load locally if allowed. |
|
| 297 | - * |
|
| 298 | - * @return string The url to the file. |
|
| 299 | - */ |
|
| 300 | - public function get_url( $shims = false, $local = true ) { |
|
| 301 | - $script = $shims ? 'v4-shims' : 'all'; |
|
| 302 | - $sub = $this->settings['pro'] ? 'pro' : 'use'; |
|
| 303 | - $type = $this->settings['type']; |
|
| 304 | - $version = $this->settings['version']; |
|
| 305 | - $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
| 306 | - $url = ''; |
|
| 307 | - |
|
| 308 | - if ( $type == 'KIT' && $kit_url ) { |
|
| 309 | - if ( $shims ) { |
|
| 310 | - // if its a kit then we don't add shims here |
|
| 311 | - return ''; |
|
| 312 | - } |
|
| 313 | - $url .= $kit_url; // CDN |
|
| 314 | - $url .= "?wpfas=true"; // set our var so our version is not removed |
|
| 315 | - } else { |
|
| 316 | - $v = ''; |
|
| 317 | - // Check and load locally. |
|
| 318 | - if ( $local && $this->has_local() ) { |
|
| 319 | - $script .= ".min"; |
|
| 320 | - $v .= '&ver=' . strip_tags( $this->settings['local_version'] ); |
|
| 321 | - $url .= $this->get_fonts_url(); // Local fonts url. |
|
| 322 | - } else { |
|
| 323 | - $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
|
| 324 | - $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
| 325 | - } |
|
| 326 | - $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
|
| 327 | - $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
|
| 328 | - $url .= "?wpfas=true" . $v; // set our var so our version is not removed |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - return $url; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - /** |
|
| 335 | - * Try and remove any other versions of Font Awesome added by other plugins/themes. |
|
| 336 | - * |
|
| 337 | - * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version. |
|
| 338 | - * |
|
| 339 | - * @param $url |
|
| 340 | - * @param $original_url |
|
| 341 | - * @param $_context |
|
| 342 | - * |
|
| 343 | - * @return string The filtered url. |
|
| 344 | - */ |
|
| 345 | - public function remove_font_awesome( $url, $original_url, $_context ) { |
|
| 346 | - |
|
| 347 | - if ( $_context == 'display' |
|
| 348 | - && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
| 349 | - && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
| 350 | - ) {// it's a font-awesome-url (probably) |
|
| 351 | - |
|
| 352 | - if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
| 353 | - if ( $this->settings['type'] == 'JS' ) { |
|
| 354 | - if ( $this->settings['js-pseudo'] ) { |
|
| 355 | - $url .= "' data-search-pseudo-elements defer='defer"; |
|
| 356 | - } else { |
|
| 357 | - $url .= "' defer='defer"; |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - } else { |
|
| 361 | - $url = ''; // removing the url removes the file |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - return $url; |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Register the database settings with WordPress. |
|
| 371 | - */ |
|
| 372 | - public function register_settings() { |
|
| 373 | - register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Add the WordPress settings menu item. |
|
| 378 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 379 | - */ |
|
| 380 | - public function menu_item() { |
|
| 381 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 382 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
| 383 | - $this, |
|
| 384 | - 'settings_page' |
|
| 385 | - ) ); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * Get the current Font Awesome output settings. |
|
| 390 | - * |
|
| 391 | - * @return array The array of settings. |
|
| 392 | - */ |
|
| 393 | - public function get_settings() { |
|
| 394 | - $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
| 395 | - |
|
| 396 | - $defaults = array( |
|
| 397 | - 'type' => 'CSS', // type to use, CSS or JS or KIT |
|
| 398 | - 'version' => '', // latest |
|
| 399 | - 'enqueue' => '', // front and backend |
|
| 400 | - 'shims' => '0', // default OFF now in 2020 |
|
| 401 | - 'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive) |
|
| 402 | - 'dequeue' => '0', // if we should try to remove other versions added by other plugins/themes |
|
| 403 | - 'pro' => '0', // if pro CDN url should be used |
|
| 404 | - 'local' => '0', // Store fonts locally. |
|
| 405 | - 'local_version' => '', // Local fonts version. |
|
| 406 | - 'kit-url' => '', // the kit url |
|
| 407 | - ); |
|
| 408 | - |
|
| 409 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Filter the Font Awesome settings. |
|
| 413 | - * |
|
| 414 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 415 | - */ |
|
| 416 | - return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - /** |
|
| 420 | - * The settings page html output. |
|
| 421 | - */ |
|
| 422 | - public function settings_page() { |
|
| 423 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 424 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - // a hidden way to force the update of the version number via api instead of waiting the 48 hours |
|
| 428 | - if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
| 429 | - $this->get_latest_version( $force_api = true ); |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
| 433 | - ?> |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
| 189 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
| 190 | + add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 ); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + } else { |
|
| 194 | + |
|
| 195 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
| 196 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
| 200 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
| 201 | + add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 ); |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + // remove font awesome if set to do so |
|
| 206 | + if ( $this->settings['dequeue'] == '1' ) { |
|
| 207 | + add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Add FA to the FSE. |
|
| 215 | + * |
|
| 216 | + * @param $editor_settings |
|
| 217 | + * @param $block_editor_context |
|
| 218 | + * |
|
| 219 | + * @return array |
|
| 220 | + */ |
|
| 221 | + public function enqueue_editor_styles( $editor_settings, $block_editor_context ){ |
|
| 222 | + |
|
| 223 | + if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) { |
|
| 224 | + $url = $this->get_url(); |
|
| 225 | + $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css' href='$url' media='all' />"; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return $editor_settings; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Add FA to the FSE. |
|
| 233 | + * |
|
| 234 | + * @param $editor_settings |
|
| 235 | + * @param $block_editor_context |
|
| 236 | + * |
|
| 237 | + * @return array |
|
| 238 | + */ |
|
| 239 | + public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){ |
|
| 240 | + |
|
| 241 | + $url = $this->get_url(); |
|
| 242 | + $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>"; |
|
| 243 | + |
|
| 244 | + return $editor_settings; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * Adds the Font Awesome styles. |
|
| 249 | + */ |
|
| 250 | + public function enqueue_style() { |
|
| 251 | + // build url |
|
| 252 | + $url = $this->get_url(); |
|
| 253 | + $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null; |
|
| 254 | + |
|
| 255 | + wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
| 256 | + wp_register_style( 'font-awesome', $url, array(), $version ); |
|
| 257 | + wp_enqueue_style( 'font-awesome' ); |
|
| 258 | + |
|
| 259 | + // RTL language support CSS. |
|
| 260 | + if ( is_rtl() ) { |
|
| 261 | + wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() ); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + if ( $this->settings['shims'] ) { |
|
| 265 | + $url = $this->get_url( true ); |
|
| 266 | + wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
| 267 | + wp_register_style( 'font-awesome-shims', $url, array(), $version ); |
|
| 268 | + wp_enqueue_style( 'font-awesome-shims' ); |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * Adds the Font Awesome JS. |
|
| 274 | + */ |
|
| 275 | + public function enqueue_scripts() { |
|
| 276 | + // build url |
|
| 277 | + $url = $this->get_url(); |
|
| 278 | + |
|
| 279 | + $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
|
| 280 | + call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
| 281 | + wp_register_script( 'font-awesome', $url, array(), null ); |
|
| 282 | + wp_enqueue_script( 'font-awesome' ); |
|
| 283 | + |
|
| 284 | + if ( $this->settings['shims'] ) { |
|
| 285 | + $url = $this->get_url( true ); |
|
| 286 | + call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
| 287 | + wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
| 288 | + wp_enqueue_script( 'font-awesome-shims' ); |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Get the url of the Font Awesome files. |
|
| 294 | + * |
|
| 295 | + * @param bool $shims If this is a shim file or not. |
|
| 296 | + * @param bool $local Load locally if allowed. |
|
| 297 | + * |
|
| 298 | + * @return string The url to the file. |
|
| 299 | + */ |
|
| 300 | + public function get_url( $shims = false, $local = true ) { |
|
| 301 | + $script = $shims ? 'v4-shims' : 'all'; |
|
| 302 | + $sub = $this->settings['pro'] ? 'pro' : 'use'; |
|
| 303 | + $type = $this->settings['type']; |
|
| 304 | + $version = $this->settings['version']; |
|
| 305 | + $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
| 306 | + $url = ''; |
|
| 307 | + |
|
| 308 | + if ( $type == 'KIT' && $kit_url ) { |
|
| 309 | + if ( $shims ) { |
|
| 310 | + // if its a kit then we don't add shims here |
|
| 311 | + return ''; |
|
| 312 | + } |
|
| 313 | + $url .= $kit_url; // CDN |
|
| 314 | + $url .= "?wpfas=true"; // set our var so our version is not removed |
|
| 315 | + } else { |
|
| 316 | + $v = ''; |
|
| 317 | + // Check and load locally. |
|
| 318 | + if ( $local && $this->has_local() ) { |
|
| 319 | + $script .= ".min"; |
|
| 320 | + $v .= '&ver=' . strip_tags( $this->settings['local_version'] ); |
|
| 321 | + $url .= $this->get_fonts_url(); // Local fonts url. |
|
| 322 | + } else { |
|
| 323 | + $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
|
| 324 | + $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
| 325 | + } |
|
| 326 | + $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
|
| 327 | + $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
|
| 328 | + $url .= "?wpfas=true" . $v; // set our var so our version is not removed |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + return $url; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + /** |
|
| 335 | + * Try and remove any other versions of Font Awesome added by other plugins/themes. |
|
| 336 | + * |
|
| 337 | + * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version. |
|
| 338 | + * |
|
| 339 | + * @param $url |
|
| 340 | + * @param $original_url |
|
| 341 | + * @param $_context |
|
| 342 | + * |
|
| 343 | + * @return string The filtered url. |
|
| 344 | + */ |
|
| 345 | + public function remove_font_awesome( $url, $original_url, $_context ) { |
|
| 346 | + |
|
| 347 | + if ( $_context == 'display' |
|
| 348 | + && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
| 349 | + && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
| 350 | + ) {// it's a font-awesome-url (probably) |
|
| 351 | + |
|
| 352 | + if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
| 353 | + if ( $this->settings['type'] == 'JS' ) { |
|
| 354 | + if ( $this->settings['js-pseudo'] ) { |
|
| 355 | + $url .= "' data-search-pseudo-elements defer='defer"; |
|
| 356 | + } else { |
|
| 357 | + $url .= "' defer='defer"; |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + } else { |
|
| 361 | + $url = ''; // removing the url removes the file |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + return $url; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Register the database settings with WordPress. |
|
| 371 | + */ |
|
| 372 | + public function register_settings() { |
|
| 373 | + register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Add the WordPress settings menu item. |
|
| 378 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 379 | + */ |
|
| 380 | + public function menu_item() { |
|
| 381 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 382 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
| 383 | + $this, |
|
| 384 | + 'settings_page' |
|
| 385 | + ) ); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * Get the current Font Awesome output settings. |
|
| 390 | + * |
|
| 391 | + * @return array The array of settings. |
|
| 392 | + */ |
|
| 393 | + public function get_settings() { |
|
| 394 | + $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
| 395 | + |
|
| 396 | + $defaults = array( |
|
| 397 | + 'type' => 'CSS', // type to use, CSS or JS or KIT |
|
| 398 | + 'version' => '', // latest |
|
| 399 | + 'enqueue' => '', // front and backend |
|
| 400 | + 'shims' => '0', // default OFF now in 2020 |
|
| 401 | + 'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive) |
|
| 402 | + 'dequeue' => '0', // if we should try to remove other versions added by other plugins/themes |
|
| 403 | + 'pro' => '0', // if pro CDN url should be used |
|
| 404 | + 'local' => '0', // Store fonts locally. |
|
| 405 | + 'local_version' => '', // Local fonts version. |
|
| 406 | + 'kit-url' => '', // the kit url |
|
| 407 | + ); |
|
| 408 | + |
|
| 409 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * Filter the Font Awesome settings. |
|
| 413 | + * |
|
| 414 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 415 | + */ |
|
| 416 | + return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + /** |
|
| 420 | + * The settings page html output. |
|
| 421 | + */ |
|
| 422 | + public function settings_page() { |
|
| 423 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 424 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + // a hidden way to force the update of the version number via api instead of waiting the 48 hours |
|
| 428 | + if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
| 429 | + $this->get_latest_version( $force_api = true ); |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
| 433 | + ?> |
|
| 434 | 434 | <style> |
| 435 | 435 | .wpfas-kit-show { |
| 436 | 436 | display: none; |
@@ -456,16 +456,16 @@ discard block |
||
| 456 | 456 | <h1><?php echo $this->name; ?></h1> |
| 457 | 457 | <form method="post" action="options.php" class="fas-settings-form"> |
| 458 | 458 | <?php |
| 459 | - settings_fields( 'wp-font-awesome-settings' ); |
|
| 460 | - do_settings_sections( 'wp-font-awesome-settings' ); |
|
| 461 | - $table_class = ''; |
|
| 462 | - if ( $this->settings['type'] ) { |
|
| 463 | - $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set'; |
|
| 464 | - } |
|
| 465 | - if ( ! empty( $this->settings['pro'] ) ) { |
|
| 466 | - $table_class .= ' wpfas-has-pro'; |
|
| 467 | - } |
|
| 468 | - ?> |
|
| 459 | + settings_fields( 'wp-font-awesome-settings' ); |
|
| 460 | + do_settings_sections( 'wp-font-awesome-settings' ); |
|
| 461 | + $table_class = ''; |
|
| 462 | + if ( $this->settings['type'] ) { |
|
| 463 | + $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set'; |
|
| 464 | + } |
|
| 465 | + if ( ! empty( $this->settings['pro'] ) ) { |
|
| 466 | + $table_class .= ' wpfas-has-pro'; |
|
| 467 | + } |
|
| 468 | + ?> |
|
| 469 | 469 | <?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?> |
| 470 | 470 | <?php if ( $this->has_local() ) { ?> |
| 471 | 471 | <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'font-awesome-settings' ); ?></strong></p></div> |
@@ -490,12 +490,12 @@ discard block |
||
| 490 | 490 | <td> |
| 491 | 491 | <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/> |
| 492 | 492 | <span><?php |
| 493 | - echo sprintf( |
|
| 494 | - __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
| 495 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
|
| 496 | - '</a>' |
|
| 497 | - ); |
|
| 498 | - ?></span> |
|
| 493 | + echo sprintf( |
|
| 494 | + __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
| 495 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
|
| 496 | + '</a>' |
|
| 497 | + ); |
|
| 498 | + ?></span> |
|
| 499 | 499 | </td> |
| 500 | 500 | </tr> |
| 501 | 501 | |
@@ -536,14 +536,14 @@ discard block |
||
| 536 | 536 | <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/> |
| 537 | 537 | <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/> |
| 538 | 538 | <span><?php |
| 539 | - echo wp_sprintf( |
|
| 540 | - __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
| 541 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">', |
|
| 542 | - ' <i class="fas fa-external-link-alt"></i></a>', |
|
| 543 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">', |
|
| 544 | - ' <i class="fas fa-external-link-alt"></i></a>' |
|
| 545 | - ); |
|
| 546 | - ?></span> |
|
| 539 | + echo wp_sprintf( |
|
| 540 | + __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
| 541 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">', |
|
| 542 | + ' <i class="fas fa-external-link-alt"></i></a>', |
|
| 543 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">', |
|
| 544 | + ' <i class="fas fa-external-link-alt"></i></a>' |
|
| 545 | + ); |
|
| 546 | + ?></span> |
|
| 547 | 547 | </td> |
| 548 | 548 | </tr> |
| 549 | 549 | |
@@ -597,8 +597,8 @@ discard block |
||
| 597 | 597 | </table> |
| 598 | 598 | <div class="fas-buttons"> |
| 599 | 599 | <?php |
| 600 | - submit_button(); |
|
| 601 | - ?> |
|
| 600 | + submit_button(); |
|
| 601 | + ?> |
|
| 602 | 602 | <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 24,000+ more icons with Font Awesome Pro','font-awesome-settings'); ?> <i class="fas fa-external-link-alt"></i></a></p> |
| 603 | 603 | |
| 604 | 604 | </div> |
@@ -607,392 +607,392 @@ discard block |
||
| 607 | 607 | <div id="wpfas-version"><?php echo sprintf(__( 'Version: %s (affiliate links provided)', 'font-awesome-settings' ), $this->version ); ?></div> |
| 608 | 608 | </div> |
| 609 | 609 | <?php |
| 610 | - } |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - /** |
|
| 614 | - * Check a version number is valid and if so return it or else return an empty string. |
|
| 615 | - * |
|
| 616 | - * @param $version string The version number to check. |
|
| 617 | - * |
|
| 618 | - * @since 1.0.6 |
|
| 619 | - * |
|
| 620 | - * @return string Either a valid version number or an empty string. |
|
| 621 | - */ |
|
| 622 | - public function validate_version_number( $version ) { |
|
| 623 | - |
|
| 624 | - if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
| 625 | - // valid |
|
| 626 | - } else { |
|
| 627 | - $version = '';// not validated |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - return $version; |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - |
|
| 634 | - /** |
|
| 635 | - * Get the latest version of Font Awesome. |
|
| 636 | - * |
|
| 637 | - * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours. |
|
| 638 | - * |
|
| 639 | - * @since 1.0.7 |
|
| 640 | - * @return mixed|string The latest version number found. |
|
| 641 | - */ |
|
| 642 | - public function get_latest_version( $force_api = false ) { |
|
| 643 | - $latest_version = $this->latest; |
|
| 644 | - |
|
| 645 | - $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
| 646 | - |
|
| 647 | - if ( $cache === false || $force_api ) { // its not set |
|
| 648 | - $api_ver = $this->get_latest_version_from_api(); |
|
| 649 | - if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
| 650 | - $latest_version = $api_ver; |
|
| 651 | - set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
| 652 | - } |
|
| 653 | - } elseif ( $this->validate_version_number( $cache ) ) { |
|
| 654 | - if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
| 655 | - $latest_version = $cache; |
|
| 656 | - } |
|
| 657 | - } |
|
| 658 | - |
|
| 659 | - // Check and auto download fonts locally. |
|
| 660 | - if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) { |
|
| 661 | - if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) { |
|
| 662 | - $this->download_package( $latest_version ); |
|
| 663 | - } |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - return $latest_version; |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - /** |
|
| 670 | - * Get the latest Font Awesome version from the github API. |
|
| 671 | - * |
|
| 672 | - * @since 1.0.7 |
|
| 673 | - * @return string The latest version number or `0` on API fail. |
|
| 674 | - */ |
|
| 675 | - public function get_latest_version_from_api() { |
|
| 676 | - $version = "0"; |
|
| 677 | - $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
| 678 | - if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
| 679 | - $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 680 | - if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
| 681 | - $version = $api_response['tag_name']; |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - |
|
| 685 | - return $version; |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - /** |
|
| 689 | - * Inline CSS for RTL language support. |
|
| 690 | - * |
|
| 691 | - * @since 1.0.13 |
|
| 692 | - * @return string Inline CSS. |
|
| 693 | - */ |
|
| 694 | - public function rtl_inline_css() { |
|
| 695 | - $inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}'; |
|
| 696 | - |
|
| 697 | - return $inline_css; |
|
| 698 | - } |
|
| 699 | - |
|
| 700 | - /** |
|
| 701 | - * Show any warnings as an admin notice. |
|
| 702 | - * |
|
| 703 | - * @return void |
|
| 704 | - */ |
|
| 705 | - public function admin_notices() { |
|
| 706 | - $settings = $this->settings; |
|
| 707 | - |
|
| 708 | - if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
| 709 | - if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) { |
|
| 710 | - ?> |
|
| 610 | + } |
|
| 611 | + } |
|
| 612 | + |
|
| 613 | + /** |
|
| 614 | + * Check a version number is valid and if so return it or else return an empty string. |
|
| 615 | + * |
|
| 616 | + * @param $version string The version number to check. |
|
| 617 | + * |
|
| 618 | + * @since 1.0.6 |
|
| 619 | + * |
|
| 620 | + * @return string Either a valid version number or an empty string. |
|
| 621 | + */ |
|
| 622 | + public function validate_version_number( $version ) { |
|
| 623 | + |
|
| 624 | + if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
| 625 | + // valid |
|
| 626 | + } else { |
|
| 627 | + $version = '';// not validated |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + return $version; |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + |
|
| 634 | + /** |
|
| 635 | + * Get the latest version of Font Awesome. |
|
| 636 | + * |
|
| 637 | + * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours. |
|
| 638 | + * |
|
| 639 | + * @since 1.0.7 |
|
| 640 | + * @return mixed|string The latest version number found. |
|
| 641 | + */ |
|
| 642 | + public function get_latest_version( $force_api = false ) { |
|
| 643 | + $latest_version = $this->latest; |
|
| 644 | + |
|
| 645 | + $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
| 646 | + |
|
| 647 | + if ( $cache === false || $force_api ) { // its not set |
|
| 648 | + $api_ver = $this->get_latest_version_from_api(); |
|
| 649 | + if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
| 650 | + $latest_version = $api_ver; |
|
| 651 | + set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
| 652 | + } |
|
| 653 | + } elseif ( $this->validate_version_number( $cache ) ) { |
|
| 654 | + if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
| 655 | + $latest_version = $cache; |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + // Check and auto download fonts locally. |
|
| 660 | + if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) { |
|
| 661 | + if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) { |
|
| 662 | + $this->download_package( $latest_version ); |
|
| 663 | + } |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + return $latest_version; |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + /** |
|
| 670 | + * Get the latest Font Awesome version from the github API. |
|
| 671 | + * |
|
| 672 | + * @since 1.0.7 |
|
| 673 | + * @return string The latest version number or `0` on API fail. |
|
| 674 | + */ |
|
| 675 | + public function get_latest_version_from_api() { |
|
| 676 | + $version = "0"; |
|
| 677 | + $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
| 678 | + if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
| 679 | + $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 680 | + if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
| 681 | + $version = $api_response['tag_name']; |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + |
|
| 685 | + return $version; |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + /** |
|
| 689 | + * Inline CSS for RTL language support. |
|
| 690 | + * |
|
| 691 | + * @since 1.0.13 |
|
| 692 | + * @return string Inline CSS. |
|
| 693 | + */ |
|
| 694 | + public function rtl_inline_css() { |
|
| 695 | + $inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}'; |
|
| 696 | + |
|
| 697 | + return $inline_css; |
|
| 698 | + } |
|
| 699 | + |
|
| 700 | + /** |
|
| 701 | + * Show any warnings as an admin notice. |
|
| 702 | + * |
|
| 703 | + * @return void |
|
| 704 | + */ |
|
| 705 | + public function admin_notices() { |
|
| 706 | + $settings = $this->settings; |
|
| 707 | + |
|
| 708 | + if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
| 709 | + if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) { |
|
| 710 | + ?> |
|
| 711 | 711 | <div class="notice notice-error is-dismissible"> |
| 712 | 712 | <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'font-awesome-settings' ); ?></p> |
| 713 | 713 | </div> |
| 714 | 714 | <?php |
| 715 | - } |
|
| 716 | - } else { |
|
| 717 | - if ( ! empty( $settings ) ) { |
|
| 718 | - if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) { |
|
| 719 | - $link = admin_url('options-general.php?page=wp-font-awesome-settings'); |
|
| 720 | - ?> |
|
| 715 | + } |
|
| 716 | + } else { |
|
| 717 | + if ( ! empty( $settings ) ) { |
|
| 718 | + if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) { |
|
| 719 | + $link = admin_url('options-general.php?page=wp-font-awesome-settings'); |
|
| 720 | + ?> |
|
| 721 | 721 | <div class="notice notice-error is-dismissible"> |
| 722 | 722 | <p><?php echo sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'font-awesome-settings' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p> |
| 723 | 723 | </div> |
| 724 | 724 | <?php |
| 725 | - } |
|
| 726 | - } |
|
| 727 | - } |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * Handle fontawesome add settings to download fontawesome to store locally. |
|
| 732 | - * |
|
| 733 | - * @since 1.1.1 |
|
| 734 | - * |
|
| 735 | - * @param string $option The option name. |
|
| 736 | - * @param mixed $value The option value. |
|
| 737 | - */ |
|
| 738 | - public function add_option_wp_font_awesome_settings( $option, $value ) { |
|
| 739 | - // Do nothing if WordPress is being installed. |
|
| 740 | - if ( wp_installing() ) { |
|
| 741 | - return; |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) { |
|
| 745 | - $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version(); |
|
| 746 | - |
|
| 747 | - if ( ! empty( $version ) ) { |
|
| 748 | - $response = $this->download_package( $version, $value ); |
|
| 749 | - |
|
| 750 | - if ( is_wp_error( $response ) ) { |
|
| 751 | - add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'font-awesome-settings' ) . ' ' . $response->get_error_message(), 'error' ); |
|
| 752 | - } |
|
| 753 | - } |
|
| 754 | - } |
|
| 755 | - } |
|
| 756 | - |
|
| 757 | - /** |
|
| 758 | - * Handle fontawesome update settings to download fontawesome to store locally. |
|
| 759 | - * |
|
| 760 | - * @since 1.1.0 |
|
| 761 | - * |
|
| 762 | - * @param mixed $old_value The old option value. |
|
| 763 | - * @param mixed $value The new option value. |
|
| 764 | - */ |
|
| 765 | - public function update_option_wp_font_awesome_settings( $old_value, $new_value ) { |
|
| 766 | - // Do nothing if WordPress is being installed. |
|
| 767 | - if ( wp_installing() ) { |
|
| 768 | - return; |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) { |
|
| 772 | - // Old values |
|
| 773 | - $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' ); |
|
| 774 | - $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0; |
|
| 775 | - |
|
| 776 | - // New values |
|
| 777 | - $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version(); |
|
| 778 | - |
|
| 779 | - if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) { |
|
| 780 | - $response = $this->download_package( $new_version, $new_value ); |
|
| 781 | - |
|
| 782 | - if ( is_wp_error( $response ) ) { |
|
| 783 | - add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'font-awesome-settings' ) . ' ' . $response->get_error_message(), 'error' ); |
|
| 784 | - } |
|
| 785 | - } |
|
| 786 | - } |
|
| 787 | - } |
|
| 788 | - |
|
| 789 | - /** |
|
| 790 | - * Get the fonts directory local path. |
|
| 791 | - * |
|
| 792 | - * @since 1.1.0 |
|
| 793 | - * |
|
| 794 | - * @param string Fonts directory local path. |
|
| 795 | - */ |
|
| 796 | - public function get_fonts_dir() { |
|
| 797 | - $upload_dir = wp_upload_dir( null, false ); |
|
| 798 | - |
|
| 799 | - return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR; |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - /** |
|
| 803 | - * Get the fonts directory local url. |
|
| 804 | - * |
|
| 805 | - * @since 1.1.0 |
|
| 806 | - * |
|
| 807 | - * @param string Fonts directory local url. |
|
| 808 | - */ |
|
| 809 | - public function get_fonts_url() { |
|
| 810 | - $upload_dir = wp_upload_dir( null, false ); |
|
| 811 | - |
|
| 812 | - return $upload_dir['baseurl'] . '/ayefonts/fa/'; |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - /** |
|
| 816 | - * Check whether load locally active. |
|
| 817 | - * |
|
| 818 | - * @since 1.1.0 |
|
| 819 | - * |
|
| 820 | - * @return bool True if active else false. |
|
| 821 | - */ |
|
| 822 | - public function has_local() { |
|
| 823 | - if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) { |
|
| 824 | - return true; |
|
| 825 | - } |
|
| 826 | - |
|
| 827 | - return false; |
|
| 828 | - } |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * Get the WP Filesystem access. |
|
| 832 | - * |
|
| 833 | - * @since 1.1.0 |
|
| 834 | - * |
|
| 835 | - * @return object The WP Filesystem. |
|
| 836 | - */ |
|
| 837 | - public function get_wp_filesystem() { |
|
| 838 | - if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
| 839 | - require_once( ABSPATH . "/wp-admin/includes/file.php" ); |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - $access_type = get_filesystem_method(); |
|
| 843 | - |
|
| 844 | - if ( $access_type === 'direct' ) { |
|
| 845 | - /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 846 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
| 847 | - |
|
| 848 | - /* Initialize the API */ |
|
| 849 | - if ( ! WP_Filesystem( $creds ) ) { |
|
| 850 | - /* Any problems and we exit */ |
|
| 851 | - return false; |
|
| 852 | - } |
|
| 853 | - |
|
| 854 | - global $wp_filesystem; |
|
| 855 | - |
|
| 856 | - return $wp_filesystem; |
|
| 857 | - /* Do our file manipulations below */ |
|
| 858 | - } else if ( defined( 'FTP_USER' ) ) { |
|
| 859 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
| 860 | - |
|
| 861 | - /* Initialize the API */ |
|
| 862 | - if ( ! WP_Filesystem( $creds ) ) { |
|
| 863 | - /* Any problems and we exit */ |
|
| 864 | - return false; |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - global $wp_filesystem; |
|
| 868 | - |
|
| 869 | - return $wp_filesystem; |
|
| 870 | - } else { |
|
| 871 | - /* Don't have direct write access. Prompt user with our notice */ |
|
| 872 | - return false; |
|
| 873 | - } |
|
| 874 | - } |
|
| 875 | - |
|
| 876 | - /** |
|
| 877 | - * Download the fontawesome package file. |
|
| 878 | - * |
|
| 879 | - * @since 1.1.0 |
|
| 880 | - * |
|
| 881 | - * @param mixed $version The font awesome. |
|
| 882 | - * @param array $option Fontawesome settings. |
|
| 883 | - * @return WP_ERROR|bool Error on fail and true on success. |
|
| 884 | - */ |
|
| 885 | - public function download_package( $version, $option = array() ) { |
|
| 886 | - $filename = 'fontawesome-free-' . $version . '-web'; |
|
| 887 | - $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip'; |
|
| 888 | - |
|
| 889 | - if ( ! function_exists( 'wp_handle_upload' ) ) { |
|
| 890 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
| 891 | - } |
|
| 892 | - |
|
| 893 | - $download_file = download_url( esc_url_raw( $url ) ); |
|
| 894 | - |
|
| 895 | - if ( is_wp_error( $download_file ) ) { |
|
| 896 | - return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'font-awesome-settings' ) ); |
|
| 897 | - } else if ( empty( $download_file ) ) { |
|
| 898 | - return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'font-awesome-settings' ) ); |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - $response = $this->extract_package( $download_file, $filename, true ); |
|
| 902 | - |
|
| 903 | - // Update local version. |
|
| 904 | - if ( is_wp_error( $response ) ) { |
|
| 905 | - return $response; |
|
| 906 | - } else if ( $response ) { |
|
| 907 | - if ( empty( $option ) ) { |
|
| 908 | - $option = get_option( 'wp-font-awesome-settings' ); |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - $option['local_version'] = $version; |
|
| 912 | - |
|
| 913 | - // Remove action to prevent looping. |
|
| 914 | - remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 ); |
|
| 915 | - |
|
| 916 | - update_option( 'wp-font-awesome-settings', $option ); |
|
| 917 | - |
|
| 918 | - return true; |
|
| 919 | - } |
|
| 920 | - |
|
| 921 | - return false; |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - /** |
|
| 925 | - * Extract the fontawesome package file. |
|
| 926 | - * |
|
| 927 | - * @since 1.1.0 |
|
| 928 | - * |
|
| 929 | - * @param string $package The package file path. |
|
| 930 | - * @param string $dirname Package file name. |
|
| 931 | - * @param bool $delete_package Delete temp file or not. |
|
| 932 | - * @return WP_Error|bool True on success WP_Error on fail. |
|
| 933 | - */ |
|
| 934 | - public function extract_package( $package, $dirname = '', $delete_package = false ) { |
|
| 935 | - global $wp_filesystem; |
|
| 936 | - |
|
| 937 | - $wp_filesystem = $this->get_wp_filesystem(); |
|
| 938 | - |
|
| 939 | - if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
| 940 | - return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'font-awesome-settings' ) ); |
|
| 941 | - } else if ( empty( $wp_filesystem ) ) { |
|
| 942 | - return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'font-awesome-settings' ) ); |
|
| 943 | - } |
|
| 944 | - |
|
| 945 | - $fonts_dir = $this->get_fonts_dir(); |
|
| 946 | - $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR; |
|
| 947 | - |
|
| 948 | - if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) { |
|
| 949 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - // Unzip package to working directory. |
|
| 953 | - $result = unzip_file( $package, $fonts_tmp_dir ); |
|
| 954 | - |
|
| 955 | - if ( is_wp_error( $result ) ) { |
|
| 956 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
| 957 | - |
|
| 958 | - if ( 'incompatible_archive' === $result->get_error_code() ) { |
|
| 959 | - return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'font-awesome-settings' ) ); |
|
| 960 | - } |
|
| 961 | - |
|
| 962 | - return $result; |
|
| 963 | - } |
|
| 964 | - |
|
| 965 | - if ( $wp_filesystem->is_dir( $fonts_dir ) ) { |
|
| 966 | - $wp_filesystem->delete( $fonts_dir, true ); |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - $extract_dir = $fonts_tmp_dir; |
|
| 970 | - |
|
| 971 | - if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) { |
|
| 972 | - $extract_dir .= $dirname . DIRECTORY_SEPARATOR; |
|
| 973 | - } |
|
| 974 | - |
|
| 975 | - try { |
|
| 976 | - $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true ); |
|
| 977 | - } catch ( Exception $e ) { |
|
| 978 | - $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'font-awesome-settings' ) ); |
|
| 979 | - } |
|
| 980 | - |
|
| 981 | - if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) { |
|
| 982 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
| 983 | - } |
|
| 984 | - |
|
| 985 | - // Once extracted, delete the package if required. |
|
| 986 | - if ( $delete_package ) { |
|
| 987 | - unlink( $package ); |
|
| 988 | - } |
|
| 989 | - |
|
| 990 | - return $return; |
|
| 991 | - } |
|
| 992 | - } |
|
| 993 | - |
|
| 994 | - /** |
|
| 995 | - * Run the class if found. |
|
| 996 | - */ |
|
| 997 | - WP_Font_Awesome_Settings::instance(); |
|
| 725 | + } |
|
| 726 | + } |
|
| 727 | + } |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * Handle fontawesome add settings to download fontawesome to store locally. |
|
| 732 | + * |
|
| 733 | + * @since 1.1.1 |
|
| 734 | + * |
|
| 735 | + * @param string $option The option name. |
|
| 736 | + * @param mixed $value The option value. |
|
| 737 | + */ |
|
| 738 | + public function add_option_wp_font_awesome_settings( $option, $value ) { |
|
| 739 | + // Do nothing if WordPress is being installed. |
|
| 740 | + if ( wp_installing() ) { |
|
| 741 | + return; |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) { |
|
| 745 | + $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version(); |
|
| 746 | + |
|
| 747 | + if ( ! empty( $version ) ) { |
|
| 748 | + $response = $this->download_package( $version, $value ); |
|
| 749 | + |
|
| 750 | + if ( is_wp_error( $response ) ) { |
|
| 751 | + add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'font-awesome-settings' ) . ' ' . $response->get_error_message(), 'error' ); |
|
| 752 | + } |
|
| 753 | + } |
|
| 754 | + } |
|
| 755 | + } |
|
| 756 | + |
|
| 757 | + /** |
|
| 758 | + * Handle fontawesome update settings to download fontawesome to store locally. |
|
| 759 | + * |
|
| 760 | + * @since 1.1.0 |
|
| 761 | + * |
|
| 762 | + * @param mixed $old_value The old option value. |
|
| 763 | + * @param mixed $value The new option value. |
|
| 764 | + */ |
|
| 765 | + public function update_option_wp_font_awesome_settings( $old_value, $new_value ) { |
|
| 766 | + // Do nothing if WordPress is being installed. |
|
| 767 | + if ( wp_installing() ) { |
|
| 768 | + return; |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) { |
|
| 772 | + // Old values |
|
| 773 | + $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' ); |
|
| 774 | + $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0; |
|
| 775 | + |
|
| 776 | + // New values |
|
| 777 | + $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version(); |
|
| 778 | + |
|
| 779 | + if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) { |
|
| 780 | + $response = $this->download_package( $new_version, $new_value ); |
|
| 781 | + |
|
| 782 | + if ( is_wp_error( $response ) ) { |
|
| 783 | + add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'font-awesome-settings' ) . ' ' . $response->get_error_message(), 'error' ); |
|
| 784 | + } |
|
| 785 | + } |
|
| 786 | + } |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * Get the fonts directory local path. |
|
| 791 | + * |
|
| 792 | + * @since 1.1.0 |
|
| 793 | + * |
|
| 794 | + * @param string Fonts directory local path. |
|
| 795 | + */ |
|
| 796 | + public function get_fonts_dir() { |
|
| 797 | + $upload_dir = wp_upload_dir( null, false ); |
|
| 798 | + |
|
| 799 | + return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR; |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + /** |
|
| 803 | + * Get the fonts directory local url. |
|
| 804 | + * |
|
| 805 | + * @since 1.1.0 |
|
| 806 | + * |
|
| 807 | + * @param string Fonts directory local url. |
|
| 808 | + */ |
|
| 809 | + public function get_fonts_url() { |
|
| 810 | + $upload_dir = wp_upload_dir( null, false ); |
|
| 811 | + |
|
| 812 | + return $upload_dir['baseurl'] . '/ayefonts/fa/'; |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + /** |
|
| 816 | + * Check whether load locally active. |
|
| 817 | + * |
|
| 818 | + * @since 1.1.0 |
|
| 819 | + * |
|
| 820 | + * @return bool True if active else false. |
|
| 821 | + */ |
|
| 822 | + public function has_local() { |
|
| 823 | + if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) { |
|
| 824 | + return true; |
|
| 825 | + } |
|
| 826 | + |
|
| 827 | + return false; |
|
| 828 | + } |
|
| 829 | + |
|
| 830 | + /** |
|
| 831 | + * Get the WP Filesystem access. |
|
| 832 | + * |
|
| 833 | + * @since 1.1.0 |
|
| 834 | + * |
|
| 835 | + * @return object The WP Filesystem. |
|
| 836 | + */ |
|
| 837 | + public function get_wp_filesystem() { |
|
| 838 | + if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
| 839 | + require_once( ABSPATH . "/wp-admin/includes/file.php" ); |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + $access_type = get_filesystem_method(); |
|
| 843 | + |
|
| 844 | + if ( $access_type === 'direct' ) { |
|
| 845 | + /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 846 | + $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
| 847 | + |
|
| 848 | + /* Initialize the API */ |
|
| 849 | + if ( ! WP_Filesystem( $creds ) ) { |
|
| 850 | + /* Any problems and we exit */ |
|
| 851 | + return false; |
|
| 852 | + } |
|
| 853 | + |
|
| 854 | + global $wp_filesystem; |
|
| 855 | + |
|
| 856 | + return $wp_filesystem; |
|
| 857 | + /* Do our file manipulations below */ |
|
| 858 | + } else if ( defined( 'FTP_USER' ) ) { |
|
| 859 | + $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
| 860 | + |
|
| 861 | + /* Initialize the API */ |
|
| 862 | + if ( ! WP_Filesystem( $creds ) ) { |
|
| 863 | + /* Any problems and we exit */ |
|
| 864 | + return false; |
|
| 865 | + } |
|
| 866 | + |
|
| 867 | + global $wp_filesystem; |
|
| 868 | + |
|
| 869 | + return $wp_filesystem; |
|
| 870 | + } else { |
|
| 871 | + /* Don't have direct write access. Prompt user with our notice */ |
|
| 872 | + return false; |
|
| 873 | + } |
|
| 874 | + } |
|
| 875 | + |
|
| 876 | + /** |
|
| 877 | + * Download the fontawesome package file. |
|
| 878 | + * |
|
| 879 | + * @since 1.1.0 |
|
| 880 | + * |
|
| 881 | + * @param mixed $version The font awesome. |
|
| 882 | + * @param array $option Fontawesome settings. |
|
| 883 | + * @return WP_ERROR|bool Error on fail and true on success. |
|
| 884 | + */ |
|
| 885 | + public function download_package( $version, $option = array() ) { |
|
| 886 | + $filename = 'fontawesome-free-' . $version . '-web'; |
|
| 887 | + $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip'; |
|
| 888 | + |
|
| 889 | + if ( ! function_exists( 'wp_handle_upload' ) ) { |
|
| 890 | + require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
| 891 | + } |
|
| 892 | + |
|
| 893 | + $download_file = download_url( esc_url_raw( $url ) ); |
|
| 894 | + |
|
| 895 | + if ( is_wp_error( $download_file ) ) { |
|
| 896 | + return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'font-awesome-settings' ) ); |
|
| 897 | + } else if ( empty( $download_file ) ) { |
|
| 898 | + return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'font-awesome-settings' ) ); |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + $response = $this->extract_package( $download_file, $filename, true ); |
|
| 902 | + |
|
| 903 | + // Update local version. |
|
| 904 | + if ( is_wp_error( $response ) ) { |
|
| 905 | + return $response; |
|
| 906 | + } else if ( $response ) { |
|
| 907 | + if ( empty( $option ) ) { |
|
| 908 | + $option = get_option( 'wp-font-awesome-settings' ); |
|
| 909 | + } |
|
| 910 | + |
|
| 911 | + $option['local_version'] = $version; |
|
| 912 | + |
|
| 913 | + // Remove action to prevent looping. |
|
| 914 | + remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 ); |
|
| 915 | + |
|
| 916 | + update_option( 'wp-font-awesome-settings', $option ); |
|
| 917 | + |
|
| 918 | + return true; |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + return false; |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + /** |
|
| 925 | + * Extract the fontawesome package file. |
|
| 926 | + * |
|
| 927 | + * @since 1.1.0 |
|
| 928 | + * |
|
| 929 | + * @param string $package The package file path. |
|
| 930 | + * @param string $dirname Package file name. |
|
| 931 | + * @param bool $delete_package Delete temp file or not. |
|
| 932 | + * @return WP_Error|bool True on success WP_Error on fail. |
|
| 933 | + */ |
|
| 934 | + public function extract_package( $package, $dirname = '', $delete_package = false ) { |
|
| 935 | + global $wp_filesystem; |
|
| 936 | + |
|
| 937 | + $wp_filesystem = $this->get_wp_filesystem(); |
|
| 938 | + |
|
| 939 | + if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
| 940 | + return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'font-awesome-settings' ) ); |
|
| 941 | + } else if ( empty( $wp_filesystem ) ) { |
|
| 942 | + return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'font-awesome-settings' ) ); |
|
| 943 | + } |
|
| 944 | + |
|
| 945 | + $fonts_dir = $this->get_fonts_dir(); |
|
| 946 | + $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR; |
|
| 947 | + |
|
| 948 | + if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) { |
|
| 949 | + $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + // Unzip package to working directory. |
|
| 953 | + $result = unzip_file( $package, $fonts_tmp_dir ); |
|
| 954 | + |
|
| 955 | + if ( is_wp_error( $result ) ) { |
|
| 956 | + $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
| 957 | + |
|
| 958 | + if ( 'incompatible_archive' === $result->get_error_code() ) { |
|
| 959 | + return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'font-awesome-settings' ) ); |
|
| 960 | + } |
|
| 961 | + |
|
| 962 | + return $result; |
|
| 963 | + } |
|
| 964 | + |
|
| 965 | + if ( $wp_filesystem->is_dir( $fonts_dir ) ) { |
|
| 966 | + $wp_filesystem->delete( $fonts_dir, true ); |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + $extract_dir = $fonts_tmp_dir; |
|
| 970 | + |
|
| 971 | + if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) { |
|
| 972 | + $extract_dir .= $dirname . DIRECTORY_SEPARATOR; |
|
| 973 | + } |
|
| 974 | + |
|
| 975 | + try { |
|
| 976 | + $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true ); |
|
| 977 | + } catch ( Exception $e ) { |
|
| 978 | + $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'font-awesome-settings' ) ); |
|
| 979 | + } |
|
| 980 | + |
|
| 981 | + if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) { |
|
| 982 | + $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + // Once extracted, delete the package if required. |
|
| 986 | + if ( $delete_package ) { |
|
| 987 | + unlink( $package ); |
|
| 988 | + } |
|
| 989 | + |
|
| 990 | + return $return; |
|
| 991 | + } |
|
| 992 | + } |
|
| 993 | + |
|
| 994 | + /** |
|
| 995 | + * Run the class if found. |
|
| 996 | + */ |
|
| 997 | + WP_Font_Awesome_Settings::instance(); |
|
| 998 | 998 | } |
@@ -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 | } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) && wpinv_current_user_can( 'activate_discount', array( 'discount' => (int) $discount->ID ) ) ) { |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | 'getpaid-nonce', |
| 74 | 74 | 'getpaid-nonce' |
| 75 | 75 | ); |
| 76 | - $anchor = __( 'Activate', 'invoicing' ); |
|
| 77 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 76 | + $anchor = __( 'Activate', 'invoicing' ); |
|
| 77 | + $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
| 78 | 78 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 79 | 79 | |
| 80 | 80 | } |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | $types = wpinv_get_discount_types(); |
| 122 | 122 | |
| 123 | 123 | foreach ( $types as $name => $type ) { |
| 124 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 124 | + echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 125 | 125 | |
| 126 | - if ( isset( $_GET['discount_type'] ) ) { |
|
| 127 | - selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
| 126 | + if ( isset( $_GET['discount_type'] ) ) { |
|
| 127 | + selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 130 | + echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 131 | 131 | } |
| 132 | 132 | ?> |
| 133 | 133 | </select> |
@@ -154,15 +154,15 @@ discard block |
||
| 154 | 154 | // Filter vat rule type |
| 155 | 155 | if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
| 156 | 156 | $meta_query[] = array( |
| 157 | - 'key' => '_wpi_discount_type', |
|
| 158 | - 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
| 159 | - 'compare' => '=', |
|
| 160 | - ); |
|
| 161 | - } |
|
| 157 | + 'key' => '_wpi_discount_type', |
|
| 158 | + 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
| 159 | + 'compare' => '=', |
|
| 160 | + ); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | if ( ! empty( $meta_query ) ) { |
| 164 | 164 | $vars['meta_query'] = $meta_query; |
| 165 | - } |
|
| 165 | + } |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | return $vars; |