@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class OxidInstaller extends BaseInstaller |
| 7 | 7 | { |
| 8 | - const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
| 8 | + const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
| 9 | 9 | |
| 10 | 10 | protected $locations = array( |
| 11 | 11 | 'module' => 'modules/{$name}/', |
@@ -13,47 +13,47 @@ discard block |
||
| 13 | 13 | 'out' => 'out/{$name}/', |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * getInstallPath |
|
| 18 | - * |
|
| 19 | - * @param PackageInterface $package |
|
| 20 | - * @param string $frameworkType |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
| 24 | - { |
|
| 25 | - $installPath = parent::getInstallPath($package, $frameworkType); |
|
| 26 | - $type = $this->package->getType(); |
|
| 27 | - if ($type === 'oxid-module') { |
|
| 28 | - $this->prepareVendorDirectory($installPath); |
|
| 29 | - } |
|
| 30 | - return $installPath; |
|
| 31 | - } |
|
| 16 | + /** |
|
| 17 | + * getInstallPath |
|
| 18 | + * |
|
| 19 | + * @param PackageInterface $package |
|
| 20 | + * @param string $frameworkType |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
| 24 | + { |
|
| 25 | + $installPath = parent::getInstallPath($package, $frameworkType); |
|
| 26 | + $type = $this->package->getType(); |
|
| 27 | + if ($type === 'oxid-module') { |
|
| 28 | + $this->prepareVendorDirectory($installPath); |
|
| 29 | + } |
|
| 30 | + return $installPath; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * prepareVendorDirectory |
|
| 35 | - * |
|
| 36 | - * Makes sure there is a vendormetadata.php file inside |
|
| 37 | - * the vendor folder if there is a vendor folder. |
|
| 38 | - * |
|
| 39 | - * @param string $installPath |
|
| 40 | - * @return void |
|
| 41 | - */ |
|
| 42 | - protected function prepareVendorDirectory($installPath) |
|
| 43 | - { |
|
| 44 | - $matches = ''; |
|
| 45 | - $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
| 46 | - if (!$hasVendorDirectory) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 33 | + /** |
|
| 34 | + * prepareVendorDirectory |
|
| 35 | + * |
|
| 36 | + * Makes sure there is a vendormetadata.php file inside |
|
| 37 | + * the vendor folder if there is a vendor folder. |
|
| 38 | + * |
|
| 39 | + * @param string $installPath |
|
| 40 | + * @return void |
|
| 41 | + */ |
|
| 42 | + protected function prepareVendorDirectory($installPath) |
|
| 43 | + { |
|
| 44 | + $matches = ''; |
|
| 45 | + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
| 46 | + if (!$hasVendorDirectory) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $vendorDirectory = $matches['vendor']; |
|
| 51 | - $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
| 52 | - if (!file_exists($vendorPath)) { |
|
| 53 | - mkdir($vendorPath, 0755, true); |
|
| 54 | - } |
|
| 50 | + $vendorDirectory = $matches['vendor']; |
|
| 51 | + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
| 52 | + if (!file_exists($vendorPath)) { |
|
| 53 | + mkdir($vendorPath, 0755, true); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
| 57 | - touch($vendorMetaDataPath); |
|
| 58 | - } |
|
| 56 | + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
| 57 | + touch($vendorMetaDataPath); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | |
| 4 | 4 | class ClanCatsFrameworkInstaller extends BaseInstaller |
| 5 | 5 | { |
| 6 | - protected $locations = array( |
|
| 7 | - 'ship' => 'CCF/orbit/{$name}/', |
|
| 8 | - 'theme' => 'CCF/app/themes/{$name}/', |
|
| 9 | - ); |
|
| 6 | + protected $locations = array( |
|
| 7 | + 'ship' => 'CCF/orbit/{$name}/', |
|
| 8 | + 'theme' => 'CCF/app/themes/{$name}/', |
|
| 9 | + ); |
|
| 10 | 10 | } |
| 11 | 11 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | 'library' => 'libraries/{$name}/', |
| 11 | 11 | 'profile' => 'profiles/{$name}/', |
| 12 | 12 | 'drush' => 'drush/{$name}/', |
| 13 | - 'custom-theme' => 'themes/custom/{$name}/', |
|
| 14 | - 'custom-module' => 'modules/custom/{$name}/', |
|
| 13 | + 'custom-theme' => 'themes/custom/{$name}/', |
|
| 14 | + 'custom-module' => 'modules/custom/{$name}/', |
|
| 15 | 15 | ); |
| 16 | 16 | } |
@@ -799,7 +799,7 @@ |
||
| 799 | 799 | case 'trial_interval': |
| 800 | 800 | $value = absint( $value ); |
| 801 | 801 | break; |
| 802 | - case 'editable': |
|
| 802 | + case 'editable': |
|
| 803 | 803 | $value = (int) $value; |
| 804 | 804 | break; |
| 805 | 805 | } |
@@ -30,36 +30,36 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function wpinv_can_checkout() { |
| 33 | - $can_checkout = true; // Always true for now |
|
| 33 | + $can_checkout = true; // Always true for now |
|
| 34 | 34 | |
| 35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 35 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function wpinv_get_success_page_uri() { |
| 39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | - $page_id = absint( $page_id ); |
|
| 39 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | + $page_id = absint( $page_id ); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 42 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function wpinv_get_history_page_uri() { |
| 46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | - $page_id = absint( $page_id ); |
|
| 46 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | + $page_id = absint( $page_id ); |
|
| 48 | 48 | |
| 49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 49 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function wpinv_is_success_page() { |
| 53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 53 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 56 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function wpinv_is_invoice_history_page() { |
| 60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | - $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 60 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | + $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function wpinv_is_subscriptions_history_page() { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | function wpinv_send_to_success_page( $args = null ) { |
| 72 | - $redirect = wpinv_get_success_page_uri(); |
|
| 72 | + $redirect = wpinv_get_success_page_uri(); |
|
| 73 | 73 | |
| 74 | 74 | if ( !empty( $args ) ) { |
| 75 | 75 | // Check for backward compatibility |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function wpinv_send_to_failed_page( $args = null ) { |
| 92 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
| 92 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
| 93 | 93 | |
| 94 | 94 | if ( !empty( $args ) ) { |
| 95 | 95 | // Check for backward compatibility |
@@ -109,72 +109,72 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | function wpinv_get_checkout_uri( $args = array() ) { |
| 112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 112 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 113 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 114 | 114 | |
| 115 | - if ( !empty( $args ) ) { |
|
| 116 | - // Check for backward compatibility |
|
| 117 | - if ( is_string( $args ) ) |
|
| 118 | - $args = str_replace( '?', '', $args ); |
|
| 115 | + if ( !empty( $args ) ) { |
|
| 116 | + // Check for backward compatibility |
|
| 117 | + if ( is_string( $args ) ) |
|
| 118 | + $args = str_replace( '?', '', $args ); |
|
| 119 | 119 | |
| 120 | - $args = wp_parse_args( $args ); |
|
| 120 | + $args = wp_parse_args( $args ); |
|
| 121 | 121 | |
| 122 | - $uri = add_query_arg( $args, $uri ); |
|
| 123 | - } |
|
| 122 | + $uri = add_query_arg( $args, $uri ); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 125 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 126 | 126 | |
| 127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 127 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 128 | 128 | |
| 129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 131 | - } |
|
| 129 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 130 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 133 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | function wpinv_send_back_to_checkout( $args = array() ) { |
| 137 | - $redirect = wpinv_get_checkout_uri(); |
|
| 137 | + $redirect = wpinv_get_checkout_uri(); |
|
| 138 | 138 | |
| 139 | - if ( ! empty( $args ) ) { |
|
| 140 | - // Check for backward compatibility |
|
| 141 | - if ( is_string( $args ) ) |
|
| 142 | - $args = str_replace( '?', '', $args ); |
|
| 139 | + if ( ! empty( $args ) ) { |
|
| 140 | + // Check for backward compatibility |
|
| 141 | + if ( is_string( $args ) ) |
|
| 142 | + $args = str_replace( '?', '', $args ); |
|
| 143 | 143 | |
| 144 | - $args = wp_parse_args( $args ); |
|
| 144 | + $args = wp_parse_args( $args ); |
|
| 145 | 145 | |
| 146 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 147 | - } |
|
| 146 | + $redirect = add_query_arg( $args, $redirect ); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 150 | - exit; |
|
| 149 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 150 | + exit; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | function wpinv_get_success_page_url( $query_string = null ) { |
| 154 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 155 | - $success_page = get_permalink( $success_page ); |
|
| 154 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 155 | + $success_page = get_permalink( $success_page ); |
|
| 156 | 156 | |
| 157 | - if ( $query_string ) |
|
| 158 | - $success_page .= $query_string; |
|
| 157 | + if ( $query_string ) |
|
| 158 | + $success_page .= $query_string; |
|
| 159 | 159 | |
| 160 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 160 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
| 164 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 165 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 164 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 165 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 166 | 166 | |
| 167 | - if ( $extras ) |
|
| 168 | - $uri .= $extras; |
|
| 167 | + if ( $extras ) |
|
| 168 | + $uri .= $extras; |
|
| 169 | 169 | |
| 170 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 170 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | function wpinv_is_failed_transaction_page() { |
| 174 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
| 175 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 174 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
| 175 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 176 | 176 | |
| 177 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 177 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -320,36 +320,36 @@ discard block |
||
| 320 | 320 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
| 321 | 321 | |
| 322 | 322 | if ( $require_billing_details ) { |
| 323 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
| 324 | - $required_fields['first_name'] = array( |
|
| 325 | - 'error_id' => 'invalid_first_name', |
|
| 326 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
| 327 | - ); |
|
| 328 | - } |
|
| 329 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
| 330 | - $required_fields['address'] = array( |
|
| 331 | - 'error_id' => 'invalid_address', |
|
| 332 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
| 333 | - ); |
|
| 334 | - } |
|
| 335 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
| 336 | - $required_fields['city'] = array( |
|
| 337 | - 'error_id' => 'invalid_city', |
|
| 338 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
| 339 | - ); |
|
| 340 | - } |
|
| 341 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
| 342 | - $required_fields['state'] = array( |
|
| 343 | - 'error_id' => 'invalid_state', |
|
| 344 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
| 345 | - ); |
|
| 346 | - } |
|
| 347 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
| 348 | - $required_fields['country'] = array( |
|
| 349 | - 'error_id' => 'invalid_country', |
|
| 350 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
| 351 | - ); |
|
| 352 | - } |
|
| 323 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
| 324 | + $required_fields['first_name'] = array( |
|
| 325 | + 'error_id' => 'invalid_first_name', |
|
| 326 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
| 327 | + ); |
|
| 328 | + } |
|
| 329 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
| 330 | + $required_fields['address'] = array( |
|
| 331 | + 'error_id' => 'invalid_address', |
|
| 332 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
| 333 | + ); |
|
| 334 | + } |
|
| 335 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
| 336 | + $required_fields['city'] = array( |
|
| 337 | + 'error_id' => 'invalid_city', |
|
| 338 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
| 339 | + ); |
|
| 340 | + } |
|
| 341 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
| 342 | + $required_fields['state'] = array( |
|
| 343 | + 'error_id' => 'invalid_state', |
|
| 344 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
| 345 | + ); |
|
| 346 | + } |
|
| 347 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
| 348 | + $required_fields['country'] = array( |
|
| 349 | + 'error_id' => 'invalid_country', |
|
| 350 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
| 351 | + ); |
|
| 352 | + } |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -955,326 +955,326 @@ discard block |
||
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
| 958 | - $pages_options = array(); |
|
| 958 | + $pages_options = array(); |
|
| 959 | 959 | |
| 960 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 961 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 962 | - } |
|
| 960 | + if( $default_label !== NULL && $default_label !== false ) { |
|
| 961 | + $pages_options = array( '' => $default_label ); // Blank option |
|
| 962 | + } |
|
| 963 | 963 | |
| 964 | - $pages = get_pages(); |
|
| 965 | - if ( $pages ) { |
|
| 966 | - foreach ( $pages as $page ) { |
|
| 967 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 964 | + $pages = get_pages(); |
|
| 965 | + if ( $pages ) { |
|
| 966 | + foreach ( $pages as $page ) { |
|
| 967 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 968 | 968 | $pages_options[ $page->ID ] = $title; |
| 969 | - } |
|
| 970 | - } |
|
| 969 | + } |
|
| 970 | + } |
|
| 971 | 971 | |
| 972 | - return $pages_options; |
|
| 972 | + return $pages_options; |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | function wpinv_header_callback( $args ) { |
| 976 | - if ( !empty( $args['desc'] ) ) { |
|
| 976 | + if ( !empty( $args['desc'] ) ) { |
|
| 977 | 977 | echo $args['desc']; |
| 978 | 978 | } |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | function wpinv_hidden_callback( $args ) { |
| 982 | - global $wpinv_options; |
|
| 983 | - |
|
| 984 | - if ( isset( $args['set_value'] ) ) { |
|
| 985 | - $value = $args['set_value']; |
|
| 986 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 987 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 988 | - } else { |
|
| 989 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 990 | - } |
|
| 991 | - |
|
| 992 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 993 | - $args['readonly'] = true; |
|
| 994 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 995 | - $name = ''; |
|
| 996 | - } else { |
|
| 997 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 998 | - } |
|
| 999 | - |
|
| 1000 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 982 | + global $wpinv_options; |
|
| 983 | + |
|
| 984 | + if ( isset( $args['set_value'] ) ) { |
|
| 985 | + $value = $args['set_value']; |
|
| 986 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 987 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 988 | + } else { |
|
| 989 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 990 | + } |
|
| 991 | + |
|
| 992 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 993 | + $args['readonly'] = true; |
|
| 994 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 995 | + $name = ''; |
|
| 996 | + } else { |
|
| 997 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 998 | + } |
|
| 999 | + |
|
| 1000 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 1001 | 1001 | |
| 1002 | - echo $html; |
|
| 1002 | + echo $html; |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | function wpinv_checkbox_callback( $args ) { |
| 1006 | - global $wpinv_options; |
|
| 1006 | + global $wpinv_options; |
|
| 1007 | 1007 | |
| 1008 | 1008 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1009 | 1009 | |
| 1010 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1011 | - $name = ''; |
|
| 1012 | - } else { |
|
| 1013 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 1014 | - } |
|
| 1010 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1011 | + $name = ''; |
|
| 1012 | + } else { |
|
| 1013 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 1014 | + } |
|
| 1015 | 1015 | |
| 1016 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 1017 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 1018 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1016 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 1017 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 1018 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1019 | 1019 | |
| 1020 | - echo $html; |
|
| 1020 | + echo $html; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | function wpinv_multicheck_callback( $args ) { |
| 1024 | - global $wpinv_options; |
|
| 1024 | + global $wpinv_options; |
|
| 1025 | 1025 | |
| 1026 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1027 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 1026 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1027 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 1028 | 1028 | |
| 1029 | - if ( ! empty( $args['options'] ) ) { |
|
| 1030 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 1029 | + if ( ! empty( $args['options'] ) ) { |
|
| 1030 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 1031 | 1031 | foreach( $args['options'] as $key => $option ): |
| 1032 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1033 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 1034 | - $enabled = $sanitize_key; |
|
| 1035 | - } else { |
|
| 1036 | - $enabled = NULL; |
|
| 1037 | - } |
|
| 1038 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 1039 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 1040 | - endforeach; |
|
| 1041 | - echo '</div>'; |
|
| 1042 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 1043 | - } |
|
| 1032 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1033 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 1034 | + $enabled = $sanitize_key; |
|
| 1035 | + } else { |
|
| 1036 | + $enabled = NULL; |
|
| 1037 | + } |
|
| 1038 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 1039 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 1040 | + endforeach; |
|
| 1041 | + echo '</div>'; |
|
| 1042 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 1043 | + } |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | function wpinv_payment_icons_callback( $args ) { |
| 1047 | - global $wpinv_options; |
|
| 1047 | + global $wpinv_options; |
|
| 1048 | 1048 | |
| 1049 | 1049 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1050 | 1050 | |
| 1051 | - if ( ! empty( $args['options'] ) ) { |
|
| 1052 | - foreach( $args['options'] as $key => $option ) { |
|
| 1051 | + if ( ! empty( $args['options'] ) ) { |
|
| 1052 | + foreach( $args['options'] as $key => $option ) { |
|
| 1053 | 1053 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 1054 | 1054 | |
| 1055 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 1056 | - $enabled = $option; |
|
| 1057 | - } else { |
|
| 1058 | - $enabled = NULL; |
|
| 1059 | - } |
|
| 1060 | - |
|
| 1061 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 1062 | - |
|
| 1063 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 1064 | - |
|
| 1065 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 1066 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 1067 | - } else { |
|
| 1068 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 1069 | - |
|
| 1070 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 1071 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 1072 | - } else { |
|
| 1073 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 1074 | - $content_dir = WP_CONTENT_DIR; |
|
| 1075 | - |
|
| 1076 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 1077 | - // Replaces backslashes with forward slashes for Windows systems |
|
| 1078 | - $image = wp_normalize_path( $image ); |
|
| 1079 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 1080 | - } |
|
| 1081 | - |
|
| 1082 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 1083 | - } |
|
| 1084 | - |
|
| 1085 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 1086 | - } |
|
| 1087 | - echo $option . '</label>'; |
|
| 1088 | - } |
|
| 1089 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 1090 | - } |
|
| 1055 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 1056 | + $enabled = $option; |
|
| 1057 | + } else { |
|
| 1058 | + $enabled = NULL; |
|
| 1059 | + } |
|
| 1060 | + |
|
| 1061 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 1062 | + |
|
| 1063 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 1064 | + |
|
| 1065 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
| 1066 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 1067 | + } else { |
|
| 1068 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 1069 | + |
|
| 1070 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 1071 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 1072 | + } else { |
|
| 1073 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 1074 | + $content_dir = WP_CONTENT_DIR; |
|
| 1075 | + |
|
| 1076 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 1077 | + // Replaces backslashes with forward slashes for Windows systems |
|
| 1078 | + $image = wp_normalize_path( $image ); |
|
| 1079 | + $content_dir = wp_normalize_path( $content_dir ); |
|
| 1080 | + } |
|
| 1081 | + |
|
| 1082 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
| 1083 | + } |
|
| 1084 | + |
|
| 1085 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 1086 | + } |
|
| 1087 | + echo $option . '</label>'; |
|
| 1088 | + } |
|
| 1089 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 1090 | + } |
|
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 | function wpinv_radio_callback( $args ) { |
| 1094 | - global $wpinv_options; |
|
| 1094 | + global $wpinv_options; |
|
| 1095 | 1095 | |
| 1096 | 1096 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1097 | 1097 | |
| 1098 | 1098 | foreach ( $args['options'] as $key => $option ) : |
| 1099 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1099 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1100 | 1100 | |
| 1101 | 1101 | $checked = false; |
| 1102 | 1102 | |
| 1103 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 1104 | - $checked = true; |
|
| 1105 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 1106 | - $checked = true; |
|
| 1103 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 1104 | + $checked = true; |
|
| 1105 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 1106 | + $checked = true; |
|
| 1107 | 1107 | |
| 1108 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 1109 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 1110 | - endforeach; |
|
| 1108 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 1109 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 1110 | + endforeach; |
|
| 1111 | 1111 | |
| 1112 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 1112 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | function wpinv_gateways_callback( $args ) { |
| 1116 | - global $wpinv_options; |
|
| 1116 | + global $wpinv_options; |
|
| 1117 | 1117 | |
| 1118 | 1118 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1119 | 1119 | |
| 1120 | - foreach ( $args['options'] as $key => $option ) : |
|
| 1121 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1120 | + foreach ( $args['options'] as $key => $option ) : |
|
| 1121 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1122 | 1122 | |
| 1123 | 1123 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
| 1124 | - $enabled = '1'; |
|
| 1125 | - else |
|
| 1126 | - $enabled = null; |
|
| 1124 | + $enabled = '1'; |
|
| 1125 | + else |
|
| 1126 | + $enabled = null; |
|
| 1127 | 1127 | |
| 1128 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 1129 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 1130 | - endforeach; |
|
| 1128 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 1129 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 1130 | + endforeach; |
|
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | 1133 | function wpinv_gateway_select_callback($args) { |
| 1134 | - global $wpinv_options; |
|
| 1134 | + global $wpinv_options; |
|
| 1135 | 1135 | |
| 1136 | 1136 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1137 | 1137 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
| 1138 | 1138 | |
| 1139 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 1139 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 1140 | 1140 | |
| 1141 | - foreach ( $args['options'] as $key => $option ) : |
|
| 1142 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1141 | + foreach ( $args['options'] as $key => $option ) : |
|
| 1142 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1143 | 1143 | $selected = selected( $key, $args['selected'], false ); |
| 1144 | 1144 | } else { |
| 1145 | 1145 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
| 1146 | 1146 | } |
| 1147 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 1148 | - endforeach; |
|
| 1147 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 1148 | + endforeach; |
|
| 1149 | 1149 | |
| 1150 | - echo '</select>'; |
|
| 1151 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1150 | + echo '</select>'; |
|
| 1151 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | function wpinv_text_callback( $args ) { |
| 1155 | - global $wpinv_options; |
|
| 1155 | + global $wpinv_options; |
|
| 1156 | 1156 | |
| 1157 | 1157 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1158 | 1158 | |
| 1159 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1160 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1161 | - } else { |
|
| 1162 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1163 | - } |
|
| 1164 | - |
|
| 1165 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1166 | - $args['readonly'] = true; |
|
| 1167 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1168 | - $name = ''; |
|
| 1169 | - } else { |
|
| 1170 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1171 | - } |
|
| 1172 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1173 | - |
|
| 1174 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 1175 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1176 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 1177 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1178 | - |
|
| 1179 | - echo $html; |
|
| 1159 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1160 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1161 | + } else { |
|
| 1162 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1163 | + } |
|
| 1164 | + |
|
| 1165 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1166 | + $args['readonly'] = true; |
|
| 1167 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1168 | + $name = ''; |
|
| 1169 | + } else { |
|
| 1170 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1171 | + } |
|
| 1172 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1173 | + |
|
| 1174 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 1175 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1176 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 1177 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1178 | + |
|
| 1179 | + echo $html; |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | function wpinv_number_callback( $args ) { |
| 1183 | - global $wpinv_options; |
|
| 1183 | + global $wpinv_options; |
|
| 1184 | 1184 | |
| 1185 | 1185 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1186 | 1186 | |
| 1187 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1188 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1189 | - } else { |
|
| 1190 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1194 | - $args['readonly'] = true; |
|
| 1195 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1196 | - $name = ''; |
|
| 1197 | - } else { |
|
| 1198 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1199 | - } |
|
| 1200 | - |
|
| 1201 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1202 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1203 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1204 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1205 | - |
|
| 1206 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1207 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1208 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1209 | - |
|
| 1210 | - echo $html; |
|
| 1187 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1188 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1189 | + } else { |
|
| 1190 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1194 | + $args['readonly'] = true; |
|
| 1195 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1196 | + $name = ''; |
|
| 1197 | + } else { |
|
| 1198 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1199 | + } |
|
| 1200 | + |
|
| 1201 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1202 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1203 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1204 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1205 | + |
|
| 1206 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1207 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1208 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1209 | + |
|
| 1210 | + echo $html; |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | function wpinv_textarea_callback( $args ) { |
| 1214 | - global $wpinv_options; |
|
| 1214 | + global $wpinv_options; |
|
| 1215 | 1215 | |
| 1216 | 1216 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1217 | 1217 | |
| 1218 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1219 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1220 | - } else { |
|
| 1221 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1222 | - } |
|
| 1218 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1219 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1220 | + } else { |
|
| 1221 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1222 | + } |
|
| 1223 | 1223 | |
| 1224 | 1224 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
| 1225 | 1225 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
| 1226 | 1226 | |
| 1227 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1228 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1227 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1228 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1229 | 1229 | |
| 1230 | - echo $html; |
|
| 1230 | + echo $html; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | function wpinv_password_callback( $args ) { |
| 1234 | - global $wpinv_options; |
|
| 1234 | + global $wpinv_options; |
|
| 1235 | 1235 | |
| 1236 | 1236 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1237 | 1237 | |
| 1238 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1239 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1240 | - } else { |
|
| 1241 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1242 | - } |
|
| 1238 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1239 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1240 | + } else { |
|
| 1241 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1242 | + } |
|
| 1243 | 1243 | |
| 1244 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1245 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1246 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1244 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1245 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1246 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1247 | 1247 | |
| 1248 | - echo $html; |
|
| 1248 | + echo $html; |
|
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | function wpinv_missing_callback($args) { |
| 1252 | - printf( |
|
| 1253 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1254 | - '<strong>' . $args['id'] . '</strong>' |
|
| 1255 | - ); |
|
| 1252 | + printf( |
|
| 1253 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1254 | + '<strong>' . $args['id'] . '</strong>' |
|
| 1255 | + ); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | function wpinv_select_callback($args) { |
| 1259 | - global $wpinv_options; |
|
| 1259 | + global $wpinv_options; |
|
| 1260 | 1260 | |
| 1261 | 1261 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1262 | 1262 | |
| 1263 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1264 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1265 | - } else { |
|
| 1266 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1267 | - } |
|
| 1263 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1264 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1265 | + } else { |
|
| 1266 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1267 | + } |
|
| 1268 | 1268 | |
| 1269 | 1269 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
| 1270 | 1270 | $value = $args['selected']; |
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1274 | - $placeholder = $args['placeholder']; |
|
| 1275 | - } else { |
|
| 1276 | - $placeholder = ''; |
|
| 1277 | - } |
|
| 1273 | + if ( isset( $args['placeholder'] ) ) { |
|
| 1274 | + $placeholder = $args['placeholder']; |
|
| 1275 | + } else { |
|
| 1276 | + $placeholder = ''; |
|
| 1277 | + } |
|
| 1278 | 1278 | |
| 1279 | 1279 | if( !empty( $args['onchange'] ) ) { |
| 1280 | 1280 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -1284,142 +1284,142 @@ discard block |
||
| 1284 | 1284 | |
| 1285 | 1285 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
| 1286 | 1286 | |
| 1287 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1287 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1288 | 1288 | |
| 1289 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1290 | - $selected = selected( $option, $value, false ); |
|
| 1291 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1292 | - } |
|
| 1289 | + foreach ( $args['options'] as $option => $name ) { |
|
| 1290 | + $selected = selected( $option, $value, false ); |
|
| 1291 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1292 | + } |
|
| 1293 | 1293 | |
| 1294 | - $html .= '</select>'; |
|
| 1295 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1294 | + $html .= '</select>'; |
|
| 1295 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1296 | 1296 | |
| 1297 | - echo $html; |
|
| 1297 | + echo $html; |
|
| 1298 | 1298 | } |
| 1299 | 1299 | |
| 1300 | 1300 | function wpinv_color_select_callback( $args ) { |
| 1301 | - global $wpinv_options; |
|
| 1301 | + global $wpinv_options; |
|
| 1302 | 1302 | |
| 1303 | 1303 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1304 | 1304 | |
| 1305 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1306 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1307 | - } else { |
|
| 1308 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1309 | - } |
|
| 1305 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1306 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1307 | + } else { |
|
| 1308 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1309 | + } |
|
| 1310 | 1310 | |
| 1311 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1311 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1312 | 1312 | |
| 1313 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1314 | - $selected = selected( $option, $value, false ); |
|
| 1315 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1316 | - } |
|
| 1313 | + foreach ( $args['options'] as $option => $color ) { |
|
| 1314 | + $selected = selected( $option, $value, false ); |
|
| 1315 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1316 | + } |
|
| 1317 | 1317 | |
| 1318 | - $html .= '</select>'; |
|
| 1319 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1318 | + $html .= '</select>'; |
|
| 1319 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1320 | 1320 | |
| 1321 | - echo $html; |
|
| 1321 | + echo $html; |
|
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | 1324 | function wpinv_rich_editor_callback( $args ) { |
| 1325 | - global $wpinv_options, $wp_version; |
|
| 1325 | + global $wpinv_options, $wp_version; |
|
| 1326 | 1326 | |
| 1327 | 1327 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1328 | 1328 | |
| 1329 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1330 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1329 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1330 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1331 | 1331 | |
| 1332 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1333 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1334 | - } |
|
| 1335 | - } else { |
|
| 1336 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1337 | - } |
|
| 1332 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1333 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1334 | + } |
|
| 1335 | + } else { |
|
| 1336 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1337 | + } |
|
| 1338 | 1338 | |
| 1339 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1339 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1340 | 1340 | |
| 1341 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1342 | - ob_start(); |
|
| 1343 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
| 1344 | - $html = ob_get_clean(); |
|
| 1345 | - } else { |
|
| 1346 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1347 | - } |
|
| 1341 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1342 | + ob_start(); |
|
| 1343 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
| 1344 | + $html = ob_get_clean(); |
|
| 1345 | + } else { |
|
| 1346 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1347 | + } |
|
| 1348 | 1348 | |
| 1349 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1349 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1350 | 1350 | |
| 1351 | - echo $html; |
|
| 1351 | + echo $html; |
|
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | function wpinv_upload_callback( $args ) { |
| 1355 | - global $wpinv_options; |
|
| 1355 | + global $wpinv_options; |
|
| 1356 | 1356 | |
| 1357 | 1357 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1358 | 1358 | |
| 1359 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1360 | - $value = $wpinv_options[$args['id']]; |
|
| 1361 | - } else { |
|
| 1362 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1363 | - } |
|
| 1359 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1360 | + $value = $wpinv_options[$args['id']]; |
|
| 1361 | + } else { |
|
| 1362 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1363 | + } |
|
| 1364 | 1364 | |
| 1365 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1366 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1367 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1368 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1365 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1366 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1367 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1368 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1369 | 1369 | |
| 1370 | - echo $html; |
|
| 1370 | + echo $html; |
|
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | 1373 | function wpinv_color_callback( $args ) { |
| 1374 | - global $wpinv_options; |
|
| 1374 | + global $wpinv_options; |
|
| 1375 | 1375 | |
| 1376 | 1376 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1377 | 1377 | |
| 1378 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1379 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1380 | - } else { |
|
| 1381 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1382 | - } |
|
| 1378 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1379 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1380 | + } else { |
|
| 1381 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1382 | + } |
|
| 1383 | 1383 | |
| 1384 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1384 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1385 | 1385 | |
| 1386 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1387 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1386 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1387 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1388 | 1388 | |
| 1389 | - echo $html; |
|
| 1389 | + echo $html; |
|
| 1390 | 1390 | } |
| 1391 | 1391 | |
| 1392 | 1392 | function wpinv_country_states_callback($args) { |
| 1393 | - global $wpinv_options; |
|
| 1393 | + global $wpinv_options; |
|
| 1394 | 1394 | |
| 1395 | 1395 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1396 | 1396 | |
| 1397 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1398 | - $placeholder = $args['placeholder']; |
|
| 1399 | - } else { |
|
| 1400 | - $placeholder = ''; |
|
| 1401 | - } |
|
| 1397 | + if ( isset( $args['placeholder'] ) ) { |
|
| 1398 | + $placeholder = $args['placeholder']; |
|
| 1399 | + } else { |
|
| 1400 | + $placeholder = ''; |
|
| 1401 | + } |
|
| 1402 | 1402 | |
| 1403 | - $states = wpinv_get_country_states(); |
|
| 1403 | + $states = wpinv_get_country_states(); |
|
| 1404 | 1404 | |
| 1405 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 1406 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1405 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 1406 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1407 | 1407 | |
| 1408 | - foreach ( $states as $option => $name ) { |
|
| 1409 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1410 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1411 | - } |
|
| 1408 | + foreach ( $states as $option => $name ) { |
|
| 1409 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1410 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1411 | + } |
|
| 1412 | 1412 | |
| 1413 | - $html .= '</select>'; |
|
| 1414 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1413 | + $html .= '</select>'; |
|
| 1414 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1415 | 1415 | |
| 1416 | - echo $html; |
|
| 1416 | + echo $html; |
|
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | function wpinv_tax_rates_callback($args) { |
| 1420 | - global $wpinv_options; |
|
| 1421 | - $rates = wpinv_get_tax_rates(); |
|
| 1422 | - ob_start(); ?> |
|
| 1420 | + global $wpinv_options; |
|
| 1421 | + $rates = wpinv_get_tax_rates(); |
|
| 1422 | + ob_start(); ?> |
|
| 1423 | 1423 | </td><tr> |
| 1424 | 1424 | <td colspan="2" class="wpinv_tax_tdbox"> |
| 1425 | 1425 | <p><?php echo $args['desc']; ?></p> |
@@ -1443,40 +1443,40 @@ discard block |
||
| 1443 | 1443 | <tr> |
| 1444 | 1444 | <td class="wpinv_tax_country"> |
| 1445 | 1445 | <?php |
| 1446 | - echo wpinv_html_select( array( |
|
| 1447 | - 'options' => wpinv_get_country_list( true ), |
|
| 1448 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 1446 | + echo wpinv_html_select( array( |
|
| 1447 | + 'options' => wpinv_get_country_list( true ), |
|
| 1448 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 1449 | 1449 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1450 | - 'selected' => $rate['country'], |
|
| 1451 | - 'show_option_all' => false, |
|
| 1452 | - 'show_option_none' => false, |
|
| 1453 | - 'class' => 'wpinv-tax-country wpi_select2', |
|
| 1454 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1455 | - ) ); |
|
| 1456 | - ?> |
|
| 1450 | + 'selected' => $rate['country'], |
|
| 1451 | + 'show_option_all' => false, |
|
| 1452 | + 'show_option_none' => false, |
|
| 1453 | + 'class' => 'wpinv-tax-country wpi_select2', |
|
| 1454 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1455 | + ) ); |
|
| 1456 | + ?> |
|
| 1457 | 1457 | </td> |
| 1458 | 1458 | <td class="wpinv_tax_state"> |
| 1459 | 1459 | <?php |
| 1460 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1461 | - if( !empty( $states ) ) { |
|
| 1462 | - echo wpinv_html_select( array( |
|
| 1463 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1464 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 1460 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1461 | + if( !empty( $states ) ) { |
|
| 1462 | + echo wpinv_html_select( array( |
|
| 1463 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1464 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 1465 | 1465 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1466 | - 'selected' => $rate['state'], |
|
| 1467 | - 'show_option_all' => false, |
|
| 1468 | - 'show_option_none' => false, |
|
| 1466 | + 'selected' => $rate['state'], |
|
| 1467 | + 'show_option_all' => false, |
|
| 1468 | + 'show_option_none' => false, |
|
| 1469 | 1469 | 'class' => 'wpi_select2', |
| 1470 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1471 | - ) ); |
|
| 1472 | - } else { |
|
| 1473 | - echo wpinv_html_text( array( |
|
| 1474 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 1475 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1470 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1471 | + ) ); |
|
| 1472 | + } else { |
|
| 1473 | + echo wpinv_html_text( array( |
|
| 1474 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 1475 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1476 | 1476 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1477 | - ) ); |
|
| 1478 | - } |
|
| 1479 | - ?> |
|
| 1477 | + ) ); |
|
| 1478 | + } |
|
| 1479 | + ?> |
|
| 1480 | 1480 | </td> |
| 1481 | 1481 | <td class="wpinv_tax_global"> |
| 1482 | 1482 | <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
@@ -1491,19 +1491,19 @@ discard block |
||
| 1491 | 1491 | <tr> |
| 1492 | 1492 | <td class="wpinv_tax_country"> |
| 1493 | 1493 | <?php |
| 1494 | - echo wpinv_html_select( array( |
|
| 1495 | - 'options' => wpinv_get_country_list( true ), |
|
| 1496 | - 'name' => 'tax_rates[0][country]', |
|
| 1497 | - 'show_option_all' => false, |
|
| 1498 | - 'show_option_none' => false, |
|
| 1499 | - 'class' => 'wpinv-tax-country wpi_select2', |
|
| 1500 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1501 | - ) ); ?> |
|
| 1494 | + echo wpinv_html_select( array( |
|
| 1495 | + 'options' => wpinv_get_country_list( true ), |
|
| 1496 | + 'name' => 'tax_rates[0][country]', |
|
| 1497 | + 'show_option_all' => false, |
|
| 1498 | + 'show_option_none' => false, |
|
| 1499 | + 'class' => 'wpinv-tax-country wpi_select2', |
|
| 1500 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1501 | + ) ); ?> |
|
| 1502 | 1502 | </td> |
| 1503 | 1503 | <td class="wpinv_tax_state"> |
| 1504 | 1504 | <?php echo wpinv_html_text( array( |
| 1505 | - 'name' => 'tax_rates[0][state]' |
|
| 1506 | - ) ); ?> |
|
| 1505 | + 'name' => 'tax_rates[0][state]' |
|
| 1506 | + ) ); ?> |
|
| 1507 | 1507 | </td> |
| 1508 | 1508 | <td class="wpinv_tax_global"> |
| 1509 | 1509 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -1518,7 +1518,7 @@ discard block |
||
| 1518 | 1518 | <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
| 1519 | 1519 | </table> |
| 1520 | 1520 | <?php |
| 1521 | - echo ob_get_clean(); |
|
| 1521 | + echo ob_get_clean(); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | function wpinv_tools_callback($args) { |
@@ -1546,15 +1546,15 @@ discard block |
||
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | 1548 | function wpinv_descriptive_text_callback( $args ) { |
| 1549 | - echo wp_kses_post( $args['desc'] ); |
|
| 1549 | + echo wp_kses_post( $args['desc'] ); |
|
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | function wpinv_hook_callback( $args ) { |
| 1553 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1553 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | 1556 | function wpinv_set_settings_cap() { |
| 1557 | - return 'manage_options'; |
|
| 1557 | + return 'manage_options'; |
|
| 1558 | 1558 | } |
| 1559 | 1559 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
| 1560 | 1560 | |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | function wpinv_get_default_country() { |
| 16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 17 | 17 | |
| 18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
| 18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function wpinv_is_base_country( $country ) { |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function wpinv_get_default_state() { |
| 43 | - $state = wpinv_get_option( 'default_state', false ); |
|
| 43 | + $state = wpinv_get_option( 'default_state', false ); |
|
| 44 | 44 | |
| 45 | - return apply_filters( 'wpinv_default_state', $state ); |
|
| 45 | + return apply_filters( 'wpinv_default_state', $state ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -115,260 +115,260 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | function wpinv_get_country_list( $first_empty = false ) { |
| 118 | - $countries = array( |
|
| 119 | - 'US' => __('United States', 'invoicing'), |
|
| 120 | - 'CA' => __('Canada', 'invoicing'), |
|
| 121 | - 'GB' => __('United Kingdom', 'invoicing'), |
|
| 122 | - 'AF' => __('Afghanistan', 'invoicing'), |
|
| 123 | - 'AX' => __('Aland Islands', 'invoicing'), |
|
| 124 | - 'AL' => __('Albania', 'invoicing'), |
|
| 125 | - 'DZ' => __('Algeria', 'invoicing'), |
|
| 126 | - 'AS' => __('American Samoa', 'invoicing'), |
|
| 127 | - 'AD' => __('Andorra', 'invoicing'), |
|
| 128 | - 'AO' => __('Angola', 'invoicing'), |
|
| 129 | - 'AI' => __('Anguilla', 'invoicing'), |
|
| 130 | - 'AQ' => __('Antarctica', 'invoicing'), |
|
| 131 | - 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
| 132 | - 'AR' => __('Argentina', 'invoicing'), |
|
| 133 | - 'AM' => __('Armenia', 'invoicing'), |
|
| 134 | - 'AW' => __('Aruba', 'invoicing'), |
|
| 135 | - 'AU' => __('Australia', 'invoicing'), |
|
| 136 | - 'AT' => __('Austria', 'invoicing'), |
|
| 137 | - 'AZ' => __('Azerbaijan', 'invoicing'), |
|
| 138 | - 'BS' => __('Bahamas', 'invoicing'), |
|
| 139 | - 'BH' => __('Bahrain', 'invoicing'), |
|
| 140 | - 'BD' => __('Bangladesh', 'invoicing'), |
|
| 141 | - 'BB' => __('Barbados', 'invoicing'), |
|
| 142 | - 'BY' => __('Belarus', 'invoicing'), |
|
| 143 | - 'BE' => __('Belgium', 'invoicing'), |
|
| 144 | - 'BZ' => __('Belize', 'invoicing'), |
|
| 145 | - 'BJ' => __('Benin', 'invoicing'), |
|
| 146 | - 'BM' => __('Bermuda', 'invoicing'), |
|
| 147 | - 'BT' => __('Bhutan', 'invoicing'), |
|
| 148 | - 'BO' => __('Bolivia', 'invoicing'), |
|
| 149 | - 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
| 150 | - 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
| 151 | - 'BW' => __('Botswana', 'invoicing'), |
|
| 152 | - 'BV' => __('Bouvet Island', 'invoicing'), |
|
| 153 | - 'BR' => __('Brazil', 'invoicing'), |
|
| 154 | - 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
| 155 | - 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
| 156 | - 'BG' => __('Bulgaria', 'invoicing'), |
|
| 157 | - 'BF' => __('Burkina Faso', 'invoicing'), |
|
| 158 | - 'BI' => __('Burundi', 'invoicing'), |
|
| 159 | - 'KH' => __('Cambodia', 'invoicing'), |
|
| 160 | - 'CM' => __('Cameroon', 'invoicing'), |
|
| 161 | - 'CV' => __('Cape Verde', 'invoicing'), |
|
| 162 | - 'KY' => __('Cayman Islands', 'invoicing'), |
|
| 163 | - 'CF' => __('Central African Republic', 'invoicing'), |
|
| 164 | - 'TD' => __('Chad', 'invoicing'), |
|
| 165 | - 'CL' => __('Chile', 'invoicing'), |
|
| 166 | - 'CN' => __('China', 'invoicing'), |
|
| 167 | - 'CX' => __('Christmas Island', 'invoicing'), |
|
| 168 | - 'CC' => __('Cocos Islands', 'invoicing'), |
|
| 169 | - 'CO' => __('Colombia', 'invoicing'), |
|
| 170 | - 'KM' => __('Comoros', 'invoicing'), |
|
| 171 | - 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
| 172 | - 'CG' => __('Congo, Republic of', 'invoicing'), |
|
| 173 | - 'CK' => __('Cook Islands', 'invoicing'), |
|
| 174 | - 'CR' => __('Costa Rica', 'invoicing'), |
|
| 175 | - 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
| 176 | - 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
| 177 | - 'CU' => __('Cuba', 'invoicing'), |
|
| 178 | - 'CW' => __('CuraÇao', 'invoicing'), |
|
| 179 | - 'CY' => __('Cyprus', 'invoicing'), |
|
| 180 | - 'CZ' => __('Czech Republic', 'invoicing'), |
|
| 181 | - 'DK' => __('Denmark', 'invoicing'), |
|
| 182 | - 'DJ' => __('Djibouti', 'invoicing'), |
|
| 183 | - 'DM' => __('Dominica', 'invoicing'), |
|
| 184 | - 'DO' => __('Dominican Republic', 'invoicing'), |
|
| 185 | - 'TP' => __('East Timor', 'invoicing'), |
|
| 186 | - 'EC' => __('Ecuador', 'invoicing'), |
|
| 187 | - 'EG' => __('Egypt', 'invoicing'), |
|
| 188 | - 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
| 189 | - 'SV' => __('El Salvador', 'invoicing'), |
|
| 190 | - 'ER' => __('Eritrea', 'invoicing'), |
|
| 191 | - 'EE' => __('Estonia', 'invoicing'), |
|
| 192 | - 'ET' => __('Ethiopia', 'invoicing'), |
|
| 193 | - 'FK' => __('Falkland Islands', 'invoicing'), |
|
| 194 | - 'FO' => __('Faroe Islands', 'invoicing'), |
|
| 195 | - 'FJ' => __('Fiji', 'invoicing'), |
|
| 196 | - 'FI' => __('Finland', 'invoicing'), |
|
| 197 | - 'FR' => __('France', 'invoicing'), |
|
| 198 | - 'GF' => __('French Guiana', 'invoicing'), |
|
| 199 | - 'PF' => __('French Polynesia', 'invoicing'), |
|
| 200 | - 'TF' => __('French Southern Territories', 'invoicing'), |
|
| 201 | - 'GA' => __('Gabon', 'invoicing'), |
|
| 202 | - 'GM' => __('Gambia', 'invoicing'), |
|
| 203 | - 'GE' => __('Georgia', 'invoicing'), |
|
| 204 | - 'DE' => __('Germany', 'invoicing'), |
|
| 205 | - 'GR' => __('Greece', 'invoicing'), |
|
| 206 | - 'GH' => __('Ghana', 'invoicing'), |
|
| 207 | - 'GI' => __('Gibraltar', 'invoicing'), |
|
| 208 | - 'GL' => __('Greenland', 'invoicing'), |
|
| 209 | - 'GD' => __('Grenada', 'invoicing'), |
|
| 210 | - 'GP' => __('Guadeloupe', 'invoicing'), |
|
| 211 | - 'GU' => __('Guam', 'invoicing'), |
|
| 212 | - 'GT' => __('Guatemala', 'invoicing'), |
|
| 213 | - 'GG' => __('Guernsey', 'invoicing'), |
|
| 214 | - 'GN' => __('Guinea', 'invoicing'), |
|
| 215 | - 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
| 216 | - 'GY' => __('Guyana', 'invoicing'), |
|
| 217 | - 'HT' => __('Haiti', 'invoicing'), |
|
| 218 | - 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
| 219 | - 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
| 220 | - 'HN' => __('Honduras', 'invoicing'), |
|
| 221 | - 'HK' => __('Hong Kong', 'invoicing'), |
|
| 222 | - 'HU' => __('Hungary', 'invoicing'), |
|
| 223 | - 'IS' => __('Iceland', 'invoicing'), |
|
| 224 | - 'IN' => __('India', 'invoicing'), |
|
| 225 | - 'ID' => __('Indonesia', 'invoicing'), |
|
| 226 | - 'IR' => __('Iran', 'invoicing'), |
|
| 227 | - 'IQ' => __('Iraq', 'invoicing'), |
|
| 228 | - 'IE' => __('Ireland', 'invoicing'), |
|
| 229 | - 'IM' => __('Isle of Man', 'invoicing'), |
|
| 230 | - 'IL' => __('Israel', 'invoicing'), |
|
| 231 | - 'IT' => __('Italy', 'invoicing'), |
|
| 232 | - 'JM' => __('Jamaica', 'invoicing'), |
|
| 233 | - 'JP' => __('Japan', 'invoicing'), |
|
| 234 | - 'JE' => __('Jersey', 'invoicing'), |
|
| 235 | - 'JO' => __('Jordan', 'invoicing'), |
|
| 236 | - 'KZ' => __('Kazakhstan', 'invoicing'), |
|
| 237 | - 'KE' => __('Kenya', 'invoicing'), |
|
| 238 | - 'KI' => __('Kiribati', 'invoicing'), |
|
| 239 | - 'KW' => __('Kuwait', 'invoicing'), |
|
| 240 | - 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
| 241 | - 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
| 242 | - 'LV' => __('Latvia', 'invoicing'), |
|
| 243 | - 'LB' => __('Lebanon', 'invoicing'), |
|
| 244 | - 'LS' => __('Lesotho', 'invoicing'), |
|
| 245 | - 'LR' => __('Liberia', 'invoicing'), |
|
| 246 | - 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
| 247 | - 'LI' => __('Liechtenstein', 'invoicing'), |
|
| 248 | - 'LT' => __('Lithuania', 'invoicing'), |
|
| 249 | - 'LU' => __('Luxembourg', 'invoicing'), |
|
| 250 | - 'MO' => __('Macau', 'invoicing'), |
|
| 251 | - 'MK' => __('Macedonia', 'invoicing'), |
|
| 252 | - 'MG' => __('Madagascar', 'invoicing'), |
|
| 253 | - 'MW' => __('Malawi', 'invoicing'), |
|
| 254 | - 'MY' => __('Malaysia', 'invoicing'), |
|
| 255 | - 'MV' => __('Maldives', 'invoicing'), |
|
| 256 | - 'ML' => __('Mali', 'invoicing'), |
|
| 257 | - 'MT' => __('Malta', 'invoicing'), |
|
| 258 | - 'MH' => __('Marshall Islands', 'invoicing'), |
|
| 259 | - 'MQ' => __('Martinique', 'invoicing'), |
|
| 260 | - 'MR' => __('Mauritania', 'invoicing'), |
|
| 261 | - 'MU' => __('Mauritius', 'invoicing'), |
|
| 262 | - 'YT' => __('Mayotte', 'invoicing'), |
|
| 263 | - 'MX' => __('Mexico', 'invoicing'), |
|
| 264 | - 'FM' => __('Micronesia', 'invoicing'), |
|
| 265 | - 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
| 266 | - 'MC' => __('Monaco', 'invoicing'), |
|
| 267 | - 'MN' => __('Mongolia', 'invoicing'), |
|
| 268 | - 'ME' => __('Montenegro', 'invoicing'), |
|
| 269 | - 'MS' => __('Montserrat', 'invoicing'), |
|
| 270 | - 'MA' => __('Morocco', 'invoicing'), |
|
| 271 | - 'MZ' => __('Mozambique', 'invoicing'), |
|
| 272 | - 'MM' => __('Myanmar', 'invoicing'), |
|
| 273 | - 'NA' => __('Namibia', 'invoicing'), |
|
| 274 | - 'NR' => __('Nauru', 'invoicing'), |
|
| 275 | - 'NP' => __('Nepal', 'invoicing'), |
|
| 276 | - 'NL' => __('Netherlands', 'invoicing'), |
|
| 277 | - 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
| 278 | - 'NC' => __('New Caledonia', 'invoicing'), |
|
| 279 | - 'NZ' => __('New Zealand', 'invoicing'), |
|
| 280 | - 'NI' => __('Nicaragua', 'invoicing'), |
|
| 281 | - 'NE' => __('Niger', 'invoicing'), |
|
| 282 | - 'NG' => __('Nigeria', 'invoicing'), |
|
| 283 | - 'NU' => __('Niue', 'invoicing'), |
|
| 284 | - 'NF' => __('Norfolk Island', 'invoicing'), |
|
| 285 | - 'KP' => __('North Korea', 'invoicing'), |
|
| 286 | - 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
| 287 | - 'NO' => __('Norway', 'invoicing'), |
|
| 288 | - 'OM' => __('Oman', 'invoicing'), |
|
| 289 | - 'PK' => __('Pakistan', 'invoicing'), |
|
| 290 | - 'PW' => __('Palau', 'invoicing'), |
|
| 291 | - 'PS' => __('Palestinian Territories', 'invoicing'), |
|
| 292 | - 'PA' => __('Panama', 'invoicing'), |
|
| 293 | - 'PG' => __('Papua New Guinea', 'invoicing'), |
|
| 294 | - 'PY' => __('Paraguay', 'invoicing'), |
|
| 295 | - 'PE' => __('Peru', 'invoicing'), |
|
| 296 | - 'PH' => __('Phillipines', 'invoicing'), |
|
| 297 | - 'PN' => __('Pitcairn Island', 'invoicing'), |
|
| 298 | - 'PL' => __('Poland', 'invoicing'), |
|
| 299 | - 'PT' => __('Portugal', 'invoicing'), |
|
| 300 | - 'PR' => __('Puerto Rico', 'invoicing'), |
|
| 301 | - 'QA' => __('Qatar', 'invoicing'), |
|
| 302 | - 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
| 303 | - 'RE' => __('Reunion Island', 'invoicing'), |
|
| 304 | - 'RO' => __('Romania', 'invoicing'), |
|
| 305 | - 'RU' => __('Russian Federation', 'invoicing'), |
|
| 306 | - 'RW' => __('Rwanda', 'invoicing'), |
|
| 307 | - 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
| 308 | - 'SH' => __('Saint Helena', 'invoicing'), |
|
| 309 | - 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
| 310 | - 'LC' => __('Saint Lucia', 'invoicing'), |
|
| 311 | - 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
| 312 | - 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
| 313 | - 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
| 314 | - 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
| 315 | - 'SM' => __('San Marino', 'invoicing'), |
|
| 316 | - 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
| 317 | - 'SA' => __('Saudi Arabia', 'invoicing'), |
|
| 318 | - 'SN' => __('Senegal', 'invoicing'), |
|
| 319 | - 'RS' => __('Serbia', 'invoicing'), |
|
| 320 | - 'SC' => __('Seychelles', 'invoicing'), |
|
| 321 | - 'SL' => __('Sierra Leone', 'invoicing'), |
|
| 322 | - 'SG' => __('Singapore', 'invoicing'), |
|
| 323 | - 'SK' => __('Slovak Republic', 'invoicing'), |
|
| 324 | - 'SI' => __('Slovenia', 'invoicing'), |
|
| 325 | - 'SB' => __('Solomon Islands', 'invoicing'), |
|
| 326 | - 'SO' => __('Somalia', 'invoicing'), |
|
| 327 | - 'ZA' => __('South Africa', 'invoicing'), |
|
| 328 | - 'GS' => __('South Georgia', 'invoicing'), |
|
| 329 | - 'KR' => __('South Korea', 'invoicing'), |
|
| 330 | - 'SS' => __('South Sudan', 'invoicing'), |
|
| 331 | - 'ES' => __('Spain', 'invoicing'), |
|
| 332 | - 'LK' => __('Sri Lanka', 'invoicing'), |
|
| 333 | - 'SD' => __('Sudan', 'invoicing'), |
|
| 334 | - 'SR' => __('Suriname', 'invoicing'), |
|
| 335 | - 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
| 336 | - 'SZ' => __('Swaziland', 'invoicing'), |
|
| 337 | - 'SE' => __('Sweden', 'invoicing'), |
|
| 338 | - 'CH' => __('Switzerland', 'invoicing'), |
|
| 339 | - 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
| 340 | - 'TW' => __('Taiwan', 'invoicing'), |
|
| 341 | - 'TJ' => __('Tajikistan', 'invoicing'), |
|
| 342 | - 'TZ' => __('Tanzania', 'invoicing'), |
|
| 343 | - 'TH' => __('Thailand', 'invoicing'), |
|
| 344 | - 'TL' => __('Timor-Leste', 'invoicing'), |
|
| 345 | - 'TG' => __('Togo', 'invoicing'), |
|
| 346 | - 'TK' => __('Tokelau', 'invoicing'), |
|
| 347 | - 'TO' => __('Tonga', 'invoicing'), |
|
| 348 | - 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
| 349 | - 'TN' => __('Tunisia', 'invoicing'), |
|
| 350 | - 'TR' => __('Turkey', 'invoicing'), |
|
| 351 | - 'TM' => __('Turkmenistan', 'invoicing'), |
|
| 352 | - 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
| 353 | - 'TV' => __('Tuvalu', 'invoicing'), |
|
| 354 | - 'UG' => __('Uganda', 'invoicing'), |
|
| 355 | - 'UA' => __('Ukraine', 'invoicing'), |
|
| 356 | - 'AE' => __('United Arab Emirates', 'invoicing'), |
|
| 357 | - 'UY' => __('Uruguay', 'invoicing'), |
|
| 358 | - 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
| 359 | - 'UZ' => __('Uzbekistan', 'invoicing'), |
|
| 360 | - 'VU' => __('Vanuatu', 'invoicing'), |
|
| 361 | - 'VE' => __('Venezuela', 'invoicing'), |
|
| 362 | - 'VN' => __('Vietnam', 'invoicing'), |
|
| 363 | - 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
| 364 | - 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
| 365 | - 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
| 366 | - 'EH' => __('Western Sahara', 'invoicing'), |
|
| 367 | - 'WS' => __('Western Samoa', 'invoicing'), |
|
| 368 | - 'YE' => __('Yemen', 'invoicing'), |
|
| 369 | - 'ZM' => __('Zambia', 'invoicing'), |
|
| 370 | - 'ZW' => __('Zimbabwe', 'invoicing'), |
|
| 371 | - ); |
|
| 118 | + $countries = array( |
|
| 119 | + 'US' => __('United States', 'invoicing'), |
|
| 120 | + 'CA' => __('Canada', 'invoicing'), |
|
| 121 | + 'GB' => __('United Kingdom', 'invoicing'), |
|
| 122 | + 'AF' => __('Afghanistan', 'invoicing'), |
|
| 123 | + 'AX' => __('Aland Islands', 'invoicing'), |
|
| 124 | + 'AL' => __('Albania', 'invoicing'), |
|
| 125 | + 'DZ' => __('Algeria', 'invoicing'), |
|
| 126 | + 'AS' => __('American Samoa', 'invoicing'), |
|
| 127 | + 'AD' => __('Andorra', 'invoicing'), |
|
| 128 | + 'AO' => __('Angola', 'invoicing'), |
|
| 129 | + 'AI' => __('Anguilla', 'invoicing'), |
|
| 130 | + 'AQ' => __('Antarctica', 'invoicing'), |
|
| 131 | + 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
| 132 | + 'AR' => __('Argentina', 'invoicing'), |
|
| 133 | + 'AM' => __('Armenia', 'invoicing'), |
|
| 134 | + 'AW' => __('Aruba', 'invoicing'), |
|
| 135 | + 'AU' => __('Australia', 'invoicing'), |
|
| 136 | + 'AT' => __('Austria', 'invoicing'), |
|
| 137 | + 'AZ' => __('Azerbaijan', 'invoicing'), |
|
| 138 | + 'BS' => __('Bahamas', 'invoicing'), |
|
| 139 | + 'BH' => __('Bahrain', 'invoicing'), |
|
| 140 | + 'BD' => __('Bangladesh', 'invoicing'), |
|
| 141 | + 'BB' => __('Barbados', 'invoicing'), |
|
| 142 | + 'BY' => __('Belarus', 'invoicing'), |
|
| 143 | + 'BE' => __('Belgium', 'invoicing'), |
|
| 144 | + 'BZ' => __('Belize', 'invoicing'), |
|
| 145 | + 'BJ' => __('Benin', 'invoicing'), |
|
| 146 | + 'BM' => __('Bermuda', 'invoicing'), |
|
| 147 | + 'BT' => __('Bhutan', 'invoicing'), |
|
| 148 | + 'BO' => __('Bolivia', 'invoicing'), |
|
| 149 | + 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
| 150 | + 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
| 151 | + 'BW' => __('Botswana', 'invoicing'), |
|
| 152 | + 'BV' => __('Bouvet Island', 'invoicing'), |
|
| 153 | + 'BR' => __('Brazil', 'invoicing'), |
|
| 154 | + 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
| 155 | + 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
| 156 | + 'BG' => __('Bulgaria', 'invoicing'), |
|
| 157 | + 'BF' => __('Burkina Faso', 'invoicing'), |
|
| 158 | + 'BI' => __('Burundi', 'invoicing'), |
|
| 159 | + 'KH' => __('Cambodia', 'invoicing'), |
|
| 160 | + 'CM' => __('Cameroon', 'invoicing'), |
|
| 161 | + 'CV' => __('Cape Verde', 'invoicing'), |
|
| 162 | + 'KY' => __('Cayman Islands', 'invoicing'), |
|
| 163 | + 'CF' => __('Central African Republic', 'invoicing'), |
|
| 164 | + 'TD' => __('Chad', 'invoicing'), |
|
| 165 | + 'CL' => __('Chile', 'invoicing'), |
|
| 166 | + 'CN' => __('China', 'invoicing'), |
|
| 167 | + 'CX' => __('Christmas Island', 'invoicing'), |
|
| 168 | + 'CC' => __('Cocos Islands', 'invoicing'), |
|
| 169 | + 'CO' => __('Colombia', 'invoicing'), |
|
| 170 | + 'KM' => __('Comoros', 'invoicing'), |
|
| 171 | + 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
| 172 | + 'CG' => __('Congo, Republic of', 'invoicing'), |
|
| 173 | + 'CK' => __('Cook Islands', 'invoicing'), |
|
| 174 | + 'CR' => __('Costa Rica', 'invoicing'), |
|
| 175 | + 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
| 176 | + 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
| 177 | + 'CU' => __('Cuba', 'invoicing'), |
|
| 178 | + 'CW' => __('CuraÇao', 'invoicing'), |
|
| 179 | + 'CY' => __('Cyprus', 'invoicing'), |
|
| 180 | + 'CZ' => __('Czech Republic', 'invoicing'), |
|
| 181 | + 'DK' => __('Denmark', 'invoicing'), |
|
| 182 | + 'DJ' => __('Djibouti', 'invoicing'), |
|
| 183 | + 'DM' => __('Dominica', 'invoicing'), |
|
| 184 | + 'DO' => __('Dominican Republic', 'invoicing'), |
|
| 185 | + 'TP' => __('East Timor', 'invoicing'), |
|
| 186 | + 'EC' => __('Ecuador', 'invoicing'), |
|
| 187 | + 'EG' => __('Egypt', 'invoicing'), |
|
| 188 | + 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
| 189 | + 'SV' => __('El Salvador', 'invoicing'), |
|
| 190 | + 'ER' => __('Eritrea', 'invoicing'), |
|
| 191 | + 'EE' => __('Estonia', 'invoicing'), |
|
| 192 | + 'ET' => __('Ethiopia', 'invoicing'), |
|
| 193 | + 'FK' => __('Falkland Islands', 'invoicing'), |
|
| 194 | + 'FO' => __('Faroe Islands', 'invoicing'), |
|
| 195 | + 'FJ' => __('Fiji', 'invoicing'), |
|
| 196 | + 'FI' => __('Finland', 'invoicing'), |
|
| 197 | + 'FR' => __('France', 'invoicing'), |
|
| 198 | + 'GF' => __('French Guiana', 'invoicing'), |
|
| 199 | + 'PF' => __('French Polynesia', 'invoicing'), |
|
| 200 | + 'TF' => __('French Southern Territories', 'invoicing'), |
|
| 201 | + 'GA' => __('Gabon', 'invoicing'), |
|
| 202 | + 'GM' => __('Gambia', 'invoicing'), |
|
| 203 | + 'GE' => __('Georgia', 'invoicing'), |
|
| 204 | + 'DE' => __('Germany', 'invoicing'), |
|
| 205 | + 'GR' => __('Greece', 'invoicing'), |
|
| 206 | + 'GH' => __('Ghana', 'invoicing'), |
|
| 207 | + 'GI' => __('Gibraltar', 'invoicing'), |
|
| 208 | + 'GL' => __('Greenland', 'invoicing'), |
|
| 209 | + 'GD' => __('Grenada', 'invoicing'), |
|
| 210 | + 'GP' => __('Guadeloupe', 'invoicing'), |
|
| 211 | + 'GU' => __('Guam', 'invoicing'), |
|
| 212 | + 'GT' => __('Guatemala', 'invoicing'), |
|
| 213 | + 'GG' => __('Guernsey', 'invoicing'), |
|
| 214 | + 'GN' => __('Guinea', 'invoicing'), |
|
| 215 | + 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
| 216 | + 'GY' => __('Guyana', 'invoicing'), |
|
| 217 | + 'HT' => __('Haiti', 'invoicing'), |
|
| 218 | + 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
| 219 | + 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
| 220 | + 'HN' => __('Honduras', 'invoicing'), |
|
| 221 | + 'HK' => __('Hong Kong', 'invoicing'), |
|
| 222 | + 'HU' => __('Hungary', 'invoicing'), |
|
| 223 | + 'IS' => __('Iceland', 'invoicing'), |
|
| 224 | + 'IN' => __('India', 'invoicing'), |
|
| 225 | + 'ID' => __('Indonesia', 'invoicing'), |
|
| 226 | + 'IR' => __('Iran', 'invoicing'), |
|
| 227 | + 'IQ' => __('Iraq', 'invoicing'), |
|
| 228 | + 'IE' => __('Ireland', 'invoicing'), |
|
| 229 | + 'IM' => __('Isle of Man', 'invoicing'), |
|
| 230 | + 'IL' => __('Israel', 'invoicing'), |
|
| 231 | + 'IT' => __('Italy', 'invoicing'), |
|
| 232 | + 'JM' => __('Jamaica', 'invoicing'), |
|
| 233 | + 'JP' => __('Japan', 'invoicing'), |
|
| 234 | + 'JE' => __('Jersey', 'invoicing'), |
|
| 235 | + 'JO' => __('Jordan', 'invoicing'), |
|
| 236 | + 'KZ' => __('Kazakhstan', 'invoicing'), |
|
| 237 | + 'KE' => __('Kenya', 'invoicing'), |
|
| 238 | + 'KI' => __('Kiribati', 'invoicing'), |
|
| 239 | + 'KW' => __('Kuwait', 'invoicing'), |
|
| 240 | + 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
| 241 | + 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
| 242 | + 'LV' => __('Latvia', 'invoicing'), |
|
| 243 | + 'LB' => __('Lebanon', 'invoicing'), |
|
| 244 | + 'LS' => __('Lesotho', 'invoicing'), |
|
| 245 | + 'LR' => __('Liberia', 'invoicing'), |
|
| 246 | + 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
| 247 | + 'LI' => __('Liechtenstein', 'invoicing'), |
|
| 248 | + 'LT' => __('Lithuania', 'invoicing'), |
|
| 249 | + 'LU' => __('Luxembourg', 'invoicing'), |
|
| 250 | + 'MO' => __('Macau', 'invoicing'), |
|
| 251 | + 'MK' => __('Macedonia', 'invoicing'), |
|
| 252 | + 'MG' => __('Madagascar', 'invoicing'), |
|
| 253 | + 'MW' => __('Malawi', 'invoicing'), |
|
| 254 | + 'MY' => __('Malaysia', 'invoicing'), |
|
| 255 | + 'MV' => __('Maldives', 'invoicing'), |
|
| 256 | + 'ML' => __('Mali', 'invoicing'), |
|
| 257 | + 'MT' => __('Malta', 'invoicing'), |
|
| 258 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
| 259 | + 'MQ' => __('Martinique', 'invoicing'), |
|
| 260 | + 'MR' => __('Mauritania', 'invoicing'), |
|
| 261 | + 'MU' => __('Mauritius', 'invoicing'), |
|
| 262 | + 'YT' => __('Mayotte', 'invoicing'), |
|
| 263 | + 'MX' => __('Mexico', 'invoicing'), |
|
| 264 | + 'FM' => __('Micronesia', 'invoicing'), |
|
| 265 | + 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
| 266 | + 'MC' => __('Monaco', 'invoicing'), |
|
| 267 | + 'MN' => __('Mongolia', 'invoicing'), |
|
| 268 | + 'ME' => __('Montenegro', 'invoicing'), |
|
| 269 | + 'MS' => __('Montserrat', 'invoicing'), |
|
| 270 | + 'MA' => __('Morocco', 'invoicing'), |
|
| 271 | + 'MZ' => __('Mozambique', 'invoicing'), |
|
| 272 | + 'MM' => __('Myanmar', 'invoicing'), |
|
| 273 | + 'NA' => __('Namibia', 'invoicing'), |
|
| 274 | + 'NR' => __('Nauru', 'invoicing'), |
|
| 275 | + 'NP' => __('Nepal', 'invoicing'), |
|
| 276 | + 'NL' => __('Netherlands', 'invoicing'), |
|
| 277 | + 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
| 278 | + 'NC' => __('New Caledonia', 'invoicing'), |
|
| 279 | + 'NZ' => __('New Zealand', 'invoicing'), |
|
| 280 | + 'NI' => __('Nicaragua', 'invoicing'), |
|
| 281 | + 'NE' => __('Niger', 'invoicing'), |
|
| 282 | + 'NG' => __('Nigeria', 'invoicing'), |
|
| 283 | + 'NU' => __('Niue', 'invoicing'), |
|
| 284 | + 'NF' => __('Norfolk Island', 'invoicing'), |
|
| 285 | + 'KP' => __('North Korea', 'invoicing'), |
|
| 286 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
| 287 | + 'NO' => __('Norway', 'invoicing'), |
|
| 288 | + 'OM' => __('Oman', 'invoicing'), |
|
| 289 | + 'PK' => __('Pakistan', 'invoicing'), |
|
| 290 | + 'PW' => __('Palau', 'invoicing'), |
|
| 291 | + 'PS' => __('Palestinian Territories', 'invoicing'), |
|
| 292 | + 'PA' => __('Panama', 'invoicing'), |
|
| 293 | + 'PG' => __('Papua New Guinea', 'invoicing'), |
|
| 294 | + 'PY' => __('Paraguay', 'invoicing'), |
|
| 295 | + 'PE' => __('Peru', 'invoicing'), |
|
| 296 | + 'PH' => __('Phillipines', 'invoicing'), |
|
| 297 | + 'PN' => __('Pitcairn Island', 'invoicing'), |
|
| 298 | + 'PL' => __('Poland', 'invoicing'), |
|
| 299 | + 'PT' => __('Portugal', 'invoicing'), |
|
| 300 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
| 301 | + 'QA' => __('Qatar', 'invoicing'), |
|
| 302 | + 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
| 303 | + 'RE' => __('Reunion Island', 'invoicing'), |
|
| 304 | + 'RO' => __('Romania', 'invoicing'), |
|
| 305 | + 'RU' => __('Russian Federation', 'invoicing'), |
|
| 306 | + 'RW' => __('Rwanda', 'invoicing'), |
|
| 307 | + 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
| 308 | + 'SH' => __('Saint Helena', 'invoicing'), |
|
| 309 | + 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
| 310 | + 'LC' => __('Saint Lucia', 'invoicing'), |
|
| 311 | + 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
| 312 | + 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
| 313 | + 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
| 314 | + 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
| 315 | + 'SM' => __('San Marino', 'invoicing'), |
|
| 316 | + 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
| 317 | + 'SA' => __('Saudi Arabia', 'invoicing'), |
|
| 318 | + 'SN' => __('Senegal', 'invoicing'), |
|
| 319 | + 'RS' => __('Serbia', 'invoicing'), |
|
| 320 | + 'SC' => __('Seychelles', 'invoicing'), |
|
| 321 | + 'SL' => __('Sierra Leone', 'invoicing'), |
|
| 322 | + 'SG' => __('Singapore', 'invoicing'), |
|
| 323 | + 'SK' => __('Slovak Republic', 'invoicing'), |
|
| 324 | + 'SI' => __('Slovenia', 'invoicing'), |
|
| 325 | + 'SB' => __('Solomon Islands', 'invoicing'), |
|
| 326 | + 'SO' => __('Somalia', 'invoicing'), |
|
| 327 | + 'ZA' => __('South Africa', 'invoicing'), |
|
| 328 | + 'GS' => __('South Georgia', 'invoicing'), |
|
| 329 | + 'KR' => __('South Korea', 'invoicing'), |
|
| 330 | + 'SS' => __('South Sudan', 'invoicing'), |
|
| 331 | + 'ES' => __('Spain', 'invoicing'), |
|
| 332 | + 'LK' => __('Sri Lanka', 'invoicing'), |
|
| 333 | + 'SD' => __('Sudan', 'invoicing'), |
|
| 334 | + 'SR' => __('Suriname', 'invoicing'), |
|
| 335 | + 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
| 336 | + 'SZ' => __('Swaziland', 'invoicing'), |
|
| 337 | + 'SE' => __('Sweden', 'invoicing'), |
|
| 338 | + 'CH' => __('Switzerland', 'invoicing'), |
|
| 339 | + 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
| 340 | + 'TW' => __('Taiwan', 'invoicing'), |
|
| 341 | + 'TJ' => __('Tajikistan', 'invoicing'), |
|
| 342 | + 'TZ' => __('Tanzania', 'invoicing'), |
|
| 343 | + 'TH' => __('Thailand', 'invoicing'), |
|
| 344 | + 'TL' => __('Timor-Leste', 'invoicing'), |
|
| 345 | + 'TG' => __('Togo', 'invoicing'), |
|
| 346 | + 'TK' => __('Tokelau', 'invoicing'), |
|
| 347 | + 'TO' => __('Tonga', 'invoicing'), |
|
| 348 | + 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
| 349 | + 'TN' => __('Tunisia', 'invoicing'), |
|
| 350 | + 'TR' => __('Turkey', 'invoicing'), |
|
| 351 | + 'TM' => __('Turkmenistan', 'invoicing'), |
|
| 352 | + 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
| 353 | + 'TV' => __('Tuvalu', 'invoicing'), |
|
| 354 | + 'UG' => __('Uganda', 'invoicing'), |
|
| 355 | + 'UA' => __('Ukraine', 'invoicing'), |
|
| 356 | + 'AE' => __('United Arab Emirates', 'invoicing'), |
|
| 357 | + 'UY' => __('Uruguay', 'invoicing'), |
|
| 358 | + 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
| 359 | + 'UZ' => __('Uzbekistan', 'invoicing'), |
|
| 360 | + 'VU' => __('Vanuatu', 'invoicing'), |
|
| 361 | + 'VE' => __('Venezuela', 'invoicing'), |
|
| 362 | + 'VN' => __('Vietnam', 'invoicing'), |
|
| 363 | + 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
| 364 | + 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
| 365 | + 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
| 366 | + 'EH' => __('Western Sahara', 'invoicing'), |
|
| 367 | + 'WS' => __('Western Samoa', 'invoicing'), |
|
| 368 | + 'YE' => __('Yemen', 'invoicing'), |
|
| 369 | + 'ZM' => __('Zambia', 'invoicing'), |
|
| 370 | + 'ZW' => __('Zimbabwe', 'invoicing'), |
|
| 371 | + ); |
|
| 372 | 372 | |
| 373 | 373 | if ( $first_empty ) { |
| 374 | 374 | $countries = array_merge( array( '' => '' ), $countries ); |
@@ -1537,30 +1537,30 @@ discard block |
||
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | 1539 | function wpinv_get_states_field() { |
| 1540 | - if( empty( $_POST['country'] ) ) { |
|
| 1541 | - $_POST['country'] = wpinv_get_default_country(); |
|
| 1542 | - } |
|
| 1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 1540 | + if( empty( $_POST['country'] ) ) { |
|
| 1541 | + $_POST['country'] = wpinv_get_default_country(); |
|
| 1542 | + } |
|
| 1543 | + $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 1544 | 1544 | |
| 1545 | - if( !empty( $states ) ) { |
|
| 1546 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 1545 | + if( !empty( $states ) ) { |
|
| 1546 | + $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 1547 | 1547 | |
| 1548 | 1548 | $args = array( |
| 1549 | - 'name' => $sanitized_field_name, |
|
| 1550 | - 'id' => $sanitized_field_name, |
|
| 1551 | - 'class' => $sanitized_field_name . ' wpinv-select wpi_select2', |
|
| 1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1553 | - 'show_option_all' => false, |
|
| 1554 | - 'show_option_none' => false |
|
| 1555 | - ); |
|
| 1556 | - |
|
| 1557 | - $response = wpinv_html_select( $args ); |
|
| 1558 | - |
|
| 1559 | - } else { |
|
| 1560 | - $response = 'nostates'; |
|
| 1561 | - } |
|
| 1549 | + 'name' => $sanitized_field_name, |
|
| 1550 | + 'id' => $sanitized_field_name, |
|
| 1551 | + 'class' => $sanitized_field_name . ' wpinv-select wpi_select2', |
|
| 1552 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1553 | + 'show_option_all' => false, |
|
| 1554 | + 'show_option_none' => false |
|
| 1555 | + ); |
|
| 1556 | + |
|
| 1557 | + $response = wpinv_html_select( $args ); |
|
| 1558 | + |
|
| 1559 | + } else { |
|
| 1560 | + $response = 'nostates'; |
|
| 1561 | + } |
|
| 1562 | 1562 | |
| 1563 | - return $response; |
|
| 1563 | + return $response; |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
@@ -1,149 +1,149 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 11 | - * |
|
| 12 | - * Should not be called direct but extended instead. |
|
| 13 | - * |
|
| 14 | - * Class WP_Super_Duper |
|
| 15 | - * @since 1.0.3 is_block_content_call() method added. |
|
| 16 | - * @since 1.0.3 Placeholder text will be shown for widget that return no block content. |
|
| 17 | - * @since 1.0.4 is_elementor_widget_output() method added. |
|
| 18 | - * @since 1.0.4 is_elementor_preview() method added. |
|
| 19 | - * @since 1.0.5 Block checkbox options are set as true by default even when set as false - FIXED |
|
| 20 | - * @since 1.0.6 Some refactoring for page builders - CHANGED |
|
| 21 | - * @since 1.0.7 Some refactoring for page builders - CHANGED |
|
| 22 | - * @since 1.0.8 Some refactoring for page builders ( cornerstone builder now supported ) - CHANGED |
|
| 23 | - * @since 1.0.9 Numbers saving as strings and not numbers which can cause block render issues on refresh - FIXED |
|
| 24 | - * @since 1.0.10 Some refactoring for page builders ( Avia builder for Enfold theme now supported ) - CHANGED |
|
| 25 | - * @since 1.0.11 Some refactoring for page builders - CHANGED |
|
| 26 | - * @since 1.0.12 A checkbox default value can make a argument true even when unchecked - FIXED |
|
| 27 | - * @ver 1.0.12 |
|
| 28 | - */ |
|
| 29 | - class WP_Super_Duper extends WP_Widget { |
|
| 30 | - |
|
| 31 | - public $version = "1.0.12"; |
|
| 32 | - public $block_code; |
|
| 33 | - public $options; |
|
| 34 | - public $base_id; |
|
| 35 | - public $arguments = array(); |
|
| 36 | - public $instance = array(); |
|
| 37 | - private $class_name; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Take the array options and use them to build. |
|
| 41 | - */ |
|
| 42 | - public function __construct( $options ) { |
|
| 43 | - global $sd_widgets; |
|
| 44 | - |
|
| 45 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 46 | - 'name' => $options['name'], |
|
| 47 | - 'class_name' => $options['class_name'] |
|
| 48 | - ); |
|
| 49 | - $this->base_id = $options['base_id']; |
|
| 50 | - // lets filter the options before we do anything |
|
| 51 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 52 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 53 | - $options = $this->add_name_from_key( $options ); |
|
| 54 | - $this->options = $options; |
|
| 55 | - |
|
| 56 | - $this->base_id = $options['base_id']; |
|
| 57 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 58 | - |
|
| 59 | - // init parent |
|
| 60 | - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 61 | - |
|
| 62 | - if ( isset( $options['class_name'] ) ) { |
|
| 63 | - // register widget |
|
| 64 | - $this->class_name = $options['class_name']; |
|
| 65 | - |
|
| 66 | - // register shortcode |
|
| 67 | - $this->register_shortcode(); |
|
| 68 | - |
|
| 69 | - // register block |
|
| 70 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - // add the CSS and JS we need ONCE |
|
| 74 | - global $sd_widget_scripts; |
|
| 75 | - |
|
| 76 | - if ( ! $sd_widget_scripts ) { |
|
| 77 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 78 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 79 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 80 | - |
|
| 81 | - $sd_widget_scripts = true; |
|
| 82 | - |
|
| 83 | - // add shortcode insert button once |
|
| 84 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 85 | - if ( $this->is_preview() ) { |
|
| 86 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 87 | - // this makes the insert button work for elementor |
|
| 88 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 89 | - $this, |
|
| 90 | - 'shortcode_insert_button_script' |
|
| 91 | - ) ); // for elementor |
|
| 92 | - } |
|
| 93 | - // this makes the insert button work for cornerstone |
|
| 94 | - add_action('wp_print_footer_scripts',array( __CLASS__, 'maybe_cornerstone_builder' )); |
|
| 95 | - |
|
| 96 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 97 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 98 | - |
|
| 99 | - // add generator text to admin head |
|
| 100 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 108 | - */ |
|
| 109 | - public static function maybe_cornerstone_builder(){ |
|
| 110 | - if(did_action('cornerstone_before_boot_app')){ |
|
| 111 | - self::shortcode_insert_button_script(); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * A function to ge the shortcode builder picker html. |
|
| 117 | - * |
|
| 118 | - * @param string $editor_id |
|
| 119 | - * |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - public static function get_picker( $editor_id = '' ) { |
|
| 123 | - |
|
| 124 | - ob_start(); |
|
| 125 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 126 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 127 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 128 | - $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - global $sd_widgets; |
|
| 132 | - ?> |
|
| 9 | + /** |
|
| 10 | + * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 11 | + * |
|
| 12 | + * Should not be called direct but extended instead. |
|
| 13 | + * |
|
| 14 | + * Class WP_Super_Duper |
|
| 15 | + * @since 1.0.3 is_block_content_call() method added. |
|
| 16 | + * @since 1.0.3 Placeholder text will be shown for widget that return no block content. |
|
| 17 | + * @since 1.0.4 is_elementor_widget_output() method added. |
|
| 18 | + * @since 1.0.4 is_elementor_preview() method added. |
|
| 19 | + * @since 1.0.5 Block checkbox options are set as true by default even when set as false - FIXED |
|
| 20 | + * @since 1.0.6 Some refactoring for page builders - CHANGED |
|
| 21 | + * @since 1.0.7 Some refactoring for page builders - CHANGED |
|
| 22 | + * @since 1.0.8 Some refactoring for page builders ( cornerstone builder now supported ) - CHANGED |
|
| 23 | + * @since 1.0.9 Numbers saving as strings and not numbers which can cause block render issues on refresh - FIXED |
|
| 24 | + * @since 1.0.10 Some refactoring for page builders ( Avia builder for Enfold theme now supported ) - CHANGED |
|
| 25 | + * @since 1.0.11 Some refactoring for page builders - CHANGED |
|
| 26 | + * @since 1.0.12 A checkbox default value can make a argument true even when unchecked - FIXED |
|
| 27 | + * @ver 1.0.12 |
|
| 28 | + */ |
|
| 29 | + class WP_Super_Duper extends WP_Widget { |
|
| 30 | + |
|
| 31 | + public $version = "1.0.12"; |
|
| 32 | + public $block_code; |
|
| 33 | + public $options; |
|
| 34 | + public $base_id; |
|
| 35 | + public $arguments = array(); |
|
| 36 | + public $instance = array(); |
|
| 37 | + private $class_name; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Take the array options and use them to build. |
|
| 41 | + */ |
|
| 42 | + public function __construct( $options ) { |
|
| 43 | + global $sd_widgets; |
|
| 44 | + |
|
| 45 | + $sd_widgets[ $options['base_id'] ] = array( |
|
| 46 | + 'name' => $options['name'], |
|
| 47 | + 'class_name' => $options['class_name'] |
|
| 48 | + ); |
|
| 49 | + $this->base_id = $options['base_id']; |
|
| 50 | + // lets filter the options before we do anything |
|
| 51 | + $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 52 | + $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 53 | + $options = $this->add_name_from_key( $options ); |
|
| 54 | + $this->options = $options; |
|
| 55 | + |
|
| 56 | + $this->base_id = $options['base_id']; |
|
| 57 | + $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 58 | + |
|
| 59 | + // init parent |
|
| 60 | + parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 61 | + |
|
| 62 | + if ( isset( $options['class_name'] ) ) { |
|
| 63 | + // register widget |
|
| 64 | + $this->class_name = $options['class_name']; |
|
| 65 | + |
|
| 66 | + // register shortcode |
|
| 67 | + $this->register_shortcode(); |
|
| 68 | + |
|
| 69 | + // register block |
|
| 70 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // add the CSS and JS we need ONCE |
|
| 74 | + global $sd_widget_scripts; |
|
| 75 | + |
|
| 76 | + if ( ! $sd_widget_scripts ) { |
|
| 77 | + wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 78 | + wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 79 | + wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 80 | + |
|
| 81 | + $sd_widget_scripts = true; |
|
| 82 | + |
|
| 83 | + // add shortcode insert button once |
|
| 84 | + add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 85 | + if ( $this->is_preview() ) { |
|
| 86 | + add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 87 | + // this makes the insert button work for elementor |
|
| 88 | + add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 89 | + $this, |
|
| 90 | + 'shortcode_insert_button_script' |
|
| 91 | + ) ); // for elementor |
|
| 92 | + } |
|
| 93 | + // this makes the insert button work for cornerstone |
|
| 94 | + add_action('wp_print_footer_scripts',array( __CLASS__, 'maybe_cornerstone_builder' )); |
|
| 95 | + |
|
| 96 | + add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 97 | + add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 98 | + |
|
| 99 | + // add generator text to admin head |
|
| 100 | + add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 108 | + */ |
|
| 109 | + public static function maybe_cornerstone_builder(){ |
|
| 110 | + if(did_action('cornerstone_before_boot_app')){ |
|
| 111 | + self::shortcode_insert_button_script(); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * A function to ge the shortcode builder picker html. |
|
| 117 | + * |
|
| 118 | + * @param string $editor_id |
|
| 119 | + * |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + public static function get_picker( $editor_id = '' ) { |
|
| 123 | + |
|
| 124 | + ob_start(); |
|
| 125 | + if ( isset( $_POST['editor_id'] ) ) { |
|
| 126 | + $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 127 | + } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 128 | + $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + global $sd_widgets; |
|
| 132 | + ?> |
|
| 133 | 133 | |
| 134 | 134 | <div class="sd-shortcode-left-wrap"> |
| 135 | 135 | <?php |
| 136 | - asort( $sd_widgets ); |
|
| 137 | - if ( ! empty( $sd_widgets ) ) { |
|
| 138 | - echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 139 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 140 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 141 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 142 | - } |
|
| 143 | - echo "</select>"; |
|
| 144 | - |
|
| 145 | - } |
|
| 146 | - ?> |
|
| 136 | + asort( $sd_widgets ); |
|
| 137 | + if ( ! empty( $sd_widgets ) ) { |
|
| 138 | + echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 139 | + echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 140 | + foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 141 | + echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 142 | + } |
|
| 143 | + echo "</select>"; |
|
| 144 | + |
|
| 145 | + } |
|
| 146 | + ?> |
|
| 147 | 147 | <div class="sd-shortcode-settings"></div> |
| 148 | 148 | |
| 149 | 149 | </div> |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | <?php if ( $editor_id != '' ) { ?> |
| 155 | 155 | <button class="button sd-insert-shortcode-button" |
| 156 | 156 | onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
| 157 | - echo "'" . $editor_id . "'"; |
|
| 158 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 157 | + echo "'" . $editor_id . "'"; |
|
| 158 | + } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 159 | 159 | <?php } ?> |
| 160 | 160 | <button class="button" |
| 161 | 161 | onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
@@ -163,129 +163,129 @@ discard block |
||
| 163 | 163 | </div> |
| 164 | 164 | <?php |
| 165 | 165 | |
| 166 | - $html = ob_get_clean(); |
|
| 167 | - |
|
| 168 | - if ( wp_doing_ajax() ) { |
|
| 169 | - echo $html; |
|
| 170 | - $should_die = true; |
|
| 171 | - |
|
| 172 | - // some builder get the editor via ajax so we should not die on those ocasions |
|
| 173 | - $dont_die = array( |
|
| 174 | - 'parent_tag',// WP Bakery |
|
| 175 | - 'avia_request' // enfold |
|
| 176 | - ); |
|
| 177 | - |
|
| 178 | - foreach ( $dont_die as $request ) { |
|
| 179 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 180 | - $should_die = false; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ( $should_die ) { |
|
| 185 | - wp_die(); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - } else { |
|
| 189 | - return $html; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - return ''; |
|
| 193 | - |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Output the version in the admin header. |
|
| 198 | - */ |
|
| 199 | - public function generator() { |
|
| 200 | - echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Get widget settings. |
|
| 205 | - * |
|
| 206 | - * @since 1.0.0 |
|
| 207 | - */ |
|
| 208 | - public static function get_widget_settings() { |
|
| 209 | - global $sd_widgets; |
|
| 210 | - |
|
| 211 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 212 | - if ( ! $shortcode ) { |
|
| 213 | - wp_die(); |
|
| 214 | - } |
|
| 215 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 216 | - if ( ! $widget_args ) { |
|
| 217 | - wp_die(); |
|
| 218 | - } |
|
| 219 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 220 | - if ( ! $class_name ) { |
|
| 221 | - wp_die(); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - // invoke an instance method |
|
| 225 | - $widget = new $class_name; |
|
| 226 | - |
|
| 227 | - ob_start(); |
|
| 228 | - $widget->form( array() ); |
|
| 229 | - $form = ob_get_clean(); |
|
| 230 | - echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 231 | - echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 232 | - echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 233 | - ?> |
|
| 166 | + $html = ob_get_clean(); |
|
| 167 | + |
|
| 168 | + if ( wp_doing_ajax() ) { |
|
| 169 | + echo $html; |
|
| 170 | + $should_die = true; |
|
| 171 | + |
|
| 172 | + // some builder get the editor via ajax so we should not die on those ocasions |
|
| 173 | + $dont_die = array( |
|
| 174 | + 'parent_tag',// WP Bakery |
|
| 175 | + 'avia_request' // enfold |
|
| 176 | + ); |
|
| 177 | + |
|
| 178 | + foreach ( $dont_die as $request ) { |
|
| 179 | + if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 180 | + $should_die = false; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ( $should_die ) { |
|
| 185 | + wp_die(); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + } else { |
|
| 189 | + return $html; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + return ''; |
|
| 193 | + |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Output the version in the admin header. |
|
| 198 | + */ |
|
| 199 | + public function generator() { |
|
| 200 | + echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Get widget settings. |
|
| 205 | + * |
|
| 206 | + * @since 1.0.0 |
|
| 207 | + */ |
|
| 208 | + public static function get_widget_settings() { |
|
| 209 | + global $sd_widgets; |
|
| 210 | + |
|
| 211 | + $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 212 | + if ( ! $shortcode ) { |
|
| 213 | + wp_die(); |
|
| 214 | + } |
|
| 215 | + $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 216 | + if ( ! $widget_args ) { |
|
| 217 | + wp_die(); |
|
| 218 | + } |
|
| 219 | + $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 220 | + if ( ! $class_name ) { |
|
| 221 | + wp_die(); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + // invoke an instance method |
|
| 225 | + $widget = new $class_name; |
|
| 226 | + |
|
| 227 | + ob_start(); |
|
| 228 | + $widget->form( array() ); |
|
| 229 | + $form = ob_get_clean(); |
|
| 230 | + echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 231 | + echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 232 | + echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 233 | + ?> |
|
| 234 | 234 | <?php |
| 235 | - wp_die(); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 240 | - * |
|
| 241 | - * @since 1.0.0 |
|
| 242 | - * |
|
| 243 | - * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 244 | - * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null. |
|
| 245 | - */ |
|
| 246 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 247 | - global $sd_widgets, $shortcode_insert_button_once; |
|
| 248 | - if ( $shortcode_insert_button_once ) { |
|
| 249 | - return; |
|
| 250 | - } |
|
| 251 | - add_thickbox(); |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * Cornerstone makes us play dirty tricks :/ |
|
| 256 | - * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 257 | - */ |
|
| 258 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 259 | - echo '<span id="insert-media-button">'; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 263 | - |
|
| 264 | - // see opening note |
|
| 265 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 266 | - echo '</span>'; // end #insert-media-button |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 270 | - $shortcode_insert_button_once = true; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * Gets the shortcode insert button html. |
|
| 275 | - * |
|
| 276 | - * @param string $id |
|
| 277 | - * @param string $search_for_id |
|
| 278 | - * |
|
| 279 | - * @return mixed |
|
| 280 | - */ |
|
| 281 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 282 | - ob_start(); |
|
| 283 | - ?> |
|
| 235 | + wp_die(); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 240 | + * |
|
| 241 | + * @since 1.0.0 |
|
| 242 | + * |
|
| 243 | + * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 244 | + * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null. |
|
| 245 | + */ |
|
| 246 | + public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 247 | + global $sd_widgets, $shortcode_insert_button_once; |
|
| 248 | + if ( $shortcode_insert_button_once ) { |
|
| 249 | + return; |
|
| 250 | + } |
|
| 251 | + add_thickbox(); |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Cornerstone makes us play dirty tricks :/ |
|
| 256 | + * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 257 | + */ |
|
| 258 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 259 | + echo '<span id="insert-media-button">'; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + echo self::shortcode_button( 'this', 'true' ); |
|
| 263 | + |
|
| 264 | + // see opening note |
|
| 265 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 266 | + echo '</span>'; // end #insert-media-button |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 270 | + $shortcode_insert_button_once = true; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * Gets the shortcode insert button html. |
|
| 275 | + * |
|
| 276 | + * @param string $id |
|
| 277 | + * @param string $search_for_id |
|
| 278 | + * |
|
| 279 | + * @return mixed |
|
| 280 | + */ |
|
| 281 | + public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 282 | + ob_start(); |
|
| 283 | + ?> |
|
| 284 | 284 | <span class="sd-lable-shortcode-inserter"> |
| 285 | 285 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 286 | - if ( $search_for_id ) { |
|
| 287 | - echo "," . $search_for_id; |
|
| 288 | - } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 286 | + if ( $search_for_id ) { |
|
| 287 | + echo "," . $search_for_id; |
|
| 288 | + } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 289 | 289 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
| 290 | 290 | <span style="vertical-align: middle;line-height: 18px;font-size: 20px;" |
| 291 | 291 | class="dashicons dashicons-screenoptions"></span> |
@@ -296,21 +296,21 @@ discard block |
||
| 296 | 296 | </span> |
| 297 | 297 | |
| 298 | 298 | <?php |
| 299 | - $html = ob_get_clean(); |
|
| 300 | - |
|
| 301 | - // remove line breaks so we can use it in js |
|
| 302 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Makes SD work with the siteOrigin page builder. |
|
| 307 | - * |
|
| 308 | - * @since 1.0.6 |
|
| 309 | - * @return mixed |
|
| 310 | - */ |
|
| 311 | - public static function siteorigin_js() { |
|
| 312 | - ob_start(); |
|
| 313 | - ?> |
|
| 299 | + $html = ob_get_clean(); |
|
| 300 | + |
|
| 301 | + // remove line breaks so we can use it in js |
|
| 302 | + return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Makes SD work with the siteOrigin page builder. |
|
| 307 | + * |
|
| 308 | + * @since 1.0.6 |
|
| 309 | + * @return mixed |
|
| 310 | + */ |
|
| 311 | + public static function siteorigin_js() { |
|
| 312 | + ob_start(); |
|
| 313 | + ?> |
|
| 314 | 314 | <script> |
| 315 | 315 | /** |
| 316 | 316 | * Check a form to see what items shoudl be shown or hidden. |
@@ -388,28 +388,28 @@ discard block |
||
| 388 | 388 | }); |
| 389 | 389 | </script> |
| 390 | 390 | <?php |
| 391 | - $output = ob_get_clean(); |
|
| 391 | + $output = ob_get_clean(); |
|
| 392 | 392 | |
| 393 | - /* |
|
| 393 | + /* |
|
| 394 | 394 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 395 | 395 | */ |
| 396 | 396 | |
| 397 | - return str_replace( array( |
|
| 398 | - '<script>', |
|
| 399 | - '</script>' |
|
| 400 | - ), '', $output ); |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * Output the JS and CSS for the shortcode insert button. |
|
| 405 | - * |
|
| 406 | - * @since 1.0.6 |
|
| 407 | - * |
|
| 408 | - * @param string $editor_id |
|
| 409 | - * @param string $insert_shortcode_function |
|
| 410 | - */ |
|
| 411 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 412 | - ?> |
|
| 397 | + return str_replace( array( |
|
| 398 | + '<script>', |
|
| 399 | + '</script>' |
|
| 400 | + ), '', $output ); |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * Output the JS and CSS for the shortcode insert button. |
|
| 405 | + * |
|
| 406 | + * @since 1.0.6 |
|
| 407 | + * |
|
| 408 | + * @param string $editor_id |
|
| 409 | + * @param string $insert_shortcode_function |
|
| 410 | + */ |
|
| 411 | + public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 412 | + ?> |
|
| 413 | 413 | <style> |
| 414 | 414 | .sd-shortcode-left-wrap { |
| 415 | 415 | float: left; |
@@ -528,22 +528,22 @@ discard block |
||
| 528 | 528 | } |
| 529 | 529 | </style> |
| 530 | 530 | <?php |
| 531 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 532 | - echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 533 | - } |
|
| 534 | - ?> |
|
| 531 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 532 | + echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 533 | + } |
|
| 534 | + ?> |
|
| 535 | 535 | <script> |
| 536 | 536 | <?php |
| 537 | - if(! empty( $insert_shortcode_function )){ |
|
| 538 | - echo $insert_shortcode_function; |
|
| 539 | - }else{ |
|
| 540 | - |
|
| 541 | - /** |
|
| 542 | - * Function for super duper insert shortcode. |
|
| 543 | - * |
|
| 544 | - * @since 1.0.0 |
|
| 545 | - */ |
|
| 546 | - ?> |
|
| 537 | + if(! empty( $insert_shortcode_function )){ |
|
| 538 | + echo $insert_shortcode_function; |
|
| 539 | + }else{ |
|
| 540 | + |
|
| 541 | + /** |
|
| 542 | + * Function for super duper insert shortcode. |
|
| 543 | + * |
|
| 544 | + * @since 1.0.0 |
|
| 545 | + */ |
|
| 546 | + ?> |
|
| 547 | 547 | function sd_insert_shortcode($editor_id) { |
| 548 | 548 | $shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val(); |
| 549 | 549 | if ($shortcode) { |
@@ -551,14 +551,14 @@ discard block |
||
| 551 | 551 | if (!$editor_id) { |
| 552 | 552 | |
| 553 | 553 | <?php |
| 554 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 555 | - echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 556 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 557 | - echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 558 | - } else { |
|
| 559 | - echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 560 | - } |
|
| 561 | - ?> |
|
| 554 | + if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 555 | + echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 556 | + } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 557 | + echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 558 | + } else { |
|
| 559 | + echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 560 | + } |
|
| 561 | + ?> |
|
| 562 | 562 | } else { |
| 563 | 563 | $editor_id = '#' + $editor_id; |
| 564 | 564 | } |
@@ -868,16 +868,16 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | </script> |
| 870 | 870 | <?php |
| 871 | - } |
|
| 872 | - |
|
| 873 | - /** |
|
| 874 | - * Gets some CSS for the widgets screen. |
|
| 875 | - * |
|
| 876 | - * @return mixed |
|
| 877 | - */ |
|
| 878 | - public function widget_css() { |
|
| 879 | - ob_start(); |
|
| 880 | - ?> |
|
| 871 | + } |
|
| 872 | + |
|
| 873 | + /** |
|
| 874 | + * Gets some CSS for the widgets screen. |
|
| 875 | + * |
|
| 876 | + * @return mixed |
|
| 877 | + */ |
|
| 878 | + public function widget_css() { |
|
| 879 | + ob_start(); |
|
| 880 | + ?> |
|
| 881 | 881 | <style> |
| 882 | 882 | .sd-advanced-setting { |
| 883 | 883 | display: none; |
@@ -898,26 +898,26 @@ discard block |
||
| 898 | 898 | } |
| 899 | 899 | </style> |
| 900 | 900 | <?php |
| 901 | - $output = ob_get_clean(); |
|
| 901 | + $output = ob_get_clean(); |
|
| 902 | 902 | |
| 903 | - /* |
|
| 903 | + /* |
|
| 904 | 904 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 905 | 905 | */ |
| 906 | 906 | |
| 907 | - return str_replace( array( |
|
| 908 | - '<style>', |
|
| 909 | - '</style>' |
|
| 910 | - ), '', $output ); |
|
| 911 | - } |
|
| 912 | - |
|
| 913 | - /** |
|
| 914 | - * Gets some JS for the widgets screen. |
|
| 915 | - * |
|
| 916 | - * @return mixed |
|
| 917 | - */ |
|
| 918 | - public function widget_js() { |
|
| 919 | - ob_start(); |
|
| 920 | - ?> |
|
| 907 | + return str_replace( array( |
|
| 908 | + '<style>', |
|
| 909 | + '</style>' |
|
| 910 | + ), '', $output ); |
|
| 911 | + } |
|
| 912 | + |
|
| 913 | + /** |
|
| 914 | + * Gets some JS for the widgets screen. |
|
| 915 | + * |
|
| 916 | + * @return mixed |
|
| 917 | + */ |
|
| 918 | + public function widget_js() { |
|
| 919 | + ob_start(); |
|
| 920 | + ?> |
|
| 921 | 921 | <script> |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -1072,307 +1072,307 @@ discard block |
||
| 1072 | 1072 | <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
| 1073 | 1073 | </script> |
| 1074 | 1074 | <?php |
| 1075 | - $output = ob_get_clean(); |
|
| 1075 | + $output = ob_get_clean(); |
|
| 1076 | 1076 | |
| 1077 | - /* |
|
| 1077 | + /* |
|
| 1078 | 1078 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1079 | 1079 | */ |
| 1080 | 1080 | |
| 1081 | - return str_replace( array( |
|
| 1082 | - '<script>', |
|
| 1083 | - '</script>' |
|
| 1084 | - ), '', $output ); |
|
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - |
|
| 1088 | - /** |
|
| 1089 | - * Set the name from the argument key. |
|
| 1090 | - * |
|
| 1091 | - * @param $options |
|
| 1092 | - * |
|
| 1093 | - * @return mixed |
|
| 1094 | - */ |
|
| 1095 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1096 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1097 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1098 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1099 | - } |
|
| 1100 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1101 | - foreach ( $options as $key => $val ) { |
|
| 1102 | - $options[ $key ]['name'] = $key; |
|
| 1103 | - } |
|
| 1104 | - } |
|
| 1105 | - |
|
| 1106 | - return $options; |
|
| 1107 | - } |
|
| 1108 | - |
|
| 1109 | - /** |
|
| 1110 | - * Register the parent shortcode. |
|
| 1111 | - * |
|
| 1112 | - * @since 1.0.0 |
|
| 1113 | - */ |
|
| 1114 | - public function register_shortcode() { |
|
| 1115 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1116 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) ); |
|
| 1117 | - } |
|
| 1118 | - |
|
| 1119 | - /** |
|
| 1120 | - * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1121 | - * |
|
| 1122 | - * @since 1.0.0 |
|
| 1123 | - */ |
|
| 1124 | - public static function render_shortcode() { |
|
| 1125 | - |
|
| 1126 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1127 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1128 | - wp_die(); |
|
| 1129 | - } |
|
| 1130 | - |
|
| 1131 | - // we might need the $post value here so lets set it. |
|
| 1132 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1133 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1134 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1135 | - global $post; |
|
| 1136 | - $post = $post_obj; |
|
| 1137 | - } |
|
| 1138 | - } |
|
| 1139 | - |
|
| 1140 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1141 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1142 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1143 | - $attributes = ''; |
|
| 1144 | - if ( ! empty( $attributes_array ) ) { |
|
| 1145 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1146 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' "; |
|
| 1147 | - } |
|
| 1148 | - } |
|
| 1149 | - |
|
| 1150 | - $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1151 | - |
|
| 1152 | - echo do_shortcode( $shortcode ); |
|
| 1153 | - |
|
| 1154 | - } |
|
| 1155 | - wp_die(); |
|
| 1156 | - } |
|
| 1157 | - |
|
| 1158 | - /** |
|
| 1159 | - * Output the shortcode. |
|
| 1160 | - * |
|
| 1161 | - * @param array $args |
|
| 1162 | - * @param string $content |
|
| 1163 | - * |
|
| 1164 | - * @return string |
|
| 1165 | - */ |
|
| 1166 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1167 | - $args = self::argument_values( $args ); |
|
| 1168 | - |
|
| 1169 | - // add extra argument so we know its a output to gutenberg |
|
| 1170 | - //$args |
|
| 1171 | - $args = $this->string_to_bool( $args ); |
|
| 1172 | - |
|
| 1173 | - |
|
| 1174 | - $calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1175 | - |
|
| 1176 | - $calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this ); |
|
| 1177 | - $calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this ); |
|
| 1178 | - |
|
| 1179 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1180 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1181 | - |
|
| 1182 | - $shortcode_args = array(); |
|
| 1183 | - $output = ''; |
|
| 1184 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1185 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1186 | - if ( $main_content && ! $no_wrap ) { |
|
| 1187 | - // wrap the shortcode in a dive with the same class as the widget |
|
| 1188 | - $output .= '<div class="' . $calss . '" ' . $attrs . '>'; |
|
| 1189 | - if ( ! empty( $args['title'] ) ) { |
|
| 1190 | - // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1191 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1192 | - if ( empty( $instance ) ) { |
|
| 1193 | - global $wp_registered_sidebars; |
|
| 1194 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1195 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1196 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1197 | - $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1198 | - $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1199 | - break; |
|
| 1200 | - } |
|
| 1201 | - } |
|
| 1202 | - } |
|
| 1203 | - } |
|
| 1204 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1205 | - } |
|
| 1206 | - $output .= $main_content; |
|
| 1207 | - $output .= '</div>'; |
|
| 1208 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1209 | - $output .= $main_content; |
|
| 1210 | - } |
|
| 1211 | - |
|
| 1212 | - // if preview show a placeholder if empty |
|
| 1213 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1214 | - $output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" ); |
|
| 1215 | - } |
|
| 1216 | - |
|
| 1217 | - return $output; |
|
| 1218 | - } |
|
| 1219 | - |
|
| 1220 | - /** |
|
| 1221 | - * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1222 | - * |
|
| 1223 | - * @param string $name |
|
| 1224 | - * |
|
| 1225 | - * @return string |
|
| 1226 | - */ |
|
| 1227 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1228 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1229 | - } |
|
| 1230 | - |
|
| 1231 | - /** |
|
| 1232 | - * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1233 | - * |
|
| 1234 | - * @param $options |
|
| 1235 | - * |
|
| 1236 | - * @return mixed |
|
| 1237 | - */ |
|
| 1238 | - public function string_to_bool( $options ) { |
|
| 1239 | - // convert bool strings to booleans |
|
| 1240 | - foreach ( $options as $key => $val ) { |
|
| 1241 | - if ( $val == 'false' ) { |
|
| 1242 | - $options[ $key ] = false; |
|
| 1243 | - } elseif ( $val == 'true' ) { |
|
| 1244 | - $options[ $key ] = true; |
|
| 1245 | - } |
|
| 1246 | - } |
|
| 1247 | - |
|
| 1248 | - return $options; |
|
| 1249 | - } |
|
| 1250 | - |
|
| 1251 | - /** |
|
| 1252 | - * Get the argument values that are also filterable. |
|
| 1253 | - * |
|
| 1254 | - * @param $instance |
|
| 1255 | - * |
|
| 1256 | - * @since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1257 | - * |
|
| 1258 | - * @return array |
|
| 1259 | - */ |
|
| 1260 | - public function argument_values( $instance ) { |
|
| 1261 | - $argument_values = array(); |
|
| 1262 | - |
|
| 1263 | - // set widget instance |
|
| 1264 | - $this->instance = $instance; |
|
| 1265 | - |
|
| 1266 | - if ( empty( $this->arguments ) ) { |
|
| 1267 | - $this->arguments = $this->get_arguments(); |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - if ( ! empty( $this->arguments ) ) { |
|
| 1271 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1272 | - // set the input name from the key |
|
| 1273 | - $args['name'] = $key; |
|
| 1274 | - // |
|
| 1275 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1276 | - if($args['type']=='checkbox' && $argument_values[ $key ] == ''){ |
|
| 1277 | - // don't set default for an empty checkbox |
|
| 1278 | - } |
|
| 1279 | - elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1280 | - $argument_values[ $key ] = $args['default']; |
|
| 1281 | - } |
|
| 1282 | - } |
|
| 1283 | - } |
|
| 1284 | - |
|
| 1285 | - return $argument_values; |
|
| 1286 | - } |
|
| 1287 | - |
|
| 1288 | - /** |
|
| 1289 | - * Set arguments in super duper. |
|
| 1290 | - * |
|
| 1291 | - * @since 1.0.0 |
|
| 1292 | - * |
|
| 1293 | - * @return array Set arguments. |
|
| 1294 | - */ |
|
| 1295 | - public function set_arguments() { |
|
| 1296 | - return $this->arguments; |
|
| 1297 | - } |
|
| 1298 | - |
|
| 1299 | - /** |
|
| 1300 | - * Get arguments in super duper. |
|
| 1301 | - * |
|
| 1302 | - * @since 1.0.0 |
|
| 1303 | - * |
|
| 1304 | - * @return array Get arguments. |
|
| 1305 | - */ |
|
| 1306 | - public function get_arguments() { |
|
| 1307 | - if ( empty( $this->arguments ) ) { |
|
| 1308 | - $this->arguments = $this->set_arguments(); |
|
| 1309 | - } |
|
| 1310 | - |
|
| 1311 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1312 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1313 | - |
|
| 1314 | - return $this->arguments; |
|
| 1315 | - } |
|
| 1316 | - |
|
| 1317 | - /** |
|
| 1318 | - * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1319 | - * |
|
| 1320 | - * @param array $args |
|
| 1321 | - * @param array $widget_args |
|
| 1322 | - * @param string $content |
|
| 1323 | - */ |
|
| 1324 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1325 | - |
|
| 1326 | - } |
|
| 1327 | - |
|
| 1328 | - /** |
|
| 1329 | - * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1330 | - */ |
|
| 1331 | - public function register_block() { |
|
| 1332 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1333 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1334 | - |
|
| 1335 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1336 | - |
|
| 1337 | - } |
|
| 1338 | - } |
|
| 1339 | - |
|
| 1340 | - /** |
|
| 1341 | - * Check if we need to show advanced options. |
|
| 1342 | - * |
|
| 1343 | - * @return bool |
|
| 1344 | - */ |
|
| 1345 | - public function block_show_advanced() { |
|
| 1346 | - |
|
| 1347 | - $show = false; |
|
| 1348 | - $arguments = $this->arguments; |
|
| 1349 | - |
|
| 1350 | - if ( empty( $arguments ) ) { |
|
| 1351 | - $arguments = $this->get_arguments(); |
|
| 1352 | - } |
|
| 1353 | - |
|
| 1354 | - if ( ! empty( $arguments ) ) { |
|
| 1355 | - foreach ( $arguments as $argument ) { |
|
| 1356 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1357 | - $show = true; |
|
| 1358 | - } |
|
| 1359 | - } |
|
| 1360 | - } |
|
| 1361 | - |
|
| 1362 | - return $show; |
|
| 1363 | - } |
|
| 1364 | - |
|
| 1365 | - |
|
| 1366 | - /** |
|
| 1367 | - * Output the JS for building the dynamic Guntenberg block. |
|
| 1368 | - * |
|
| 1369 | - * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1370 | - * @since 1.0.9 Save numbers as numbers and not strings. |
|
| 1371 | - * @return mixed |
|
| 1372 | - */ |
|
| 1373 | - public function block() { |
|
| 1374 | - ob_start(); |
|
| 1375 | - ?> |
|
| 1081 | + return str_replace( array( |
|
| 1082 | + '<script>', |
|
| 1083 | + '</script>' |
|
| 1084 | + ), '', $output ); |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + |
|
| 1088 | + /** |
|
| 1089 | + * Set the name from the argument key. |
|
| 1090 | + * |
|
| 1091 | + * @param $options |
|
| 1092 | + * |
|
| 1093 | + * @return mixed |
|
| 1094 | + */ |
|
| 1095 | + private function add_name_from_key( $options, $arguments = false ) { |
|
| 1096 | + if ( ! empty( $options['arguments'] ) ) { |
|
| 1097 | + foreach ( $options['arguments'] as $key => $val ) { |
|
| 1098 | + $options['arguments'][ $key ]['name'] = $key; |
|
| 1099 | + } |
|
| 1100 | + } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1101 | + foreach ( $options as $key => $val ) { |
|
| 1102 | + $options[ $key ]['name'] = $key; |
|
| 1103 | + } |
|
| 1104 | + } |
|
| 1105 | + |
|
| 1106 | + return $options; |
|
| 1107 | + } |
|
| 1108 | + |
|
| 1109 | + /** |
|
| 1110 | + * Register the parent shortcode. |
|
| 1111 | + * |
|
| 1112 | + * @since 1.0.0 |
|
| 1113 | + */ |
|
| 1114 | + public function register_shortcode() { |
|
| 1115 | + add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1116 | + add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) ); |
|
| 1117 | + } |
|
| 1118 | + |
|
| 1119 | + /** |
|
| 1120 | + * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1121 | + * |
|
| 1122 | + * @since 1.0.0 |
|
| 1123 | + */ |
|
| 1124 | + public static function render_shortcode() { |
|
| 1125 | + |
|
| 1126 | + check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1127 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1128 | + wp_die(); |
|
| 1129 | + } |
|
| 1130 | + |
|
| 1131 | + // we might need the $post value here so lets set it. |
|
| 1132 | + if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1133 | + $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1134 | + if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1135 | + global $post; |
|
| 1136 | + $post = $post_obj; |
|
| 1137 | + } |
|
| 1138 | + } |
|
| 1139 | + |
|
| 1140 | + if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1141 | + $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1142 | + $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1143 | + $attributes = ''; |
|
| 1144 | + if ( ! empty( $attributes_array ) ) { |
|
| 1145 | + foreach ( $attributes_array as $key => $value ) { |
|
| 1146 | + $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' "; |
|
| 1147 | + } |
|
| 1148 | + } |
|
| 1149 | + |
|
| 1150 | + $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1151 | + |
|
| 1152 | + echo do_shortcode( $shortcode ); |
|
| 1153 | + |
|
| 1154 | + } |
|
| 1155 | + wp_die(); |
|
| 1156 | + } |
|
| 1157 | + |
|
| 1158 | + /** |
|
| 1159 | + * Output the shortcode. |
|
| 1160 | + * |
|
| 1161 | + * @param array $args |
|
| 1162 | + * @param string $content |
|
| 1163 | + * |
|
| 1164 | + * @return string |
|
| 1165 | + */ |
|
| 1166 | + public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1167 | + $args = self::argument_values( $args ); |
|
| 1168 | + |
|
| 1169 | + // add extra argument so we know its a output to gutenberg |
|
| 1170 | + //$args |
|
| 1171 | + $args = $this->string_to_bool( $args ); |
|
| 1172 | + |
|
| 1173 | + |
|
| 1174 | + $calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1175 | + |
|
| 1176 | + $calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this ); |
|
| 1177 | + $calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this ); |
|
| 1178 | + |
|
| 1179 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1180 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1181 | + |
|
| 1182 | + $shortcode_args = array(); |
|
| 1183 | + $output = ''; |
|
| 1184 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1185 | + $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1186 | + if ( $main_content && ! $no_wrap ) { |
|
| 1187 | + // wrap the shortcode in a dive with the same class as the widget |
|
| 1188 | + $output .= '<div class="' . $calss . '" ' . $attrs . '>'; |
|
| 1189 | + if ( ! empty( $args['title'] ) ) { |
|
| 1190 | + // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1191 | + $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1192 | + if ( empty( $instance ) ) { |
|
| 1193 | + global $wp_registered_sidebars; |
|
| 1194 | + if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1195 | + foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1196 | + if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1197 | + $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1198 | + $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1199 | + break; |
|
| 1200 | + } |
|
| 1201 | + } |
|
| 1202 | + } |
|
| 1203 | + } |
|
| 1204 | + $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1205 | + } |
|
| 1206 | + $output .= $main_content; |
|
| 1207 | + $output .= '</div>'; |
|
| 1208 | + } elseif ( $main_content && $no_wrap ) { |
|
| 1209 | + $output .= $main_content; |
|
| 1210 | + } |
|
| 1211 | + |
|
| 1212 | + // if preview show a placeholder if empty |
|
| 1213 | + if ( $this->is_preview() && $output == '' ) { |
|
| 1214 | + $output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" ); |
|
| 1215 | + } |
|
| 1216 | + |
|
| 1217 | + return $output; |
|
| 1218 | + } |
|
| 1219 | + |
|
| 1220 | + /** |
|
| 1221 | + * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1222 | + * |
|
| 1223 | + * @param string $name |
|
| 1224 | + * |
|
| 1225 | + * @return string |
|
| 1226 | + */ |
|
| 1227 | + public function preview_placeholder_text( $name = '' ) { |
|
| 1228 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1229 | + } |
|
| 1230 | + |
|
| 1231 | + /** |
|
| 1232 | + * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1233 | + * |
|
| 1234 | + * @param $options |
|
| 1235 | + * |
|
| 1236 | + * @return mixed |
|
| 1237 | + */ |
|
| 1238 | + public function string_to_bool( $options ) { |
|
| 1239 | + // convert bool strings to booleans |
|
| 1240 | + foreach ( $options as $key => $val ) { |
|
| 1241 | + if ( $val == 'false' ) { |
|
| 1242 | + $options[ $key ] = false; |
|
| 1243 | + } elseif ( $val == 'true' ) { |
|
| 1244 | + $options[ $key ] = true; |
|
| 1245 | + } |
|
| 1246 | + } |
|
| 1247 | + |
|
| 1248 | + return $options; |
|
| 1249 | + } |
|
| 1250 | + |
|
| 1251 | + /** |
|
| 1252 | + * Get the argument values that are also filterable. |
|
| 1253 | + * |
|
| 1254 | + * @param $instance |
|
| 1255 | + * |
|
| 1256 | + * @since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1257 | + * |
|
| 1258 | + * @return array |
|
| 1259 | + */ |
|
| 1260 | + public function argument_values( $instance ) { |
|
| 1261 | + $argument_values = array(); |
|
| 1262 | + |
|
| 1263 | + // set widget instance |
|
| 1264 | + $this->instance = $instance; |
|
| 1265 | + |
|
| 1266 | + if ( empty( $this->arguments ) ) { |
|
| 1267 | + $this->arguments = $this->get_arguments(); |
|
| 1268 | + } |
|
| 1269 | + |
|
| 1270 | + if ( ! empty( $this->arguments ) ) { |
|
| 1271 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1272 | + // set the input name from the key |
|
| 1273 | + $args['name'] = $key; |
|
| 1274 | + // |
|
| 1275 | + $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1276 | + if($args['type']=='checkbox' && $argument_values[ $key ] == ''){ |
|
| 1277 | + // don't set default for an empty checkbox |
|
| 1278 | + } |
|
| 1279 | + elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1280 | + $argument_values[ $key ] = $args['default']; |
|
| 1281 | + } |
|
| 1282 | + } |
|
| 1283 | + } |
|
| 1284 | + |
|
| 1285 | + return $argument_values; |
|
| 1286 | + } |
|
| 1287 | + |
|
| 1288 | + /** |
|
| 1289 | + * Set arguments in super duper. |
|
| 1290 | + * |
|
| 1291 | + * @since 1.0.0 |
|
| 1292 | + * |
|
| 1293 | + * @return array Set arguments. |
|
| 1294 | + */ |
|
| 1295 | + public function set_arguments() { |
|
| 1296 | + return $this->arguments; |
|
| 1297 | + } |
|
| 1298 | + |
|
| 1299 | + /** |
|
| 1300 | + * Get arguments in super duper. |
|
| 1301 | + * |
|
| 1302 | + * @since 1.0.0 |
|
| 1303 | + * |
|
| 1304 | + * @return array Get arguments. |
|
| 1305 | + */ |
|
| 1306 | + public function get_arguments() { |
|
| 1307 | + if ( empty( $this->arguments ) ) { |
|
| 1308 | + $this->arguments = $this->set_arguments(); |
|
| 1309 | + } |
|
| 1310 | + |
|
| 1311 | + $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1312 | + $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1313 | + |
|
| 1314 | + return $this->arguments; |
|
| 1315 | + } |
|
| 1316 | + |
|
| 1317 | + /** |
|
| 1318 | + * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1319 | + * |
|
| 1320 | + * @param array $args |
|
| 1321 | + * @param array $widget_args |
|
| 1322 | + * @param string $content |
|
| 1323 | + */ |
|
| 1324 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1325 | + |
|
| 1326 | + } |
|
| 1327 | + |
|
| 1328 | + /** |
|
| 1329 | + * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1330 | + */ |
|
| 1331 | + public function register_block() { |
|
| 1332 | + wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1333 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1334 | + |
|
| 1335 | + wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1336 | + |
|
| 1337 | + } |
|
| 1338 | + } |
|
| 1339 | + |
|
| 1340 | + /** |
|
| 1341 | + * Check if we need to show advanced options. |
|
| 1342 | + * |
|
| 1343 | + * @return bool |
|
| 1344 | + */ |
|
| 1345 | + public function block_show_advanced() { |
|
| 1346 | + |
|
| 1347 | + $show = false; |
|
| 1348 | + $arguments = $this->arguments; |
|
| 1349 | + |
|
| 1350 | + if ( empty( $arguments ) ) { |
|
| 1351 | + $arguments = $this->get_arguments(); |
|
| 1352 | + } |
|
| 1353 | + |
|
| 1354 | + if ( ! empty( $arguments ) ) { |
|
| 1355 | + foreach ( $arguments as $argument ) { |
|
| 1356 | + if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1357 | + $show = true; |
|
| 1358 | + } |
|
| 1359 | + } |
|
| 1360 | + } |
|
| 1361 | + |
|
| 1362 | + return $show; |
|
| 1363 | + } |
|
| 1364 | + |
|
| 1365 | + |
|
| 1366 | + /** |
|
| 1367 | + * Output the JS for building the dynamic Guntenberg block. |
|
| 1368 | + * |
|
| 1369 | + * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1370 | + * @since 1.0.9 Save numbers as numbers and not strings. |
|
| 1371 | + * @return mixed |
|
| 1372 | + */ |
|
| 1373 | + public function block() { |
|
| 1374 | + ob_start(); |
|
| 1375 | + ?> |
|
| 1376 | 1376 | <script> |
| 1377 | 1377 | /** |
| 1378 | 1378 | * BLOCK: Basic |
@@ -1411,76 +1411,76 @@ discard block |
||
| 1411 | 1411 | icon: '<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
| 1412 | 1412 | category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
| 1413 | 1413 | <?php if ( isset( $this->options['block-keywords'] ) ) { |
| 1414 | - echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 1415 | - }?> |
|
| 1414 | + echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 1415 | + }?> |
|
| 1416 | 1416 | |
| 1417 | 1417 | <?php |
| 1418 | 1418 | |
| 1419 | - $show_advanced = $this->block_show_advanced(); |
|
| 1420 | - |
|
| 1421 | - $show_alignment = false; |
|
| 1422 | - |
|
| 1423 | - if ( ! empty( $this->arguments ) ) { |
|
| 1424 | - echo "attributes : {"; |
|
| 1425 | - |
|
| 1426 | - if ( $show_advanced ) { |
|
| 1427 | - echo "show_advanced: {"; |
|
| 1428 | - echo " type: 'boolean',"; |
|
| 1429 | - echo " default: false,"; |
|
| 1430 | - echo "},"; |
|
| 1431 | - } |
|
| 1432 | - |
|
| 1433 | - // block wrap element |
|
| 1434 | - if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 1435 | - echo "block_wrap: {"; |
|
| 1436 | - echo " type: 'string',"; |
|
| 1437 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 1438 | - echo "},"; |
|
| 1439 | - } |
|
| 1440 | - |
|
| 1441 | - |
|
| 1442 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1443 | - |
|
| 1444 | - // set if we should show alignment |
|
| 1445 | - if ( $key == 'alignment' ) { |
|
| 1446 | - $show_alignment = true; |
|
| 1447 | - } |
|
| 1448 | - |
|
| 1449 | - $extra = ''; |
|
| 1450 | - |
|
| 1451 | - if ( $args['type'] == 'checkbox' ) { |
|
| 1452 | - $type = 'boolean'; |
|
| 1453 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 1454 | - } elseif ( $args['type'] == 'number' ) { |
|
| 1455 | - $type = 'number'; |
|
| 1456 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1457 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 1458 | - $type = 'array'; |
|
| 1459 | - if ( is_array( $args['default'] ) ) { |
|
| 1460 | - $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 1461 | - } else { |
|
| 1462 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1463 | - } |
|
| 1464 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 1465 | - $type = 'array'; |
|
| 1466 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1467 | - } else { |
|
| 1468 | - $type = 'string'; |
|
| 1469 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1470 | - } |
|
| 1471 | - echo $key . " : {"; |
|
| 1472 | - echo "type : '$type',"; |
|
| 1473 | - echo "default : $default,"; |
|
| 1474 | - echo "},"; |
|
| 1475 | - } |
|
| 1476 | - |
|
| 1477 | - echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 1478 | - |
|
| 1479 | - echo "},"; |
|
| 1480 | - |
|
| 1481 | - } |
|
| 1482 | - |
|
| 1483 | - ?> |
|
| 1419 | + $show_advanced = $this->block_show_advanced(); |
|
| 1420 | + |
|
| 1421 | + $show_alignment = false; |
|
| 1422 | + |
|
| 1423 | + if ( ! empty( $this->arguments ) ) { |
|
| 1424 | + echo "attributes : {"; |
|
| 1425 | + |
|
| 1426 | + if ( $show_advanced ) { |
|
| 1427 | + echo "show_advanced: {"; |
|
| 1428 | + echo " type: 'boolean',"; |
|
| 1429 | + echo " default: false,"; |
|
| 1430 | + echo "},"; |
|
| 1431 | + } |
|
| 1432 | + |
|
| 1433 | + // block wrap element |
|
| 1434 | + if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 1435 | + echo "block_wrap: {"; |
|
| 1436 | + echo " type: 'string',"; |
|
| 1437 | + echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 1438 | + echo "},"; |
|
| 1439 | + } |
|
| 1440 | + |
|
| 1441 | + |
|
| 1442 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1443 | + |
|
| 1444 | + // set if we should show alignment |
|
| 1445 | + if ( $key == 'alignment' ) { |
|
| 1446 | + $show_alignment = true; |
|
| 1447 | + } |
|
| 1448 | + |
|
| 1449 | + $extra = ''; |
|
| 1450 | + |
|
| 1451 | + if ( $args['type'] == 'checkbox' ) { |
|
| 1452 | + $type = 'boolean'; |
|
| 1453 | + $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 1454 | + } elseif ( $args['type'] == 'number' ) { |
|
| 1455 | + $type = 'number'; |
|
| 1456 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1457 | + } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 1458 | + $type = 'array'; |
|
| 1459 | + if ( is_array( $args['default'] ) ) { |
|
| 1460 | + $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 1461 | + } else { |
|
| 1462 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1463 | + } |
|
| 1464 | + } elseif ( $args['type'] == 'multiselect' ) { |
|
| 1465 | + $type = 'array'; |
|
| 1466 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1467 | + } else { |
|
| 1468 | + $type = 'string'; |
|
| 1469 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1470 | + } |
|
| 1471 | + echo $key . " : {"; |
|
| 1472 | + echo "type : '$type',"; |
|
| 1473 | + echo "default : $default,"; |
|
| 1474 | + echo "},"; |
|
| 1475 | + } |
|
| 1476 | + |
|
| 1477 | + echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 1478 | + |
|
| 1479 | + echo "},"; |
|
| 1480 | + |
|
| 1481 | + } |
|
| 1482 | + |
|
| 1483 | + ?> |
|
| 1484 | 1484 | |
| 1485 | 1485 | // The "edit" property must be a valid function. |
| 1486 | 1486 | edit: function (props) { |
@@ -1499,8 +1499,8 @@ discard block |
||
| 1499 | 1499 | 'shortcode': '<?php echo $this->options['base_id'];?>', |
| 1500 | 1500 | 'attributes': props.attributes, |
| 1501 | 1501 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 1502 | - echo $post->ID; |
|
| 1503 | - }?>, |
|
| 1502 | + echo $post->ID; |
|
| 1503 | + }?>, |
|
| 1504 | 1504 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 1505 | 1505 | }; |
| 1506 | 1506 | |
@@ -1547,10 +1547,10 @@ discard block |
||
| 1547 | 1547 | |
| 1548 | 1548 | <?php |
| 1549 | 1549 | |
| 1550 | - if(! empty( $this->arguments )){ |
|
| 1550 | + if(! empty( $this->arguments )){ |
|
| 1551 | 1551 | |
| 1552 | - if ( $show_advanced ) { |
|
| 1553 | - ?> |
|
| 1552 | + if ( $show_advanced ) { |
|
| 1553 | + ?> |
|
| 1554 | 1554 | el( |
| 1555 | 1555 | wp.components.ToggleControl, |
| 1556 | 1556 | { |
@@ -1563,73 +1563,73 @@ discard block |
||
| 1563 | 1563 | ), |
| 1564 | 1564 | <?php |
| 1565 | 1565 | |
| 1566 | - } |
|
| 1567 | - |
|
| 1568 | - foreach($this->arguments as $key => $args){ |
|
| 1569 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 1570 | - $options = ''; |
|
| 1571 | - $extra = ''; |
|
| 1572 | - $require = ''; |
|
| 1573 | - $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 1574 | - $value = "props.attributes.$key"; |
|
| 1575 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' ); |
|
| 1576 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 1577 | - $type = 'TextControl'; |
|
| 1578 | - // Save numbers as numbers and not strings |
|
| 1579 | - if ( $args['type'] == 'number' ) { |
|
| 1580 | - $onchange = "props.setAttributes({ $key: Number($key) } )"; |
|
| 1581 | - } |
|
| 1582 | - } |
|
| 1566 | + } |
|
| 1567 | + |
|
| 1568 | + foreach($this->arguments as $key => $args){ |
|
| 1569 | + $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 1570 | + $options = ''; |
|
| 1571 | + $extra = ''; |
|
| 1572 | + $require = ''; |
|
| 1573 | + $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 1574 | + $value = "props.attributes.$key"; |
|
| 1575 | + $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' ); |
|
| 1576 | + if ( in_array( $args['type'], $text_type ) ) { |
|
| 1577 | + $type = 'TextControl'; |
|
| 1578 | + // Save numbers as numbers and not strings |
|
| 1579 | + if ( $args['type'] == 'number' ) { |
|
| 1580 | + $onchange = "props.setAttributes({ $key: Number($key) } )"; |
|
| 1581 | + } |
|
| 1582 | + } |
|
| 1583 | 1583 | // elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we may have to add our own https://github.com/WordPress/gutenberg/issues/14378 |
| 1584 | 1584 | // $type = 'ColorPicker'; |
| 1585 | 1585 | // } |
| 1586 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 1587 | - $type = 'CheckboxControl'; |
|
| 1588 | - $extra .= "checked: props.attributes.$key,"; |
|
| 1589 | - $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 1590 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 1591 | - $type = 'SelectControl'; |
|
| 1592 | - if ( ! empty( $args['options'] ) ) { |
|
| 1593 | - $options .= "options : ["; |
|
| 1594 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 1595 | - $options .= "{ value : '" . esc_attr( $option_val ) . "', label : '" . esc_attr( $option_label ) . "' },"; |
|
| 1596 | - } |
|
| 1597 | - $options .= "],"; |
|
| 1598 | - } |
|
| 1599 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 1600 | - $extra .= ' multiple: true, '; |
|
| 1601 | - //$onchange = "props.setAttributes({ $key: ['edit'] } )"; |
|
| 1602 | - //$value = "['edit', 'delete']"; |
|
| 1603 | - } |
|
| 1604 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 1605 | - $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 1606 | - } else { |
|
| 1607 | - continue;// if we have not implemented the control then don't break the JS. |
|
| 1608 | - } |
|
| 1609 | - |
|
| 1610 | - // add show only if advanced |
|
| 1611 | - if ( ! empty( $args['advanced'] ) ) { |
|
| 1612 | - echo "props.attributes.show_advanced && "; |
|
| 1613 | - } |
|
| 1614 | - // add setting require if defined |
|
| 1615 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 1616 | - echo $this->block_props_replace( $args['element_require'], true ) . " && "; |
|
| 1617 | - } |
|
| 1618 | - ?> |
|
| 1586 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 1587 | + $type = 'CheckboxControl'; |
|
| 1588 | + $extra .= "checked: props.attributes.$key,"; |
|
| 1589 | + $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 1590 | + } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 1591 | + $type = 'SelectControl'; |
|
| 1592 | + if ( ! empty( $args['options'] ) ) { |
|
| 1593 | + $options .= "options : ["; |
|
| 1594 | + foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 1595 | + $options .= "{ value : '" . esc_attr( $option_val ) . "', label : '" . esc_attr( $option_label ) . "' },"; |
|
| 1596 | + } |
|
| 1597 | + $options .= "],"; |
|
| 1598 | + } |
|
| 1599 | + if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 1600 | + $extra .= ' multiple: true, '; |
|
| 1601 | + //$onchange = "props.setAttributes({ $key: ['edit'] } )"; |
|
| 1602 | + //$value = "['edit', 'delete']"; |
|
| 1603 | + } |
|
| 1604 | + } elseif ( $args['type'] == 'alignment' ) { |
|
| 1605 | + $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 1606 | + } else { |
|
| 1607 | + continue;// if we have not implemented the control then don't break the JS. |
|
| 1608 | + } |
|
| 1609 | + |
|
| 1610 | + // add show only if advanced |
|
| 1611 | + if ( ! empty( $args['advanced'] ) ) { |
|
| 1612 | + echo "props.attributes.show_advanced && "; |
|
| 1613 | + } |
|
| 1614 | + // add setting require if defined |
|
| 1615 | + if ( ! empty( $args['element_require'] ) ) { |
|
| 1616 | + echo $this->block_props_replace( $args['element_require'], true ) . " && "; |
|
| 1617 | + } |
|
| 1618 | + ?> |
|
| 1619 | 1619 | el( |
| 1620 | 1620 | wp.components.<?php echo esc_attr( $type );?>, |
| 1621 | 1621 | { |
| 1622 | 1622 | label: '<?php echo esc_attr( $args['title'] );?>', |
| 1623 | 1623 | help: '<?php if ( isset( $args['desc'] ) ) { |
| 1624 | - echo esc_attr( $args['desc'] ); |
|
| 1625 | - }?>', |
|
| 1624 | + echo esc_attr( $args['desc'] ); |
|
| 1625 | + }?>', |
|
| 1626 | 1626 | value: <?php echo $value;?>, |
| 1627 | 1627 | <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
| 1628 | - echo "type: '" . esc_attr( $args['type'] ) . "',"; |
|
| 1629 | - }?> |
|
| 1628 | + echo "type: '" . esc_attr( $args['type'] ) . "',"; |
|
| 1629 | + }?> |
|
| 1630 | 1630 | <?php if ( ! empty( $args['placeholder'] ) ) { |
| 1631 | - echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',"; |
|
| 1632 | - }?> |
|
| 1631 | + echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',"; |
|
| 1632 | + }?> |
|
| 1633 | 1633 | <?php echo $options;?> |
| 1634 | 1634 | <?php echo $extra;?> |
| 1635 | 1635 | <?php echo $custom_attributes;?> |
@@ -1639,27 +1639,27 @@ discard block |
||
| 1639 | 1639 | } |
| 1640 | 1640 | ), |
| 1641 | 1641 | <?php |
| 1642 | - } |
|
| 1643 | - } |
|
| 1644 | - ?> |
|
| 1642 | + } |
|
| 1643 | + } |
|
| 1644 | + ?> |
|
| 1645 | 1645 | |
| 1646 | 1646 | ), |
| 1647 | 1647 | |
| 1648 | 1648 | <?php |
| 1649 | - // If the user sets block-output array then build it |
|
| 1650 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 1651 | - $this->block_element( $this->options['block-output'] ); |
|
| 1652 | - }else{ |
|
| 1653 | - // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 1654 | - ?> |
|
| 1649 | + // If the user sets block-output array then build it |
|
| 1650 | + if ( ! empty( $this->options['block-output'] ) ) { |
|
| 1651 | + $this->block_element( $this->options['block-output'] ); |
|
| 1652 | + }else{ |
|
| 1653 | + // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 1654 | + ?> |
|
| 1655 | 1655 | el('div', { |
| 1656 | 1656 | dangerouslySetInnerHTML: {__html: onChangeContent()}, |
| 1657 | 1657 | className: props.className, |
| 1658 | 1658 | style: {'min-height': '30px'} |
| 1659 | 1659 | }) |
| 1660 | 1660 | <?php |
| 1661 | - } |
|
| 1662 | - ?> |
|
| 1661 | + } |
|
| 1662 | + ?> |
|
| 1663 | 1663 | ]; // end return |
| 1664 | 1664 | }, |
| 1665 | 1665 | |
@@ -1676,17 +1676,17 @@ discard block |
||
| 1676 | 1676 | var content = "[<?php echo $this->options['base_id'];?>"; |
| 1677 | 1677 | <?php |
| 1678 | 1678 | |
| 1679 | - if(! empty( $this->arguments )){ |
|
| 1680 | - foreach($this->arguments as $key => $args){ |
|
| 1681 | - ?> |
|
| 1679 | + if(! empty( $this->arguments )){ |
|
| 1680 | + foreach($this->arguments as $key => $args){ |
|
| 1681 | + ?> |
|
| 1682 | 1682 | if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
| 1683 | 1683 | content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' "; |
| 1684 | 1684 | } |
| 1685 | 1685 | <?php |
| 1686 | - } |
|
| 1687 | - } |
|
| 1686 | + } |
|
| 1687 | + } |
|
| 1688 | 1688 | |
| 1689 | - ?> |
|
| 1689 | + ?> |
|
| 1690 | 1690 | content += "]"; |
| 1691 | 1691 | |
| 1692 | 1692 | |
@@ -1715,456 +1715,456 @@ discard block |
||
| 1715 | 1715 | })(); |
| 1716 | 1716 | </script> |
| 1717 | 1717 | <?php |
| 1718 | - $output = ob_get_clean(); |
|
| 1718 | + $output = ob_get_clean(); |
|
| 1719 | 1719 | |
| 1720 | - /* |
|
| 1720 | + /* |
|
| 1721 | 1721 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1722 | 1722 | */ |
| 1723 | 1723 | |
| 1724 | - return str_replace( array( |
|
| 1725 | - '<script>', |
|
| 1726 | - '</script>' |
|
| 1727 | - ), '', $output ); |
|
| 1728 | - } |
|
| 1729 | - |
|
| 1730 | - /** |
|
| 1731 | - * Convert an array of attributes to block string. |
|
| 1732 | - * |
|
| 1733 | - * @todo there is prob a faster way to do this, also we could add some validation here. |
|
| 1734 | - * |
|
| 1735 | - * @param $custom_attributes |
|
| 1736 | - * |
|
| 1737 | - * @return string |
|
| 1738 | - */ |
|
| 1739 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 1740 | - $attributes = ''; |
|
| 1741 | - if ( ! empty( $custom_attributes ) ) { |
|
| 1742 | - |
|
| 1743 | - if ( $html ) { |
|
| 1744 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 1745 | - $attributes .= " $key='$val' "; |
|
| 1746 | - } |
|
| 1747 | - } else { |
|
| 1748 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 1749 | - $attributes .= "'$key': '$val',"; |
|
| 1750 | - } |
|
| 1751 | - } |
|
| 1752 | - } |
|
| 1753 | - |
|
| 1754 | - return $attributes; |
|
| 1755 | - } |
|
| 1756 | - |
|
| 1757 | - /** |
|
| 1758 | - * A self looping function to create the output for JS block elements. |
|
| 1759 | - * |
|
| 1760 | - * This is what is output in the WP Editor visual view. |
|
| 1761 | - * |
|
| 1762 | - * @param $args |
|
| 1763 | - */ |
|
| 1764 | - public function block_element( $args ) { |
|
| 1765 | - |
|
| 1766 | - |
|
| 1767 | - if ( ! empty( $args ) ) { |
|
| 1768 | - foreach ( $args as $element => $new_args ) { |
|
| 1769 | - |
|
| 1770 | - if ( is_array( $new_args ) ) { // its an element |
|
| 1771 | - |
|
| 1772 | - |
|
| 1773 | - if ( isset( $new_args['element'] ) ) { |
|
| 1774 | - |
|
| 1775 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 1776 | - echo str_replace( array( |
|
| 1777 | - "'+", |
|
| 1778 | - "+'" |
|
| 1779 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 1780 | - unset( $new_args['element_require'] ); |
|
| 1781 | - } |
|
| 1782 | - |
|
| 1783 | - echo "\n el( '" . $new_args['element'] . "', {"; |
|
| 1784 | - |
|
| 1785 | - // get the attributes |
|
| 1786 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 1787 | - |
|
| 1788 | - |
|
| 1789 | - if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 1790 | - // do nothing |
|
| 1791 | - } else { |
|
| 1792 | - echo $this->block_element( array( $new_key => $new_value ) ); |
|
| 1793 | - } |
|
| 1794 | - } |
|
| 1795 | - |
|
| 1796 | - echo "},";// end attributes |
|
| 1797 | - |
|
| 1798 | - // get the content |
|
| 1799 | - $first_item = 0; |
|
| 1800 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 1801 | - if ( $new_key === 'content' || is_array( $new_value ) ) { |
|
| 1802 | - |
|
| 1803 | - if ( $new_key === 'content' ) { |
|
| 1804 | - echo "'" . $this->block_props_replace( $new_value ) . "'"; |
|
| 1805 | - } |
|
| 1806 | - |
|
| 1807 | - if ( is_array( $new_value ) ) { |
|
| 1808 | - |
|
| 1809 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 1810 | - echo str_replace( array( |
|
| 1811 | - "'+", |
|
| 1812 | - "+'" |
|
| 1813 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 1814 | - unset( $new_value['element_require'] ); |
|
| 1815 | - } |
|
| 1816 | - |
|
| 1817 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 1818 | - $x = 1; |
|
| 1819 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 1820 | - $this->block_element( array( '' => $new_value ) ); |
|
| 1821 | - $x ++; |
|
| 1822 | - } |
|
| 1823 | - } else { |
|
| 1824 | - $this->block_element( array( '' => $new_value ) ); |
|
| 1825 | - } |
|
| 1826 | - } |
|
| 1827 | - $first_item ++; |
|
| 1828 | - } |
|
| 1829 | - } |
|
| 1830 | - |
|
| 1831 | - echo ")";// end content |
|
| 1832 | - |
|
| 1833 | - echo ", \n"; |
|
| 1834 | - |
|
| 1835 | - } |
|
| 1836 | - } else { |
|
| 1837 | - |
|
| 1838 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 1839 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 1840 | - } elseif ( $element == 'style' ) { |
|
| 1841 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 1842 | - } else { |
|
| 1843 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 1844 | - } |
|
| 1845 | - |
|
| 1846 | - } |
|
| 1847 | - } |
|
| 1848 | - } |
|
| 1849 | - } |
|
| 1850 | - |
|
| 1851 | - /** |
|
| 1852 | - * Replace block attributes placeholders with the proper naming. |
|
| 1853 | - * |
|
| 1854 | - * @param $string |
|
| 1855 | - * |
|
| 1856 | - * @return mixed |
|
| 1857 | - */ |
|
| 1858 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 1859 | - |
|
| 1860 | - if ( $no_wrap ) { |
|
| 1861 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 1862 | - } else { |
|
| 1863 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 1864 | - } |
|
| 1865 | - |
|
| 1866 | - return $string; |
|
| 1867 | - } |
|
| 1868 | - |
|
| 1869 | - /** |
|
| 1870 | - * Outputs the content of the widget |
|
| 1871 | - * |
|
| 1872 | - * @param array $args |
|
| 1873 | - * @param array $instance |
|
| 1874 | - */ |
|
| 1875 | - public function widget( $args, $instance ) { |
|
| 1876 | - |
|
| 1877 | - // get the filtered values |
|
| 1878 | - $argument_values = $this->argument_values( $instance ); |
|
| 1879 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 1880 | - $output = $this->output( $argument_values, $args ); |
|
| 1881 | - |
|
| 1882 | - if ( $output ) { |
|
| 1883 | - // Before widget |
|
| 1884 | - $before_widget = $args['before_widget']; |
|
| 1885 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 1886 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 1887 | - |
|
| 1888 | - // After widget |
|
| 1889 | - $after_widget = $args['after_widget']; |
|
| 1890 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 1891 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 1892 | - |
|
| 1893 | - echo $before_widget; |
|
| 1894 | - // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 1895 | - if ( $this->is_elementor_widget_output() ) { |
|
| 1896 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : ''; |
|
| 1897 | - } |
|
| 1898 | - echo $this->output_title( $args, $instance ); |
|
| 1899 | - echo $output; |
|
| 1900 | - if ( $this->is_elementor_widget_output() ) { |
|
| 1901 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : ''; |
|
| 1902 | - } |
|
| 1903 | - echo $after_widget; |
|
| 1904 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 1905 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1906 | - echo $output; |
|
| 1907 | - } |
|
| 1908 | - } |
|
| 1909 | - |
|
| 1910 | - /** |
|
| 1911 | - * Tests if the current output is inside a elementor container. |
|
| 1912 | - * |
|
| 1913 | - * @since 1.0.4 |
|
| 1914 | - * @return bool |
|
| 1915 | - */ |
|
| 1916 | - public function is_elementor_widget_output() { |
|
| 1917 | - $result = false; |
|
| 1918 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 1919 | - $result = true; |
|
| 1920 | - } |
|
| 1921 | - |
|
| 1922 | - return $result; |
|
| 1923 | - } |
|
| 1924 | - |
|
| 1925 | - /** |
|
| 1926 | - * Tests if the current output is inside a elementor preview. |
|
| 1927 | - * |
|
| 1928 | - * @since 1.0.4 |
|
| 1929 | - * @return bool |
|
| 1930 | - */ |
|
| 1931 | - public function is_elementor_preview() { |
|
| 1932 | - $result = false; |
|
| 1933 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 1934 | - $result = true; |
|
| 1935 | - } |
|
| 1936 | - |
|
| 1937 | - return $result; |
|
| 1938 | - } |
|
| 1939 | - |
|
| 1940 | - /** |
|
| 1941 | - * Tests if the current output is inside a Divi preview. |
|
| 1942 | - * |
|
| 1943 | - * @since 1.0.6 |
|
| 1944 | - * @return bool |
|
| 1945 | - */ |
|
| 1946 | - public function is_divi_preview() { |
|
| 1947 | - $result = false; |
|
| 1948 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 1949 | - $result = true; |
|
| 1950 | - } |
|
| 1951 | - |
|
| 1952 | - return $result; |
|
| 1953 | - } |
|
| 1954 | - |
|
| 1955 | - /** |
|
| 1956 | - * Tests if the current output is inside a Beaver builder preview. |
|
| 1957 | - * |
|
| 1958 | - * @since 1.0.6 |
|
| 1959 | - * @return bool |
|
| 1960 | - */ |
|
| 1961 | - public function is_beaver_preview() { |
|
| 1962 | - $result = false; |
|
| 1963 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 1964 | - $result = true; |
|
| 1965 | - } |
|
| 1966 | - |
|
| 1967 | - return $result; |
|
| 1968 | - } |
|
| 1969 | - |
|
| 1970 | - /** |
|
| 1971 | - * Tests if the current output is inside a siteorigin builder preview. |
|
| 1972 | - * |
|
| 1973 | - * @since 1.0.6 |
|
| 1974 | - * @return bool |
|
| 1975 | - */ |
|
| 1976 | - public function is_siteorigin_preview() { |
|
| 1977 | - $result = false; |
|
| 1978 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 1979 | - $result = true; |
|
| 1980 | - } |
|
| 1981 | - |
|
| 1982 | - return $result; |
|
| 1983 | - } |
|
| 1984 | - |
|
| 1985 | - /** |
|
| 1986 | - * Tests if the current output is inside a cornerstone builder preview. |
|
| 1987 | - * |
|
| 1988 | - * @since 1.0.8 |
|
| 1989 | - * @return bool |
|
| 1990 | - */ |
|
| 1991 | - public function is_cornerstone_preview() { |
|
| 1992 | - $result = false; |
|
| 1993 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 1994 | - $result = true; |
|
| 1995 | - } |
|
| 1996 | - |
|
| 1997 | - return $result; |
|
| 1998 | - } |
|
| 1999 | - |
|
| 2000 | - /** |
|
| 2001 | - * General function to check if we are in a preview situation. |
|
| 2002 | - * |
|
| 2003 | - * @since 1.0.6 |
|
| 2004 | - * @return bool |
|
| 2005 | - */ |
|
| 2006 | - public function is_preview() { |
|
| 2007 | - $preview = false; |
|
| 2008 | - if ( $this->is_divi_preview() ) { |
|
| 2009 | - $preview = true; |
|
| 2010 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 2011 | - $preview = true; |
|
| 2012 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 2013 | - $preview = true; |
|
| 2014 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 2015 | - $preview = true; |
|
| 2016 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 2017 | - $preview = true; |
|
| 2018 | - } |
|
| 2019 | - |
|
| 2020 | - return $preview; |
|
| 2021 | - } |
|
| 2022 | - |
|
| 2023 | - /** |
|
| 2024 | - * Output the super title. |
|
| 2025 | - * |
|
| 2026 | - * @param $args |
|
| 2027 | - * @param array $instance |
|
| 2028 | - * |
|
| 2029 | - * @return string |
|
| 2030 | - */ |
|
| 2031 | - public function output_title( $args, $instance = array() ) { |
|
| 2032 | - $output = ''; |
|
| 2033 | - if ( ! empty( $instance['title'] ) ) { |
|
| 2034 | - /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 2035 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 2036 | - $output = $args['before_title'] . $title . $args['after_title']; |
|
| 2037 | - } |
|
| 2038 | - |
|
| 2039 | - return $output; |
|
| 2040 | - } |
|
| 2041 | - |
|
| 2042 | - /** |
|
| 2043 | - * Outputs the options form inputs for the widget. |
|
| 2044 | - * |
|
| 2045 | - * @param array $instance The widget options. |
|
| 2046 | - */ |
|
| 2047 | - public function form( $instance ) { |
|
| 2048 | - |
|
| 2049 | - // set widget instance |
|
| 2050 | - $this->instance = $instance; |
|
| 2051 | - |
|
| 2052 | - // set it as a SD widget |
|
| 2053 | - echo $this->widget_advanced_toggle(); |
|
| 2054 | - |
|
| 2055 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 2056 | - $arguments = $this->get_arguments(); |
|
| 2057 | - |
|
| 2058 | - if ( is_array( $arguments ) ) { |
|
| 2059 | - foreach ( $arguments as $key => $args ) { |
|
| 2060 | - $this->widget_inputs( $args, $instance ); |
|
| 2061 | - } |
|
| 2062 | - } |
|
| 2063 | - } |
|
| 2064 | - |
|
| 2065 | - /** |
|
| 2066 | - * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 2067 | - * |
|
| 2068 | - * @return string |
|
| 2069 | - */ |
|
| 2070 | - public function widget_advanced_toggle() { |
|
| 2071 | - |
|
| 2072 | - $output = ''; |
|
| 2073 | - if ( $this->block_show_advanced() ) { |
|
| 2074 | - $val = 1; |
|
| 2075 | - } else { |
|
| 2076 | - $val = 0; |
|
| 2077 | - } |
|
| 2078 | - |
|
| 2079 | - $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 2080 | - |
|
| 2081 | - return $output; |
|
| 2082 | - } |
|
| 2083 | - |
|
| 2084 | - /** |
|
| 2085 | - * Convert require element. |
|
| 2086 | - * |
|
| 2087 | - * @since 1.0.0 |
|
| 2088 | - * |
|
| 2089 | - * @param string $input Input element. |
|
| 2090 | - * |
|
| 2091 | - * @return string $output |
|
| 2092 | - */ |
|
| 2093 | - public function convert_element_require( $input ) { |
|
| 2094 | - |
|
| 2095 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 2096 | - |
|
| 2097 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 2098 | - "jQuery(form).find('[data-argument=\"", |
|
| 2099 | - "\"]').find('input,select').val()" |
|
| 2100 | - ), $input ) ); |
|
| 2101 | - |
|
| 2102 | - return $output; |
|
| 2103 | - } |
|
| 2104 | - |
|
| 2105 | - /** |
|
| 2106 | - * Builds the inputs for the widget options. |
|
| 2107 | - * |
|
| 2108 | - * @param $args |
|
| 2109 | - * @param $instance |
|
| 2110 | - */ |
|
| 2111 | - public function widget_inputs( $args, $instance ) { |
|
| 2112 | - |
|
| 2113 | - $class = ""; |
|
| 2114 | - $element_require = ""; |
|
| 2115 | - $custom_attributes = ""; |
|
| 2116 | - |
|
| 2117 | - // get value |
|
| 2118 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 2119 | - $value = $instance[ $args['name'] ]; |
|
| 2120 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 2121 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 2122 | - } else { |
|
| 2123 | - $value = ''; |
|
| 2124 | - } |
|
| 2125 | - |
|
| 2126 | - // get placeholder |
|
| 2127 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 2128 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 2129 | - } else { |
|
| 2130 | - $placeholder = ''; |
|
| 2131 | - } |
|
| 2132 | - |
|
| 2133 | - // get if advanced |
|
| 2134 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 2135 | - $class .= " sd-advanced-setting "; |
|
| 2136 | - } |
|
| 2137 | - |
|
| 2138 | - // element_require |
|
| 2139 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 2140 | - $element_require = $args['element_require']; |
|
| 2141 | - } |
|
| 2142 | - |
|
| 2143 | - // custom_attributes |
|
| 2144 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 2145 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 2146 | - } |
|
| 2147 | - |
|
| 2148 | - // before wrapper |
|
| 2149 | - ?> |
|
| 1724 | + return str_replace( array( |
|
| 1725 | + '<script>', |
|
| 1726 | + '</script>' |
|
| 1727 | + ), '', $output ); |
|
| 1728 | + } |
|
| 1729 | + |
|
| 1730 | + /** |
|
| 1731 | + * Convert an array of attributes to block string. |
|
| 1732 | + * |
|
| 1733 | + * @todo there is prob a faster way to do this, also we could add some validation here. |
|
| 1734 | + * |
|
| 1735 | + * @param $custom_attributes |
|
| 1736 | + * |
|
| 1737 | + * @return string |
|
| 1738 | + */ |
|
| 1739 | + public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 1740 | + $attributes = ''; |
|
| 1741 | + if ( ! empty( $custom_attributes ) ) { |
|
| 1742 | + |
|
| 1743 | + if ( $html ) { |
|
| 1744 | + foreach ( $custom_attributes as $key => $val ) { |
|
| 1745 | + $attributes .= " $key='$val' "; |
|
| 1746 | + } |
|
| 1747 | + } else { |
|
| 1748 | + foreach ( $custom_attributes as $key => $val ) { |
|
| 1749 | + $attributes .= "'$key': '$val',"; |
|
| 1750 | + } |
|
| 1751 | + } |
|
| 1752 | + } |
|
| 1753 | + |
|
| 1754 | + return $attributes; |
|
| 1755 | + } |
|
| 1756 | + |
|
| 1757 | + /** |
|
| 1758 | + * A self looping function to create the output for JS block elements. |
|
| 1759 | + * |
|
| 1760 | + * This is what is output in the WP Editor visual view. |
|
| 1761 | + * |
|
| 1762 | + * @param $args |
|
| 1763 | + */ |
|
| 1764 | + public function block_element( $args ) { |
|
| 1765 | + |
|
| 1766 | + |
|
| 1767 | + if ( ! empty( $args ) ) { |
|
| 1768 | + foreach ( $args as $element => $new_args ) { |
|
| 1769 | + |
|
| 1770 | + if ( is_array( $new_args ) ) { // its an element |
|
| 1771 | + |
|
| 1772 | + |
|
| 1773 | + if ( isset( $new_args['element'] ) ) { |
|
| 1774 | + |
|
| 1775 | + if ( isset( $new_args['element_require'] ) ) { |
|
| 1776 | + echo str_replace( array( |
|
| 1777 | + "'+", |
|
| 1778 | + "+'" |
|
| 1779 | + ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 1780 | + unset( $new_args['element_require'] ); |
|
| 1781 | + } |
|
| 1782 | + |
|
| 1783 | + echo "\n el( '" . $new_args['element'] . "', {"; |
|
| 1784 | + |
|
| 1785 | + // get the attributes |
|
| 1786 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 1787 | + |
|
| 1788 | + |
|
| 1789 | + if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 1790 | + // do nothing |
|
| 1791 | + } else { |
|
| 1792 | + echo $this->block_element( array( $new_key => $new_value ) ); |
|
| 1793 | + } |
|
| 1794 | + } |
|
| 1795 | + |
|
| 1796 | + echo "},";// end attributes |
|
| 1797 | + |
|
| 1798 | + // get the content |
|
| 1799 | + $first_item = 0; |
|
| 1800 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 1801 | + if ( $new_key === 'content' || is_array( $new_value ) ) { |
|
| 1802 | + |
|
| 1803 | + if ( $new_key === 'content' ) { |
|
| 1804 | + echo "'" . $this->block_props_replace( $new_value ) . "'"; |
|
| 1805 | + } |
|
| 1806 | + |
|
| 1807 | + if ( is_array( $new_value ) ) { |
|
| 1808 | + |
|
| 1809 | + if ( isset( $new_value['element_require'] ) ) { |
|
| 1810 | + echo str_replace( array( |
|
| 1811 | + "'+", |
|
| 1812 | + "+'" |
|
| 1813 | + ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 1814 | + unset( $new_value['element_require'] ); |
|
| 1815 | + } |
|
| 1816 | + |
|
| 1817 | + if ( isset( $new_value['element_repeat'] ) ) { |
|
| 1818 | + $x = 1; |
|
| 1819 | + while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 1820 | + $this->block_element( array( '' => $new_value ) ); |
|
| 1821 | + $x ++; |
|
| 1822 | + } |
|
| 1823 | + } else { |
|
| 1824 | + $this->block_element( array( '' => $new_value ) ); |
|
| 1825 | + } |
|
| 1826 | + } |
|
| 1827 | + $first_item ++; |
|
| 1828 | + } |
|
| 1829 | + } |
|
| 1830 | + |
|
| 1831 | + echo ")";// end content |
|
| 1832 | + |
|
| 1833 | + echo ", \n"; |
|
| 1834 | + |
|
| 1835 | + } |
|
| 1836 | + } else { |
|
| 1837 | + |
|
| 1838 | + if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 1839 | + echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 1840 | + } elseif ( $element == 'style' ) { |
|
| 1841 | + echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 1842 | + } else { |
|
| 1843 | + echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 1844 | + } |
|
| 1845 | + |
|
| 1846 | + } |
|
| 1847 | + } |
|
| 1848 | + } |
|
| 1849 | + } |
|
| 1850 | + |
|
| 1851 | + /** |
|
| 1852 | + * Replace block attributes placeholders with the proper naming. |
|
| 1853 | + * |
|
| 1854 | + * @param $string |
|
| 1855 | + * |
|
| 1856 | + * @return mixed |
|
| 1857 | + */ |
|
| 1858 | + public function block_props_replace( $string, $no_wrap = false ) { |
|
| 1859 | + |
|
| 1860 | + if ( $no_wrap ) { |
|
| 1861 | + $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 1862 | + } else { |
|
| 1863 | + $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 1864 | + } |
|
| 1865 | + |
|
| 1866 | + return $string; |
|
| 1867 | + } |
|
| 1868 | + |
|
| 1869 | + /** |
|
| 1870 | + * Outputs the content of the widget |
|
| 1871 | + * |
|
| 1872 | + * @param array $args |
|
| 1873 | + * @param array $instance |
|
| 1874 | + */ |
|
| 1875 | + public function widget( $args, $instance ) { |
|
| 1876 | + |
|
| 1877 | + // get the filtered values |
|
| 1878 | + $argument_values = $this->argument_values( $instance ); |
|
| 1879 | + $argument_values = $this->string_to_bool( $argument_values ); |
|
| 1880 | + $output = $this->output( $argument_values, $args ); |
|
| 1881 | + |
|
| 1882 | + if ( $output ) { |
|
| 1883 | + // Before widget |
|
| 1884 | + $before_widget = $args['before_widget']; |
|
| 1885 | + $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 1886 | + $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 1887 | + |
|
| 1888 | + // After widget |
|
| 1889 | + $after_widget = $args['after_widget']; |
|
| 1890 | + $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 1891 | + $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 1892 | + |
|
| 1893 | + echo $before_widget; |
|
| 1894 | + // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 1895 | + if ( $this->is_elementor_widget_output() ) { |
|
| 1896 | + echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : ''; |
|
| 1897 | + } |
|
| 1898 | + echo $this->output_title( $args, $instance ); |
|
| 1899 | + echo $output; |
|
| 1900 | + if ( $this->is_elementor_widget_output() ) { |
|
| 1901 | + echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : ''; |
|
| 1902 | + } |
|
| 1903 | + echo $after_widget; |
|
| 1904 | + } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 1905 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1906 | + echo $output; |
|
| 1907 | + } |
|
| 1908 | + } |
|
| 1909 | + |
|
| 1910 | + /** |
|
| 1911 | + * Tests if the current output is inside a elementor container. |
|
| 1912 | + * |
|
| 1913 | + * @since 1.0.4 |
|
| 1914 | + * @return bool |
|
| 1915 | + */ |
|
| 1916 | + public function is_elementor_widget_output() { |
|
| 1917 | + $result = false; |
|
| 1918 | + if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 1919 | + $result = true; |
|
| 1920 | + } |
|
| 1921 | + |
|
| 1922 | + return $result; |
|
| 1923 | + } |
|
| 1924 | + |
|
| 1925 | + /** |
|
| 1926 | + * Tests if the current output is inside a elementor preview. |
|
| 1927 | + * |
|
| 1928 | + * @since 1.0.4 |
|
| 1929 | + * @return bool |
|
| 1930 | + */ |
|
| 1931 | + public function is_elementor_preview() { |
|
| 1932 | + $result = false; |
|
| 1933 | + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 1934 | + $result = true; |
|
| 1935 | + } |
|
| 1936 | + |
|
| 1937 | + return $result; |
|
| 1938 | + } |
|
| 1939 | + |
|
| 1940 | + /** |
|
| 1941 | + * Tests if the current output is inside a Divi preview. |
|
| 1942 | + * |
|
| 1943 | + * @since 1.0.6 |
|
| 1944 | + * @return bool |
|
| 1945 | + */ |
|
| 1946 | + public function is_divi_preview() { |
|
| 1947 | + $result = false; |
|
| 1948 | + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 1949 | + $result = true; |
|
| 1950 | + } |
|
| 1951 | + |
|
| 1952 | + return $result; |
|
| 1953 | + } |
|
| 1954 | + |
|
| 1955 | + /** |
|
| 1956 | + * Tests if the current output is inside a Beaver builder preview. |
|
| 1957 | + * |
|
| 1958 | + * @since 1.0.6 |
|
| 1959 | + * @return bool |
|
| 1960 | + */ |
|
| 1961 | + public function is_beaver_preview() { |
|
| 1962 | + $result = false; |
|
| 1963 | + if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 1964 | + $result = true; |
|
| 1965 | + } |
|
| 1966 | + |
|
| 1967 | + return $result; |
|
| 1968 | + } |
|
| 1969 | + |
|
| 1970 | + /** |
|
| 1971 | + * Tests if the current output is inside a siteorigin builder preview. |
|
| 1972 | + * |
|
| 1973 | + * @since 1.0.6 |
|
| 1974 | + * @return bool |
|
| 1975 | + */ |
|
| 1976 | + public function is_siteorigin_preview() { |
|
| 1977 | + $result = false; |
|
| 1978 | + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 1979 | + $result = true; |
|
| 1980 | + } |
|
| 1981 | + |
|
| 1982 | + return $result; |
|
| 1983 | + } |
|
| 1984 | + |
|
| 1985 | + /** |
|
| 1986 | + * Tests if the current output is inside a cornerstone builder preview. |
|
| 1987 | + * |
|
| 1988 | + * @since 1.0.8 |
|
| 1989 | + * @return bool |
|
| 1990 | + */ |
|
| 1991 | + public function is_cornerstone_preview() { |
|
| 1992 | + $result = false; |
|
| 1993 | + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 1994 | + $result = true; |
|
| 1995 | + } |
|
| 1996 | + |
|
| 1997 | + return $result; |
|
| 1998 | + } |
|
| 1999 | + |
|
| 2000 | + /** |
|
| 2001 | + * General function to check if we are in a preview situation. |
|
| 2002 | + * |
|
| 2003 | + * @since 1.0.6 |
|
| 2004 | + * @return bool |
|
| 2005 | + */ |
|
| 2006 | + public function is_preview() { |
|
| 2007 | + $preview = false; |
|
| 2008 | + if ( $this->is_divi_preview() ) { |
|
| 2009 | + $preview = true; |
|
| 2010 | + } elseif ( $this->is_elementor_preview() ) { |
|
| 2011 | + $preview = true; |
|
| 2012 | + } elseif ( $this->is_beaver_preview() ) { |
|
| 2013 | + $preview = true; |
|
| 2014 | + } elseif ( $this->is_siteorigin_preview() ) { |
|
| 2015 | + $preview = true; |
|
| 2016 | + } elseif ( $this->is_cornerstone_preview() ) { |
|
| 2017 | + $preview = true; |
|
| 2018 | + } |
|
| 2019 | + |
|
| 2020 | + return $preview; |
|
| 2021 | + } |
|
| 2022 | + |
|
| 2023 | + /** |
|
| 2024 | + * Output the super title. |
|
| 2025 | + * |
|
| 2026 | + * @param $args |
|
| 2027 | + * @param array $instance |
|
| 2028 | + * |
|
| 2029 | + * @return string |
|
| 2030 | + */ |
|
| 2031 | + public function output_title( $args, $instance = array() ) { |
|
| 2032 | + $output = ''; |
|
| 2033 | + if ( ! empty( $instance['title'] ) ) { |
|
| 2034 | + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 2035 | + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 2036 | + $output = $args['before_title'] . $title . $args['after_title']; |
|
| 2037 | + } |
|
| 2038 | + |
|
| 2039 | + return $output; |
|
| 2040 | + } |
|
| 2041 | + |
|
| 2042 | + /** |
|
| 2043 | + * Outputs the options form inputs for the widget. |
|
| 2044 | + * |
|
| 2045 | + * @param array $instance The widget options. |
|
| 2046 | + */ |
|
| 2047 | + public function form( $instance ) { |
|
| 2048 | + |
|
| 2049 | + // set widget instance |
|
| 2050 | + $this->instance = $instance; |
|
| 2051 | + |
|
| 2052 | + // set it as a SD widget |
|
| 2053 | + echo $this->widget_advanced_toggle(); |
|
| 2054 | + |
|
| 2055 | + echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 2056 | + $arguments = $this->get_arguments(); |
|
| 2057 | + |
|
| 2058 | + if ( is_array( $arguments ) ) { |
|
| 2059 | + foreach ( $arguments as $key => $args ) { |
|
| 2060 | + $this->widget_inputs( $args, $instance ); |
|
| 2061 | + } |
|
| 2062 | + } |
|
| 2063 | + } |
|
| 2064 | + |
|
| 2065 | + /** |
|
| 2066 | + * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 2067 | + * |
|
| 2068 | + * @return string |
|
| 2069 | + */ |
|
| 2070 | + public function widget_advanced_toggle() { |
|
| 2071 | + |
|
| 2072 | + $output = ''; |
|
| 2073 | + if ( $this->block_show_advanced() ) { |
|
| 2074 | + $val = 1; |
|
| 2075 | + } else { |
|
| 2076 | + $val = 0; |
|
| 2077 | + } |
|
| 2078 | + |
|
| 2079 | + $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 2080 | + |
|
| 2081 | + return $output; |
|
| 2082 | + } |
|
| 2083 | + |
|
| 2084 | + /** |
|
| 2085 | + * Convert require element. |
|
| 2086 | + * |
|
| 2087 | + * @since 1.0.0 |
|
| 2088 | + * |
|
| 2089 | + * @param string $input Input element. |
|
| 2090 | + * |
|
| 2091 | + * @return string $output |
|
| 2092 | + */ |
|
| 2093 | + public function convert_element_require( $input ) { |
|
| 2094 | + |
|
| 2095 | + $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 2096 | + |
|
| 2097 | + $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 2098 | + "jQuery(form).find('[data-argument=\"", |
|
| 2099 | + "\"]').find('input,select').val()" |
|
| 2100 | + ), $input ) ); |
|
| 2101 | + |
|
| 2102 | + return $output; |
|
| 2103 | + } |
|
| 2104 | + |
|
| 2105 | + /** |
|
| 2106 | + * Builds the inputs for the widget options. |
|
| 2107 | + * |
|
| 2108 | + * @param $args |
|
| 2109 | + * @param $instance |
|
| 2110 | + */ |
|
| 2111 | + public function widget_inputs( $args, $instance ) { |
|
| 2112 | + |
|
| 2113 | + $class = ""; |
|
| 2114 | + $element_require = ""; |
|
| 2115 | + $custom_attributes = ""; |
|
| 2116 | + |
|
| 2117 | + // get value |
|
| 2118 | + if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 2119 | + $value = $instance[ $args['name'] ]; |
|
| 2120 | + } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 2121 | + $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 2122 | + } else { |
|
| 2123 | + $value = ''; |
|
| 2124 | + } |
|
| 2125 | + |
|
| 2126 | + // get placeholder |
|
| 2127 | + if ( ! empty( $args['placeholder'] ) ) { |
|
| 2128 | + $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 2129 | + } else { |
|
| 2130 | + $placeholder = ''; |
|
| 2131 | + } |
|
| 2132 | + |
|
| 2133 | + // get if advanced |
|
| 2134 | + if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 2135 | + $class .= " sd-advanced-setting "; |
|
| 2136 | + } |
|
| 2137 | + |
|
| 2138 | + // element_require |
|
| 2139 | + if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 2140 | + $element_require = $args['element_require']; |
|
| 2141 | + } |
|
| 2142 | + |
|
| 2143 | + // custom_attributes |
|
| 2144 | + if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 2145 | + $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 2146 | + } |
|
| 2147 | + |
|
| 2148 | + // before wrapper |
|
| 2149 | + ?> |
|
| 2150 | 2150 | <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
| 2151 | 2151 | data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
| 2152 | 2152 | data-element_require='<?php if ( $element_require ) { |
| 2153 | - echo $this->convert_element_require( $element_require ); |
|
| 2154 | - } ?>' |
|
| 2153 | + echo $this->convert_element_require( $element_require ); |
|
| 2154 | + } ?>' |
|
| 2155 | 2155 | > |
| 2156 | 2156 | <?php |
| 2157 | 2157 | |
| 2158 | - switch ( $args['type'] ) { |
|
| 2159 | - //array('text','password','number','email','tel','url','color') |
|
| 2160 | - case "text": |
|
| 2161 | - case "password": |
|
| 2162 | - case "number": |
|
| 2163 | - case "email": |
|
| 2164 | - case "tel": |
|
| 2165 | - case "url": |
|
| 2166 | - case "color": |
|
| 2167 | - ?> |
|
| 2158 | + switch ( $args['type'] ) { |
|
| 2159 | + //array('text','password','number','email','tel','url','color') |
|
| 2160 | + case "text": |
|
| 2161 | + case "password": |
|
| 2162 | + case "number": |
|
| 2163 | + case "email": |
|
| 2164 | + case "tel": |
|
| 2165 | + case "url": |
|
| 2166 | + case "color": |
|
| 2167 | + ?> |
|
| 2168 | 2168 | <label |
| 2169 | 2169 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 2170 | 2170 | <input <?php echo $placeholder; ?> class="widefat" |
@@ -2175,47 +2175,47 @@ discard block |
||
| 2175 | 2175 | value="<?php echo esc_attr( $value ); ?>"> |
| 2176 | 2176 | <?php |
| 2177 | 2177 | |
| 2178 | - break; |
|
| 2179 | - case "select": |
|
| 2180 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 2181 | - if ( $multiple ) { |
|
| 2182 | - if ( empty( $value ) ) { |
|
| 2183 | - $value = array(); |
|
| 2184 | - } |
|
| 2185 | - } |
|
| 2186 | - ?> |
|
| 2178 | + break; |
|
| 2179 | + case "select": |
|
| 2180 | + $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 2181 | + if ( $multiple ) { |
|
| 2182 | + if ( empty( $value ) ) { |
|
| 2183 | + $value = array(); |
|
| 2184 | + } |
|
| 2185 | + } |
|
| 2186 | + ?> |
|
| 2187 | 2187 | <label |
| 2188 | 2188 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 2189 | 2189 | <select <?php echo $placeholder; ?> class="widefat" |
| 2190 | 2190 | <?php echo $custom_attributes; ?> |
| 2191 | 2191 | id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 2192 | 2192 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
| 2193 | - if ( $multiple ) { |
|
| 2194 | - echo "[]"; |
|
| 2195 | - } ?>" |
|
| 2193 | + if ( $multiple ) { |
|
| 2194 | + echo "[]"; |
|
| 2195 | + } ?>" |
|
| 2196 | 2196 | <?php if ( $multiple ) { |
| 2197 | - echo "multiple"; |
|
| 2198 | - } //@todo not implemented yet due to gutenberg not supporting it |
|
| 2199 | - ?> |
|
| 2197 | + echo "multiple"; |
|
| 2198 | + } //@todo not implemented yet due to gutenberg not supporting it |
|
| 2199 | + ?> |
|
| 2200 | 2200 | > |
| 2201 | 2201 | <?php |
| 2202 | 2202 | |
| 2203 | - if ( ! empty( $args['options'] ) ) { |
|
| 2204 | - foreach ( $args['options'] as $val => $label ) { |
|
| 2205 | - if ( $multiple ) { |
|
| 2206 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 2207 | - } else { |
|
| 2208 | - $selected = selected( $value, $val, false ); |
|
| 2209 | - } |
|
| 2210 | - echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 2211 | - } |
|
| 2212 | - } |
|
| 2213 | - ?> |
|
| 2203 | + if ( ! empty( $args['options'] ) ) { |
|
| 2204 | + foreach ( $args['options'] as $val => $label ) { |
|
| 2205 | + if ( $multiple ) { |
|
| 2206 | + $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 2207 | + } else { |
|
| 2208 | + $selected = selected( $value, $val, false ); |
|
| 2209 | + } |
|
| 2210 | + echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 2211 | + } |
|
| 2212 | + } |
|
| 2213 | + ?> |
|
| 2214 | 2214 | </select> |
| 2215 | 2215 | <?php |
| 2216 | - break; |
|
| 2217 | - case "checkbox": |
|
| 2218 | - ?> |
|
| 2216 | + break; |
|
| 2217 | + case "checkbox": |
|
| 2218 | + ?> |
|
| 2219 | 2219 | <input <?php echo $placeholder; ?> |
| 2220 | 2220 | <?php checked( 1, $value, true ) ?> |
| 2221 | 2221 | <?php echo $custom_attributes; ?> |
@@ -2225,136 +2225,136 @@ discard block |
||
| 2225 | 2225 | <label |
| 2226 | 2226 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 2227 | 2227 | <?php |
| 2228 | - break; |
|
| 2229 | - case "hidden": |
|
| 2230 | - ?> |
|
| 2228 | + break; |
|
| 2229 | + case "hidden": |
|
| 2230 | + ?> |
|
| 2231 | 2231 | <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 2232 | 2232 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
| 2233 | 2233 | value="<?php echo esc_attr( $value ); ?>"> |
| 2234 | 2234 | <?php |
| 2235 | - break; |
|
| 2236 | - default: |
|
| 2237 | - echo "No input type found!"; // @todo we need to add more input types. |
|
| 2238 | - } |
|
| 2235 | + break; |
|
| 2236 | + default: |
|
| 2237 | + echo "No input type found!"; // @todo we need to add more input types. |
|
| 2238 | + } |
|
| 2239 | 2239 | |
| 2240 | - // after wrapper |
|
| 2241 | - ?> |
|
| 2240 | + // after wrapper |
|
| 2241 | + ?> |
|
| 2242 | 2242 | </p> |
| 2243 | 2243 | <?php |
| 2244 | 2244 | |
| 2245 | - } |
|
| 2246 | - |
|
| 2247 | - /** |
|
| 2248 | - * Get the widget input description html. |
|
| 2249 | - * |
|
| 2250 | - * @param $args |
|
| 2251 | - * |
|
| 2252 | - * @return string |
|
| 2253 | - * @todo, need to make its own tooltip script |
|
| 2254 | - */ |
|
| 2255 | - public function widget_field_desc( $args ) { |
|
| 2256 | - |
|
| 2257 | - $description = ''; |
|
| 2258 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 2259 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 2260 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 2261 | - } else { |
|
| 2262 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 2263 | - } |
|
| 2264 | - } |
|
| 2265 | - |
|
| 2266 | - return $description; |
|
| 2267 | - } |
|
| 2268 | - |
|
| 2269 | - /** |
|
| 2270 | - * Get the tool tip html. |
|
| 2271 | - * |
|
| 2272 | - * @param $tip |
|
| 2273 | - * @param bool $allow_html |
|
| 2274 | - * |
|
| 2275 | - * @return string |
|
| 2276 | - */ |
|
| 2277 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 2278 | - if ( $allow_html ) { |
|
| 2279 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 2280 | - } else { |
|
| 2281 | - $tip = esc_attr( $tip ); |
|
| 2282 | - } |
|
| 2283 | - |
|
| 2284 | - return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 2285 | - } |
|
| 2286 | - |
|
| 2287 | - /** |
|
| 2288 | - * Sanitize a string destined to be a tooltip. |
|
| 2289 | - * |
|
| 2290 | - * @param string $var |
|
| 2291 | - * |
|
| 2292 | - * @return string |
|
| 2293 | - */ |
|
| 2294 | - public function sanitize_tooltip( $var ) { |
|
| 2295 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 2296 | - 'br' => array(), |
|
| 2297 | - 'em' => array(), |
|
| 2298 | - 'strong' => array(), |
|
| 2299 | - 'small' => array(), |
|
| 2300 | - 'span' => array(), |
|
| 2301 | - 'ul' => array(), |
|
| 2302 | - 'li' => array(), |
|
| 2303 | - 'ol' => array(), |
|
| 2304 | - 'p' => array(), |
|
| 2305 | - ) ) ); |
|
| 2306 | - } |
|
| 2307 | - |
|
| 2308 | - /** |
|
| 2309 | - * Processing widget options on save |
|
| 2310 | - * |
|
| 2311 | - * @param array $new_instance The new options |
|
| 2312 | - * @param array $old_instance The previous options |
|
| 2313 | - * |
|
| 2314 | - * @return array |
|
| 2315 | - * @todo we should add some sanitation here. |
|
| 2316 | - */ |
|
| 2317 | - public function update( $new_instance, $old_instance ) { |
|
| 2318 | - |
|
| 2319 | - //save the widget |
|
| 2320 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 2321 | - |
|
| 2322 | - // set widget instance |
|
| 2323 | - $this->instance = $instance; |
|
| 2324 | - |
|
| 2325 | - if ( empty( $this->arguments ) ) { |
|
| 2326 | - $this->get_arguments(); |
|
| 2327 | - } |
|
| 2328 | - |
|
| 2329 | - // check for checkboxes |
|
| 2330 | - if ( ! empty( $this->arguments ) ) { |
|
| 2331 | - foreach ( $this->arguments as $argument ) { |
|
| 2332 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 2333 | - $instance[ $argument['name'] ] = '0'; |
|
| 2334 | - } |
|
| 2335 | - } |
|
| 2336 | - } |
|
| 2337 | - |
|
| 2338 | - return $instance; |
|
| 2339 | - } |
|
| 2340 | - |
|
| 2341 | - /** |
|
| 2342 | - * Checks if the current call is a ajax call to get the block content. |
|
| 2343 | - * |
|
| 2344 | - * This can be used in your widget to return different content as the block content. |
|
| 2345 | - * |
|
| 2346 | - * @since 1.0.3 |
|
| 2347 | - * @return bool |
|
| 2348 | - */ |
|
| 2349 | - public function is_block_content_call() { |
|
| 2350 | - $result = false; |
|
| 2351 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 2352 | - $result = true; |
|
| 2353 | - } |
|
| 2354 | - |
|
| 2355 | - return $result; |
|
| 2356 | - } |
|
| 2357 | - |
|
| 2358 | - } |
|
| 2245 | + } |
|
| 2246 | + |
|
| 2247 | + /** |
|
| 2248 | + * Get the widget input description html. |
|
| 2249 | + * |
|
| 2250 | + * @param $args |
|
| 2251 | + * |
|
| 2252 | + * @return string |
|
| 2253 | + * @todo, need to make its own tooltip script |
|
| 2254 | + */ |
|
| 2255 | + public function widget_field_desc( $args ) { |
|
| 2256 | + |
|
| 2257 | + $description = ''; |
|
| 2258 | + if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 2259 | + if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 2260 | + $description = $this->desc_tip( $args['desc'] ); |
|
| 2261 | + } else { |
|
| 2262 | + $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 2263 | + } |
|
| 2264 | + } |
|
| 2265 | + |
|
| 2266 | + return $description; |
|
| 2267 | + } |
|
| 2268 | + |
|
| 2269 | + /** |
|
| 2270 | + * Get the tool tip html. |
|
| 2271 | + * |
|
| 2272 | + * @param $tip |
|
| 2273 | + * @param bool $allow_html |
|
| 2274 | + * |
|
| 2275 | + * @return string |
|
| 2276 | + */ |
|
| 2277 | + function desc_tip( $tip, $allow_html = false ) { |
|
| 2278 | + if ( $allow_html ) { |
|
| 2279 | + $tip = $this->sanitize_tooltip( $tip ); |
|
| 2280 | + } else { |
|
| 2281 | + $tip = esc_attr( $tip ); |
|
| 2282 | + } |
|
| 2283 | + |
|
| 2284 | + return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 2285 | + } |
|
| 2286 | + |
|
| 2287 | + /** |
|
| 2288 | + * Sanitize a string destined to be a tooltip. |
|
| 2289 | + * |
|
| 2290 | + * @param string $var |
|
| 2291 | + * |
|
| 2292 | + * @return string |
|
| 2293 | + */ |
|
| 2294 | + public function sanitize_tooltip( $var ) { |
|
| 2295 | + return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 2296 | + 'br' => array(), |
|
| 2297 | + 'em' => array(), |
|
| 2298 | + 'strong' => array(), |
|
| 2299 | + 'small' => array(), |
|
| 2300 | + 'span' => array(), |
|
| 2301 | + 'ul' => array(), |
|
| 2302 | + 'li' => array(), |
|
| 2303 | + 'ol' => array(), |
|
| 2304 | + 'p' => array(), |
|
| 2305 | + ) ) ); |
|
| 2306 | + } |
|
| 2307 | + |
|
| 2308 | + /** |
|
| 2309 | + * Processing widget options on save |
|
| 2310 | + * |
|
| 2311 | + * @param array $new_instance The new options |
|
| 2312 | + * @param array $old_instance The previous options |
|
| 2313 | + * |
|
| 2314 | + * @return array |
|
| 2315 | + * @todo we should add some sanitation here. |
|
| 2316 | + */ |
|
| 2317 | + public function update( $new_instance, $old_instance ) { |
|
| 2318 | + |
|
| 2319 | + //save the widget |
|
| 2320 | + $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 2321 | + |
|
| 2322 | + // set widget instance |
|
| 2323 | + $this->instance = $instance; |
|
| 2324 | + |
|
| 2325 | + if ( empty( $this->arguments ) ) { |
|
| 2326 | + $this->get_arguments(); |
|
| 2327 | + } |
|
| 2328 | + |
|
| 2329 | + // check for checkboxes |
|
| 2330 | + if ( ! empty( $this->arguments ) ) { |
|
| 2331 | + foreach ( $this->arguments as $argument ) { |
|
| 2332 | + if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 2333 | + $instance[ $argument['name'] ] = '0'; |
|
| 2334 | + } |
|
| 2335 | + } |
|
| 2336 | + } |
|
| 2337 | + |
|
| 2338 | + return $instance; |
|
| 2339 | + } |
|
| 2340 | + |
|
| 2341 | + /** |
|
| 2342 | + * Checks if the current call is a ajax call to get the block content. |
|
| 2343 | + * |
|
| 2344 | + * This can be used in your widget to return different content as the block content. |
|
| 2345 | + * |
|
| 2346 | + * @since 1.0.3 |
|
| 2347 | + * @return bool |
|
| 2348 | + */ |
|
| 2349 | + public function is_block_content_call() { |
|
| 2350 | + $result = false; |
|
| 2351 | + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 2352 | + $result = true; |
|
| 2353 | + } |
|
| 2354 | + |
|
| 2355 | + return $result; |
|
| 2356 | + } |
|
| 2357 | + |
|
| 2358 | + } |
|
| 2359 | 2359 | |
| 2360 | 2360 | } |
| 2361 | 2361 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | - exit; |
|
| 9 | + exit; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -15,71 +15,71 @@ discard block |
||
| 15 | 15 | class WPInv_Admin_Addons extends Ayecode_Addons { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Get the extensions page tabs. |
|
| 20 | - * |
|
| 21 | - * @return array of tabs. |
|
| 22 | - */ |
|
| 23 | - public function get_tabs(){ |
|
| 24 | - $tabs = array( |
|
| 25 | - 'addons' => __("Addons", "invoicing"), |
|
| 18 | + /** |
|
| 19 | + * Get the extensions page tabs. |
|
| 20 | + * |
|
| 21 | + * @return array of tabs. |
|
| 22 | + */ |
|
| 23 | + public function get_tabs(){ |
|
| 24 | + $tabs = array( |
|
| 25 | + 'addons' => __("Addons", "invoicing"), |
|
| 26 | 26 | 'gateways' => __("Payment Gateways", "invoicing"), |
| 27 | 27 | 'recommended_plugins' => __("Recommended plugins", "invoicing"), |
| 28 | 28 | 'membership' => __("Membership", "invoicing"), |
| 29 | - ); |
|
| 30 | - |
|
| 31 | - return $tabs; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Get section content for the addons screen. |
|
| 36 | - * |
|
| 37 | - * @param string $section_id |
|
| 38 | - * |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - public function get_section_data( $section_id ) { |
|
| 42 | - $section = self::get_tab( $section_id ); |
|
| 43 | - $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
| 44 | - $section_data = new stdClass(); |
|
| 45 | - |
|
| 46 | - if($section_id=='recommended_plugins'){ |
|
| 47 | - $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
| 48 | - } |
|
| 49 | - elseif ( ! empty( $section ) ) { |
|
| 50 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 51 | - //if ( 1==1) { |
|
| 52 | - |
|
| 53 | - $query_args = array( 'category' => $section_id, 'number' => 100); |
|
| 54 | - $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
| 55 | - |
|
| 56 | - $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
| 57 | - |
|
| 58 | - if ( ! is_wp_error( $raw_section ) ) { |
|
| 59 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 60 | - |
|
| 61 | - if ( ! empty( $section_data->products ) ) { |
|
| 62 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $products = isset($section_data->products) ? $section_data->products : ''; |
|
| 69 | - |
|
| 70 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Outputs a button. |
|
| 75 | - *ccc |
|
| 76 | - * @param string $url |
|
| 77 | - * @param string $text |
|
| 78 | - * @param string $theme |
|
| 79 | - * @param string $plugin |
|
| 80 | - */ |
|
| 81 | - public function output_button( $addon ) { |
|
| 82 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 29 | + ); |
|
| 30 | + |
|
| 31 | + return $tabs; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Get section content for the addons screen. |
|
| 36 | + * |
|
| 37 | + * @param string $section_id |
|
| 38 | + * |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + public function get_section_data( $section_id ) { |
|
| 42 | + $section = self::get_tab( $section_id ); |
|
| 43 | + $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
| 44 | + $section_data = new stdClass(); |
|
| 45 | + |
|
| 46 | + if($section_id=='recommended_plugins'){ |
|
| 47 | + $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
| 48 | + } |
|
| 49 | + elseif ( ! empty( $section ) ) { |
|
| 50 | + if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 51 | + //if ( 1==1) { |
|
| 52 | + |
|
| 53 | + $query_args = array( 'category' => $section_id, 'number' => 100); |
|
| 54 | + $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
| 55 | + |
|
| 56 | + $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
| 57 | + |
|
| 58 | + if ( ! is_wp_error( $raw_section ) ) { |
|
| 59 | + $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 60 | + |
|
| 61 | + if ( ! empty( $section_data->products ) ) { |
|
| 62 | + set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $products = isset($section_data->products) ? $section_data->products : ''; |
|
| 69 | + |
|
| 70 | + return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Outputs a button. |
|
| 75 | + *ccc |
|
| 76 | + * @param string $url |
|
| 77 | + * @param string $text |
|
| 78 | + * @param string $theme |
|
| 79 | + * @param string $plugin |
|
| 80 | + */ |
|
| 81 | + public function output_button( $addon ) { |
|
| 82 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 83 | 83 | // $button_text = __('Free','invoicing'); |
| 84 | 84 | // $licensing = false; |
| 85 | 85 | // $installed = false; |
@@ -91,123 +91,123 @@ discard block |
||
| 91 | 91 | // $install_status = 'get'; |
| 92 | 92 | // $onclick = ''; |
| 93 | 93 | |
| 94 | - $wp_org_themes = array('supreme-directory','directory-starter'); |
|
| 95 | - |
|
| 96 | - $button_args = array( |
|
| 97 | - 'type' => $current_tab, |
|
| 98 | - 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
| 99 | - 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
| 100 | - 'button_text' => __('Free','invoicing'), |
|
| 101 | - 'price_text' => __('Free','invoicing'), |
|
| 102 | - 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
| 103 | - 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
| 104 | - 'class' => 'button-primary', |
|
| 105 | - 'install_status' => 'get', |
|
| 106 | - 'installed' => false, |
|
| 107 | - 'price' => '', |
|
| 108 | - 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
| 109 | - 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
| 110 | - 'onclick' => '', |
|
| 111 | - 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
| 112 | - 'active' => false, |
|
| 113 | - 'file' => '', |
|
| 114 | - 'update_url' => '', |
|
| 115 | - ); |
|
| 116 | - |
|
| 117 | - if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
| 118 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 119 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 120 | - $status = self::install_plugin_install_status($addon); |
|
| 121 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 122 | - if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
| 123 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 124 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 125 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 126 | - $button_args['installed'] = self::is_theme_installed($addon); |
|
| 127 | - if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
| 128 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 129 | - } |
|
| 130 | - }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
| 131 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 132 | - $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
| 133 | - $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
| 134 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // set price |
|
| 138 | - if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
| 139 | - if(is_object($addon->pricing)){ |
|
| 140 | - $prices = (Array)$addon->pricing; |
|
| 141 | - $button_args['price'] = reset($prices); |
|
| 142 | - }elseif(isset($addon->pricing)){ |
|
| 143 | - $button_args['price'] = $addon->pricing; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // set price text |
|
| 148 | - if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
| 149 | - $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - // set if installed |
|
| 154 | - if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
| 155 | - $button_args['installed'] = true; |
|
| 156 | - } |
|
| 94 | + $wp_org_themes = array('supreme-directory','directory-starter'); |
|
| 95 | + |
|
| 96 | + $button_args = array( |
|
| 97 | + 'type' => $current_tab, |
|
| 98 | + 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
| 99 | + 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
| 100 | + 'button_text' => __('Free','invoicing'), |
|
| 101 | + 'price_text' => __('Free','invoicing'), |
|
| 102 | + 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
| 103 | + 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
| 104 | + 'class' => 'button-primary', |
|
| 105 | + 'install_status' => 'get', |
|
| 106 | + 'installed' => false, |
|
| 107 | + 'price' => '', |
|
| 108 | + 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
| 109 | + 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
| 110 | + 'onclick' => '', |
|
| 111 | + 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
| 112 | + 'active' => false, |
|
| 113 | + 'file' => '', |
|
| 114 | + 'update_url' => '', |
|
| 115 | + ); |
|
| 116 | + |
|
| 117 | + if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
| 118 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 119 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 120 | + $status = self::install_plugin_install_status($addon); |
|
| 121 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 122 | + if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
| 123 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 124 | + }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 125 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 126 | + $button_args['installed'] = self::is_theme_installed($addon); |
|
| 127 | + if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
| 128 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 129 | + } |
|
| 130 | + }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
| 131 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 132 | + $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
| 133 | + $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
| 134 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // set price |
|
| 138 | + if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
| 139 | + if(is_object($addon->pricing)){ |
|
| 140 | + $prices = (Array)$addon->pricing; |
|
| 141 | + $button_args['price'] = reset($prices); |
|
| 142 | + }elseif(isset($addon->pricing)){ |
|
| 143 | + $button_args['price'] = $addon->pricing; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // set price text |
|
| 148 | + if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
| 149 | + $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + // set if installed |
|
| 154 | + if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
| 155 | + $button_args['installed'] = true; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | // print_r($button_args); |
| 159 | - // set if active |
|
| 160 | - if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
| 161 | - if($button_args['type'] != 'themes'){ |
|
| 162 | - $button_args['active'] = is_plugin_active($button_args['file']); |
|
| 163 | - }else{ |
|
| 164 | - $button_args['active'] = self::is_theme_active($addon); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // set button text and class |
|
| 169 | - if($button_args['active']){ |
|
| 170 | - $button_args['button_text'] = __('Active','invoicing'); |
|
| 171 | - $button_args['class'] = ' button-secondary disabled '; |
|
| 172 | - }elseif($button_args['installed']){ |
|
| 173 | - $button_args['button_text'] = __('Activate','invoicing'); |
|
| 174 | - |
|
| 175 | - if($button_args['type'] != 'themes'){ |
|
| 176 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 177 | - $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
| 178 | - }else{ |
|
| 179 | - $button_args['url'] = '#'; |
|
| 180 | - } |
|
| 181 | - }else{ |
|
| 182 | - if ( current_user_can( 'switch_themes' ) ) { |
|
| 183 | - $button_args['url'] = self::get_theme_activation_url($addon); |
|
| 184 | - }else{ |
|
| 185 | - $button_args['url'] = '#'; |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - }else{ |
|
| 190 | - if($button_args['type'] == 'recommended_plugins'){ |
|
| 191 | - $button_args['button_text'] = __('Install','invoicing'); |
|
| 192 | - }else{ |
|
| 193 | - $button_args['button_text'] = __('Get it','invoicing'); |
|
| 194 | - |
|
| 195 | - /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
| 159 | + // set if active |
|
| 160 | + if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
| 161 | + if($button_args['type'] != 'themes'){ |
|
| 162 | + $button_args['active'] = is_plugin_active($button_args['file']); |
|
| 163 | + }else{ |
|
| 164 | + $button_args['active'] = self::is_theme_active($addon); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // set button text and class |
|
| 169 | + if($button_args['active']){ |
|
| 170 | + $button_args['button_text'] = __('Active','invoicing'); |
|
| 171 | + $button_args['class'] = ' button-secondary disabled '; |
|
| 172 | + }elseif($button_args['installed']){ |
|
| 173 | + $button_args['button_text'] = __('Activate','invoicing'); |
|
| 174 | + |
|
| 175 | + if($button_args['type'] != 'themes'){ |
|
| 176 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 177 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
| 178 | + }else{ |
|
| 179 | + $button_args['url'] = '#'; |
|
| 180 | + } |
|
| 181 | + }else{ |
|
| 182 | + if ( current_user_can( 'switch_themes' ) ) { |
|
| 183 | + $button_args['url'] = self::get_theme_activation_url($addon); |
|
| 184 | + }else{ |
|
| 185 | + $button_args['url'] = '#'; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + }else{ |
|
| 190 | + if($button_args['type'] == 'recommended_plugins'){ |
|
| 191 | + $button_args['button_text'] = __('Install','invoicing'); |
|
| 192 | + }else{ |
|
| 193 | + $button_args['button_text'] = __('Get it','invoicing'); |
|
| 194 | + |
|
| 195 | + /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
| 196 | 196 | $button_args['button_text'] = __('Install','invoicing'); |
| 197 | 197 | $button_args['url'] = self::get_theme_install_url($button_args['slug']); |
| 198 | 198 | $button_args['onclick'] = 'gd_set_button_installing(this);'; |
| 199 | 199 | }*/ |
| 200 | 200 | |
| 201 | - } |
|
| 202 | - } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | |
| 205 | - // filter the button arguments |
|
| 206 | - $button_args = apply_filters('edd_api_button_args',$button_args); |
|
| 205 | + // filter the button arguments |
|
| 206 | + $button_args = apply_filters('edd_api_button_args',$button_args); |
|
| 207 | 207 | |
| 208 | - // set price text |
|
| 209 | - if(isset($button_args['price_text'])){ |
|
| 210 | - ?> |
|
| 208 | + // set price text |
|
| 209 | + if(isset($button_args['price_text'])){ |
|
| 210 | + ?> |
|
| 211 | 211 | <a |
| 212 | 212 | target="_blank" |
| 213 | 213 | class="addons-price-text" |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | <?php echo esc_html( $button_args['price_text'] ); ?> |
| 216 | 216 | </a> |
| 217 | 217 | <?php |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | 220 | |
| 221 | - $target = ''; |
|
| 222 | - if ( ! empty( $button_args['url'] ) ) { |
|
| 223 | - $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
| 224 | - } |
|
| 221 | + $target = ''; |
|
| 222 | + if ( ! empty( $button_args['url'] ) ) { |
|
| 223 | + $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - ?> |
|
| 226 | + ?> |
|
| 227 | 227 | <a |
| 228 | 228 | data-licence="<?php echo esc_attr($button_args['license']);?>" |
| 229 | 229 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>" |
@@ -246,28 +246,28 @@ discard block |
||
| 246 | 246 | <?php |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Handles output of the addons page in admin. |
|
| 254 | - */ |
|
| 255 | - public function output() { |
|
| 256 | - $tabs = self::get_tabs(); |
|
| 257 | - $sections = self::get_sections(); |
|
| 258 | - $theme = wp_get_theme(); |
|
| 259 | - $section_keys = array_keys( $sections ); |
|
| 260 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 261 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 262 | - include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * A list of recommended wp.org plugins. |
|
| 267 | - * @return array |
|
| 268 | - */ |
|
| 269 | - public function get_recommend_wp_plugins(){ |
|
| 270 | - $plugins = array( |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Handles output of the addons page in admin. |
|
| 254 | + */ |
|
| 255 | + public function output() { |
|
| 256 | + $tabs = self::get_tabs(); |
|
| 257 | + $sections = self::get_sections(); |
|
| 258 | + $theme = wp_get_theme(); |
|
| 259 | + $section_keys = array_keys( $sections ); |
|
| 260 | + $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 261 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 262 | + include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * A list of recommended wp.org plugins. |
|
| 267 | + * @return array |
|
| 268 | + */ |
|
| 269 | + public function get_recommend_wp_plugins(){ |
|
| 270 | + $plugins = array( |
|
| 271 | 271 | 'invoicing-quotes' => array( |
| 272 | 272 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
| 273 | 273 | 'slug' => 'invoicing-quotes', |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | 'name' => 'UsersWP', |
| 288 | 288 | 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'), |
| 289 | 289 | ), |
| 290 | - ); |
|
| 290 | + ); |
|
| 291 | 291 | |
| 292 | - return $plugins; |
|
| 293 | - } |
|
| 292 | + return $plugins; |
|
| 293 | + } |
|
| 294 | 294 | } |