-
Notifications
You must be signed in to change notification settings - Fork 1
/
polylang-wc-stubs.php
6922 lines (6921 loc) · 166 KB
/
polylang-wc-stubs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* @package Polylang-WC
*/
/**
* Manages the coupons.
*
* @since 0.9
*/
class PLLWC_Coupons
{
/**
* Product language data store.
*
* @var PLLWC_Product_Language_CPT
*/
protected $data_store;
/**
* Constructor.
*
* @since 0.9
*/
public function __construct()
{
}
/**
* Translates products and categories restrictions in coupons.
* Hooked to the filter 'woocommerce_coupon_loaded'.
*
* @since 0.3.6
*
* @param WC_Coupon $data Coupon properties.
* @return void
*/
public function coupon_loaded($data)
{
}
/**
* Returns the translated product id or the current product id if it is not translated.
*
* @since 1.0
*
* @param int $id Product id.
* @return int Translated product id.
*/
protected function maybe_get_translated_product($id)
{
}
/**
* Returns the translated term id or the current term id if it is not translated.
*
* @since 1.0
*
* @param int $id Term id.
* @return int Translated term id.
*/
protected function maybe_get_translated_term($id)
{
}
}
/**
* @package Polylang-WC
*/
/**
* Manages the coupons in the backend.
*
* @since 0.3.6
*/
class PLLWC_Admin_Coupons extends \PLLWC_Coupons
{
/**
* Constructor.
*
* @since 0.3.6
*/
public function __construct()
{
}
/**
* Filters the product category per language.
*
* @since 0.3.6
*
* @param array $args Arguments passed to WP_Term_Query.
* @param string[] $taxonomies Taxonomies passed to WP_Term_Query.
* @return array Modified arguments.
*/
public function get_terms_args($args, $taxonomies)
{
}
}
/**
* @package Polylang-WC
*/
/**
* A class to translate the endpoints in the WooCommerce Endpoints nav menu metabox.
*
* @since 0.1
*/
class PLLWC_Admin_Menus
{
/**
* Constructor.
*
* @since 0.1
*/
public function __construct()
{
}
/**
* Replaces the WooCommerce endpoints metabox by our own.
* Hooked to the action 'admin_menu'.
*
* @since 0.1
*
* @return void
*/
public function init()
{
}
/**
* Adds our endpoints metabox.
*
* @since 0.7.5
*
* @return void
*/
public function add_meta_box()
{
}
/**
* Displays the WooCommerce endpoints metabox.
*
* @since 0.1
*
* @return void
*/
public function nav_menu_metabox()
{
}
/**
* Displays the endpoints menu items.
* The titles are translated in the admin interface language.
* The links are in the language of the admin language filter.
*
* @since 0.1
*
* @return void
*/
public function nav_menu_links()
{
}
/**
* Get endpoints available in the WooCommerce endpoints menu metabox.
*
* @since 0.9.3
*
* @return string[]
*/
protected function get_endpoints()
{
}
}
/**
* @package Polylang-WC
*/
/**
* Handles the language information displayed for orders.
*
* @since 0.1
* @since 1.9 Changed the class to abstract.
*/
abstract class PLLWC_Admin_Orders
{
/**
* Order language data store.
*
* @var PLLWC_Order_Language_CPT
*/
protected $data_store;
/**
* Constructor.
*
* @since 0.1
*/
public function __construct()
{
}
/**
* Adds the language columns to the orders list table.
*
* @since 0.1
*
* @return void
*/
public abstract function custom_columns();
/**
* Adds the language column in the orders list table.
*
* @since 0.1
*
* @param string[] $columns List of table columns.
* @return string[] modified list of columns.
*/
public function add_order_column($columns)
{
}
/**
* Fills the language column of each order.
*
* @since 0.1
* @since 1.9 The second param has been renamed to `$order` and accepts `WC_Order` and `int`.
*
* @param string $column Column name.
* @param WC_Order|int $order Order object when using HPOS, or order ID otherwise.
* @return void
*/
public function order_column($column, $order)
{
}
/**
* Add the languages metabox for orders.
* Add filters specific to the orders page.
*
* @since 0.1
*
* @param string $screen_id Screen id of the order edit page.
* @return void
*/
public function add_meta_boxes($screen_id)
{
}
/**
* Displays the Languages metabox.
*
* @since 0.1
*
* @param object $order Order object.
* @return void
*/
public abstract function order_language($order);
/**
* Displays the Languages metabox.
*
* @since 1.9
*
* @param int $order_id Order id.
* @return void
*/
protected function display_language_metabox($order_id)
{
}
/**
* Add our pll_ajax_backend parameter to the WooCommerce admin order actions urls.
*
* @since 1.0.4
*
* @param array $actions Admin order actions.
* @return array
*/
public function admin_order_actions($actions)
{
}
/**
* Checks if the current screen is allowed.
*
* @since 1.9
*
* @param string $screen_id Optional screen id, defaults to the current screen.
* @return bool
*/
protected function is_allowed_screen($screen_id = '')
{
}
/**
* Returns a list of allowed screens.
*
* @since 1.9
*
* @return string[]
*/
protected function get_allowed_screens()
{
}
}
/**
* @package Polylang-WC
*/
/**
* Handles the language information displayed for orders when using HPOS.
*
* @since 1.9
*/
class PLLWC_Admin_Orders_HPOS extends \PLLWC_Admin_Orders
{
/**
* Constructor.
*
* @since 1.9
*/
public function __construct()
{
}
/**
* Adds the language columns to the orders list table.
*
* @since 1.9
*
* @return void
*/
public function custom_columns()
{
}
/**
* Displays the Languages metabox in HPOS context.
*
* @since 1.9
*
* @param WC_Order $order Order object.
* @return void
*/
public function order_language($order)
{
}
/**
* Returns a list of allowed screens.
*
* @since 1.9
*
* @return string[]
*/
protected function get_allowed_screens()
{
}
/**
* Add pll_order_id parameter in the list of parameters of the admin ajax request.
*
* @since 1.9
*
* @param array $params List of parameters to add to the admin ajax request.
* @return array Modified list of parameters to add to the admin ajax request.
*/
public function set_pll_order_id($params)
{
}
/**
* Sets the current language in order screen when using HPOS.
*
* @since 1.9
*
* @param PLL_Language|bool $current_language The current language already set.
* @return PLL_Language|bool
*/
public function set_current_language($current_language)
{
}
/**
* Saves order language from admin when HPOS is enabled and order custom tables authoritative.
*
* @since 1.9
*
* @param WC_Order $order Order object being saved.
* @return void
*/
public function save_order_language($order)
{
}
/**
* Enqueues order edit page script.
*
* @since 1.9
*
* @return void
*/
public function enqueue_order_script()
{
}
}
/**
* @package Polylang-WC
*/
/**
* Handles the language information displayed for orders hen using legacy orders
*
* @since 1.9
*/
class PLLWC_Admin_Orders_Legacy extends \PLLWC_Admin_Orders
{
/**
* Removes the standard Polylang languages columns for the orders list table
* and replace them with one unique column.
*
* @since 0.1
*
* @return void
*/
public function custom_columns()
{
}
/**
* Displays the Languages metabox.
*
* @since 0.1
*
* @param WP_Post $order Order object.
* @return void
*/
public function order_language($order)
{
}
}
/**
* @package Polylang-WC
*/
/**
* Duplicates the product translations when duplicating a product.
*
* @since 1.0
*/
class PLLWC_Admin_Product_Duplicate
{
/**
* Product language data store.
*
* @var PLLWC_Product_Language_CPT
*/
protected $data_store;
/**
* Constructor.
*
* @since 1.0
*/
public function __construct()
{
}
/**
* Removes the taxonomy terms language check when duplicating products.
* This is necessary because duplicate products are assigned the default language at creation.
* Hooked to the acton 'admin_action_duplicate_product'.
*
* @since 0.9.3
*
* @return void
*/
public function duplicate_product_action()
{
}
/**
* Fires the duplication of duplicated product translations.
*
* We are obliged to copy the whole logic of WC_Admin_Duplicate_Product::product_duplicate()
* otherwise we can't avoid that WC creates a new sku before the language is assigned.
* Code last checked: WC 4.0
*
* @see https://github.com/woocommerce/woocommerce/issues/13262
* @since 0.7
*
* @param WC_Product $duplicate Duplicated product.
* @param WC_Product $product Original product.
* @return void
*/
public function product_duplicate($duplicate, $product)
{
}
/**
* Generates a unique slug for a given product. We do this so that we can override the
* behavior of wp_unique_post_slug(). The normal slug generation will run single
* select queries on every non-unique slug, resulting in very bad performance.
* This is an exact copy of WC_Admin_Duplicate_Product::generate_unique_slug()
* Code last checked: WC 4.0
*
* @since 1.5
*
* @param WC_Product $product The product to generate a slug for.
* @return void
*/
private function generate_unique_slug($product)
{
}
}
/**
* @package Polylang-WC
*/
/**
* Manages the products on admin side.
*
* @since 0.1
*/
class PLLWC_Admin_Products
{
/**
* Product language data store.
*
* @var PLLWC_Product_Language_CPT
*/
protected $data_store;
/**
* Constructor.
* Setups actions and filters.
*
* @since 0.1
*/
public function __construct()
{
}
/**
* Setups the our js script (only on the products page).
*
* @since 0.1
*
* @return void
*/
public function admin_enqueue_scripts()
{
}
/**
* Ajax response for changing the language in the product language metabox.
*
* @since 0.1
*
* @return void
*/
public function product_lang_choice()
{
}
/**
* Synchronizes the product ordering.
* Hooked to the action 'woocommerce_after_product_ordering'.
*
* @since 1.0
*
* @param int $id Product id.
* @param int[] $menu_orders An array with product ids as key and menu_order as value.
* @return void
*/
public function product_ordering($id, $menu_orders)
{
}
/**
* Filters the products per language in autocomplete ajax searches.
* Hooked to the filters 'woocommerce_json_search_found_products'
* and 'woocommerce_json_search_found_grouped_products'.
*
* @since 0.1
*
* @param string[] $products array with product ids as keys and names as values.
* @return string[]
*/
public function search_found_products($products)
{
}
/**
* Fixes the search in the Products list table.
* It is necessary since WC 3.3.1 as the query uses 'post__in'
* which is usually excluded from the language filter.
* Hooked to the filter 'pll_filter_query_excluded_query_vars'.
*
* @since 1.0
*
* @param string[] $excludes Query vars excluded from the language filter.
* @param WP_Query $query WP Query object.
* @return string[]
*/
public function fix_products_search($excludes, $query)
{
}
/**
* Removes the German and Danish specific sanitization for titles.
*
* @since 0.7.1
*
* @return void
*/
public function remove_sanitize_title()
{
}
/**
* Restores the German and Danish specific sanitization for titles.
*
* @since 0.7.1
*
* @return void
*/
public function add_sanitize_title()
{
}
}
/**
* @package Polylang-WC
*/
/**
* Filters the reports as some need to combine all languages
* and other need to be filtered per language.
*
* @since 0.1
*/
class PLLWC_Admin_Reports
{
/**
* Product language data store.
*
* @var PLLWC_Product_Language_CPT
*/
protected $data_store;
/**
* Constructor.
* Setup filters.
*
* @since 0.1
*/
public function __construct()
{
}
/**
* Filters report queries to combine all languages.
* Hooked to the filter 'woocommerce_reports_get_order_report_query'.
*
* @since 0.1
*
* @param string[] $query Array of SQL clauses.
* @return string[]
*/
public function report_query($query)
{
}
/**
* Makes sure that the products returned by WC_Admin_Report::get_order_report_data() are in the expected language.
* It's necessary as the filtered report_query() does not give any warranty on the product language.
*
* @since 0.1
*
* @param array $results Array of products returned by WC_Admin_Report::get_order_report_data().
* @return array
*/
public function report_data($results)
{
}
/**
* Combines all translations of a product for a given category.
* Hooked to the filter 'woocommerce_report_sales_by_category_get_products_in_category'.
*
* @since 0.1
*
* @param int[] $product_ids Not used.
* @param int $category_id Product category id.
* @return int[]
*/
public function get_products_in_category($product_ids, $category_id)
{
}
/**
* Filters the list of categories per language in Sales by category.
* Hooked to the filter 'terms_clauses'.
*
* @since 0.1
*
* @param string[] $clauses SQL clauses.
* @param string[] $taxonomies Not used.
* @param array $args WP_Term_Query arguments.
* @return string[] Modified SQL clauses
*/
public function terms_clauses($clauses, $taxonomies, $args)
{
}
/**
* Filters the stock queries per language.
*
* @since 0.1
*
* @param string $query_from Part of the SQL query (FROM, JOIN, WHERE clauses).
* @return string
*/
public function stock_query($query_from)
{
}
}
/**
* @package Polylang-WC
*/
/**
* Class PLLWC_Admin_Site_Health
*
* @since 1.5
*/
class PLLWC_Admin_Site_Health
{
/**
* PLLWC_Admin_Site_Health constructor.
*
* @since 1.5
*/
public function __construct()
{
}
/**
* Add Polylang for WooCommerce informations to the Site Health Informations tab.
*
* @since 1.5
*
* @param array $debug_info The debug information to be added to the core information page.
* @return array
*/
public function info($debug_info)
{
}
}
/**
* @package Polylang-WC
*/
/**
* Manages the status reports for the WooCommerce pages
* to verify if they exist for alls languages.
*
* @since 1.3
*/
class PLLWC_Admin_Status_Reports
{
/**
* Reference to PLL_Model object.
*
* @var PLL_Model
*/
protected $model;
/**
* List of controls on default WooCommerce pages.
*
* @var stdClass|null
*/
protected $woocommerce_pages_status = \null;
/**
* Retrieves the status of the WooCommerce pages.
* Partially copied from {@see WC_REST_System_Status_V2_Controller::get_pages()}.
*
* @since 1.3
*
* @return stdClass
*/
public function get_woocommerce_pages_status()
{
}
/**
* Loads the status report for the translations of the default pages in the WooCommerce status page.
*
* @since 1.3
*
* @return void
*/
public function status_report()
{
}
/**
* Loads the status report for the translations of the default pages in our wizard.
*
* @since 1.3
*
* @return void
*/
public function wizard_status_report()
{
}
}
/**
* @package Polylang-WC
*/
/**
* Handles the Woocommerce taxonomies on admin side.
*
* @since 0.1
*/
class PLLWC_Admin_Taxonomies
{
/**
* Constructor.
*
* @since 0.1
*/
public function __construct()
{
}
/**
* Setups actions and filters.
*
* @since 0.1
*
* @return void
*/
public function init()
{
}
/**
* Adds term metas to copy or synchronize.
*
* @since 1.0
*
* @param string[] $to_copy List of term metas names.
* @param bool $sync True if it is synchronization, false if it is a copy.
* @param int $from Id of the term from which we copy informations.
* @param int $to Id of the term to which we paste informations.
* @param string $lang Language slug.
* @return string[]
*/
public function get_metas_to_copy($to_copy, $sync, $from, $to, $lang)
{
}
/**
* Suppresses the language filter in _get_term_hierarchy() specifically for product_cat
* because WC modifies the orderby arg to meta_value_num in wc_change_pre_get_terms().
*
* @see PLL_CRUD_Terms::get_terms_args()
*
* @since 1.2.1
*
* @param array $args WP_Term_Query arguments.
* @return array Modified arguments
*/
public function get_terms_args($args)
{
}
/**
* Translates the thumbnail id.
*
* @since 1.0
*
* @param mixed $value Meta value.
* @param string $key Meta key.
* @param string $lang Language of target.
* @return mixed
*/
public function translate_meta($value, $key, $lang)
{
}
/**
* Maybe fix the language of the product cat image.
* It is required because if the image was just uploaded,
* it is assigned the preferred language instead of the current language.
*
* @since 0.1
*
* @param int $term_id Term id.
* @return void
*/
public function fix_term_thumbnail($term_id)
{
}
/**
* Saves the language of an attribute term when created from the product metabox.
*
* @since 1.0
*
* @param int $term_id Term id.
* @param int $tt_id Term taxonomy id.
* @param string $taxonomy Taxonomy name.
* @return void
*/
public function create_attribute_term($term_id, $tt_id, $taxonomy)
{
}
/**
* Rewrites WC_Admin_Taxonomies::add_category_fields to populate the metas when creating a new translation.
*
* @since 0.1
*
* @return void
*/
public function add_category_fields()
{
}
/**
* Filters the media list when adding an image to a product category.
*
* @since 1.6
*
* @return void
*/
public function admin_enqueue_scripts()
{
}
/**
* Enqueues filter script.
*
* @since 1.7.2
*
* @return void
*/
public function load_scripts()
{
}
}
/**
* @package Polylang-WC
*/
/**
* Allows to automatically install the translations of the WooCommerce default pages.
* Manages the installation of the default product category.
*
* @since 0.1
*/
class PLLWC_Admin_WC_Install
{
/**
* List of WooCommerce pages in all languages.
*
* @var array<string, array<string, array<string, string>>>
*/
private $pages = array();
/**
* Locale used to translate WooCommerce pages title.
*
* @var string
*/
private $locale;
/**
* Constructor.
*
* @since 0.1
*/
public function __construct()
{
}
/**
* Translates the default WooCommerce pages in all existing languages.
*
* @since 1.7
*
* @return void
*/
public function translate_default_wc_pages()
{
}
/**
* Add post states for the translations of the shop, cart, checkout, account and terms pages.
*
* @since 0.9
*
* @param string[] $post_states List of post display states.
* @param WP_Post $post The post object.
* @return string[]
*/
public function display_post_states($post_states, $post)
{
}
/**
* Replaces the Install WooCommerce Pages tool by our own to be able to create translations.
*
* @since 0.1
*
* @param array $tools List of available tools.
* @return array
*/
public function debug_tools($tools)
{
}
/**
* Filters the locale when creating WooCommerce translated pages.
*
* @since 0.1
*
* @param string $locale The plugin's current locale.
* @param string $domain Text domain.
* @return string
*/
public function plugin_locale($locale, $domain)
{
}
/**
* Initializes the page names and content in all available languages.
* The method does not actually create the pages.
*
* It implements its own locale switch rather than using switch_to_locale()
* for performance reasons as we only need our own translations.
*
* @since 0.1
*
* @return void
*/
public function init_translated_pages()
{
}
/**
* Install pages from the WooCommerce status tools when using the "Install pages" button.
*
* @since 0.1
*
* @return string
*/
public function install_pages()
{
}
/**
* Creates a page translation.
*
* @since 0.1
*
* @param string $page WooCommerce Page slug.
* @param string $lang Language slug.
* @return void
*/
public function translate_page($page, $lang)
{