Version Description
- 2021-12-06 =
- Added FS methods duplication
Download this release
Release Info
Developer | wpdesk |
Plugin | Flexible Shipping for WooCommerce |
Version | 4.11.0 |
Comparing to | |
See all releases |
Code changes from version 4.10.1 to 4.11.0
- assets/js/duplicate-methods.js +27 -0
- assets/js/duplicate-methods.min.js +3 -0
- classes/class-flexible-shipping-plugin.php +71 -51
- classes/tracker/tracker.php +4 -0
- flexible-shipping.php +3 -3
- lang/flexible-shipping.pot +44 -22
- readme.txt +4 -1
- src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertAction.php +25 -62
- src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateAction.php +138 -0
- src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateNotice.php +53 -0
- src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateScript.php +73 -0
- src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateTracker.php +35 -0
- src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicatorChecker.php +46 -0
- src/WPDesk/FS/TableRate/ShippingMethod/Management/ShippingMethodManagement.php +100 -0
- vendor/autoload.php +1 -1
- vendor/composer/autoload_classmap.php +6 -0
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +11 -5
- vendor_prefixed/wpdesk/wp-wpdesk-license/src/ApiManager/class-wc-plugin-update.php +5 -2
assets/js/duplicate-methods.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function fs_add_duplicate_field() {
|
2 |
+
setTimeout( function () {
|
3 |
+
jQuery( '.wc-shipping-zone-method-type' ).filter( function () {
|
4 |
+
return jQuery( this ).text() === fs_duplicate_methods.shipping_method;
|
5 |
+
} ).each( function () {
|
6 |
+
let row = jQuery( this ).closest( 'tr' );
|
7 |
+
|
8 |
+
if ( row.find( '.js--duplicate-button' ).length > 0 ) {
|
9 |
+
return;
|
10 |
+
}
|
11 |
+
|
12 |
+
let instance_id = parseInt( new URL( row.find( 'a.wc-shipping-zone-method-settings' ).attr( 'href' ), window.location.origin ).searchParams.get( fs_duplicate_methods.param_name ), 10 );
|
13 |
+
let row_actions = row.find( '.row-actions' );
|
14 |
+
let duplicate_url = new URL( fs_duplicate_methods.duplicate_url );
|
15 |
+
duplicate_url.searchParams.append( fs_duplicate_methods.param_name, instance_id );
|
16 |
+
let duplicate = ' | <a href="' + duplicate_url + '" class="js--duplicate-button">' + fs_duplicate_methods.duplicate_label + '</a>';
|
17 |
+
|
18 |
+
row_actions.append( duplicate );
|
19 |
+
} );
|
20 |
+
}, 10 );
|
21 |
+
}
|
22 |
+
|
23 |
+
fs_add_duplicate_field();
|
24 |
+
|
25 |
+
document.querySelector( '.wc-shipping-zone-method-rows' ).addEventListener( 'DOMNodeInserted', function ( event ) {
|
26 |
+
fs_add_duplicate_field();
|
27 |
+
}, false );
|
assets/js/duplicate-methods.min.js
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
function fs_add_duplicate_field(){setTimeout(function(){jQuery('.wc-shipping-zone-method-type').filter(function(){return jQuery(this).text()===fs_duplicate_methods.shipping_method}).each(function(){let row=jQuery(this).closest('tr');if(row.find('.js--duplicate-button').length>0){return}
|
2 |
+
let instance_id=parseInt(new URL(row.find('a.wc-shipping-zone-method-settings').attr('href'),window.location.origin).searchParams.get(fs_duplicate_methods.param_name),10);let row_actions=row.find('.row-actions');let duplicate_url=new URL(fs_duplicate_methods.duplicate_url);duplicate_url.searchParams.append(fs_duplicate_methods.param_name,instance_id);let duplicate=' | <a href="'+duplicate_url+'" class="js--duplicate-button">'+fs_duplicate_methods.duplicate_label+'</a>';row_actions.append(duplicate)})},10)}
|
3 |
+
fs_add_duplicate_field();document.querySelector('.wc-shipping-zone-method-rows').addEventListener('DOMNodeInserted',function(event){fs_add_duplicate_field()},!1)
|
classes/class-flexible-shipping-plugin.php
CHANGED
@@ -64,6 +64,12 @@ use WPDesk\FS\TableRate\ShippingMethod\BlockEditing\BlockEditing;
|
|
64 |
use WPDesk\FS\TableRate\ShippingMethod\Convert\ConvertAction;
|
65 |
use WPDesk\FS\TableRate\ShippingMethod\Convert\ConvertNotice;
|
66 |
use WPDesk\FS\TableRate\ShippingMethod\Convert\ConvertTracker;
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
use WPDesk\FS\TableRate\ShippingMethod\MethodTitle;
|
68 |
use WPDesk\FS\TableRate\ShippingMethod\MethodDescription;
|
69 |
use WPDesk\FS\TableRate\ShippingMethodSingle;
|
@@ -86,15 +92,15 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
86 |
const PLUGIN_FILE = 'flexible-shipping/flexible-shipping.php';
|
87 |
|
88 |
const PRIORITY_BEFORE_SHARED_HELPER = - 35;
|
89 |
-
const PRIORITY_LAST
|
90 |
-
const PRIORITY_AFTER_DEFAULT
|
91 |
|
92 |
/**
|
93 |
* Scripts version.
|
94 |
*
|
95 |
* @var string
|
96 |
*/
|
97 |
-
private $scripts_version = '
|
98 |
|
99 |
/**
|
100 |
* Admin notices.
|
@@ -180,6 +186,8 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
180 |
* Load dependencies.
|
181 |
*/
|
182 |
private function load_dependencies() {
|
|
|
|
|
183 |
require_once __DIR__ . '/../inc/functions.php';
|
184 |
|
185 |
$session_factory = new SessionFactory();
|
@@ -247,11 +255,24 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
247 |
$this->add_hookable( new ImporterData() );
|
248 |
$this->add_hookable( new ExporterData() );
|
249 |
|
|
|
|
|
250 |
// Converter.
|
251 |
-
$this->add_hookable( new ConvertAction() );
|
252 |
$this->add_hookable( new ConvertNotice() );
|
253 |
$this->add_hookable( new ConvertTracker() );
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
// Block Settings.
|
256 |
$this->add_hookable( new BlockEditing() );
|
257 |
|
@@ -280,17 +301,17 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
280 |
$this->get_plugin_assets_url() . '../vendor_prefixed/wpdesk/wp-nps/assets/',
|
281 |
$this->scripts_version,
|
282 |
new DisplayNpsLocationsAndUserDecisions(
|
283 |
-
|
284 |
new ShippingMethodDisplayNpsDecision( 'flexible_shipping_single' ),
|
285 |
-
new AdminPageDisplayNpsDecision(
|
286 |
'page' => 'wc-settings',
|
287 |
'tab' => 'shipping',
|
288 |
-
'section' => 'flexible_shipping_info'
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
new NpsDisplayDecision( new UserDisplayNpsDecision( $user_meta_name ) )
|
293 |
-
|
294 |
),
|
295 |
$user_meta_name,
|
296 |
admin_url( 'admin-ajax.php' )
|
@@ -369,9 +390,9 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
369 |
$this->settings_url = admin_url( 'admin.php?page=flexible-shipping-settings' );
|
370 |
$this->docs_url = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://docs.flexibleshipping.com/collection/20-fs-table-rate/';
|
371 |
|
372 |
-
$this->default_view_args =
|
373 |
'plugin_url' => $this->get_plugin_url(),
|
374 |
-
|
375 |
|
376 |
}
|
377 |
|
@@ -411,66 +432,66 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
411 |
public function hooks() {
|
412 |
parent::hooks();
|
413 |
|
414 |
-
add_filter( 'woocommerce_shipping_methods',
|
415 |
$this,
|
416 |
-
'woocommerce_shipping_methods_filter'
|
417 |
-
|
418 |
|
419 |
add_action(
|
420 |
'flexible_shipping_method_rate_id',
|
421 |
-
|
422 |
$this,
|
423 |
'flexible_shipping_method_rate_id',
|
424 |
-
|
425 |
9999999,
|
426 |
2
|
427 |
);
|
428 |
|
429 |
add_filter(
|
430 |
'woocommerce_shipping_chosen_method',
|
431 |
-
|
432 |
$this,
|
433 |
'woocommerce_default_shipment_method',
|
434 |
-
|
435 |
10,
|
436 |
3
|
437 |
);
|
438 |
|
439 |
add_action(
|
440 |
'woocommerce_checkout_update_order_meta',
|
441 |
-
|
442 |
$this,
|
443 |
'add_flexible_shipping_order_meta_on_checkout_woo_pre_27',
|
444 |
-
|
445 |
);
|
446 |
|
447 |
add_action(
|
448 |
'woocommerce_checkout_create_order',
|
449 |
-
|
450 |
$this,
|
451 |
'add_flexible_shipping_order_meta_on_checkout',
|
452 |
-
|
453 |
);
|
454 |
|
455 |
-
add_filter( 'option_woocommerce_cod_settings',
|
456 |
|
457 |
-
add_action( 'plugins_loaded',
|
458 |
|
459 |
-
add_action( 'admin_init',
|
460 |
|
461 |
-
add_action( 'woocommerce_init',
|
462 |
|
463 |
-
add_action( 'woocommerce_init',
|
464 |
|
465 |
-
add_action( 'woocommerce_init',
|
466 |
|
467 |
-
add_action( 'woocommerce_init',
|
468 |
|
469 |
-
add_action( 'woocommerce_init',
|
470 |
|
471 |
-
add_action( 'woocommerce_init',
|
472 |
|
473 |
-
add_action( 'woocommerce_init',
|
474 |
|
475 |
$this->hooks_on_hookable_objects();
|
476 |
}
|
@@ -491,7 +512,6 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
491 |
|
492 |
/**
|
493 |
* .
|
494 |
-
*
|
495 |
* @internal
|
496 |
*/
|
497 |
public function init_shipping_zones_notice() {
|
@@ -691,7 +711,8 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
691 |
* @param WC_Shipping_Rate[] $available_methods Available methods in frontend.
|
692 |
* Function is assigned to woocommerce_default_shipment_method filter.
|
693 |
* In this parameter we expecting array of WC_Shipping_Rate objects.
|
694 |
-
* But third party plugins can change this parameter type or set it to
|
|
|
695 |
* @param string|bool|null $chosen_method If false or null then no method is chosen.
|
696 |
*
|
697 |
* @return string
|
@@ -722,14 +743,14 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
722 |
wp_register_script(
|
723 |
'fs_rules_settings',
|
724 |
trailingslashit( $this->get_plugin_assets_url() ) . 'js/rules-settings.js',
|
725 |
-
|
726 |
$this->scripts_version
|
727 |
);
|
728 |
wp_enqueue_script( 'fs_rules_settings' );
|
729 |
wp_enqueue_style(
|
730 |
'fs_rules_settings',
|
731 |
trailingslashit( $this->get_plugin_assets_url() ) . 'css/rules-settings.css',
|
732 |
-
|
733 |
$this->scripts_version
|
734 |
);
|
735 |
wp_set_script_translations( 'fs_rules_settings', 'flexible-shipping', $this->plugin_path . '/lang/' );
|
@@ -745,7 +766,7 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
745 |
wp_register_script(
|
746 |
'fs_admin',
|
747 |
trailingslashit( $this->get_plugin_assets_url() ) . 'js/admin' . $suffix . '.js',
|
748 |
-
|
749 |
$this->scripts_version
|
750 |
);
|
751 |
|
@@ -753,7 +774,7 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
753 |
wp_localize_script(
|
754 |
'fs_admin',
|
755 |
'fs_admin',
|
756 |
-
|
757 |
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
758 |
'notice_not_good_enought' => sprintf(
|
759 |
// Translators: link.
|
@@ -761,7 +782,7 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
761 |
'<a class="button close-fs-rate-notice" target="_blank" href="' . esc_url( $notice_url ) . '">',
|
762 |
'</a>'
|
763 |
),
|
764 |
-
|
765 |
);
|
766 |
wp_enqueue_script( 'fs_admin' );
|
767 |
|
@@ -770,7 +791,7 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
770 |
wp_register_script(
|
771 |
'wpdesk_contextual_info',
|
772 |
trailingslashit( $this->get_plugin_assets_url() ) . 'js/contextual-info' . $suffix . '.js',
|
773 |
-
|
774 |
$this->scripts_version
|
775 |
);
|
776 |
wp_enqueue_script( 'wpdesk_contextual_info' );
|
@@ -782,13 +803,13 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
782 |
wp_enqueue_style(
|
783 |
'fs_admin',
|
784 |
trailingslashit( $this->get_plugin_assets_url() ) . 'css/admin.css',
|
785 |
-
|
786 |
$this->scripts_version
|
787 |
);
|
788 |
wp_enqueue_style(
|
789 |
'fs_font',
|
790 |
trailingslashit( $this->get_plugin_assets_url() ) . 'css/font' . $suffix . '.css',
|
791 |
-
|
792 |
$this->scripts_version
|
793 |
);
|
794 |
|
@@ -805,10 +826,10 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
805 |
private function should_enqueue_admin_scripts() {
|
806 |
$current_screen = get_current_screen();
|
807 |
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
|
808 |
-
if ( in_array( $current_screen->post_type,
|
809 |
'shop_order',
|
810 |
-
'shop_subscription'
|
811 |
-
|
812 |
return true;
|
813 |
}
|
814 |
|
@@ -837,14 +858,14 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
837 |
|
838 |
$settings_url = admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=' . WPDesk_Flexible_Shipping_Settings::METHOD_ID );
|
839 |
|
840 |
-
$plugin_links =
|
841 |
'<a href="' . $settings_url . '">' . __(
|
842 |
'Settings',
|
843 |
'flexible-shipping'
|
844 |
) . '</a>',
|
845 |
'<a target="_blank" href="' . $docs_link . '">' . __( 'Docs', 'flexible-shipping' ) . '</a>',
|
846 |
'<a target="_blank" href="' . $support_link . '">' . __( 'Support', 'flexible-shipping' ) . '</a>',
|
847 |
-
|
848 |
$pro_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/sklep/flexible-shipping-pro-woocommerce/' : 'https://flexibleshipping.com/products/flexible-shipping-pro-woocommerce/';
|
849 |
$utm = get_locale() === 'pl_PL' ? '?utm_campaign=flexible-shipping&utm_source=user-site&utm_medium=link&utm_term=&utm_content=fs-plugins-upgrade' : '?utm_source=fs&utm_medium=quick-link&utm_campaign=upgrade-quick-link';
|
850 |
|
@@ -860,7 +881,6 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
860 |
|
861 |
/**
|
862 |
* .
|
863 |
-
*
|
864 |
* @param string $method_id .
|
865 |
* @param array $shipping_method .
|
866 |
*
|
64 |
use WPDesk\FS\TableRate\ShippingMethod\Convert\ConvertAction;
|
65 |
use WPDesk\FS\TableRate\ShippingMethod\Convert\ConvertNotice;
|
66 |
use WPDesk\FS\TableRate\ShippingMethod\Convert\ConvertTracker;
|
67 |
+
use WPDesk\FS\TableRate\ShippingMethod\Duplicate\DuplicateAction;
|
68 |
+
use WPDesk\FS\TableRate\ShippingMethod\Duplicate\DuplicateNotice;
|
69 |
+
use WPDesk\FS\TableRate\ShippingMethod\Duplicate\DuplicateScript;
|
70 |
+
use WPDesk\FS\TableRate\ShippingMethod\Duplicate\DuplicateTracker;
|
71 |
+
use WPDesk\FS\TableRate\ShippingMethod\Duplicate\DuplicatorChecker;
|
72 |
+
use WPDesk\FS\TableRate\ShippingMethod\Management\ShippingMethodManagement;
|
73 |
use WPDesk\FS\TableRate\ShippingMethod\MethodTitle;
|
74 |
use WPDesk\FS\TableRate\ShippingMethod\MethodDescription;
|
75 |
use WPDesk\FS\TableRate\ShippingMethodSingle;
|
92 |
const PLUGIN_FILE = 'flexible-shipping/flexible-shipping.php';
|
93 |
|
94 |
const PRIORITY_BEFORE_SHARED_HELPER = - 35;
|
95 |
+
const PRIORITY_LAST = 999999;
|
96 |
+
const PRIORITY_AFTER_DEFAULT = 20;
|
97 |
|
98 |
/**
|
99 |
* Scripts version.
|
100 |
*
|
101 |
* @var string
|
102 |
*/
|
103 |
+
private $scripts_version = '269';
|
104 |
|
105 |
/**
|
106 |
* Admin notices.
|
186 |
* Load dependencies.
|
187 |
*/
|
188 |
private function load_dependencies() {
|
189 |
+
global $wpdb;
|
190 |
+
|
191 |
require_once __DIR__ . '/../inc/functions.php';
|
192 |
|
193 |
$session_factory = new SessionFactory();
|
255 |
$this->add_hookable( new ImporterData() );
|
256 |
$this->add_hookable( new ExporterData() );
|
257 |
|
258 |
+
$shipping_method_management = new ShippingMethodManagement( $wpdb );
|
259 |
+
|
260 |
// Converter.
|
261 |
+
$this->add_hookable( new ConvertAction( $shipping_method_management ) );
|
262 |
$this->add_hookable( new ConvertNotice() );
|
263 |
$this->add_hookable( new ConvertTracker() );
|
264 |
|
265 |
+
// Duplicate FS Method.
|
266 |
+
$duplicator_checker = new DuplicatorChecker( $shipping_method_management );
|
267 |
+
$this->add_hookable( new DuplicateAction( $duplicator_checker, $shipping_method_management ) );
|
268 |
+
$this->add_hookable( new DuplicateNotice() );
|
269 |
+
$this->add_hookable( new DuplicateTracker() );
|
270 |
+
$this->add_hookable( new DuplicateScript(
|
271 |
+
trailingslashit( $this->get_plugin_assets_url() ),
|
272 |
+
$this->scripts_version
|
273 |
+
)
|
274 |
+
);
|
275 |
+
|
276 |
// Block Settings.
|
277 |
$this->add_hookable( new BlockEditing() );
|
278 |
|
301 |
$this->get_plugin_assets_url() . '../vendor_prefixed/wpdesk/wp-nps/assets/',
|
302 |
$this->scripts_version,
|
303 |
new DisplayNpsLocationsAndUserDecisions(
|
304 |
+
[
|
305 |
new ShippingMethodDisplayNpsDecision( 'flexible_shipping_single' ),
|
306 |
+
new AdminPageDisplayNpsDecision( [
|
307 |
'page' => 'wc-settings',
|
308 |
'tab' => 'shipping',
|
309 |
+
'section' => 'flexible_shipping_info',
|
310 |
+
] ),
|
311 |
+
],
|
312 |
+
[
|
313 |
+
new NpsDisplayDecision( new UserDisplayNpsDecision( $user_meta_name ) ),
|
314 |
+
]
|
315 |
),
|
316 |
$user_meta_name,
|
317 |
admin_url( 'admin-ajax.php' )
|
390 |
$this->settings_url = admin_url( 'admin.php?page=flexible-shipping-settings' );
|
391 |
$this->docs_url = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://docs.flexibleshipping.com/collection/20-fs-table-rate/';
|
392 |
|
393 |
+
$this->default_view_args = [
|
394 |
'plugin_url' => $this->get_plugin_url(),
|
395 |
+
];
|
396 |
|
397 |
}
|
398 |
|
432 |
public function hooks() {
|
433 |
parent::hooks();
|
434 |
|
435 |
+
add_filter( 'woocommerce_shipping_methods', [
|
436 |
$this,
|
437 |
+
'woocommerce_shipping_methods_filter',
|
438 |
+
], self::PRIORITY_AFTER_DEFAULT );
|
439 |
|
440 |
add_action(
|
441 |
'flexible_shipping_method_rate_id',
|
442 |
+
[
|
443 |
$this,
|
444 |
'flexible_shipping_method_rate_id',
|
445 |
+
],
|
446 |
9999999,
|
447 |
2
|
448 |
);
|
449 |
|
450 |
add_filter(
|
451 |
'woocommerce_shipping_chosen_method',
|
452 |
+
[
|
453 |
$this,
|
454 |
'woocommerce_default_shipment_method',
|
455 |
+
],
|
456 |
10,
|
457 |
3
|
458 |
);
|
459 |
|
460 |
add_action(
|
461 |
'woocommerce_checkout_update_order_meta',
|
462 |
+
[
|
463 |
$this,
|
464 |
'add_flexible_shipping_order_meta_on_checkout_woo_pre_27',
|
465 |
+
]
|
466 |
);
|
467 |
|
468 |
add_action(
|
469 |
'woocommerce_checkout_create_order',
|
470 |
+
[
|
471 |
$this,
|
472 |
'add_flexible_shipping_order_meta_on_checkout',
|
473 |
+
]
|
474 |
);
|
475 |
|
476 |
+
add_filter( 'option_woocommerce_cod_settings', [ $this, 'option_woocommerce_cod_settings' ] );
|
477 |
|
478 |
+
add_action( 'plugins_loaded', [ $this, 'create_tracker' ], self::PRIORITY_BEFORE_SHARED_HELPER );
|
479 |
|
480 |
+
add_action( 'admin_init', [ $this, 'init_deactivation_tracker' ] );
|
481 |
|
482 |
+
add_action( 'woocommerce_init', [ $this, 'init_free_shipping_notice' ] );
|
483 |
|
484 |
+
add_action( 'woocommerce_init', [ $this, 'init_logger_on_shipping_method' ] );
|
485 |
|
486 |
+
add_action( 'woocommerce_init', [ $this, 'init_contextual_info' ] );
|
487 |
|
488 |
+
add_action( 'woocommerce_init', [ $this, 'init_beacon' ] );
|
489 |
|
490 |
+
add_action( 'woocommerce_init', [ $this, 'init_shipping_zones_notice' ] );
|
491 |
|
492 |
+
add_action( 'woocommerce_init', [ $this, 'init_multicurrency' ] );
|
493 |
|
494 |
+
add_action( 'woocommerce_init', [ $this, 'init_external_plugin_access' ] );
|
495 |
|
496 |
$this->hooks_on_hookable_objects();
|
497 |
}
|
512 |
|
513 |
/**
|
514 |
* .
|
|
|
515 |
* @internal
|
516 |
*/
|
517 |
public function init_shipping_zones_notice() {
|
711 |
* @param WC_Shipping_Rate[] $available_methods Available methods in frontend.
|
712 |
* Function is assigned to woocommerce_default_shipment_method filter.
|
713 |
* In this parameter we expecting array of WC_Shipping_Rate objects.
|
714 |
+
* But third party plugins can change this parameter type or set it to
|
715 |
+
* null.
|
716 |
* @param string|bool|null $chosen_method If false or null then no method is chosen.
|
717 |
*
|
718 |
* @return string
|
743 |
wp_register_script(
|
744 |
'fs_rules_settings',
|
745 |
trailingslashit( $this->get_plugin_assets_url() ) . 'js/rules-settings.js',
|
746 |
+
[ 'wp-i18n' ],
|
747 |
$this->scripts_version
|
748 |
);
|
749 |
wp_enqueue_script( 'fs_rules_settings' );
|
750 |
wp_enqueue_style(
|
751 |
'fs_rules_settings',
|
752 |
trailingslashit( $this->get_plugin_assets_url() ) . 'css/rules-settings.css',
|
753 |
+
[],
|
754 |
$this->scripts_version
|
755 |
);
|
756 |
wp_set_script_translations( 'fs_rules_settings', 'flexible-shipping', $this->plugin_path . '/lang/' );
|
766 |
wp_register_script(
|
767 |
'fs_admin',
|
768 |
trailingslashit( $this->get_plugin_assets_url() ) . 'js/admin' . $suffix . '.js',
|
769 |
+
[ 'jquery' ],
|
770 |
$this->scripts_version
|
771 |
);
|
772 |
|
774 |
wp_localize_script(
|
775 |
'fs_admin',
|
776 |
'fs_admin',
|
777 |
+
[
|
778 |
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
779 |
'notice_not_good_enought' => sprintf(
|
780 |
// Translators: link.
|
782 |
'<a class="button close-fs-rate-notice" target="_blank" href="' . esc_url( $notice_url ) . '">',
|
783 |
'</a>'
|
784 |
),
|
785 |
+
]
|
786 |
);
|
787 |
wp_enqueue_script( 'fs_admin' );
|
788 |
|
791 |
wp_register_script(
|
792 |
'wpdesk_contextual_info',
|
793 |
trailingslashit( $this->get_plugin_assets_url() ) . 'js/contextual-info' . $suffix . '.js',
|
794 |
+
[ 'jquery' ],
|
795 |
$this->scripts_version
|
796 |
);
|
797 |
wp_enqueue_script( 'wpdesk_contextual_info' );
|
803 |
wp_enqueue_style(
|
804 |
'fs_admin',
|
805 |
trailingslashit( $this->get_plugin_assets_url() ) . 'css/admin.css',
|
806 |
+
[],
|
807 |
$this->scripts_version
|
808 |
);
|
809 |
wp_enqueue_style(
|
810 |
'fs_font',
|
811 |
trailingslashit( $this->get_plugin_assets_url() ) . 'css/font' . $suffix . '.css',
|
812 |
+
[],
|
813 |
$this->scripts_version
|
814 |
);
|
815 |
|
826 |
private function should_enqueue_admin_scripts() {
|
827 |
$current_screen = get_current_screen();
|
828 |
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
|
829 |
+
if ( in_array( $current_screen->post_type, [
|
830 |
'shop_order',
|
831 |
+
'shop_subscription',
|
832 |
+
], true ) || $wc_screen_id . '_page_wc-settings' === $current_screen->id ) {
|
833 |
return true;
|
834 |
}
|
835 |
|
858 |
|
859 |
$settings_url = admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=' . WPDesk_Flexible_Shipping_Settings::METHOD_ID );
|
860 |
|
861 |
+
$plugin_links = [
|
862 |
'<a href="' . $settings_url . '">' . __(
|
863 |
'Settings',
|
864 |
'flexible-shipping'
|
865 |
) . '</a>',
|
866 |
'<a target="_blank" href="' . $docs_link . '">' . __( 'Docs', 'flexible-shipping' ) . '</a>',
|
867 |
'<a target="_blank" href="' . $support_link . '">' . __( 'Support', 'flexible-shipping' ) . '</a>',
|
868 |
+
];
|
869 |
$pro_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/sklep/flexible-shipping-pro-woocommerce/' : 'https://flexibleshipping.com/products/flexible-shipping-pro-woocommerce/';
|
870 |
$utm = get_locale() === 'pl_PL' ? '?utm_campaign=flexible-shipping&utm_source=user-site&utm_medium=link&utm_term=&utm_content=fs-plugins-upgrade' : '?utm_source=fs&utm_medium=quick-link&utm_campaign=upgrade-quick-link';
|
871 |
|
881 |
|
882 |
/**
|
883 |
* .
|
|
|
884 |
* @param string $method_id .
|
885 |
* @param array $shipping_method .
|
886 |
*
|
classes/tracker/tracker.php
CHANGED
@@ -82,6 +82,10 @@ class WPDesk_Flexible_Shipping_Tracker implements Hookable {
|
|
82 |
|
83 |
foreach ( $flexible_shipping_rates as $rate_id => $flexible_shipping_rate ) {
|
84 |
|
|
|
|
|
|
|
|
|
85 |
$data['flexible_shipping']['total_shipping_methods'] ++;
|
86 |
|
87 |
if ( ShippingMethodSingle::SHIPPING_METHOD_ID === $flexible_shipping_rate['method_id'] ) {
|
82 |
|
83 |
foreach ( $flexible_shipping_rates as $rate_id => $flexible_shipping_rate ) {
|
84 |
|
85 |
+
if ( ! isset( $flexible_shipping_rate['method_rules'] ) ) {
|
86 |
+
$flexible_shipping_rate['method_rules'] = [];
|
87 |
+
}
|
88 |
+
|
89 |
$data['flexible_shipping']['total_shipping_methods'] ++;
|
90 |
|
91 |
if ( ShippingMethodSingle::SHIPPING_METHOD_ID === $flexible_shipping_rate['method_id'] ) {
|
flexible-shipping.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Flexible Shipping
|
4 |
* Plugin URI: https://wordpress.org/plugins/flexible-shipping/
|
5 |
* Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
|
6 |
-
* Version: 4.
|
7 |
* Author: WP Desk
|
8 |
* Author URI: https://flexibleshipping.com/?utm_source=fs&utm_medium=link&utm_campaign=plugin-list-author
|
9 |
* Text Domain: flexible-shipping
|
@@ -11,7 +11,7 @@
|
|
11 |
* Requires at least: 5.2
|
12 |
* Tested up to: 5.8
|
13 |
* WC requires at least: 5.6
|
14 |
-
* WC tested up to:
|
15 |
* Requires PHP: 7.0
|
16 |
*
|
17 |
* Copyright 2017 WP Desk Ltd.
|
@@ -38,7 +38,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
38 |
} // Exit if accessed directly
|
39 |
|
40 |
/* THIS VARIABLE CAN BE CHANGED AUTOMATICALLY */
|
41 |
-
$plugin_version = '4.
|
42 |
|
43 |
$plugin_name = 'Flexible Shipping';
|
44 |
$product_id = 'Flexible Shipping';
|
3 |
* Plugin Name: Flexible Shipping
|
4 |
* Plugin URI: https://wordpress.org/plugins/flexible-shipping/
|
5 |
* Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
|
6 |
+
* Version: 4.11.0
|
7 |
* Author: WP Desk
|
8 |
* Author URI: https://flexibleshipping.com/?utm_source=fs&utm_medium=link&utm_campaign=plugin-list-author
|
9 |
* Text Domain: flexible-shipping
|
11 |
* Requires at least: 5.2
|
12 |
* Tested up to: 5.8
|
13 |
* WC requires at least: 5.6
|
14 |
+
* WC tested up to: 6.0
|
15 |
* Requires PHP: 7.0
|
16 |
*
|
17 |
* Copyright 2017 WP Desk Ltd.
|
38 |
} // Exit if accessed directly
|
39 |
|
40 |
/* THIS VARIABLE CAN BE CHANGED AUTOMATICALLY */
|
41 |
+
$plugin_version = '4.11.0';
|
42 |
|
43 |
$plugin_name = 'Flexible Shipping';
|
44 |
$product_id = 'Flexible Shipping';
|
lang/flexible-shipping.pot
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
# This file is distributed under the same license as the Flexible Shipping plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Flexible Shipping 4.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/flexible-shipping\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2021-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: flexible-shipping\n"
|
@@ -22,6 +22,8 @@ msgstr ""
|
|
22 |
#: classes/table-rate/settings/flexible-shipping.php:33
|
23 |
#: classes/table-rate/shipping-method.php:95
|
24 |
#: src/WPDesk/FS/TableRate/ShippingMethod/CommonMethodSettings.php:154
|
|
|
|
|
25 |
#: src/WPDesk/FS/TableRate/ShippingMethodSingle.php:63
|
26 |
msgid "Flexible Shipping"
|
27 |
msgstr ""
|
@@ -42,77 +44,77 @@ msgstr ""
|
|
42 |
msgid "https://flexibleshipping.com/?utm_source=fs&utm_medium=link&utm_campaign=plugin-list-author"
|
43 |
msgstr ""
|
44 |
|
45 |
-
#: classes/class-flexible-shipping-plugin.php:
|
46 |
msgid "Hey, we are curious how would you grade your first impression on Flexible Shipping so far?"
|
47 |
msgstr ""
|
48 |
|
49 |
-
#: classes/class-flexible-shipping-plugin.php:
|
50 |
msgid "Wow, it's awesome!"
|
51 |
msgstr ""
|
52 |
|
53 |
-
#: classes/class-flexible-shipping-plugin.php:
|
54 |
msgid "Really poor"
|
55 |
msgstr ""
|
56 |
|
57 |
-
#: classes/class-flexible-shipping-plugin.php:
|
58 |
msgid "By using the 'Send feedback' button I hereby agree and consent to the terms of %1$sPrivacy Policy%2$s."
|
59 |
msgstr ""
|
60 |
|
61 |
-
#: classes/class-flexible-shipping-plugin.php:
|
62 |
msgid "More calculation conditions"
|
63 |
msgstr ""
|
64 |
|
65 |
-
#: classes/class-flexible-shipping-plugin.php:
|
66 |
msgid "What exactly should the conditions you need be based on?"
|
67 |
msgstr ""
|
68 |
|
69 |
-
#: classes/class-flexible-shipping-plugin.php:
|
70 |
msgid "More detailed documentation"
|
71 |
msgstr ""
|
72 |
|
73 |
-
#: classes/class-flexible-shipping-plugin.php:
|
74 |
msgid "Easier contact with support"
|
75 |
msgstr ""
|
76 |
|
77 |
-
#: classes/class-flexible-shipping-plugin.php:
|
78 |
msgid "More user-friendly interface"
|
79 |
msgstr ""
|
80 |
|
81 |
-
#: classes/class-flexible-shipping-plugin.php:
|
82 |
msgid "Less complicated settings"
|
83 |
msgstr ""
|
84 |
|
85 |
-
#: classes/class-flexible-shipping-plugin.php:
|
86 |
msgid "Too soon to say"
|
87 |
msgstr ""
|
88 |
|
89 |
-
#: classes/class-flexible-shipping-plugin.php:
|
90 |
#: classes/views/deactivation_thickbox.php:106
|
91 |
msgid "Other"
|
92 |
msgstr ""
|
93 |
|
94 |
-
#: classes/class-flexible-shipping-plugin.php:
|
95 |
msgid "Please tell us what exactly can we do to improve our plugin?"
|
96 |
msgstr ""
|
97 |
|
98 |
#. Translators: link.
|
99 |
-
#: classes/class-flexible-shipping-plugin.php:
|
100 |
msgid "How can We make Flexible Shipping better for you? %1$sJust write to us.%2$s"
|
101 |
msgstr ""
|
102 |
|
103 |
-
#: classes/class-flexible-shipping-plugin.php:
|
104 |
msgid "Settings"
|
105 |
msgstr ""
|
106 |
|
107 |
-
#: classes/class-flexible-shipping-plugin.php:
|
108 |
msgid "Docs"
|
109 |
msgstr ""
|
110 |
|
111 |
-
#: classes/class-flexible-shipping-plugin.php:
|
112 |
msgid "Support"
|
113 |
msgstr ""
|
114 |
|
115 |
-
#: classes/class-flexible-shipping-plugin.php:
|
116 |
msgid "Upgrade"
|
117 |
msgstr ""
|
118 |
|
@@ -609,11 +611,11 @@ msgstr ""
|
|
609 |
msgid "Enable integration with Flexible Shipping Connect"
|
610 |
msgstr ""
|
611 |
|
612 |
-
#: classes/tracker/tracker.php:
|
613 |
msgid "Opt-in"
|
614 |
msgstr ""
|
615 |
|
616 |
-
#: classes/tracker/tracker.php:
|
617 |
msgid "Opt-out"
|
618 |
msgstr ""
|
619 |
|
@@ -1423,6 +1425,26 @@ msgstr ""
|
|
1423 |
msgid "Flexible Shipping group method has been converted to its new single version and deactivated for safety reasons. Once you make sure everything was converted properly, you can safely delete the previous group method."
|
1424 |
msgstr ""
|
1425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1426 |
#: src/WPDesk/FS/TableRate/ShippingMethod/RateCalculator.php:185
|
1427 |
msgid "Method available only for logged in users, but user is not logged in."
|
1428 |
msgstr ""
|
2 |
# This file is distributed under the same license as the Flexible Shipping plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Flexible Shipping 4.11.0\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/flexible-shipping\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2021-12-06T14:44:33+00:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: flexible-shipping\n"
|
22 |
#: classes/table-rate/settings/flexible-shipping.php:33
|
23 |
#: classes/table-rate/shipping-method.php:95
|
24 |
#: src/WPDesk/FS/TableRate/ShippingMethod/CommonMethodSettings.php:154
|
25 |
+
#: src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateAction.php:76
|
26 |
+
#: src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateScript.php:67
|
27 |
#: src/WPDesk/FS/TableRate/ShippingMethodSingle.php:63
|
28 |
msgid "Flexible Shipping"
|
29 |
msgstr ""
|
44 |
msgid "https://flexibleshipping.com/?utm_source=fs&utm_medium=link&utm_campaign=plugin-list-author"
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: classes/class-flexible-shipping-plugin.php:319
|
48 |
msgid "Hey, we are curious how would you grade your first impression on Flexible Shipping so far?"
|
49 |
msgstr ""
|
50 |
|
51 |
+
#: classes/class-flexible-shipping-plugin.php:320
|
52 |
msgid "Wow, it's awesome!"
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: classes/class-flexible-shipping-plugin.php:321
|
56 |
msgid "Really poor"
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: classes/class-flexible-shipping-plugin.php:324
|
60 |
msgid "By using the 'Send feedback' button I hereby agree and consent to the terms of %1$sPrivacy Policy%2$s."
|
61 |
msgstr ""
|
62 |
|
63 |
+
#: classes/class-flexible-shipping-plugin.php:330
|
64 |
msgid "More calculation conditions"
|
65 |
msgstr ""
|
66 |
|
67 |
+
#: classes/class-flexible-shipping-plugin.php:330
|
68 |
msgid "What exactly should the conditions you need be based on?"
|
69 |
msgstr ""
|
70 |
|
71 |
+
#: classes/class-flexible-shipping-plugin.php:331
|
72 |
msgid "More detailed documentation"
|
73 |
msgstr ""
|
74 |
|
75 |
+
#: classes/class-flexible-shipping-plugin.php:332
|
76 |
msgid "Easier contact with support"
|
77 |
msgstr ""
|
78 |
|
79 |
+
#: classes/class-flexible-shipping-plugin.php:333
|
80 |
msgid "More user-friendly interface"
|
81 |
msgstr ""
|
82 |
|
83 |
+
#: classes/class-flexible-shipping-plugin.php:334
|
84 |
msgid "Less complicated settings"
|
85 |
msgstr ""
|
86 |
|
87 |
+
#: classes/class-flexible-shipping-plugin.php:335
|
88 |
msgid "Too soon to say"
|
89 |
msgstr ""
|
90 |
|
91 |
+
#: classes/class-flexible-shipping-plugin.php:336
|
92 |
#: classes/views/deactivation_thickbox.php:106
|
93 |
msgid "Other"
|
94 |
msgstr ""
|
95 |
|
96 |
+
#: classes/class-flexible-shipping-plugin.php:336
|
97 |
msgid "Please tell us what exactly can we do to improve our plugin?"
|
98 |
msgstr ""
|
99 |
|
100 |
#. Translators: link.
|
101 |
+
#: classes/class-flexible-shipping-plugin.php:781
|
102 |
msgid "How can We make Flexible Shipping better for you? %1$sJust write to us.%2$s"
|
103 |
msgstr ""
|
104 |
|
105 |
+
#: classes/class-flexible-shipping-plugin.php:862
|
106 |
msgid "Settings"
|
107 |
msgstr ""
|
108 |
|
109 |
+
#: classes/class-flexible-shipping-plugin.php:866
|
110 |
msgid "Docs"
|
111 |
msgstr ""
|
112 |
|
113 |
+
#: classes/class-flexible-shipping-plugin.php:867
|
114 |
msgid "Support"
|
115 |
msgstr ""
|
116 |
|
117 |
+
#: classes/class-flexible-shipping-plugin.php:873
|
118 |
msgid "Upgrade"
|
119 |
msgstr ""
|
120 |
|
611 |
msgid "Enable integration with Flexible Shipping Connect"
|
612 |
msgstr ""
|
613 |
|
614 |
+
#: classes/tracker/tracker.php:204
|
615 |
msgid "Opt-in"
|
616 |
msgstr ""
|
617 |
|
618 |
+
#: classes/tracker/tracker.php:207
|
619 |
msgid "Opt-out"
|
620 |
msgstr ""
|
621 |
|
1425 |
msgid "Flexible Shipping group method has been converted to its new single version and deactivated for safety reasons. Once you make sure everything was converted properly, you can safely delete the previous group method."
|
1426 |
msgstr ""
|
1427 |
|
1428 |
+
#: src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateAction.php:56
|
1429 |
+
msgid "Shipping method duplication error. Please try again later."
|
1430 |
+
msgstr ""
|
1431 |
+
|
1432 |
+
#: src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateAction.php:79
|
1433 |
+
msgid "(Copy)"
|
1434 |
+
msgstr ""
|
1435 |
+
|
1436 |
+
#: src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateNotice.php:36
|
1437 |
+
msgid "%1$s%2$s%3$s successfully duplicated."
|
1438 |
+
msgstr ""
|
1439 |
+
|
1440 |
+
#: src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateNotice.php:38
|
1441 |
+
msgid "%1$s%2$s%3$s shipping method duplication error. Please try again later."
|
1442 |
+
msgstr ""
|
1443 |
+
|
1444 |
+
#: src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateScript.php:68
|
1445 |
+
msgid "Duplicate"
|
1446 |
+
msgstr ""
|
1447 |
+
|
1448 |
#: src/WPDesk/FS/TableRate/ShippingMethod/RateCalculator.php:185
|
1449 |
msgid "Method available only for logged in users, but user is not logged in."
|
1450 |
msgstr ""
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flexibleshipping.com/products/flexible-shipping-pro-woocomm
|
|
4 |
Tags: table rate, table rate shipping, conditional shipping, free shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes, shipping, free shipping, advanced shipping
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.8
|
7 |
-
Stable tag: 4.
|
8 |
Requires PHP: 7.0
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -200,6 +200,9 @@ If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible
|
|
200 |
|
201 |
== Changelog ==
|
202 |
|
|
|
|
|
|
|
203 |
= 4.10.1 - 2021-11-18 =
|
204 |
* Removed unnecessary tax calculation when free shipping
|
205 |
|
4 |
Tags: table rate, table rate shipping, conditional shipping, free shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes, shipping, free shipping, advanced shipping
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.8
|
7 |
+
Stable tag: 4.11.0
|
8 |
Requires PHP: 7.0
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
200 |
|
201 |
== Changelog ==
|
202 |
|
203 |
+
= 4.11.0 - 2021-12-06 =
|
204 |
+
* Added FS methods duplication
|
205 |
+
|
206 |
= 4.10.1 - 2021-11-18 =
|
207 |
* Removed unnecessary tax calculation when free shipping
|
208 |
|
src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertAction.php
CHANGED
@@ -10,6 +10,7 @@ namespace WPDesk\FS\TableRate\ShippingMethod\Convert;
|
|
10 |
use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
|
11 |
use WC_Shipping_Zone;
|
12 |
use WC_Shipping_Zones;
|
|
|
13 |
use WPDesk\FS\TableRate\ShippingMethodSingle;
|
14 |
use WPDesk_Flexible_Shipping;
|
15 |
|
@@ -18,13 +19,25 @@ use WPDesk_Flexible_Shipping;
|
|
18 |
*/
|
19 |
class ConvertAction implements Hookable {
|
20 |
const AJAX_ACTION = 'flexible_shipping_process_converting';
|
21 |
-
const AJAX_NONCE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
/**
|
24 |
* Hooks.
|
25 |
*/
|
26 |
public function hooks() {
|
27 |
-
add_action( 'wp_ajax_' . self::AJAX_ACTION,
|
28 |
}
|
29 |
|
30 |
/**
|
@@ -52,22 +65,22 @@ class ConvertAction implements Hookable {
|
|
52 |
$shipping_methods = $shipping_method->get_shipping_methods();
|
53 |
|
54 |
// Shipping method orders.
|
55 |
-
$shipping_method_order = $this->get_shipping_method_order( $instance_id );
|
56 |
-
$this->update_shipping_methods_order( $zone->get_id(), $shipping_method_order, count( $shipping_methods ) );
|
57 |
|
58 |
foreach ( $shipping_methods as $single_shipping_method ) {
|
59 |
$single_shipping_method_instance_id = $this->add_new_shipping_method_to_zone( $zone, $single_shipping_method, $shipping_method );
|
60 |
|
61 |
$method_status = $shipping_method->is_enabled() ? isset( $single_shipping_method['method_enabled'] ) && 'yes' === $single_shipping_method['method_enabled'] : false;
|
62 |
|
63 |
-
$this->set_shipping_method_status( $single_shipping_method_instance_id, $method_status, $zone );
|
64 |
-
$this->update_shipping_method_field( $single_shipping_method_instance_id, 'method_order',
|
65 |
|
66 |
do_action( 'flexible-shipping/group-method/converted-single-method', $single_shipping_method_instance_id, $single_shipping_method );
|
67 |
}
|
68 |
|
69 |
// Turn off current Flexible Shipping Group Method.
|
70 |
-
$this->set_shipping_method_status( $instance_id, false, $zone );
|
71 |
$shipping_method->set_as_converted();
|
72 |
|
73 |
do_action( 'flexible-shipping/group-method/converted-method', $shipping_method );
|
@@ -83,7 +96,7 @@ class ConvertAction implements Hookable {
|
|
83 |
*
|
84 |
* @return int
|
85 |
*/
|
86 |
-
private function add_new_shipping_method_to_zone( WC_Shipping_Zone $zone, array $old_shipping_method_settings, WPDesk_Flexible_Shipping $old_shipping_method ) {
|
87 |
$instance_id = $zone->add_shipping_method( ShippingMethodSingle::SHIPPING_METHOD_ID );
|
88 |
|
89 |
/** @var ShippingMethodSingle $shipping_method . */
|
@@ -91,7 +104,7 @@ class ConvertAction implements Hookable {
|
|
91 |
$shipping_method_key = $shipping_method->get_instance_option_key();
|
92 |
|
93 |
if ( ! is_array( $old_shipping_method_settings ) ) {
|
94 |
-
$old_shipping_method_settings =
|
95 |
}
|
96 |
|
97 |
$old_shipping_method_settings['tax_status'] = $old_shipping_method->get_instance_option( 'tax_status' );
|
@@ -102,69 +115,19 @@ class ConvertAction implements Hookable {
|
|
102 |
return $instance_id;
|
103 |
}
|
104 |
|
105 |
-
/**
|
106 |
-
* @param int $instance_id .
|
107 |
-
* @param bool $status .
|
108 |
-
* @param WC_Shipping_Zone $zone .
|
109 |
-
*/
|
110 |
-
private function set_shipping_method_status( $instance_id, $status, $zone ) {
|
111 |
-
$status = $status ? 1 : 0;
|
112 |
-
|
113 |
-
if ( $this->update_shipping_method_field( $instance_id, 'is_enabled', $status ) ) {
|
114 |
-
$shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
|
115 |
-
|
116 |
-
do_action( 'woocommerce_shipping_zone_method_status_toggled', $shipping_method->instance_id, $shipping_method->id, $zone->get_id(), $status );
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* @param int $instance_id .
|
122 |
-
* @param string $key .
|
123 |
-
* @param string $value .
|
124 |
-
*
|
125 |
-
* @return bool|int
|
126 |
-
*/
|
127 |
-
private function update_shipping_method_field( $instance_id, $key, $value ) {
|
128 |
-
global $wpdb;
|
129 |
-
|
130 |
-
return $wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( $key => $value ), array( 'instance_id' => absint( $instance_id ) ) );
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* @param int $zone_id .
|
135 |
-
* @param int $method_order .
|
136 |
-
* @param int $number_of_shipping_methods .
|
137 |
-
*/
|
138 |
-
private function update_shipping_methods_order( $zone_id, $method_order, $number_of_shipping_methods ) {
|
139 |
-
global $wpdb;
|
140 |
-
|
141 |
-
$wpdb->query( $wpdb->prepare( "UPDATE `{$wpdb->prefix}woocommerce_shipping_zone_methods` SET `method_order` = `method_order`+%d WHERE `zone_id` = %d AND `method_order` > %d", $number_of_shipping_methods, $zone_id, $method_order ) );
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* @param int $instance_id .
|
146 |
-
*
|
147 |
-
* @return int
|
148 |
-
*/
|
149 |
-
private function get_shipping_method_order( $instance_id ) {
|
150 |
-
global $wpdb;
|
151 |
-
|
152 |
-
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT `method_order` FROM `{$wpdb->prefix}woocommerce_shipping_zone_methods` WHERE `instance_id` = %d ORDER BY `method_order` ASC", $instance_id ) );
|
153 |
-
}
|
154 |
-
|
155 |
/**
|
156 |
* @param int $zone_id .
|
157 |
*
|
158 |
* @return string
|
159 |
*/
|
160 |
-
private function get_redirect_url_success_convert( $zone_id ) {
|
161 |
return add_query_arg(
|
162 |
-
|
163 |
'page' => 'wc-settings',
|
164 |
'tab' => 'shipping',
|
165 |
'converted' => '1',
|
166 |
'zone_id' => $zone_id,
|
167 |
-
|
168 |
admin_url( 'admin.php' )
|
169 |
);
|
170 |
}
|
10 |
use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
|
11 |
use WC_Shipping_Zone;
|
12 |
use WC_Shipping_Zones;
|
13 |
+
use WPDesk\FS\TableRate\ShippingMethod\Management\ShippingMethodManagement;
|
14 |
use WPDesk\FS\TableRate\ShippingMethodSingle;
|
15 |
use WPDesk_Flexible_Shipping;
|
16 |
|
19 |
*/
|
20 |
class ConvertAction implements Hookable {
|
21 |
const AJAX_ACTION = 'flexible_shipping_process_converting';
|
22 |
+
const AJAX_NONCE = 'flexible_shipping_process_converting';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var ShippingMethodManagement
|
26 |
+
*/
|
27 |
+
private $shipping_method_management;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param ShippingMethodManagement $shipping_method_management
|
31 |
+
*/
|
32 |
+
public function __construct( ShippingMethodManagement $shipping_method_management ) {
|
33 |
+
$this->shipping_method_management = $shipping_method_management;
|
34 |
+
}
|
35 |
|
36 |
/**
|
37 |
* Hooks.
|
38 |
*/
|
39 |
public function hooks() {
|
40 |
+
add_action( 'wp_ajax_' . self::AJAX_ACTION, [ $this, 'ajax_run_convert' ] );
|
41 |
}
|
42 |
|
43 |
/**
|
65 |
$shipping_methods = $shipping_method->get_shipping_methods();
|
66 |
|
67 |
// Shipping method orders.
|
68 |
+
$shipping_method_order = $this->shipping_method_management->get_shipping_method_order( $instance_id );
|
69 |
+
$this->shipping_method_management->update_shipping_methods_order( $zone->get_id(), $shipping_method_order, count( $shipping_methods ) );
|
70 |
|
71 |
foreach ( $shipping_methods as $single_shipping_method ) {
|
72 |
$single_shipping_method_instance_id = $this->add_new_shipping_method_to_zone( $zone, $single_shipping_method, $shipping_method );
|
73 |
|
74 |
$method_status = $shipping_method->is_enabled() ? isset( $single_shipping_method['method_enabled'] ) && 'yes' === $single_shipping_method['method_enabled'] : false;
|
75 |
|
76 |
+
$this->shipping_method_management->set_shipping_method_status( $single_shipping_method_instance_id, $method_status, $zone );
|
77 |
+
$this->shipping_method_management->update_shipping_method_field( $single_shipping_method_instance_id, 'method_order', ++$shipping_method_order );
|
78 |
|
79 |
do_action( 'flexible-shipping/group-method/converted-single-method', $single_shipping_method_instance_id, $single_shipping_method );
|
80 |
}
|
81 |
|
82 |
// Turn off current Flexible Shipping Group Method.
|
83 |
+
$this->shipping_method_management->set_shipping_method_status( $instance_id, false, $zone );
|
84 |
$shipping_method->set_as_converted();
|
85 |
|
86 |
do_action( 'flexible-shipping/group-method/converted-method', $shipping_method );
|
96 |
*
|
97 |
* @return int
|
98 |
*/
|
99 |
+
private function add_new_shipping_method_to_zone( WC_Shipping_Zone $zone, array $old_shipping_method_settings, WPDesk_Flexible_Shipping $old_shipping_method ): int {
|
100 |
$instance_id = $zone->add_shipping_method( ShippingMethodSingle::SHIPPING_METHOD_ID );
|
101 |
|
102 |
/** @var ShippingMethodSingle $shipping_method . */
|
104 |
$shipping_method_key = $shipping_method->get_instance_option_key();
|
105 |
|
106 |
if ( ! is_array( $old_shipping_method_settings ) ) {
|
107 |
+
$old_shipping_method_settings = [];
|
108 |
}
|
109 |
|
110 |
$old_shipping_method_settings['tax_status'] = $old_shipping_method->get_instance_option( 'tax_status' );
|
115 |
return $instance_id;
|
116 |
}
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
/**
|
119 |
* @param int $zone_id .
|
120 |
*
|
121 |
* @return string
|
122 |
*/
|
123 |
+
private function get_redirect_url_success_convert( int $zone_id ): string {
|
124 |
return add_query_arg(
|
125 |
+
[
|
126 |
'page' => 'wc-settings',
|
127 |
'tab' => 'shipping',
|
128 |
'converted' => '1',
|
129 |
'zone_id' => $zone_id,
|
130 |
+
],
|
131 |
admin_url( 'admin.php' )
|
132 |
);
|
133 |
}
|
src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateAction.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class DuplicateAction
|
4 |
+
*
|
5 |
+
* @package WPDesk\FS\TableRate\ShippingMethod\Duplicate
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WPDesk\FS\TableRate\ShippingMethod\Duplicate;
|
9 |
+
|
10 |
+
use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
|
11 |
+
use WPDesk\FS\TableRate\ShippingMethod\Management\ShippingMethodManagement;
|
12 |
+
use WPDesk\FS\TableRate\ShippingMethodSingle;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Duplicate Action.
|
16 |
+
*/
|
17 |
+
class DuplicateAction implements Hookable {
|
18 |
+
const ACTION = 'fs_duplicate_method';
|
19 |
+
const OPTION = 'fs_duplicate_method';
|
20 |
+
const PARAM_ID = 'instance_id';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var ShippingMethodManagement
|
24 |
+
*/
|
25 |
+
private $shipping_method_management;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var DuplicatorChecker
|
29 |
+
*/
|
30 |
+
private $duplicator_checker;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param DuplicatorChecker $duplicator_checker .
|
34 |
+
* @param ShippingMethodManagement $shipping_method_management .
|
35 |
+
*/
|
36 |
+
public function __construct( DuplicatorChecker $duplicator_checker, ShippingMethodManagement $shipping_method_management ) {
|
37 |
+
$this->duplicator_checker = $duplicator_checker;
|
38 |
+
$this->shipping_method_management = $shipping_method_management;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Init hooks (actions and filters).
|
43 |
+
*
|
44 |
+
* @return void
|
45 |
+
*/
|
46 |
+
public function hooks() {
|
47 |
+
add_action( 'admin_post_' . self::ACTION, [ $this, 'action_duplicate' ] );
|
48 |
+
}
|
49 |
+
|
50 |
+
public function action_duplicate() {
|
51 |
+
check_admin_referer( self::ACTION );
|
52 |
+
|
53 |
+
$instance_id = (int) ( sanitize_text_field( wp_unslash( $_GET[ self::PARAM_ID ] ?? 0 ) ) );
|
54 |
+
|
55 |
+
if ( ! $instance_id ) {
|
56 |
+
wp_die( __( 'Shipping method duplication error. Please try again later.', 'flexible-shipping' ) ); // phpcs:ignore
|
57 |
+
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
|
61 |
+
$title = $this->shipping_method_management->get_shipping_method( $instance_id )->get_title();
|
62 |
+
|
63 |
+
if ( ! $this->duplicator_checker->should_duplicate( $instance_id ) ) {
|
64 |
+
wp_redirect( $this->get_redirect_url( 'error', $title ) );
|
65 |
+
$this->end_request();
|
66 |
+
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
|
70 |
+
$zone = $this->shipping_method_management->get_shipping_zone( $instance_id );
|
71 |
+
$new_instance_id = $zone->add_shipping_method( ShippingMethodSingle::SHIPPING_METHOD_ID );
|
72 |
+
|
73 |
+
$options = $this->get_instance_settings( $instance_id );
|
74 |
+
|
75 |
+
if ( empty( $options['method_title'] ?? '' ) ) {
|
76 |
+
$options['method_title'] = __( 'Flexible Shipping', 'flexible-shipping' );
|
77 |
+
}
|
78 |
+
|
79 |
+
$options['method_title'] .= ' ' . __( '(Copy)', 'flexible-shipping' );
|
80 |
+
|
81 |
+
add_option( $this->get_option_settings_field( $new_instance_id ), $options );
|
82 |
+
|
83 |
+
$this->shipping_method_management->set_shipping_method_status( $new_instance_id, false, $zone );
|
84 |
+
|
85 |
+
$this->update_usage_functionality();
|
86 |
+
|
87 |
+
wp_redirect( $this->get_redirect_url( 'success', $title ) );
|
88 |
+
$this->end_request();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @codeCoverageIgnore
|
93 |
+
*/
|
94 |
+
protected function end_request() {
|
95 |
+
die();
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @param int $instance_id .
|
100 |
+
*
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
private function get_instance_settings( int $instance_id ): array {
|
104 |
+
return (array) get_option( $this->get_option_settings_field( $instance_id ), [] );
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @param int $instance_id .
|
109 |
+
*
|
110 |
+
* @return string
|
111 |
+
*/
|
112 |
+
private function get_option_settings_field( int $instance_id ): string {
|
113 |
+
return sprintf( 'woocommerce_%s_%d_settings', ShippingMethodSingle::SHIPPING_METHOD_ID, $instance_id );
|
114 |
+
}
|
115 |
+
|
116 |
+
private function update_usage_functionality() {
|
117 |
+
$current = (int) get_option( self::OPTION, 0 );
|
118 |
+
|
119 |
+
update_option( self::OPTION, ++$current );
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* @param string $status .
|
124 |
+
* @param string $method_title .
|
125 |
+
*
|
126 |
+
* @return string
|
127 |
+
*/
|
128 |
+
private function get_redirect_url( string $status, string $method_title ): string {
|
129 |
+
return add_query_arg(
|
130 |
+
[
|
131 |
+
self::ACTION => true,
|
132 |
+
'status' => $status,
|
133 |
+
'method_title' => urlencode( $method_title ),
|
134 |
+
],
|
135 |
+
wp_get_referer()
|
136 |
+
);
|
137 |
+
}
|
138 |
+
}
|
src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateNotice.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class DuplicateNotice
|
4 |
+
*
|
5 |
+
* @package WPDesk\FS\TableRate\ShippingMethod\Duplicate
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WPDesk\FS\TableRate\ShippingMethod\Duplicate;
|
9 |
+
|
10 |
+
use FSVendor\WPDesk\Notice\Notice;
|
11 |
+
use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Display admin notices.
|
15 |
+
*/
|
16 |
+
class DuplicateNotice implements Hookable {
|
17 |
+
/**
|
18 |
+
* Hooks.
|
19 |
+
*/
|
20 |
+
public function hooks() {
|
21 |
+
add_action( 'woocommerce_settings_shipping', [ $this, 'add_admin_notice' ] );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add admin notices.
|
26 |
+
*/
|
27 |
+
public function add_admin_notice() {
|
28 |
+
if ( ! isset( $_GET['status'], $_GET[ DuplicateAction::ACTION ], $_GET['method_title'] ) ) {
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
$status = in_array( $_GET['status'], [ 'success', 'error' ] ) ? $_GET['status'] : 'warning'; // phpcs:ignore
|
33 |
+
$title = sanitize_text_field( urldecode( wp_unslash( $_GET['method_title'] ) ) ); // phpcs:ignore
|
34 |
+
|
35 |
+
if ( $status === 'success' ) {
|
36 |
+
$message = __( '%1$s%2$s%3$s successfully duplicated.', 'flexible-shipping' ); // phpcs:ignore
|
37 |
+
} else {
|
38 |
+
$message = __( '%1$s%2$s%3$s shipping method duplication error. Please try again later.', 'flexible-shipping' ); // phpcs:ignore
|
39 |
+
}
|
40 |
+
|
41 |
+
$this->display_notice( sprintf( $message, '<strong>', $title, '</strong>' ), $status );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @param string $content .
|
46 |
+
* @param string $type .
|
47 |
+
*
|
48 |
+
* @codeCoverageIgnore
|
49 |
+
*/
|
50 |
+
protected function display_notice( string $content, string $type ) {
|
51 |
+
new Notice( $content, $type, true );
|
52 |
+
}
|
53 |
+
}
|
src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateScript.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class DuplicateScript
|
4 |
+
*
|
5 |
+
* @package WPDesk\FS\TableRate\ShippingMethod\Duplicate
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WPDesk\FS\TableRate\ShippingMethod\Duplicate;
|
9 |
+
|
10 |
+
use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Duplicate Script.
|
14 |
+
*/
|
15 |
+
class DuplicateScript implements Hookable {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
private $assets_url;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $scripts_version;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* DuplicateScript constructor.
|
29 |
+
*
|
30 |
+
* @param string $assets_url .
|
31 |
+
* @param string $scripts_version .
|
32 |
+
*/
|
33 |
+
public function __construct( string $assets_url, string $scripts_version ) {
|
34 |
+
$this->assets_url = $assets_url;
|
35 |
+
$this->scripts_version = $scripts_version;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Init hooks (actions and filters).
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function hooks() {
|
44 |
+
add_action( 'woocommerce_shipping_zone_after_methods_table', [ $this, 'add_duplicate_scripts' ] );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* .
|
49 |
+
*/
|
50 |
+
public function add_duplicate_scripts() {
|
51 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
52 |
+
|
53 |
+
$handle = 'fs_duplicate_methods';
|
54 |
+
|
55 |
+
wp_enqueue_script(
|
56 |
+
$handle,
|
57 |
+
trailingslashit( $this->assets_url ) . 'js/duplicate-methods' . $suffix . '.js',
|
58 |
+
[ 'jquery', 'wc-shipping-zone-methods' ],
|
59 |
+
$this->scripts_version
|
60 |
+
);
|
61 |
+
|
62 |
+
wp_localize_script(
|
63 |
+
$handle,
|
64 |
+
'fs_duplicate_methods',
|
65 |
+
[
|
66 |
+
'param_name' => DuplicateAction::PARAM_ID,
|
67 |
+
'shipping_method' => __( 'Flexible Shipping', 'flexible-shipping' ),
|
68 |
+
'duplicate_label' => __( 'Duplicate', 'flexible-shipping' ),
|
69 |
+
'duplicate_url' => wp_nonce_url( add_query_arg( 'action', DuplicateAction::ACTION, admin_url( 'admin-post.php' ) ), DuplicateAction::ACTION ),
|
70 |
+
]
|
71 |
+
);
|
72 |
+
}
|
73 |
+
}
|
src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateTracker.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class DuplicateTracker
|
4 |
+
*
|
5 |
+
* @package WPDesk\FS\TableRate\ShippingMethod\Duplicate
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WPDesk\FS\TableRate\ShippingMethod\Duplicate;
|
9 |
+
|
10 |
+
use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Tracking of duplicate usages.
|
14 |
+
*/
|
15 |
+
class DuplicateTracker implements Hookable {
|
16 |
+
const PRIORITY_AFTER_FS_TRACKER = 12;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Hooks.
|
20 |
+
*/
|
21 |
+
public function hooks() {
|
22 |
+
add_filter( 'wpdesk_tracker_data', [ $this, 'add_tracking_data' ], self::PRIORITY_AFTER_FS_TRACKER );
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param array $data .
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
public function add_tracking_data( $data ): array {
|
31 |
+
$data['flexible_shipping']['duplicate'] = (int) get_option( DuplicateAction::OPTION, 0 );
|
32 |
+
|
33 |
+
return $data;
|
34 |
+
}
|
35 |
+
}
|
src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicatorChecker.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class DuplicatorChecker
|
4 |
+
*
|
5 |
+
* @package WPDesk\FS\TableRate\ShippingMethod\Duplicate
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WPDesk\FS\TableRate\ShippingMethod\Duplicate;
|
9 |
+
|
10 |
+
use WC_Shipping_Zone;
|
11 |
+
use WPDesk\FS\TableRate\ShippingMethod\Management\ShippingMethodManagement;
|
12 |
+
use WPDesk\FS\TableRate\ShippingMethodSingle;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Checker duplicating.
|
16 |
+
*/
|
17 |
+
class DuplicatorChecker {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var ShippingMethodManagement
|
21 |
+
*/
|
22 |
+
private $shipping_method_management;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param ShippingMethodManagement $shipping_method_management
|
26 |
+
*/
|
27 |
+
public function __construct( ShippingMethodManagement $shipping_method_management ) {
|
28 |
+
$this->shipping_method_management = $shipping_method_management;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @param int $instance_id
|
33 |
+
*
|
34 |
+
* @return bool
|
35 |
+
*/
|
36 |
+
public function should_duplicate( int $instance_id ): bool {
|
37 |
+
if ( ! $instance_id ) {
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
|
41 |
+
$shipping_method = $this->shipping_method_management->get_shipping_method( $instance_id );
|
42 |
+
$zone = $this->shipping_method_management->get_shipping_zone( $instance_id );
|
43 |
+
|
44 |
+
return $shipping_method instanceof ShippingMethodSingle && $zone instanceof WC_Shipping_Zone;
|
45 |
+
}
|
46 |
+
}
|
src/WPDesk/FS/TableRate/ShippingMethod/Management/ShippingMethodManagement.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class ShippingMethodManagement
|
4 |
+
*
|
5 |
+
* @package WPDesk\FS\TableRate\ShippingMethod\Management
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WPDesk\FS\TableRate\ShippingMethod\Management;
|
9 |
+
|
10 |
+
use WC_Shipping_Zone;
|
11 |
+
use WC_Shipping_Zones;
|
12 |
+
use wpdb;
|
13 |
+
use WPDesk\FS\TableRate\ShippingMethodSingle;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @codeCoverageIgnore
|
17 |
+
*/
|
18 |
+
class ShippingMethodManagement {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var wpdb
|
22 |
+
*/
|
23 |
+
private $wpdb;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param wpdb $wpdb
|
27 |
+
*/
|
28 |
+
public function __construct( wpdb $wpdb ) {
|
29 |
+
$this->wpdb = $wpdb;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param int $instance_id .
|
34 |
+
* @param bool $status .
|
35 |
+
* @param WC_Shipping_Zone $zone .
|
36 |
+
*/
|
37 |
+
public function set_shipping_method_status( int $instance_id, bool $status, WC_Shipping_Zone $zone ) {
|
38 |
+
$status = $status ? 1 : 0;
|
39 |
+
|
40 |
+
if ( $this->update_shipping_method_field( $instance_id, 'is_enabled', $status ) ) {
|
41 |
+
$shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
|
42 |
+
|
43 |
+
do_action( 'woocommerce_shipping_zone_method_status_toggled', $shipping_method->instance_id, $shipping_method->id, $zone->get_id(), $status );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @param int $zone_id .
|
49 |
+
* @param int $method_order .
|
50 |
+
* @param int $number_of_shipping_methods .
|
51 |
+
*/
|
52 |
+
public function update_shipping_methods_order( int $zone_id, int $method_order, int $number_of_shipping_methods ) {
|
53 |
+
$this->wpdb->query( $this->wpdb->prepare( sprintf( 'UPDATE `%s` SET `method_order` = `method_order`+%%d WHERE `zone_id` = %%d AND `method_order` > %%d', $this->get_table() ), $number_of_shipping_methods, $zone_id, $method_order ) ); // phpcs:ignore
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @param int $instance_id .
|
58 |
+
*
|
59 |
+
* @return int
|
60 |
+
*/
|
61 |
+
public function get_shipping_method_order( int $instance_id ): int {
|
62 |
+
return (int) $this->wpdb->get_var( $this->wpdb->prepare( sprintf( 'SELECT `method_order` FROM `%s` WHERE `instance_id` = %%d ORDER BY `method_order` ASC', $this->get_table() ), $instance_id ) ); // phpcs:ignore
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @param int $instance_id .
|
67 |
+
*
|
68 |
+
* @return bool|ShippingMethodSingle
|
69 |
+
*/
|
70 |
+
public function get_shipping_method( int $instance_id ) {
|
71 |
+
return WC_Shipping_Zones::get_shipping_method( $instance_id );
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @param int $instance_id .
|
76 |
+
*
|
77 |
+
* @return bool|WC_Shipping_Zone
|
78 |
+
*/
|
79 |
+
public function get_shipping_zone( int $instance_id ) {
|
80 |
+
return WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id );
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param int $instance_id .
|
85 |
+
* @param string $key .
|
86 |
+
* @param string $value .
|
87 |
+
*
|
88 |
+
* @return bool|int
|
89 |
+
*/
|
90 |
+
public function update_shipping_method_field( int $instance_id, string $key, string $value ) {
|
91 |
+
return $this->wpdb->update( $this->get_table(), [ $key => $value ], [ 'instance_id' => $instance_id ] );
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
private function get_table(): string {
|
98 |
+
return $this->wpdb->prefix . 'woocommerce_shipping_zone_methods';
|
99 |
+
}
|
100 |
+
}
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit5ebba595540d7b02f0f8003854939e3c::getLoader();
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -548,7 +548,13 @@ return array(
|
|
548 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertAction' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertAction.php',
|
549 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertNotice' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertNotice.php',
|
550 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertTracker' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertTracker.php',
|
|
|
|
|
|
|
|
|
|
|
551 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\FreeShippingCalculator' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/FreeShippingCalculator.php',
|
|
|
552 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodDescription' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodDescription.php',
|
553 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodSettings' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodSettings.php',
|
554 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodTitle' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodTitle.php',
|
548 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertAction' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertAction.php',
|
549 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertNotice' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertNotice.php',
|
550 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertTracker' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertTracker.php',
|
551 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicateAction' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateAction.php',
|
552 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicateNotice' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateNotice.php',
|
553 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicateScript' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateScript.php',
|
554 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicateTracker' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateTracker.php',
|
555 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicatorChecker' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicatorChecker.php',
|
556 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\FreeShippingCalculator' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/FreeShippingCalculator.php',
|
557 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Management\\ShippingMethodManagement' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/Management/ShippingMethodManagement.php',
|
558 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodDescription' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodDescription.php',
|
559 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodSettings' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodSettings.php',
|
560 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodTitle' => $baseDir . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodTitle.php',
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -22,15 +22,15 @@ class ComposerAutoloaderInitf929054d750d9e7963097b1927623354
|
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
-
spl_autoload_register(array('
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
-
spl_autoload_unregister(array('
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
-
call_user_func(\Composer\Autoload\
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit5ebba595540d7b02f0f8003854939e3c
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInit5ebba595540d7b02f0f8003854939e3c', 'loadClassLoader'), true, true);
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit5ebba595540d7b02f0f8003854939e3c', 'loadClassLoader'));
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit5ebba595540d7b02f0f8003854939e3c::getInitializer($loader));
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'P' =>
|
@@ -567,7 +567,13 @@ class ComposerStaticInitf929054d750d9e7963097b1927623354
|
|
567 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertAction' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertAction.php',
|
568 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertNotice' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertNotice.php',
|
569 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertTracker' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertTracker.php',
|
|
|
|
|
|
|
|
|
|
|
570 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\FreeShippingCalculator' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/FreeShippingCalculator.php',
|
|
|
571 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodDescription' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodDescription.php',
|
572 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodSettings' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodSettings.php',
|
573 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodTitle' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodTitle.php',
|
@@ -607,10 +613,10 @@ class ComposerStaticInitf929054d750d9e7963097b1927623354
|
|
607 |
public static function getInitializer(ClassLoader $loader)
|
608 |
{
|
609 |
return \Closure::bind(function () use ($loader) {
|
610 |
-
$loader->prefixLengthsPsr4 =
|
611 |
-
$loader->prefixDirsPsr4 =
|
612 |
-
$loader->fallbackDirsPsr4 =
|
613 |
-
$loader->classMap =
|
614 |
|
615 |
}, null, ClassLoader::class);
|
616 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit5ebba595540d7b02f0f8003854939e3c
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'P' =>
|
567 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertAction' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertAction.php',
|
568 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertNotice' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertNotice.php',
|
569 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\Convert\\ConvertTracker' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Convert/ConvertTracker.php',
|
570 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicateAction' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateAction.php',
|
571 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicateNotice' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateNotice.php',
|
572 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicateScript' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateScript.php',
|
573 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicateTracker' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicateTracker.php',
|
574 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Duplicate\\DuplicatorChecker' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Duplicate/DuplicatorChecker.php',
|
575 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\FreeShippingCalculator' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/FreeShippingCalculator.php',
|
576 |
+
'WPDesk\\FS\\TableRate\\ShippingMethod\\Management\\ShippingMethodManagement' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/Management/ShippingMethodManagement.php',
|
577 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodDescription' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodDescription.php',
|
578 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodSettings' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodSettings.php',
|
579 |
'WPDesk\\FS\\TableRate\\ShippingMethod\\MethodTitle' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ShippingMethod/MethodTitle.php',
|
613 |
public static function getInitializer(ClassLoader $loader)
|
614 |
{
|
615 |
return \Closure::bind(function () use ($loader) {
|
616 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit5ebba595540d7b02f0f8003854939e3c::$prefixLengthsPsr4;
|
617 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit5ebba595540d7b02f0f8003854939e3c::$prefixDirsPsr4;
|
618 |
+
$loader->fallbackDirsPsr4 = ComposerStaticInit5ebba595540d7b02f0f8003854939e3c::$fallbackDirsPsr4;
|
619 |
+
$loader->classMap = ComposerStaticInit5ebba595540d7b02f0f8003854939e3c::$classMap;
|
620 |
|
621 |
}, null, ClassLoader::class);
|
622 |
}
|
vendor_prefixed/wpdesk/wp-wpdesk-license/src/ApiManager/class-wc-plugin-update.php
CHANGED
@@ -154,8 +154,11 @@ if (!\class_exists('FSVendor\\WPDesk_Update_API_Check')) {
|
|
154 |
*/
|
155 |
public function update_check($transient)
|
156 |
{
|
157 |
-
if (
|
158 |
-
|
|
|
|
|
|
|
159 |
}
|
160 |
$args = ['request' => 'pluginupdatecheck', 'slug' => $this->slug, 'plugin_name' => $this->plugin_name, 'version' => $this->software_version, 'product_id' => $this->product_id, 'api_key' => $this->api_key, 'activation_email' => $this->activation_email, 'instance' => $this->instance, 'domain' => $this->domain, 'software_version' => $this->software_version, 'extra' => $this->extra];
|
161 |
// Check for a plugin update
|
154 |
*/
|
155 |
public function update_check($transient)
|
156 |
{
|
157 |
+
if (!\is_object($transient)) {
|
158 |
+
$transient = new \stdClass();
|
159 |
+
}
|
160 |
+
if (!isset($transient->response) || !\is_array($transient->response)) {
|
161 |
+
$transient->response = [];
|
162 |
}
|
163 |
$args = ['request' => 'pluginupdatecheck', 'slug' => $this->slug, 'plugin_name' => $this->plugin_name, 'version' => $this->software_version, 'product_id' => $this->product_id, 'api_key' => $this->api_key, 'activation_email' => $this->activation_email, 'instance' => $this->instance, 'domain' => $this->domain, 'software_version' => $this->software_version, 'extra' => $this->extra];
|
164 |
// Check for a plugin update
|