Facebook for WooCommerce - Version 1.9.11

Version Description

  • 2019-02-26 =
  • changing contributor to facebook from facebook4woocommerce, so that woo plugin will be shown under https://profiles.wordpress.org/facebook/#content-plugins
  • adding changelog in readme.txt so that notifications will be sent for updates and changelog will be shown under https://wordpress.org/plugins/facebook-for-woocommerce/#developers
  • removing debug flags notice under facebook-for-woocommerce.php so that developers will be able to debug with debug logs
Download this release

Release Info

Developer facebook4woocommerce
Plugin Icon Facebook for WooCommerce
Version 1.9.11
Comparing to
See all releases

Version 1.9.11

CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,5 @@
1
+ # Code of Conduct
2
+
3
+ Facebook has adopted a Code of Conduct that we expect project participants to adhere to.
4
+ Please read the [full text](https://code.fb.com/codeofconduct/)
5
+ so that you can understand what actions will and will not be tolerated.
CONTRIBUTING.md ADDED
@@ -0,0 +1,35 @@
1
+ # Contributing to Facebook for WooCommerce
2
+ We want to make contributing to this project as easy and transparent as
3
+ possible.
4
+
5
+ ## Pull Requests
6
+ We actively welcome your pull requests.
7
+
8
+ 1. Fork the repo and create your branch from `master`.
9
+ 2. If you've added code that should be tested, add tests.
10
+ 3. If you've changed APIs, update the documentation.
11
+ 4. Make sure your code lints.
12
+ 5. If you haven't already, complete the Contributor License Agreement ("CLA").
13
+
14
+ ## Contributor License Agreement ("CLA")
15
+ In order to accept your pull request, we need you to submit a CLA. You only need
16
+ to do this once to work on any of Facebook's open source projects.
17
+
18
+ Complete your CLA here: <https://code.facebook.com/cla>
19
+
20
+ ## Issues
21
+ We use GitHub issues to track public bugs. Please ensure your description is
22
+ clear and has sufficient instructions to be able to reproduce the issue.
23
+
24
+ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
25
+ disclosure of security bugs. In those cases, please go through the process
26
+ outlined on that page and do not file a public issue.
27
+
28
+ ## Coding Style
29
+ * 4 spaces for indentation rather than tabs
30
+ * 80 character line length
31
+
32
+ ## License
33
+ By contributing to Facebook for WooCommerce, you agree that your contributions
34
+ will be licensed under the LICENSE file in the root directory of
35
+ this source tree.
LICENSE ADDED
@@ -0,0 +1,339 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
assets/css/facebook-infobanner.css ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+ #fbinfobanner .btn {
10
+ /* container: */
11
+ background-color: rgb(86,120,227);
12
+ border: 1px solid;
13
+ border-color: #435a8b #3c5488 #334c83;
14
+ border-radius: 2px;
15
+ padding: 5px 10px 5px 10px;
16
+ /* Get started: */
17
+ font-family: helvetica, arial, sans-serif;
18
+ font-size: 12px;
19
+ font-weight: 600;
20
+ color: #FFFFFF;
21
+ text-align: center;
22
+ text-decoration: none;
23
+ display: inline-block;
24
+ margin: 5px 10px 1px 1px;
25
+ }
26
+
27
+ #fbinfobanner .btn.dismiss {
28
+ margin: 5px 10px 5px 1px;
29
+ }
30
+
31
+ #fbinfobanner .btn.grey{
32
+ background: #f6f7f8;
33
+ border-color: #e0e1e2;
34
+ color: #4e5665;
35
+ }
36
+
37
+ #fbinfobanner .iconDetails {
38
+ margin: 5px 10px 5px 3px;
39
+ float:left;
40
+ height:50px;
41
+ width:50px;
42
+ }
43
+
44
+ #fbinfobanner .tipTitle {
45
+ padding: 1px 12px 1px 20px;
46
+ font-size: 14px;
47
+ }
48
+
49
+ #fbinfobanner .tipContent {
50
+ padding: 1px 12px 1px 20px;
51
+ font-size: 14px;
52
+ }
53
+
54
+ #fbinfobanner .tipButton {
55
+ margin-bottom: 0px;
56
+ }
assets/css/facebook.css ADDED
@@ -0,0 +1,274 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+ #fbsetup .wrapper {
10
+ box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
11
+ display: block;
12
+ width: 600px;
13
+ background: white url(../image/small-store.png) no-repeat;
14
+ background-position-x: 92%;
15
+ background-position-y: 172px;
16
+ background-size: 180px;
17
+ }
18
+
19
+ #fbsetup .wrapper .help-center {
20
+ float: right;
21
+ margin-top: -23px;
22
+ }
23
+
24
+ #fbsetup .wrapper .help-center a {
25
+ color: white;
26
+ }
27
+
28
+ #fbsetup .wrapper .help-center-icon {
29
+ display: inline-block;
30
+ background-image: url(../image/help-center.png);
31
+ background-size: 38px 38px;
32
+ background-repeat: no-repeat;
33
+ width: 38px;
34
+ height: 38px;
35
+ zoom: 0.7;
36
+ top: 12px;
37
+ position: relative;
38
+ }
39
+
40
+ #fbsetup .content {
41
+ padding: 10px 30px 20px 30px;
42
+ }
43
+
44
+ #fbsetup .loader {
45
+ border: 4px solid #f3f3f3; /* Light grey */
46
+ border-top: 4px solid #3498db; /* Blue */
47
+ border-radius: 50%;
48
+ width: 20px;
49
+ height: 20px;
50
+ animation: spin 2s linear infinite;
51
+ }
52
+ @keyframes spin {
53
+ 0% { transform: rotate(0deg); }
54
+ 100% { transform: rotate(360deg); }
55
+ }
56
+
57
+ #fbsetup .btn {
58
+ /* container: */
59
+ background-color: rgb(86,120,227);
60
+ border: 1px solid;
61
+ border-color: #435a8b #3c5488 #334c83;
62
+ border-radius: 2px;
63
+ padding: 10px 20px;
64
+ /* Get started: */
65
+ font-family: helvetica, arial, sans-serif;
66
+ font-size: 12px;
67
+ font-weight: 550;
68
+ color: #FFFFFF;
69
+ text-align: center;
70
+ text-decoration: none;
71
+ display: inline-block;
72
+ letter-spacing: 0.2px;
73
+ margin: 0px 12px 10px 0px;
74
+ width: 60px;
75
+ }
76
+
77
+ #fbsetup .btn.grey{
78
+ background: #f6f7f8;
79
+ border-color: #e0e1e2;
80
+ color: #4e5665;
81
+ width: 75px;
82
+ }
83
+
84
+ #fbsetup .btn.pre-setup{
85
+ font-size: 13px;
86
+ width: 80px;
87
+ }
88
+
89
+ #fbsetup header {
90
+ display: block;
91
+ background: url(../image/facebook.png) no-repeat #4267B2;
92
+ background-position: 20px center;
93
+ background-size: 100px 19px;
94
+ padding: 20px;
95
+ }
96
+ #fbsetup h1 {
97
+ /* title: */
98
+ font-family: arial;
99
+ font-size: 18px;
100
+ font-weight: bold;
101
+ color: #141823;
102
+ margin-top: 12px;
103
+ width: 400px;
104
+ }
105
+ #fbsetup p {
106
+ /* copy: */
107
+ font-family: Helvetica;
108
+ font-size: 12px;
109
+ color: #1D2129;
110
+ margin: 10px 0px 14px 0px;
111
+ }
112
+ #fbsetup h2 {
113
+ color: rgb(0,0,0);
114
+ font-size: 14px;
115
+ font-weight: normal;
116
+ line-height: 18px;
117
+ margin-bottom: 6px;
118
+ margin-top: 12px;
119
+ width: 520px;
120
+ }
121
+ #fbsetup ul {
122
+ list-style-type: disc;
123
+ margin: 10px 10px 15px 19px;
124
+ }
125
+ #fbsetup li {
126
+ margin: 2px 0px;
127
+ padding-left: 8px;
128
+ }
129
+ #fbsetup .nux-message {
130
+ box-sizing: border-box;
131
+ color: #fff;
132
+ overflow: hidden;
133
+ padding: 9px;
134
+ position: absolute;
135
+ text-align: left;
136
+ transform: translateZ(0);
137
+ transition: all 200ms cubic-bezier(.08,.52,.52,1);
138
+ z-index: 5;
139
+ }
140
+ #fbsetup .nux-message .nux-message-text {
141
+ background: #3578e5;
142
+ border-radius: 3px;
143
+ box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
144
+ box-sizing: border-box;
145
+ padding: 10px 34px 12px 10px;
146
+ white-space: normal;
147
+ min-width: 252px;
148
+ }
149
+ #fbsetup .nux-message .nux-message-close-btn {
150
+ cursor: pointer;
151
+ position: absolute;
152
+ right: 19px;
153
+ top: 19px;
154
+ height: 12px;
155
+ width: 12px;
156
+ font-style: normal;
157
+ color: #ccc;
158
+ }
159
+ #fbsetup .nux-message .nux-message-close-btn:hover {
160
+ color: #fff;
161
+ }
162
+ #fbsetup .nux-message .nux-message-arrow {
163
+ border-right: 9px solid #3578e5;
164
+ left: 0;
165
+ position: absolute;
166
+ border-bottom: 9px solid transparent;
167
+ border-top: 9px solid transparent;
168
+ margin-top: -9px;
169
+ top: 50%;
170
+ }
171
+ #fbsetup .settings-section {
172
+ display: inline-block;
173
+ min-width: 45%;
174
+ max-width: 45%;
175
+ margin-right: 8px;
176
+ vertical-align: top;
177
+ }
178
+ #fbsetup .settings-section h1 {
179
+ color: rgb(126,129,136);
180
+ font-size: 14px;
181
+ margin-top: 0px;
182
+ width: auto;
183
+ }
184
+ #fbsetup .settings-section h2 {
185
+ color: rgb(126,129,136);
186
+ font-size: 14px;
187
+ margin-top: 2px;
188
+ width: auto;
189
+ }
190
+ #fbsetup .settings-section .btn.small {
191
+ background: #f6f7f8;
192
+ border-color: #e0e1e2;
193
+ color: #4e5665;
194
+ height: 20px;
195
+ margin-top: 10px;
196
+ padding: 2px 6px;
197
+ width: auto;
198
+ }
199
+ .tooltip {
200
+ position: relative;
201
+ border-bottom: 1px dotted black;
202
+ /* container: */
203
+ border: 1px solid;
204
+ border-radius: 2px;
205
+ /* Launch Test: */
206
+ font-size: 12px;
207
+ font-weight: 550;
208
+ color: #FFFFFF;
209
+ text-align: center;
210
+ text-decoration: none;
211
+ display: inline-block;
212
+ letter-spacing: 0.2px;
213
+ margin: 0px 12px 10px 0px;
214
+ background: #f6f7f8;
215
+ border-color: #e0e1e2;
216
+ color: #4e5665;
217
+ height: 20px;
218
+ margin-top: 10px;
219
+ padding: 2px 6px;
220
+ width: auto;
221
+ }
222
+ .tooltip .tooltiptext {
223
+ color: black;
224
+ font-size: 13px;
225
+ padding: 5px 0;
226
+ text-align: justify;
227
+ visibility: hidden;
228
+ width: 400px;
229
+ /* Position the tooltip */
230
+ position: absolute;
231
+ z-index: 1;
232
+ top: 100%;
233
+ left: 50%;
234
+ margin-left: -60px;
235
+ }
236
+ .tooltip:hover .tooltiptext {
237
+ visibility: visible;
238
+ opacity: 1;
239
+ }
240
+ #fbsetup a {
241
+ text-decoration: none;
242
+ }
243
+
244
+ #fbAdvancedOptionsText {
245
+ color: rgb(69, 114, 169);
246
+ font-size: 14px;
247
+ font-family: Helvetica;
248
+ padding: 8px 0px 8px 0px;
249
+ }
250
+
251
+ #fbAdvancedOptions {
252
+ color: rgb(126,129,136);
253
+ font-size: 12px;
254
+ font-family: Helvetica;
255
+ display: none;
256
+ padding: 8px 4px 8px 4px;
257
+ }
258
+
259
+ #fbAdvancedOptions .autosyncSavedNotice {
260
+ color: green;
261
+ font-size: 10px;
262
+ display: none;
263
+ }
264
+
265
+ #fbAdvancedOptions div {
266
+ padding: 4px 4px 4px 4px;
267
+ }
268
+
269
+ .autosyncTime {
270
+ padding: 0px;
271
+ font-family: Helvetica;
272
+ font-size: 12px;
273
+ height: 18px;
274
+ }
assets/image/FB-f-Logo__blue_29.png ADDED
Binary file
assets/image/facebook.png ADDED
Binary file
assets/image/help-center.png ADDED
Binary file
assets/image/small-store.png ADDED
Binary file
assets/js/facebook-infobanner.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+ /*
10
+ * Ajax helper function.
11
+ * Takes optional payload for POST and optional callback.
12
+ */
13
+ function ajax(action, payload = null, callback = null, failcallback = null) {
14
+ var data = {
15
+ 'action': action,
16
+ };
17
+ if (payload){
18
+ for (var attrname in payload) { data[attrname] = payload[attrname]; }
19
+ }
20
+
21
+ // Since Wordpress 2.8 ajaxurl is always defined in admin header and
22
+ // points to admin-ajax.php
23
+ jQuery.post(ajaxurl, data, function(response) {
24
+ if(callback) {
25
+ callback(response);
26
+ }
27
+ }).fail(function(errorResponse){
28
+ if(failcallback) {
29
+ failcallback(errorResponse);
30
+ }
31
+ });
32
+ }
33
+
34
+ function fb_woo_infobanner_post_click(){
35
+ console.log("Woo infobanner post tip click!");
36
+ return ajax('ajax_woo_infobanner_post_click');
37
+ }
38
+
39
+ function fb_woo_infobanner_post_xout() {
40
+ console.log("Woo infobanner post tip xout!");
41
+ return ajax('ajax_woo_infobanner_post_xout');
42
+ }
assets/js/facebook-metabox.js ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+
10
+ /*
11
+ * Ajax helper function.
12
+ * Takes optional payload for POST and optional callback.
13
+ */
14
+ function ajax(action, payload = null, cb = null, failcb = null) {
15
+ var data = {
16
+ 'action': action,
17
+ };
18
+ if (payload){
19
+ for (var attrname in payload) { data[attrname] = payload[attrname]; }
20
+ }
21
+
22
+ // Since Wordpress 2.8 ajaxurl is always defined in admin header and
23
+ // points to admin-ajax.php
24
+ jQuery.post(ajaxurl, data, function(response) {
25
+ if(cb) {
26
+ cb(response);
27
+ }
28
+ }).fail(function(errorResponse){
29
+ if(failcb) {
30
+ failcb(errorResponse);
31
+ }
32
+ });
33
+ }
34
+
35
+ function fb_reset_product(wp_id) {
36
+ if(confirm('Resetting Facebook metadata will not remove this product from your shop. ' +
37
+ 'If you have duplicated another product and are trying to publish a new Facebook product, ' +
38
+ 'click OK to proceed. ' +
39
+ 'Otherwise, Facebook metadata will be restored when this product is updated again.')) {
40
+ var metadata = document.querySelector('#fb_metadata');
41
+ if(metadata) {
42
+ metadata.innerHTML =
43
+ "<b>This product is not yet synced to Facebook.</b>";
44
+ }
45
+ return ajax(
46
+ 'ajax_reset_single_fb_product',
47
+ {'wp_id': wp_id}
48
+ );
49
+ }
50
+ }
51
+
52
+ function fb_delete_product(wp_id) {
53
+ if(confirm('Are you sure you want to delete this product on Facebook? If you only want to "hide" the product, '+
54
+ 'uncheck the "Visible" checkbox and hit "Update". If you delete a product on Facebook and hit "Update" after, ' +
55
+ 'this product will be recreated. To permanently remove this product from Facebook, hit "OK" and close the window.'+
56
+ 'This will not delete the product from WooCommerce.')) {
57
+ var metadata = document.querySelector('#fb_metadata');
58
+ if(metadata) {
59
+ metadata.innerHTML =
60
+ "<b>This product is not yet synced to Facebook.</b>";
61
+ }
62
+ return ajax(
63
+ 'ajax_delete_fb_product',
64
+ {'wp_id': wp_id}
65
+ );
66
+ }
67
+ }
assets/js/facebook-products.js ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+
10
+ /*
11
+ * Ajax helper function.
12
+ * Takes optional payload for POST and optional callback.
13
+ */
14
+ function ajax(action, payload = null, cb = null, failcb = null) {
15
+ var data = {
16
+ 'action': action,
17
+ };
18
+ if (payload){
19
+ for (var attrname in payload) { data[attrname] = payload[attrname]; }
20
+ }
21
+
22
+ // Since Wordpress 2.8 ajaxurl is always defined in admin header and
23
+ // points to admin-ajax.php
24
+ jQuery.post(ajaxurl, data, function(response) {
25
+ if(cb) {
26
+ cb(response);
27
+ }
28
+ }).fail(function(errorResponse){
29
+ if(failcb) {
30
+ failcb(errorResponse);
31
+ }
32
+ });
33
+ }
34
+
35
+ function fb_toggle_visibility(wp_id, published) {
36
+ var buttonId = document.querySelector("#viz_" + wp_id);
37
+ var tooltip = document.querySelector("#tip_" + wp_id);
38
+
39
+ if(published){
40
+ tooltip.setAttribute('data-tip',
41
+ 'Product is synced and published (visible) on Facebook.'
42
+ );
43
+ buttonId.setAttribute('onclick','fb_toggle_visibility('+wp_id+', false)');
44
+ buttonId.innerHTML = 'Hide';
45
+ buttonId.setAttribute('class', 'button');
46
+ } else {
47
+ tooltip.setAttribute('data-tip',
48
+ 'Product is synced but not marked as published (visible) on Facebook.'
49
+ );
50
+ buttonId.setAttribute('onclick','fb_toggle_visibility('+wp_id+', true)');
51
+ buttonId.innerHTML = 'Show';
52
+ buttonId.setAttribute('class', 'button button-primary button-large');
53
+ }
54
+
55
+ //Reset tooltip
56
+ jQuery(function($) {
57
+ $('.tips').tipTip({
58
+ 'attribute': 'data-tip',
59
+ 'fadeIn': 50,
60
+ 'fadeOut': 50,
61
+ 'delay': 200
62
+ });
63
+ });
64
+
65
+ return ajax(
66
+ 'ajax_fb_toggle_visibility',
67
+ {'wp_id': wp_id, 'published': published}
68
+ );
69
+ }
assets/js/facebook-settings.js ADDED
@@ -0,0 +1,882 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+
10
+ var fb_sync_no_response_count = 0;
11
+ var fb_show_advanced_options = false;
12
+
13
+ function toggleAdvancedOptions() {
14
+ var opts = document.getElementById("fbAdvancedOptions");
15
+ if (!fb_show_advanced_options) {
16
+ opts.style.display = "block";
17
+ document.getElementById('fbAdvancedOptionsText').innerHTML = 'Hide Advanced Settings';
18
+ } else {
19
+ opts.style.display = "none";
20
+ document.getElementById('fbAdvancedOptionsText').innerHTML = 'Show Advanced Settings';
21
+ }
22
+ fb_show_advanced_options = !fb_show_advanced_options;
23
+ }
24
+
25
+ function openPopup() {
26
+ var width = 1153;
27
+ var height = 808;
28
+ var topPos = screen.height / 2 - height / 2;
29
+ var leftPos = screen.width / 2 - width / 2;
30
+ window.originParam = window.location.protocol + '//' + window.location.host;
31
+ var popupUrl;
32
+ if(window.facebookAdsToolboxConfig.popupOrigin.includes('staticxx')) {
33
+ window.facebookAdsToolboxConfig.popupOrigin = 'https://www.facebook.com/';
34
+ }
35
+ window.facebookAdsToolboxConfig.popupOrigin = prepend_protocol(
36
+ window.facebookAdsToolboxConfig.popupOrigin
37
+ );
38
+ popupUrl = window.facebookAdsToolboxConfig.popupOrigin;
39
+
40
+ var path = '/ads/dia';
41
+ var page = window.open(popupUrl + '/login.php?display=popup&next=' + encodeURIComponent(popupUrl + path + '?origin=' + window.originParam + ' &merchant_settings_id=' + window.facebookAdsToolboxConfig.diaSettingId), 'DiaWizard', ['toolbar=no', 'location=no', 'directories=no', 'status=no', 'menubar=no', 'scrollbars=no', 'resizable=no', 'copyhistory=no', 'width=' + width, 'height=' + height, 'top=' + topPos, 'left=' + leftPos].join(','));
42
+
43
+ return function (type, params) {
44
+ page.postMessage({
45
+ type: type,
46
+ params: params
47
+ }, window.facebookAdsToolboxConfig.popupOrigin);
48
+ };
49
+ }
50
+
51
+ function prepend_protocol(url) {
52
+ // Preprend https if the url begis with //www.
53
+ if (url.indexOf('//www.') === 0) {
54
+ url = 'https:' + url;
55
+ }
56
+ return url;
57
+ }
58
+
59
+ function get_product_catalog_id_box() {
60
+ return document.querySelector('#woocommerce_facebookcommerce_fb_product_catalog_id') || null;
61
+ }
62
+ function get_pixel_id_box() {
63
+ return document.querySelector('#woocommerce_facebookcommerce_fb_pixel_id') || null;
64
+ }
65
+ function get_pixel_use_pii_id_box() {
66
+ return document.querySelector('#woocommerce_facebookcommerce_fb_pixel_use_pii') || null;
67
+ }
68
+ function get_api_key_box() {
69
+ return document.querySelector('#woocommerce_facebookcommerce_fb_api_key') || null;
70
+ }
71
+ function get_page_id_box() {
72
+ return document.querySelector('#woocommerce_facebookcommerce_fb_page_id') || null;
73
+ }
74
+ function get_ems_id_box() {
75
+ return document.querySelector('#woocommerce_facebookcommerce_fb_external_merchant_settings_id') || null;
76
+ }
77
+
78
+ /*
79
+ * Ajax helper function.
80
+ * Takes optional payload for POST and optional callback.
81
+ */
82
+ function ajax(action, payload = null, callback = null, failcallback = null) {
83
+ var data = {
84
+ 'action': action,
85
+ };
86
+ if (payload){
87
+ for (var attrname in payload) { data[attrname] = payload[attrname]; }
88
+ }
89
+
90
+ // Since Wordpress 2.8 ajaxurl is always defined in admin header and
91
+ // points to admin-ajax.php
92
+ jQuery.post(ajaxurl, data, function(response) {
93
+ if(callback) {
94
+ callback(response);
95
+ }
96
+ }).fail(function(errorResponse){
97
+ if(failcallback) {
98
+ failcallback(errorResponse);
99
+ }
100
+ });
101
+ }
102
+
103
+ var settings = {'facebook_for_woocommerce' : 1};
104
+ var pixel_settings = {'facebook_for_woocommerce' : 1};
105
+
106
+ function facebookConfig() {
107
+ window.sendToFacebook = openPopup();
108
+ window.diaConfig = { 'clientSetup': window.facebookAdsToolboxConfig };
109
+ }
110
+
111
+ function fb_flush(){
112
+ console.log("Removing all FBIDs from all products!");
113
+ return ajax('ajax_reset_all_fb_products');
114
+ }
115
+
116
+ function sync_confirm(verbose = null) {
117
+ var msg = '';
118
+ switch (verbose) {
119
+ case 'fb_force_resync':
120
+ msg = 'Your products will now be resynced with Facebook, ' +
121
+ 'this may take some time.';
122
+ break;
123
+ case 'fb_test_product_sync':
124
+ msg = 'Launch Test?';
125
+ break;
126
+ default:
127
+ msg = 'Facebook for WooCommerce automatically syncs your products on ' +
128
+ 'create/update. Are you sure you want to force product resync? ' +
129
+ 'This will query all published products and may take some time. ' +
130
+ 'You only need to do this if your products are out of sync ' +
131
+ 'or some of your products did not sync.';
132
+ }
133
+ if(confirm(msg)) {
134
+ sync_all_products(
135
+ window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload,
136
+ verbose == 'fb_test_product_sync'
137
+ );
138
+ window.fb_sync_start_time = new Date().getTime();
139
+ }
140
+ }
141
+
142
+ // Launch the confirm dialog immediately if the param is in the URL.
143
+ if (window.location.href.includes("fb_force_resync")) {
144
+ window.onload = function() { sync_confirm("fb_force_resync"); };
145
+ } else if (window.location.href.includes("fb_test_product_sync")) {
146
+ // Test products sync by feed.
147
+ window.is_test = true;
148
+ window.onload = function() { sync_confirm("fb_test_product_sync"); };
149
+ }
150
+
151
+ function sync_all_products($using_feed = false, $is_test = false) {
152
+ if (get_product_catalog_id_box() && !get_product_catalog_id_box().value){
153
+ return;
154
+ }
155
+ if (get_api_key_box() && !get_api_key_box().value){
156
+ return;
157
+ }
158
+ console.log('Syncing all products!');
159
+ window.fb_connected = true;
160
+ sync_in_progress();
161
+ if ($using_feed) {
162
+ window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload = true;
163
+ window.feed_upload = true;
164
+ ping_feed_status_queue();
165
+ return $is_test ? ajax('ajax_test_sync_products_using_feed')
166
+ : ajax('ajax_sync_all_fb_products_using_feed');
167
+ } else {
168
+ return ajax('ajax_sync_all_fb_products');
169
+ }
170
+ }
171
+
172
+ // Reset all state
173
+ function delete_all_settings(callback = null, failcallback = null) {
174
+ if (get_product_catalog_id_box()) {
175
+ get_product_catalog_id_box().value = '';
176
+ }
177
+ if(get_pixel_id_box()) {
178
+ get_pixel_id_box().value = '';
179
+ }
180
+ if(get_pixel_use_pii_id_box()) {
181
+ get_pixel_use_pii_id_box().checked = false;
182
+ }
183
+ if(get_api_key_box()) {
184
+ get_api_key_box().value = '';
185
+ }
186
+ if(get_page_id_box()) {
187
+ get_page_id_box().value = '';
188
+ }
189
+ if(get_ems_id_box()) {
190
+ get_ems_id_box().value = '';
191
+ }
192
+
193
+ window.facebookAdsToolboxConfig.pixel.pixelId = '';
194
+ window.facebookAdsToolboxConfig.diaSettingId = '';
195
+
196
+ reset_buttons();
197
+ window.fb_connected = false;
198
+
199
+ console.log('Deleting all settings and removing all FBIDs!');
200
+ return ajax('ajax_delete_fb_settings', null, callback, failcallback);
201
+ }
202
+
203
+ // save_settings and save_settings_and_sync should only be called once
204
+ // after all variables are set up in the settings global variable
205
+ // if called multiple times, race conditions might occur
206
+ // ---
207
+ // It's also called again if the pixel id is ever changed or pixel pii is
208
+ // enabled or disabled.
209
+ function save_settings(callback = null, failcallback = null, localsettings = null){
210
+ if (!localsettings) {
211
+ localsettings = settings;
212
+ }
213
+ ajax('ajax_save_fb_settings', localsettings,
214
+ function(response){
215
+ if(callback) {
216
+ callback(response);
217
+ }
218
+ },
219
+ function(errorResponse){
220
+ if(failcallback) {
221
+ failcallback(errorResponse);
222
+ }
223
+ }
224
+ );
225
+ }
226
+
227
+ // save_settings wrapper for plugins as we do not need to:
228
+ // 1. sync products again after plugin is configured
229
+ // 2. check api_key, which is from facebook and is only necessary
230
+ // for following sync products
231
+ function save_settings_for_plugin(callback, failcallback) {
232
+ save_settings(
233
+ function(response){
234
+ if (response && response.includes('settings_saved')){
235
+ console.log(response);
236
+ callback(response);
237
+ } else {
238
+ console.log('Fail response on save_settings_and_sync');
239
+ failcallback(response);
240
+ }
241
+ },
242
+ function(errorResponse){
243
+ console.log('Ajax error while saving settings:' + JSON.stringify(errorResponse));
244
+ failcallback(errorResponse);
245
+ });
246
+ }
247
+
248
+ // see comments in save_settings function above
249
+ function save_settings_and_sync(message) {
250
+ if ('api_key' in settings){
251
+ save_settings(
252
+ function(response){
253
+ if (response && response.includes('settings_saved')){
254
+ console.log(response);
255
+ //Final acks
256
+ window.sendToFacebook('ack set pixel', message.params);
257
+ window.sendToFacebook('ack set page access token', message.params);
258
+ window.sendToFacebook('ack set merchant settings', message.params);
259
+ sync_all_products(true);
260
+ } else {
261
+ window.sendToFacebook('fail save_settings', response);
262
+ console.log('Fail response on save_settings_and_sync');
263
+ }
264
+ },
265
+ function(errorResponse){
266
+ console.log('Ajax error while saving settings:' + JSON.stringify(errorResponse));
267
+ window.sendToFacebook('fail save_settings_ajax', JSON.stringify(errorResponse));
268
+ }
269
+ );
270
+ }
271
+ }
272
+
273
+ //Reset buttons to brand new setup state
274
+ function reset_buttons(){
275
+ if(document.querySelector('#settings')){
276
+ document.querySelector('#settings').style.display = 'none';
277
+ }
278
+ if(document.querySelector('#cta_button')){
279
+ var cta_element = document.querySelector('#cta_button');
280
+ cta_element.innerHTML = 'Get Started';
281
+ cta_element.style['font-size'] = '13px';
282
+ cta_element.style.width = '80px';
283
+ cta_element.href = '#';
284
+ cta_element.onclick= function() { facebookConfig(); };
285
+ }
286
+ if(document.querySelector('#learnmore_button')){
287
+ document.querySelector('#learnmore_button').style.display = 'none';
288
+ }
289
+ if(document.querySelector('#setup_h1')) {
290
+ document.querySelector('#setup_h1').innerHTML =
291
+ 'Grow your business on Facebook';
292
+ }
293
+ if(document.querySelector('#setup_l1')){
294
+ document.querySelector('#setup_l1').innerHTML =
295
+ 'Easily install a tracking pixel';
296
+ }
297
+ if(document.querySelector('#setup_l2')){
298
+ document.querySelector('#setup_l2').innerHTML =
299
+ 'Upload your products and create a shop';
300
+ }
301
+ if(document.querySelector('#setup_l3')){
302
+ document.querySelector('#setup_l3').innerHTML =
303
+ 'Create dynamic ads with your products and pixel';
304
+ }
305
+ }
306
+
307
+ //Remove reset/settings buttons during product sync
308
+ function sync_in_progress(){
309
+ if(document.querySelector('#settings')){
310
+ document.querySelector('#settings').style.display = '';
311
+ }
312
+ if(document.querySelector('#connection_status')){
313
+ document.querySelector('#connection_status').style.display = '';
314
+ }
315
+ if(document.querySelector('#sync_complete')){
316
+ document.querySelector('#sync_complete').style.display = 'none';
317
+ }
318
+ //Get rid of all the buttons
319
+ if(document.querySelector('#setting_button')){
320
+ document.querySelector('#setting_button').style['pointer-events'] = 'none';
321
+ }
322
+ if(document.querySelector('#resync_products')) {
323
+ document.querySelector('#resync_products').style['pointer-events'] = 'none';
324
+ }
325
+ if(document.querySelector('#test_product_sync')) {
326
+ document.querySelector('#test_product_sync').style.display = 'none';
327
+ }
328
+ //Set a product sync status
329
+ if(document.querySelector('#sync_progress')){
330
+ document.querySelector('#sync_progress').innerHTML =
331
+ 'Syncing... Keep this browser open <br/>' +
332
+ 'Until sync is complete<br/>' +
333
+ '<div class="loader"></div>';
334
+ }
335
+ }
336
+
337
+ function sync_not_in_progress(){
338
+ // Reset to pre-setup state.
339
+ if(document.querySelector('#cta_button')){
340
+ var cta_element = document.querySelector('#cta_button');
341
+ cta_element.innerHTML = 'Create Ad';
342
+ cta_element.style['font-size'] = '12px';
343
+ cta_element.style.width = '60px';
344
+ if (window.facebookAdsToolboxConfig.diaSettingId) {
345
+ cta_element.onclick= function() {
346
+ window.open('https://www.facebook.com/ads/dia/redirect/?settings_id=' +
347
+ window.facebookAdsToolboxConfig.diaSettingId + '&version=2' +
348
+ '&entry_point=admin_panel');
349
+ };
350
+ } else {
351
+ cta_element.style['pointer-events'] = 'none';
352
+ }
353
+ }
354
+ if(document.querySelector('#learnmore_button')){
355
+ var learnmore_element = document.querySelector('#learnmore_button');
356
+ if (window.facebookAdsToolboxConfig.diaSettingId) {
357
+ learnmore_element.style.display = '';
358
+ }
359
+ }
360
+ if(document.querySelector('#setup_h1')) {
361
+ document.querySelector('#setup_h1').innerHTML =
362
+ 'Reach the right people and sell more products';
363
+ }
364
+ if(document.querySelector('#setup_l1')){
365
+ document.querySelector('#setup_l1').innerHTML =
366
+ 'Create an ad in a few steps';
367
+ }
368
+ if(document.querySelector('#setup_l2')){
369
+ document.querySelector('#setup_l2').innerHTML =
370
+ 'Use built-in best practice for online sales';
371
+ }
372
+ if(document.querySelector('#setup_l3')){
373
+ document.querySelector('#setup_l3').innerHTML =
374
+ 'Get reporting on sales and revenue';
375
+ }
376
+ if(document.querySelector('#settings')){
377
+ document.querySelector('#settings').style.display = '';
378
+ }
379
+ // Enable buttons.
380
+ if(document.querySelector('#setting_button')){
381
+ document.querySelector('#setting_button').style['pointer-events'] = 'auto';
382
+ }
383
+ if(document.querySelector('#resync_products')) {
384
+ document.querySelector('#resync_products').style ['pointer-events'] = 'auto';
385
+ }
386
+ // Remove sync progress.
387
+ if(document.querySelector('#sync_progress')){
388
+ document.querySelector('#sync_progress').innerHTML = '';
389
+ }
390
+ }
391
+
392
+ function not_connected(){
393
+ if(document.querySelector('#connection_status')){
394
+ document.querySelector('#connection_status').style.display = 'none';
395
+ }
396
+
397
+ if(document.querySelector('#setting_button')){
398
+ document.querySelector('#setting_button').style['pointer-events'] = 'auto';
399
+ }
400
+ if(document.querySelector('#resync_products')) {
401
+ document.querySelector('#resync_products').style['pointer-events'] = 'none';
402
+ }
403
+ if(document.querySelector('#sync_complete')) {
404
+ document.querySelector('#sync_complete').style.display = 'none';
405
+ }
406
+ if(document.querySelector('#sync_progress')){
407
+ document.querySelector('#sync_progress').innerHTML = '';
408
+ }
409
+ }
410
+
411
+ function addAnEventListener(obj,evt,func) {
412
+ if ('addEventListener' in obj){
413
+ obj.addEventListener(evt,func, false);
414
+ } else if ('attachEvent' in obj){//IE
415
+ obj.attachEvent('on'+evt,func);
416
+ }
417
+ }
418
+
419
+ function setMerchantSettings(message) {
420
+ if (!message.params.setting_id) {
421
+ console.error('Facebook Extension Error: got no setting_id', message.params);
422
+ window.sendToFacebook('fail set merchant settings', message.params);
423
+ return;
424
+ }
425
+ if(get_ems_id_box()){
426
+ get_ems_id_box().value = message.params.setting_id;
427
+ }
428
+
429
+ settings.external_merchant_settings_id = message.params.setting_id;
430
+
431
+ //Immediately set in case button is clicked again
432
+ window.facebookAdsToolboxConfig.diaSettingId = message.params.setting_id;
433
+ //Ack merchant settings happens after settings are saved
434
+ }
435
+
436
+ function setCatalog(message) {
437
+ if (!message.params.catalog_id) {
438
+ console.error('Facebook Extension Error: got no catalog_id', message.params);
439
+ window.sendToFacebook('fail set catalog', message.params);
440
+ return;
441
+ }
442
+ if(get_api_key_box()){
443
+ get_product_catalog_id_box().value = message.params.catalog_id;
444
+ }
445
+
446
+ settings.product_catalog_id = message.params.catalog_id;
447
+
448
+ window.sendToFacebook('ack set catalog', message.params);
449
+ }
450
+
451
+
452
+ function setPixel(message) {
453
+ if (!message.params.pixel_id) {
454
+ console.error('Facebook Ads Extension Error: got no pixel_id', message.params);
455
+ window.sendToFacebook('fail set pixel', message.params);
456
+ return;
457
+ }
458
+ if(get_pixel_id_box()){
459
+ get_pixel_id_box().value = message.params.pixel_id;
460
+ }
461
+
462
+ settings.pixel_id = message.params.pixel_id;
463
+ pixel_settings.pixel_id = settings.pixel_id;
464
+ if (message.params.pixel_use_pii !== undefined) {
465
+ if(get_pixel_use_pii_id_box()){
466
+ //!! will explicitly convert truthy/falsy values to a boolean
467
+ get_pixel_use_pii_id_box().checked = !!message.params.pixel_use_pii;
468
+ }
469
+ settings.pixel_use_pii = message.params.pixel_use_pii;
470
+ pixel_settings.pixel_use_pii = settings.pixel_use_pii;
471
+ }
472
+
473
+ // We need this to support changing the pixel id after setup.
474
+ save_settings(
475
+ function(response){
476
+ if (response && response.includes('settings_saved')){
477
+ window.sendToFacebook('ack set pixel', message.params);
478
+ } //may not get settings_saved if we try to save pixel before an API key
479
+ },
480
+ function(errorResponse){
481
+ console.log(errorResponse);
482
+ window.sendToFacebook('fail set pixel', errorResponse);
483
+ },
484
+ pixel_settings
485
+ );
486
+ }
487
+
488
+ function genFeed(message) {
489
+ //no-op
490
+ }
491
+
492
+ function setAccessTokenAndPageId(message) {
493
+ if (!message.params.page_token) {
494
+ console.error('Facebook Ads Extension Error: got no page_token',
495
+ message.params);
496
+ window.sendToFacebook('fail set page access token', message.params);
497
+ return;
498
+ }
499
+ /*
500
+ Set page_token here
501
+ */
502
+
503
+ if(get_api_key_box()){
504
+ get_api_key_box().value = message.params.page_token;
505
+ }
506
+
507
+ if(get_page_id_box()){
508
+ get_page_id_box().value = message.params.page_id;
509
+ }
510
+
511
+ settings.api_key = message.params.page_token;
512
+ settings.page_id = message.params.page_id;
513
+ //Ack token in "save_settings_and_sync" for final ack
514
+
515
+ window.facebookAdsToolboxConfig.tokenExpired = false;
516
+ if(document.querySelector('#token_text')){
517
+ document.querySelector('#token_text').innerHTML =
518
+ `<strong>Your API key has been updated.<br />
519
+ Please refresh the page.</strong>`;
520
+ }
521
+ }
522
+
523
+ function setMsgerChatSetup(data) {
524
+ if (data.hasOwnProperty('is_messenger_chat_plugin_enabled')) {
525
+ settings.is_messenger_chat_plugin_enabled =
526
+ data.is_messenger_chat_plugin_enabled;
527
+ }
528
+ if (data.hasOwnProperty('facebook_jssdk_version')) {
529
+ settings.facebook_jssdk_version =
530
+ data.facebook_jssdk_version;
531
+ }
532
+ if (data.hasOwnProperty('page_id')) {
533
+ settings.fb_page_id = data.page_id;
534
+ }
535
+
536
+ if (data.hasOwnProperty('customization')) {
537
+ var customization = data.customization;
538
+
539
+ if (customization.hasOwnProperty('greetingTextCode')) {
540
+ settings.msger_chat_customization_greeting_text_code =
541
+ customization.greetingTextCode;
542
+ }
543
+ if (customization.hasOwnProperty('locale')) {
544
+ settings.msger_chat_customization_locale =
545
+ customization.locale;
546
+ }
547
+ if (customization.hasOwnProperty('themeColorCode')) {
548
+ settings.msger_chat_customization_theme_color_code =
549
+ customization.themeColorCode;
550
+ }
551
+ }
552
+ }
553
+
554
+ function iFrameListener(event) {
555
+ // Fix for web.facebook.com
556
+ const origin = event.origin || event.originalEvent.origin;
557
+ if (origin != window.facebookAdsToolboxConfig.popupOrigin &&
558
+ urlFromSameDomain(origin, window.facebookAdsToolboxConfig.popupOrigin)) {
559
+ window.facebookAdsToolboxConfig.popupOrigin = origin;
560
+ }
561
+
562
+ switch (event.data.type) {
563
+ case 'reset':
564
+ delete_all_settings(function(res){
565
+ if(res && event.data.params) {
566
+ if(res === 'Settings Deleted'){
567
+ window.sendToFacebook('ack reset', event.data.params);
568
+ }else{
569
+ console.log(res);
570
+ alert(res);
571
+ }
572
+ }else {
573
+ console.log("Got no response from delete_all_settings");
574
+ }
575
+ },function(err){
576
+ console.error(err);
577
+ });
578
+ break;
579
+ case 'get dia settings':
580
+ window.sendToFacebook('dia settings', window.diaConfig);
581
+ break;
582
+ case 'set merchant settings':
583
+ setMerchantSettings(event.data);
584
+ break;
585
+ case 'set catalog':
586
+ setCatalog(event.data);
587
+ break;
588
+ case 'set pixel':
589
+ setPixel(event.data);
590
+ break;
591
+ case 'gen feed':
592
+ genFeed();
593
+ break;
594
+ case 'set page access token':
595
+ //Should be last message received
596
+ setAccessTokenAndPageId(event.data);
597
+ save_settings_and_sync(event.data);
598
+ break;
599
+ case 'set msger chat':
600
+ setMsgerChatSetup(event.data.params);
601
+ save_settings_for_plugin(
602
+ function(response) {
603
+ window.sendToFacebook('ack msger chat', event.data);
604
+ },
605
+ function(response) {
606
+ window.sendToFacebook('fail ack msger chat', event.data);
607
+ });
608
+ break;
609
+ }
610
+ }
611
+
612
+ addAnEventListener(window,'message',iFrameListener);
613
+
614
+ function urlFromSameDomain(url1, url2) {
615
+ if (!url1.startsWith('http') || !url2.startsWith('http')) {
616
+ return false;
617
+ }
618
+ var u1 = parseURL(url1);
619
+ var u2 = parseURL(url2);
620
+ var u1host = u1.host.replace(/^\w+\./, 'www.');
621
+ var u2host = u2.host.replace(/^\w+\./, 'www.');
622
+ return u1.protocol === u2.protocol && u1host === u2host;
623
+ }
624
+
625
+ function parseURL(url) {
626
+ var parser = document.createElement('a');
627
+ parser.href = url;
628
+ return parser;
629
+ }
630
+
631
+ // Only do pings for supporting older (pre 1.8) setups.
632
+ window.fb_pings =
633
+ (window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload) ?
634
+ null :
635
+ setInterval(function(){
636
+ console.log("Pinging queue...");
637
+ check_queues();
638
+ }, 10000);
639
+
640
+ function ping_feed_status_queue(count = 0) {
641
+ window.fb_feed_pings = setInterval(function() {
642
+ console.log('Pinging feed uploading queue...');
643
+ check_feed_upload_queue(count);
644
+ }, 30000*(1 << count));
645
+ }
646
+
647
+ function product_sync_complete(sync_progress_element){
648
+ sync_not_in_progress();
649
+ if(document.querySelector('#sync_complete')){
650
+ document.querySelector('#sync_complete').style.display = '';
651
+ }
652
+ if(sync_progress_element) {
653
+ sync_progress_element.innerHTML = '';
654
+ }
655
+ clearInterval(window.fb_pings);
656
+ }
657
+
658
+ function check_queues(){
659
+ ajax('ajax_fb_background_check_queue',
660
+ {"request_time": new Date().getTime()}, function(response){
661
+ if (window.feed_upload) {
662
+ clearInterval(window.fb_pings);
663
+ return;
664
+ }
665
+ var sync_progress_element = document.querySelector('#sync_progress');
666
+ var res = parse_response_check_connection(response);
667
+ if (!res) {
668
+ if (fb_sync_no_response_count++ > 5) {
669
+ clearInterval(window.fb_pings);
670
+ }
671
+ return;
672
+ }
673
+ fb_sync_no_response_count = 0;
674
+
675
+ if(res){
676
+ if(!res.background){
677
+ console.log("No background sync found, disabling pings");
678
+ clearInterval(window.fb_pings);
679
+ }
680
+
681
+ var processing = !!res.processing; //explicit boolean conversion
682
+ var remaining = res.remaining;
683
+ if(processing) {
684
+ if(sync_progress_element) {
685
+ sync_progress_element.innerHTML =
686
+ '<strong>Progress:</strong> ' + remaining + ' item' +
687
+ (remaining > 1 ? 's' : '') + ' remaining.';
688
+ }
689
+ if(remaining === 0){
690
+ product_sync_complete(sync_progress_element);
691
+ }
692
+ } else {
693
+ //Not processing, none remaining. Either long complete, or just completed
694
+ if(window.fb_sync_start_time && res.request_time){
695
+ var request_time = new Date(parseInt(res.request_time));
696
+ if(window.fb_sync_start_time > request_time){
697
+ //Old ping, do nothing.
698
+ console.log("OLD PING");
699
+ return;
700
+ }
701
+ }
702
+
703
+ if(remaining === 0){
704
+ product_sync_complete(sync_progress_element);
705
+ }
706
+ }
707
+ }
708
+ });
709
+ }
710
+
711
+ function parse_response_check_connection(res) {
712
+ if (res) {
713
+ console.log(res);
714
+ var response = res.substring(res.indexOf("{")); //Trim leading extra chars (rnrnr)
715
+ response = JSON.parse(response);
716
+ if(!response.connected && !window.fb_connected){
717
+ not_connected();
718
+ return null;
719
+ }
720
+ return response;
721
+ }
722
+ return null;
723
+ }
724
+
725
+ function check_feed_upload_queue(check_num) {
726
+ ajax('ajax_check_feed_upload_status', null, function(response) {
727
+ var sync_progress_element = document.querySelector('#sync_progress');
728
+ var res = parse_response_check_connection(response);
729
+ clearInterval(window.fb_feed_pings);
730
+ if (res) {
731
+ var status = res.status;
732
+ switch (status) {
733
+ case 'complete':
734
+ window.feed_upload = false;
735
+ if (window.is_test) {
736
+ display_test_result();
737
+ } else {
738
+ product_sync_complete(sync_progress_element);
739
+ }
740
+ break;
741
+ case 'in progress':
742
+ if (sync_progress_element) {
743
+ sync_progress_element.innerHTML =
744
+ 'Syncing... Keep this browser open <br/>' +
745
+ 'Until sync is complete<br/>';
746
+ }
747
+ ping_feed_status_queue(check_num+1);
748
+ break;
749
+ default:
750
+ sync_progress_element.innerHTML =
751
+ '<strong>Something wrong when uploading, please try again.</strong>';
752
+ window.feed_upload = false;
753
+ if (window.is_test) {
754
+ display_test_result();
755
+ }
756
+ }
757
+ }
758
+ });
759
+ }
760
+
761
+ function display_test_result() {
762
+ ajax('ajax_display_test_result', null, function(response) {
763
+ var sync_complete_element = document.querySelector('#sync_complete');
764
+ var sync_progress_element = document.querySelector('#sync_progress');
765
+ var res = parse_response_check_connection(response);
766
+ if (res) {
767
+ var status = res.pass;
768
+ switch (status) {
769
+ case 'true':
770
+ sync_not_in_progress();
771
+ if(sync_complete_element) {
772
+ sync_complete_element.style.display = '';
773
+ sync_complete_element.innerHTML =
774
+ '<strong>Status: </strong>Test Pass.';
775
+ }
776
+ if(sync_progress_element) {
777
+ sync_progress_element.innerHTML = '';
778
+ }
779
+ window.is_test = false;
780
+ break;
781
+ case 'in progress':
782
+ if (sync_progress_element) {
783
+ sync_progress_element.innerHTML =
784
+ '<strong>Integration test in progress...</strong>';
785
+ }
786
+ ping_feed_status_queue();
787
+ break;
788
+ default:
789
+ window.debug_info = res.debug_info + '<br/>' + res.stack_trace;
790
+ if(sync_complete_element) {
791
+ sync_complete_element.style.display = '';
792
+ sync_complete_element.innerHTML =
793
+ '<strong>Status: </strong>Test Fail.';
794
+ }
795
+ if (sync_progress_element) {
796
+ sync_progress_element.innerHTML = '';
797
+ }
798
+ if(document.querySelector('#debug_info')) {
799
+ document.querySelector('#debug_info').style.display = '';
800
+ }
801
+ window.is_test = false;
802
+ }
803
+ }
804
+ });
805
+ }
806
+
807
+ function show_debug_info() {
808
+ var stack_trace_element = document.querySelector('#stack_trace');
809
+ if(stack_trace_element) {
810
+ stack_trace_element.innerHTML = window.debug_info;
811
+ }
812
+ if(document.querySelector('#debug_info')) {
813
+ document.querySelector('#debug_info').style.display = 'none';
814
+ }
815
+ window.debug_info = '';
816
+ }
817
+
818
+ function fbe_init_nux_messages() {
819
+ var jQuery = window.jQuery;
820
+ jQuery(function() {
821
+ jQuery.each(jQuery('.nux-message'), function(_index, nux_msg) {
822
+ var nux_msg_elem = jQuery(nux_msg);
823
+ var targetid = nux_msg_elem.data('target');
824
+ var target_elem = jQuery('#' + targetid);
825
+ var t_pos = target_elem.position();
826
+ var t_half_height = target_elem.height() / 2;
827
+ var t_width = target_elem.outerWidth();
828
+ nux_msg_elem.css({
829
+ 'top': '' + Math.ceil(t_pos.top + t_half_height) + 'px',
830
+ 'left': '' + Math.ceil(t_pos.left + t_width) + 'px',
831
+ 'display': 'block'
832
+ });
833
+ jQuery('.nux-message-close-btn', nux_msg_elem).click(function() {
834
+ jQuery(nux_msg).hide();
835
+ });
836
+ });
837
+ });
838
+ }
839
+
840
+ function saveAutoSyncSchedule() {
841
+ var isChecked = document.getElementsByClassName('autosyncCheck')[0].checked;
842
+ var timebox = document.getElementsByClassName('autosyncTime')[0];
843
+ var button = document.getElementsByClassName('autosyncSaveButton')[0];
844
+ var saved = document.getElementsByClassName('autosyncSavedNotice')[0];
845
+
846
+ if (!isChecked) {
847
+ timebox.setAttribute('disabled', true);
848
+ } else {
849
+ timebox.removeAttribute('disabled');
850
+ saved.style.transition = '';
851
+ saved.style.opacity = 1;
852
+ // Fade out the small 'Saved' after 3 seconds.
853
+ setTimeout(function() {
854
+ saved.style.opacity = 0;
855
+ saved.style.transition = 'opacity 5s';}
856
+ ,3000);
857
+ }
858
+
859
+ ajax('ajax_schedule_force_resync', {"enabled": isChecked ? 1 : 0, "time": timebox.value});
860
+ }
861
+
862
+ function onSetDisableSyncOnDevEnvironment() {
863
+ var isChecked = document.getElementsByClassName('disableOnDevEnvironment')[0].checked;
864
+ ajax(
865
+ 'ajax_update_fb_option',
866
+ {
867
+ "option": "fb_disable_sync_on_dev_environment",
868
+ "option_value": isChecked ? 1 : 0
869
+ }
870
+ );
871
+ }
872
+
873
+ function syncShortDescription() {
874
+ var isChecked = document.getElementsByClassName('syncShortDescription')[0].checked;
875
+ ajax(
876
+ 'ajax_update_fb_option',
877
+ {
878
+ "option": "fb_sync_short_description",
879
+ "option_value": isChecked ? 1 : 0
880
+ }
881
+ );
882
+ }
changelog.txt ADDED
@@ -0,0 +1,399 @@
1
+ *** Facebook for WooCommerce Changelog ***
2
+ 2019-02-26 - Version 1.9.11
3
+ * changing contributor to facebook from facebook4woocommerce, so that
4
+ woo plugin will be shown under https://profiles.wordpress.org/facebook/#content-plugins
5
+ * adding changelog in readme.txt so that notifications will be sent for updates and
6
+ changelog will be shown under https://wordpress.org/plugins/facebook-for-woocommerce/#developers
7
+ * removing debug flags notice under facebook-for-woocommerce.php so that developers will
8
+ be able to debug with debug logs
9
+
10
+ 2019-02-11 - Version 1.9.10
11
+ * Add facebook support link, this will help merchants to reach out to facebook customer service.
12
+ * Make plugin wordpress compatible by removing woocommerce updater and removing woo_include
13
+
14
+ 2018-12-30 - Version 1.9.9
15
+ * Fix issue with missing file in v1.9.8
16
+ * Remove misleading content relating to Instagram which is not launched yet.
17
+
18
+ 2018-11-30 - Version 1.9.8
19
+ * Prevent Show/Hide button auto scroll.
20
+ * DIY entry field for FB product Image.
21
+ * Initial Support for Advanced Bulk Edit.
22
+ * Added Option to Use short description instead of description.
23
+ * Added checkbox for disable sync with FB for dev environment.
24
+ * Add New Advanced Option : Auto Force Resync on Schedule.
25
+ * Don't sync out of stock items to FB depending on Woo setting.
26
+ * Add custom price.
27
+ * Fix 502 Bad Gateway Error When Redirect.
28
+ * Sync composite product with calculating the price based on the price of sub-items.
29
+ * Advanced Options Toggle in Configuration Screen.
30
+
31
+ 2018-11-01 - Version 1.9.7
32
+ * Support messenger chat customization dialog
33
+ * Add Copyright header.
34
+ * Fix lowercasting product description.
35
+ * Fix Connect Woo AYMT Logic Flow and improve Logging.
36
+
37
+ 2018-09-21 - Version 1.9.6
38
+ * Update plugin description of new design for WooCommerce.
39
+ * Remove get_date() in Woocommerce plugin.
40
+ * Add External Action-to-Make Channel Support.
41
+
42
+ 2018-08-14 - Version 1.9.5
43
+ * Fix Subscription Event Injection
44
+
45
+ 2018-08-10 - Version 1.9.4