Skip to content

Commit 76c7509

Browse files
committed
initial commit
1 parent 4f626a6 commit 76c7509

22 files changed

+1885
-0
lines changed

Gruntfile.js

+216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
/* jshint node:true */
2+
module.exports = function( grunt ){
3+
'use strict';
4+
5+
grunt.initConfig({
6+
7+
pkg: grunt.file.readJSON('package.json'),
8+
9+
// setting folder templates
10+
dirs: {
11+
css: 'assets/css',
12+
js: 'assets/js'
13+
},
14+
15+
// Compile all .less files.
16+
less: {
17+
compile: {
18+
options: {
19+
// These paths are searched for @imports
20+
paths: ['<%= dirs.css %>/']
21+
},
22+
files: [{
23+
expand: true,
24+
cwd: '<%= dirs.css %>/',
25+
src: [
26+
'*.less',
27+
'!mixins.less'
28+
],
29+
dest: '<%= dirs.css %>/',
30+
ext: '.css'
31+
}]
32+
}
33+
},
34+
35+
// Minify all .css files.
36+
cssmin: {
37+
minify: {
38+
expand: true,
39+
cwd: '<%= dirs.css %>/',
40+
src: ['*.css'],
41+
dest: '<%= dirs.css %>/',
42+
ext: '.css'
43+
}
44+
},
45+
46+
// Minify .js files.
47+
uglify: {
48+
options: {
49+
preserveComments: 'some'
50+
},
51+
jsfiles: {
52+
files: [{
53+
expand: true,
54+
cwd: '<%= dirs.js %>/',
55+
src: [
56+
'*.js',
57+
'!*.min.js',
58+
'!Gruntfile.js',
59+
],
60+
dest: '<%= dirs.js %>/',
61+
ext: '.min.js'
62+
}]
63+
}
64+
},
65+
66+
// Watch changes for assets
67+
watch: {
68+
less: {
69+
files: ['<%= dirs.css %>/*.less'],
70+
tasks: ['less', 'cssmin'],
71+
},
72+
js: {
73+
files: [
74+
'<%= dirs.js %>/*js',
75+
'!<%= dirs.js %>/*.min.js'
76+
],
77+
tasks: ['uglify']
78+
}
79+
},
80+
81+
// Create .pot files
82+
makepot: {
83+
dist: {
84+
options: {
85+
domainPath: '/languages/',
86+
exclude: [
87+
'node_modules/.*',
88+
'build/.*'
89+
],
90+
potFilename: 'tracking-la-poste-for-woocommerce.pot',
91+
type: 'wp-plugin',
92+
potHeaders: {
93+
'language': 'en',
94+
'plural-forms': 'nplurals=2; plural=(n != 1);',
95+
'x-poedit-country': 'United States',
96+
'x-poedit-sourcecharset': 'UTF-8',
97+
'x-poedit-keywordslist': '__;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c;_nc:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;',
98+
'x-poedit-basepath': '../',
99+
'x-poedit-searchpath-0': '.',
100+
'x-poedit-bookmarks': '',
101+
'x-textdomain-support': 'yes',
102+
'report-msgid-bugs-to': 'https://remicorson.com',
103+
'language-team': 'YOUR TEAM <YOUR-EMAIL@ADDRESS>'
104+
}
105+
}
106+
}
107+
},
108+
109+
// Check the textdomain
110+
checktextdomain: {
111+
options:{
112+
text_domain: 'tracking-la-poste-for-woocommerce',
113+
keywords: [
114+
'__:1,2d',
115+
'_e:1,2d',
116+
'_x:1,2c,3d',
117+
'esc_html__:1,2d',
118+
'esc_html_e:1,2d',
119+
'esc_html_x:1,2c,3d',
120+
'esc_attr__:1,2d',
121+
'esc_attr_e:1,2d',
122+
'esc_attr_x:1,2c,3d',
123+
'_ex:1,2c,3d',
124+
'_n:1,2,4d',
125+
'_nx:1,2,4c,5d',
126+
'_n_noop:1,2,3d',
127+
'_nx_noop:1,2,3c,4d'
128+
]
129+
},
130+
files: {
131+
src: [
132+
'**/*.php', // Include all files
133+
'!node_modules/**', // Exclude node_modules/
134+
'!build/.*' // Exclude build/
135+
],
136+
expand: true
137+
}
138+
},
139+
140+
// Clean up build directory
141+
clean: {
142+
main: ['build/<%= pkg.name %>']
143+
},
144+
145+
// Copy into the build directory
146+
copy: {
147+
main: {
148+
expand: true,
149+
src: [
150+
'**',
151+
'!node_modules/**',
152+
'!build/**',
153+
'!Gruntfile.js',
154+
'!package.json',
155+
'!**/Gruntfile.js',
156+
'!**/package.json',
157+
'!<%= dirs.css %>/*.less',
158+
'!**/*~'
159+
],
160+
dest: 'build/<%= pkg.name %>/',
161+
},
162+
},
163+
164+
//Compress build directory into <name>.zip and <name>-<version>.zip
165+
compress: {
166+
main: {
167+
options: {
168+
mode: 'zip',
169+
archive: './build/<%= pkg.name %>-<%= pkg.version %>.zip'
170+
},
171+
expand: true,
172+
cwd: 'build/<%= pkg.name %>/',
173+
src: ['**/*'],
174+
dest: '<%= pkg.name %>/'
175+
}
176+
},
177+
178+
});
179+
180+
// Load NPM tasks to be used here
181+
grunt.loadNpmTasks( 'grunt-wp-i18n' );
182+
grunt.loadNpmTasks( 'grunt-contrib-less' );
183+
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
184+
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
185+
grunt.loadNpmTasks( 'grunt-contrib-watch' );
186+
grunt.loadNpmTasks( 'grunt-checktextdomain' );
187+
grunt.loadNpmTasks( 'grunt-contrib-clean' );
188+
grunt.loadNpmTasks( 'grunt-contrib-copy' );
189+
grunt.loadNpmTasks( 'grunt-contrib-compress' );
190+
191+
// Register tasks
192+
grunt.registerTask( 'default', [
193+
'less',
194+
'cssmin',
195+
'uglify'
196+
] );
197+
198+
// Just an alias for pot file generation
199+
grunt.registerTask( 'pot', [
200+
'makepot'
201+
] );
202+
203+
// Build task(s).
204+
grunt.registerTask( 'build', [
205+
'clean',
206+
'copy',
207+
'compress',
208+
'build-clean'
209+
] );
210+
211+
// Build-clean task(s).
212+
grunt.registerTask( 'build-clean', [
213+
'clean'
214+
] );
215+
216+
};

assets/css/admin.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/admin.js

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
jQuery( function( $ ) {
3+
4+
var WC_La_Poste_Tracking_items = {
5+
6+
// init Class
7+
init: function() {
8+
$( '#tracking-la-poste-for-woocommerce' )
9+
.on( 'click', 'a.delete-tracking', this.delete_tracking )
10+
.on( 'click', 'button.button-show-form', this.show_form )
11+
.on( 'click', 'button.button-save-form', this.save_form );
12+
},
13+
14+
// When a user enters a new tracking item
15+
save_form: function () {
16+
17+
if ( !$( 'input#tracking_number' ).val() ) {
18+
return false;
19+
}
20+
21+
$( '#la-poste-tracking-form' ).block( {
22+
message: null,
23+
overlayCSS: {
24+
background: '#fff',
25+
opacity: 0.6
26+
}
27+
} );
28+
29+
var data = {
30+
action: 'WC_La_Poste_Tracking_save_form',
31+
order_id: woocommerce_admin_meta_boxes.post_id,
32+
tracking_number: $( 'input#tracking_number' ).val(),
33+
date_shipped: $( 'input#date_shipped' ).val(),
34+
security: $( '#WC_La_Poste_Tracking_create_nonce' ).val()
35+
};
36+
37+
38+
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
39+
$( '#la-poste-tracking-form' ).unblock();
40+
if ( response != '-1' ) {
41+
$( '#la-poste-tracking-form' ).hide();
42+
$( '#tracking-la-poste-for-woocommerce #tracking-items' ).append( response );
43+
$( '#tracking-la-poste-for-woocommerce button.button-show-form' ).show();
44+
$( 'input#tracking_number' ).val( '' );
45+
$( 'input#date_shipped' ).val( '' );
46+
}
47+
});
48+
49+
return false;
50+
},
51+
52+
// Show the new tracking item form
53+
show_form: function () {
54+
$( '#la-poste-tracking-form' ).show();
55+
$( '#tracking-la-poste-for-woocommerce button.button-show-form' ).hide();
56+
},
57+
58+
// Delete a tracking item
59+
delete_tracking: function() {
60+
61+
var tracking_id = $( this ).attr( 'rel' );
62+
63+
$( '#tracking-item-' + tracking_id ).block({
64+
message: null,
65+
overlayCSS: {
66+
background: '#fff',
67+
opacity: 0.6
68+
}
69+
});
70+
71+
var data = {
72+
action: 'WC_La_Poste_Tracking_delete_item',
73+
order_id: woocommerce_admin_meta_boxes.post_id,
74+
tracking_id: tracking_id,
75+
security: $( '#WC_La_Poste_Tracking_delete_nonce' ).val()
76+
};
77+
78+
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
79+
$( '#tracking-item-' + tracking_id ).unblock();
80+
if ( response != '-1' ) {
81+
$( '#tracking-item-' + tracking_id ).remove();
82+
}
83+
});
84+
85+
return false;
86+
}
87+
}
88+
89+
WC_La_Poste_Tracking_items.init();
90+
91+
} );

assets/js/admin.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

changelog.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*** Tracking La Poste for WooCommerce Changelog ***
2+
3+
2016.11.17 - version 1.0
4+
* Initial release
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/**
4+
* WooCommerce Shipoment Tracking compats handler.
5+
*
6+
* @since 1.01.6.0
7+
*/
8+
9+
class WC_La_Poste_Tracking_Compat {
10+
11+
/**
12+
* Load compat classes and instantiate it.
13+
*/
14+
public function load_compats() {
15+
16+
// Load built-in compat classes.
17+
require_once( 'compats/class-wc-la-poste-tracking-pip-compat.php' );
18+
require_once( 'compats/class-wc-la-poste-tracking-order-xml-export-compat.php' );
19+
20+
$compats = array(
21+
'WC_La_Poste_Tracking_PIP_Compat',
22+
'WC_La_Poste_Tracking_XML_Export_Compat',
23+
);
24+
25+
/**
26+
* Filters the La Poste tracking compats.
27+
*
28+
* @since 1.01.6.0
29+
*
30+
* @param array $compats List of class names that provide compatibilities
31+
* with WooCommerce La Poste Tracking
32+
*/
33+
$compats = apply_filters( 'WC_La_Poste_Tracking_compats', $compats );
34+
35+
foreach ( $compats as $compat ) {
36+
if ( class_exists( $compat ) ) {
37+
new $compat();
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)