├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── package-lock.json ├── package.json ├── public ├── admin │ ├── class-bing-url-submission-admin.php │ ├── index.php │ ├── js │ │ └── bing-url-submission-admin.js │ ├── partials │ │ └── bing-url-submission-admin-react.php │ └── utils │ │ ├── class-bing-url-submission-admin-routes.php │ │ └── class-bing-url-submission-admin-utils.php ├── bing-url-submission.php ├── includes │ ├── class-bing-url-submission-activator.php │ ├── class-bing-url-submission-deactivator.php │ ├── class-bing-url-submission-loader.php │ ├── class-bing-url-submission.php │ └── index.php ├── index.html ├── index.php ├── readme.txt └── uninstall.php ├── src ├── App.test.js ├── Constants.ts ├── components │ ├── APIHelper.tsx │ ├── App.tsx │ ├── Card.tsx │ ├── Dashboard.tsx │ ├── ErrorConstants.tsx │ ├── Header.tsx │ ├── Interfaces.ts │ ├── StartPage.tsx │ └── withDashboardData.tsx ├── index.css ├── index.js ├── logo.svg ├── react-app-env.d.ts ├── scss │ ├── App.scss │ ├── Dashboard.scss │ ├── Header.scss │ ├── StartPage.scss │ ├── _common.scss │ ├── _mixin.scss │ ├── _variables.scss │ ├── default.scss │ ├── headerPanel.scss │ ├── mixins │ │ ├── _border-radius.scss │ │ ├── _clearfix.scss │ │ ├── _disabletext.scss │ │ ├── _display.scss │ │ ├── _fonts.scss │ │ ├── _icons.scss │ │ ├── _opacity.scss │ │ ├── _shadow.scss │ │ ├── _textellipsis.scss │ │ ├── _transform.scss │ │ └── _transition.scss │ └── responsiveLayout.scss ├── serviceWorker.js └── setupTests.js └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules/ 3 | 4 | # Logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # vscode 11 | .vscode/* 12 | !.vscode/settings.json 13 | !.vscode/tasks.json 14 | !.vscode/launch.json 15 | !.vscode/extensions.json 16 | *.code-workspace 17 | 18 | # Build 19 | build/ 20 | 21 | # Publish 22 | publish/ 23 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 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 | 294 | Copyright (C) 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 | , 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bing URL Submissions Plugin 2 | 3 | Bing URL Submission Plugin for WordPress enables WordPress site owners to instantly and automatically submit their new and updated pages to the Bing index. Once setup, the plugin detects any page creation or update in WordPress and automatically submits the URL behind the scenes ensuring that the site content is always fresh in Bing index. 4 | 5 | Some other handy features included in the plugin: 6 | 7 | - Toggle automatic submission feature on or off. 8 | - Manually submit a site URL to Bing Index. 9 | - View list of recent URLs submitted by the plugin. 10 | - Retry any failed submissions from recent submission history. 11 | - Download recent submissions list. 12 | 13 | This plugin was developed with love and coffee by the Bing Webmaster team. 14 | 15 | ## Getting Started 16 | 17 | Follow instructions below to install the plugin and set up automatic submission of new pages in your WordPress site to the Bing index. 18 | 19 | ### VERIFYING YOUR WORDPRESS SITE ON BING WEBMASTER 20 | 21 | 1. Log in to [Bing Webmaster][bing-webmaster] (or sign up for an account). 22 | 1. Follow instructions [here][verify-wordpress] to verify your WordPress site with Bing Webmaster. 23 | 1. Once verified, you can access your API key by following the instructions [here][api-key-access]. 24 | 25 | ### INSTALLING THE PLUGIN 26 | 27 | 1. Log in to the admin panel for your WordPress site. Click on `Plugins` > `Add New`. 28 | 1. Search for "Bing URL Submissions Plugin" and install. 29 | 1. Once installed, click on `Activate` to enable plugin. 30 | 31 | ### SETTING UP THE PLUGIN 32 | 33 | 1. Open Bing URL Submissions plugin settings page by clicking on `Settings` link for the plugin. (Or the `Bing Webmaster` link in the navigation menu). 34 | 1. Enter your Bing Webmaster API key into the API key prompt in the plugin page. 35 | 36 | Voila! Your WordPress site is now configured to automatically submit URLs to Bing. 37 | 38 | ## Frequently Asked Questions 39 | 40 | - Why should I install Bing URL Submission Plugin? 41 | 42 | Bing Webmaster enables quick indexing of your site URLs via the Submit URL API. Bing URL Submissions Plugin automates the submissions of your site URLs to this API by automatically submitting URLs for any page updated/created from WordPress. 43 | 44 | - Where do I find the API key? 45 | 46 | To automate Bing URL submissions using the Bing URL Submission Plugin, you need to have your WordPress site registered with Bing Webmaster. Once your site is verified at Bing Webmaster, you can access your API key by navigating to `Settings` > `API Access` > `API Key` within [Bing Webmaster portal][bing-webmaster]. 47 | 48 | - I got an error "Adding API key failed: Invalid API Key" when I'm trying to log in to the plugin dashboard using API key. What do I do? 49 | 50 | "Invalid URL" error indicates that your API key is invalid for the WordPress site you're trying to configure the plugin against. Please verify that your WordPress site is added and verified against your Webmaster account. 51 | 52 | - "Automatic URL Submission" and "Manual URL Submission" cards are greyed out in plugin dashboard. How do I fix this? 53 | 54 | Automatic and manual URL submission cards are disabled if your API key is detected as invalid for submitting URLs against this WordPress site. Please ensure that your site is verified in your Bing Webmaster account and update the plugin with your new API key using 'Update key' option in the API key card. 55 | 56 | - I got an error "Invalid API key : Update API key to enable Automatic & Manual URL submission.". What do I do? 57 | 58 | See answer to `"Automatic URL Submission" and "Manual URL Submission" cards are greyed out in plugin dashboard. How do I fix this?` above. 59 | 60 | - How can I reset the plugin and delete any stored data from my WordPress database? 61 | 62 | You can go to 'Plugins' page from your WordPress side menu and click on `Deactivate` under Bing URL Submissions plugin listing. This will remove the API key integration as well as any locally stored data about submitted URLs. Reactivating the plugin will present you with a clean slate and ask for API key input. 63 | 64 | ## Changelog 65 | 66 | ### 1.0.13 67 | - Fix: Compatibility update with wordpress v5.8 and linting fixes. 68 | 69 | ### 1.0.12 70 | - Fix: Compatibility issue with older wordpress versions. 71 | 72 | ### 1.0.11 73 | 74 | - Fix: Non public URL subimssions. 75 | - Fix: Upgrade dependencies to fix vulnerabilities. 76 | 77 | ### 1.0.10 78 | 79 | - Upgrade dependencies to fix vulnerabilities. 80 | 81 | ### 1.0.9 82 | 83 | - Update readme to reflect support for WordPress v5.7. 84 | 85 | ### 1.0.8 86 | 87 | - Upgrade dependencies to fix vulnerabilities and update latest compatible wordpress version. 88 | 89 | ### 1.0.7 90 | 91 | - Fix console error being thrown by React when not in plugin page. 92 | 93 | ### 1.0.6 94 | 95 | - Upgrade dependencies to fix known vulnerabilities. 96 | 97 | ### 1.0.5 98 | 99 | - Filter out URLs containing specific post_types that aren't browsable. 100 | 101 | ### 1.0.4 102 | 103 | - Fix encoded URLs being displayed in URL Submissions table. 104 | 105 | ### 1.0.3 106 | 107 | - Update root element name. Fixes issue loading plugin settings page. 108 | 109 | ### 1.0.2 110 | 111 | - Rename root element of settings page to avoid conflicts with other plugins. 112 | 113 | ### 1.0.1 114 | 115 | - Update readme to reflect support for WordPress v5.5. 116 | 117 | ### 1.0.0 118 | 119 | - Initial release. 120 | 121 | [bing-webmaster]: https://bing.com/webmasters 122 | [verify-wordpress]: https://docs.microsoft.com/bingwebmaster/verifying-wordpress 123 | [api-key-access]: https://docs.microsoft.com/bingwebmaster/getting-access#using-api-key 124 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). 40 | 41 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@fluentui/react": "^7.146.2", 4 | "@testing-library/jest-dom": "^5.11.4", 5 | "@testing-library/react": "^11.1.0", 6 | "@testing-library/user-event": "^12.1.8", 7 | "@types/react": "^16.9.52", 8 | "@uifabric/react-hooks": "^7.13.6", 9 | "date-fns": "^2.16.1", 10 | "hosted-git-info": "^2.8.9", 11 | "lodash": "^4.17.21", 12 | "node-sass": "^4.13.1", 13 | "react": "^16.14.0", 14 | "react-dev-utils": "^11.0.4", 15 | "react-dom": "^16.14.0", 16 | "react-scripts": "^4.0.3", 17 | "typescript": "^4.0.3", 18 | "url-parse": "^1.5.0", 19 | "y18n": "^4.0.1" 20 | }, 21 | "scripts": { 22 | "start": "react-scripts start", 23 | "build": "react-scripts build", 24 | "test": "react-scripts test", 25 | "eject": "react-scripts eject", 26 | "clean": "rimraf build publish", 27 | "zip": "mkdir publish && cd build/ && copy ..\\*.md . && copy ..\\LICENSE.txt . && rimraf index.html && bestzip ../publish/plugin.zip *" 28 | }, 29 | "eslintConfig": { 30 | "extends": "react-app" 31 | }, 32 | "browserslist": { 33 | "production": [ 34 | ">0.2%", 35 | "not dead", 36 | "not op_mini all" 37 | ], 38 | "development": [ 39 | "last 1 chrome version", 40 | "last 1 firefox version", 41 | "last 1 safari version" 42 | ] 43 | }, 44 | "devDependencies": { 45 | "bestzip": "^2.1.7", 46 | "rimraf": "^3.0.2" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /public/admin/class-bing-url-submission-admin.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class Bing_Webmaster_Admin { 11 | 12 | /** 13 | * The ID of this plugin. 14 | * 15 | * @since 0.01.01 16 | * @access private 17 | * @var string $plugin_name The ID of this plugin. 18 | */ 19 | private $plugin_name; 20 | 21 | /** 22 | * The version of this plugin. 23 | * 24 | * @since 0.01.01 25 | * @access private 26 | * @var string $version The current version of this plugin. 27 | */ 28 | private $version; 29 | 30 | private $prefix = "bwt-"; 31 | 32 | private $routes; 33 | 34 | /** 35 | * Initialize the class and set its properties. 36 | * 37 | * @since 0.01.01 38 | * @param string $plugin_name The name of this plugin. 39 | * @param string $version The version of this plugin. 40 | */ 41 | public function __construct( $plugin_name, $version ) { 42 | 43 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/utils/class-bing-url-submission-admin-utils.php'; 44 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/utils/class-bing-url-submission-admin-routes.php'; 45 | $this->plugin_name = $plugin_name; 46 | $this->version = $version; 47 | $this->routes = new Bing_Webmaster_Admin_Routes($this->plugin_name, $this->version, $this->prefix); 48 | 49 | } 50 | 51 | /** 52 | * Register the stylesheets for the admin area. 53 | * 54 | * @since 0.01.01 55 | */ 56 | public function enqueue_styles() { 57 | 58 | $CSSfiles = scandir(dirname(__FILE__) . '/../static/css/'); 59 | foreach($CSSfiles as $filename) { 60 | if(strpos($filename,'.css')&&strpos($filename,'.css')+4 === strlen($filename)) { 61 | wp_enqueue_style( $filename, plugin_dir_url( __FILE__ ) . '../static/css/' . $filename, array(), mt_rand(10,1000), 'all' ); 62 | } 63 | } 64 | } 65 | 66 | /** 67 | * Register the JavaScript for the admin area. 68 | * 69 | * @since 0.01.01 70 | */ 71 | public function enqueue_scripts() { 72 | 73 | wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/bing-url-submission-admin.js', array( 'jquery' ), $this->version, false ); 74 | 75 | $JSfiles = scandir(dirname(__FILE__) . '/../static/js/'); 76 | $react_js_to_load = ''; 77 | foreach($JSfiles as $filename) { 78 | if(strpos($filename,'.js')&&strpos($filename,'.js')+3 === strlen($filename)) { 79 | $react_js_to_load = plugin_dir_url( __FILE__ ) . '../static/js/' . $filename; 80 | wp_enqueue_script($filename, $react_js_to_load, '', mt_rand(10,1000), true); 81 | } 82 | } 83 | 84 | wp_localize_script( $this->plugin_name, 'wpr_object', array( 85 | 'api_nonce' => wp_create_nonce( 'wp_rest' ), 86 | 'api_url' => rest_url( $this->plugin_name . '/v_' . $this->version .'/' ), 87 | ) 88 | ); 89 | 90 | } 91 | 92 | public function register_routes() 93 | { 94 | $this->routes->register_routes(); 95 | } 96 | 97 | /** 98 | * Register the administration menu for this plugin into the WordPress Dashboard menu. 99 | * 100 | * @since 0.01.01 101 | */ 102 | public function add_plugin_admin_menu() 103 | { 104 | /* 105 | * Add a menu page for this plugin. 106 | */ 107 | add_menu_page( 108 | __('Bing Webmaster Tools Url Submission', $this->plugin_name), 109 | __('Bing Webmaster', $this->plugin_name), 110 | 'manage_options', 111 | $this->plugin_name, 112 | array($this, 'display_plugin_admin_page'), 113 | 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNC45MiIgaGVpZ2h0PSIyMS4zMjgiIHZpZXdCb3g9IjAgMCAxNC45MiAyMS4zMjgiPg0KICAgIDxnIGZpbGw9IiNmZmYiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDMxMS41IC03OTYuMTY5KSI+DQogICAgICAgIDxwYXRoIGQ9Ik0tMzExLjUsNzk2LjE2OWw0LjI2MSwxLjV2MTVsNi0zLjQ2NC0yLjk0Mi0xLjM4LTEuODU2LTQuNjIsOS40NTYsMy4zMjJ2NC44M2wtMTAuNjU2LDYuMTQ2LTQuMjYzLTIuMzcxWiI+PC9wYXRoPg0KICAgIDwvZz4NCjwvc3ZnPg==' 114 | ); 115 | } 116 | 117 | /** 118 | * Render the admin page for this plugin. 119 | * 120 | * @since 0.01.01 121 | */ 122 | public function display_plugin_admin_page() 123 | { 124 | include_once('partials/bing-url-submission-admin-react.php'); 125 | } 126 | 127 | /** 128 | * Add action link to the plugins page. 129 | * 130 | * @since 0.01.01 131 | */ 132 | public function add_action_links($links) 133 | { 134 | /* 135 | * Documentation : https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name) 136 | */ 137 | $settings_link = array( 138 | '' . __('Settings', $this->plugin_name) . '', 139 | ); 140 | return array_merge($settings_link, $links); 141 | } 142 | 143 | // This function checks the type of update on a page/post and accordingly calls the submit api if enabled 144 | public function on_post_published($new_status, $old_status, $post) 145 | { 146 | $admin_api_key = get_option( $this->prefix . "admin_api_key" ); 147 | $is_valid_api_key = get_option( $this->prefix . "is_valid_api_key" ); 148 | $auto_submission_enabled = get_option( $this->prefix . "auto_submission_enabled" ); 149 | $is_change = false; 150 | $type = "add"; 151 | if ($old_status === 'publish' && $new_status === 'publish') { 152 | $is_change = true; 153 | $type = "update"; 154 | } 155 | else if ($old_status != 'publish' && $new_status === 'publish') { 156 | $is_change = true; 157 | $type = "add"; 158 | } 159 | else if ($old_status === 'publish' && $new_status === 'trash') { 160 | $is_change = true; 161 | $type = "delete"; 162 | } 163 | if ($is_change) { 164 | if (isset($is_valid_api_key) && $is_valid_api_key && $auto_submission_enabled && $auto_submission_enabled === "1") { 165 | $link = get_permalink($post); 166 | // remove __trashed from page url 167 | if (strpos($link, "__trashed") > 0) { 168 | $link = substr($link, 0, strlen($link) - 10) . "/"; 169 | } 170 | if(empty($link)){ 171 | if ( true === WP_DEBUG && true === WP_DEBUG_LOG) error_log(__METHOD__ . " link is empty"); 172 | return; 173 | } 174 | 175 | if(function_exists('is_post_publicly_viewable')){ 176 | $is_public_post = is_post_publicly_viewable($post); 177 | 178 | if ( true === WP_DEBUG && true === WP_DEBUG_LOG) { 179 | error_log(__METHOD__ . " is_public_post". (int)$is_public_post); 180 | error_log(__METHOD__ . " link ". $link); 181 | } 182 | 183 | if(!$is_public_post && $type != 'delete'){ 184 | return; 185 | } 186 | }else{ 187 | $http_response_header = wp_safe_remote_head($link); 188 | $res_code = wp_remote_retrieve_response_code($http_response_header); 189 | 190 | if (true === WP_DEBUG && true === WP_DEBUG_LOG) error_log(__METHOD__ . " link ". $link." ".$res_code); 191 | 192 | if(empty($res_code) || ($res_code != 200 && $type != 'delete')){ 193 | return; 194 | } 195 | } 196 | 197 | $siteUrl = get_home_url(); 198 | 199 | // check if same url was submitted recently(within a minute) 200 | if ($new_status != 'trash' && Bing_Webmaster_Admin_Utils::url_submitted_within_last_minute(Bing_Webmaster_Admin_Routes::$passed_submissions_table, $link)) { 201 | return; 202 | } 203 | $api_key = base64_decode($admin_api_key); 204 | $output = $this->routes->submit_url_to_bwt($siteUrl, $link, $api_key, $type, false); 205 | $this->routes->update_submission_output($output, $link); 206 | } 207 | } 208 | } 209 | 210 | public function options_update() 211 | { 212 | register_setting($this->plugin_name, $this->plugin_name, array($this, 'validate')); 213 | } 214 | 215 | public function validate($input) 216 | { 217 | return $input; 218 | } 219 | 220 | } 221 | -------------------------------------------------------------------------------- /public/admin/index.php: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /public/admin/utils/class-bing-url-submission-admin-routes.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class Bing_Webmaster_Admin_Routes { 12 | 13 | /** 14 | * The ID of this plugin. 15 | * 16 | * @since 0.01.01 17 | * @access private 18 | * @var string $plugin_name The ID of this plugin. 19 | */ 20 | private $plugin_name; 21 | 22 | /** 23 | * The version of this plugin. 24 | * 25 | * @since 0.01.01 26 | * @access private 27 | * @var string $version The current version of this plugin. 28 | */ 29 | private $version; 30 | 31 | private $prefix = "bwt-"; 32 | 33 | public static $passed_submissions_table = "bwt_passed_submissions"; 34 | 35 | public static $failed_submissions_table = "bwt_failed_submissions"; 36 | 37 | /** 38 | * Initialize the class and set its properties. 39 | * 40 | * @since 0.01.01 41 | * @param string $plugin_name The name of this plugin. 42 | * @param string $version The version of this plugin. 43 | */ 44 | public function __construct( $plugin_name, $version, $prefix ) { 45 | 46 | $this->plugin_name = $plugin_name; 47 | $this->version = $version; 48 | $this->prefix = $prefix; 49 | } 50 | 51 | // This function registers all the necessary routes needed by the UI 52 | public function register_routes() { 53 | $namespace = $this->plugin_name . '/v_' . $this->version; 54 | 55 | $endpoint = '/apiKey/'; 56 | register_rest_route( $namespace, $endpoint, array( 57 | array( 58 | 'methods' => \WP_REST_Server::READABLE, 59 | 'callback' => array( $this, 'get_api_key' ), 60 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 61 | ), 62 | ) ); 63 | 64 | register_rest_route( $namespace, $endpoint, array( 65 | array( 66 | 'methods' => \WP_REST_Server::EDITABLE, 67 | 'callback' => array( $this, 'update_api_key' ), 68 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 69 | ), 70 | ) ); 71 | 72 | $endpoint = '/apiKeyValidity/'; 73 | register_rest_route( $namespace, $endpoint, array( 74 | array( 75 | 'methods' => \WP_REST_Server::READABLE, 76 | 'callback' => array( $this, 'check_api_key_validity' ), 77 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 78 | ), 79 | ) ); 80 | 81 | $endpoint = '/apiSettings/'; 82 | register_rest_route( $namespace, $endpoint, array( 83 | array( 84 | 'methods' => \WP_REST_Server::READABLE, 85 | 'callback' => array( $this, 'get_api_settings' ), 86 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 87 | ), 88 | ) ); 89 | 90 | $endpoint = '/automaticSubmission/'; 91 | register_rest_route( $namespace, $endpoint, array( 92 | array( 93 | 'methods' => \WP_REST_Server::EDITABLE, 94 | 'callback' => array( $this, 'update_auto_submit' ), 95 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 96 | ), 97 | ) ); 98 | 99 | $endpoint = '/submitUrl/'; 100 | register_rest_route( $namespace, $endpoint, array( 101 | array( 102 | 'methods' => \WP_REST_Server::EDITABLE, 103 | 'callback' => array( $this, 'submit_url' ), 104 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 105 | ), 106 | ) ); 107 | 108 | $endpoint = '/getStats/'; 109 | register_rest_route( $namespace, $endpoint, array( 110 | array( 111 | 'methods' => \WP_REST_Server::READABLE, 112 | 'callback' => array( $this, 'get_stats' ), 113 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 114 | ), 115 | ) ); 116 | 117 | $endpoint = '/allSubmissions/'; 118 | register_rest_route( $namespace, $endpoint, array( 119 | array( 120 | 'methods' => \WP_REST_Server::READABLE, 121 | 'callback' => array( $this, 'get_submissions' ), 122 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 123 | ), 124 | ) ); 125 | 126 | register_rest_route( $namespace, $endpoint, array( 127 | array( 128 | 'methods' => \WP_REST_Server::EDITABLE, 129 | 'callback' => array( $this, 'resubmit_submissions' ), 130 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 131 | ), 132 | ) ); 133 | 134 | $endpoint = '/deleteSubmissions/'; 135 | register_rest_route( $namespace, $endpoint, array( 136 | array( 137 | 'methods' => \WP_REST_Server::READABLE, 138 | 'callback' => array( $this, 'delete_submissions' ), 139 | 'permission_callback' => array( $this, 'admin_permissions_check' ), 140 | ), 141 | ) ); 142 | } 143 | 144 | public function admin_permissions_check( $request ) { 145 | return current_user_can( "manage_options" ); 146 | } 147 | 148 | public function get_api_key( $request ) { 149 | return $this->try_catch($request, array($this, 'call_get_api_key')); 150 | } 151 | 152 | public function update_api_key( $request ) { 153 | return $this->try_catch($request, array($this, 'call_update_api_key')); 154 | } 155 | 156 | public function check_api_key_validity( $request ) { 157 | return $this->try_catch(array($request, array($this, 'call_check_api_key_validity')), array($this, 'validate_api_key')); 158 | } 159 | 160 | public function get_api_settings( $request ) { 161 | return $this->try_catch(array($request, array($this, 'call_get_api_settings')), array($this, 'validate_api_key')); 162 | } 163 | 164 | public function update_auto_submit( $request ) { 165 | return $this->try_catch(array($request, array($this, 'call_update_auto_submit')), array($this, 'validate_api_key')); 166 | } 167 | 168 | /** 169 | * Submitting the Url 170 | */ 171 | public function submit_url($request) { 172 | return $this->try_catch(array($request, array($this, 'call_submit_url')), array($this, 'validate_api_key')); 173 | } 174 | 175 | public function get_stats( $request ) { 176 | return $this->try_catch(array($request, array($this, 'call_get_stats')), array($this, 'validate_api_key')); 177 | } 178 | 179 | public function get_submissions( $request ) { 180 | return $this->try_catch(array($request, array($this, 'call_get_submissions')), array($this, 'validate_api_key')); 181 | } 182 | 183 | public function resubmit_submissions( $request ) { 184 | return $this->try_catch(array($request, array($this, 'call_resubmit_submissions')), array($this, 'validate_api_key')); 185 | } 186 | 187 | public function delete_submissions( $request ) { 188 | return $this->try_catch(array($request, array($this, 'call_delete_submissions')), array($this, 'validate_api_key')); 189 | } 190 | 191 | private function get_site_quota($api_key, $siteUrl) 192 | { 193 | $response = wp_remote_get( "https://www.bing.com/webmaster/api.svc/json/GetUrlSubmissionQuota?apikey=" . $api_key . "&siteUrl=" . $siteUrl . "&client=wp_v_" . $this->version ); 194 | 195 | if (is_wp_error( $response )) { 196 | if ( true === WP_DEBUG && true === WP_DEBUG_LOG) { 197 | error_log(__METHOD__ . " error:WP_Error: ".$response->get_error_message()) ; 198 | } 199 | return -1; 200 | } 201 | if (isset($response['errors'])) { 202 | return -1; 203 | } 204 | try { 205 | if ($response['response']['code'] === 200) { 206 | $message = json_decode($response['body'])->{'d'}->{'DailyQuota'}; 207 | return $message; 208 | } else { 209 | return -1; 210 | } 211 | } catch (\Throwable $th) { 212 | return -1; 213 | } 214 | } 215 | 216 | private function check_bwt_api_key( $api_key ) { 217 | $siteUrl = get_home_url(); 218 | $data = "{\n\t\"siteUrl\":\"".$siteUrl."\"}"; 219 | $response = wp_remote_get( "https://www.bing.com/webmaster/api.svc/json/CheckSiteVerification?apikey=" . $api_key . "&client=wp_v_" . $this->version . "&siteUrl=" . $siteUrl); 220 | 221 | if (is_wp_error( $response )) { 222 | if ( true === WP_DEBUG && true === WP_DEBUG_LOG) { 223 | error_log(__METHOD__ . " error:WP_Error: ".$response->get_error_message()) ; 224 | } 225 | return "error:WP_Error"; 226 | } 227 | if (isset($response['errors'])) { 228 | return "error:RequestFailed"; 229 | } 230 | try { 231 | if ($response['response']['code'] === 200) { 232 | $is_verified = json_decode($response['body'])->{'d'}; 233 | if (is_bool($is_verified) && $is_verified) { 234 | return "success"; 235 | } 236 | else { 237 | return "error:NotVerified"; 238 | } 239 | } else { 240 | if ($response['response']['code'] >= 500 || $response['response']['code'] === 404) { 241 | return "error:" . $response['response']['message']; 242 | } else { 243 | $message = json_decode($response['body'])->{'Message'}; 244 | return "error:" . $message; 245 | } 246 | } 247 | } 248 | catch (\Throwable $th) { 249 | return "error:RequestFailed"; 250 | } 251 | } 252 | 253 | private function resubmit_single_submission($siteUrl, $api_key, $submission, &$responses) { 254 | $is_valid_api_key = get_option( $this->prefix . 'is_valid_api_key' ); 255 | $failed_count = get_option( $this->prefix . 'failed_count' ); 256 | $passed_count = get_option( $this->prefix . 'passed_count' ); 257 | 258 | $fail_count = null; 259 | if (is_bool($failed_count)) { 260 | $fail_count = new SubmissionCount(); 261 | } 262 | else { 263 | $fail_count = $failed_count; 264 | } 265 | $pass_count = null; 266 | if (is_bool($passed_count)) { 267 | $pass_count = new SubmissionCount(); 268 | } 269 | else { 270 | $pass_count = $passed_count; 271 | } 272 | 273 | if ($is_valid_api_key && $is_valid_api_key === "1") { 274 | $output = $this->submit_url_to_bwt($siteUrl, $submission->url, $api_key, $submission->type, true); 275 | if (substr($output, 0, 6) == 'error:') { 276 | $error = $this->get_api_error(substr($output, 6)); 277 | $response = new SubmissionResponse($submission->url, false, $error); 278 | Bing_Webmaster_Admin_Utils::insert_submission(Bing_Webmaster_Admin_Routes::$failed_submissions_table, new Submissions($submission->url, time(), 0, $submission->type, $error)); 279 | array_push($responses, $response); 280 | Bing_Webmaster_Admin_Utils::increase_count($fail_count); 281 | update_option( $this->prefix . 'failed_count', $fail_count ); 282 | return false; 283 | } else { 284 | $response = new SubmissionResponse($submission->url, true, WPErrors::Success); 285 | array_push($responses, $response); 286 | Bing_Webmaster_Admin_Utils::insert_submission(Bing_Webmaster_Admin_Routes::$passed_submissions_table, new Submissions($submission->url, time(), 1, $submission->type, WPErrors::Success)); 287 | Bing_Webmaster_Admin_Utils::increase_count($pass_count); 288 | update_option( $this->prefix . 'passed_count', $passed_count ); 289 | return true; 290 | } 291 | } 292 | else { 293 | $response = new SubmissionResponse($submission->url, false, WPErrors::InvalidApiKey); 294 | Bing_Webmaster_Admin_Utils::insert_submission(Bing_Webmaster_Admin_Routes::$failed_submissions_table, new Submissions($submission->url, time(), 0, $submission->type), WPErrors::InvalidApiKey); 295 | array_push($responses, $response); 296 | Bing_Webmaster_Admin_Utils::increase_count($fail_count); 297 | update_option( $this->prefix . 'failed_count', $fail_count ); 298 | return false; 299 | } 300 | } 301 | 302 | public function submit_url_to_bwt($siteUrl, $url, $api_key, $type, $is_manual_submission) 303 | { 304 | $data = "{\n\t\"siteUrl\":\"".$siteUrl."\",\n\"url\":\"".$url."\"\n}"; 305 | $response = wp_remote_post( "https://www.bing.com/webmaster/api.svc/json/WPSubmitUrl?apikey=" . $api_key . "&auto=" . ($is_manual_submission ? "0" : "1") . "&type=" . $type . "&client=wp_v_" . $this->version . "&siteUrl=" . $siteUrl, array( 'body' => $data, 306 | 'headers' => array( 'Content-Type' => 'application/json') ) ); 307 | 308 | if (is_wp_error( $response )) { 309 | if ( true === WP_DEBUG && true === WP_DEBUG_LOG) { 310 | error_log(__METHOD__ . " error:WP_Error: ".$response->get_error_message()) ; 311 | } 312 | return "error:WP_Error"; 313 | } 314 | if (isset($response['errors'])) { 315 | return "error:RequestFailed"; 316 | } 317 | try { 318 | if ($response['response']['code'] === 200) { 319 | return "success"; 320 | } else { 321 | if ($response['response']['code'] >= 500) { 322 | return "error:" . $response['response']['message']; 323 | } else { 324 | $message = json_decode($response['body'])->{'Message'}; 325 | return "error:" . $message; 326 | } 327 | } 328 | } 329 | catch (\Throwable $th) { 330 | return "error:RequestFailed"; 331 | } 332 | } 333 | 334 | public function update_submission_output($output, $url) { 335 | $failed_count = get_option( $this->prefix . 'failed_count' ); 336 | $passed_count = get_option( $this->prefix . 'passed_count' ); 337 | if (substr($output, 0, 6) == 'error:') { 338 | $error_msg = substr($output, 6); 339 | $error_type = $this->get_api_error($error_msg); 340 | $failedUrl = new Submissions($url, time(), 0, "add", $error_type); 341 | Bing_Webmaster_Admin_Utils::insert_submission(Bing_Webmaster_Admin_Routes::$failed_submissions_table, $failedUrl); 342 | $fail_count = null; 343 | if (is_bool($failed_count)) { 344 | $fail_count = new SubmissionCount(); 345 | } 346 | else { 347 | $fail_count = $failed_count; 348 | } 349 | Bing_Webmaster_Admin_Utils::increase_count($fail_count); 350 | // get the lastest options to avoid inconsistency 351 | update_option( $this->prefix . 'failed_count', $fail_count ); 352 | 353 | return new \WP_REST_Response( array( 354 | 'error' => $error_type 355 | ), 200 ); 356 | } else { 357 | $passedUrl = new Submissions($url, time(), 1, "add", WPErrors::Success); 358 | Bing_Webmaster_Admin_Utils::insert_submission(Bing_Webmaster_Admin_Routes::$passed_submissions_table, $passedUrl); 359 | $pass_count = null; 360 | if (is_bool($passed_count)) { 361 | $pass_count = new SubmissionCount(); 362 | } 363 | else { 364 | $pass_count = $passed_count; 365 | } 366 | Bing_Webmaster_Admin_Utils::increase_count($pass_count); 367 | // get the lastest options to avoid inconsistency 368 | update_option( $this->prefix . 'passed_count', $pass_count ); 369 | 370 | return new \WP_REST_Response( array( 371 | 'error' => WPErrors::NoError 372 | ), 200 ); 373 | } 374 | } 375 | 376 | private function try_catch( $parameters, $function ) { 377 | try { 378 | return call_user_func($function, $parameters); 379 | } 380 | catch (\Throwable $th) { 381 | return new \WP_REST_Response( array( 382 | 'hasAPIKey' => false, 383 | 'error' => WPErrors::InvalidRequest, 384 | 'error_type' => WPErrors::InvalidRequest 385 | ), 500 ); 386 | } 387 | catch (\Exception $e) { 388 | return new \WP_REST_Response( array( 389 | 'hasAPIKey' => false, 390 | 'error' => WPErrors::InvalidRequest, 391 | 'error_type' => WPErrors::InvalidRequest 392 | ), 500 ); 393 | } 394 | } 395 | 396 | private function validate_api_key( $parameters ) { 397 | $admin_api_key = get_option($this->prefix . "admin_api_key"); 398 | if ($admin_api_key && !empty($admin_api_key)) { 399 | return call_user_func($parameters[1], $parameters[0], $admin_api_key); 400 | } 401 | if (!$admin_api_key) { 402 | return new \WP_REST_Response( array( 403 | 'error_type' => WPErrors::ErrorInWpOptions, 404 | 'error' => WPErrors::ErrorInWpOptions 405 | ), 400 ); 406 | } 407 | return new \WP_REST_Response( array( 408 | 'error_type' => WPErrors::ApiKeyNotFound, 409 | 'error' => WPErrors::ApiKeyNotFound 410 | ), 400 ); 411 | } 412 | 413 | private function call_get_api_key( $request ) { 414 | $admin_api_key = get_option($this->prefix . "admin_api_key"); 415 | 416 | if ( ! $admin_api_key || empty($admin_api_key)) { 417 | return new \WP_REST_Response( array( 418 | 'hasAPIKey' => false 419 | ), 200 ); 420 | } 421 | 422 | return new \WP_REST_Response( array( 423 | 'hasAPIKey' => true 424 | ), 200 ); 425 | } 426 | 427 | private function call_update_api_key( $request ) { 428 | $body = $request->get_body(); 429 | if (isset($body)) { 430 | $json = json_decode($body); 431 | if (isset($json->APIKey) && !empty($json->APIKey)) { 432 | $apiKey = sanitize_text_field($json->APIKey); 433 | if (preg_match('/^[a-f0-9]{32}$/i', $json->APIKey)) { 434 | $response = $this->check_bwt_api_key($apiKey); 435 | 436 | if (substr($response, 0, 6) != "error:") { 437 | // get the lastest options to avoid inconsistency 438 | update_option($this->prefix . 'admin_api_key', base64_encode($apiKey)); 439 | update_option($this->prefix . 'is_valid_api_key', "1"); 440 | update_option($this->prefix . 'auto_submission_enabled', "1"); 441 | return new \WP_REST_Response( array( 442 | 'error_type' => WPErrors::NoError 443 | ), 200 ); 444 | } 445 | else { 446 | $message = substr($response, 6); 447 | $error_type = $this->get_api_error($message, true); 448 | return new \WP_REST_Response( array( 449 | 'error_type' => $error_type 450 | ), 200 ); 451 | } 452 | } 453 | else { 454 | return new \WP_REST_Response( array( 455 | 'error_type' => WPErrors::InvalidApiKeyFormat 456 | ), 200 ); 457 | } 458 | } 459 | // REMOVE LATER 460 | else if(isset($json->APIKey) && empty($json->APIKey)) { 461 | // get the lastest options to avoid inconsistency 462 | update_option($this->prefix . 'admin_api_key', $json->APIKey); 463 | // php treats "0" as false which makes it difficult to check in option is false or value is false 464 | update_option($this->prefix . 'is_valid_api_key', "2"); 465 | update_option($this->prefix . 'auto_submission_enabled', "1"); 466 | return new \WP_REST_Response( array( 467 | 'error_type' => WPErrors::NoError 468 | ), 200 ); 469 | } 470 | } 471 | 472 | return new \WP_REST_Response( array( 473 | 'error_type' => WPErrors::InvalidRequest 474 | ), 200 ); 475 | } 476 | 477 | private function call_check_api_key_validity( $request, $admin_api_key ) { 478 | $api_key = base64_decode($admin_api_key); 479 | $is_valid_api_key = get_option( $this->prefix . 'is_valid_api_key' ); 480 | $response = $this->check_bwt_api_key($api_key); 481 | 482 | if (substr($response, 0, 6) != "error:") { 483 | if (!$is_valid_api_key || $is_valid_api_key === "2") { 484 | // get the lastest options to avoid inconsistency 485 | update_option( $this->prefix . 'is_valid_api_key', true ); 486 | } 487 | return new \WP_REST_Response( array( 488 | 'error_type' => WPErrors::NoError 489 | ), 200 ); 490 | } 491 | else { 492 | $message = substr($response, 6); 493 | $error_type = $this->get_api_error($message); 494 | // get the lastest options to avoid inconsistency 495 | update_option( $this->prefix . 'is_valid_api_key', "2" ); 496 | return new \WP_REST_Response( array( 497 | 'error_type' => $error_type 498 | ), 200 ); 499 | } 500 | } 501 | 502 | private function call_get_api_settings( $request, $admin_api_key ) { 503 | $auto_submission_enabled = get_option( $this->prefix . 'auto_submission_enabled' ); 504 | if (!$auto_submission_enabled) { 505 | update_option( $this->prefix . 'auto_submission_enabled', "1" ); 506 | $auto_submission_enabled = "1"; 507 | } 508 | $siteUrl = get_home_url(); 509 | return new \WP_REST_Response( array( 510 | 'AutoSubmissionEnabled' => $auto_submission_enabled === "1", 511 | 'SiteUrl' => $siteUrl, 512 | 'error_type' => WPErrors::NoError 513 | ), 200 ); 514 | } 515 | 516 | private function call_update_auto_submit( $request, $admin_api_key ) { 517 | $body = $request->get_body(); 518 | if (isset($body)) { 519 | $json = json_decode($body); 520 | if (isset($json->AutoSubmissionEnabled)) { 521 | update_option( $this->prefix . 'auto_submission_enabled', $json->AutoSubmissionEnabled ? "1" : "2" ); 522 | return new \WP_REST_Response( array( 523 | 'error_type' => WPErrors::NoError 524 | ), 200 ); 525 | } 526 | } 527 | 528 | return new \WP_REST_Response( array( 529 | 'error_type' => WPErrors::InvalidRequest 530 | ), 200 ); 531 | } 532 | 533 | private function call_submit_url( $request, $admin_api_key ) { 534 | $api_key = base64_decode(($admin_api_key)); 535 | $is_valid_api_key = get_option( $this->prefix . 'is_valid_api_key' ); 536 | $body = $request->get_body(); 537 | if (isset($body)) { 538 | $json = json_decode($body); 539 | if (isset($json->url) && !empty($json->url)) { 540 | $url = sanitize_text_field($json->url); 541 | if (empty($url) || !preg_match('/^(https?:\/\/([-\w\.]+)+(:\d+)?(\/([-\w\/_\.]*(\?\S+)?)?)?)$/i', $url, $matches)) { 542 | return new \WP_REST_Response( array( 543 | 'error' => WPErrors::InvalidInputUrl 544 | ), 200 ); 545 | } else { 546 | if ($is_valid_api_key && $is_valid_api_key === "1") { 547 | $parsedUrl = wp_parse_url($url); 548 | $siteUrl = get_home_url(); 549 | $output = $this->submit_url_to_bwt($siteUrl, $url, $api_key, "add", true); 550 | return $this->update_submission_output($output, $url); 551 | } 552 | return new \WP_REST_Response( array( 553 | 'error' => WPErrors::InvalidApiKey 554 | ), 200 ); 555 | } 556 | } 557 | return new \WP_REST_Response( array( 558 | 'error' => WPErrors::EmptyUrl 559 | ), 200 ); 560 | } 561 | } 562 | 563 | private function call_get_stats( $request, $admin_api_key ) { 564 | $failed_count = get_option( $this->prefix . 'failed_count' ); 565 | $passed_count = get_option( $this->prefix . 'passed_count' ); 566 | $is_valid_api_key = get_option( $this->prefix . 'is_valid_api_key' ); 567 | // check if we have failed submissions 568 | if (is_bool($failed_count)) { 569 | $failed_count = new SubmissionCount(); 570 | } 571 | // check if we have passed submissions 572 | if (is_bool($passed_count)) { 573 | $passed_count = new SubmissionCount(); 574 | } 575 | $pass_count = Bing_Webmaster_Admin_Utils::get_count($passed_count); 576 | $fail_count = Bing_Webmaster_Admin_Utils::get_count($failed_count); 577 | // save the options, incase they got updated 578 | update_option( $this->prefix . 'failed_count', $failed_count ); 579 | update_option( $this->prefix . 'passed_count', $passed_count ); 580 | $quota = -1; 581 | if ($is_valid_api_key && $is_valid_api_key === "1") { 582 | $siteUrl = get_home_url(); 583 | $quota = $this->get_site_quota(base64_decode($admin_api_key), $siteUrl); 584 | } 585 | return new \WP_REST_Response( array( 586 | 'FailedSubmissionCount' => $fail_count, 587 | 'PassedSubmissionCount' => $pass_count, 588 | 'Quota' => $quota, 589 | 'error_type' => WPErrors::NoError 590 | ), 200 ); 591 | } 592 | 593 | private function call_get_submissions( $request, $admin_api_key ) { 594 | $passed_submissions = Bing_Webmaster_Admin_Utils::get_submissions(Bing_Webmaster_Admin_Routes::$passed_submissions_table); 595 | $failed_submissions = Bing_Webmaster_Admin_Utils::get_submissions(Bing_Webmaster_Admin_Routes::$failed_submissions_table); 596 | $submissions = array_merge($failed_submissions, $passed_submissions); 597 | usort($submissions, function ($a, $b) { 598 | return $a->submission_date > $b->submission_date; 599 | }); 600 | 601 | return new \WP_REST_Response( array( 602 | 'Submissions' => $submissions, 603 | 'error_type' => WPErrors::NoError 604 | ), 200 ); 605 | } 606 | 607 | private function call_resubmit_submissions( $request, $admin_api_key ) { 608 | $api_key = base64_decode(($admin_api_key)); 609 | $body = $request->get_body(); 610 | if (isset($body)) { 611 | $json = json_decode($body); 612 | if (isset($json->Submissions) && count($json->Submissions) > 0) { 613 | $responses = array(); 614 | $siteUrl = get_home_url(); 615 | 616 | $submissions = $json->Submissions; 617 | $has_error = false; 618 | 619 | foreach ($submissions as $submission) { 620 | $has_error = $has_error || !$this->resubmit_single_submission($siteUrl, $api_key, $submission, $responses); 621 | } 622 | if (count($responses) == 0) { 623 | return new \WP_REST_Response( array( 624 | 'error_type' => WPErrors::InvalidOrNoUrls 625 | ), 400 ); 626 | } 627 | return new \WP_REST_Response( array( 628 | 'hasError' => $has_error, 629 | 'SubmissionErrors' => $responses, 630 | 'error_type' => WPErrors::NoError 631 | ), 200 ); 632 | } 633 | return new \WP_REST_Response( array( 634 | 'error_type' => WPErrors::InvalidOrNoUrls 635 | ), 400 ); 636 | } 637 | } 638 | 639 | private function call_delete_submissions( $request, $admin_api_key ) { 640 | Bing_Webmaster_Admin_Utils::delete_submissions(Bing_Webmaster_Admin_Routes::$failed_submissions_table); 641 | Bing_Webmaster_Admin_Utils::delete_submissions(Bing_Webmaster_Admin_Routes::$passed_submissions_table); 642 | 643 | return new \WP_REST_Response( array( 644 | 'FailedSubmissions' => array(), 645 | 'PassedSubmissions' => array(), 646 | 'error_type' => WPErrors::NoError 647 | ), 200 ); 648 | } 649 | 650 | private function get_api_error($message, $isSite = false) { 651 | switch ($message) { 652 | case 'RequestFailed' : return WPErrors::WP_RequestFailed; 653 | case 'NotVerified' : return WPErrors::NotVerified; 654 | case 'Not Found' : return WPErrors::BWT_InvalidApiCall; 655 | default : break; 656 | } 657 | if (strlen($message) < 9) { 658 | return WPErrors::OtherError; 659 | } 660 | $error = substr($message, 9); 661 | switch ($error) { 662 | case 'InternalError' : return WPErrors::BWT_InternalError; 663 | case 'UnknownError' : return WPErrors::BWT_UnknownError; 664 | case 'InvalidApiKey' : return WPErrors::BWT_InvalidApiKey; 665 | case 'ThrottleUser' : return WPErrors::BWT_ThrottleUser; 666 | case 'ThrottleHost' : return WPErrors::BWT_ThrottleHost; 667 | case 'UserBlocked' : return WPErrors::BWT_UserBlocked; 668 | case 'InvalidUrl' : return WPErrors::BWT_InvalidUrl; 669 | case 'InvalidParameter' : return WPErrors::BWT_InvalidParameter; 670 | case 'UserNotFound' : return WPErrors::BWT_UserNotFound; 671 | case 'NotFound' : return WPErrors::BWT_NotFound; 672 | case 'NotAllowed' : return WPErrors::BWT_NotAllowed; 673 | case 'NotAuthorized' : return WPErrors::BWT_NotAuthorized; 674 | case 'ThrottleIP' : return WPErrors::BWT_ThrottleIP; 675 | case 'InvalidToken' : return WPErrors::BWT_InvalidToken; 676 | case 'SiteUriSchemeIsNotSupported' : return WPErrors::BWT_SiteUriSchemeIsNotSupported; 677 | case 'AuthorizationFailed' : return $isSite ? WPErrors::BWT_AuthorizationFailed_Site : WPErrors::BWT_AuthorizationFailed_Url; 678 | default : return $this->get_custom_api_error($error); 679 | } 680 | } 681 | 682 | private function get_custom_api_error($error) { 683 | if (stripos($error, "Invalid Urls") !== false) { 684 | return WPErrors::BWT_InvalidUrl; 685 | } 686 | else if (stripos($error, "null") !== false) { 687 | return WPErrors::BWT_NullException; 688 | } 689 | else if (stripos($error, "exceeded") !== false) { 690 | return WPErrors::BWT_QuotaFull; 691 | } 692 | else { 693 | return $error; 694 | } 695 | } 696 | } 697 | 698 | class Submissions { 699 | public function __construct($url, $submission_date, $submission_type, $type, $error = WPErrors::Success) { 700 | $this->url = $url; 701 | $this->submission_type = $submission_type; 702 | $this->submission_date = $submission_date; 703 | $this->error = $error; 704 | $this->type = $type; 705 | } 706 | 707 | public $url; 708 | public $submission_date; 709 | public $submission_type; 710 | public $error; 711 | public $type; 712 | } 713 | 714 | class SubmissionResponse { 715 | public function __construct($url, $isSubmitted, $error_msg = "") { 716 | $this->url = $url; 717 | $this->isSubmitted = $isSubmitted; 718 | $this->error_msg = $error_msg; 719 | } 720 | public $url; 721 | public $isSubmitted; 722 | public $error_msg; 723 | } 724 | 725 | // The list of potential erorr. All may not be used. 726 | class WPErrors { 727 | const __default = self::Success; 728 | 729 | const NoError = ""; 730 | const Success = "Success"; 731 | const InvalidApiKeyFormat = "Invalid API Key Format"; 732 | const InvalidRequest = "Invalid Request"; 733 | const ErrorInWpOptions = "Error In Fetching WordPress Data"; 734 | const ApiKeyNotFound = "API Key Not Found"; 735 | const InvalidInputUrl = "Invalid Input URL"; 736 | const InvalidApiKey = "Invalid API Key"; 737 | const InvalidOrNoUrls = "Invalid/Missing URLs"; 738 | const NotVerified = "Not Verified"; 739 | const EmptyUrl = "Empty URL"; 740 | const WP_RequestFailed = "Request Failed"; 741 | const BWT_InternalError = "Internal Server Error"; 742 | const BWT_UnknownError = "Unknown Error"; 743 | const BWT_InvalidApiKey = "Invalid API Key"; 744 | const BWT_ThrottleUser = "User Throttled"; 745 | const BWT_ThrottleHost = "Host Throttled"; 746 | const BWT_UserBlocked = "User Blocked"; 747 | const BWT_InvalidUrl = "Invalid Url"; 748 | const BWT_InvalidParameter = "Invalid Parameter"; 749 | const BWT_UserNotFound = "User Not Found"; 750 | const BWT_NotFound = "Not Found"; 751 | const BWT_NotAllowed = "Not Allowed"; 752 | const BWT_NotAuthorized = "Not Authorized"; 753 | const BWT_ThrottleIP = "IP Throttled"; 754 | const BWT_InvalidToken = "Invalid Token"; 755 | const BWT_SiteUriSchemeIsNotSupported = "Site Uri Scheme Is Not Supported"; 756 | const BWT_AuthorizationFailed_Site = "Site Not Registered/Verified In Bing Webmaster"; 757 | const BWT_AuthorizationFailed_Url = "URL Doesn't Belong To The Site"; 758 | const BWT_AuthorizationFailed = "Authorization Failed"; 759 | const BWT_NullException = "Null Value Found"; 760 | const BWT_QuotaFull = "Quota Exceeded"; 761 | const BWT_InvalidApiCall = "Invalid API Call"; 762 | const OtherError = "Unknown Error Occured"; 763 | } 764 | -------------------------------------------------------------------------------- /public/admin/utils/class-bing-url-submission-admin-utils.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class Bing_Webmaster_Admin_Utils { 12 | /** 13 | * This function finds out the ocunt of submissions in last 48 hours. 14 | */ 15 | public static function get_count( SubmissionCount $submission_count ) { 16 | $curr_time = time(); 17 | self::set_last_date( $submission_count, $curr_time ); 18 | $count = 0; 19 | for ( $i = 0; $i < 48; $i++ ) { 20 | $count += $submission_count->hourly_count[ $i ]; 21 | } 22 | return $count; 23 | } 24 | 25 | /** 26 | * Increase the count by 1. 27 | */ 28 | public static function increase_count( SubmissionCount $submission_count ) { 29 | $curr_time = time(); 30 | self::set_last_date( $submission_count, $curr_time ); 31 | $submission_count->hourly_count[ $submission_count->index ]++; 32 | } 33 | 34 | /** 35 | * Set the last date when count was accessed/increased. 36 | * We store the count in array of size 48, count per hour so that we don't need to store every submission. 37 | */ 38 | private static function set_last_date( SubmissionCount $submission_count, $curr_time ) { 39 | $curr_hour = (int) ( $curr_time / 3600 ); 40 | $last_hour = (int) ( $submission_count->last_count_date / 3600 ); 41 | if ( $curr_hour - $last_hour <= 48 ) { 42 | $i = 0; 43 | for ( $i = ( $submission_count->index + 1 ) % 48; $last_hour < $curr_hour; $i = ( $i + 1 ) % 48, $last_hour++ ) { 44 | $submission_count->hourly_count[ $i ] = 0; 45 | } 46 | $submission_count->index = ( $i + 47 ) % 48; 47 | } else { 48 | for ( $i = 0; $i < 48; $i++ ) { 49 | $submission_count->hourly_count[ $i ] = 0; 50 | } 51 | $submission_count->index = $curr_hour % 24; 52 | } 53 | $submission_count->last_count_date = $curr_time; 54 | } 55 | 56 | /** 57 | * This function retrieves the latest submitted urls upto 20. 58 | * It deletes the older submitted urls from the table. 59 | */ 60 | public static function get_submissions( $table ) { 61 | global $wpdb; 62 | $table_name = $wpdb->prefix . $table; 63 | $date = time() - 48 * 60 * 60; 64 | $results = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . ' WHERE submission_date > %d ORDER BY submission_date DESC LIMIT 21', $date ), OBJECT ); 65 | if ( is_array( $results ) && count( $results ) === 21 ) { 66 | $ids = array(); 67 | $results = array_slice( $results, 0, 20 ); 68 | foreach ( $results as $result ) { 69 | array_push( $ids, $result->id ); 70 | } 71 | $res = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $table_name . ' WHERE id not in ( %s )', implode( ',', $ids ) ) ); 72 | } 73 | return $results; 74 | } 75 | 76 | public static function url_submitted_within_last_minute( $table, $url ) { 77 | global $wpdb; 78 | $table_name = $wpdb->prefix . $table; 79 | $date = time() - 60; 80 | $results = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . ' WHERE submission_date > %d AND url = %s LIMIT 1', array( $date, $url ) ), OBJECT ); 81 | return is_array( $results ) && count( $results ) > 0; 82 | } 83 | 84 | public static function insert_submission( $table, Submissions $submission ) { 85 | global $wpdb; 86 | $table_name = $wpdb->prefix . $table; 87 | $results = $wpdb->insert( 88 | $table_name, 89 | array( 90 | 'url' => $submission->url, 91 | 'submission_type' => $submission->submission_type, 92 | 'submission_date' => $submission->submission_date, 93 | 'error' => $submission->error, 94 | 'type' => $submission->type, 95 | ) 96 | ); 97 | } 98 | 99 | public static function delete_submissions( $table ) { 100 | global $wpdb; 101 | $table_name = $wpdb->prefix . $table; 102 | //phpcs:disable WordPress.DB.PreparedSQL.NotPrepared 103 | $results = $wpdb->query( 'DELETE FROM ' . $table_name ); 104 | return $results; 105 | //phpcs:enable WordPress.DB.PreparedSQL.NotPrepared 106 | } 107 | 108 | public static function is_localhost( $ip = array( '127.0.0.1', '::1' ) ) { 109 | return in_array( $_SERVER['REMOTE_ADDR'], $ip ); 110 | } 111 | } 112 | 113 | class SubmissionCount { 114 | 115 | public function __construct() { 116 | 117 | $this->hourly_count = array(); 118 | for ( $i = 0; $i < 48; $i++ ) { 119 | array_push( $this->hourly_count, 0 ); 120 | } 121 | $this->last_count_date = time(); 122 | 123 | } 124 | 125 | public $hourly_count; 126 | public $last_count_date; 127 | public $index; 128 | } 129 | -------------------------------------------------------------------------------- /public/bing-url-submission.php: -------------------------------------------------------------------------------- 1 | run(); 69 | 70 | } 71 | run_bing_webmaster_url_submission(); 72 | -------------------------------------------------------------------------------- /public/includes/class-bing-url-submission-activator.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | class Bing_Webmaster_Activator { 14 | 15 | /** 16 | * 17 | * @since 0.01.01 18 | */ 19 | public static function activate($plugin_name) { 20 | self::add_failed_submissions_table(); 21 | self::add_passed_submissions_table(); 22 | } 23 | 24 | public static function add_passed_submissions_table() { 25 | global $wpdb; 26 | 27 | $table_name = $wpdb->prefix . 'bwt_passed_submissions'; 28 | 29 | $charset_collate = $wpdb->get_charset_collate(); 30 | 31 | $sql = "CREATE TABLE $table_name ( 32 | id mediumint(10) NOT NULL AUTO_INCREMENT, 33 | submission_date bigint(20) NOT NULL, 34 | submission_type tinytext NOT NULL, 35 | type tinytext NOT NULL, 36 | error text NOT NULL, 37 | url varchar(200) DEFAULT '' NOT NULL, 38 | PRIMARY KEY (id) 39 | ) $charset_collate;"; 40 | 41 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 42 | dbDelta( $sql ); 43 | } 44 | 45 | public static function add_failed_submissions_table() { 46 | global $wpdb; 47 | 48 | $table_name = $wpdb->prefix . 'bwt_failed_submissions'; 49 | 50 | $charset_collate = $wpdb->get_charset_collate(); 51 | 52 | $sql = "CREATE TABLE $table_name ( 53 | id mediumint(10) NOT NULL AUTO_INCREMENT, 54 | submission_date bigint(20) NOT NULL, 55 | submission_type tinytext NOT NULL, 56 | type tinytext NOT NULL, 57 | error text NOT NULL, 58 | url varchar(200) DEFAULT '' NOT NULL, 59 | PRIMARY KEY (id) 60 | ) $charset_collate;"; 61 | 62 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 63 | dbDelta( $sql ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /public/includes/class-bing-url-submission-deactivator.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | class Bing_Webmaster_Deactivator { 14 | 15 | /** 16 | * Short Description. (use period) 17 | * 18 | * Long Description. 19 | * 20 | * @since 0.01.01 21 | */ 22 | public static function deactivate( $plugin_name ) { 23 | delete_option( 'bwt-failed_count' ); 24 | delete_option( 'bwt-passed_count' ); 25 | delete_option( 'bwt-is_valid_api_key' ); 26 | delete_option( 'bwt-admin_api_key' ); 27 | delete_option( 'bwt-auto_submission_enabled' ); 28 | 29 | global $wpdb; 30 | 31 | $table_name = $wpdb->prefix . 'bwt_failed_submissions'; 32 | //phpcs:disable 33 | $wpdb->query( 'DROP TABLE ' . $table_name ); 34 | //phpcs:enable 35 | $table_name = $wpdb->prefix . 'bwt_passed_submissions'; 36 | //phpcs:disable 37 | $wpdb->query( 'DROP TABLE ' . $table_name ); 38 | //phpcs:enable 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /public/includes/class-bing-url-submission-loader.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class Bing_Webmaster_Loader { 15 | 16 | /** 17 | * The array of actions registered with WordPress. 18 | * 19 | * @since 0.01.01 20 | * @access protected 21 | * @var array $actions The actions registered with WordPress to fire when the plugin loads. 22 | */ 23 | protected $actions; 24 | 25 | /** 26 | * The array of filters registered with WordPress. 27 | * 28 | * @since 0.01.01 29 | * @access protected 30 | * @var array $filters The filters registered with WordPress to fire when the plugin loads. 31 | */ 32 | protected $filters; 33 | 34 | /** 35 | * Initialize the collections used to maintain the actions and filters. 36 | * 37 | * @since 0.01.01 38 | */ 39 | public function __construct() { 40 | 41 | $this->actions = array(); 42 | $this->filters = array(); 43 | 44 | } 45 | 46 | /** 47 | * Add a new action to the collection to be registered with WordPress. 48 | * 49 | * @since 0.01.01 50 | * @param string $hook The name of the WordPress action that is being registered. 51 | * @param object $component A reference to the instance of the object on which the action is defined. 52 | * @param string $callback The name of the function definition on the $component. 53 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10. 54 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. 55 | */ 56 | public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 57 | $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); 58 | } 59 | 60 | /** 61 | * Add a new filter to the collection to be registered with WordPress. 62 | * 63 | * @since 0.01.01 64 | * @param string $hook The name of the WordPress filter that is being registered. 65 | * @param object $component A reference to the instance of the object on which the filter is defined. 66 | * @param string $callback The name of the function definition on the $component. 67 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10. 68 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 69 | */ 70 | public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 71 | $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); 72 | } 73 | 74 | /** 75 | * A utility function that is used to register the actions and hooks into a single 76 | * collection. 77 | * 78 | * @since 0.01.01 79 | * @access private 80 | * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). 81 | * @param string $hook The name of the WordPress filter that is being registered. 82 | * @param object $component A reference to the instance of the object on which the filter is defined. 83 | * @param string $callback The name of the function definition on the $component. 84 | * @param int $priority The priority at which the function should be fired. 85 | * @param int $accepted_args The number of arguments that should be passed to the $callback. 86 | * @return array The collection of actions and filters registered with WordPress. 87 | */ 88 | private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { 89 | 90 | $hooks[] = array( 91 | 'hook' => $hook, 92 | 'component' => $component, 93 | 'callback' => $callback, 94 | 'priority' => $priority, 95 | 'accepted_args' => $accepted_args 96 | ); 97 | 98 | return $hooks; 99 | 100 | } 101 | 102 | /** 103 | * Register the filters and actions with WordPress. 104 | * 105 | * @since 0.01.01 106 | */ 107 | public function run() { 108 | 109 | foreach ( $this->filters as $hook ) { 110 | add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 111 | } 112 | 113 | foreach ( $this->actions as $hook ) { 114 | add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 115 | } 116 | 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /public/includes/class-bing-url-submission.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class Bing_Webmaster { 17 | 18 | /** 19 | * The loader that's responsible for maintaining and registering all hooks that power 20 | * the plugin. 21 | * 22 | * @since 0.01.01 23 | * @access protected 24 | * @var Bing_Webmaster_Loader $loader Maintains and registers all hooks for the plugin. 25 | */ 26 | protected $loader; 27 | 28 | /** 29 | * The unique identifier of this plugin. 30 | * 31 | * @since 0.01.01 32 | * @access protected 33 | * @var string $plugin_name The string used to uniquely identify this plugin. 34 | */ 35 | protected $plugin_name; 36 | 37 | /** 38 | * The current version of the plugin. 39 | * 40 | * @since 0.01.01 41 | * @access protected 42 | * @var string $version The current version of the plugin. 43 | */ 44 | protected $version; 45 | 46 | /** 47 | * Define the core functionality of the plugin. 48 | * 49 | * Set the plugin name and the plugin version that can be used throughout the plugin. 50 | * Load the dependencies and set the hooks for the admin area. 51 | * 52 | * @since 0.01.01 53 | */ 54 | public function __construct($plugin_name) { 55 | if ( defined( 'BWT_URL_SUBMISSION_PLUGIN_VERSION' ) ) { 56 | $this->version = BWT_URL_SUBMISSION_PLUGIN_VERSION; 57 | } else { 58 | $this->version = '1.0.13'; 59 | } 60 | $this->plugin_name = $plugin_name; 61 | 62 | $this->load_dependencies(); 63 | $this->define_admin_hooks(); 64 | 65 | } 66 | 67 | /** 68 | * Load the required dependencies for this plugin. 69 | * 70 | * Include the following files that make up the plugin: 71 | * 72 | * - Bing_Webmaster_Loader. Orchestrates the hooks of the plugin. 73 | * - Bing_Webmaster_Admin. Defines all hooks for the admin area. 74 | * 75 | * Create an instance of the loader which will be used to register the hooks 76 | * with WordPress. 77 | * 78 | * @since 0.01.01 79 | * @access private 80 | */ 81 | private function load_dependencies() { 82 | 83 | /** 84 | * The class responsible for orchestrating the actions and filters of the 85 | * core plugin. 86 | */ 87 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-bing-url-submission-loader.php'; 88 | 89 | /** 90 | * The class responsible for defining all actions that occur in the admin area. 91 | */ 92 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-bing-url-submission-admin.php'; 93 | 94 | $this->loader = new Bing_Webmaster_Loader(); 95 | 96 | } 97 | 98 | /** 99 | * Register all of the hooks related to the admin area functionality 100 | * of the plugin. 101 | * 102 | * @since 0.01.01 103 | * @access private 104 | */ 105 | private function define_admin_hooks() { 106 | 107 | $plugin_admin = new Bing_Webmaster_Admin( $this->get_plugin_name(), $this->get_version() ); 108 | 109 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); 110 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); 111 | 112 | // Save/Update our plugin options. 113 | $this->loader->add_action( 'admin_init', $plugin_admin, 'options_update'); 114 | 115 | $this->loader->add_action( 'rest_api_init', $plugin_admin, 'register_routes'); 116 | 117 | // Add a new admin menu. 118 | $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_admin_menu' ); 119 | 120 | // Add Settings link to the plugin. 121 | $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' ); 122 | $this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $plugin_admin, 'add_action_links' ); 123 | 124 | // Add url submit action & post publishing. 125 | $this->loader->add_action( 'transition_post_status', $plugin_admin, 'on_post_published', 10, 3 ); 126 | } 127 | 128 | /** 129 | * Run the loader to execute all of the hooks with WordPress. 130 | * 131 | * @since 0.01.01 132 | */ 133 | public function run() { 134 | $this->loader->run(); 135 | } 136 | 137 | /** 138 | * The name of the plugin used to uniquely identify it within the context of 139 | * WordPress and to define internationalization functionality. 140 | * 141 | * @since 1.0.0 142 | * @return string The name of the plugin. 143 | */ 144 | public function get_plugin_name() { 145 | return $this->plugin_name; 146 | } 147 | 148 | /** 149 | * The reference to the class that orchestrates the hooks with the plugin. 150 | * 151 | * @since 1.0.0 152 | * @return Bing_Webmaster_Loader Orchestrates the hooks of the plugin. 153 | */ 154 | public function get_loader() { 155 | return $this->loader; 156 | } 157 | 158 | /** 159 | * Retrieve the version number of the plugin. 160 | * 161 | * @since 1.0.0 162 | * @return string The version number of the plugin. 163 | */ 164 | public function get_version() { 165 | return $this->version; 166 | } 167 | 168 | } 169 | -------------------------------------------------------------------------------- /public/includes/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | Add New'. 38 | 1. Search for 'Bing URL Submissions Plugin' and install. 39 | 1. Once installed, click on 'Activate' to enable plugin. 40 | 41 | ### SETTING UP WITH API KEY 42 | 1. Open Bing URL Submissions plugin settings page by clicking on "Settings" link for the plugin. (Or the 'Bing Webmaster' link in the navigation menu). 43 | 1. You should now be greeted with a prompt to enter API key. 44 | 1. Enter your Bing Webmaster API key into the prompt in the plugin page. (You can obtain API key by following the instructions [here](https://docs.microsoft.com/bingwebmaster/getting-access#using-api-key). Ensure that your WordPress site is verified with Bing Webmaster). 45 | 1. Voila! Your WordPress site is now configured to automatically submit URLs to Bing. 46 | 47 | 48 | == Frequently Asked Questions == 49 | 50 | = Why should I install Bing URL Submission Plugin = 51 | 52 | Bing Webmaster enables quick indexing of your site URLs via the Submit URL API. Bing URL Submissions Plugin automates the submissions of your site URLs to this API by automatically submitting URLs for any page updated/created from WordPress. 53 | 54 | = Where do I get API key? = 55 | 56 | To automate Bing URL submissions using the Bing URL Submission Plugin, you need to have your WordPress site registered with Bing Webmaster. Once your site is verified at Bing Webmaster, you can access your API key by navigating to Settings > API Access > API Key within Bing Webmaster portal. 57 | 58 | = I got an error "Adding API key failed: Invalid API Key" when I'm trying to log in to the plugin dashboard using API key. What do I do? = 59 | 60 | "Invalid URL" error indicates that your API key is invalid for the WordPress site you're trying to configure the plugin against. Please verify that your WordPress site is added and verified against your Webmaster account. 61 | 62 | = "Automatic URL Submission" and "Manual URL Submission" cards are greyed out in plugin dashboard. How do I fix this? = 63 | 64 | Automatic and manual URL submission cards are disabled if your API key is detected as invalid for submitting URLs against this WordPress site. Please ensure that your site is verified in your Bing Webmaster account and update the plugin with your new API key using 'Update key' option in the API key card. 65 | 66 | = I got an error "Invalid API key : Update API key to enable Automatic & Manual URL submission.". What do I do? = 67 | 68 | See answer to '"Automatic URL Submission" and "Manual URL Submission" cards are greyed out in plugin dashboard. How do I fix this?' above. 69 | 70 | = How can I delete any stored data in my WordPress database? = 71 | 72 | You can go to 'Plugins' page from your WordPress sidebar and click on Deactivate under Bing URL Submissions plugin. This will remove the API key integration as well as any locally stored data about submitted URLs. Reactivating the plugin will present you with a clean slate and ask for API key input. 73 | 74 | 75 | == Changelog == 76 | 77 | = 1.0.13 = 78 | - Fix: Compatibility update with wordpress v5.8 and linting fixes. 79 | 80 | = 1.0.12 = 81 | - Fix: Compatibility issue with older wordpress versions. 82 | 83 | = 1.0.11 = 84 | - Fix: Non public URL subimssions. 85 | - Fix: Upgrade dependencies to fix vulnerabilities. 86 | 87 | = 1.0.10 = 88 | - Upgrade dependencies to fix vulnerabilities. 89 | 90 | = 1.0.9 = 91 | * Update readme to reflect support for WordPress v5.7. 92 | 93 | = 1.0.8 = 94 | - Upgrade dependencies to fix vulnerabilities and update latest compatiable wordpress version. 95 | 96 | = 1.0.7 = 97 | - Fix console error being thrown by React when not in plugin page. 98 | 99 | = 1.0.6 = 100 | - Upgrade dependencies to fix known vulnerabilities. 101 | 102 | = 1.0.5 = 103 | - Filter out URLs containing specific post_types that aren't browsable. 104 | 105 | = 1.0.4 = 106 | * Fix encoded URLs being displayed in URL Submissions table. 107 | 108 | = 1.0.3 = 109 | * Update root element name. Fixes issue loading plugin settings page. 110 | 111 | = 1.0.2 = 112 | * Rename root element of settings page to avoid conflicts with other plugins. 113 | 114 | = 1.0.1 = 115 | * Update readme to reflect support for WordPress v5.5. 116 | 117 | = 1.0.0 = 118 | * Initial release. 119 | -------------------------------------------------------------------------------- /public/uninstall.php: -------------------------------------------------------------------------------- 1 | { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /src/Constants.ts: -------------------------------------------------------------------------------- 1 | export class StringConstants { 2 | static readonly ApiKeyHelpLink = 3 | "https://docs.microsoft.com/en-us/bingwebmaster/getting-access#using-api-key"; 4 | static readonly BingWebmasterLink = "https://bing.com/webmaster"; 5 | static readonly PluginInfoLink = "https://aka.ms/BingWordpressPluginAbout"; 6 | static readonly ApiKeyValidationError = 7 | "Invalid API key! (Should be alphanumeric and 32 characters in length.)"; 8 | // static readonly domain = "example.com"; 9 | static readonly UrlSubmitErrorMessage = "Invalid URL!"; 10 | } 11 | 12 | export const ApiKeyRegex = RegExp("^[a-zA-Z0-9]{0,32}$"); 13 | // eslint-disable-next-line no-useless-escape 14 | // export const urlRegex = RegExp(`^(?:http(s)?:\/\/)?[\w.-]+(?:\.(${url})+)+[/\w.\S]*$`); 15 | 16 | // eslint-disable-next-line no-useless-escape 17 | export const SubmitUrlRegex = RegExp( 18 | `^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)$` 19 | ); 20 | -------------------------------------------------------------------------------- /src/components/APIHelper.tsx: -------------------------------------------------------------------------------- 1 | import { ErrorConstants } from "./ErrorConstants"; 2 | 3 | declare global { 4 | interface Window { wpr_object: any; } 5 | } 6 | 7 | const baseURL = `${window['wpr_object']['api_url']}`; 8 | 9 | export interface IHttpResponse extends Response { 10 | data?: T; 11 | error?: IAPIError; 12 | } 13 | 14 | export interface IAPIError { 15 | code: string; 16 | message: string; 17 | details?: IAPIErrorDetails[]; 18 | } 19 | 20 | export interface IAPIErrorDetails { 21 | target: string; 22 | message: string; 23 | } 24 | 25 | const nonceHeader = { 26 | headers: { 27 | "X-WP-Nonce": `${window['wpr_object']['api_nonce']}` 28 | } 29 | }; 30 | 31 | export async function useFetch( 32 | requestUrl: RequestInfo 33 | ): Promise> { 34 | return withTimeout( 35 | new Promise((resolve, reject) => { 36 | let response: IHttpResponse; 37 | fetch(`${baseURL}${requestUrl}`, nonceHeader) 38 | .then(res => { 39 | response = res; 40 | return res.json(); 41 | }) 42 | .then(body => { 43 | if (response.ok) { 44 | response.data = body; 45 | } else { 46 | response.error = body; 47 | } 48 | resolve(response); 49 | }) 50 | .catch(err => { 51 | reject(err); 52 | }); 53 | }) 54 | ); 55 | } 56 | 57 | export async function useSubmit( 58 | requestUrl: RequestInfo, 59 | requestData: any 60 | ): Promise> { 61 | return withTimeout( 62 | new Promise((resolve, reject) => { 63 | let response: IHttpResponse; 64 | fetch(`${baseURL}${requestUrl}`, { 65 | method: "POST", 66 | headers: { 67 | ...(nonceHeader.headers), 68 | "Accept": "application/json, text/javascript, */*; q=0.01", 69 | "Content-Type": "application/json;charset=UTF-8" 70 | }, 71 | body: JSON.stringify(requestData) 72 | }) 73 | .then(res => { 74 | response = res; 75 | return res.json(); 76 | }) 77 | .then(body => { 78 | if (response.ok) { 79 | response.data = body; 80 | } else { 81 | response.error = body; 82 | } 83 | resolve(response); 84 | }) 85 | .catch(err => { 86 | reject(err); 87 | }); 88 | }) 89 | ); 90 | } 91 | 92 | export function withTimeout( 93 | promise: Promise>, 94 | timeout = 60000 95 | ) { 96 | let timer: ReturnType; 97 | return Promise.race>([ 98 | promise, 99 | new Promise>((resolve, _) => { 100 | let response: IHttpResponse; 101 | const timeoutInit: ResponseInit = { 102 | status: ErrorConstants.RequestTimedOut.HttpStatusCode 103 | }; 104 | response = new Response(null, timeoutInit); 105 | timer = setTimeout(() => { 106 | response.error = { 107 | code: ErrorConstants.RequestTimedOut.Code, 108 | message: ErrorConstants.RequestTimedOut.Message 109 | }; 110 | resolve(response); 111 | }, timeout); 112 | }) 113 | ]).then(result => { 114 | clearTimeout(timer); 115 | return result; 116 | }); 117 | } 118 | 119 | export async function useDownload( 120 | requestUrl: RequestInfo, 121 | requestData: any, 122 | callback?: () => void 123 | ): Promise> { 124 | return new Promise((resolve, reject) => { 125 | let response: any; 126 | fetch(`${baseURL}${requestUrl}`, { 127 | method: "POST", 128 | headers: { 129 | ...(nonceHeader.headers), 130 | "Accept": "application/json, text/javascript, */*; q=0.01", 131 | "Content-Type": "application/json;charset=UTF-8" 132 | }, 133 | body: JSON.stringify(requestData) 134 | }) 135 | .then(res => { 136 | response = res; 137 | return res.blob(); 138 | }) 139 | .then(blob => { 140 | const url: string = window.URL.createObjectURL(blob); 141 | const a: HTMLAnchorElement = document.createElement("a"); 142 | a.href = url; 143 | a.download = response.headers 144 | .get("content-disposition") 145 | .split("filename=")[1]; 146 | document.body.appendChild(a); // we need to append the element to the dom -> otherwise it will not work in firefox 147 | a.click(); 148 | resolve(response); 149 | setTimeout(() => { 150 | a.remove(); // afterwards we remove the element again 151 | }, 100); 152 | if (callback) { 153 | callback(); 154 | } 155 | }) 156 | .catch(err => { 157 | reject(err); 158 | }); 159 | }); 160 | } 161 | -------------------------------------------------------------------------------- /src/components/App.tsx: -------------------------------------------------------------------------------- 1 | import "../scss/_common.scss"; 2 | import "../scss/responsiveLayout.scss"; 3 | import "../scss/App.scss"; 4 | 5 | import * as React from "react"; 6 | import { useState, useEffect } from "react"; 7 | import { GetApiKey } from "./withDashboardData"; 8 | 9 | import { Header } from "./Header"; 10 | import { StartPage } from "./StartPage"; 11 | import { Dashboard } from "./Dashboard"; 12 | import { Icon } from "@fluentui/react/lib/Icon"; 13 | 14 | export const App: React.FunctionComponent = () => { 15 | const [hasAPIKey, setHasAPIKey] = useState(false); 16 | 17 | // variable to store banners 18 | const [bannerList, setBannerList] = useState([]); 19 | 20 | useEffect(() => { 21 | const data = Promise.resolve(GetApiKey()); 22 | data.then((response) => { 23 | if (response && response.data) { 24 | setHasAPIKey(response.data.hasAPIKey); 25 | } 26 | }); 27 | }, []); 28 | 29 | // Function to add new banner notification 30 | const addBanner = (notification: string) => 31 | setBannerList([notification].concat(bannerList.slice())); 32 | 33 | // remove banner when close button is clicked 34 | const closeBannerOnClick = ( 35 | event: React.MouseEvent 36 | ) => { 37 | let bannerIndexString: string = 38 | (event.target as HTMLElement).dataset.index ?? "0"; 39 | let temp: string[] = bannerList.slice(); 40 | temp.splice(parseInt(bannerIndexString), 1); 41 | setBannerList(temp); 42 | }; 43 | 44 | return ( 45 |
46 |
47 |
48 | {bannerList.map((bannerItem, index) => { 49 | return ( 50 |
-1 55 | ? " bw-BannerSuccess" 56 | : " bw-BannerFailure") 57 | } 58 | > 59 | {bannerItem} 60 | 66 |
67 | ); 68 | })} 69 | {!hasAPIKey && ( 70 | { 73 | setHasAPIKey(true); 74 | setBannerList([]); 75 | }} 76 | /> 77 | )} 78 | {hasAPIKey && } 79 |
80 |
81 | ); 82 | }; 83 | -------------------------------------------------------------------------------- /src/components/Card.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Icon } from "@fluentui/react/lib/Icon"; 3 | import { TooltipHost, ITooltipProps } from "@fluentui/react"; 4 | import { useId } from "@uifabric/react-hooks/lib/useId"; 5 | 6 | export interface ICardProps { 7 | title: string; 8 | tooltip: string; 9 | leadingIconName: string; 10 | className?: string; 11 | } 12 | 13 | export const Card: React.FunctionComponent = (props) => { 14 | const tooltipId = useId(props.title); 15 | 16 | const tooltipProps: ITooltipProps = { 17 | onRenderContent: () => {props.tooltip}, 18 | }; 19 | 20 | return ( 21 |
22 |
23 | 24 | 25 | {props.title} 26 | 27 | 33 | 38 | 39 | 40 |
41 |
42 | {props.children} 43 |
44 |
45 | ); 46 | }; 47 | -------------------------------------------------------------------------------- /src/components/Dashboard.tsx: -------------------------------------------------------------------------------- 1 | import "../scss/Dashboard.scss"; 2 | 3 | import * as React from "react"; 4 | import { useState, useEffect } from "react"; 5 | import { DefaultButton, PrimaryButton } from "@fluentui/react/lib/Button"; 6 | import { Icon } from "@fluentui/react/lib/Icon"; 7 | import { 8 | GetApiSettings, 9 | GetStats, 10 | GetAllSubmissions, 11 | RetryFailedSubmissions, 12 | SubmitUrl, 13 | UpdateAutoSubmissionsEnabled, 14 | SetApiKey, 15 | CheckApiKeyValidity, 16 | } from "./withDashboardData"; 17 | import { ShimmeredDetailsList } from "@fluentui/react/lib/ShimmeredDetailsList"; 18 | import { 19 | IColumn, 20 | SelectionMode, 21 | IChoiceGroupOption, 22 | ChoiceGroup, 23 | TextField, 24 | } from "@fluentui/react/lib/index"; 25 | import { format, formatISO } from "date-fns"; 26 | import { 27 | IGetStatsResponse, 28 | IGetApiSettingsResponse, 29 | IGetAllSubmissionsResponse, 30 | UrlSubmission, 31 | } from "./Interfaces"; 32 | import { Card } from "./Card"; 33 | import { StringConstants, ApiKeyRegex, SubmitUrlRegex } from "../Constants"; 34 | 35 | interface IDashboardProps { 36 | addBanner: (str: string) => void; 37 | } 38 | 39 | export const Dashboard: React.FunctionComponent = (props) => { 40 | enum DashboardModalState { 41 | Hidden = 0, 42 | UpdateApiKeyModal = 1, 43 | EditPrefAutoSubmissionModal = 2, 44 | SubmitUrlModal = 3, 45 | } 46 | 47 | const [apiKeyInvalid, setApiKeyInvalid] = useState(false); 48 | const [apiSettings, setAPISettings] = useState(); 49 | const [submissionStats, setSubmissionStats] = useState(); 50 | const [submissionsList, setSubmissionsList] = useState< 51 | IGetAllSubmissionsResponse 52 | >(); 53 | 54 | // variables to store flyout menu states 55 | const [showApiKeyPopOverMenu, setShowApiKeyPopOverMenu] = useState( 56 | false 57 | ); 58 | const [ 59 | showAutoSubmissionsPopOverMenu, 60 | setShowAutoSubmissionsPopOverMenu, 61 | ] = useState(); 62 | 63 | // variable to control modal display state 64 | const [modalState, setModalState] = useState( 65 | DashboardModalState.Hidden 66 | ); 67 | 68 | // variables storing modal UI controls state 69 | const [ 70 | selectedOptionAutoSubmissions, 71 | setSelectedOptionAutoSubmissions, 72 | ] = useState("enable"); 73 | const [textFieldValueUrlSubmit, setTextFieldValueUrlSubmit] = useState< 74 | string 75 | >(""); 76 | const [textFieldValueApiKey, setTextFieldValueApiKey] = useState(""); 77 | 78 | // variables to trigger UI data refresh 79 | const [urlSubmitted, setUrlSubmitted] = useState(0); 80 | const [apiSettingsUpdated, setApiSettingsUpdated] = useState(0); 81 | const [apiKeyUpdated, setApiKeyUpdated] = useState(0); 82 | 83 | // Check if API key is valid 84 | useEffect(() => { 85 | Promise.resolve(CheckApiKeyValidity()).then((response) => { 86 | if (response && response.data) { 87 | if (response.data.error_type.length !== 0) { 88 | props.addBanner( 89 | "API Key Validation Error: Please check if site is verified or API key is valid to enable Automatic & Manual URL submission." 90 | ); 91 | setApiKeyInvalid(true); 92 | } 93 | } 94 | }); 95 | }, []); 96 | 97 | // Get API settings 98 | useEffect(() => { 99 | Promise.resolve(GetApiSettings()).then((response) => { 100 | if (response && response.data && response.data.error_type.length === 0) { 101 | setAPISettings(response.data); 102 | setSelectedOptionAutoSubmissions( 103 | response.data.AutoSubmissionEnabled ? "enable" : "disable" 104 | ); 105 | } 106 | }); 107 | }, [apiKeyUpdated, apiSettingsUpdated]); 108 | 109 | // Get submissions statistics 110 | useEffect(() => { 111 | Promise.resolve(GetStats()).then((response) => { 112 | if (response && response.data && response.data.error_type.length === 0) { 113 | setSubmissionStats(response.data); 114 | } 115 | }); 116 | }, [apiKeyUpdated, urlSubmitted]); 117 | 118 | // Get submissions list 119 | useEffect(() => { 120 | Promise.resolve(GetAllSubmissions()).then((response) => { 121 | if (response && response.data && response.data.error_type.length === 0) { 122 | response.data.Submissions.sort((a, b) => 123 | a.submission_date > b.submission_date ? -1 : 1 124 | ); 125 | setSubmissionsList(response.data); 126 | } 127 | }); 128 | }, [apiKeyUpdated, urlSubmitted]); 129 | 130 | // constants 131 | const autoSubmissionOptions: IChoiceGroupOption[] = [ 132 | { key: "enable", text: "Enable (recommended)" }, 133 | { key: "disable", text: "Disable" }, 134 | ]; 135 | const urlSubmissionTableColumns: IColumn[] = [ 136 | { 137 | key: "url", 138 | name: "URL", 139 | fieldName: "url", 140 | onRender: (item: UrlSubmission): JSX.Element => { 141 | return ( 142 | 143 | {decodeURI(item.url)} 144 | 145 | ); 146 | }, 147 | minWidth: 250, 148 | }, 149 | { 150 | key: "submittedOn", 151 | name: "Submitted On", 152 | fieldName: "submission_date", 153 | onRender: (item: UrlSubmission): string => { 154 | let time: Date = new Date(0); 155 | time.setUTCSeconds(item.submission_date); 156 | let dateString: string = 157 | time.getFullYear === new Date().getFullYear 158 | ? format(time, "d MMM 'at' HH':'mm", {}) 159 | : format(time, "d MMM yyyy'at' HH':'mm", {}); 160 | return dateString; 161 | }, 162 | minWidth: 150, 163 | }, 164 | { 165 | key: "status", 166 | name: "Status", 167 | fieldName: "error", 168 | onRender: (item: UrlSubmission): string => { 169 | return item.error === "Success" ? item.error : `Failed - ${item.error}`; 170 | }, 171 | minWidth: 200, 172 | }, 173 | { 174 | key: "resubmit", 175 | name: "", 176 | onRender: (item: UrlSubmission) => { 177 | return ( 178 | 184 | ); 185 | }, 186 | minWidth: 40, 187 | maxWidth: 70, 188 | className: "retryColumn", 189 | }, 190 | ]; 191 | 192 | // Function handler for URL submission retries 193 | const resubmitOnClick = ( 194 | event: React.MouseEvent 195 | ) => { 196 | const submissionItemString: string = 197 | (event.target as HTMLInputElement).dataset.submission ?? ""; 198 | const submissionItem: UrlSubmission = JSON.parse(submissionItemString); 199 | Promise.resolve(RetryFailedSubmissions([submissionItem])).then( 200 | (response) => { 201 | if (response && response.data) { 202 | setUrlSubmitted(urlSubmitted + 1); 203 | if ( 204 | !response.data.hasError && 205 | response.data.error_type.length === 0 && 206 | response.data.SubmissionErrors.length >= 1 && 207 | response.data.SubmissionErrors[0].isSubmitted 208 | ) { 209 | // add new success banner 210 | props.addBanner("Success : URL submitted successfully."); 211 | } else { 212 | // set failed banner 213 | props.addBanner( 214 | `Error : Submission failed for URL - ${submissionItem.url}` 215 | ); 216 | } 217 | } 218 | } 219 | ); 220 | }; 221 | 222 | const onClickUpdateApiKey = ( 223 | event: React.MouseEvent 224 | ) => { 225 | setModalState(DashboardModalState.Hidden); 226 | Promise.resolve(SetApiKey(textFieldValueApiKey)).then((response) => { 227 | if (response && response.data) { 228 | setApiKeyUpdated(apiKeyUpdated + 1); 229 | if (response.data.error_type.length === 0) { 230 | props.addBanner("Success : API key is updated successfully."); 231 | } else { 232 | props.addBanner("Error : Unable to update API key."); 233 | } 234 | } 235 | }); 236 | }; 237 | 238 | const onClickUpdateAutoSubmissions = ( 239 | event: React.MouseEvent 240 | ) => { 241 | setModalState(DashboardModalState.Hidden); 242 | Promise.resolve( 243 | UpdateAutoSubmissionsEnabled(selectedOptionAutoSubmissions === "enable") 244 | ).then((response) => { 245 | if (response && response.data) { 246 | setApiSettingsUpdated(apiSettingsUpdated + 1); 247 | if (response.data.error_type.length === 0) { 248 | props.addBanner( 249 | "Success : Automatic URL submission preferences updated." 250 | ); 251 | } else { 252 | props.addBanner( 253 | "Error : Automatic URL submission preferences not updated." 254 | ); 255 | } 256 | } 257 | }); 258 | }; 259 | 260 | const onClickModalSubmitUrl = ( 261 | event: React.MouseEvent 262 | ) => { 263 | // hide modal and submit Url 264 | setModalState(DashboardModalState.Hidden); 265 | Promise.resolve(SubmitUrl(textFieldValueUrlSubmit)).then((response) => { 266 | if (response && response.data) { 267 | setUrlSubmitted(urlSubmitted + 1); 268 | if (response.data.error.length === 0) { 269 | // add new success banner 270 | props.addBanner("Success : URL submitted successfully."); 271 | } else { 272 | // set failed banner 273 | props.addBanner( 274 | `Error : Submission failed for URL - ${textFieldValueUrlSubmit}` 275 | ); 276 | } 277 | } 278 | }); 279 | }; 280 | 281 | const downloadUrls = () => { 282 | let data = submissionsList?.Submissions?.map((item) => { 283 | let timestamp: Date = new Date(0); 284 | timestamp.setUTCSeconds(item.submission_date); 285 | return { 286 | url: item.url, 287 | timestamp: formatISO(timestamp), 288 | submitted: item.error === "Success", 289 | status: item.error, 290 | }; 291 | }); 292 | const json = JSON.stringify(data); 293 | const blob = new Blob([json], { type: "application/json" }); 294 | const link = document.createElement("a"); 295 | link.href = URL.createObjectURL(blob); 296 | link.download = "submissionslist.json"; 297 | link.click(); 298 | }; 299 | 300 | return ( 301 | <> 302 |
308 |
309 |
310 | 316 |

317 | ******************************** 318 |

319 |
320 |
{ 323 | setShowApiKeyPopOverMenu(true); 324 | }} 325 | onMouseLeave={() => { 326 | setShowApiKeyPopOverMenu(false); 327 | }} 328 | > 329 | 330 |
331 |
    337 |
  • { 339 | // reset UI controls and display modal 340 | setTextFieldValueApiKey(""); 341 | setModalState(DashboardModalState.UpdateApiKeyModal); 342 | }} 343 | > 344 | Update key 345 |
  • 346 |
347 |
348 |
349 |
350 | 351 |
352 | 360 |

361 | {apiSettings 362 | ? apiSettings.AutoSubmissionEnabled 363 | ? "Enabled" 364 | : "Disabled" 365 | : "-"} 366 |

367 |
368 |
{ 373 | // don't show popover menu if API key is invalid 374 | !apiKeyInvalid && setShowAutoSubmissionsPopOverMenu(true); 375 | }} 376 | onMouseLeave={() => { 377 | setShowAutoSubmissionsPopOverMenu(false); 378 | }} 379 | > 380 | 381 |
382 |
    388 |
  • { 390 | // reset UI controls settings and display modal 391 | setSelectedOptionAutoSubmissions( 392 | apiSettings?.AutoSubmissionEnabled 393 | ? "enable" 394 | : "disable" 395 | ); 396 | setModalState( 397 | DashboardModalState.EditPrefAutoSubmissionModal 398 | ); 399 | }} 400 | > 401 | Edit preference 402 |
  • 403 |
404 |
405 |
406 |
407 |
408 | 409 |
410 |
411 | 417 |

418 | This feature allows you to submit a URL directly into the Bing 419 | index. 420 |

421 | { 424 | // reset UI controls and display modal 425 | setTextFieldValueUrlSubmit(""); 426 | setModalState(DashboardModalState.SubmitUrlModal); 427 | }} 428 | className="buttonSubmitUrl" 429 | text="Submit URL" 430 | /> 431 |
432 |
433 |
434 | 435 |

Overview

436 |
437 |
438 |
439 |

Quota left for the day

440 |

441 | {submissionStats && submissionStats.Quota !== null 442 | ? submissionStats.Quota 443 | : "-"} 444 |

445 |

(Resets at 00:00 GMT)

446 |
447 |
448 |

Successful submissions

449 |

450 | {submissionStats && 451 | submissionStats.PassedSubmissionCount !== null 452 | ? submissionStats.PassedSubmissionCount 453 | : "-"} 454 |

455 |

In last 48 hours

456 |
457 |
458 |

Failed submissions

459 |

460 | {submissionStats && 461 | submissionStats.FailedSubmissionCount !== null 462 | ? submissionStats.FailedSubmissionCount 463 | : "-"} 464 |

465 |

In last 48 hours

466 |
467 |
468 |
469 | 470 |
471 |

URLs submitted

472 | 481 |
482 |
483 |
484 | { 494 | return props?.checked ? ( 495 | 496 | ) : ( 497 | 498 | ); 499 | }} 500 | /> 501 |
502 |
503 | 504 |
505 |

506 | Maximum of 20 successful and 20 failed submissions in last 48hrs 507 | will be displayed. 508 |

509 |

510 | For more information, login to{" "} 511 | Bing Webmaster Tools 512 | . 513 |

514 |
515 |
516 |
522 | {modalState === DashboardModalState.UpdateApiKeyModal && ( 523 |
524 |
525 |

Update API Key

526 | { 530 | setModalState(DashboardModalState.Hidden); 531 | }} 532 | /> 533 |
534 |
535 | { 540 | setTextFieldValueApiKey(val || ""); 541 | }} 542 | validateOnLoad={false} 543 | onGetErrorMessage={() => { 544 | return !ApiKeyRegex.test(textFieldValueApiKey) || 545 | textFieldValueApiKey.length !== 32 546 | ? StringConstants.ApiKeyValidationError 547 | : ""; 548 | }} 549 | /> 550 |

551 | Don’t have API key?{" "} 552 | 553 | Click here to know how to generate. 554 | 555 |

556 |
557 |
558 | 567 | { 571 | setModalState(DashboardModalState.Hidden); 572 | }} 573 | /> 574 |
575 |
576 | )} 577 | {modalState === DashboardModalState.EditPrefAutoSubmissionModal && ( 578 |
579 |
580 |

581 | Edit preference for Automate URL Submission 582 |

583 | { 587 | setModalState(DashboardModalState.Hidden); 588 | }} 589 | /> 590 |
591 |
592 |

593 | We recommend you to enable automation to submit new, updated & 594 | deleted URLs to Bing and stay updated. 595 |

596 | { 600 | if (option !== undefined) { 601 | setSelectedOptionAutoSubmissions(option.key); 602 | } 603 | }} 604 | /> 605 |
606 |
607 | 617 | { 621 | setModalState(DashboardModalState.Hidden); 622 | }} 623 | /> 624 |
625 |
626 | )} 627 | 628 | {modalState === DashboardModalState.SubmitUrlModal && ( 629 |
630 |
631 |

Manual URL submission

632 | { 636 | setModalState(DashboardModalState.Hidden); 637 | }} 638 | /> 639 |
640 |
641 | { 647 | return !SubmitUrlRegex.test(textFieldValueUrlSubmit) 648 | ? StringConstants.UrlSubmitErrorMessage 649 | : ""; 650 | }} 651 | onChange={(event, val) => { 652 | setTextFieldValueUrlSubmit(val?.trim() || ""); 653 | }} 654 | /> 655 |
656 |
657 | 663 | { 667 | setModalState(DashboardModalState.Hidden); 668 | }} 669 | /> 670 |
671 |
672 | )} 673 |
674 | 675 | ); 676 | }; 677 | -------------------------------------------------------------------------------- /src/components/ErrorConstants.tsx: -------------------------------------------------------------------------------- 1 | export const ErrorConstants = { 2 | NoDataFound: { 3 | Code: "NoDataFound", 4 | Message: "No data available" 5 | }, 6 | 7 | RequestTimedOut: { 8 | HttpStatusCode: 408, 9 | Code: "RequestTimedOut", 10 | Message: 11 | "This might be a momentary issue, please try again or check back later" 12 | }, 13 | 14 | UrlNotAllowed: { 15 | Code: "UrlNotAllowed", 16 | Message: 17 | "We found that the URL submitted for block is important for Bing users and hence cannot be blocked through Bing Webmaster tools." 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /src/components/Header.tsx: -------------------------------------------------------------------------------- 1 | import "../scss/Header.scss"; 2 | 3 | import * as React from "react"; 4 | import { Icon } from "@fluentui/react/lib/Icon"; 5 | import { StringConstants } from "../Constants"; 6 | 7 | const logosvg = ( 8 | 14 | 15 | 16 | 17 | 21 | 25 | 29 | 33 | 34 | 35 | 36 | ); 37 | 38 | const mobileLogoSvg = ( 39 | 45 | 46 | 47 | 48 | 49 | ); 50 | 51 | interface IRightPanel { 52 | title: string; 53 | } 54 | 55 | export const Header: React.FunctionComponent = () => { 56 | 57 | return ( 58 | <> 59 |
60 |
61 | {logosvg} 62 | {mobileLogoSvg} 63 | 64 | URL Submission plugin 65 | 66 |
67 |
68 | 71 | window.open(StringConstants.PluginInfoLink, "_blank") 72 | } 73 | key="headerHelp" 74 | > 75 | About this plugin 76 | 77 | 78 |
79 |
80 | 81 | ); 82 | }; 83 | -------------------------------------------------------------------------------- /src/components/Interfaces.ts: -------------------------------------------------------------------------------- 1 | interface ApiResponse { 2 | errors?: any 3 | } 4 | 5 | export interface IGetApiKeyResponse extends ApiResponse { 6 | hasAPIKey: boolean; 7 | } 8 | 9 | export interface ISetApiKeyRequest { 10 | APIKey: string; 11 | } 12 | 13 | export interface ISetApiKeyResponse extends ApiResponse { 14 | error_type: string; 15 | } 16 | 17 | export interface ICheckApiKeyValidityResponse extends ApiResponse { 18 | error_type: string; 19 | } 20 | 21 | export interface IGetApiSettingsResponse extends ApiResponse { 22 | AutoSubmissionEnabled: boolean; 23 | SiteUrl: string; 24 | error_type: string; 25 | } 26 | 27 | export interface IGetStatsResponse extends ApiResponse { 28 | FailedSubmissionCount: number; 29 | PassedSubmissionCount: number; 30 | Quota: number; 31 | error_type: string; 32 | } 33 | 34 | export interface IGetAllSubmissionsResponse extends ApiResponse { 35 | Submissions: UrlSubmission[]; 36 | error_type: string; 37 | } 38 | 39 | export interface IRetryFailedSubmissionsRequest { 40 | Submissions: UrlSubmission[]; 41 | } 42 | 43 | export interface IRetryFailedSubmissionsResponse extends ApiResponse { 44 | hasError: boolean; 45 | SubmissionErrors: SubmissionErrors[]; 46 | error_type: string; 47 | } 48 | 49 | export interface ISubmitUrlRequest { 50 | url: string; 51 | } 52 | 53 | export interface ISubmitUrlResponse extends ApiResponse { 54 | error: string; 55 | } 56 | 57 | export interface ISetAutoSubmissionEnabledRequest { 58 | AutoSubmissionEnabled: boolean; 59 | } 60 | 61 | export interface ISetAutoSubmissionEnabledResponse extends ApiResponse { 62 | error_type: string; 63 | } 64 | 65 | export interface UrlSubmission { 66 | url: string; 67 | submission_type: number; 68 | submission_date: number; 69 | error: string; 70 | type: SubmissionType; 71 | } 72 | 73 | enum SubmissionType { 74 | add, 75 | update, 76 | delete, 77 | } 78 | 79 | export interface SubmissionErrors { 80 | url: string; 81 | isSubmitted: boolean; 82 | status: string; 83 | error_msg: string; 84 | } 85 | -------------------------------------------------------------------------------- /src/components/StartPage.tsx: -------------------------------------------------------------------------------- 1 | import "../scss/StartPage.scss"; 2 | 3 | import * as React from "react"; 4 | import { useState } from "react"; 5 | import { PrimaryButton } from "@fluentui/react/lib/Button"; 6 | import { Icon } from "@fluentui/react/lib/Icon"; 7 | import { TextField } from "@fluentui/react/lib/TextField"; 8 | import { SetApiKey } from "./withDashboardData"; 9 | import { ApiKeyRegex, StringConstants } from "../Constants"; 10 | 11 | interface IStartPage { 12 | addBanner: (str: string) => void; 13 | setAPIKeyAdded: () => void; 14 | } 15 | 16 | export const StartPage: React.FunctionComponent = (props) => { 17 | const [apiKey, setApiKey] = useState(""); 18 | 19 | const onSubmitApiKey = (): void => { 20 | Promise.resolve(SetApiKey(apiKey)).then((response) => { 21 | if (response?.data?.error_type.length === 0) { 22 | props.setAPIKeyAdded(); 23 | } else { 24 | props.addBanner(`Adding API key failed: ${response.data?.error_type}`); 25 | } 26 | }); 27 | }; 28 | 29 | return ( 30 |
31 |
32 |

What you can do with this plugin

33 | 34 |
35 |
36 | 37 |

Automate URL submissions

38 |
39 |
40 | 41 |

Manual URL submissions

42 |
43 |
44 | 45 |

View stats of submitted URLs

46 |
47 |
48 | 49 |

View recent submissions

50 |
51 |
52 | 53 |

Re-submit recent submissions

54 |
55 |
56 |
57 | 58 |
59 |
60 |

Add API Key To Get Started

61 |

62 | Add valid API key and automate URL submission by clicking on Start 63 | using this plugin. You can disable auto submission later from plugin 64 | if needed. 65 |

66 | { 71 | setApiKey(item || ""); 72 | }} 73 | placeholder="Enter 32 digit API key" 74 | validateOnLoad={false} 75 | onGetErrorMessage={() => { 76 | return !ApiKeyRegex.test(apiKey) || apiKey.length !== 32 77 | ? StringConstants.ApiKeyValidationError 78 | : ""; 79 | }} 80 | /> 81 |

82 | Don"t have API key?{" "} 83 | 84 | Click here to know how to generate. 85 | 86 |

87 |
88 | 94 |
95 |
96 |
97 |
98 | ); 99 | }; 100 | -------------------------------------------------------------------------------- /src/components/withDashboardData.tsx: -------------------------------------------------------------------------------- 1 | import { IHttpResponse, useFetch, useSubmit } from "./APIHelper"; 2 | import { 3 | ISetApiKeyRequest, 4 | IGetApiSettingsResponse, 5 | IGetStatsResponse, 6 | IGetAllSubmissionsResponse, 7 | ISubmitUrlResponse, 8 | ISubmitUrlRequest, 9 | IGetApiKeyResponse, 10 | ISetApiKeyResponse, 11 | IRetryFailedSubmissionsResponse, 12 | IRetryFailedSubmissionsRequest, 13 | ISetAutoSubmissionEnabledResponse, 14 | ISetAutoSubmissionEnabledRequest, 15 | ICheckApiKeyValidityResponse, 16 | UrlSubmission, 17 | } from "./Interfaces"; 18 | 19 | export async function GetApiKey() { 20 | let response: IHttpResponse; 21 | const url = `apiKey`; 22 | response = await useFetch(url).catch((err) => { 23 | console.error("Error while fetching API key."); 24 | return err; 25 | }); 26 | return response; 27 | } 28 | 29 | export async function SetApiKey(apiKey: string) { 30 | let response: IHttpResponse; 31 | const url = `apiKey`; 32 | const apiContent: ISetApiKeyRequest = { 33 | APIKey: apiKey, 34 | }; 35 | response = await useSubmit(url, apiContent).catch( 36 | (err) => { 37 | console.error("Error while updating API key."); 38 | return err; 39 | } 40 | ); 41 | return response; 42 | } 43 | 44 | export async function CheckApiKeyValidity() { 45 | let response: IHttpResponse; 46 | const url = `apiKeyValidity`; 47 | response = await useFetch(url).catch((err) => { 48 | console.error("Error while checking API key validity."); 49 | return err; 50 | }); 51 | return response; 52 | } 53 | 54 | export async function GetApiSettings() { 55 | let response: IHttpResponse; 56 | const url = `apiSettings`; 57 | response = await useFetch(url).catch((err) => { 58 | console.error("Error while fetching plugin settings."); 59 | return err; 60 | }); 61 | return response; 62 | } 63 | 64 | export async function GetStats() { 65 | let response: IHttpResponse; 66 | const url = `getStats`; 67 | response = await useFetch(url).catch((err) => { 68 | console.error("Error while fetching submission statistics."); 69 | return err; 70 | }); 71 | return response; 72 | } 73 | 74 | export async function GetAllSubmissions() { 75 | let response: IHttpResponse; 76 | const url = `allSubmissions`; 77 | response = await useFetch(url).catch((err) => { 78 | console.error("Error while fetching submitted URLs list."); 79 | return err; 80 | }); 81 | return response; 82 | } 83 | 84 | export async function RetryFailedSubmissions( 85 | failedSubmissions: UrlSubmission[] 86 | ) { 87 | const param: IRetryFailedSubmissionsRequest = { 88 | Submissions: failedSubmissions, 89 | }; 90 | let response: IHttpResponse; 91 | const url = `allSubmissions`; 92 | response = await useSubmit(url, param).catch( 93 | (err) => { 94 | console.error("Error while retrying failed submissions."); 95 | return err; 96 | } 97 | ); 98 | return response; 99 | } 100 | 101 | export async function UpdateAutoSubmissionsEnabled(isEnabled: boolean) { 102 | const param: ISetAutoSubmissionEnabledRequest = { 103 | AutoSubmissionEnabled: isEnabled, 104 | }; 105 | let response: IHttpResponse; 106 | const url = `automaticSubmission`; 107 | response = await useSubmit( 108 | url, 109 | param 110 | ).catch((err) => { 111 | console.error("Error while updating automatic submission settings."); 112 | return err; 113 | }); 114 | return response; 115 | } 116 | 117 | export async function SubmitUrl(url: string) { 118 | let response: IHttpResponse; 119 | const ep = `submitUrl`; 120 | const apiContent: ISubmitUrlRequest = { 121 | url: url, 122 | }; 123 | response = await useSubmit(ep, apiContent).catch( 124 | (err) => { 125 | console.error("Error while submitting URL."); 126 | return err; 127 | } 128 | ); 129 | return response; 130 | } 131 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | li.toplevel_page_bing-url-submission > a > div.svg { 2 | background-size: 13px auto !important; 3 | } 4 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import { App } from './components/App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | import { initializeIcons } from "@fluentui/react/lib/Icons"; 7 | 8 | initializeIcons(); 9 | 10 | var rootElement = document.getElementById("bwAppRoot"); 11 | 12 | if (rootElement !== null) { 13 | ReactDOM.render( 14 | 15 | 16 | , 17 | rootElement 18 | ); 19 | } 20 | 21 | // If you want your app to work offline and load faster, you can change 22 | // unregister() to register() below. Note this comes with some pitfalls. 23 | // Learn more about service workers: https://bit.ly/CRA-PWA 24 | serviceWorker.unregister(); 25 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /src/scss/App.scss: -------------------------------------------------------------------------------- 1 | @import "default"; 2 | 3 | .bw-App { 4 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 5 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 6 | sans-serif; 7 | display: flex; 8 | flex-flow: row wrap; 9 | justify-content: center; 10 | 11 | .bw-Banner { 12 | margin: 12px 0; 13 | width: 100%; 14 | padding: 8px 24px; 15 | position: relative; 16 | border-radius: 2px; 17 | font-size: 12px; 18 | color: black; 19 | 20 | .closeIcon { 21 | position: absolute; 22 | top: 10px; 23 | right: 12px; 24 | font-size: 10px; 25 | cursor: pointer; 26 | } 27 | } 28 | 29 | .bw-BannerHidden { 30 | display: none; 31 | } 32 | 33 | .bw-BannerSuccess { 34 | background-color: #caeaca; 35 | } 36 | 37 | .bw-BannerFailure { 38 | background-color: #f6cfcf; 39 | } 40 | } 41 | 42 | .bw-MainContainer { 43 | width: $bwt_pageContentWidth; 44 | } 45 | -------------------------------------------------------------------------------- /src/scss/Dashboard.scss: -------------------------------------------------------------------------------- 1 | @import "./default"; 2 | 3 | .bw-DashboardContent { 4 | margin-top: 25px; 5 | 6 | .sectionTitle { 7 | font-size: 16px; 8 | color: $bwt_cardTextColor; 9 | margin-top: 24px; 10 | } 11 | 12 | .sectionTitleContainer { 13 | display: flex; 14 | justify-content: space-between; 15 | margin-top: 24px; 16 | 17 | .sectionTitle { 18 | margin-top: 0; 19 | } 20 | 21 | button.buttonUrlSubmissionsDownload { 22 | margin-right: 24px; 23 | } 24 | } 25 | 26 | .bw-CardRow { 27 | margin: 8px 0; 28 | font-size: 16px; 29 | display: flex; 30 | flex-flow: row wrap; 31 | justify-content: space-between; 32 | 33 | .bw-CardColumn-1 { 34 | width: 100%; 35 | min-width: 320px; 36 | } 37 | 38 | .bw-CardColumn-2 { 39 | width: calc((100% - 8px) / 2); 40 | min-width: 320px; 41 | } 42 | 43 | .bw-CardColumn { 44 | background-color: $bwt_white; 45 | position: relative; 46 | box-shadow: 0px 0.6px 2px #0000001c; 47 | border-radius: 2px; 48 | display: flex; 49 | 50 | .bw-PopOverMenu { 51 | width: 10%; 52 | height: 100%; 53 | display: flex; 54 | flex-direction: column; 55 | align-items: center; 56 | 57 | &:hover { 58 | background-color: rgba(0, 0, 0, 0.1); 59 | cursor: pointer; 60 | } 61 | 62 | .moreIcon { 63 | margin-top: 18px; 64 | } 65 | 66 | .popOverContainer { 67 | position: relative; 68 | 69 | .popOverPanel { 70 | position: absolute; 71 | top: 0; 72 | right: 0; 73 | padding: 8px 10px; 74 | z-index: 100; 75 | box-shadow: 0px 1px 4px #0000001c; 76 | background-color: $bwt_white; 77 | border: 1px solid #eeeeee; 78 | border-radius: 2px; 79 | white-space: nowrap; 80 | display: none; 81 | } 82 | 83 | .openPopOverMenu { 84 | display: block; 85 | } 86 | } 87 | } 88 | 89 | .bw-Card-WithPopOver { 90 | width: 90%; 91 | } 92 | 93 | .bw-Disabled { 94 | filter: opacity(0.4); 95 | &:hover { 96 | background-color: inherit; 97 | cursor: inherit; 98 | } 99 | } 100 | 101 | .bw-Card { 102 | padding: 18px 24px; 103 | width: 100%; 104 | 105 | .cardTitle { 106 | font-size: 16px; 107 | color: $bwt_cardTextColor; 108 | 109 | .bw-CardTitleIcon { 110 | margin-right: 4px; 111 | } 112 | 113 | span { 114 | margin: 0 8px; 115 | } 116 | 117 | i.info { 118 | color: $bwt_optionalTextColor; 119 | cursor: pointer; 120 | vertical-align: middle; 121 | } 122 | } 123 | 124 | .cardDescription { 125 | font-size: 12px; 126 | color: $bwt_standardTextColor; 127 | margin-left: 25px; 128 | margin-top: 10px; 129 | } 130 | } 131 | } 132 | 133 | .bw-OverviewSection { 134 | display: flex; 135 | justify-content: space-between; 136 | width: 100%; 137 | 138 | .infoCards { 139 | background-color: $bwt_white; 140 | width: calc((100% - 16px) / 3); 141 | padding: 24px; 142 | box-shadow: 0px 0.6px 2px #0000001c; 143 | border-radius: 2px; 144 | 145 | h4 { 146 | font-size: 14px; 147 | } 148 | h2 { 149 | font-size: 24px; 150 | } 151 | p { 152 | font-size: 11px; 153 | color: $bwt_optionalTextColor; 154 | } 155 | } 156 | } 157 | 158 | .bw-ApiKeyCard { 159 | .cardDescription { 160 | color: $bwt_cardTextColor; 161 | } 162 | } 163 | 164 | .bw-ManualURLSubmissionCard { 165 | .bw-Card { 166 | .cardContent { 167 | display: flex; 168 | justify-content: space-between; 169 | } 170 | } 171 | } 172 | 173 | .bw-UrlSubmissions { 174 | padding: 0; 175 | 176 | > * { 177 | width: 100%; 178 | } 179 | 180 | .ms-DetailsHeader { 181 | padding-top: 0; 182 | } 183 | 184 | .ms-DetailsRow-cell { 185 | color: $bwt_cardTextColor; 186 | } 187 | 188 | i.retryIcon { 189 | cursor: pointer; 190 | 191 | &:hover { 192 | color: $bwt_primaryTealColor; 193 | font-weight: bolder; 194 | font-size: 16px; 195 | } 196 | } 197 | } 198 | } 199 | 200 | .footnotes { 201 | font-size: 12px; 202 | color: $bwt_secondaryTextColor; 203 | } 204 | } 205 | 206 | .bw-Modal { 207 | display: none; 208 | position: fixed; 209 | width: 40%; 210 | top: 30%; 211 | left: 30%; 212 | z-index: 1; 213 | box-shadow: -3px 6px 16px #00000029; 214 | border-radius: 2px; 215 | 216 | .modalContainer { 217 | display: flex; 218 | flex-direction: column; 219 | background-color: $bwt_white; 220 | 221 | .modalHeader { 222 | padding: 24px 32px; 223 | color: $bwt_cardTextColor; 224 | display: flex; 225 | justify-content: space-between; 226 | 227 | p { 228 | font-size: 21px; 229 | } 230 | 231 | .modalClose { 232 | cursor: pointer; 233 | } 234 | } 235 | 236 | .modalContent { 237 | padding: 24px 32px; 238 | 239 | .textField { 240 | input { 241 | border-radius: 0; 242 | border: none; 243 | } 244 | } 245 | 246 | p { 247 | font-size: 12px; 248 | color: $bwt_standardTextColor; 249 | } 250 | } 251 | 252 | .modalFooter { 253 | padding: 24px 32px; 254 | border-top: solid 1px rgba(0, 0, 0, 0.1); 255 | 256 | button.button { 257 | border-radius: 0; 258 | margin-right: 16px; 259 | } 260 | 261 | button.primaryButton { 262 | background-color: $bwt_primaryTealColor; 263 | color: $bwt_white; 264 | } 265 | 266 | button.secondaryButton { 267 | background-color: $bwt_white; 268 | } 269 | } 270 | } 271 | } 272 | 273 | .showModal { 274 | display: block; 275 | animation: animateIn 0.3s; 276 | } 277 | 278 | @keyframes animateIn { 279 | from { 280 | top: 100%; 281 | opacity: 0; 282 | } 283 | to { 284 | top: 30%; 285 | opacity: 1; 286 | } 287 | } 288 | 289 | .darken { 290 | filter: opacity(0.5); 291 | } 292 | -------------------------------------------------------------------------------- /src/scss/Header.scss: -------------------------------------------------------------------------------- 1 | @import "./default"; 2 | 3 | // Page header css 4 | .bw-Header { 5 | width: 100%; 6 | background: $bwt_primaryTealColor; 7 | color: $bwt_white; 8 | padding-left: calc((100% - #{$bwt_pageContentWidth})/2); 9 | padding-right: calc((100% - #{$bwt_pageContentWidth})/2); 10 | 11 | .headerLeftElements { 12 | > * { 13 | vertical-align: middle; 14 | } 15 | } 16 | 17 | .headerRightElements { 18 | > * { 19 | vertical-align: middle; 20 | line-height: $bwt_topHeaderHeight; 21 | cursor: pointer; 22 | font-size: 12px; 23 | 24 | .bw-Icon { 25 | color: $bwt_white; 26 | vertical-align: middle; 27 | } 28 | 29 | span { 30 | padding: 0 8px; 31 | } 32 | } 33 | } 34 | 35 | .bingLogo { 36 | margin: 0 16px 0 0; 37 | border-right: $bwt_pageTitleBorder; 38 | padding-right: 16px; 39 | height: 42px; 40 | } 41 | 42 | .bingLogoMobile { 43 | padding-right: 8px; 44 | } 45 | 46 | .pageTitle { 47 | @include font-type($bwt_semiboldFontFamily, $bwt_mediumFontSize); 48 | color: $bwt_white; 49 | line-height: $bwt_topHeaderHeight; 50 | sup { 51 | @include border-radius(2px); 52 | font-size: 10px; 53 | font-weight: 600; 54 | bottom: 5px; 55 | position: relative; 56 | background-color: $bwt_headerTitleSupTextBackGroundColor; 57 | margin-left: 6px; 58 | padding: 2px 8px; 59 | text-align: center; 60 | vertical-align: super; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/scss/StartPage.scss: -------------------------------------------------------------------------------- 1 | @import "./default"; 2 | 3 | .bw-StartPageContent { 4 | text-align: center; 5 | border: 1px solid $bwt_lightGray60Color; 6 | margin-top: 25px; 7 | 8 | .featuresSection { 9 | padding: 1.5rem 0; 10 | background-color: $bwt_lightGray30Color; 11 | 12 | h2 { 13 | color: $bwt_darkGray20Color; 14 | padding: 1rem 0; 15 | } 16 | 17 | .featuresListContainer { 18 | display: flex; 19 | flex-flow: row wrap; 20 | justify-content: space-evenly; 21 | } 22 | 23 | .featureItem { 24 | max-width: 8rem; 25 | margin: 0 4px; 26 | margin: 1rem 1rem; 27 | display: flex; 28 | flex-flow: column nowrap; 29 | justify-content: center; 30 | 31 | .featureIcon { 32 | color: $bwt_darkGray20Color; 33 | font-size: 1.5rem; 34 | } 35 | 36 | p { 37 | color: $bwt_darkGray20Color; 38 | font-size: 0.8rem; 39 | } 40 | } 41 | } 42 | 43 | .keyEntrySection { 44 | background-color: $bwt_white; 45 | padding: 5rem 0rem; 46 | display: flex; 47 | justify-content: center; 48 | padding: 5px 24px; 49 | 50 | .keyEntryCard { 51 | max-width: 400px; 52 | display: flex; 53 | flex-flow: column nowrap; 54 | justify-content: center; 55 | padding: 24px 0; 56 | 57 | h3 { 58 | font-size: 26px; 59 | color: $bwt_cardTextColor; 60 | } 61 | 62 | >* { 63 | margin: 8px 0; 64 | } 65 | 66 | p { 67 | font-size: 14px; 68 | } 69 | 70 | .apiKeyTextField { 71 | input { 72 | border-radius: 0; 73 | border: none; 74 | min-height: auto; 75 | } 76 | 77 | p { 78 | display: flex; 79 | justify-content: center; 80 | } 81 | } 82 | 83 | 84 | 85 | button.submitButton { 86 | background-color: $bwt_primaryTealColor; 87 | color: $bwt_white; 88 | border-radius: 0; 89 | width: 300px; 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/scss/_common.scss: -------------------------------------------------------------------------------- 1 | @import "default"; 2 | 3 | .bw-App { 4 | h2 { 5 | @include font-type($bwt_scopeFontFamily, $bwt_focusFontSize); 6 | } 7 | 8 | h3 { 9 | @include font-type($bwt_scopeFontFamily, $bwt_mediumFontSize); 10 | } 11 | 12 | .floatLeft { 13 | float: left; 14 | } 15 | 16 | .floatRight { 17 | float: right; 18 | } 19 | 20 | h2 { 21 | @include font-type($bwt_scopeFontFamily, $bwt_focusFontSize); 22 | } 23 | 24 | h3 { 25 | @include font-type($bwt_scopeFontFamily, $bwt_mediumFontSize); 26 | } 27 | 28 | .textCenter { 29 | text-align: center; 30 | } 31 | 32 | .textRight { 33 | text-align: right; 34 | } 35 | 36 | .floatNone { 37 | float: none; 38 | } 39 | 40 | .b_hide { 41 | display: none; 42 | } 43 | 44 | .colorBlack { 45 | color: $bwt_darkGray50Color; 46 | } 47 | 48 | .clearfix { 49 | @include clearfix; 50 | } 51 | 52 | .pageLayout { 53 | background: $bwt_lightGray30Color; 54 | } 55 | 56 | .pageContainer { 57 | display: flex; 58 | min-height: calc(100vh - #{$bwt_topHeaderHeight}); 59 | margin-top: $bwt_topHeaderHeight; 60 | } 61 | 62 | a { 63 | text-decoration: none; 64 | 65 | &:focus, 66 | &:active, 67 | &:hover { 68 | outline: none; 69 | text-decoration: none; 70 | color: inherit; 71 | } 72 | } 73 | 74 | i { 75 | font-size: $bwt_smallIconSize; 76 | color: $bwt_darkGray30Color; 77 | } 78 | 79 | .bwtIconTxtPair { 80 | > * { 81 | @include displayIB(); 82 | } 83 | 84 | i { 85 | margin-right: 8px; 86 | } 87 | } 88 | 89 | .warningIcon { 90 | color: $bwt_warningColor; 91 | } 92 | 93 | .errorIcon { 94 | color: $bwt_errorColor; 95 | } 96 | 97 | .infoIcon { 98 | font-size: 10px; 99 | padding-left: 4px; 100 | color: $bwt_lightGray60Color; 101 | } 102 | 103 | .globalPanelMask { 104 | width: 100%; 105 | height: 100%; 106 | position: absolute; 107 | top: 0; 108 | left: 0; 109 | background: rgba(255, 255, 255, 0.1); 110 | z-index: 1000; 111 | 112 | .maskSpinner { 113 | position: absolute; 114 | left: 50%; 115 | top: 50%; 116 | } 117 | } 118 | 119 | .validationError { 120 | margin-top: 10px; 121 | color: $bwt_errorColor; 122 | } 123 | 124 | .siteUrlInfo { 125 | .siteUrl { 126 | display: -webkit-inline-box; 127 | max-width: 100%; 128 | height: auto; 129 | -webkit-line-clamp: 2; 130 | -webkit-box-orient: vertical; 131 | overflow: hidden; 132 | text-overflow: ellipsis; 133 | word-break: break-all; 134 | } 135 | &:hover { 136 | .siteUrl:after { 137 | background: $bwt_rowHoverColor; 138 | } 139 | 140 | .siteUrl:before { 141 | color: transparent; 142 | } 143 | .siteUrl { 144 | text-decoration: underline; 145 | } 146 | } 147 | } 148 | 149 | .secondaryInfo { 150 | margin-top: 4px; 151 | color: $bwt_darkGray20Color; 152 | font-size: $bwt_secondaryFontSize; 153 | } 154 | 155 | .bwtToolTip { 156 | text-align: left; 157 | display: block; 158 | padding: 8px 8px 6px 8px; 159 | min-width: 115px; 160 | .toolTipUrl { 161 | word-break: break-all; 162 | white-space: initial; 163 | font-size: $bwt_secondaryFontSize; 164 | } 165 | 166 | i { 167 | cursor: pointer; 168 | color: $bwt_primaryTextColor; 169 | margin-left: 0px; 170 | } 171 | } 172 | .errorPageContainerLayout { 173 | width: 100%; 174 | margin: 0 auto; 175 | padding: 16px; 176 | } 177 | 178 | .iconButtonMenu { 179 | width: 100%; 180 | } 181 | 182 | .moreEdgedCell { 183 | padding-top: 5px; 184 | padding-right: 4px; 185 | padding-bottom: 0px; 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /src/scss/_mixin.scss: -------------------------------------------------------------------------------- 1 | // Toggles 2 | // 3 | // Used in conjunction with global variables to enable certain theme features. 4 | 5 | // Utilities 6 | @import "mixins/fonts"; 7 | @import "mixins/border-radius"; 8 | @import "mixins/textellipsis"; 9 | @import "mixins/disabletext"; 10 | @import "mixins/icons"; 11 | @import "mixins/display"; 12 | @import "mixins/clearfix"; 13 | 14 | // Skins 15 | @import "mixins/opacity"; 16 | @import "mixins/shadow"; 17 | @import "mixins/transform"; 18 | @import "mixins/transition"; -------------------------------------------------------------------------------- /src/scss/_variables.scss: -------------------------------------------------------------------------------- 1 | // Variables 2 | // 3 | // Variables should follow the `$shortansname-propertynameincamelcase` formula for 4 | // consistent naming. Ex: $bingtravel-linkDisabledColor and $bwt_contentBoxShadow. 5 | 6 | // 7 | // Color system 8 | // 9 | 10 | // Primary Colors 11 | $bwt_white: #ffffff; 12 | $bwt_primaryTealColor: #00809d; 13 | $bwt_darkTealColor: #006887; 14 | 15 | // Secondary Color 16 | $bwt_headerAccentColor: #0046ff; 17 | $bwt_attributionColor: #006d21; 18 | $bwt_warningColor: #be5a00; 19 | $bwt_errorColor: #c80000; 20 | $bwt_pendingColor: #797673; 21 | $bwt_successColor: #006d21; 22 | 23 | // Text colors 24 | $bwt_primaryTextColor: #444444; 25 | $bwt_standardTextColor: #666666; 26 | $bwt_secondaryTextColor: #767676; 27 | $bwt_optionalTextColor: #919191; 28 | $bwt_linkTextColor: #0078d7; 29 | $bwt_harmfulLinkIconColor: #e06f6a; 30 | 31 | // Gray Colors 32 | $bwt_lightGray10Color: #f7f9f8; 33 | $bwt_lightGray15Color: #f8f8f8; 34 | $bwt_lightGray20Color: #f9f9f9; 35 | $bwt_lightGray30Color: #f5f5f5; 36 | $bwt_lightGray40Color: #f3f3f3; 37 | $bwt_lightGray50Color: #ececec; 38 | $bwt_lightGray60Color: #dddddd; 39 | $bwt_lightGray70Color: #cccccc; 40 | $bwt_darkGray10Color: #919191; 41 | $bwt_darkGray20Color: #767676; 42 | $bwt_darkGray30Color: #666666; 43 | $bwt_darkGray40Color: #444444; 44 | $bwt_darkGray50Color: #111111; 45 | $bwt_whiteGrayBlack: #e1e1e1; 46 | $bwt_veryDarkGrayColor: #212121; 47 | $bwt_darkCyanColor: #0c8484; 48 | $bwt_veryDarkCyanColor: #0c6e6e; 49 | $bwt_buttonActiveColor: #0b5858; 50 | $bwt_filterBorderColor: #a19f9d; 51 | $bwt_paginationButtonColor: #eaeaea; 52 | $bwt_paginationButtonDisabledColor: #f4f4f4; 53 | $bwt_buttonHoverColor: #027c91; 54 | $bwt_cardTextColor: #333333; 55 | $bwt_textFiledBorderColor: #a19f9d; 56 | $bwt_buttonClassicPortalLinkBackgroundColor: #fff5d5; 57 | $bwt_buttonClassicPortalLinkBorderColor: #ba7b17; 58 | 59 | $bwt_headerLinkTextColor: #0078d4; 60 | $bwt_headerTitleSupTextBackGroundColor: #00b7c8; 61 | $bwt_headerElementsHoverBackGroundColor: #00748e; 62 | $bwt_filterButtonsHoverBackGroundColor: #edebe9; 63 | $bwt_attributionHoverBackGroundColor: #00631e; 64 | $bwt_errorHoverBackGroundColor: #b30000; 65 | $bwt_filterButtonHoverColor: #605e5c; 66 | $bwt_navHoverColor: rgba(0, 128, 150, 0.1); 67 | $bwt_navHoverAfterColor: rgba(0, 128, 150, 0.01); 68 | $bwt_navButtonHoverBackground: #f3f2f1; 69 | $bwt_rowHoverColor: rgb(243, 242, 241); 70 | 71 | // Font faces 72 | $bwt_scopeFontFamily: "Segoe UI", Arial, Helvetica, Sans-Serif; 73 | $bwt_semiboldFontFamily: "Segoe UI Semibold", "Segoe UI", Arial, Helvetica, 74 | Sans-Serif; 75 | $bwt_bodyFontFamily: Arial, Helvetica, Sans-Serif; 76 | 77 | // Font sizes 78 | $bwt_focusTitleMFontSize: 44px; 79 | $bwt_titleFontSize: 24px; 80 | $bwt_focusFontSize: 20px; 81 | $bwt_mediumFontSize: 16px; 82 | $bwt_standardFontSize: 14px; 83 | $bwt_secondaryFontSize: 12px; 84 | 85 | // Width 86 | $bwt_pageMinWidth: 1266px; 87 | $bwt_pageContentWidth: 960px; 88 | 89 | // Heights 90 | $bwt_topHeaderHeight: 54px; 91 | 92 | // Borders 93 | $bwt_lightGrayBorder: 1px solid $bwt_lightGray60Color; 94 | $bwt_whiteBorder: 1px solid $bwt_white; 95 | $bwt_filterBoxBorder: 1px solid $bwt_filterBorderColor; 96 | $bwt_transparentBorder: 1px solid transparent; 97 | $bwt_pageHeaderBorder: 1px solid $bwt_whiteGrayBlack; 98 | $bwt_pageTitleBorder: 1px solid $bwt_lightGray70Color; 99 | $bwt_filterButtonHoverBorder: 1px solid $bwt_filterButtonHoverColor; 100 | 101 | // Shadows 102 | $bwt_cardShadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 2px 3px 0 rgba(0, 0, 0, 0.1); 103 | $bwt_hoverShadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 2px 4px 0 rgba(0, 0, 0, 0.14); 104 | $bwt_btnhoverShadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1); 105 | $bwt_messageCardShadow: rgba(0, 0, 0, 0.133) 0px 1.6px 3.6px 0px, 106 | rgba(0, 0, 0, 0.11) 0px 0.3px 0.9px 0px; 107 | $bwt_messageCardHoverShadow: rgba(0, 0, 0, 0.133) 0px 3.2px 7.2px 0px, 108 | rgba(0, 0, 0, 0.11) 0px 0.6px 1.8px 0px; 109 | 110 | // Transitions 111 | $bwt_shadowTransition: box-shadow 0.1s ease-in-out; 112 | $bwt_cardExpandTransition: all 0.3s ease-in-out; 113 | 114 | // Icon sizes 115 | $bwt_smallIconSize: 16px; 116 | $bwt_mediumIconSize: 20px; 117 | $bwt_largeIconSize: 24px; 118 | $bwt_xlargeIconSize: 32px; 119 | -------------------------------------------------------------------------------- /src/scss/default.scss: -------------------------------------------------------------------------------- 1 | // Combination of all variables, mixins and utilities 2 | 3 | // Variables 4 | @import "variables"; 5 | @import "mixin"; -------------------------------------------------------------------------------- /src/scss/headerPanel.scss: -------------------------------------------------------------------------------- 1 | @import "./default"; 2 | 3 | .rightHeaderPanel { 4 | margin: 24px -16px; 5 | 6 | .panelView { 7 | padding: 0 16px; 8 | } 9 | 10 | .contentLabel { 11 | @include font-type($bwt_scopeFontFamily, $bwt_standardFontSize); 12 | } 13 | .contentLabelActive { 14 | @include font-type($bwt_semiboldFontFamily, $bwt_standardFontSize); 15 | } 16 | .showContent { 17 | height: auto; 18 | overflow: hidden; 19 | } 20 | 21 | .chevronIcon { 22 | cursor: pointer; 23 | padding-right: 10px; 24 | } 25 | 26 | .contentLabelInfo { 27 | @include font-type($bwt_semiboldFontFamily, $bwt_secondaryFontSize); 28 | padding-top: 8px; 29 | } 30 | 31 | .profileInfo { 32 | margin: 24px 16px 0; 33 | } 34 | .accountUserInfo { 35 | width: calc(100% - 72px); 36 | } 37 | .profileDetails { 38 | margin: 24px 0; 39 | } 40 | 41 | .accountDeleteButton { 42 | @include font-type($bwt_semiboldFontFamily, $bwt_standardFontSize); 43 | @include border-radius(2px); 44 | background: transparent; 45 | border: 1px solid $bwt_errorColor; 46 | color: $bwt_errorColor; 47 | cursor: pointer; 48 | &:hover { 49 | color: $bwt_white; 50 | background: $bwt_errorHoverBackGroundColor; 51 | border: 1px solid $bwt_errorHoverBackGroundColor; 52 | } 53 | } 54 | .contentInfo { 55 | padding-top: 16px; 56 | } 57 | .contentLabelDesc { 58 | margin: 12px 0 16px; 59 | @include font-type($bwt_scopeFontFamily, $bwt_secondaryFontSize); 60 | } 61 | 62 | .contentTextField { 63 | margin-top: 16px; 64 | } 65 | .contentTextFieldPhone { 66 | div { 67 | border-top-left-radius: 0px; 68 | border-bottom-left-radius: 0px; 69 | } 70 | } 71 | 72 | .countryCode { 73 | width: 60px; 74 | height: 32px; 75 | border: 1px solid rgb(96, 94, 92); 76 | border-top-left-radius: 2px; 77 | border-bottom-left-radius: 2px; 78 | border-right: none; 79 | text-align: center; 80 | line-height: 30px; 81 | } 82 | 83 | .phoneTextField { 84 | width: 248px; 85 | } 86 | .panelFormButtons { 87 | margin-top: 24px; 88 | } 89 | 90 | .bwtAccordion { 91 | > ul > li { 92 | padding: 16px; 93 | border-top: $bwt_lightGrayBorder; 94 | 95 | &:last-child { 96 | border-bottom: $bwt_lightGrayBorder; 97 | } 98 | 99 | &.expandItem { 100 | .contentLabel { 101 | @include font-type($bwt_semiboldFontFamily, $bwt_standardFontSize); 102 | } 103 | } 104 | } 105 | 106 | .accordionLabel { 107 | cursor: pointer; 108 | } 109 | 110 | .bwtAccordionContent { 111 | transform-origin: top; 112 | } 113 | } 114 | 115 | .toggleButton { 116 | > label { 117 | width: calc(100% - 56px); 118 | color: $bwt_primaryTextColor; 119 | } 120 | 121 | > div { 122 | label { 123 | width: 0; 124 | margin: 0; 125 | } 126 | } 127 | } 128 | 129 | .secondaryText { 130 | @include font-type($bwt_scopeFontFamily, $bwt_secondaryFontSize); 131 | color: $bwt_standardTextColor; 132 | padding-bottom: 12px; 133 | } 134 | 135 | .chevronRotate > i { 136 | transform: rotate(-180deg); 137 | } 138 | 139 | .padding0 { 140 | padding: 0; 141 | } 142 | 143 | .commentTextFiled { 144 | margin-bottom: 20px; 145 | } 146 | 147 | .ratingComponent { 148 | margin: 12px 0 20px; 149 | 150 | .ratingNumbers { 151 | list-style-type: none; 152 | display: flex; 153 | } 154 | 155 | .feedbackRatingCount { 156 | margin: 16px 0 8px; 157 | } 158 | 159 | li { 160 | @include border-radius(2px); 161 | @include font-type($bwt_semiboldFontFamily, $bwt_secondaryFontSize); 162 | margin-right: 3px; 163 | color: $bwt_primaryTextColor; 164 | background: $bwt_lightGray50Color; 165 | height: 28px; 166 | width: 24px; 167 | text-align: center; 168 | line-height: 28px; 169 | cursor: pointer; 170 | flex: 1; 171 | &:hover { 172 | background: $bwt_lightGray60Color; 173 | } 174 | 175 | &.activeClass { 176 | background: $bwt_primaryTealColor; 177 | color: $bwt_white; 178 | &:hover { 179 | background: $bwt_headerElementsHoverBackGroundColor; 180 | } 181 | } 182 | } 183 | } 184 | 185 | .feedbackComment { 186 | margin-top: 12px; 187 | 188 | h3 { 189 | @include font-type($bwt_semiboldFontFamily, $bwt_standardFontSize); 190 | margin-bottom: 4px; 191 | } 192 | 193 | p { 194 | @include font-type($bwt_scopeFontFamily, $bwt_secondaryFontSize); 195 | padding-bottom: 4px; 196 | } 197 | } 198 | 199 | .settingsModule { 200 | padding: 10px 0 24px; 201 | border-bottom: $bwt_lightGrayBorder; 202 | position: relative; 203 | 204 | &:last-child { 205 | border: 0; 206 | padding-bottom: 0; 207 | } 208 | 209 | h4 { 210 | font-weight: 600; 211 | padding-bottom: 8px; 212 | } 213 | 214 | &.disabled { 215 | opacity: 0.5; 216 | 217 | &::after { 218 | width: 100%; 219 | height: 100%; 220 | position: absolute; 221 | top: 0; 222 | left: 0; 223 | content: " "; 224 | } 225 | } 226 | } 227 | } 228 | 229 | .leftHeaderPanel { 230 | .headerTitle { 231 | font-weight: 600; 232 | margin-bottom: 20px; 233 | } 234 | 235 | .bingToolsLinks { 236 | margin: 12px 0; 237 | } 238 | } 239 | 240 | .leftPanelIcon { 241 | line-height: 54px; 242 | cursor: pointer; 243 | } 244 | 245 | .noNotification { 246 | width: 70%; 247 | margin: auto; 248 | text-align: center; 249 | padding: 50px 0; 250 | 251 | h2 { 252 | font-weight: 600; 253 | } 254 | 255 | p { 256 | padding-top: 20px; 257 | color: $bwt_optionalTextColor; 258 | } 259 | } 260 | .notificationsFilter { 261 | top: 0; 262 | position: sticky; 263 | z-index: 10; 264 | background: $bwt_lightGray10Color; 265 | padding: 0 16px 12px; 266 | margin: -24px -16px 5px; 267 | .notificationFilterDropdown { 268 | width: 135px; 269 | margin-top: 12px; 270 | margin-right: 8px; 271 | display: inline-block; 272 | 273 | * { 274 | border-color: $bwt_filterBorderColor; 275 | } 276 | } 277 | .toggleButton { 278 | width: 140px; 279 | margin-bottom: 0px; 280 | margin-top: 14px; 281 | } 282 | } 283 | 284 | .messageCard { 285 | @include box-shadow($bwt_messageCardShadow, $bwt_messageCardHoverShadow); 286 | @include border-radius(2px); 287 | background: $bwt_white; 288 | cursor: pointer; 289 | min-width: 300px; 290 | border-radius: 2px; 291 | transition: box-shadow 0.5s ease 0s; 292 | position: relative; 293 | padding: 16px; 294 | margin-bottom: 10px; 295 | 296 | .messageTime { 297 | position: absolute; 298 | right: 16px; 299 | top: 16px; 300 | @include font-type($bwt_scopeFontFamily, 12px); 301 | color: $bwt_darkGray40Color; 302 | } 303 | 304 | .messageSiteUrl { 305 | margin-bottom: 15px; 306 | span { 307 | @include singleLineEllipsis(); 308 | @include font-type($bwt_scopeFontFamily, 12px); 309 | width: calc(100% - 120px); 310 | color: $bwt_darkGray40Color; 311 | } 312 | } 313 | 314 | .messageTitle { 315 | span { 316 | @include singleLineEllipsis(); 317 | @include font-type($bwt_semiboldFontFamily, 14px); 318 | width: calc(100% - 120px); 319 | } 320 | } 321 | 322 | .messageSubject { 323 | margin-top: 8px; 324 | @include singleLineEllipsis(); 325 | } 326 | .messageDescription { 327 | max-height: 0; 328 | height: auto; 329 | overflow: hidden; 330 | transition: max-height 0.2s cubic-bezier(0, 1, 0, 1); 331 | cursor: auto; 332 | .descriptionHeader { 333 | margin-top: 12px; 334 | @include font-type($bwt_semiboldFontFamily, 14px); 335 | } 336 | .description { 337 | margin-top: 8px; 338 | } 339 | 340 | &.showDesc { 341 | max-height: 100vh; 342 | transition: max-height 0.2s ease-in-out; 343 | } 344 | a { 345 | color: $bwt_primaryTealColor; 346 | cursor: pointer; 347 | } 348 | } 349 | 350 | .messageActions { 351 | position: absolute; 352 | right: 16px; 353 | bottom: 8px; 354 | background: $bwt_white; 355 | display: none; 356 | 357 | > i { 358 | @include displayIB(); 359 | padding: 8px; 360 | color: $bwt_darkGray30Color; 361 | font-size: $bwt_smallIconSize; 362 | 363 | &:hover { 364 | background: $bwt_lightGray40Color; 365 | } 366 | } 367 | } 368 | 369 | .showActions { 370 | position: static; 371 | float: right; 372 | display: block; 373 | } 374 | 375 | &.messageRead { 376 | &:before { 377 | content: " "; 378 | position: absolute; 379 | width: 3px; 380 | height: 100%; 381 | top: 0; 382 | left: 0; 383 | background: $bwt_primaryTealColor; 384 | border-radius: 2px 0 0 2px; 385 | } 386 | .messageActions { 387 | .messageUnreadIcon, 388 | .messageReadIcon, 389 | .messageDeleteIcon { 390 | z-index: 10000000; 391 | } 392 | } 393 | } 394 | 395 | &:hover { 396 | .messageSubject { 397 | width: calc(100% - 74px); 398 | } 399 | 400 | .messageActions { 401 | display: inline-block; 402 | } 403 | } 404 | } 405 | 406 | .rightSidePanelHeader { 407 | padding: 16px 16px 0; 408 | display: flex; 409 | justify-content: space-between; 410 | 411 | .panelHeaderTitle { 412 | @include font-type($bwt_semiboldFontFamily, $bwt_mediumIconSize); 413 | } 414 | } 415 | 416 | .profileBottomLinks { 417 | .linkButton { 418 | height: 16px; 419 | line-height: 10px; 420 | margin-bottom: 10px; 421 | display: block; 422 | } 423 | a { 424 | height: 16px; 425 | display: block; 426 | line-height: 10px; 427 | } 428 | } 429 | 430 | .accountList { 431 | margin-top: 10px; 432 | width: 100%; 433 | position: relative; 434 | .personaCard { 435 | width: 100%; 436 | position: relative; 437 | } 438 | .accountPersona { 439 | @include singleLineEllipsis; 440 | padding: 4px 0; 441 | height: 44px; 442 | float: left; 443 | width: 264px; 444 | } 445 | .accountOverFlow { 446 | position: absolute; 447 | right: 0; 448 | top: 8px; 449 | width: 40px; 450 | } 451 | .accountMenu { 452 | .ms-CommandBar { 453 | padding: 0px; 454 | i { 455 | transform: rotate(90deg); 456 | } 457 | } 458 | } 459 | } 460 | 461 | .noGscAccounts { 462 | @include font-type($bwt_scopeFontFamily, $bwt_secondaryFontSize); 463 | margin-top: 10px; 464 | color: $bwt_secondaryTextColor; 465 | } 466 | 467 | .bwtAccordionAnim-enter { 468 | max-height: 0; 469 | } 470 | 471 | .bwtAccordionAnim-enter.bwtAccordionAnim-enter-active { 472 | max-height: 550px; 473 | transition: max-height 500ms cubic-bezier(0.4, 0, 0.2, 1); 474 | } 475 | 476 | .bwtAccordionAnim-leave { 477 | max-height: 550px; 478 | } 479 | 480 | .bwtAccordionAnim-leave.bwtAccordionAnim-leave-active { 481 | max-height: 0; 482 | transition: max-height 300ms cubic-bezier(0.4, 0, 0.2, 1); 483 | } 484 | 485 | @media (max-width: 639px) { 486 | .notificationsFilter { 487 | .notificationFilterDropdown { 488 | width: 100%; 489 | } 490 | 491 | .toggleButton { 492 | float: left; 493 | } 494 | } 495 | 496 | .messageCard { 497 | .messageSubject { 498 | width: calc(100% - 74px); 499 | } 500 | 501 | .messageActions { 502 | display: inline-block; 503 | } 504 | } 505 | } 506 | -------------------------------------------------------------------------------- /src/scss/mixins/_border-radius.scss: -------------------------------------------------------------------------------- 1 | @mixin border-radius($radius) { 2 | border-radius: $radius; 3 | } -------------------------------------------------------------------------------- /src/scss/mixins/_clearfix.scss: -------------------------------------------------------------------------------- 1 | // Bootstrap v3.3.5 (http://getbootstrap.com) 2 | // Copyright 2011-2015 Twitter, Inc. 3 | // Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 4 | 5 | // Clearfix 6 | // 7 | // For modern browsers 8 | // 1. The space content is one way to avoid an Opera bug when the 9 | // contenteditable attribute is included anywhere else in the document. 10 | // Otherwise it causes space to appear at the top and bottom of elements 11 | // that are clearfixed. 12 | // 2. The use of `table` rather than `block` is only necessary if using 13 | // `:before` to contain the top-margins of child elements. 14 | // 15 | // Source: http://nicolasgallagher.com/micro-clearfix-hack/ 16 | 17 | @mixin clearfix() { 18 | &:before, 19 | &:after { 20 | content: " "; // 1 21 | display: table; // 2 22 | } 23 | &:after { 24 | clear: both; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/scss/mixins/_disabletext.scss: -------------------------------------------------------------------------------- 1 | // Disable text selection on double click 2 | @mixin disable-text-selection() { 3 | -webkit-user-select: none; /* webkit (safari, chrome) browsers */ 4 | -moz-user-select: none; /* mozilla browsers */ 5 | -khtml-user-select: none; /* webkit (konqueror) browsers */ 6 | -ms-user-select: none; /* IE10+ */ 7 | } 8 | -------------------------------------------------------------------------------- /src/scss/mixins/_display.scss: -------------------------------------------------------------------------------- 1 | // Add display block or inline-block depends on the element 2 | @mixin displayIB() { 3 | display: inline-block; 4 | vertical-align: middle; 5 | } -------------------------------------------------------------------------------- /src/scss/mixins/_fonts.scss: -------------------------------------------------------------------------------- 1 | @mixin font-type($family, $size, $line-height: 1.4) { 2 | font-family: $family; 3 | font-size: $size; 4 | line-height: $line-height; 5 | } -------------------------------------------------------------------------------- /src/scss/mixins/_icons.scss: -------------------------------------------------------------------------------- 1 | @mixin iconStyle($iconSize, $iconColor) { 2 | font-size: $iconSize; 3 | color: $iconColor; 4 | } -------------------------------------------------------------------------------- /src/scss/mixins/_opacity.scss: -------------------------------------------------------------------------------- 1 | @mixin opacity($opacity) { 2 | opacity: $opacity / 100; 3 | filter: "alpha(opacity=${opacity})"; 4 | } -------------------------------------------------------------------------------- /src/scss/mixins/_shadow.scss: -------------------------------------------------------------------------------- 1 | @mixin box-shadow($boxshadow, $hovershadow) { 2 | -webkit-box-shadow: $boxshadow; 3 | -moz-box-shadow: $boxshadow; 4 | box-shadow: $boxshadow; 5 | 6 | &:hover { 7 | -webkit-box-shadow: $hovershadow; 8 | -moz-box-shadow: $hovershadow; 9 | box-shadow: $hovershadow; 10 | } 11 | } -------------------------------------------------------------------------------- /src/scss/mixins/_textellipsis.scss: -------------------------------------------------------------------------------- 1 | // Text ellipsis 2 | 3 | // Add display block or inline-block depends on the element 4 | @mixin singleLineEllipsis() { 5 | white-space: nowrap; 6 | overflow: hidden; 7 | text-overflow: ellipsis; 8 | } 9 | 10 | @mixin multiLineEllipsis($lineHeight: 1.2em, $lineCount: 2, $bgColor: white) { 11 | overflow: hidden; 12 | position: relative; 13 | line-height: $lineHeight; 14 | max-height: $lineHeight * $lineCount; 15 | text-align: justify; 16 | margin-right: -1em; 17 | padding-right: 1em; 18 | word-break: break-all; 19 | 20 | &:before { 21 | content: '...'; 22 | position: absolute; 23 | right: .5em; 24 | bottom: 0; 25 | } 26 | 27 | &:after { 28 | content: ''; 29 | position: absolute; 30 | right: .5em; 31 | width: 1em; 32 | height: 1em; 33 | margin-top: 0.2em; 34 | background: $bgColor; 35 | } 36 | } -------------------------------------------------------------------------------- /src/scss/mixins/_transform.scss: -------------------------------------------------------------------------------- 1 | @mixin bt-transform($transform) { 2 | -webkit-transform: $transform; 3 | -moz-transform: $transform; 4 | -o-transform: $transform; 5 | -ms-transform: $transform; 6 | transform: $transform; 7 | } -------------------------------------------------------------------------------- /src/scss/mixins/_transition.scss: -------------------------------------------------------------------------------- 1 | @mixin transition($transition) { 2 | -webkit-transition: $transition; 3 | -moz-transition: $transition; 4 | -o-transition: $transition; 5 | transition: $transition; 6 | } -------------------------------------------------------------------------------- /src/scss/responsiveLayout.scss: -------------------------------------------------------------------------------- 1 | @import "./default"; 2 | 3 | // mobile 4 | @media (max-width: 782px) { 5 | 6 | .desktopOnly { 7 | display: none; 8 | } 9 | 10 | .bw-Header { 11 | padding: 0 12px; 12 | 13 | .headerLeftElements { 14 | padding-left: 16px; 15 | } 16 | 17 | .headerRightElements { 18 | padding-right: 16px; 19 | } 20 | } 21 | 22 | } 23 | 24 | // non-mobile 25 | @media (min-width: 783px) { 26 | 27 | .mobileOnly { 28 | display: none; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { 'Service-Worker': 'script' }, 105 | }) 106 | .then(response => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get('content-type'); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf('javascript') === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then(registration => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | 'No internet connection found. App is running in offline mode.' 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ('serviceWorker' in navigator) { 133 | navigator.serviceWorker.ready 134 | .then(registration => { 135 | registration.unregister(); 136 | }) 137 | .catch(error => { 138 | console.error(error.message); 139 | }); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "es5" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "react", 21 | "sourceMap": true, 22 | "noFallthroughCasesInSwitch": true 23 | }, 24 | "include": [ 25 | "src" 26 | ] 27 | } 28 | --------------------------------------------------------------------------------