first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,364 @@
<?php
/**
* EAN for WooCommerce - PDF Page Formats
*
* @version 3.0.0
* @since 2.0.0
*
* @author Algoritmika Ltd
*
* @see https://github.com/tecnickcom/TCPDF/blob/6.3.5/include/tcpdf_static.php#L2129
*/
defined( 'ABSPATH' ) || exit;
return array(
// ISO 216 A Series + 2 SIS 014711 extensions
'A0' => array( 2383.937, 3370.394 ), // = ( 841 x 1189 ) mm = ( 33.11 x 46.81 ) in
'A1' => array( 1683.780, 2383.937 ), // = ( 594 x 841 ) mm = ( 23.39 x 33.11 ) in
'A2' => array( 1190.551, 1683.780 ), // = ( 420 x 594 ) mm = ( 16.54 x 23.39 ) in
'A3' => array( 841.890, 1190.551 ), // = ( 297 x 420 ) mm = ( 11.69 x 16.54 ) in
'A4' => array( 595.276, 841.890 ), // = ( 210 x 297 ) mm = ( 8.27 x 11.69 ) in
'A5' => array( 419.528, 595.276 ), // = ( 148 x 210 ) mm = ( 5.83 x 8.27 ) in
'A6' => array( 297.638, 419.528 ), // = ( 105 x 148 ) mm = ( 4.13 x 5.83 ) in
'A7' => array( 209.764, 297.638 ), // = ( 74 x 105 ) mm = ( 2.91 x 4.13 ) in
'A8' => array( 147.402, 209.764 ), // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in
'A9' => array( 104.882, 147.402 ), // = ( 37 x 52 ) mm = ( 1.46 x 2.05 ) in
'A10' => array( 73.701, 104.882 ), // = ( 26 x 37 ) mm = ( 1.02 x 1.46 ) in
'A11' => array( 51.024, 73.701 ), // = ( 18 x 26 ) mm = ( 0.71 x 1.02 ) in
'A12' => array( 36.850, 51.024 ), // = ( 13 x 18 ) mm = ( 0.51 x 0.71 ) in
// ISO 216 B Series + 2 SIS 014711 extensions
'B0' => array( 2834.646, 4008.189 ), // = ( 1000 x 1414 ) mm = ( 39.37 x 55.67 ) in
'B1' => array( 2004.094, 2834.646 ), // = ( 707 x 1000 ) mm = ( 27.83 x 39.37 ) in
'B2' => array( 1417.323, 2004.094 ), // = ( 500 x 707 ) mm = ( 19.69 x 27.83 ) in
'B3' => array( 1000.630, 1417.323 ), // = ( 353 x 500 ) mm = ( 13.90 x 19.69 ) in
'B4' => array( 708.661, 1000.630 ), // = ( 250 x 353 ) mm = ( 9.84 x 13.90 ) in
'B5' => array( 498.898, 708.661 ), // = ( 176 x 250 ) mm = ( 6.93 x 9.84 ) in
'B6' => array( 354.331, 498.898 ), // = ( 125 x 176 ) mm = ( 4.92 x 6.93 ) in
'B7' => array( 249.449, 354.331 ), // = ( 88 x 125 ) mm = ( 3.46 x 4.92 ) in
'B8' => array( 175.748, 249.449 ), // = ( 62 x 88 ) mm = ( 2.44 x 3.46 ) in
'B9' => array( 124.724, 175.748 ), // = ( 44 x 62 ) mm = ( 1.73 x 2.44 ) in
'B10' => array( 87.874, 124.724 ), // = ( 31 x 44 ) mm = ( 1.22 x 1.73 ) in
'B11' => array( 62.362, 87.874 ), // = ( 22 x 31 ) mm = ( 0.87 x 1.22 ) in
'B12' => array( 42.520, 62.362 ), // = ( 15 x 22 ) mm = ( 0.59 x 0.87 ) in
// ISO 216 C Series + 2 SIS 014711 extensions + 5 EXTENSION
'C0' => array( 2599.370, 3676.535 ), // = ( 917 x 1297 ) mm = ( 36.10 x 51.06 ) in
'C1' => array( 1836.850, 2599.370 ), // = ( 648 x 917 ) mm = ( 25.51 x 36.10 ) in
'C2' => array( 1298.268, 1836.850 ), // = ( 458 x 648 ) mm = ( 18.03 x 25.51 ) in
'C3' => array( 918.425, 1298.268 ), // = ( 324 x 458 ) mm = ( 12.76 x 18.03 ) in
'C4' => array( 649.134, 918.425 ), // = ( 229 x 324 ) mm = ( 9.02 x 12.76 ) in
'C5' => array( 459.213, 649.134 ), // = ( 162 x 229 ) mm = ( 6.38 x 9.02 ) in
'C6' => array( 323.150, 459.213 ), // = ( 114 x 162 ) mm = ( 4.49 x 6.38 ) in
'C7' => array( 229.606, 323.150 ), // = ( 81 x 114 ) mm = ( 3.19 x 4.49 ) in
'C8' => array( 161.575, 229.606 ), // = ( 57 x 81 ) mm = ( 2.24 x 3.19 ) in
'C9' => array( 113.386, 161.575 ), // = ( 40 x 57 ) mm = ( 1.57 x 2.24 ) in
'C10' => array( 79.370, 113.386 ), // = ( 28 x 40 ) mm = ( 1.10 x 1.57 ) in
'C11' => array( 56.693, 79.370 ), // = ( 20 x 28 ) mm = ( 0.79 x 1.10 ) in
'C12' => array( 39.685, 56.693 ), // = ( 14 x 20 ) mm = ( 0.55 x 0.79 ) in
'C76' => array( 229.606, 459.213 ), // = ( 81 x 162 ) mm = ( 3.19 x 6.38 ) in
'DL' => array( 311.811, 623.622 ), // = ( 110 x 220 ) mm = ( 4.33 x 8.66 ) in
'DLE' => array( 323.150, 637.795 ), // = ( 114 x 225 ) mm = ( 4.49 x 8.86 ) in
'DLX' => array( 340.158, 666.142 ), // = ( 120 x 235 ) mm = ( 4.72 x 9.25 ) in
'DLP' => array( 280.630, 595.276 ), // = ( 99 x 210 ) mm = ( 3.90 x 8.27 ) in (1/3 A4)
// SIS 014711 E Series
'E0' => array( 2491.654, 3517.795 ), // = ( 879 x 1241 ) mm = ( 34.61 x 48.86 ) in
'E1' => array( 1757.480, 2491.654 ), // = ( 620 x 879 ) mm = ( 24.41 x 34.61 ) in
'E2' => array( 1247.244, 1757.480 ), // = ( 440 x 620 ) mm = ( 17.32 x 24.41 ) in
'E3' => array( 878.740, 1247.244 ), // = ( 310 x 440 ) mm = ( 12.20 x 17.32 ) in
'E4' => array( 623.622, 878.740 ), // = ( 220 x 310 ) mm = ( 8.66 x 12.20 ) in
'E5' => array( 439.370, 623.622 ), // = ( 155 x 220 ) mm = ( 6.10 x 8.66 ) in
'E6' => array( 311.811, 439.370 ), // = ( 110 x 155 ) mm = ( 4.33 x 6.10 ) in
'E7' => array( 221.102, 311.811 ), // = ( 78 x 110 ) mm = ( 3.07 x 4.33 ) in
'E8' => array( 155.906, 221.102 ), // = ( 55 x 78 ) mm = ( 2.17 x 3.07 ) in
'E9' => array( 110.551, 155.906 ), // = ( 39 x 55 ) mm = ( 1.54 x 2.17 ) in
'E10' => array( 76.535, 110.551 ), // = ( 27 x 39 ) mm = ( 1.06 x 1.54 ) in
'E11' => array( 53.858, 76.535 ), // = ( 19 x 27 ) mm = ( 0.75 x 1.06 ) in
'E12' => array( 36.850, 53.858 ), // = ( 13 x 19 ) mm = ( 0.51 x 0.75 ) in
// SIS 014711 G Series
'G0' => array( 2715.591, 3838.110 ), // = ( 958 x 1354 ) mm = ( 37.72 x 53.31 ) in
'G1' => array( 1919.055, 2715.591 ), // = ( 677 x 958 ) mm = ( 26.65 x 37.72 ) in
'G2' => array( 1357.795, 1919.055 ), // = ( 479 x 677 ) mm = ( 18.86 x 26.65 ) in
'G3' => array( 958.110, 1357.795 ), // = ( 338 x 479 ) mm = ( 13.31 x 18.86 ) in
'G4' => array( 677.480, 958.110 ), // = ( 239 x 338 ) mm = ( 9.41 x 13.31 ) in
'G5' => array( 479.055, 677.480 ), // = ( 169 x 239 ) mm = ( 6.65 x 9.41 ) in
'G6' => array( 337.323, 479.055 ), // = ( 119 x 169 ) mm = ( 4.69 x 6.65 ) in
'G7' => array( 238.110, 337.323 ), // = ( 84 x 119 ) mm = ( 3.31 x 4.69 ) in
'G8' => array( 167.244, 238.110 ), // = ( 59 x 84 ) mm = ( 2.32 x 3.31 ) in
'G9' => array( 119.055, 167.244 ), // = ( 42 x 59 ) mm = ( 1.65 x 2.32 ) in
'G10' => array( 82.205, 119.055 ), // = ( 29 x 42 ) mm = ( 1.14 x 1.65 ) in
'G11' => array( 59.528, 82.205 ), // = ( 21 x 29 ) mm = ( 0.83 x 1.14 ) in
'G12' => array( 39.685, 59.528 ), // = ( 14 x 21 ) mm = ( 0.55 x 0.83 ) in
// ISO Press
'RA0' => array( 2437.795, 3458.268 ), // = ( 860 x 1220 ) mm = ( 33.86 x 48.03 ) in
'RA1' => array( 1729.134, 2437.795 ), // = ( 610 x 860 ) mm = ( 24.02 x 33.86 ) in
'RA2' => array( 1218.898, 1729.134 ), // = ( 430 x 610 ) mm = ( 16.93 x 24.02 ) in
'RA3' => array( 864.567, 1218.898 ), // = ( 305 x 430 ) mm = ( 12.01 x 16.93 ) in
'RA4' => array( 609.449, 864.567 ), // = ( 215 x 305 ) mm = ( 8.46 x 12.01 ) in
'SRA0' => array( 2551.181, 3628.346 ), // = ( 900 x 1280 ) mm = ( 35.43 x 50.39 ) in
'SRA1' => array( 1814.173, 2551.181 ), // = ( 640 x 900 ) mm = ( 25.20 x 35.43 ) in
'SRA2' => array( 1275.591, 1814.173 ), // = ( 450 x 640 ) mm = ( 17.72 x 25.20 ) in
'SRA3' => array( 907.087, 1275.591 ), // = ( 320 x 450 ) mm = ( 12.60 x 17.72 ) in
'SRA4' => array( 637.795, 907.087 ), // = ( 225 x 320 ) mm = ( 8.86 x 12.60 ) in
// German DIN 476
'4A0' => array( 4767.874, 6740.787 ), // = ( 1682 x 2378 ) mm = ( 66.22 x 93.62 ) in
'2A0' => array( 3370.394, 4767.874 ), // = ( 1189 x 1682 ) mm = ( 46.81 x 66.22 ) in
// Variations on the ISO Standard
'A2_EXTRA' => array( 1261.417, 1754.646 ), // = ( 445 x 619 ) mm = ( 17.52 x 24.37 ) in
'A3+' => array( 932.598, 1369.134 ), // = ( 329 x 483 ) mm = ( 12.95 x 19.02 ) in
'A3_EXTRA' => array( 912.756, 1261.417 ), // = ( 322 x 445 ) mm = ( 12.68 x 17.52 ) in
'A3_SUPER' => array( 864.567, 1440.000 ), // = ( 305 x 508 ) mm = ( 12.01 x 20.00 ) in
'SUPER_A3' => array( 864.567, 1380.472 ), // = ( 305 x 487 ) mm = ( 12.01 x 19.17 ) in
'A4_EXTRA' => array( 666.142, 912.756 ), // = ( 235 x 322 ) mm = ( 9.25 x 12.68 ) in
'A4_SUPER' => array( 649.134, 912.756 ), // = ( 229 x 322 ) mm = ( 9.02 x 12.68 ) in
'SUPER_A4' => array( 643.465, 1009.134 ), // = ( 227 x 356 ) mm = ( 8.94 x 14.02 ) in
'A4_LONG' => array( 595.276, 986.457 ), // = ( 210 x 348 ) mm = ( 8.27 x 13.70 ) in
'F4' => array( 595.276, 935.433 ), // = ( 210 x 330 ) mm = ( 8.27 x 12.99 ) in
'SO_B5_EXTRA' => array( 572.598, 782.362 ), // = ( 202 x 276 ) mm = ( 7.95 x 10.87 ) in
'A5_EXTRA' => array( 490.394, 666.142 ), // = ( 173 x 235 ) mm = ( 6.81 x 9.25 ) in
// ANSI Series
'ANSI_E' => array( 2448.000, 3168.000 ), // = ( 864 x 1118 ) mm = ( 34.00 x 44.00 ) in
'ANSI_D' => array( 1584.000, 2448.000 ), // = ( 559 x 864 ) mm = ( 22.00 x 34.00 ) in
'ANSI_C' => array( 1224.000, 1584.000 ), // = ( 432 x 559 ) mm = ( 17.00 x 22.00 ) in
'ANSI_B' => array( 792.000, 1224.000 ), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'ANSI_A' => array( 612.000, 792.000 ), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
// Traditional 'Loose' North American Paper Sizes
'USLEDGER' => array( 1224.000, 792.000 ), // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in
'LEDGER' => array( 1224.000, 792.000 ), // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in
'ORGANIZERK' => array( 792.000, 1224.000 ), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'BIBLE' => array( 792.000, 1224.000 ), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'USTABLOID' => array( 792.000, 1224.000 ), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'TABLOID' => array( 792.000, 1224.000 ), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'ORGANIZERM' => array( 612.000, 792.000 ), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'USLETTER' => array( 612.000, 792.000 ), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'LETTER' => array( 612.000, 792.000 ), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'USLEGAL' => array( 612.000, 1008.000 ), // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in
'LEGAL' => array( 612.000, 1008.000 ), // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in
'GOVERNMENTLETTER' => array( 576.000, 756.000 ), // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in
'GLETTER' => array( 576.000, 756.000 ), // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in
'JUNIORLEGAL' => array( 576.000, 360.000 ), // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in
'JLEGAL' => array( 576.000, 360.000 ), // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in
// Other North American Paper Sizes
'QUADDEMY' => array( 2520.000, 3240.000 ), // = ( 889 x 1143 ) mm = ( 35.00 x 45.00 ) in
'SUPER_B' => array( 936.000, 1368.000 ), // = ( 330 x 483 ) mm = ( 13.00 x 19.00 ) in
'QUARTO' => array( 648.000, 792.000 ), // = ( 229 x 279 ) mm = ( 9.00 x 11.00 ) in
'GOVERNMENTLEGAL' => array( 612.000, 936.000 ), // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in
'FOLIO' => array( 612.000, 936.000 ), // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in
'MONARCH' => array( 522.000, 756.000 ), // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in
'EXECUTIVE' => array( 522.000, 756.000 ), // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in
'ORGANIZERL' => array( 396.000, 612.000 ), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'STATEMENT' => array( 396.000, 612.000 ), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'MEMO' => array( 396.000, 612.000 ), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'FOOLSCAP' => array( 595.440, 936.000 ), // = ( 210 x 330 ) mm = ( 8.27 x 13.00 ) in
'COMPACT' => array( 306.000, 486.000 ), // = ( 108 x 171 ) mm = ( 4.25 x 6.75 ) in
'ORGANIZERJ' => array( 198.000, 360.000 ), // = ( 70 x 127 ) mm = ( 2.75 x 5.00 ) in
// Canadian standard CAN 2-9.60M
'P1' => array( 1587.402, 2437.795 ), // = ( 560 x 860 ) mm = ( 22.05 x 33.86 ) in
'P2' => array( 1218.898, 1587.402 ), // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in
'P3' => array( 793.701, 1218.898 ), // = ( 280 x 430 ) mm = ( 11.02 x 16.93 ) in
'P4' => array( 609.449, 793.701 ), // = ( 215 x 280 ) mm = ( 8.46 x 11.02 ) in
'P5' => array( 396.850, 609.449 ), // = ( 140 x 215 ) mm = ( 5.51 x 8.46 ) in
'P6' => array( 303.307, 396.850 ), // = ( 107 x 140 ) mm = ( 4.21 x 5.51 ) in
// North American Architectural Sizes
'ARCH_E' => array( 2592.000, 3456.000 ), // = ( 914 x 1219 ) mm = ( 36.00 x 48.00 ) in
'ARCH_E1' => array( 2160.000, 3024.000 ), // = ( 762 x 1067 ) mm = ( 30.00 x 42.00 ) in
'ARCH_D' => array( 1728.000, 2592.000 ), // = ( 610 x 914 ) mm = ( 24.00 x 36.00 ) in
'BROADSHEET' => array( 1296.000, 1728.000 ), // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in
'ARCH_C' => array( 1296.000, 1728.000 ), // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in
'ARCH_B' => array( 864.000, 1296.000 ), // = ( 305 x 457 ) mm = ( 12.00 x 18.00 ) in
'ARCH_A' => array( 648.000, 864.000 ), // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in
// -- North American Envelope Sizes
// - Announcement Envelopes
'ANNENV_A2' => array( 314.640, 414.000 ), // = ( 111 x 146 ) mm = ( 4.37 x 5.75 ) in
'ANNENV_A6' => array( 342.000, 468.000 ), // = ( 121 x 165 ) mm = ( 4.75 x 6.50 ) in
'ANNENV_A7' => array( 378.000, 522.000 ), // = ( 133 x 184 ) mm = ( 5.25 x 7.25 ) in
'ANNENV_A8' => array( 396.000, 584.640 ), // = ( 140 x 206 ) mm = ( 5.50 x 8.12 ) in
'ANNENV_A10' => array( 450.000, 692.640 ), // = ( 159 x 244 ) mm = ( 6.25 x 9.62 ) in
'ANNENV_SLIM' => array( 278.640, 638.640 ), // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in
// - Commercial Envelopes
'COMMENV_N6_1/4' => array( 252.000, 432.000 ), // = ( 89 x 152 ) mm = ( 3.50 x 6.00 ) in
'COMMENV_N6_3/4' => array( 260.640, 468.000 ), // = ( 92 x 165 ) mm = ( 3.62 x 6.50 ) in
'COMMENV_N8' => array( 278.640, 540.000 ), // = ( 98 x 191 ) mm = ( 3.87 x 7.50 ) in
'COMMENV_N9' => array( 278.640, 638.640 ), // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in
'COMMENV_N10' => array( 296.640, 684.000 ), // = ( 105 x 241 ) mm = ( 4.12 x 9.50 ) in
'COMMENV_N11' => array( 324.000, 746.640 ), // = ( 114 x 263 ) mm = ( 4.50 x 10.37 ) in
'COMMENV_N12' => array( 342.000, 792.000 ), // = ( 121 x 279 ) mm = ( 4.75 x 11.00 ) in
'COMMENV_N14' => array( 360.000, 828.000 ), // = ( 127 x 292 ) mm = ( 5.00 x 11.50 ) in
// - Catalogue Envelopes
'CATENV_N1' => array( 432.000, 648.000 ), // = ( 152 x 229 ) mm = ( 6.00 x 9.00 ) in
'CATENV_N1_3/4' => array( 468.000, 684.000 ), // = ( 165 x 241 ) mm = ( 6.50 x 9.50 ) in
'CATENV_N2' => array( 468.000, 720.000 ), // = ( 165 x 254 ) mm = ( 6.50 x 10.00 ) in
'CATENV_N3' => array( 504.000, 720.000 ), // = ( 178 x 254 ) mm = ( 7.00 x 10.00 ) in
'CATENV_N6' => array( 540.000, 756.000 ), // = ( 191 x 267 ) mm = ( 7.50 x 10.50 ) in
'CATENV_N7' => array( 576.000, 792.000 ), // = ( 203 x 279 ) mm = ( 8.00 x 11.00 ) in
'CATENV_N8' => array( 594.000, 810.000 ), // = ( 210 x 286 ) mm = ( 8.25 x 11.25 ) in
'CATENV_N9_1/2' => array( 612.000, 756.000 ), // = ( 216 x 267 ) mm = ( 8.50 x 10.50 ) in
'CATENV_N9_3/4' => array( 630.000, 810.000 ), // = ( 222 x 286 ) mm = ( 8.75 x 11.25 ) in
'CATENV_N10_1/2' => array( 648.000, 864.000 ), // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in
'CATENV_N12_1/2' => array( 684.000, 900.000 ), // = ( 241 x 318 ) mm = ( 9.50 x 12.50 ) in
'CATENV_N13_1/2' => array( 720.000, 936.000 ), // = ( 254 x 330 ) mm = ( 10.00 x 13.00 ) in
'CATENV_N14_1/4' => array( 810.000, 882.000 ), // = ( 286 x 311 ) mm = ( 11.25 x 12.25 ) in
'CATENV_N14_1/2' => array( 828.000, 1044.000 ), // = ( 292 x 368 ) mm = ( 11.50 x 14.50 ) in
// Japanese (JIS P 0138-61) Standard B-Series
'JIS_B0' => array( 2919.685, 4127.244 ), // = ( 1030 x 1456 ) mm = ( 40.55 x 57.32 ) in
'JIS_B1' => array( 2063.622, 2919.685 ), // = ( 728 x 1030 ) mm = ( 28.66 x 40.55 ) in
'JIS_B2' => array( 1459.843, 2063.622 ), // = ( 515 x 728 ) mm = ( 20.28 x 28.66 ) in
'JIS_B3' => array( 1031.811, 1459.843 ), // = ( 364 x 515 ) mm = ( 14.33 x 20.28 ) in
'JIS_B4' => array( 728.504, 1031.811 ), // = ( 257 x 364 ) mm = ( 10.12 x 14.33 ) in
'JIS_B5' => array( 515.906, 728.504 ), // = ( 182 x 257 ) mm = ( 7.17 x 10.12 ) in
'JIS_B6' => array( 362.835, 515.906 ), // = ( 128 x 182 ) mm = ( 5.04 x 7.17 ) in
'JIS_B7' => array( 257.953, 362.835 ), // = ( 91 x 128 ) mm = ( 3.58 x 5.04 ) in
'JIS_B8' => array( 181.417, 257.953 ), // = ( 64 x 91 ) mm = ( 2.52 x 3.58 ) in
'JIS_B9' => array( 127.559, 181.417 ), // = ( 45 x 64 ) mm = ( 1.77 x 2.52 ) in
'JIS_B10' => array( 90.709, 127.559 ), // = ( 32 x 45 ) mm = ( 1.26 x 1.77 ) in
'JIS_B11' => array( 62.362, 90.709 ), // = ( 22 x 32 ) mm = ( 0.87 x 1.26 ) in
'JIS_B12' => array( 45.354, 62.362 ), // = ( 16 x 22 ) mm = ( 0.63 x 0.87 ) in
// PA Series
'PA0' => array( 2381.102, 3174.803 ), // = ( 840 x 1120 ) mm = ( 33.07 x 44.09 ) in
'PA1' => array( 1587.402, 2381.102 ), // = ( 560 x 840 ) mm = ( 22.05 x 33.07 ) in
'PA2' => array( 1190.551, 1587.402 ), // = ( 420 x 560 ) mm = ( 16.54 x 22.05 ) in
'PA3' => array( 793.701, 1190.551 ), // = ( 280 x 420 ) mm = ( 11.02 x 16.54 ) in
'PA4' => array( 595.276, 793.701 ), // = ( 210 x 280 ) mm = ( 8.27 x 11.02 ) in
'PA5' => array( 396.850, 595.276 ), // = ( 140 x 210 ) mm = ( 5.51 x 8.27 ) in
'PA6' => array( 297.638, 396.850 ), // = ( 105 x 140 ) mm = ( 4.13 x 5.51 ) in
'PA7' => array( 198.425, 297.638 ), // = ( 70 x 105 ) mm = ( 2.76 x 4.13 ) in
'PA8' => array( 147.402, 198.425 ), // = ( 52 x 70 ) mm = ( 2.05 x 2.76 ) in
'PA9' => array( 99.213, 147.402 ), // = ( 35 x 52 ) mm = ( 1.38 x 2.05 ) in
'PA10' => array( 73.701, 99.213 ), // = ( 26 x 35 ) mm = ( 1.02 x 1.38 ) in
// Standard Photographic Print Sizes
'PASSPORT_PHOTO' => array( 99.213, 127.559 ), // = ( 35 x 45 ) mm = ( 1.38 x 1.77 ) in
'E' => array( 233.858, 340.157 ), // = ( 82 x 120 ) mm = ( 3.25 x 4.72 ) in
'L' => array( 252.283, 360.000 ), // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in
'3R' => array( 252.283, 360.000 ), // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in
'KG' => array( 289.134, 430.866 ), // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in
'4R' => array( 289.134, 430.866 ), // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in
'4D' => array( 340.157, 430.866 ), // = ( 120 x 152 ) mm = ( 4.72 x 5.98 ) in
'2L' => array( 360.000, 504.567 ), // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in
'5R' => array( 360.000, 504.567 ), // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in
'8P' => array( 430.866, 575.433 ), // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in
'6R' => array( 430.866, 575.433 ), // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in
'6P' => array( 575.433, 720.000 ), // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in
'8R' => array( 575.433, 720.000 ), // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in
'6PW' => array( 575.433, 864.567 ), // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in
'S8R' => array( 575.433, 864.567 ), // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in
'4P' => array( 720.000, 864.567 ), // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in
'10R' => array( 720.000, 864.567 ), // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in
'4PW' => array( 720.000, 1080.000 ), // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in
'S10R' => array( 720.000, 1080.000 ), // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in
'11R' => array( 790.866, 1009.134 ), // = ( 279 x 356 ) mm = ( 10.98 x 14.02 ) in
'S11R' => array( 790.866, 1224.567 ), // = ( 279 x 432 ) mm = ( 10.98 x 17.01 ) in
'12R' => array( 864.567, 1080.000 ), // = ( 305 x 381 ) mm = ( 12.01 x 15.00 ) in
'S12R' => array( 864.567, 1292.598 ), // = ( 305 x 456 ) mm = ( 12.01 x 17.95 ) in
// Common Newspaper Sizes
'NEWSPAPER_BROADSHEET' => array( 2125.984, 1700.787 ), // = ( 750 x 600 ) mm = ( 29.53 x 23.62 ) in
'NEWSPAPER_BERLINER' => array( 1332.283, 892.913 ), // = ( 470 x 315 ) mm = ( 18.50 x 12.40 ) in
'NEWSPAPER_TABLOID' => array( 1218.898, 793.701 ), // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in
'NEWSPAPER_COMPACT' => array( 1218.898, 793.701 ), // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in
// Business Cards
'CREDIT_CARD' => array( 153.014, 242.646 ), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD' => array( 153.014, 242.646 ), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD_ISO7810' => array( 153.014, 242.646 ), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD_ISO216' => array( 147.402, 209.764 ), // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in
'BUSINESS_CARD_IT' => array( 155.906, 240.945 ), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_UK' => array( 155.906, 240.945 ), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_FR' => array( 155.906, 240.945 ), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_DE' => array( 155.906, 240.945 ), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_ES' => array( 155.906, 240.945 ), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_CA' => array( 144.567, 252.283 ), // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in
'BUSINESS_CARD_US' => array( 144.567, 252.283 ), // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in
'BUSINESS_CARD_JP' => array( 155.906, 257.953 ), // = ( 55 x 91 ) mm = ( 2.17 x 3.58 ) in
'BUSINESS_CARD_HK' => array( 153.071, 255.118 ), // = ( 54 x 90 ) mm = ( 2.13 x 3.54 ) in
'BUSINESS_CARD_AU' => array( 155.906, 255.118 ), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_DK' => array( 155.906, 255.118 ), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_SE' => array( 155.906, 255.118 ), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_RU' => array( 141.732, 255.118 ), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_CZ' => array( 141.732, 255.118 ), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_FI' => array( 141.732, 255.118 ), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_HU' => array( 141.732, 255.118 ), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_IL' => array( 141.732, 255.118 ), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
// Billboards
'4SHEET' => array( 2880.000, 4320.000 ), // = ( 1016 x 1524 ) mm = ( 40.00 x 60.00 ) in
'6SHEET' => array( 3401.575, 5102.362 ), // = ( 1200 x 1800 ) mm = ( 47.24 x 70.87 ) in
'12SHEET' => array( 8640.000, 4320.000 ), // = ( 3048 x 1524 ) mm = (120.00 x 60.00 ) in
'16SHEET' => array( 5760.000, 8640.000 ), // = ( 2032 x 3048 ) mm = ( 80.00 x 120.00) in
'32SHEET' => array(11520.000, 8640.000 ), // = ( 4064 x 3048 ) mm = (160.00 x 120.00) in
'48SHEET' => array(17280.000, 8640.000 ), // = ( 6096 x 3048 ) mm = (240.00 x 120.00) in
'64SHEET' => array(23040.000, 8640.000 ), // = ( 8128 x 3048 ) mm = (320.00 x 120.00) in
'96SHEET' => array(34560.000, 8640.000 ), // = (12192 x 3048 ) mm = (480.00 x 120.00) in
// -- Old European Sizes
// - Old Imperial English Sizes
'EN_EMPEROR' => array( 3456.000, 5184.000 ), // = ( 1219 x 1829 ) mm = ( 48.00 x 72.00 ) in
'EN_ANTIQUARIAN' => array( 2232.000, 3816.000 ), // = ( 787 x 1346 ) mm = ( 31.00 x 53.00 ) in
'EN_GRAND_EAGLE' => array( 2070.000, 3024.000 ), // = ( 730 x 1067 ) mm = ( 28.75 x 42.00 ) in
'EN_DOUBLE_ELEPHANT' => array( 1926.000, 2880.000 ), // = ( 679 x 1016 ) mm = ( 26.75 x 40.00 ) in
'EN_ATLAS' => array( 1872.000, 2448.000 ), // = ( 660 x 864 ) mm = ( 26.00 x 34.00 ) in
'EN_COLOMBIER' => array( 1692.000, 2484.000 ), // = ( 597 x 876 ) mm = ( 23.50 x 34.50 ) in
'EN_ELEPHANT' => array( 1656.000, 2016.000 ), // = ( 584 x 711 ) mm = ( 23.00 x 28.00 ) in
'EN_DOUBLE_DEMY' => array( 1620.000, 2556.000 ), // = ( 572 x 902 ) mm = ( 22.50 x 35.50 ) in
'EN_IMPERIAL' => array( 1584.000, 2160.000 ), // = ( 559 x 762 ) mm = ( 22.00 x 30.00 ) in
'EN_PRINCESS' => array( 1548.000, 2016.000 ), // = ( 546 x 711 ) mm = ( 21.50 x 28.00 ) in
'EN_CARTRIDGE' => array( 1512.000, 1872.000 ), // = ( 533 x 660 ) mm = ( 21.00 x 26.00 ) in
'EN_DOUBLE_LARGE_POST' => array( 1512.000, 2376.000 ), // = ( 533 x 838 ) mm = ( 21.00 x 33.00 ) in
'EN_ROYAL' => array( 1440.000, 1800.000 ), // = ( 508 x 635 ) mm = ( 20.00 x 25.00 ) in
'EN_SHEET' => array( 1404.000, 1692.000 ), // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in
'EN_HALF_POST' => array( 1404.000, 1692.000 ), // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in
'EN_SUPER_ROYAL' => array( 1368.000, 1944.000 ), // = ( 483 x 686 ) mm = ( 19.00 x 27.00 ) in
'EN_DOUBLE_POST' => array( 1368.000, 2196.000 ), // = ( 483 x 775 ) mm = ( 19.00 x 30.50 ) in
'EN_MEDIUM' => array( 1260.000, 1656.000 ), // = ( 445 x 584 ) mm = ( 17.50 x 23.00 ) in
'EN_DEMY' => array( 1260.000, 1620.000 ), // = ( 445 x 572 ) mm = ( 17.50 x 22.50 ) in
'EN_LARGE_POST' => array( 1188.000, 1512.000 ), // = ( 419 x 533 ) mm = ( 16.50 x 21.00 ) in
'EN_COPY_DRAUGHT' => array( 1152.000, 1440.000 ), // = ( 406 x 508 ) mm = ( 16.00 x 20.00 ) in
'EN_POST' => array( 1116.000, 1386.000 ), // = ( 394 x 489 ) mm = ( 15.50 x 19.25 ) in
'EN_CROWN' => array( 1080.000, 1440.000 ), // = ( 381 x 508 ) mm = ( 15.00 x 20.00 ) in
'EN_PINCHED_POST' => array( 1062.000, 1332.000 ), // = ( 375 x 470 ) mm = ( 14.75 x 18.50 ) in
'EN_BRIEF' => array( 972.000, 1152.000 ), // = ( 343 x 406 ) mm = ( 13.50 x 16.00 ) in
'EN_FOOLSCAP' => array( 972.000, 1224.000 ), // = ( 343 x 432 ) mm = ( 13.50 x 17.00 ) in
'EN_SMALL_FOOLSCAP' => array( 954.000, 1188.000 ), // = ( 337 x 419 ) mm = ( 13.25 x 16.50 ) in
'EN_POTT' => array( 900.000, 1080.000 ), // = ( 318 x 381 ) mm = ( 12.50 x 15.00 ) in
// - Old Imperial Belgian Sizes
'BE_GRAND_AIGLE' => array( 1984.252, 2948.031 ), // = ( 700 x 1040 ) mm = ( 27.56 x 40.94 ) in
'BE_COLOMBIER' => array( 1757.480, 2409.449 ), // = ( 620 x 850 ) mm = ( 24.41 x 33.46 ) in
'BE_DOUBLE_CARRE' => array( 1757.480, 2607.874 ), // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in
'BE_ELEPHANT' => array( 1746.142, 2182.677 ), // = ( 616 x 770 ) mm = ( 24.25 x 30.31 ) in
'BE_PETIT_AIGLE' => array( 1700.787, 2381.102 ), // = ( 600 x 840 ) mm = ( 23.62 x 33.07 ) in
'BE_GRAND_JESUS' => array( 1559.055, 2069.291 ), // = ( 550 x 730 ) mm = ( 21.65 x 28.74 ) in
'BE_JESUS' => array( 1530.709, 2069.291 ), // = ( 540 x 730 ) mm = ( 21.26 x 28.74 ) in
'BE_RAISIN' => array( 1417.323, 1842.520 ), // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in
'BE_GRAND_MEDIAN' => array( 1303.937, 1714.961 ), // = ( 460 x 605 ) mm = ( 18.11 x 23.82 ) in
'BE_DOUBLE_POSTE' => array( 1233.071, 1601.575 ), // = ( 435 x 565 ) mm = ( 17.13 x 22.24 ) in
'BE_COQUILLE' => array( 1218.898, 1587.402 ), // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in
'BE_PETIT_MEDIAN' => array( 1176.378, 1502.362 ), // = ( 415 x 530 ) mm = ( 16.34 x 20.87 ) in
'BE_RUCHE' => array( 1020.472, 1303.937 ), // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in
'BE_PROPATRIA' => array( 977.953, 1218.898 ), // = ( 345 x 430 ) mm = ( 13.58 x 16.93 ) in
'BE_LYS' => array( 898.583, 1125.354 ), // = ( 317 x 397 ) mm = ( 12.48 x 15.63 ) in
'BE_POT' => array( 870.236, 1088.504 ), // = ( 307 x 384 ) mm = ( 12.09 x 15.12 ) in
'BE_ROSETTE' => array( 765.354, 983.622 ), // = ( 270 x 347 ) mm = ( 10.63 x 13.66 ) in
// - Old Imperial French Sizes
'FR_UNIVERS' => array( 2834.646, 3685.039 ), // = ( 1000 x 1300 ) mm = ( 39.37 x 51.18 ) in
'FR_DOUBLE_COLOMBIER' => array( 2551.181, 3571.654 ), // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in
'FR_GRANDE_MONDE' => array( 2551.181, 3571.654 ), // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in
'FR_DOUBLE_SOLEIL' => array( 2267.717, 3401.575 ), // = ( 800 x 1200 ) mm = ( 31.50 x 47.24 ) in
'FR_DOUBLE_JESUS' => array( 2154.331, 3174.803 ), // = ( 760 x 1120 ) mm = ( 29.92 x 44.09 ) in
'FR_GRAND_AIGLE' => array( 2125.984, 3004.724 ), // = ( 750 x 1060 ) mm = ( 29.53 x 41.73 ) in
'FR_PETIT_AIGLE' => array( 1984.252, 2664.567 ), // = ( 700 x 940 ) mm = ( 27.56 x 37.01 ) in
'FR_DOUBLE_RAISIN' => array( 1842.520, 2834.646 ), // = ( 650 x 1000 ) mm = ( 25.59 x 39.37 ) in
'FR_JOURNAL' => array( 1842.520, 2664.567 ), // = ( 650 x 940 ) mm = ( 25.59 x 37.01 ) in
'FR_COLOMBIER_AFFICHE' => array( 1785.827, 2551.181 ), // = ( 630 x 900 ) mm = ( 24.80 x 35.43 ) in
'FR_DOUBLE_CAVALIER' => array( 1757.480, 2607.874 ), // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in
'FR_CLOCHE' => array( 1700.787, 2267.717 ), // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in
'FR_SOLEIL' => array( 1700.787, 2267.717 ), // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in
'FR_DOUBLE_CARRE' => array( 1587.402, 2551.181 ), // = ( 560 x 900 ) mm = ( 22.05 x 35.43 ) in
'FR_DOUBLE_COQUILLE' => array( 1587.402, 2494.488 ), // = ( 560 x 880 ) mm = ( 22.05 x 34.65 ) in
'FR_JESUS' => array( 1587.402, 2154.331 ), // = ( 560 x 760 ) mm = ( 22.05 x 29.92 ) in
'FR_RAISIN' => array( 1417.323, 1842.520 ), // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in
'FR_CAVALIER' => array( 1303.937, 1757.480 ), // = ( 460 x 620 ) mm = ( 18.11 x 24.41 ) in
'FR_DOUBLE_COURONNE' => array( 1303.937, 2040.945 ), // = ( 460 x 720 ) mm = ( 18.11 x 28.35 ) in
'FR_CARRE' => array( 1275.591, 1587.402 ), // = ( 450 x 560 ) mm = ( 17.72 x 22.05 ) in
'FR_COQUILLE' => array( 1247.244, 1587.402 ), // = ( 440 x 560 ) mm = ( 17.32 x 22.05 ) in
'FR_DOUBLE_TELLIERE' => array( 1247.244, 1927.559 ), // = ( 440 x 680 ) mm = ( 17.32 x 26.77 ) in
'FR_DOUBLE_CLOCHE' => array( 1133.858, 1700.787 ), // = ( 400 x 600 ) mm = ( 15.75 x 23.62 ) in
'FR_DOUBLE_POT' => array( 1133.858, 1757.480 ), // = ( 400 x 620 ) mm = ( 15.75 x 24.41 ) in
'FR_ECU' => array( 1133.858, 1474.016 ), // = ( 400 x 520 ) mm = ( 15.75 x 20.47 ) in
'FR_COURONNE' => array( 1020.472, 1303.937 ), // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in
'FR_TELLIERE' => array( 963.780, 1247.244 ), // = ( 340 x 440 ) mm = ( 13.39 x 17.32 ) in
'FR_POT' => array( 878.740, 1133.858 ), // = ( 310 x 400 ) mm = ( 12.20 x 15.75 ) in
);

View File

@@ -0,0 +1,129 @@
<?php
/**
* EAN for WooCommerce - Advanced Section Settings
*
* @version 4.7.3
* @since 2.2.9
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Advanced' ) ) :
class Alg_WC_EAN_Settings_Advanced extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 2.2.9
* @since 2.2.9
*/
function __construct() {
$this->id = 'advanced';
$this->desc = __( 'Advanced', 'ean-for-woocommerce' );
parent::__construct();
}
/**
* get_settings.
*
* @version 4.7.3
* @since 2.2.9
*
* @todo (dev) Import/Export: move to "Tools", and/or add dashicons?
* @todo (desc) `alg_wc_ean_meta_key`
* @todo (desc) `alg_wc_ean_js_variations_form_closest`: better desc
*/
function get_settings() {
return array(
array(
'title' => __( 'Advanced Options', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_advanced_options',
),
array(
'title' => __( 'Meta key', 'ean-for-woocommerce' ),
'desc' => sprintf( __( 'Default: %s', 'ean-for-woocommerce' ), '<code>_alg_ean</code>' ),
'id' => 'alg_wc_ean_meta_key',
'default' => '_alg_ean',
'type' => 'text',
'custom_attributes' => array( 'required' => 'required' ),
),
array(
'title' => __( 'Force remote image', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Forces remote images in Barcodes > Order items table > Pages.', 'ean-for-woocommerce' ) . ' ' .
__( '<strong>Please note</strong> that this option won\'t work on <code>localhost</code> environment.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_order_items_table_barcode_force_remote_img',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_advanced_options',
),
array(
'title' => __( 'JavaScript Variation Options', 'ean-for-woocommerce' ),
'desc' => sprintf( __( 'This is used only if "%s" option is set to "%s".', 'ean-for-woocommerce' ),
__( 'Variable products: Position in variation', 'ean-for-woocommerce' ), __( 'Product meta', 'ean-for-woocommerce' ) ) . ' ' .
__( 'Leave at the default value if unsure.', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_advanced_js_options',
),
array(
'title' => __( 'Variations form', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_js_variations_form',
'default' => '.variations_form',
'type' => 'text',
),
array(
'title' => __( 'Closest container', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_js_variations_form_closest',
'default' => '.summary',
'type' => 'text',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_advanced_js_options',
),
array(
'title' => __( 'Export/Import/Reset Plugin Settings', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_export_import_settings_options',
),
array(
'title' => __( 'Export', 'ean-for-woocommerce' ),
'desc' => __( 'Export all settings', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Check the box and "Save changes" to export.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_export_settings',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Import', 'ean-for-woocommerce' ),
'desc' => __( 'Choose file and "Save changes" to import.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_import_settings',
'type' => 'alg_wc_ean_file',
),
array(
'title' => __( 'Reset', 'ean-for-woocommerce' ),
'desc' => __( 'Reset all settings', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Check the box and "Save changes" to reset.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_reset_settings',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_export_import_settings_options',
),
);
}
}
endif;
return new Alg_WC_EAN_Settings_Advanced();

View File

@@ -0,0 +1,192 @@
<?php
/**
* EAN for WooCommerce - Barcodes - Compatibility Section Settings
*
* @version 4.2.0
* @since 3.8.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Barcodes_Compatibility' ) ) :
class Alg_WC_EAN_Settings_Barcodes_Compatibility extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 3.8.0
* @since 3.8.0
*/
function __construct( $dim ) {
$this->dim = $dim;
$this->dim_suffix = ( '1d' === $this->dim ? '' : '_2d' );
$this->id = ( '1d' === $this->dim ? 'barcodes' : 'barcodes_2d' ) . '_compatibility';
$this->desc = ( '1d' === $this->dim ? __( 'Barcodes', 'ean-for-woocommerce' ) : __( '2D Barcodes', 'ean-for-woocommerce' ) ) . ' > ' . __( 'Compatibility', 'ean-for-woocommerce' );
parent::__construct();
}
/**
* get_settings.
*
* @version 4.2.0
* @since 3.8.0
*/
function get_settings() {
$settings = array(
array(
'title' => __( 'Plugin Compatibility Options', 'ean-for-woocommerce' ),
'desc' => sprintf( __( '"%s" option must be enabled.', 'ean-for-woocommerce' ),
'<a href="' . admin_url( 'admin.php?page=wc-settings&tab=alg_wc_ean&section=' . ( '1d' === $this->dim ? 'barcodes' : 'barcodes_2d' ) ) . '">' .
( '1d' === $this->dim ? __( 'Barcodes', 'ean-for-woocommerce' ) : __( '2D Barcodes', 'ean-for-woocommerce' ) ) . ' > ' . __( 'Enable section', 'ean-for-woocommerce' ) .
'</a>' ),
'type' => 'title',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_compatibility_options",
),
array(
'title' => __( 'Print Invoice & Delivery Notes for WooCommerce', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Show barcode image in PDF documents of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="' . 'https://wordpress.org/plugins/woocommerce-delivery-notes/' . '">' .
__( 'Print Invoice & Delivery Notes for WooCommerce', 'ean-for-woocommerce' ) . '</a>' ),
'id' => "alg_wc_ean_wcdn_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'WooCommerce PDF Invoices & Packing Slips', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Show barcode image in PDF documents of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="' . 'https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/' . '">' .
__( 'WooCommerce PDF Invoices & Packing Slips', 'ean-for-woocommerce' ) . '</a>' ),
'id' => "alg_wc_ean_wpo_wcpdf_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Content', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wpo_wcpdf_barcode_options{$this->dim_suffix}[content]",
'default' => '<div class="ean_wrapper' . $this->dim_suffix . '">[alg_wc_ean_barcode' . $this->dim_suffix . ']</div>',
'type' => 'textarea',
),
array(
'desc' => __( 'Position', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wpo_wcpdf_barcode_position{$this->dim_suffix}",
'default' => 'wpo_wcpdf_after_item_meta',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'wpo_wcpdf_before_item_meta' => __( 'Before item meta', 'ean-for-woocommerce' ),
'wpo_wcpdf_after_item_meta' => __( 'After item meta', 'ean-for-woocommerce' ),
),
),
array(
'title' => __( 'WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Show barcode image in PDF documents of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="' . 'https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/' . '">' .
__( 'WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels', 'ean-for-woocommerce' ) . '</a>' ),
'id' => "alg_wc_ean_wt_pklist_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Content', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wt_pklist_barcode_options{$this->dim_suffix}[content]",
'default' => "<p>[alg_wc_ean_barcode{$this->dim_suffix}]</p>",
'type' => 'textarea',
),
array(
'desc' => __( 'Position', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wt_pklist_barcode_options{$this->dim_suffix}[position]",
'default' => 'after_product_meta',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'before_product_name' => __( 'Before item name', 'ean-for-woocommerce' ),
'after_product_name' => __( 'After item name', 'ean-for-woocommerce' ),
'before_product_meta' => __( 'Before item meta', 'ean-for-woocommerce' ),
'after_product_meta' => __( 'After item meta', 'ean-for-woocommerce' ),
'column' => __( 'As a separate column', 'ean-for-woocommerce' ),
),
),
array(
'desc' => __( 'Documents', 'ean-for-woocommerce' ) . '<br>' .
sprintf( __( 'Can be a comma-separated list, e.g.: %s.', 'ean-for-woocommerce' ),
'<code>' . implode( ',', array( 'invoice', 'packinglist', 'deliverynote', 'dispatchlabel' ) ) . '</code>' ),
'desc_tip' => __( 'Leave empty to include in all documents.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wt_pklist_barcode_options{$this->dim_suffix}[documents]",
'default' => '',
'type' => 'text',
),
array(
'desc' => __( 'Column title', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Used only if the "Position" option is set to the "As a separate column".', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wt_pklist_barcode_options{$this->dim_suffix}[column_title]",
'default' => __( 'Barcode', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'desc' => sprintf( __( 'Column HTML %s', 'ean-for-woocommerce' ), '<code>class</code>' ),
'desc_tip' => __( 'Used only if the "Position" option is set to the "As a separate column".', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wt_pklist_barcode_options{$this->dim_suffix}[column_class]",
'default' => 'wfte_product_table_head_ean wfte_text_center',
'type' => 'text',
),
array(
'desc' => sprintf( __( 'Column HTML %s', 'ean-for-woocommerce' ), '<code>style</code>' ),
'desc_tip' => __( 'Used only if the "Position" option is set to the "As a separate column".', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wt_pklist_barcode_options{$this->dim_suffix}[column_style]",
'default' => '',
'type' => 'text',
),
array(
'title' => __( 'WooCommerce Customer / Order / Coupon Export', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will add %s column to the order items export of the %s plugin.', 'ean-for-woocommerce' ),
"<code>item_barcode{$this->dim_suffix}</code>", '<a target="_blank" href="https://woocommerce.com/products/ordercustomer-csv-export/">' . __( 'WooCommerce Customer / Order / Coupon Export', 'ean-for-woocommerce' ) . '</a>' ),
'id' => "alg_wc_ean_wc_customer_order_export_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Content', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_wc_customer_order_export_content_barcode{$this->dim_suffix}",
'default' => '[alg_wc_ean_barcode' . $this->dim_suffix . '_base64 before="data:image/png;base64,"]',
'type' => 'textarea',
'css' => 'width:100%;',
),
array(
'title' => __( 'Dokan', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will show barcode in vendor product form of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="https://wordpress.org/plugins/dokan-lite/">' . __( 'Dokan', 'ean-for-woocommerce' ) . '</a>' ),
'id' => "alg_wc_ean_dokan_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Title', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_dokan_title_barcode{$this->dim_suffix}",
'default' => __( 'Barcode', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'desc' => __( 'Content', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_dokan_content_barcode{$this->dim_suffix}",
'default' => "[alg_wc_ean_barcode{$this->dim_suffix}]",
'type' => 'textarea',
),
array(
'type' => 'sectionend',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_compatibility_options",
),
);
return $settings;
}
}
endif;

View File

@@ -0,0 +1,291 @@
<?php
/**
* EAN for WooCommerce - Barcodes Section Settings
*
* @version 4.5.0
* @since 2.0.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Barcodes' ) ) :
class Alg_WC_EAN_Settings_Barcodes extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 3.6.0
* @since 2.0.0
*/
function __construct( $dim ) {
$this->dim = $dim;
$this->dim_suffix = ( '1d' === $this->dim ? '' : '_2d' );
$this->id = ( '1d' === $this->dim ? 'barcodes' : 'barcodes_2d' );
$this->desc = ( '1d' === $this->dim ? __( 'Barcodes', 'ean-for-woocommerce' ) : __( '2D Barcodes', 'ean-for-woocommerce' ) );
parent::__construct();
}
/**
* get_settings.
*
* @version 4.5.0
* @since 2.0.0
*
* @todo (desc) Enable section: better desc
* @todo (desc) `alg_wc_ean_order_items_table_barcode`: "... *may* not work..."?
* @todo (dev) `alg_wc_ean_backend_column_barcode_data[]`?
* @todo (desc) `alg_wc_ean_backend_column_barcode_template`: better desc?
* @todo (dev) Barcode type: `1d`: `EAN14`?
* @todo (dev) Barcode type: add all types from https://github.com/tecnickcom/TCPDF/blob/6.3.5/tcpdf_barcodes_2d.php#L66, i.e., `QRCODE` and `PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6` (last one maybe as an additional "Custom type" option?)
*/
function get_settings() {
$settings = array(
array(
'title' => sprintf( __( '%s Options', 'ean-for-woocommerce' ), $this->desc ),
'type' => 'title',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_options",
),
array(
'title' => $this->desc,
'desc' => '<strong>' . __( 'Enable section', 'ean-for-woocommerce' ) . '</strong>',
'desc_tip' => $this->pro_msg(),
'id' => "alg_wc_ean_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
'custom_attributes' => apply_filters( 'alg_wc_ean_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'title' => __( 'Admin product edit page', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Show barcode image on admin product edit page.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_backend_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Admin products list column', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Add "Barcode" column to %s.', 'ean-for-woocommerce' ),
'<a href="' . admin_url( 'edit.php?post_type=product' ) . '">' . __( 'admin products list', 'ean-for-woocommerce' ) . '</a>' ),
'id' => "alg_wc_ean_backend_column_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Column title', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_backend_column_barcode_title{$this->dim_suffix}",
'default' => ( '1d' === $this->dim ? __( 'Barcode', 'ean-for-woocommerce' ) : __( '2D barcode', 'ean-for-woocommerce' ) ),
'type' => 'text',
),
array(
'desc' => __( 'Column template', 'ean-for-woocommerce' ) . '<br>' .
sprintf( __( 'You should use %s shortcode here.', 'ean-for-woocommerce' ), '<code>[alg_wc_ean_barcode' . $this->dim_suffix . ']</code>' ),
'id' => "alg_wc_ean_backend_column_barcode_template{$this->dim_suffix}",
'default' => '[alg_wc_ean_barcode' . $this->dim_suffix . ' content="ean" w="' . ( '1d' === $this->dim ? 1 : 1 ) . '" h="' . ( '1d' === $this->dim ? 15 : 1 ) . '" children="yes"]',
'type' => 'textarea',
'css' => 'width:100%;',
),
array(
'title' => __( 'Single product page', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Show barcode image on single product page on frontend.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_frontend_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Variable products: Position in variation', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_frontend_variation_position_barcode{$this->dim_suffix}",
'default' => 'product_meta',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'product_meta' => __( 'Product meta', 'ean-for-woocommerce' ),
'variation_description' => __( 'Description', 'ean-for-woocommerce' ),
),
),
array(
'title' => __( 'Shop pages', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Show barcode on shop (e.g., category) pages on frontend.', 'ean-for-woocommerce' ) . ' ' . $this->variable_products_note(),
'id' => "alg_wc_ean_frontend_loop_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Cart', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Show barcode on cart page on frontend.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_frontend_cart_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Cart template', 'ean-for-woocommerce' ) . '<br>' .
sprintf( __( 'You should use %s shortcode here.', 'ean-for-woocommerce' ), '<code>[alg_wc_ean_barcode' . $this->dim_suffix . ']</code>' ),
'id' => "alg_wc_ean_frontend_cart_barcode_template{$this->dim_suffix}",
'default' => '[alg_wc_ean_barcode' . $this->dim_suffix .
' before=\'<span class="sku_wrapper ean_barcode' . $this->dim_suffix . '_wrapper"><span class="ean_barcode' . $this->dim_suffix . '">\'' .
' after=\'</span></span>\']',
'type' => 'textarea',
'css' => 'width:100%;',
),
array(
'type' => 'sectionend',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_options",
),
array(
'title' => __( 'Orders & Emails', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_orders_options",
),
array(
'title' => __( 'Orders', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Show barcode image on admin order edit page.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_order_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Template', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_order_template_barcode{$this->dim_suffix}",
'default' => "<p>[alg_wc_ean_barcode{$this->dim_suffix}]</p>",
'type' => 'textarea',
'css' => 'width:100%;',
),
array(
'title' => __( 'Order items table', 'ean-for-woocommerce' ),
'desc' => __( 'Pages', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Show barcode image in order items table on <strong>pages</strong>.', 'ean-for-woocommerce' ) . ' ' .
__( 'E.g.: "thank you" (i.e., "order received") page, "view order" page (in "my account").', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_order_items_table_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Emails', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Show barcode image in order items table in <strong>emails</strong>.', 'ean-for-woocommerce' ) . ' ' .
__( 'You can limit it to the specific emails in the "Emails list" option below.', 'ean-for-woocommerce' ) . '<br>' .
__( '<strong>Please note</strong> that this option won\'t work on <code>localhost</code> environment.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_order_items_table_emails_barcode{$this->dim_suffix}",
'default' => get_option( "alg_wc_ean_order_items_table_barcode{$this->dim_suffix}", 'no' ), // for the backward compatibility
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'desc' => __( 'Emails list', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Leave empty to add to all emails.', 'ean-for-woocommerce' ) . ' ' .
__( 'Ignored unless the "Emails" option above is enabled.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_order_items_table_emails_list_barcode{$this->dim_suffix}",
'default' => array(),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => $this->get_wc_emails(),
),
array(
'type' => 'sectionend',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_orders_options",
),
array(
'title' => __( 'REST API', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_rest_api_options",
),
array(
'title' => __( 'Products', 'ean-for-woocommerce' ),
'desc' => __( 'Add barcode (base64) to each product object in REST API responses', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'E.g.: %s', 'ean-for-woocommerce' ), '<code>https://example.com/wp-json/wc/v3/products/123</code>' ),
'id' => "alg_wc_ean_rest_api_product_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Orders', 'ean-for-woocommerce' ),
'desc' => __( 'Add barcode (base64) to each order object in REST API responses', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'E.g.: %s', 'ean-for-woocommerce' ), '<code>https://example.com/wp-json/wc/v3/orders/465</code>' ),
'id' => "alg_wc_ean_rest_api_order_barcode{$this->dim_suffix}",
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Template', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Used for both "Products" and "Orders" REST API responses.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_rest_api_product_template_barcode{$this->dim_suffix}",
'default' => '[alg_wc_ean_barcode' . $this->dim_suffix . '_base64 before="data:image/png;base64,"]',
'type' => 'textarea',
'css' => 'width:100%;',
),
array(
'type' => 'sectionend',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_rest_api_options",
),
);
$settings = array_merge( $settings, array(
array(
'title' => __( 'Advanced Barcodes Options', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_advanced_options",
),
array(
'title' => __( 'Barcode type', 'ean-for-woocommerce' ),
'desc' => ( '2d' === $this->dim ? '' : sprintf( __( 'If set to "Automatic", will use the barcode type based on EAN type, i.e., %s for EAN-8, %s for UPC-A, %s for EAN-13, ISBN-13 and JAN, and %s for all other types.', 'ean-for-woocommerce' ),
'<code>EAN-8</code>', '<code>UPC-A</code>', '<code>EAN-13</code>', '<code>CODE 128</code>' ) ),
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_barcode_type",
'default' => ( '2d' === $this->dim ? 'QRCODE,L' : 'AUTO' ),
'type' => 'select',
'class' => 'chosen_select',
'options' => ( '2d' === $this->dim ?
array(
'QRCODE,L' => __( 'QR code: Low error correction', 'ean-for-woocommerce' ),
'QRCODE,M' => __( 'QR code: Medium error correction', 'ean-for-woocommerce' ),
'QRCODE,Q' => __( 'QR code: Better error correction', 'ean-for-woocommerce' ),
'QRCODE,H' => __( 'QR code: Best error correction', 'ean-for-woocommerce' ),
'DATAMATRIX' => __( 'Datamatrix (ISO/IEC 16022)', 'ean-for-woocommerce' ),
'PDF417' => __( 'PDF417 (ISO/IEC 15438:2006)', 'ean-for-woocommerce' ),
) :
array(
'AUTO' => __( 'Automatic', 'ean-for-woocommerce' ),
'EAN8' => 'EAN-8',
'UPCA' => 'UPC-A',
'EAN13' => 'EAN-13',
'C128' => 'CODE 128',
)
),
),
array(
'title' => __( 'Suppress errors', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ) . ' (' . __( 'recommended', 'ean-for-woocommerce' ) . ')',
'desc_tip' => __( 'Suppress PHP errors when generating barcode.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_suppress_errors_barcode{$this->dim_suffix}",
'default' => 'yes',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_advanced_options",
),
) );
$settings = array_merge( $settings, array(
array(
'title' => __( 'Notes', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-info"></span> ' . sprintf( __( 'You can also output barcode with %s shortcode.', 'ean-for-woocommerce' ),
"<code>[alg_wc_ean_barcode{$this->dim_suffix}]</code>" ),
'type' => 'title',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_notes",
),
array(
'type' => 'sectionend',
'id' => "alg_wc_ean_barcode{$this->dim_suffix}_notes",
),
) );
return $settings;
}
}
endif;

View File

@@ -0,0 +1,294 @@
<?php
/**
* EAN for WooCommerce - Compatibility Section Settings
*
* @version 4.7.8
* @since 2.2.9
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Compatibility' ) ) :
class Alg_WC_EAN_Settings_Compatibility extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 2.2.9
* @since 2.2.9
*/
function __construct() {
$this->id = 'compatibility';
$this->desc = __( 'Compatibility', 'ean-for-woocommerce' );
parent::__construct();
}
/**
* get_settings.
*
* @version 4.7.8
* @since 2.2.9
*
* @todo (dev) `alg_wc_ean_wcfm_hints`: better default value?
* @todo (desc) `alg_wc_ean_wcfm_add_generate_button`: better desc?
*/
function get_settings() {
return array(
array(
'title' => __( 'Plugin Compatibility Options', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_plugin_compatibility_options',
),
array(
'title' => __( 'Google Listings & Ads', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will add EAN to the product data of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="' . 'https://wordpress.org/plugins/google-listings-and-ads/' . '">' .
__( 'Google Listings & Ads', 'ean-for-woocommerce' ) . '</a>' ) . '<br>' .
sprintf( __( 'After enabling the checkbox, go to "Marketing > Google Listings & Ads > Attributes > Create attribute rule", select the "GTIN" attribute, and then select %s in the "Use value from existing product field" dropdown box.', 'ean-for-woocommerce' ),
'<code>' . alg_wc_ean()->core->ean_key . '</code>' ) . '<br>' .
( defined( 'WC_GLA_VERSION' ) ? sprintf( __( 'You may also want to "Sync All Products with Google Merchant Center" on the %s.', 'ean-for-woocommerce' ),
'<a href="' . admin_url( 'admin.php?page=connection-test-admin-page' ) . '">' . __( 'Google Listings & Ads connection testing page', 'ean-for-woocommerce' ) . '</a>' ) : '' ),
'id' => 'alg_wc_ean_gla',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Point of Sale for WooCommerce', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will add EAN to the product search of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="' . 'https://woocommerce.com/products/point-of-sale-for-woocommerce/' . '">' .
__( 'Point of Sale for WooCommerce', 'ean-for-woocommerce' ) . '</a>' ) . '<br>' .
__( '<strong>Please note</strong> that "WooCommerce > Settings > EAN > General > Search" option must be enabled as well.', 'ean-for-woocommerce' ) . '<br>' .
__( '<strong>Alternatively</strong> you can add "EAN" to the "Scanning Fields" and "Product SKU" to the "Search Includes" options in "Point of Sale > Settings > Register".', 'ean-for-woocommerce' ) . '<br>' .
'* ' . __( 'To enable searching with a scanner, add "EAN" field to the "Scanning Fields" option in "Point of Sale > Settings > Register".', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wc_pos_search',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Print Invoice & Delivery Notes for WooCommerce', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will show EAN in PDF documents of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="' . 'https://wordpress.org/plugins/woocommerce-delivery-notes/' . '">' .
__( 'Print Invoice & Delivery Notes for WooCommerce', 'ean-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_ean_wcdn',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'WooCommerce PDF Invoices & Packing Slips', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will show EAN in PDF documents of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="' . 'https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/' . '">' .
__( 'WooCommerce PDF Invoices & Packing Slips', 'ean-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_ean_wpo_wcpdf',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Content', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Available placeholder: %s.', 'ean-for-woocommerce' ), '%ean%' ),
'id' => 'alg_wc_ean_wpo_wcpdf_options[content]',
'default' => '<dl class="meta">' .
'<dt class="ean">' . esc_html( get_option( 'alg_wc_ean_title', __( 'EAN', 'ean-for-woocommerce' ) ) ) . ':' . '</dt>' .
'<dd class="ean">' . '%ean%' . '</dd>' .
'</dl>',
'type' => 'textarea',
),
array(
'desc' => __( 'Position', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wpo_wcpdf_position',
'default' => 'wpo_wcpdf_after_item_meta',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'wpo_wcpdf_before_item_meta' => __( 'Before item meta', 'ean-for-woocommerce' ),
'wpo_wcpdf_after_item_meta' => __( 'After item meta', 'ean-for-woocommerce' ),
),
),
array(
'title' => __( 'WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will show EAN in PDF documents of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="' . 'https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/' . '">' .
__( 'WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels', 'ean-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_ean_wt_pklist',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Content', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wt_pklist_options[content]',
'default' => '<p>EAN: [alg_wc_ean]</p>',
'type' => 'textarea',
),
array(
'desc' => __( 'Position', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wt_pklist_options[position]',
'default' => 'after_product_meta',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'before_product_name' => __( 'Before item name', 'ean-for-woocommerce' ),
'after_product_name' => __( 'After item name', 'ean-for-woocommerce' ),
'before_product_meta' => __( 'Before item meta', 'ean-for-woocommerce' ),
'after_product_meta' => __( 'After item meta', 'ean-for-woocommerce' ),
'column' => __( 'As a separate column', 'ean-for-woocommerce' ),
),
),
array(
'desc' => __( 'Documents', 'ean-for-woocommerce' ) . '<br>' .
sprintf( __( 'Can be a comma-separated list, e.g.: %s.', 'ean-for-woocommerce' ),
'<code>' . implode( ',', array( 'invoice', 'packinglist', 'deliverynote', 'dispatchlabel' ) ) . '</code>' ),
'desc_tip' => __( 'Leave empty to include in all documents.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wt_pklist_options[documents]',
'default' => '',
'type' => 'text',
),
array(
'desc' => __( 'Column title', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Used only if the "Position" option is set to the "As a separate column".', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wt_pklist_options[column_title]',
'default' => __( 'EAN', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'desc' => sprintf( __( 'Column HTML %s', 'ean-for-woocommerce' ), '<code>class</code>' ),
'desc_tip' => __( 'Used only if the "Position" option is set to the "As a separate column".', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wt_pklist_options[column_class]',
'default' => 'wfte_product_table_head_ean wfte_text_center',
'type' => 'text',
),
array(
'desc' => sprintf( __( 'Column HTML %s', 'ean-for-woocommerce' ), '<code>style</code>' ),
'desc_tip' => __( 'Used only if the "Position" option is set to the "As a separate column".', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wt_pklist_options[column_style]',
'default' => '',
'type' => 'text',
),
array(
'title' => __( 'WooCommerce Customer / Order / Coupon Export', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will add %s column to the order items export of the %s plugin.', 'ean-for-woocommerce' ),
'<code>item_ean</code>', '<a target="_blank" href="https://woocommerce.com/products/ordercustomer-csv-export/">' . __( 'WooCommerce Customer / Order / Coupon Export', 'ean-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_ean_wc_customer_order_export',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Dokan', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will show EAN in vendor product form of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="https://wordpress.org/plugins/dokan-lite/">' . __( 'Dokan', 'ean-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_ean_dokan',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Required', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_dokan_required',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => sprintf( __( 'Required HTML, e.g.: %s', 'ean-for-woocommerce' ),
'<code>' . esc_html( '&amp;nbsp;<abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>' ) . '</code>' ),
'id' => 'alg_wc_ean_dokan_required_html',
'default' => '',
'type' => 'textarea',
),
array(
'desc' => __( 'Title', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_dokan_title',
'default' => __( 'EAN', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'desc' => __( 'Placeholder', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_dokan_placeholder',
'default' => __( 'Product EAN...', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'desc' => __( 'Description', 'ean-for-woocommerce' ) . '<br>' .
sprintf( __( 'You can use HTML and shortcodes here, e.g.: %s', 'ean-for-woocommerce' ),
'<code>' . esc_html( '<div>[alg_wc_ean_is_valid] | [alg_wc_ean_is_unique]</div>' ) . '</code>' ),
'id' => 'alg_wc_ean_dokan_desc',
'default' => '',
'type' => 'textarea',
'css' => 'height:100px;',
),
array(
'title' => __( 'WCFM', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will show EAN in product forms of the %s and %s plugins.', 'ean-for-woocommerce' ),
'<a target="_blank" href="https://wordpress.org/plugins/wc-frontend-manager/">' . __( 'WCFM', 'ean-for-woocommerce' ) . '</a>',
'<a target="_blank" href="https://wordpress.org/plugins/wc-multivendor-marketplace/">' . __( 'WCFM Marketplace', 'ean-for-woocommerce' ) . '</a>' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wcfm',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Title', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wcfm_title',
'default' => __( 'EAN', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'desc' => __( 'Placeholder', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wcfm_placeholder',
'default' => __( 'Product EAN...', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'desc' => __( 'Hints', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_wcfm_hints',
'default' => __( 'The International Article Number (also known as European Article Number or EAN) is a standard describing a barcode symbology and numbering system used in global trade to identify a specific retail product type, in a specific packaging configuration, from a specific manufacturer.', 'ean-for-woocommerce' ),
'type' => 'textarea',
'css' => 'height:110px;',
),
array(
'desc' => __( 'Add "Generate" button', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will add "Generate %s" button to the vendor product edit pages.', 'ean-for-woocommerce' ),
get_option( 'alg_wc_ean_title', __( 'EAN', 'ean-for-woocommerce' ) ) ),
'id' => 'alg_wc_ean_wcfm_add_generate_button',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'MultiVendorX', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will show EAN in vendor product form of the %s plugin.', 'ean-for-woocommerce' ),
'<a target="_blank" href="https://wordpress.org/plugins/dc-woocommerce-multi-vendor/">' . __( 'MultiVendorX', 'ean-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_ean_mvx',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Title', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_mvx_title',
'default' => __( 'EAN:', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'desc' => __( 'Placeholder', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_mvx_placeholder',
'default' => '',
'type' => 'text',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_plugin_compatibility_options',
),
);
}
}
endif;
return new Alg_WC_EAN_Settings_Compatibility();

View File

@@ -0,0 +1,126 @@
<?php
/**
* EAN for WooCommerce - Extra Field Section Settings
*
* @version 4.7.6
* @since 4.0.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Extra_Field' ) ) :
class Alg_WC_EAN_Settings_Extra_Field extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 4.0.0
* @since 4.0.0
*/
function __construct( $num ) {
$this->num = $num;
$this->id = 'extra_field_' . $this->num;
$this->desc = $this->get_desc();
parent::__construct();
}
/**
* get_desc.
*
* @version 4.0.0
* @since 4.0.0
*
* @todo (dev) this is (almost) duplicated in `Alg_WC_EAN_Extra_Field::get_name()`
*/
function get_desc() {
$name = get_option( 'alg_wc_ean_extra_field_name', array() );
return ( isset( $name[ $this->num ] ) && '' !== $name[ $this->num ] ? $name[ $this->num ] : sprintf( __( 'Extra field #%d', 'ean-for-woocommerce' ), $this->num ) );
}
/**
* get_settings.
*
* @version 4.7.6
* @since 4.0.0
*/
function get_settings() {
$settings = array(
array(
'title' => sprintf( __( '%s Options', 'ean-for-woocommerce' ), $this->desc ),
'type' => 'title',
'id' => 'alg_wc_ean_extra_field_' . $this->num . '_options',
),
array(
'title' => $this->get_desc(),
'desc' => '<strong>' . __( 'Enable field', 'ean-for-woocommerce' ) . '</strong>',
'desc_tip' => $this->pro_msg( 'enable this field' ),
'type' => 'checkbox',
'id' => "alg_wc_ean_extra_field_enabled[{$this->num}]",
'default' => 'no',
'custom_attributes' => apply_filters( 'alg_wc_ean_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'title' => __( 'Title', 'ean-for-woocommerce' ),
'desc' => sprintf( __( 'For example: %s', 'ean-for-woocommerce' ), '<code>MPN</code>' ),
'type' => 'text',
'id' => "alg_wc_ean_extra_field_name[{$this->num}]",
'default' => sprintf( __( 'Extra field #%d', 'ean-for-woocommerce' ), $this->num ),
'custom_attributes' => array( 'required' => 'required' ),
),
array(
'title' => __( 'Meta key', 'ean-for-woocommerce' ),
'desc' => sprintf( __( 'For example: %s', 'ean-for-woocommerce' ), '<code>mpn</code>' ),
'type' => 'text',
'id' => "alg_wc_ean_extra_field_key[{$this->num}]",
'default' => sprintf( 'extra_field_%d', $this->num ),
'custom_attributes' => array( 'required' => 'required' ),
),
array(
'title' => __( 'Admin product search', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_extra_field_backend_search[{$this->num}]",
'desc_tip' => __( 'This will enable searching by the field in admin area.', 'ean-for-woocommerce' ),
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Single product page', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will show the field on single product page on frontend.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_extra_field_frontend[{$this->num}]",
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Search', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will enable searching by the field on the frontend.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_extra_field_frontend_search[{$this->num}]",
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Product structured data', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_extra_field_structured_data_product[{$this->num}]",
'desc_tip' => __( 'This will add the field to the product structured data, e.g., for Google Search Console.', 'ean-for-woocommerce' ),
'default' => 'yes',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_extra_field_' . $this->num . '_options',
),
);
return $settings;
}
}
endif;

View File

@@ -0,0 +1,95 @@
<?php
/**
* EAN for WooCommerce - Extra Fields Section Settings
*
* @version 4.7.6
* @since 4.0.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Extra_Fields' ) ) :
class Alg_WC_EAN_Settings_Extra_Fields extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 4.0.0
* @since 4.0.0
*/
function __construct() {
$this->id = 'extra_fields';
$this->desc = __( 'Extra Fields', 'ean-for-woocommerce' );
parent::__construct();
}
/**
* get_settings.
*
* @version 4.7.6
* @since 4.0.0
*
* @todo (dev) `alg_wc_ean_extra_fields_num_total`: JS?
* @todo (dev) add "Meta key"?
* @todo (desc) better section desc?
* @todo (desc) better `pro_msg`?
*/
function get_settings() {
$settings = array(
array(
'title' => __( 'Extra Fields Options', 'ean-for-woocommerce' ),
'desc' => $this->pro_msg( 'use this section' ) .
__( 'This section allows you to add multiple extra fields per product, e.g., EAN and MPN simultaneously.', 'ean-for-woocommerce' ) . '<br>' .
__( 'Please note that extra fields have less features compared to the main field.', 'ean-for-woocommerce' ) . ' ' .
sprintf( __( 'Currently supported features are: %s.', 'ean-for-woocommerce' ), implode( ', ', array(
__( 'Title', 'ean-for-woocommerce' ),
__( 'Meta key', 'ean-for-woocommerce' ),
__( 'Admin product search', 'ean-for-woocommerce' ),
__( 'Single product page display (including variations)', 'ean-for-woocommerce' ),
__( 'Search (frontend)', 'ean-for-woocommerce' ),
__( 'Product structured data', 'ean-for-woocommerce' ),
) ) ),
'type' => 'title',
'id' => 'alg_wc_ean_extra_fields_options',
),
array(
'title' => __( 'Total extra fields', 'ean-for-woocommerce' ),
'type' => 'number',
'id' => 'alg_wc_ean_extra_fields_num_total',
'default' => 0,
'custom_attributes' => array( 'min' => 0 ),
),
);
for ( $i = 1; $i <= get_option( 'alg_wc_ean_extra_fields_num_total', 0 ); $i++ ) {
$settings = array_merge( $settings, array(
array(
'title' => sprintf( __( 'Extra field #%d', 'ean-for-woocommerce' ), $i ),
'type' => 'text',
'id' => "alg_wc_ean_extra_field_name[{$i}]",
'default' => sprintf( __( 'Extra field #%d', 'ean-for-woocommerce' ), $i ),
'custom_attributes' => array( 'required' => 'required' ),
),
) );
}
$settings = array_merge( $settings, array(
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_extra_fields_options',
),
) );
return $settings;
}
}
endif;
return new Alg_WC_EAN_Settings_Extra_Fields();

View File

@@ -0,0 +1,568 @@
<?php
/**
* EAN for WooCommerce - General Section Settings
*
* @version 4.8.1
* @since 1.0.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_General' ) ) :
class Alg_WC_EAN_Settings_General extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 1.0.0
* @since 1.0.0
*/
function __construct() {
$this->id = '';
$this->desc = __( 'General', 'ean-for-woocommerce' );
parent::__construct();
}
/**
* get_types_desc.
*
* @version 4.7.0
* @since 3.3.0
*
* @see https://en.wikipedia.org/wiki/Global_Trade_Item_Number
* @see https://en.wikipedia.org/wiki/EAN-8
* @see https://en.wikipedia.org/wiki/Universal_Product_Code
* @see https://en.wikipedia.org/wiki/International_Article_Number
* @see https://en.wikipedia.org/wiki/International_Standard_Book_Number
* @see https://en.wikipedia.org/wiki/International_Article_Number#jan
* @see https://www.barcode.graphics/gtin-14-encoding/
*/
function get_types_desc() {
$types = array(
'EAN-8' => array(
'desc' => __( 'Less commonly used EAN standard. An EAN-8 number includes a 2- or 3-digit GS1 prefix, 5- or 4-digit item reference element (depending on the length of the GS1 prefix), and a checksum digit.', 'ean-for-woocommerce' ),
'length' => 8,
),
'UPC-A' => array(
'desc' => __( 'The UPC-A barcode is the most common type in the United States. UPC (technically refers to UPC-A) consists of 12 digits. It begins with a single digit number system character, which designates how the code should be classified: as a regular product, a weighted item, pharmaceuticals, coupons, etc. After that is a five digit manufacturer\'s number, followed by a five digit product number, and finally a checksum digit.', 'ean-for-woocommerce' ),
'length' => 12,
),
'EAN-13' => array(
'desc' => __( 'This is the most commonly used EAN standard. An EAN-13 number includes a 3-digit GS1 prefix, 9-digit manufacturer and product code, and a checksum digit.', 'ean-for-woocommerce' ),
'length' => 13,
),
'ISBN-13' => array(
'desc' => __( 'The International Standard Book Number (ISBN) is a numeric commercial book identifier. It\'s a subset of EAN-13 - with <code>978</code> or <code>979</code> prefix.', 'ean-for-woocommerce' ),
'length' => 13,
),
'JAN' => array(
'desc' => __( 'Japanese Article Number (JAN) is a subset of EAN-13 - with <code>45</code> or <code>49</code> prefix.', 'ean-for-woocommerce' ),
'length' => 13,
),
'EAN14' => array(
'desc' => __( 'EAN-14 is a 14 digit number used to identify trade items at various packaging levels. The first digit denotes the level of packaging.', 'ean-for-woocommerce' ),
'length' => 14,
),
__( 'Custom', 'ean-for-woocommerce' ) => array(
'desc' => __( 'Custom can represent all 128 ASCII code characters (numbers, upper case/lower case letters, symbols and control codes).', 'ean-for-woocommerce' ),
'length' => __( 'Any', 'ean-for-woocommerce' ),
),
);
$result = '';
$result .= '<table class="widefat striped">' .
'<tr>' .
'<td><strong>' . __( 'Type', 'ean-for-woocommerce' ) . '</td>' .
'<td><strong>' . __( 'Length', 'ean-for-woocommerce' ) . '</td>' .
'<td><strong>' . __( 'Description', 'ean-for-woocommerce' ) . '</td>' .
'</tr>';
foreach ( $types as $title => $data ) {
$result .= '<tr>' .
"<td><pre><strong>{$title}</strong></pre></td>" .
"<td><code>{$data['length']}</code></td>" .
"<td>{$data['desc']}</td>" .
'</tr>';
}
$result .= '</table>';
return '<details style="cursor:pointer;"><summary>' . __( 'Type details', 'ean-for-woocommerce' ) . '</summary>' . $result . '</details>';
}
/**
* get_settings.
*
* @version 4.8.1
* @since 1.0.0
*
* @see https://www.keyence.com/ss/products/auto_id/barcode_lecture/basic/barcode-types/
*
* @todo (desc) `alg_wc_ean_backend_add_generate_button`: better desc?
* @todo (dev) `alg_wc_ean_order_items_table_templates`: translate?
* @todo (dev) deprecate placeholders
* @todo (dev) `alg_wc_ean_type`: rename `C128` to `CUSTOM`
* @todo (desc) `alg_wc_ean_order_items_meta_rest`: "... tries order item meta, then uses product as a fallback..."
* @todo (desc) add subsections, e.g., "General", "Display", etc., or "Products", "Orders", etc.?
* @todo (desc) "REST API" as a separate *section*?
* @todo (desc) remove "This will" everywhere
* @todo (dev) `alg_wc_ean_order_items_meta_admin`: default to `yes` || merge with `alg_wc_ean_order_items_meta`
* @todo (dev) `alg_wc_ean_order_items_meta`: default to `yes`
* @todo (desc) `alg_wc_ean_order_items_meta_admin`: better desc
* @todo (desc) `alg_wc_ean_order_items_meta`: better desc
* @todo (dev) `$single_product_page_positions`: add more options, and maybe add `custom` hook option?
* @todo (desc) `alg_wc_ean_frontend_positions_priorities`: better desc, e.g., add "known priorities"
* @todo (desc) `alg_wc_ean_frontend_search_ajax_flatsome`: add link to the theme?
* @todo (desc) Type: add more info (and maybe links) about all types
* @todo (desc) add shortcode examples
* @todo (desc) Type: rename to "Standard"?
* @todo (desc) Shop pages: better title/desc?
* @todo (desc) Cart: better desc?
* @todo (desc) `$wcdn_settings`: better desc?
* @todo (dev) `alg_wc_ean_backend_position`: add more positions?
* @todo (desc) `alg_wc_ean_backend_position`: better names, e.g., "Inventory: SKU" to "Inventory: After SKU", etc.
* @todo (dev) `alg_wc_ean_backend_search_ajax`: remove (i.e., always `yes`)?
*/
function get_settings() {
$single_product_page_positions = array(
'woocommerce_product_meta_start' => __( 'Product meta start', 'ean-for-woocommerce' ),
'woocommerce_product_meta_end' => __( 'Product meta end', 'ean-for-woocommerce' ),
'woocommerce_before_single_product' => __( 'Before single product', 'ean-for-woocommerce' ),
'woocommerce_before_single_product_summary' => __( 'Before single product summary', 'ean-for-woocommerce' ),
'woocommerce_single_product_summary' => __( 'Single product summary', 'ean-for-woocommerce' ),
'woocommerce_after_single_product_summary' => __( 'After single product summary', 'ean-for-woocommerce' ),
'woocommerce_after_single_product' => __( 'After single product', 'ean-for-woocommerce' ),
'woocommerce_product_additional_information' => __( 'Product additional information tab', 'ean-for-woocommerce' ),
);
$settings = array(
array(
'title' => __( 'EAN Options', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_plugin_options',
),
array(
'title' => __( 'EAN', 'ean-for-woocommerce' ),
'desc' => '<strong>' . __( 'Enable plugin', 'ean-for-woocommerce' ) . '</strong>',
'id' => 'alg_wc_ean_plugin_enabled',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Type', 'ean-for-woocommerce' ),
'desc' => $this->get_types_desc(),
'desc_tip' => sprintf( __( 'The "Type" will be used for: %s', 'ean-for-woocommerce' ),
'<br><br>' . implode( ',<br><br>', array(
'* ' . __( 'EAN validation (on the admin product edit pages, and in the admin products column)', 'ean-for-woocommerce' ),
'* ' . __( 'EAN input pattern (on the admin product edit pages)', 'ean-for-woocommerce' ),
'* ' . __( 'product structured data (e.g., for Google Search Console)', 'ean-for-woocommerce' ),
'* ' . __( 'outputting 1D barcodes', 'ean-for-woocommerce' ),
) ) . '.'
),
'id' => 'alg_wc_ean_type',
'default' => 'EAN13',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'AUTO' => __( 'Automatic', 'ean-for-woocommerce' ) . ' (' . implode( ', ', array( 'EAN-13', 'UPC-A', 'EAN-8', 'ISBN-13', 'JAN', 'EAN-14' ) ) . ')',
'EAN8' => 'EAN-8',
'UPCA' => 'UPC-A',
'EAN13' => 'EAN-13',
'ISBN13' => 'ISBN-13',
'JAN' => 'JAN',
'EAN14' => 'EAN-14',
'C128' => __( 'Custom', 'ean-for-woocommerce' ), // mislabeled, should be `CUSTOM`
),
),
array(
'title' => __( 'Title', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This title will be used for the EAN input fields on admin product edit pages, in admin products list column, etc.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_title',
'default' => __( 'EAN', 'ean-for-woocommerce' ),
'type' => 'text',
),
array(
'title' => __( 'Admin product edit page', 'ean-for-woocommerce' ),
'desc' => __( 'Position', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Set to which product data tab EAN field should be added.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_backend_position',
'default' => 'woocommerce_product_options_sku',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'woocommerce_product_options_general_product_data' => __( 'General', 'ean-for-woocommerce' ),
'woocommerce_product_options_inventory_product_data' => __( 'Inventory', 'ean-for-woocommerce' ),
'woocommerce_product_options_sku' => __( 'Inventory: SKU', 'ean-for-woocommerce' ),
'woocommerce_product_options_advanced' => __( 'Advanced', 'ean-for-woocommerce' ),
),
),
array(
'desc' => __( 'Position (variation product)', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_backend_position_variation',
'default' => 'woocommerce_variation_options_pricing',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'woocommerce_variation_options_pricing' => __( 'Variations: After pricing', 'ean-for-woocommerce' ),
'woocommerce_variation_options_dimensions' => __( 'Variations: After dimensions', 'ean-for-woocommerce' ),
'woocommerce_product_after_variable_attributes' => __( 'Variations: After all', 'ean-for-woocommerce' ),
),
),
array(
'desc' => __( 'Check if valid', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will check if product EAN is valid.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_backend_is_valid',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Check if unique', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will check if product EAN is unique in your shop.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_backend_is_unique',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Require', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will make the EAN field required on the admin product edit pages.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_required',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Add pattern', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will specify a maximum length and pattern (digits only) for the EAN input field to be checked against on the admin product edit pages.', 'ean-for-woocommerce' ) . ' ' .
__( 'Ignored if "Type" is set to "Custom".', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_add_pattern',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Add "Generate" button', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will add "Generate %s" button to the admin product edit pages.', 'ean-for-woocommerce' ),
get_option( 'alg_wc_ean_title', __( 'EAN', 'ean-for-woocommerce' ) ) ),
'id' => 'alg_wc_ean_backend_add_generate_button',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Admin product search', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will enable searching by EAN in admin area.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_backend_search',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'AJAX search', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will enable searching by EAN in AJAX.', 'ean-for-woocommerce' ) . ' ' .
__( 'E.g., when searching for a product when creating new order in admin area.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_backend_search_ajax',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Admin products list column', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'This will add "%s" column to %s.', 'ean-for-woocommerce' ),
get_option( 'alg_wc_ean_title', __( 'EAN', 'ean-for-woocommerce' ) ),
'<a href ="' . admin_url( 'edit.php?post_type=product' ) . '">' . __( 'admin products list', 'ean-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_ean_backend_column',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Validate', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Validate EAN in column.', 'ean-for-woocommerce' ) . ' ' . __( 'Invalid EANs will be marked red.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_backend_column_validate',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Admin product duplicate', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will copy EAN on admin "Duplicate" product action.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_duplicate_product',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Single product page', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will show EAN on single product page on frontend.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_frontend',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'desc' => __( 'Template', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Available placeholder: %s.', 'ean-for-woocommerce' ), '%ean%' ) . '<br><br>' .
__( 'You can also use shortcodes here.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_template',
'default' => alg_wc_ean()->core->get_default_template(),
'type' => 'textarea',
),
array(
'desc' => __( 'Positions', 'ean-for-woocommerce' ),
'desc_tip' => __( 'You can select multiple positions at once.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_frontend_positions',
'default' => array( 'woocommerce_product_meta_start' ),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => $single_product_page_positions,
),
);
foreach ( get_option( 'alg_wc_ean_frontend_positions', array( 'woocommerce_product_meta_start' ) ) as $position ) {
$position_title = ( isset( $single_product_page_positions[ $position ] ) ? $single_product_page_positions[ $position ] : $position );
$settings = array_merge( $settings, array(
array(
'desc' => sprintf( __( 'Position priority: "%s"', 'ean-for-woocommerce' ), $position_title ),
'desc_tip' => __( 'Fine-tune the position.', 'ean-for-woocommerce' ),
'id' => "alg_wc_ean_frontend_positions_priorities[{$position}]",
'default' => 10,
'type' => 'number',
),
) );
}
$settings = array_merge( $settings, array(
array(
'desc' => __( 'Variable products: Position in variation', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_frontend_variation_position',
'default' => 'product_meta',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'product_meta' => __( 'Product meta', 'ean-for-woocommerce' ),
'variation_description' => __( 'Description', 'ean-for-woocommerce' ),
),
),
array(
'title' => __( 'Shop pages', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will show EAN on shop (e.g., category) pages on frontend.', 'ean-for-woocommerce' ) . ' ' . $this->variable_products_note(),
'id' => 'alg_wc_ean_frontend_loop',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Template', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Available placeholder: %s.', 'ean-for-woocommerce' ), '%ean%' ) . '<br><br>' .
__( 'You can also use shortcodes here.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_template_loop',
'default' => alg_wc_ean()->core->get_default_template(),
'type' => 'textarea',
),
array(
'title' => __( 'Cart', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will show EAN on cart page on frontend.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_frontend_cart',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Search', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will enable searching by EAN on frontend.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_frontend_search',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( '"Flatsome" theme', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will enable searching by EAN in "Flatsome" theme\'s "LIVE SEARCH".', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_frontend_search_ajax_flatsome',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Product structured data', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_frontend_product_structured_data',
'desc_tip' => __( 'This will add EAN to the product structured data, e.g., for Google Search Console.', 'ean-for-woocommerce' ),
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => sprintf( __( '"%s" plugin', 'ean-for-woocommerce' ), __( 'Rank Math SEO', 'ean-for-woocommerce' ) ),
'desc_tip' => sprintf( __( 'This will add EAN to the product structured data generated by the %s plugin.', 'ean-for-woocommerce' ),
'<a href ="https://wordpress.org/plugins/seo-by-rank-math/" target="_blank">' . __( 'Rank Math SEO', 'ean-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_ean_frontend_product_structured_data_rank_math_seo',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Automatic key', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'If enabled, will use the key based on EAN type, i.e., %s for EAN-8, %s for UPC-A, %s for EAN-13, ISBN-13 and JAN, %s for EAN-14, and %s for all other types.', 'ean-for-woocommerce' ),
'<code>gtin8</code>', '<code>gtin12</code>', '<code>gtin13</code>', '<code>gtin14</code>', '<code>gtin</code>' ),
'id' => 'alg_wc_ean_frontend_product_structured_data_key_auto',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'desc' => __( 'Custom key', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Ignored, unless the "Automatic key" option above is disabled.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_frontend_product_structured_data_key',
'default' => 'gtin',
'type' => 'text',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_plugin_options',
),
array(
'title' => __( 'Orders & Emails', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_orders_options',
),
array(
'title' => __( 'Orders', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Add EAN to new order items meta.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_order_items_meta',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Admin order', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Add EAN to new order items meta for orders created by admin.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_order_items_meta_admin',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Order items table', 'ean-for-woocommerce' ),
'desc' => __( 'Pages', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will show EAN in order items table on <strong>pages</strong>.', 'ean-for-woocommerce' ) . ' ' .
__( 'E.g.: "thank you" (i.e., "order received") page, "view order" page (in "my account").', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_order_items_table',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Emails', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will show EAN in order items table in <strong>emails</strong>.', 'ean-for-woocommerce' ) . ' ' .
__( 'You can limit it to the specific emails in the "Emails list" option below.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_order_items_table_emails',
'default' => get_option( 'alg_wc_ean_order_items_table', 'no' ), // for the backward compatibility
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'desc' => __( 'Emails list', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Leave empty to add to all emails.', 'ean-for-woocommerce' ) . ' ' .
__( 'Ignored unless the "Emails" option above is enabled.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_order_items_table_emails_list',
'default' => array(),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => $this->get_wc_emails(),
),
array(
'desc' => __( 'Template (HTML)', 'ean-for-woocommerce' ) . '<br>' .
sprintf( __( 'Available placeholder(s): %s', 'ean-for-woocommerce' ), '<code>%ean%</code>' ),
'id' => 'alg_wc_ean_order_items_table_templates[html]',
'default' => '<ul class="wc-item-meta"><li><span class="sku_wrapper ean_wrapper">EAN: <span class="ean">%ean%</span></span></li></ul>',
'type' => 'textarea',
'css' => 'height:100px;'
),
array(
'desc' => __( 'Template (Plain text (emails only))', 'ean-for-woocommerce' ) . '<br>' .
sprintf( __( 'Available placeholder(s): %s', 'ean-for-woocommerce' ), '<code>%ean%</code>, <code>%new_line%</code>' ),
'id' => 'alg_wc_ean_order_items_table_templates[plain_text]',
'default' => '%new_line%- EAN: %ean%',
'type' => 'textarea',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_orders_options',
),
array(
'title' => __( 'REST API', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_rest_api_options',
),
array(
'title' => __( 'Products', 'ean-for-woocommerce' ),
'desc' => __( 'Add EAN to each product object in REST API responses', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'E.g.: %s', 'ean-for-woocommerce' ), '<code>https://example.com/wp-json/wc/v3/products/123</code>' ),
'id' => 'alg_wc_ean_product_rest',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Search by EAN', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'E.g.: %s', 'ean-for-woocommerce' ), '<code>https://example.com/wp-json/wc/v3/products?ean=7980441417892</code>' ) .
'<br>* ' . sprintf( __( 'Alternatively, you can enable the "Search > This will enable searching by EAN on frontend" option, and then search using the standard %s parameter:', 'ean-for-woocommerce' ),
'<code>search</code>' ) .
'<br>' . sprintf( __( 'E.g.: %s', 'ean-for-woocommerce' ), '<code>https://example.com/wp-json/wc/v3/products?search=7980441417892</code>' ),
'id' => 'alg_wc_ean_product_search_rest',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Orders', 'ean-for-woocommerce' ),
'desc' => __( 'Add EAN to each order object in REST API responses', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'E.g.: %s', 'ean-for-woocommerce' ), '<code>https://example.com/wp-json/wc/v3/orders/465</code>' ),
'id' => 'alg_wc_ean_order_items_meta_rest',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Search by EAN', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'E.g.: %s', 'ean-for-woocommerce' ), '<code>https://example.com/wp-json/wc/v3/orders?ean=7980441417892</code>' ) .
'<br>* ' . __( 'Please note that the "Orders > Add EAN to new order items meta" option must be enabled.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_order_items_meta_search_rest',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_rest_api_options',
),
array(
'title' => __( 'Notes', 'ean-for-woocommerce' ),
'desc' => implode( '<br>', array(
'<span class="dashicons dashicons-info"></span> ' . sprintf( __( 'You can also output EAN with %s shortcode.', 'ean-for-woocommerce' ),
'<code>[alg_wc_ean]</code>' ),
'<span class="dashicons dashicons-info"></span> ' . sprintf( __( 'EAN is stored in product meta with %s key. You may need this for some third-party plugins, e.g., for product import.', 'ean-for-woocommerce' ),
'<code>' . alg_wc_ean()->core->ean_key . '</code>' ),
) ),
'type' => 'title',
'id' => 'alg_wc_ean_notes',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_notes',
),
) );
return $settings;
}
}
endif;
return new Alg_WC_EAN_Settings_General();

View File

@@ -0,0 +1,159 @@
<?php
/**
* EAN for WooCommerce - Print Products Section Settings
*
* @version 4.3.0
* @since 4.3.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Print_Products' ) ) :
class Alg_WC_EAN_Settings_Print_Products extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 4.3.0
* @since 4.3.0
*/
function __construct() {
$this->id = 'print_products';
$this->desc = __( 'Print Products', 'ean-for-woocommerce' );
parent::__construct();
add_action( 'woocommerce_settings_' . 'alg_wc_ean', array( $this, 'before_table' ), 9 );
add_action( 'woocommerce_settings_' . 'alg_wc_ean', array( $this, 'after_table' ), 11 );
}
/**
* print_button.
*
* @version 4.3.0
* @since 4.3.0
*
* @see https://github.com/woocommerce/woocommerce/blob/6.7.0/plugins/woocommerce/includes/admin/views/html-admin-settings.php#L40
*/
function print_button() {
?>
<p class="submit">
<button name="save" class="button-primary woocommerce-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>"><?php esc_html_e( 'Print', 'ean-for-woocommerce' ); ?></button>
</p>
<?php
}
/**
* before_table.
*
* @version 4.3.0
* @since 4.3.0
*/
function before_table() {
global $current_section;
if ( 'print_products' === $current_section ) {
echo '<h2>' . esc_html__( 'Print Products Tool', 'ean-for-woocommerce' ) . '</h2>';
$this->print_button();
}
}
/**
* after_table.
*
* @version 4.3.0
* @since 4.3.0
*/
function after_table() {
global $current_section;
if ( 'print_products' === $current_section ) {
$this->print_button();
$GLOBALS['hide_save_button'] = true;
}
}
/**
* style.
*
* @version 4.3.0
* @since 4.3.0
*/
function style() {
?>
<style>
.form-table,
.form-table th,
.form-table td {
padding: 5px;
width: auto;
border: 1px solid #ddd;
}
.woocommerce table.form-table input[type=number] {
width: 4em;
}
</style>
<?php
}
/**
* get_settings.
*
* @version 4.3.0
* @since 4.3.0
*
* @todo (dev) pagination
* @todo (dev) `set_transient( 'alg_wc_ean_print_products_list', $products, HOUR_IN_SECONDS )`, `get_transient( 'alg_wc_ean_print_products_list' )`?
*/
function get_settings() {
$settings = array();
add_action( 'admin_footer', array( $this, 'style' ), PHP_INT_MAX );
$products = wc_get_products( array(
'limit' => -1,
'return' => 'ids',
'orderby' => 'title',
'order' => 'ASC',
'type' => array_merge( array_keys( wc_get_product_types() ), array( 'variation' ) ),
) );
$settings = array_merge( $settings, array(
array(
'type' => 'title',
'id' => 'alg_wc_ean_print_products_list_options',
),
) );
foreach ( $products as $product_id ) {
$settings = array_merge( $settings, array(
array(
'title' => sprintf( '%s (%s)',
get_the_title( $product_id ), ( '' !== ( $sku = get_post_meta( $product_id, '_sku', true ) ) ? $sku : '#' . $product_id ) ),
'type' => 'number',
'id' => "alg_wc_ean_print_products_list[{$product_id}]",
'default' => '',
'custom_attributes' => array( 'min' => 0 ),
),
) );
}
$settings = array_merge( $settings, array(
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_print_products_list_options',
),
) );
return $settings;
}
}
endif;
return new Alg_WC_EAN_Settings_Print_Products();

View File

@@ -0,0 +1,510 @@
<?php
/**
* EAN for WooCommerce - Print Section Settings
*
* @version 4.7.4
* @since 2.0.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Print' ) ) :
class Alg_WC_EAN_Settings_Print extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 2.0.0
* @since 2.0.0
*/
function __construct() {
$this->id = 'print';
$this->desc = __( 'Print', 'ean-for-woocommerce' );
parent::__construct();
}
/**
* get_settings.
*
* @version 4.7.4
* @since 2.0.0
*
* @see https://www.avery.com/templates/6879 (default margins etc.)
*
* @todo (feature) predefined templates, e.g., with `<table>`
* @todo (feature) Cell border: add customization options
* @todo (desc) "Deprecated placeholders" desc tip: remove?
* @todo (feature) `wpautop()`?
* @todo (desc) `children`: better desc?
* @todo (desc) better section desc?
* @todo (desc) Page format: better desc?
*/
function get_settings() {
$options = get_option( 'alg_wc_ean_print_barcodes_to_pdf_settings', array() );
$unit = ( isset( $options['unit'] ) ? $options['unit'] : 'in' );
$units = array(
'mm' => __( 'millimeters', 'ean-for-woocommerce' ),
'cm' => __( 'centimeters', 'ean-for-woocommerce' ),
'in' => __( 'inches', 'ean-for-woocommerce' ),
'pt' => __( 'points', 'ean-for-woocommerce' ),
);
$unit_title = $units[ $unit ];
$point_desc = __( 'A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.', 'ean-for-woocommerce' );
$pdf_page_formats = require( 'alg-wc-ean-pdf-page-formats.php' );
foreach ( $pdf_page_formats as $format_id => $format_dim ) {
// Converting from points to `$unit`
switch ( $unit ) {
case 'mm':
$format_dim_w = round( $format_dim[0] / 2.835 );
$format_dim_h = round( $format_dim[1] / 2.835 );
break;
case 'cm':
$format_dim_w = round( $format_dim[0] / 28.35, 1 );
$format_dim_h = round( $format_dim[1] / 28.35, 1 );
break;
default: // 'in'
$format_dim_w = round( $format_dim[0] / 72, 1 );
$format_dim_h = round( $format_dim[1] / 72, 1 );
}
$pdf_page_formats[ $format_id ] = "{$format_id} ({$format_dim_w} x {$format_dim_h} {$unit_title})";
}
$settings = array(
array(
'title' => __( 'Print Barcodes (PDF)', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_options',
),
array(
'title' => __( 'Print barcodes (PDF)', 'ean-for-woocommerce' ),
'desc' => '<strong>' . __( 'Enable section', 'ean-for-woocommerce' ) . '</strong>',
'desc_tip' => sprintf( __( 'This will add "Print barcodes" to the "Bulk actions" in %s.', 'ean-for-woocommerce' ),
'<a href="' . admin_url( 'edit.php?post_type=product' ) . '">' . __( 'admin products list', 'ean-for-woocommerce' ) . '</a>' ) . $this->pro_msg(),
'id' => 'alg_wc_ean_print_barcodes_to_pdf',
'default' => 'no',
'type' => 'checkbox',
'custom_attributes' => apply_filters( 'alg_wc_ean_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_options',
),
array(
'title' => __( 'General Options', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_general_options',
),
array(
'title' => __( 'Page orientation', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[page_orientation]',
'default' => 'P',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'P' => __( 'Portrait', 'ean-for-woocommerce' ),
'L' => __( 'Landscape', 'ean-for-woocommerce' ),
),
),
array(
'title' => __( 'Unit', 'ean-for-woocommerce' ),
'desc_tip' => __( 'User measure unit.', 'ean-for-woocommerce' ) . '<br><br>' .
sprintf( __( 'Used in %s options.', 'ean-for-woocommerce' ), '"' . implode( '", "', array(
__( 'Page format: Custom: Width', 'ean-for-woocommerce' ),
__( 'Page format: Custom: Height', 'ean-for-woocommerce' ),
__( 'Cell width', 'ean-for-woocommerce' ),
__( 'Cell height', 'ean-for-woocommerce' ),
__( 'Top margin', 'ean-for-woocommerce' ),
__( 'Left margin', 'ean-for-woocommerce' ),
__( 'Right margin', 'ean-for-woocommerce' ),
__( 'Page break margin', 'ean-for-woocommerce' ),
) ) . '"' ) . '<br><br>' .
'* ' . $point_desc,
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[unit]',
'default' => 'in',
'type' => 'select',
'class' => 'chosen_select',
'options' => $units,
),
array(
'title' => __( 'Page format', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[page_format]',
'default' => 'LETTER',
'type' => 'select',
'class' => 'chosen_select',
'options' => array_merge( array( 'custom' => __( 'Custom', 'ean-for-woocommerce' ) ), $pdf_page_formats ),
),
array(
'desc' => __( 'Page format: Custom: Width', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ) . '<br><br>' .
sprintf( __( 'Ignored unless "%s" option is set to "%s".', 'ean-for-woocommerce' ),
__( 'Page format', 'ean-for-woocommerce' ), __( 'Custom', 'ean-for-woocommerce' ) ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[page_format_custom_width]',
'default' => 0,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Page format: Custom: Height', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ) . '<br><br>' .
sprintf( __( 'Ignored unless "%s" option is set to "%s".', 'ean-for-woocommerce' ),
__( 'Page format', 'ean-for-woocommerce' ), __( 'Custom', 'ean-for-woocommerce' ) ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[page_format_custom_height]',
'default' => 0,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'title' => __( 'Max barcodes per page', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[per_page]',
'default' => 12,
'type' => 'number',
'custom_attributes' => array( 'min' => 1 ),
),
array(
'title' => __( 'Columns', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[columns]',
'default' => 2,
'type' => 'number',
'custom_attributes' => array( 'min' => 1 ),
),
array(
'title' => __( 'Cell', 'ean-for-woocommerce' ),
'desc' => __( 'Cell width', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[cell_width]',
'default' => 4,
'type' => 'number',
'custom_attributes' => array( 'min' => 0.000001, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Cell height', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[cell_height]',
'default' => 1.5,
'type' => 'number',
'custom_attributes' => array( 'min' => 0.000001, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Cell border', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[cell_border]',
'default' => 0,
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
0 => __( 'No', 'ean-for-woocommerce' ),
1 => __( 'Yes', 'ean-for-woocommerce' ),
),
),
array(
'desc' => __( 'Cell top margin', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[cell_margin_top]',
'default' => 0,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Cell left margin', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[cell_margin_left]',
'default' => 0,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Cell right margin', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[cell_margin_right]',
'default' => 0,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Cell bottom margin', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[cell_margin_bottom]',
'default' => 0,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Cell content alignment', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[cell_align]',
'default' => '',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'' => __( 'Default', 'ean-for-woocommerce' ),
'L' => __( 'Left', 'ean-for-woocommerce' ),
'C' => __( 'Center', 'ean-for-woocommerce' ),
'R' => __( 'Right', 'ean-for-woocommerce' ),
),
),
array(
'title' => __( 'Page margins', 'ean-for-woocommerce' ),
'desc' => __( 'Top margin', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[margin_top]',
'default' => 1.13,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Left margin', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[margin_left]',
'default' => 0.46,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Right margin', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[margin_right]',
'default' => 0.31,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'desc' => __( 'Page break (i.e., bottom) margin', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'In %s.', 'ean-for-woocommerce' ), $unit_title ) . '<br><br>' .
__( 'Distance from the bottom of the page that defines the automatic page breaking triggering limit.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[page_break_margin]',
'default' => 0.79,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'step' => 0.000001 ),
),
array(
'title' => __( 'Font', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'If you are having issues displaying your language specific letters, select "%s" font.', 'ean-for-woocommerce' ),
'DejaVu Sans (Unicode)' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[font_family]',
'default' => 'dejavusans',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'dejavusans' => 'DejaVu Sans (Unicode)',
'times' => 'Times New Roman',
'helvetica' => 'Helvetica',
'courier' => 'Courier',
),
),
array(
'title' => __( 'Font size', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[font_size]',
'default' => 11,
'type' => 'number',
'custom_attributes' => array( 'min' => 1 ),
),
array(
'title' => __( 'Template', 'ean-for-woocommerce' ),
'desc' => sprintf( '<details><summary style="%s">%s</summary>%s</details>',
'cursor: pointer; color: #2271b1;',
__( 'Available shortcodes', 'ean-for-woocommerce' ),
'<ul><li><code>' . implode( '</code></li><li><code>', array(
'[alg_wc_ean]',
'[alg_wc_ean_barcode]',
'[alg_wc_ean_barcode_2d]',
'[alg_wc_ean_product_image]',
'[alg_wc_ean_product_name]',
'[alg_wc_ean_product_price]',
'[alg_wc_ean_product_sku]',
'[alg_wc_ean_product_attr]',
'[alg_wc_ean_product_id]',
'[alg_wc_ean_product_meta]',
'[alg_wc_ean_product_function]',
) ) . '</code></li></ul>' ),
'desc_tip' => apply_filters( 'alg_wc_ean_print_barcodes_to_pdf_template_settings_desc', '' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[template]',
'default' => '[alg_wc_ean_barcode]<br>[alg_wc_ean]',
'type' => 'textarea',
'css' => 'width:100%;height:200px;',
),
array(
'title' => __( 'Style', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Defines style information (CSS) for the labels.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[style]',
'default' => '',
'type' => 'textarea',
'css' => 'width:100%;height:100px;',
),
array(
'title' => __( 'Variations', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[children]',
'default' => 'no',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'no' => __( 'Do not include', 'ean-for-woocommerce' ),
'yes' => __( 'Add', 'ean-for-woocommerce' ),
'replace' => __( 'Replace', 'ean-for-woocommerce' ),
),
),
array(
'title' => __( 'Use stock quantity', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Print separate label for each product inventory item.', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[use_qty]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_general_options',
),
);
$settings = apply_filters( 'alg_wc_ean_print_barcodes_to_pdf_general_settings', $settings, $options );
$settings = array_merge( $settings, array(
array(
'title' => __( 'Admin Options', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_admin_options',
),
array(
'title' => __( 'Print buttons', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings_print_buttons',
'default' => array( 'bulk_actions' ),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => array(
'bulk_actions' => __( 'Products > Bulk actions', 'ean-for-woocommerce' ),
'single_product' => __( 'Single product', 'ean-for-woocommerce' ),
'single_order' => __( 'Single order', 'ean-for-woocommerce' ),
),
),
array(
'desc' => sprintf( __( 'Print buttons style, e.g.: %s', 'ean-for-woocommerce' ), '<code>font-size: 40px; width: 40px; height: 40px;</code>' ),
'desc_tip' => sprintf( __( 'Applied to the "%s" and "%s" print buttons.', 'ean-for-woocommerce' ),
__( 'Single product', 'ean-for-woocommerce' ), __( 'Single order', 'ean-for-woocommerce' ) ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings_print_buttons_style',
'default' => '',
'type' => 'text',
),
array(
'desc' => __( 'Variations print buttons', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Applied to the "%s" print buttons.', 'ean-for-woocommerce' ),
__( 'Single product', 'ean-for-woocommerce' ) ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings_buttons_variations',
'default' => array( 'variations_tab' ),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => array(
'variations_tab' => __( 'Variations tab', 'ean-for-woocommerce' ),
'meta_box' => __( 'Meta box', 'ean-for-woocommerce' ),
),
),
array(
'desc' => __( 'Quantity input', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Adds quantity input field for the print buttons.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings_print_qty',
'default' => array(),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => array(
'bulk_actions' => __( 'Products > Bulk actions', 'ean-for-woocommerce' ),
'bulk_actions_each_product' => __( 'Products > Bulk actions > Each product', 'ean-for-woocommerce' ),
),
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_admin_options',
),
array(
'title' => __( 'Advanced Print Options', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_advanced_options',
),
array(
'title' => __( 'Skip products without EAN', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Skip products without EAN when generating PDF.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings_skip_empty_ean',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Use Print.js', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Use %s library for printing PDFs.', 'ean-for-woocommerce' ),
'<a href="https://printjs.crabbly.com/" target="_blank">Print.js</a>' ),
'id' => 'alg_wc_ean_print_use_print_js',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Suppress errors', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ) . ' (' . __( 'recommended', 'ean-for-woocommerce' ) . ')',
'desc_tip' => __( 'Suppress PHP errors when generating PDF.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_settings[suppress_errors]',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_advanced_options',
),
array(
'title' => __( 'Print Tools', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_tools',
),
array(
'title' => __( 'Print', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Print', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Check the box and "Save changes" to run the tool.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_tool',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Product(s)', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_tool_data[products]',
'default' => array(),
'type' => 'multiselect',
'class' => 'wc-product-search',
'options' => array(),
'custom_attributes' => array(
'data-placeholder' => esc_attr__( 'Search for a product&hellip;', 'woocommerce' ),
'data-action' => 'woocommerce_json_search_products_and_variations',
'data-allow_clear' => true,
),
),
array(
'desc' => __( 'Quantity', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_barcodes_to_pdf_tool_data[qty]',
'default' => 1,
'type' => 'number',
'placeholder' => '1',
'custom_attributes' => array( 'min' => 1 ),
),
array(
'title' => __( 'Products List', 'ean-for-woocommerce' ),
'desc' => __( 'Enable', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This will add new "Print Products" section to "WooCommerce > Settings > EAN".', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_print_products_list_section',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_print_barcodes_to_pdf_tools',
),
) );
return $settings;
}
}
endif;
return new Alg_WC_EAN_Settings_Print();

View File

@@ -0,0 +1,80 @@
<?php
/**
* EAN for WooCommerce - Section Settings
*
* @version 4.0.0
* @since 1.0.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Section' ) ) :
class Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 1.0.0
* @since 1.0.0
*/
function __construct() {
add_filter( 'woocommerce_get_sections_alg_wc_ean', array( $this, 'settings_section' ) );
add_filter( 'woocommerce_get_settings_alg_wc_ean_' . $this->id, array( $this, 'get_settings' ), PHP_INT_MAX );
}
/**
* settings_section.
*
* @version 1.0.0
* @since 1.0.0
*/
function settings_section( $sections ) {
$sections[ $this->id ] = $this->desc;
return $sections;
}
/**
* pro_msg.
*
* @version 4.0.0
* @since 2.0.0
*/
function pro_msg( $msg = 'enable this section' ) {
return apply_filters( 'alg_wc_ean_settings', '<p style="padding:15px;color:black;background-color:white;font-weight:bold;">' .
sprintf( 'You will need <a target="_blank" href="https://wpfactory.com/item/ean-for-woocommerce/">EAN for WooCommerce Pro</a> plugin version to %s.', $msg ) .
'</p>' );
}
/**
* variable_products_note.
*
* @version 2.4.0
* @since 2.0.0
*
* @todo (desc) better desc?
*/
function variable_products_note() {
return __( 'Please note that for the <strong>variable</strong> products, <strong>main</strong> product\'s EAN must be set.', 'ean-for-woocommerce' );
}
/**
* get_wc_emails.
*
* @version 3.1.0
* @since 3.1.0
*/
function get_wc_emails() {
$emails = array();
$wc_emails = WC_Emails::instance();
foreach ( $wc_emails->get_emails() as $email_id => $email ) {
$emails[ $email->id ] = $email->get_title();
}
return $emails;
}
}
endif;

View File

@@ -0,0 +1,489 @@
<?php
/**
* EAN for WooCommerce - Tools Section Settings
*
* @version 4.8.3
* @since 2.2.5
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings_Tools' ) ) :
class Alg_WC_EAN_Settings_Tools extends Alg_WC_EAN_Settings_Section {
/**
* Constructor.
*
* @version 2.2.5
* @since 2.2.5
*/
function __construct() {
$this->id = 'tools';
$this->desc = __( 'Tools', 'ean-for-woocommerce' );
parent::__construct();
}
/**
* get_product_actions_list.
*
* @version 4.4.2
* @since 2.9.0
*/
function get_product_actions_list() {
return array(
'' => __( 'Disabled', 'ean-for-woocommerce' ),
'generate' => __( 'Generate', 'ean-for-woocommerce' ),
'copy_sku' => __( 'Copy from product SKU', 'ean-for-woocommerce' ),
'copy_id' => __( 'Copy from product ID', 'ean-for-woocommerce' ),
'copy_meta' => __( 'Copy from product meta', 'ean-for-woocommerce' ),
'copy_attr' => __( 'Copy from product attribute', 'ean-for-woocommerce' ),
'assign_list' => __( 'Assign from the list', 'ean-for-woocommerce' ),
'copy_to_sku' => __( 'Copy to product SKU', 'ean-for-woocommerce' ),
'copy_to_meta' => __( 'Copy to product meta', 'ean-for-woocommerce' ),
'copy_to_attr' => __( 'Copy to product attribute', 'ean-for-woocommerce' ),
);
}
/**
* get_missing_product_cat_title.
*
* @version 3.0.0
* @since 3.0.0
*/
function get_missing_product_cat_title( $term_id ) {
return sprintf( __( 'Product category #%s', 'ean-for-woocommerce' ), $term_id );
}
/**
* get_terms.
*
* @version 3.0.0
* @since 3.0.0
*
* @todo (desc) add term ID?
*/
function get_terms( $taxonomy, $option ) {
$terms = get_option( $option, array() );
$terms = ( ! empty( $terms[ $taxonomy ] ) ? array_combine( $terms[ $taxonomy ], array_map( array( $this, "get_missing_{$taxonomy}_title" ), $terms[ $taxonomy ] ) ) : array() );
$_terms = get_terms( array( 'taxonomy' => $taxonomy, 'hide_empty' => false ) );
$_terms = ( ! empty( $_terms ) && ! is_wp_error( $_terms ) ? array_combine( wp_list_pluck( $_terms, 'term_id' ), wp_list_pluck( $_terms, 'name' ) ) : array() );
return array_replace( $terms, $_terms );
}
/**
* get_product_attributes.
*
* @version 4.6.0
* @since 3.7.2
*/
function get_product_attributes( $none_title = false, $do_add_custom = false ) {
$options = array();
$options[''] = ( $none_title ? $none_title : esc_html__( 'Disable', 'ean-for-woocommerce' ) );
if ( $do_add_custom ) {
$options['alg_wc_ean_product_attribute_custom'] = '(' . esc_html__( 'Custom', 'ean-for-woocommerce' ) . ')';
}
$taxonomies = wc_get_attribute_taxonomies();
if ( ! empty( $taxonomies ) ) {
foreach ( $taxonomies as $tax ) {
$id = esc_attr( wc_attribute_taxonomy_name( $tax->attribute_name ) );
$label = esc_html( $tax->attribute_label ? $tax->attribute_label : $tax->attribute_name );
$options[ $id ] = $label;
}
}
return $options;
}
/**
* get_settings.
*
* @version 4.8.3
* @since 2.2.5
*
* @todo (dev) Product Tools: Generate: Type: `EAN14`
* @todo (dev) `alg_wc_ean_product_bulk_actions_confirm`: better default value?
* @todo (dev) "Product tags" (similar to "Product categories")
* @todo (dev) add "Product categories" (and "Product tags") to all tools (now only in "Assign from the list")
* @todo (desc) add subsections, e.g.: "Automatic and Periodic Actions", "Bulk Actions"
* @todo (desc) Periodic action: rename?
* @todo (desc) `seed_prefix`
* @todo (desc) "Order Tools": add info about "General > Orders" options (i.e., "Add EAN to new order items meta", etc.)
* @todo (desc) better desc for all tools?
*/
function get_settings() {
$settings = array(
array(
'title' => __( 'Tools', 'ean-for-woocommerce' ),
'desc' => sprintf( __( 'Check the %s box and "Save changes" to run the tool. Please note that there is no undo for these tools.', 'ean-for-woocommerce' ),
'<span class="dashicons dashicons-admin-generic"></span>' ),
'type' => 'title',
'id' => 'alg_wc_ean_tools',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_tools',
),
array(
'title' => __( 'Product Tools', 'ean-for-woocommerce' ),
'desc' => sprintf( __( 'Please note that %s, %s and %s tools will <strong>not</strong> overwrite EANs for products with existing EANs.', 'ean-for-woocommerce' ),
'<strong>' . __( 'Generate', 'ean-for-woocommerce' ) . '</strong>',
'<strong>' . __( 'Copy', 'ean-for-woocommerce' ) . '</strong>',
'<strong>' . __( 'Assign', 'ean-for-woocommerce' ) . '</strong>' ) . ' ' .
sprintf( __( 'You can use the %s tool to clear the existing EANs before generating or copying.', 'ean-for-woocommerce' ),
'<strong>' . __( 'Delete', 'ean-for-woocommerce' ) . '</strong>' ),
'type' => 'title',
'id' => 'alg_wc_ean_tools_products',
),
array(
'title' => __( 'Generate', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Generate EAN for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[generate]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Type', 'ean-for-woocommerce' ),
'desc_tip' =>
'* ' . __( 'To generate ISBN-13, set this option to "EAN-13", and then set the "Country prefix" option to 978 or 979.', 'ean-for-woocommerce' ) . '<br><br>' .
'* ' . __( 'To generate JAN, set this option to "EAN-13", and then set the "Country prefix" option to a number in the 450-459 range or in the 490-499 range.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_generate[type]',
'default' => 'EAN13',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'EAN8' => 'EAN-8',
'UPCA' => 'UPC-A',
'EAN13' => 'EAN-13',
),
),
array(
'desc' => __( 'Country prefix (from)', 'ean-for-woocommerce' ) . ' ' .
sprintf( '<a target="_blank" title="%s" style="text-decoration:none;" href="%s">%s</a>',
__( 'List of GS1 country codes.', 'ean-for-woocommerce' ),
'https://en.wikipedia.org/wiki/List_of_GS1_country_codes',
'<span class="dashicons dashicons-external"></span>' ),
'id' => 'alg_wc_ean_tool_product_generate[prefix]',
'default' => 200,
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'max' => 999 ),
),
array(
'desc' => __( 'County prefix (to)', 'ean-for-woocommerce' ) . ' (' . __( 'optional', 'ean-for-woocommerce' ) . ')',
'desc_tip' => sprintf( __( 'If set, prefix will be generated randomly between "%s" and "%s" values.', 'ean-for-woocommerce' ),
__( 'Prefix from', 'ean-for-woocommerce' ), __( 'Prefix to', 'ean-for-woocommerce' ) ),
'id' => 'alg_wc_ean_tool_product_generate[prefix_to]',
'default' => '',
'type' => 'number',
'custom_attributes' => array( 'min' => 0, 'max' => 999 ),
),
array(
'desc' => __( 'County prefix length', 'ean-for-woocommerce' ),
'desc_tip' => __( 'For EAN-8 type only. County prefix length for other types will always be 3.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_generate[prefix_length]',
'default' => 3,
'type' => 'number',
'custom_attributes' => array( 'min' => 2, 'max' => 3 ),
),
array(
'desc' => __( 'Seed prefix', 'ean-for-woocommerce' ) . ' (' . __( 'optional', 'ean-for-woocommerce' ) . ')',
'desc_tip' => __( 'Or manufacturer code.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_generate[seed_prefix]',
'default' => '',
'type' => 'text',
'custom_attributes' => array( 'pattern' => '[0-9]+' ),
),
array(
'desc' => __( 'Seed', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Or product code.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_generate[seed_method]',
'default' => 'product_id',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'product_id' => __( 'Product ID', 'ean-for-woocommerce' ),
'counter' => __( 'Counter', 'ean-for-woocommerce' ),
),
),
array(
'desc' => __( 'Seed counter', 'ean-for-woocommerce' ) . ' (' . __( 'ignored unless "Seed" option is set to "Counter"', 'ean-for-woocommerce' ) . ')',
'id' => 'alg_wc_ean_tool_product_generate_seed_counter',
'default' => 0,
'type' => 'number',
'custom_attributes' => array( 'min' => 0 ),
),
array(
'desc' => __( 'Product attribute', 'ean-for-woocommerce' ) . ' (' . __( 'optional', 'ean-for-woocommerce' ) . ')',
'desc_tip' => __( 'If enabled, will copy the generated EAN to the selected product attribute as well.', 'ean-for-woocommerce' ) . ' (' . __( 'optional', 'ean-for-woocommerce' ) . ')',
'id' => 'alg_wc_ean_tool_product_generate[product_attribute]',
'default' => '',
'type' => 'select',
'class' => 'chosen_select',
'options' => $this->get_product_attributes(),
),
array(
'title' => __( 'Copy from product SKU', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Copy EAN from product SKU for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[copy_sku]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Copy from product ID', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Copy EAN from product ID for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[copy_id]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Copy from product meta', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Copy EAN from product meta for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[copy_meta]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => sprintf( __( 'Meta key, e.g., %s', 'ean-for-woocommerce' ), '<code>_gtin</code>' ),
'desc_tip' => __( 'Product meta key to copy from.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_copy_meta[key]',
'default' => '',
'type' => 'text',
),
array(
'desc' => __( 'Meta sub key', 'ean-for-woocommerce' ) . ' (' . __( 'optional', 'ean-for-woocommerce' ) . ')',
'desc_tip' => __( 'Optional sub key. This is used when meta was saved in an array.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_copy_meta[sub_key]',
'default' => '',
'type' => 'text',
),
array(
'title' => __( 'Copy from product attribute', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Copy EAN from product attribute for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[copy_attr]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Product attribute', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_copy_attr[product_attribute]',
'default' => '',
'type' => 'select',
'class' => 'chosen_select',
'options' => $this->get_product_attributes( __( 'Select attribute...', 'ean-for-woocommerce' ), true ),
),
array(
'desc' => __( 'Custom product attribute', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Ignored, unless the "Product attribute" option is set to "Custom".', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_copy_attr[product_attribute_custom]',
'default' => '',
'type' => 'text',
),
array(
'title' => __( 'Assign from the list', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Assign EAN from the list for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[assign_list]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Product categories', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Sets which product categories to include when assigning the EANs (i.e., all other categories will be skipped).', 'ean-for-woocommerce' ) . ' ' .
__( 'Leave blank to use all product categories.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_assign_list_settings[product_cat]',
'default' => array(),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => $this->get_terms( 'product_cat', 'alg_wc_ean_tool_product_assign_list_settings' ),
),
array(
'desc' => __( 'Reuse deleted', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Will add EANs from the deleted products to the "List" option.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_assign_list_settings[reuse_deleted]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'List', 'ean-for-woocommerce' ),
'desc_tip' => __( 'EAN list to assign from.', 'ean-for-woocommerce' ) . ' ' .
__( 'One EAN per line.', 'ean-for-woocommerce' ) . ' ' .
__( 'Used (i.e., assigned) EANs will be automatically removed from the list.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_assign_list',
'default' => '',
'type' => 'textarea',
'css' => 'height:100px;',
),
array(
'title' => __( 'Delete', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Delete all EANs for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_delete_product_meta',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Copy to product SKU', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Copy EAN to the product SKU for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[copy_to_sku]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Copy to product meta', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Copy EAN to the product meta for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[copy_to_meta]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => sprintf( __( 'Meta key, e.g.: %s, or comma-separated list of keys, e.g.: %s', 'ean-for-woocommerce' ), '<code>_gtin</code>', '<code>_gtin,_ean13</code>' ),
'desc_tip' => __( 'Product meta key to copy to.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_copy_to_meta[key]',
'default' => '',
'type' => 'text',
),
array(
'desc' => __( 'Meta sub key', 'ean-for-woocommerce' ) . ' (' . __( 'optional', 'ean-for-woocommerce' ) . ')',
'desc_tip' => __( 'Optional sub key. This is used when meta is saved in an array.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_copy_to_meta[sub_key]',
'default' => '',
'type' => 'text',
),
array(
'title' => __( 'Copy to product attribute', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Copy EAN to the product attribute for all products', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[copy_to_attr]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'desc' => __( 'Product attribute', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_copy_to_attr[product_attribute]',
'default' => '',
'type' => 'select',
'class' => 'chosen_select',
'options' => $this->get_product_attributes( __( 'Select attribute...', 'ean-for-woocommerce' ) ),
),
array(
'title' => __( 'Get stats', 'ean-for-woocommerce' ),
'desc_tip' => __( 'This tool will not assign/delete any EANs, instead it will count how many products in your shop do not have EAN.', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Get stats', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product[get_stats]',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Variable products', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Sets how variable products should be handled in all product tools.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_variable',
'default' => 'all',
'type' => 'select',
'class' => 'chosen_select',
'options' => array(
'all' => __( 'All (variable and variations)', 'ean-for-woocommerce' ),
'variations_only' => __( 'Variations only', 'ean-for-woocommerce' ),
'variable_only' => __( 'Variable only', 'ean-for-woocommerce' ),
),
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_tools_products',
),
array(
'title' => __( 'Product Actions', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_tools_products_actions',
),
array(
'title' => __( 'Automatic actions', 'ean-for-woocommerce' ),
'desc' => __( 'New product', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Sets actions to be automatically performed when new product is added.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_action_on_new',
'default' => '',
'type' => 'select',
'class' => 'chosen_select',
'options' => $this->get_product_actions_list(),
),
array(
'desc' => __( 'Update product', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Sets actions to be automatically performed when product is updated.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_product_action_on_update',
'default' => '',
'type' => 'select',
'class' => 'chosen_select',
'options' => $this->get_product_actions_list(),
),
array(
'title' => __( 'Periodic action', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Sets action to be automatically performed on a periodic basis (for all products).', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_products_periodic_action',
'default' => '',
'type' => 'select',
'class' => 'chosen_select',
'options' => $this->get_product_actions_list(),
),
array(
'desc' => __( 'Periodic action interval in seconds', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_products_periodic_action_interval',
'default' => 3600,
'type' => 'number',
'custom_attributes' => array( 'min' => 1 ),
),
array(
'title' => __( '"Products > Bulk actions"', 'ean-for-woocommerce' ),
'desc_tip' => __( 'Sets actions to be added to the "Products > Bulk actions" dropdown.', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_product_bulk_actions',
'default' => array( 'alg_wc_ean_delete', 'alg_wc_ean_generate' ),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => array(
'alg_wc_ean_generate' => __( 'Generate EAN', 'ean-for-woocommerce' ),
'alg_wc_ean_delete' => __( 'Delete EAN', 'ean-for-woocommerce' ),
),
),
array(
'desc' => __( 'Require confirmation?', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_product_bulk_actions_confirm',
'default' => array( 'alg_wc_ean_delete' ),
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => array(
'alg_wc_ean_generate' => __( 'Generate EAN', 'ean-for-woocommerce' ),
'alg_wc_ean_delete' => __( 'Delete EAN', 'ean-for-woocommerce' ),
),
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_tools_products_actions',
),
array(
'title' => __( 'Order Tools', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_ean_tools_orders',
),
array(
'title' => __( 'Add', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Add EANs to all order items', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_orders_add',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Delete', 'ean-for-woocommerce' ),
'desc' => '<span class="dashicons dashicons-admin-generic"></span> ' . __( 'Delete EANs from all order items', 'ean-for-woocommerce' ),
'id' => 'alg_wc_ean_tool_orders_delete',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ean_tools_orders',
),
);
return $settings;
}
}
endif;
return new Alg_WC_EAN_Settings_Tools();

View File

@@ -0,0 +1,197 @@
<?php
/**
* EAN for WooCommerce - Settings
*
* @version 4.3.0
* @since 1.0.0
*
* @author Algoritmika Ltd
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Alg_WC_EAN_Settings' ) ) :
class Alg_WC_EAN_Settings extends WC_Settings_Page {
/**
* Constructor.
*
* @version 4.3.0
* @since 1.0.0
*/
function __construct() {
$this->id = 'alg_wc_ean';
$this->label = apply_filters( 'alg_wc_ean_settings_page_label', __( 'EAN', 'ean-for-woocommerce' ) );
parent::__construct();
// Sections
require_once( 'class-alg-wc-ean-settings-section.php' );
// Sections: EAN
require_once( 'class-alg-wc-ean-settings-general.php' );
require_once( 'class-alg-wc-ean-settings-tools.php' );
require_once( 'class-alg-wc-ean-settings-compatibility.php' );
// Sections: Barcodes
require_once( 'class-alg-wc-ean-settings-barcodes.php' );
require_once( 'class-alg-wc-ean-settings-barcodes-compatibility.php' );
new Alg_WC_EAN_Settings_Barcodes( '1d' );
new Alg_WC_EAN_Settings_Barcodes_Compatibility( '1d' );
new Alg_WC_EAN_Settings_Barcodes( '2d' );
new Alg_WC_EAN_Settings_Barcodes_Compatibility( '2d' );
// Sections: Print
require_once( 'class-alg-wc-ean-settings-print.php' );
if ( 'yes' === get_option( 'alg_wc_ean_print_products_list_section', 'no' ) && 'yes' === get_option( 'alg_wc_ean_print_barcodes_to_pdf', 'no' ) ) {
require_once( 'class-alg-wc-ean-settings-print-products.php' );
}
// Sections: Advanced
require_once( 'class-alg-wc-ean-settings-advanced.php' );
// Sections: Extra fields
require_once( 'class-alg-wc-ean-settings-extra-fields.php' );
require_once( 'class-alg-wc-ean-settings-extra-field.php' );
for ( $i = 1; $i <= get_option( 'alg_wc_ean_extra_fields_num_total', 0 ); $i++ ) {
new Alg_WC_EAN_Settings_Extra_Field( $i );
}
// Custom fields
add_action( 'woocommerce_admin_field_' . 'alg_wc_ean_file', array( $this, 'alg_wc_ean_file' ) );
}
/**
* alg_wc_ean_file.
*
* @version 3.1.0
* @since 3.1.0
*
* @see https://github.com/woocommerce/woocommerce/blob/6.1.1/plugins/woocommerce/includes/admin/class-wc-admin-settings.php#L720
*/
function alg_wc_ean_file( $value ) {
// Custom attribute handling.
$custom_attributes = array();
if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
}
}
// Description handling.
$field_description = WC_Admin_Settings::get_field_description( $value );
$description = $field_description['description'];
$tooltip_html = $field_description['tooltip_html'];
?><tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
</th>
<td class="forminp forminp-file">
<input
name="<?php echo esc_attr( $value['id'] ); ?>"
id="<?php echo esc_attr( $value['id'] ); ?>"
type="file"
style="<?php echo esc_attr( $value['css'] ); ?>"
value=""
class="<?php echo esc_attr( $value['class'] ); ?>"
placeholder=""
<?php echo implode( ' ', $custom_attributes ); // WPCS: XSS ok. ?>
/><?php echo esc_html( $value['suffix'] ); ?> <?php echo $description; // WPCS: XSS ok. ?>
</td>
</tr>
<?php
}
/**
* get_settings.
*
* @version 4.3.0
* @since 1.0.0
*/
function get_settings() {
global $current_section;
$reset_settings = ( 'print_products' === $current_section ? array() : array(
array(
'title' => __( 'Reset Settings', 'ean-for-woocommerce' ),
'type' => 'title',
'id' => $this->id . '_' . $current_section . '_reset_options',
),
array(
'title' => __( 'Reset section settings', 'ean-for-woocommerce' ),
'desc' => '<strong>' . __( 'Reset', 'ean-for-woocommerce' ) . '</strong>',
'desc_tip' => __( 'Check the box and save changes to reset.', 'ean-for-woocommerce' ),
'id' => $this->id . '_' . $current_section . '_reset',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => $this->id . '_' . $current_section . '_reset_options',
),
) );
return array_merge( apply_filters( 'woocommerce_get_settings_' . $this->id . '_' . $current_section, array() ), $reset_settings );
}
/**
* maybe_reset_settings.
*
* @version 1.0.0
* @since 1.0.0
*/
function maybe_reset_settings() {
global $current_section;
if ( 'yes' === get_option( $this->id . '_' . $current_section . '_reset', 'no' ) ) {
foreach ( $this->get_settings() as $value ) {
if ( isset( $value['id'] ) ) {
$id = explode( '[', $value['id'] );
delete_option( $id[0] );
}
}
add_action( 'admin_notices', array( $this, 'admin_notices_settings_reset_success' ), PHP_INT_MAX );
}
}
/**
* admin_notices_settings_reset_success.
*
* @version 1.0.0
* @since 1.0.0
*/
function admin_notices_settings_reset_success() {
echo '<div class="notice notice-success is-dismissible"><p><strong>' .
__( 'Your settings have been reset.', 'ean-for-woocommerce' ) . '</strong></p></div>';
}
/**
* save.
*
* @version 4.3.0
* @since 1.0.0
*
* @todo (dev) `wp_safe_redirect`: better solution?
*/
function save() {
global $current_section;
parent::save();
$this->maybe_reset_settings();
do_action( 'alg_wc_ean_settings_saved', $current_section );
if ( 'print' === $current_section || 'advanced' === $current_section || 'extra_field' === substr( $current_section, 0, strlen( 'extra_field' ) ) ) {
wp_safe_redirect( add_query_arg( array() ) );
exit;
}
}
}
endif;
return new Alg_WC_EAN_Settings();