├── .babelrc ├── .eslintrc ├── .gitignore ├── .stylelintrc ├── .sublimelinterrc ├── .travis.yml ├── LICENSE ├── Readme.md ├── bin └── install-wp-tests.sh ├── composer.json ├── composer.lock ├── gulpfile.babel.js ├── package-lock.json ├── package.json ├── phpunit.xml ├── src └── json-wp-post-parser │ ├── LICENSE.txt │ ├── README.txt │ ├── admin │ ├── class-admin.php │ ├── class-parse.php │ ├── class-rest-functionality.php │ └── index.php │ ├── includes │ ├── class-activator.php │ ├── class-deactivator.php │ ├── class-internationalization.php │ ├── class-loader.php │ ├── class-main.php │ └── index.php │ ├── index.php │ ├── json-wp-post-parser.php │ ├── lib │ ├── autoloader.php │ └── index.php │ ├── skin │ └── assets │ │ ├── application.js │ │ ├── scripts │ │ ├── ajax-helper.js │ │ └── scriptsAdmin.js │ │ └── styles │ │ └── stylesAdmin.scss │ └── uninstall.php ├── tests ├── bootstrap.php └── test-parsed-content.php └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "targets": { 5 | "browsers": ["last 2 versions", "not ie < 11", "android >= 4.2"] 6 | } 7 | }] 8 | ] 9 | } -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@infinumjs", 3 | 4 | "env": { 5 | "browser": true, 6 | "node": true, 7 | "commonjs": true, 8 | "es6": true, 9 | "jquery": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Project dev files 2 | /vendor/ 3 | /node_modules/ 4 | 5 | # Project build folder 6 | /build/ 7 | 8 | # Vagrantfile 9 | Vagrantfile 10 | 11 | # Build files 12 | /build/ 13 | 14 | # Mac OS custom attribute store and thumbnails 15 | *.DS_Store 16 | ._* 17 | 18 | # Windows thumbnail cache files 19 | Thumbs.db 20 | ehthumbs.db 21 | ehthumbs_vista.db 22 | -------------------------------------------------------------------------------- /.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@infinumjs/stylelint-config", 3 | "ignoreFiles": [ 4 | "build/**/*.css", 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.sublimelinterrc: -------------------------------------------------------------------------------- 1 | { 2 | "SublimeLinter": { 3 | "paths": { 4 | "linux": [], 5 | "osx": [ 6 | "/vendor/bin" 7 | ], 8 | "windows": [] 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | dist: trusty 3 | 4 | language: php 5 | 6 | before_install: 7 | - phpenv config-rm xdebug.ini 8 | 9 | notifications: 10 | email: 11 | on_success: never 12 | on_failure: change 13 | 14 | branches: 15 | only: 16 | - master 17 | 18 | cache: 19 | apt: true 20 | directories: 21 | - vendor 22 | - node_modules 23 | - composer 24 | - $HOME/.composer/cache 25 | 26 | matrix: 27 | fast_finish: true 28 | include: 29 | - php: 7.1 30 | env: WP_VERSION=latest WP_MULTISITE=0 SNIFF=1 31 | - php: 7.0 32 | env: WP_VERSION=latest 33 | - php: 5.6 34 | env: WP_VERSION=latest WP_MULTISITE=1 35 | 36 | before_script: 37 | - export PATH="$HOME/.composer/vendor/bin:$PATH" 38 | - if [[ "$SNIFF" == "1" ]]; then 39 | composer global require wp-coding-standards/wpcs; 40 | phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs; 41 | phpcs --config-set standard infinum; 42 | fi 43 | - | 44 | if [[ ! -z "$WP_VERSION" ]]; then 45 | bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION 46 | if [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then 47 | composer global require "phpunit/phpunit=4.8.*" 48 | else 49 | composer global require "phpunit/phpunit=5.7.*" 50 | fi 51 | fi 52 | 53 | script: 54 | # Search theme for PHP syntax errors. 55 | - find . \( -name '*.php' \) -exec php -lf {} \; 56 | - | 57 | if [[ ! -z "$WP_VERSION" ]]; then 58 | phpunit 59 | WP_MULTISITE=1 phpunit 60 | fi 61 | - | 62 | if [[ "$SNIFF" == "1" ]]; then 63 | composer global require wp-coding-standards/wpcs; 64 | phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs; 65 | phpcs --config-set standard infinum; 66 | fi 67 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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 | ### JSON post parser 2 | 3 | [![Travis](https://img.shields.io/travis/infinum/json-wp-post-parser.svg?style=for-the-badge)](https://github.com/infinum/json-wp-post-parser) 4 | [![GitHub tag](https://img.shields.io/github/tag/infinum/json-wp-post-parser.svg?style=for-the-badge)](https://github.com/infinum/json-wp-post-parser) 5 | 6 | JSON Post Parser plugin parses your content and saves it as JSON available in REST posts and pages endpoints. 7 | 8 | ## Description 9 | 10 | When working on decoupled WordPress, while using one of the popular frameworks or libraries such as React, post content in pure HTML can be a bit of a problem. Having absolute links that point to the on-site resource would cause a page refresh. Which defeats the purpose of building with, for instance, React, which uses Link component to handle routes. 11 | This is where having post served as JSON simplifies things, in that you can find all the links, and then replace them with the appropriate router alternative. 12 | 13 | When you create a post and then save it, the parser will go through your rendered post and parse it in JSON, which will then be saved in `post_content_json` table in the `posts` table. 14 | Other than parsing the post, this plugin registers the additional REST field called `post_content_json` which you can fetch by going to `wp-json/wp/v2/posts/` or `wp-json/wp/v2/pages/`. 15 | 16 | If you want to expose your own custom post types to the REST endpoint, use the filter `json_post_parser_add_post_types`. 17 | 18 | ## Development Setup 19 | 20 | ```sh 21 | npm i 22 | ``` 23 | 24 | or 25 | 26 | ```sh 27 | yarn 28 | ``` 29 | 30 | ```sh 31 | composer install 32 | ``` 33 | 34 | ## Precommit tests 35 | 36 | This will run eslint, stylelint and phpcs tests. 37 | 38 | ```sh 39 | npm run precommit 40 | ``` 41 | 42 | ### Build 43 | 44 | ```sh 45 | npm run build 46 | ``` 47 | 48 | ### Unit tests 49 | 50 | All the unit tests are located in the `\tests` folder. The unit testing is done via [PHPUnit](https://phpunit.de/). Feel free to add you own tests or check the existing one. You need to have at the most PHPUnit 6 for the tests to pass. 51 | 52 | To initialize the testing environment locally go to the project root (where `phpunit.xml` resides) and run 53 | 54 | ```sh 55 | sh bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest 56 | ``` 57 | 58 | This should create a temporary WordPress installation in the `/private/tmp/wordpress` folder. Be sure to set up the `wp-config.php` in the test WordPress install. 59 | 60 | After that you can run plugin tests by writing 61 | 62 | ```sh 63 | vendor/bin/phpunit 64 | ``` 65 | 66 | ## WordPress Installation 67 | 68 | Once you've built the plugin using npm, you can use code found in the `/build/` folder as a regular WordPress plugin. 69 | 70 | 1. Place `json-wp-post-parser` folder in the `/wp-content/plugins/` directory 71 | 2. Activate the plugin through the 'Plugins' menu in WordPress 72 | 73 | ## Other usages 74 | 75 | You can use parse methods in other plugins if you want to. Once you install the plugin you can use the `parse_content_to_json()` method to parse HTML to json parsed content. 76 | 77 | ```php 78 | 79 | $parser = new \Json_WP_Post_Parser\Admin\Parse(); 80 | 81 | $parsed_content = $parser->parse_content_to_json( $html_content ); 82 | ``` 83 | 84 | ## Frequently Asked Questions 85 | 86 | ### Will all my posts automatically be parsed? 87 | 88 | No. Upon plugin activation, you will see a prompt that will ask you if you want to update all your posts, pages, custom post types. 89 | If you say yes, you'll be sent to a page where you'll see all your posts being resaved using AJAX. 90 | The reason for this is that someone can have 1000+ posts, and doing bulk upgrade would fail (exhausted memory, timeout etc.). 91 | By using AJAX we can trigger post saving asynchronously, which doesn't overload the system. 92 | 93 | ### How can I add my custom post types, so that rest route has it as well? 94 | 95 | There is a built in filter hook which you can use called `json_wp_post_parser_add_post_types`. Say you have custom post type called `books`, 96 | you'd add them like this: 97 | 98 | ```php 99 | add_filter( 'json_wp_post_parser_add_post_types', 'my_slug_add_cpt_to_parser' ); 100 | 101 | function my_slug_add_cpt_to_parser( $post_types ) { 102 | // the $post_types parameter is an array of all post_types from the api_fields_init() method. 103 | $post_types[] = 'books'; 104 | return $post_types; 105 | } 106 | ``` 107 | 108 | Be aware that to access the custom post content of your custom post type, you'll have to enable its [REST capabilities](https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-rest-api-support-for-custom-content-types/). 109 | 110 | ## Possible issues 111 | 112 | When using post update to update all your posts, the default number of posts that are queried is 5000. This is done to optimize query performance. Because you should never use `'posts_per_page' => -1`. If you have more than 5000 posts then open `class-json-post-parser-admin.php` and change this number on line 84. 113 | 114 | ## Changelog 115 | 116 | ### 1.0.7 117 | 118 | * Autoloader fix 119 | * Removed unused packages 120 | * Fix the unit testing 121 | 122 | ### 1.0.6 123 | 124 | * Minor class fixes 125 | 126 | ### 1.0.5 127 | 128 | * Linter fixes 129 | * Class name fixes 130 | 131 | ### 1.0 132 | 133 | * Initial release 134 | 135 | ## Credits 136 | 137 | JSON post parser is maintained and sponsored by 138 | [Infinum](https://www.infinum.co). 139 | 140 | 141 | 142 | ## License 143 | 144 | JSON post parser is Copyright © 2017 Infinum. It is free software, and may be redistributed under the terms specified in the LICENSE file. 145 | -------------------------------------------------------------------------------- /bin/install-wp-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "usage: $0 [db-host] [wp-version] [skip-database-creation]" 5 | exit 1 6 | fi 7 | 8 | DB_NAME=$1 9 | DB_USER=$2 10 | DB_PASS=$3 11 | DB_HOST=${4-localhost} 12 | WP_VERSION=${5-latest} 13 | SKIP_DB_CREATE=${6-false} 14 | 15 | WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} 16 | WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} 17 | 18 | download() { 19 | if [ `which curl` ]; then 20 | curl -s "$1" > "$2"; 21 | elif [ `which wget` ]; then 22 | wget -nv -O "$2" "$1" 23 | fi 24 | } 25 | 26 | if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then 27 | WP_TESTS_TAG="tags/$WP_VERSION" 28 | elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then 29 | WP_TESTS_TAG="trunk" 30 | else 31 | # http serves a single offer, whereas https serves multiple. we only want one 32 | download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json 33 | grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json 34 | LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') 35 | if [[ -z "$LATEST_VERSION" ]]; then 36 | echo "Latest WordPress version could not be found" 37 | exit 1 38 | fi 39 | WP_TESTS_TAG="tags/$LATEST_VERSION" 40 | fi 41 | 42 | set -ex 43 | 44 | install_wp() { 45 | 46 | if [ -d $WP_CORE_DIR ]; then 47 | return; 48 | fi 49 | 50 | mkdir -p $WP_CORE_DIR 51 | 52 | if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then 53 | mkdir -p /tmp/wordpress-nightly 54 | download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip 55 | unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/ 56 | mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR 57 | else 58 | if [ $WP_VERSION == 'latest' ]; then 59 | local ARCHIVE_NAME='latest' 60 | else 61 | local ARCHIVE_NAME="wordpress-$WP_VERSION" 62 | fi 63 | download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz 64 | tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR 65 | fi 66 | 67 | download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php 68 | } 69 | 70 | install_test_suite() { 71 | # portable in-place argument for both GNU sed and Mac OSX sed 72 | if [[ $(uname -s) == 'Darwin' ]]; then 73 | local ioption='-i .bak' 74 | else 75 | local ioption='-i' 76 | fi 77 | 78 | # set up testing suite if it doesn't yet exist 79 | if [ ! -d $WP_TESTS_DIR ]; then 80 | # set up testing suite 81 | mkdir -p $WP_TESTS_DIR 82 | svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes 83 | svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data 84 | fi 85 | 86 | if [ ! -f wp-tests-config.php ]; then 87 | download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php 88 | # remove all forward slashes in the end 89 | WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") 90 | sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php 91 | sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php 92 | sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php 93 | sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php 94 | sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php 95 | fi 96 | 97 | } 98 | 99 | install_db() { 100 | 101 | if [ ${SKIP_DB_CREATE} = "true" ]; then 102 | return 0 103 | fi 104 | 105 | # parse DB_HOST for port or socket references 106 | local PARTS=(${DB_HOST//\:/ }) 107 | local DB_HOSTNAME=${PARTS[0]}; 108 | local DB_SOCK_OR_PORT=${PARTS[1]}; 109 | local EXTRA="" 110 | 111 | if ! [ -z $DB_HOSTNAME ] ; then 112 | if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then 113 | EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" 114 | elif ! [ -z $DB_SOCK_OR_PORT ] ; then 115 | EXTRA=" --socket=$DB_SOCK_OR_PORT" 116 | elif ! [ -z $DB_HOSTNAME ] ; then 117 | EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" 118 | fi 119 | fi 120 | 121 | # create database 122 | mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA 123 | } 124 | 125 | install_wp 126 | install_test_suite 127 | install_db 128 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "infinum/json-wp-post-parser", 3 | "type": "wordpress-plugin", 4 | "description": "JSON Post Parser plugin parses your content and saves it as JSON available in REST posts and pages endpoints.", 5 | "keywords": ["plugin", "WordPress", "json", "REST API", "parser"], 6 | "homepage": "https://github.com/infinum/json-wp-post-parser/", 7 | "license": "GPL-2.0", 8 | "authors": [ 9 | { 10 | "name" : "Contributors", 11 | "homepage": "https://github.com/infinum/json-wp-post-parser/graphs/contributors" 12 | } 13 | ], 14 | "require-dev": { 15 | "dealerdirect/phpcodesniffer-composer-installer": "0.5.0", 16 | "infinum/coding-standards-wp": "0.4.1", 17 | "phpunit/phpunit": "^6.4" 18 | }, 19 | "support" : { 20 | "issues": "https://github.com/infinum/json-wp-post-parser/issues", 21 | "wiki" : "https://github.com/infinum/json-wp-post-parser/wiki", 22 | "source": "https://github.com/infinum/json-wp-post-parser" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "890cd159deca60b6419edb650303e3d9", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "dealerdirect/phpcodesniffer-composer-installer", 12 | "version": "v0.4.4", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", 16 | "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/2e41850d5f7797cbb1af7b030d245b3b24e63a08", 21 | "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "composer-plugin-api": "^1.0", 26 | "php": "^5.3|^7", 27 | "squizlabs/php_codesniffer": "*" 28 | }, 29 | "require-dev": { 30 | "composer/composer": "*", 31 | "wimg/php-compatibility": "^8.0" 32 | }, 33 | "suggest": { 34 | "dealerdirect/qa-tools": "All the PHP QA tools you'll need" 35 | }, 36 | "type": "composer-plugin", 37 | "extra": { 38 | "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" 43 | } 44 | }, 45 | "notification-url": "https://packagist.org/downloads/", 46 | "license": [ 47 | "MIT" 48 | ], 49 | "authors": [ 50 | { 51 | "name": "Franck Nijhof", 52 | "email": "f.nijhof@dealerdirect.nl", 53 | "homepage": "http://workingatdealerdirect.eu", 54 | "role": "Developer" 55 | } 56 | ], 57 | "description": "PHP_CodeSniffer Standards Composer Installer Plugin", 58 | "homepage": "http://workingatdealerdirect.eu", 59 | "keywords": [ 60 | "PHPCodeSniffer", 61 | "PHP_CodeSniffer", 62 | "code quality", 63 | "codesniffer", 64 | "composer", 65 | "installer", 66 | "phpcs", 67 | "plugin", 68 | "qa", 69 | "quality", 70 | "standard", 71 | "standards", 72 | "style guide", 73 | "stylecheck", 74 | "tests" 75 | ], 76 | "time": "2017-12-06T16:27:17+00:00" 77 | }, 78 | { 79 | "name": "doctrine/instantiator", 80 | "version": "1.1.0", 81 | "source": { 82 | "type": "git", 83 | "url": "https://github.com/doctrine/instantiator.git", 84 | "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" 85 | }, 86 | "dist": { 87 | "type": "zip", 88 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", 89 | "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", 90 | "shasum": "" 91 | }, 92 | "require": { 93 | "php": "^7.1" 94 | }, 95 | "require-dev": { 96 | "athletic/athletic": "~0.1.8", 97 | "ext-pdo": "*", 98 | "ext-phar": "*", 99 | "phpunit/phpunit": "^6.2.3", 100 | "squizlabs/php_codesniffer": "^3.0.2" 101 | }, 102 | "type": "library", 103 | "extra": { 104 | "branch-alias": { 105 | "dev-master": "1.2.x-dev" 106 | } 107 | }, 108 | "autoload": { 109 | "psr-4": { 110 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 111 | } 112 | }, 113 | "notification-url": "https://packagist.org/downloads/", 114 | "license": [ 115 | "MIT" 116 | ], 117 | "authors": [ 118 | { 119 | "name": "Marco Pivetta", 120 | "email": "ocramius@gmail.com", 121 | "homepage": "http://ocramius.github.com/" 122 | } 123 | ], 124 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 125 | "homepage": "https://github.com/doctrine/instantiator", 126 | "keywords": [ 127 | "constructor", 128 | "instantiate" 129 | ], 130 | "time": "2017-07-22T11:58:36+00:00" 131 | }, 132 | { 133 | "name": "infinum/coding-standards-wp", 134 | "version": "0.2.7", 135 | "source": { 136 | "type": "git", 137 | "url": "https://github.com/infinum/coding-standards-wp.git", 138 | "reference": "a741e2fb46db966145f5bfa6237504018ec74308" 139 | }, 140 | "dist": { 141 | "type": "zip", 142 | "url": "https://api.github.com/repos/infinum/coding-standards-wp/zipball/a741e2fb46db966145f5bfa6237504018ec74308", 143 | "reference": "a741e2fb46db966145f5bfa6237504018ec74308", 144 | "shasum": "" 145 | }, 146 | "require": { 147 | "wp-coding-standards/wpcs": "0.14.0" 148 | }, 149 | "type": "phpcodesniffer-standard", 150 | "notification-url": "https://packagist.org/downloads/", 151 | "license": [ 152 | "MIT" 153 | ], 154 | "authors": [ 155 | { 156 | "name": "Contributors", 157 | "homepage": "https://github.com/infinum/coding-standards-wp/graphs/contributors" 158 | } 159 | ], 160 | "description": "Infinum WordPress Coding Standards", 161 | "homepage": "https://github.com/infinum/coding-standards-wp", 162 | "keywords": [ 163 | "Eightshift", 164 | "Infinum", 165 | "phpcs", 166 | "standards", 167 | "wordpress" 168 | ], 169 | "time": "2018-02-20T12:36:10+00:00" 170 | }, 171 | { 172 | "name": "jakub-onderka/php-console-color", 173 | "version": "0.1", 174 | "source": { 175 | "type": "git", 176 | "url": "https://github.com/JakubOnderka/PHP-Console-Color.git", 177 | "reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1" 178 | }, 179 | "dist": { 180 | "type": "zip", 181 | "url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/e0b393dacf7703fc36a4efc3df1435485197e6c1", 182 | "reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1", 183 | "shasum": "" 184 | }, 185 | "require": { 186 | "php": ">=5.3.2" 187 | }, 188 | "require-dev": { 189 | "jakub-onderka/php-code-style": "1.0", 190 | "jakub-onderka/php-parallel-lint": "0.*", 191 | "jakub-onderka/php-var-dump-check": "0.*", 192 | "phpunit/phpunit": "3.7.*", 193 | "squizlabs/php_codesniffer": "1.*" 194 | }, 195 | "type": "library", 196 | "autoload": { 197 | "psr-0": { 198 | "JakubOnderka\\PhpConsoleColor": "src/" 199 | } 200 | }, 201 | "notification-url": "https://packagist.org/downloads/", 202 | "license": [ 203 | "BSD-2-Clause" 204 | ], 205 | "authors": [ 206 | { 207 | "name": "Jakub Onderka", 208 | "email": "jakub.onderka@gmail.com", 209 | "homepage": "http://www.acci.cz" 210 | } 211 | ], 212 | "time": "2014-04-08T15:00:19+00:00" 213 | }, 214 | { 215 | "name": "jakub-onderka/php-console-highlighter", 216 | "version": "v0.3.2", 217 | "source": { 218 | "type": "git", 219 | "url": "https://github.com/JakubOnderka/PHP-Console-Highlighter.git", 220 | "reference": "7daa75df45242c8d5b75a22c00a201e7954e4fb5" 221 | }, 222 | "dist": { 223 | "type": "zip", 224 | "url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Highlighter/zipball/7daa75df45242c8d5b75a22c00a201e7954e4fb5", 225 | "reference": "7daa75df45242c8d5b75a22c00a201e7954e4fb5", 226 | "shasum": "" 227 | }, 228 | "require": { 229 | "jakub-onderka/php-console-color": "~0.1", 230 | "php": ">=5.3.0" 231 | }, 232 | "require-dev": { 233 | "jakub-onderka/php-code-style": "~1.0", 234 | "jakub-onderka/php-parallel-lint": "~0.5", 235 | "jakub-onderka/php-var-dump-check": "~0.1", 236 | "phpunit/phpunit": "~4.0", 237 | "squizlabs/php_codesniffer": "~1.5" 238 | }, 239 | "type": "library", 240 | "autoload": { 241 | "psr-0": { 242 | "JakubOnderka\\PhpConsoleHighlighter": "src/" 243 | } 244 | }, 245 | "notification-url": "https://packagist.org/downloads/", 246 | "license": [ 247 | "MIT" 248 | ], 249 | "authors": [ 250 | { 251 | "name": "Jakub Onderka", 252 | "email": "acci@acci.cz", 253 | "homepage": "http://www.acci.cz/" 254 | } 255 | ], 256 | "time": "2015-04-20T18:58:01+00:00" 257 | }, 258 | { 259 | "name": "jakub-onderka/php-parallel-lint", 260 | "version": "v1.0.0", 261 | "source": { 262 | "type": "git", 263 | "url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git", 264 | "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8" 265 | }, 266 | "dist": { 267 | "type": "zip", 268 | "url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/04fbd3f5fb1c83f08724aa58a23db90bd9086ee8", 269 | "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8", 270 | "shasum": "" 271 | }, 272 | "require": { 273 | "php": ">=5.3.3" 274 | }, 275 | "require-dev": { 276 | "jakub-onderka/php-console-highlighter": "~0.3", 277 | "nette/tester": "~1.3", 278 | "squizlabs/php_codesniffer": "~2.7" 279 | }, 280 | "suggest": { 281 | "jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet" 282 | }, 283 | "bin": [ 284 | "parallel-lint" 285 | ], 286 | "type": "library", 287 | "autoload": { 288 | "classmap": [ 289 | "./" 290 | ] 291 | }, 292 | "notification-url": "https://packagist.org/downloads/", 293 | "license": [ 294 | "BSD-2-Clause" 295 | ], 296 | "authors": [ 297 | { 298 | "name": "Jakub Onderka", 299 | "email": "ahoj@jakubonderka.cz" 300 | } 301 | ], 302 | "description": "This tool check syntax of PHP files about 20x faster than serial check.", 303 | "homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint", 304 | "time": "2018-02-24T15:31:20+00:00" 305 | }, 306 | { 307 | "name": "myclabs/deep-copy", 308 | "version": "1.7.0", 309 | "source": { 310 | "type": "git", 311 | "url": "https://github.com/myclabs/DeepCopy.git", 312 | "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" 313 | }, 314 | "dist": { 315 | "type": "zip", 316 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", 317 | "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", 318 | "shasum": "" 319 | }, 320 | "require": { 321 | "php": "^5.6 || ^7.0" 322 | }, 323 | "require-dev": { 324 | "doctrine/collections": "^1.0", 325 | "doctrine/common": "^2.6", 326 | "phpunit/phpunit": "^4.1" 327 | }, 328 | "type": "library", 329 | "autoload": { 330 | "psr-4": { 331 | "DeepCopy\\": "src/DeepCopy/" 332 | }, 333 | "files": [ 334 | "src/DeepCopy/deep_copy.php" 335 | ] 336 | }, 337 | "notification-url": "https://packagist.org/downloads/", 338 | "license": [ 339 | "MIT" 340 | ], 341 | "description": "Create deep copies (clones) of your objects", 342 | "keywords": [ 343 | "clone", 344 | "copy", 345 | "duplicate", 346 | "object", 347 | "object graph" 348 | ], 349 | "time": "2017-10-19T19:58:43+00:00" 350 | }, 351 | { 352 | "name": "phar-io/manifest", 353 | "version": "1.0.1", 354 | "source": { 355 | "type": "git", 356 | "url": "https://github.com/phar-io/manifest.git", 357 | "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" 358 | }, 359 | "dist": { 360 | "type": "zip", 361 | "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", 362 | "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", 363 | "shasum": "" 364 | }, 365 | "require": { 366 | "ext-dom": "*", 367 | "ext-phar": "*", 368 | "phar-io/version": "^1.0.1", 369 | "php": "^5.6 || ^7.0" 370 | }, 371 | "type": "library", 372 | "extra": { 373 | "branch-alias": { 374 | "dev-master": "1.0.x-dev" 375 | } 376 | }, 377 | "autoload": { 378 | "classmap": [ 379 | "src/" 380 | ] 381 | }, 382 | "notification-url": "https://packagist.org/downloads/", 383 | "license": [ 384 | "BSD-3-Clause" 385 | ], 386 | "authors": [ 387 | { 388 | "name": "Arne Blankerts", 389 | "email": "arne@blankerts.de", 390 | "role": "Developer" 391 | }, 392 | { 393 | "name": "Sebastian Heuer", 394 | "email": "sebastian@phpeople.de", 395 | "role": "Developer" 396 | }, 397 | { 398 | "name": "Sebastian Bergmann", 399 | "email": "sebastian@phpunit.de", 400 | "role": "Developer" 401 | } 402 | ], 403 | "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", 404 | "time": "2017-03-05T18:14:27+00:00" 405 | }, 406 | { 407 | "name": "phar-io/version", 408 | "version": "1.0.1", 409 | "source": { 410 | "type": "git", 411 | "url": "https://github.com/phar-io/version.git", 412 | "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" 413 | }, 414 | "dist": { 415 | "type": "zip", 416 | "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", 417 | "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", 418 | "shasum": "" 419 | }, 420 | "require": { 421 | "php": "^5.6 || ^7.0" 422 | }, 423 | "type": "library", 424 | "autoload": { 425 | "classmap": [ 426 | "src/" 427 | ] 428 | }, 429 | "notification-url": "https://packagist.org/downloads/", 430 | "license": [ 431 | "BSD-3-Clause" 432 | ], 433 | "authors": [ 434 | { 435 | "name": "Arne Blankerts", 436 | "email": "arne@blankerts.de", 437 | "role": "Developer" 438 | }, 439 | { 440 | "name": "Sebastian Heuer", 441 | "email": "sebastian@phpeople.de", 442 | "role": "Developer" 443 | }, 444 | { 445 | "name": "Sebastian Bergmann", 446 | "email": "sebastian@phpunit.de", 447 | "role": "Developer" 448 | } 449 | ], 450 | "description": "Library for handling version information and constraints", 451 | "time": "2017-03-05T17:38:23+00:00" 452 | }, 453 | { 454 | "name": "phpdocumentor/reflection-common", 455 | "version": "1.0.1", 456 | "source": { 457 | "type": "git", 458 | "url": "https://github.com/phpDocumentor/ReflectionCommon.git", 459 | "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" 460 | }, 461 | "dist": { 462 | "type": "zip", 463 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", 464 | "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", 465 | "shasum": "" 466 | }, 467 | "require": { 468 | "php": ">=5.5" 469 | }, 470 | "require-dev": { 471 | "phpunit/phpunit": "^4.6" 472 | }, 473 | "type": "library", 474 | "extra": { 475 | "branch-alias": { 476 | "dev-master": "1.0.x-dev" 477 | } 478 | }, 479 | "autoload": { 480 | "psr-4": { 481 | "phpDocumentor\\Reflection\\": [ 482 | "src" 483 | ] 484 | } 485 | }, 486 | "notification-url": "https://packagist.org/downloads/", 487 | "license": [ 488 | "MIT" 489 | ], 490 | "authors": [ 491 | { 492 | "name": "Jaap van Otterdijk", 493 | "email": "opensource@ijaap.nl" 494 | } 495 | ], 496 | "description": "Common reflection classes used by phpdocumentor to reflect the code structure", 497 | "homepage": "http://www.phpdoc.org", 498 | "keywords": [ 499 | "FQSEN", 500 | "phpDocumentor", 501 | "phpdoc", 502 | "reflection", 503 | "static analysis" 504 | ], 505 | "time": "2017-09-11T18:02:19+00:00" 506 | }, 507 | { 508 | "name": "phpdocumentor/reflection-docblock", 509 | "version": "4.3.0", 510 | "source": { 511 | "type": "git", 512 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 513 | "reference": "94fd0001232e47129dd3504189fa1c7225010d08" 514 | }, 515 | "dist": { 516 | "type": "zip", 517 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", 518 | "reference": "94fd0001232e47129dd3504189fa1c7225010d08", 519 | "shasum": "" 520 | }, 521 | "require": { 522 | "php": "^7.0", 523 | "phpdocumentor/reflection-common": "^1.0.0", 524 | "phpdocumentor/type-resolver": "^0.4.0", 525 | "webmozart/assert": "^1.0" 526 | }, 527 | "require-dev": { 528 | "doctrine/instantiator": "~1.0.5", 529 | "mockery/mockery": "^1.0", 530 | "phpunit/phpunit": "^6.4" 531 | }, 532 | "type": "library", 533 | "extra": { 534 | "branch-alias": { 535 | "dev-master": "4.x-dev" 536 | } 537 | }, 538 | "autoload": { 539 | "psr-4": { 540 | "phpDocumentor\\Reflection\\": [ 541 | "src/" 542 | ] 543 | } 544 | }, 545 | "notification-url": "https://packagist.org/downloads/", 546 | "license": [ 547 | "MIT" 548 | ], 549 | "authors": [ 550 | { 551 | "name": "Mike van Riel", 552 | "email": "me@mikevanriel.com" 553 | } 554 | ], 555 | "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", 556 | "time": "2017-11-30T07:14:17+00:00" 557 | }, 558 | { 559 | "name": "phpdocumentor/type-resolver", 560 | "version": "0.4.0", 561 | "source": { 562 | "type": "git", 563 | "url": "https://github.com/phpDocumentor/TypeResolver.git", 564 | "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" 565 | }, 566 | "dist": { 567 | "type": "zip", 568 | "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", 569 | "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", 570 | "shasum": "" 571 | }, 572 | "require": { 573 | "php": "^5.5 || ^7.0", 574 | "phpdocumentor/reflection-common": "^1.0" 575 | }, 576 | "require-dev": { 577 | "mockery/mockery": "^0.9.4", 578 | "phpunit/phpunit": "^5.2||^4.8.24" 579 | }, 580 | "type": "library", 581 | "extra": { 582 | "branch-alias": { 583 | "dev-master": "1.0.x-dev" 584 | } 585 | }, 586 | "autoload": { 587 | "psr-4": { 588 | "phpDocumentor\\Reflection\\": [ 589 | "src/" 590 | ] 591 | } 592 | }, 593 | "notification-url": "https://packagist.org/downloads/", 594 | "license": [ 595 | "MIT" 596 | ], 597 | "authors": [ 598 | { 599 | "name": "Mike van Riel", 600 | "email": "me@mikevanriel.com" 601 | } 602 | ], 603 | "time": "2017-07-14T14:27:02+00:00" 604 | }, 605 | { 606 | "name": "phpspec/prophecy", 607 | "version": "1.7.5", 608 | "source": { 609 | "type": "git", 610 | "url": "https://github.com/phpspec/prophecy.git", 611 | "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" 612 | }, 613 | "dist": { 614 | "type": "zip", 615 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", 616 | "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", 617 | "shasum": "" 618 | }, 619 | "require": { 620 | "doctrine/instantiator": "^1.0.2", 621 | "php": "^5.3|^7.0", 622 | "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", 623 | "sebastian/comparator": "^1.1|^2.0", 624 | "sebastian/recursion-context": "^1.0|^2.0|^3.0" 625 | }, 626 | "require-dev": { 627 | "phpspec/phpspec": "^2.5|^3.2", 628 | "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" 629 | }, 630 | "type": "library", 631 | "extra": { 632 | "branch-alias": { 633 | "dev-master": "1.7.x-dev" 634 | } 635 | }, 636 | "autoload": { 637 | "psr-0": { 638 | "Prophecy\\": "src/" 639 | } 640 | }, 641 | "notification-url": "https://packagist.org/downloads/", 642 | "license": [ 643 | "MIT" 644 | ], 645 | "authors": [ 646 | { 647 | "name": "Konstantin Kudryashov", 648 | "email": "ever.zet@gmail.com", 649 | "homepage": "http://everzet.com" 650 | }, 651 | { 652 | "name": "Marcello Duarte", 653 | "email": "marcello.duarte@gmail.com" 654 | } 655 | ], 656 | "description": "Highly opinionated mocking framework for PHP 5.3+", 657 | "homepage": "https://github.com/phpspec/prophecy", 658 | "keywords": [ 659 | "Double", 660 | "Dummy", 661 | "fake", 662 | "mock", 663 | "spy", 664 | "stub" 665 | ], 666 | "time": "2018-02-19T10:16:54+00:00" 667 | }, 668 | { 669 | "name": "phpunit/php-code-coverage", 670 | "version": "5.3.0", 671 | "source": { 672 | "type": "git", 673 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 674 | "reference": "661f34d0bd3f1a7225ef491a70a020ad23a057a1" 675 | }, 676 | "dist": { 677 | "type": "zip", 678 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/661f34d0bd3f1a7225ef491a70a020ad23a057a1", 679 | "reference": "661f34d0bd3f1a7225ef491a70a020ad23a057a1", 680 | "shasum": "" 681 | }, 682 | "require": { 683 | "ext-dom": "*", 684 | "ext-xmlwriter": "*", 685 | "php": "^7.0", 686 | "phpunit/php-file-iterator": "^1.4.2", 687 | "phpunit/php-text-template": "^1.2.1", 688 | "phpunit/php-token-stream": "^2.0.1", 689 | "sebastian/code-unit-reverse-lookup": "^1.0.1", 690 | "sebastian/environment": "^3.0", 691 | "sebastian/version": "^2.0.1", 692 | "theseer/tokenizer": "^1.1" 693 | }, 694 | "require-dev": { 695 | "phpunit/phpunit": "^6.0" 696 | }, 697 | "suggest": { 698 | "ext-xdebug": "^2.5.5" 699 | }, 700 | "type": "library", 701 | "extra": { 702 | "branch-alias": { 703 | "dev-master": "5.3.x-dev" 704 | } 705 | }, 706 | "autoload": { 707 | "classmap": [ 708 | "src/" 709 | ] 710 | }, 711 | "notification-url": "https://packagist.org/downloads/", 712 | "license": [ 713 | "BSD-3-Clause" 714 | ], 715 | "authors": [ 716 | { 717 | "name": "Sebastian Bergmann", 718 | "email": "sebastian@phpunit.de", 719 | "role": "lead" 720 | } 721 | ], 722 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 723 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 724 | "keywords": [ 725 | "coverage", 726 | "testing", 727 | "xunit" 728 | ], 729 | "time": "2017-12-06T09:29:45+00:00" 730 | }, 731 | { 732 | "name": "phpunit/php-file-iterator", 733 | "version": "1.4.5", 734 | "source": { 735 | "type": "git", 736 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 737 | "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" 738 | }, 739 | "dist": { 740 | "type": "zip", 741 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", 742 | "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", 743 | "shasum": "" 744 | }, 745 | "require": { 746 | "php": ">=5.3.3" 747 | }, 748 | "type": "library", 749 | "extra": { 750 | "branch-alias": { 751 | "dev-master": "1.4.x-dev" 752 | } 753 | }, 754 | "autoload": { 755 | "classmap": [ 756 | "src/" 757 | ] 758 | }, 759 | "notification-url": "https://packagist.org/downloads/", 760 | "license": [ 761 | "BSD-3-Clause" 762 | ], 763 | "authors": [ 764 | { 765 | "name": "Sebastian Bergmann", 766 | "email": "sb@sebastian-bergmann.de", 767 | "role": "lead" 768 | } 769 | ], 770 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 771 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 772 | "keywords": [ 773 | "filesystem", 774 | "iterator" 775 | ], 776 | "time": "2017-11-27T13:52:08+00:00" 777 | }, 778 | { 779 | "name": "phpunit/php-text-template", 780 | "version": "1.2.1", 781 | "source": { 782 | "type": "git", 783 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 784 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" 785 | }, 786 | "dist": { 787 | "type": "zip", 788 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 789 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 790 | "shasum": "" 791 | }, 792 | "require": { 793 | "php": ">=5.3.3" 794 | }, 795 | "type": "library", 796 | "autoload": { 797 | "classmap": [ 798 | "src/" 799 | ] 800 | }, 801 | "notification-url": "https://packagist.org/downloads/", 802 | "license": [ 803 | "BSD-3-Clause" 804 | ], 805 | "authors": [ 806 | { 807 | "name": "Sebastian Bergmann", 808 | "email": "sebastian@phpunit.de", 809 | "role": "lead" 810 | } 811 | ], 812 | "description": "Simple template engine.", 813 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 814 | "keywords": [ 815 | "template" 816 | ], 817 | "time": "2015-06-21T13:50:34+00:00" 818 | }, 819 | { 820 | "name": "phpunit/php-timer", 821 | "version": "1.0.9", 822 | "source": { 823 | "type": "git", 824 | "url": "https://github.com/sebastianbergmann/php-timer.git", 825 | "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" 826 | }, 827 | "dist": { 828 | "type": "zip", 829 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", 830 | "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", 831 | "shasum": "" 832 | }, 833 | "require": { 834 | "php": "^5.3.3 || ^7.0" 835 | }, 836 | "require-dev": { 837 | "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" 838 | }, 839 | "type": "library", 840 | "extra": { 841 | "branch-alias": { 842 | "dev-master": "1.0-dev" 843 | } 844 | }, 845 | "autoload": { 846 | "classmap": [ 847 | "src/" 848 | ] 849 | }, 850 | "notification-url": "https://packagist.org/downloads/", 851 | "license": [ 852 | "BSD-3-Clause" 853 | ], 854 | "authors": [ 855 | { 856 | "name": "Sebastian Bergmann", 857 | "email": "sb@sebastian-bergmann.de", 858 | "role": "lead" 859 | } 860 | ], 861 | "description": "Utility class for timing", 862 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 863 | "keywords": [ 864 | "timer" 865 | ], 866 | "time": "2017-02-26T11:10:40+00:00" 867 | }, 868 | { 869 | "name": "phpunit/php-token-stream", 870 | "version": "2.0.2", 871 | "source": { 872 | "type": "git", 873 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 874 | "reference": "791198a2c6254db10131eecfe8c06670700904db" 875 | }, 876 | "dist": { 877 | "type": "zip", 878 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", 879 | "reference": "791198a2c6254db10131eecfe8c06670700904db", 880 | "shasum": "" 881 | }, 882 | "require": { 883 | "ext-tokenizer": "*", 884 | "php": "^7.0" 885 | }, 886 | "require-dev": { 887 | "phpunit/phpunit": "^6.2.4" 888 | }, 889 | "type": "library", 890 | "extra": { 891 | "branch-alias": { 892 | "dev-master": "2.0-dev" 893 | } 894 | }, 895 | "autoload": { 896 | "classmap": [ 897 | "src/" 898 | ] 899 | }, 900 | "notification-url": "https://packagist.org/downloads/", 901 | "license": [ 902 | "BSD-3-Clause" 903 | ], 904 | "authors": [ 905 | { 906 | "name": "Sebastian Bergmann", 907 | "email": "sebastian@phpunit.de" 908 | } 909 | ], 910 | "description": "Wrapper around PHP's tokenizer extension.", 911 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 912 | "keywords": [ 913 | "tokenizer" 914 | ], 915 | "time": "2017-11-27T05:48:46+00:00" 916 | }, 917 | { 918 | "name": "phpunit/phpunit", 919 | "version": "6.5.7", 920 | "source": { 921 | "type": "git", 922 | "url": "https://github.com/sebastianbergmann/phpunit.git", 923 | "reference": "6bd77b57707c236833d2b57b968e403df060c9d9" 924 | }, 925 | "dist": { 926 | "type": "zip", 927 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6bd77b57707c236833d2b57b968e403df060c9d9", 928 | "reference": "6bd77b57707c236833d2b57b968e403df060c9d9", 929 | "shasum": "" 930 | }, 931 | "require": { 932 | "ext-dom": "*", 933 | "ext-json": "*", 934 | "ext-libxml": "*", 935 | "ext-mbstring": "*", 936 | "ext-xml": "*", 937 | "myclabs/deep-copy": "^1.6.1", 938 | "phar-io/manifest": "^1.0.1", 939 | "phar-io/version": "^1.0", 940 | "php": "^7.0", 941 | "phpspec/prophecy": "^1.7", 942 | "phpunit/php-code-coverage": "^5.3", 943 | "phpunit/php-file-iterator": "^1.4.3", 944 | "phpunit/php-text-template": "^1.2.1", 945 | "phpunit/php-timer": "^1.0.9", 946 | "phpunit/phpunit-mock-objects": "^5.0.5", 947 | "sebastian/comparator": "^2.1", 948 | "sebastian/diff": "^2.0", 949 | "sebastian/environment": "^3.1", 950 | "sebastian/exporter": "^3.1", 951 | "sebastian/global-state": "^2.0", 952 | "sebastian/object-enumerator": "^3.0.3", 953 | "sebastian/resource-operations": "^1.0", 954 | "sebastian/version": "^2.0.1" 955 | }, 956 | "conflict": { 957 | "phpdocumentor/reflection-docblock": "3.0.2", 958 | "phpunit/dbunit": "<3.0" 959 | }, 960 | "require-dev": { 961 | "ext-pdo": "*" 962 | }, 963 | "suggest": { 964 | "ext-xdebug": "*", 965 | "phpunit/php-invoker": "^1.1" 966 | }, 967 | "bin": [ 968 | "phpunit" 969 | ], 970 | "type": "library", 971 | "extra": { 972 | "branch-alias": { 973 | "dev-master": "6.5.x-dev" 974 | } 975 | }, 976 | "autoload": { 977 | "classmap": [ 978 | "src/" 979 | ] 980 | }, 981 | "notification-url": "https://packagist.org/downloads/", 982 | "license": [ 983 | "BSD-3-Clause" 984 | ], 985 | "authors": [ 986 | { 987 | "name": "Sebastian Bergmann", 988 | "email": "sebastian@phpunit.de", 989 | "role": "lead" 990 | } 991 | ], 992 | "description": "The PHP Unit Testing framework.", 993 | "homepage": "https://phpunit.de/", 994 | "keywords": [ 995 | "phpunit", 996 | "testing", 997 | "xunit" 998 | ], 999 | "time": "2018-02-26T07:01:09+00:00" 1000 | }, 1001 | { 1002 | "name": "phpunit/phpunit-mock-objects", 1003 | "version": "5.0.6", 1004 | "source": { 1005 | "type": "git", 1006 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 1007 | "reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf" 1008 | }, 1009 | "dist": { 1010 | "type": "zip", 1011 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/33fd41a76e746b8fa96d00b49a23dadfa8334cdf", 1012 | "reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf", 1013 | "shasum": "" 1014 | }, 1015 | "require": { 1016 | "doctrine/instantiator": "^1.0.5", 1017 | "php": "^7.0", 1018 | "phpunit/php-text-template": "^1.2.1", 1019 | "sebastian/exporter": "^3.1" 1020 | }, 1021 | "conflict": { 1022 | "phpunit/phpunit": "<6.0" 1023 | }, 1024 | "require-dev": { 1025 | "phpunit/phpunit": "^6.5" 1026 | }, 1027 | "suggest": { 1028 | "ext-soap": "*" 1029 | }, 1030 | "type": "library", 1031 | "extra": { 1032 | "branch-alias": { 1033 | "dev-master": "5.0.x-dev" 1034 | } 1035 | }, 1036 | "autoload": { 1037 | "classmap": [ 1038 | "src/" 1039 | ] 1040 | }, 1041 | "notification-url": "https://packagist.org/downloads/", 1042 | "license": [ 1043 | "BSD-3-Clause" 1044 | ], 1045 | "authors": [ 1046 | { 1047 | "name": "Sebastian Bergmann", 1048 | "email": "sebastian@phpunit.de", 1049 | "role": "lead" 1050 | } 1051 | ], 1052 | "description": "Mock Object library for PHPUnit", 1053 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 1054 | "keywords": [ 1055 | "mock", 1056 | "xunit" 1057 | ], 1058 | "time": "2018-01-06T05:45:45+00:00" 1059 | }, 1060 | { 1061 | "name": "sebastian/code-unit-reverse-lookup", 1062 | "version": "1.0.1", 1063 | "source": { 1064 | "type": "git", 1065 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 1066 | "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" 1067 | }, 1068 | "dist": { 1069 | "type": "zip", 1070 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", 1071 | "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", 1072 | "shasum": "" 1073 | }, 1074 | "require": { 1075 | "php": "^5.6 || ^7.0" 1076 | }, 1077 | "require-dev": { 1078 | "phpunit/phpunit": "^5.7 || ^6.0" 1079 | }, 1080 | "type": "library", 1081 | "extra": { 1082 | "branch-alias": { 1083 | "dev-master": "1.0.x-dev" 1084 | } 1085 | }, 1086 | "autoload": { 1087 | "classmap": [ 1088 | "src/" 1089 | ] 1090 | }, 1091 | "notification-url": "https://packagist.org/downloads/", 1092 | "license": [ 1093 | "BSD-3-Clause" 1094 | ], 1095 | "authors": [ 1096 | { 1097 | "name": "Sebastian Bergmann", 1098 | "email": "sebastian@phpunit.de" 1099 | } 1100 | ], 1101 | "description": "Looks up which function or method a line of code belongs to", 1102 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 1103 | "time": "2017-03-04T06:30:41+00:00" 1104 | }, 1105 | { 1106 | "name": "sebastian/comparator", 1107 | "version": "2.1.3", 1108 | "source": { 1109 | "type": "git", 1110 | "url": "https://github.com/sebastianbergmann/comparator.git", 1111 | "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" 1112 | }, 1113 | "dist": { 1114 | "type": "zip", 1115 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", 1116 | "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", 1117 | "shasum": "" 1118 | }, 1119 | "require": { 1120 | "php": "^7.0", 1121 | "sebastian/diff": "^2.0 || ^3.0", 1122 | "sebastian/exporter": "^3.1" 1123 | }, 1124 | "require-dev": { 1125 | "phpunit/phpunit": "^6.4" 1126 | }, 1127 | "type": "library", 1128 | "extra": { 1129 | "branch-alias": { 1130 | "dev-master": "2.1.x-dev" 1131 | } 1132 | }, 1133 | "autoload": { 1134 | "classmap": [ 1135 | "src/" 1136 | ] 1137 | }, 1138 | "notification-url": "https://packagist.org/downloads/", 1139 | "license": [ 1140 | "BSD-3-Clause" 1141 | ], 1142 | "authors": [ 1143 | { 1144 | "name": "Jeff Welch", 1145 | "email": "whatthejeff@gmail.com" 1146 | }, 1147 | { 1148 | "name": "Volker Dusch", 1149 | "email": "github@wallbash.com" 1150 | }, 1151 | { 1152 | "name": "Bernhard Schussek", 1153 | "email": "bschussek@2bepublished.at" 1154 | }, 1155 | { 1156 | "name": "Sebastian Bergmann", 1157 | "email": "sebastian@phpunit.de" 1158 | } 1159 | ], 1160 | "description": "Provides the functionality to compare PHP values for equality", 1161 | "homepage": "https://github.com/sebastianbergmann/comparator", 1162 | "keywords": [ 1163 | "comparator", 1164 | "compare", 1165 | "equality" 1166 | ], 1167 | "time": "2018-02-01T13:46:46+00:00" 1168 | }, 1169 | { 1170 | "name": "sebastian/diff", 1171 | "version": "2.0.1", 1172 | "source": { 1173 | "type": "git", 1174 | "url": "https://github.com/sebastianbergmann/diff.git", 1175 | "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" 1176 | }, 1177 | "dist": { 1178 | "type": "zip", 1179 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", 1180 | "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", 1181 | "shasum": "" 1182 | }, 1183 | "require": { 1184 | "php": "^7.0" 1185 | }, 1186 | "require-dev": { 1187 | "phpunit/phpunit": "^6.2" 1188 | }, 1189 | "type": "library", 1190 | "extra": { 1191 | "branch-alias": { 1192 | "dev-master": "2.0-dev" 1193 | } 1194 | }, 1195 | "autoload": { 1196 | "classmap": [ 1197 | "src/" 1198 | ] 1199 | }, 1200 | "notification-url": "https://packagist.org/downloads/", 1201 | "license": [ 1202 | "BSD-3-Clause" 1203 | ], 1204 | "authors": [ 1205 | { 1206 | "name": "Kore Nordmann", 1207 | "email": "mail@kore-nordmann.de" 1208 | }, 1209 | { 1210 | "name": "Sebastian Bergmann", 1211 | "email": "sebastian@phpunit.de" 1212 | } 1213 | ], 1214 | "description": "Diff implementation", 1215 | "homepage": "https://github.com/sebastianbergmann/diff", 1216 | "keywords": [ 1217 | "diff" 1218 | ], 1219 | "time": "2017-08-03T08:09:46+00:00" 1220 | }, 1221 | { 1222 | "name": "sebastian/environment", 1223 | "version": "3.1.0", 1224 | "source": { 1225 | "type": "git", 1226 | "url": "https://github.com/sebastianbergmann/environment.git", 1227 | "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" 1228 | }, 1229 | "dist": { 1230 | "type": "zip", 1231 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", 1232 | "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", 1233 | "shasum": "" 1234 | }, 1235 | "require": { 1236 | "php": "^7.0" 1237 | }, 1238 | "require-dev": { 1239 | "phpunit/phpunit": "^6.1" 1240 | }, 1241 | "type": "library", 1242 | "extra": { 1243 | "branch-alias": { 1244 | "dev-master": "3.1.x-dev" 1245 | } 1246 | }, 1247 | "autoload": { 1248 | "classmap": [ 1249 | "src/" 1250 | ] 1251 | }, 1252 | "notification-url": "https://packagist.org/downloads/", 1253 | "license": [ 1254 | "BSD-3-Clause" 1255 | ], 1256 | "authors": [ 1257 | { 1258 | "name": "Sebastian Bergmann", 1259 | "email": "sebastian@phpunit.de" 1260 | } 1261 | ], 1262 | "description": "Provides functionality to handle HHVM/PHP environments", 1263 | "homepage": "http://www.github.com/sebastianbergmann/environment", 1264 | "keywords": [ 1265 | "Xdebug", 1266 | "environment", 1267 | "hhvm" 1268 | ], 1269 | "time": "2017-07-01T08:51:00+00:00" 1270 | }, 1271 | { 1272 | "name": "sebastian/exporter", 1273 | "version": "3.1.0", 1274 | "source": { 1275 | "type": "git", 1276 | "url": "https://github.com/sebastianbergmann/exporter.git", 1277 | "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" 1278 | }, 1279 | "dist": { 1280 | "type": "zip", 1281 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", 1282 | "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", 1283 | "shasum": "" 1284 | }, 1285 | "require": { 1286 | "php": "^7.0", 1287 | "sebastian/recursion-context": "^3.0" 1288 | }, 1289 | "require-dev": { 1290 | "ext-mbstring": "*", 1291 | "phpunit/phpunit": "^6.0" 1292 | }, 1293 | "type": "library", 1294 | "extra": { 1295 | "branch-alias": { 1296 | "dev-master": "3.1.x-dev" 1297 | } 1298 | }, 1299 | "autoload": { 1300 | "classmap": [ 1301 | "src/" 1302 | ] 1303 | }, 1304 | "notification-url": "https://packagist.org/downloads/", 1305 | "license": [ 1306 | "BSD-3-Clause" 1307 | ], 1308 | "authors": [ 1309 | { 1310 | "name": "Jeff Welch", 1311 | "email": "whatthejeff@gmail.com" 1312 | }, 1313 | { 1314 | "name": "Volker Dusch", 1315 | "email": "github@wallbash.com" 1316 | }, 1317 | { 1318 | "name": "Bernhard Schussek", 1319 | "email": "bschussek@2bepublished.at" 1320 | }, 1321 | { 1322 | "name": "Sebastian Bergmann", 1323 | "email": "sebastian@phpunit.de" 1324 | }, 1325 | { 1326 | "name": "Adam Harvey", 1327 | "email": "aharvey@php.net" 1328 | } 1329 | ], 1330 | "description": "Provides the functionality to export PHP variables for visualization", 1331 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1332 | "keywords": [ 1333 | "export", 1334 | "exporter" 1335 | ], 1336 | "time": "2017-04-03T13:19:02+00:00" 1337 | }, 1338 | { 1339 | "name": "sebastian/global-state", 1340 | "version": "2.0.0", 1341 | "source": { 1342 | "type": "git", 1343 | "url": "https://github.com/sebastianbergmann/global-state.git", 1344 | "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" 1345 | }, 1346 | "dist": { 1347 | "type": "zip", 1348 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", 1349 | "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", 1350 | "shasum": "" 1351 | }, 1352 | "require": { 1353 | "php": "^7.0" 1354 | }, 1355 | "require-dev": { 1356 | "phpunit/phpunit": "^6.0" 1357 | }, 1358 | "suggest": { 1359 | "ext-uopz": "*" 1360 | }, 1361 | "type": "library", 1362 | "extra": { 1363 | "branch-alias": { 1364 | "dev-master": "2.0-dev" 1365 | } 1366 | }, 1367 | "autoload": { 1368 | "classmap": [ 1369 | "src/" 1370 | ] 1371 | }, 1372 | "notification-url": "https://packagist.org/downloads/", 1373 | "license": [ 1374 | "BSD-3-Clause" 1375 | ], 1376 | "authors": [ 1377 | { 1378 | "name": "Sebastian Bergmann", 1379 | "email": "sebastian@phpunit.de" 1380 | } 1381 | ], 1382 | "description": "Snapshotting of global state", 1383 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1384 | "keywords": [ 1385 | "global state" 1386 | ], 1387 | "time": "2017-04-27T15:39:26+00:00" 1388 | }, 1389 | { 1390 | "name": "sebastian/object-enumerator", 1391 | "version": "3.0.3", 1392 | "source": { 1393 | "type": "git", 1394 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1395 | "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" 1396 | }, 1397 | "dist": { 1398 | "type": "zip", 1399 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", 1400 | "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", 1401 | "shasum": "" 1402 | }, 1403 | "require": { 1404 | "php": "^7.0", 1405 | "sebastian/object-reflector": "^1.1.1", 1406 | "sebastian/recursion-context": "^3.0" 1407 | }, 1408 | "require-dev": { 1409 | "phpunit/phpunit": "^6.0" 1410 | }, 1411 | "type": "library", 1412 | "extra": { 1413 | "branch-alias": { 1414 | "dev-master": "3.0.x-dev" 1415 | } 1416 | }, 1417 | "autoload": { 1418 | "classmap": [ 1419 | "src/" 1420 | ] 1421 | }, 1422 | "notification-url": "https://packagist.org/downloads/", 1423 | "license": [ 1424 | "BSD-3-Clause" 1425 | ], 1426 | "authors": [ 1427 | { 1428 | "name": "Sebastian Bergmann", 1429 | "email": "sebastian@phpunit.de" 1430 | } 1431 | ], 1432 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1433 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1434 | "time": "2017-08-03T12:35:26+00:00" 1435 | }, 1436 | { 1437 | "name": "sebastian/object-reflector", 1438 | "version": "1.1.1", 1439 | "source": { 1440 | "type": "git", 1441 | "url": "https://github.com/sebastianbergmann/object-reflector.git", 1442 | "reference": "773f97c67f28de00d397be301821b06708fca0be" 1443 | }, 1444 | "dist": { 1445 | "type": "zip", 1446 | "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", 1447 | "reference": "773f97c67f28de00d397be301821b06708fca0be", 1448 | "shasum": "" 1449 | }, 1450 | "require": { 1451 | "php": "^7.0" 1452 | }, 1453 | "require-dev": { 1454 | "phpunit/phpunit": "^6.0" 1455 | }, 1456 | "type": "library", 1457 | "extra": { 1458 | "branch-alias": { 1459 | "dev-master": "1.1-dev" 1460 | } 1461 | }, 1462 | "autoload": { 1463 | "classmap": [ 1464 | "src/" 1465 | ] 1466 | }, 1467 | "notification-url": "https://packagist.org/downloads/", 1468 | "license": [ 1469 | "BSD-3-Clause" 1470 | ], 1471 | "authors": [ 1472 | { 1473 | "name": "Sebastian Bergmann", 1474 | "email": "sebastian@phpunit.de" 1475 | } 1476 | ], 1477 | "description": "Allows reflection of object attributes, including inherited and non-public ones", 1478 | "homepage": "https://github.com/sebastianbergmann/object-reflector/", 1479 | "time": "2017-03-29T09:07:27+00:00" 1480 | }, 1481 | { 1482 | "name": "sebastian/recursion-context", 1483 | "version": "3.0.0", 1484 | "source": { 1485 | "type": "git", 1486 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1487 | "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" 1488 | }, 1489 | "dist": { 1490 | "type": "zip", 1491 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", 1492 | "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", 1493 | "shasum": "" 1494 | }, 1495 | "require": { 1496 | "php": "^7.0" 1497 | }, 1498 | "require-dev": { 1499 | "phpunit/phpunit": "^6.0" 1500 | }, 1501 | "type": "library", 1502 | "extra": { 1503 | "branch-alias": { 1504 | "dev-master": "3.0.x-dev" 1505 | } 1506 | }, 1507 | "autoload": { 1508 | "classmap": [ 1509 | "src/" 1510 | ] 1511 | }, 1512 | "notification-url": "https://packagist.org/downloads/", 1513 | "license": [ 1514 | "BSD-3-Clause" 1515 | ], 1516 | "authors": [ 1517 | { 1518 | "name": "Jeff Welch", 1519 | "email": "whatthejeff@gmail.com" 1520 | }, 1521 | { 1522 | "name": "Sebastian Bergmann", 1523 | "email": "sebastian@phpunit.de" 1524 | }, 1525 | { 1526 | "name": "Adam Harvey", 1527 | "email": "aharvey@php.net" 1528 | } 1529 | ], 1530 | "description": "Provides functionality to recursively process PHP variables", 1531 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1532 | "time": "2017-03-03T06:23:57+00:00" 1533 | }, 1534 | { 1535 | "name": "sebastian/resource-operations", 1536 | "version": "1.0.0", 1537 | "source": { 1538 | "type": "git", 1539 | "url": "https://github.com/sebastianbergmann/resource-operations.git", 1540 | "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" 1541 | }, 1542 | "dist": { 1543 | "type": "zip", 1544 | "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", 1545 | "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", 1546 | "shasum": "" 1547 | }, 1548 | "require": { 1549 | "php": ">=5.6.0" 1550 | }, 1551 | "type": "library", 1552 | "extra": { 1553 | "branch-alias": { 1554 | "dev-master": "1.0.x-dev" 1555 | } 1556 | }, 1557 | "autoload": { 1558 | "classmap": [ 1559 | "src/" 1560 | ] 1561 | }, 1562 | "notification-url": "https://packagist.org/downloads/", 1563 | "license": [ 1564 | "BSD-3-Clause" 1565 | ], 1566 | "authors": [ 1567 | { 1568 | "name": "Sebastian Bergmann", 1569 | "email": "sebastian@phpunit.de" 1570 | } 1571 | ], 1572 | "description": "Provides a list of PHP built-in functions that operate on resources", 1573 | "homepage": "https://www.github.com/sebastianbergmann/resource-operations", 1574 | "time": "2015-07-28T20:34:47+00:00" 1575 | }, 1576 | { 1577 | "name": "sebastian/version", 1578 | "version": "2.0.1", 1579 | "source": { 1580 | "type": "git", 1581 | "url": "https://github.com/sebastianbergmann/version.git", 1582 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" 1583 | }, 1584 | "dist": { 1585 | "type": "zip", 1586 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", 1587 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", 1588 | "shasum": "" 1589 | }, 1590 | "require": { 1591 | "php": ">=5.6" 1592 | }, 1593 | "type": "library", 1594 | "extra": { 1595 | "branch-alias": { 1596 | "dev-master": "2.0.x-dev" 1597 | } 1598 | }, 1599 | "autoload": { 1600 | "classmap": [ 1601 | "src/" 1602 | ] 1603 | }, 1604 | "notification-url": "https://packagist.org/downloads/", 1605 | "license": [ 1606 | "BSD-3-Clause" 1607 | ], 1608 | "authors": [ 1609 | { 1610 | "name": "Sebastian Bergmann", 1611 | "email": "sebastian@phpunit.de", 1612 | "role": "lead" 1613 | } 1614 | ], 1615 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1616 | "homepage": "https://github.com/sebastianbergmann/version", 1617 | "time": "2016-10-03T07:35:21+00:00" 1618 | }, 1619 | { 1620 | "name": "squizlabs/php_codesniffer", 1621 | "version": "3.2.3", 1622 | "source": { 1623 | "type": "git", 1624 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", 1625 | "reference": "4842476c434e375f9d3182ff7b89059583aa8b27" 1626 | }, 1627 | "dist": { 1628 | "type": "zip", 1629 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27", 1630 | "reference": "4842476c434e375f9d3182ff7b89059583aa8b27", 1631 | "shasum": "" 1632 | }, 1633 | "require": { 1634 | "ext-simplexml": "*", 1635 | "ext-tokenizer": "*", 1636 | "ext-xmlwriter": "*", 1637 | "php": ">=5.4.0" 1638 | }, 1639 | "require-dev": { 1640 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" 1641 | }, 1642 | "bin": [ 1643 | "bin/phpcs", 1644 | "bin/phpcbf" 1645 | ], 1646 | "type": "library", 1647 | "extra": { 1648 | "branch-alias": { 1649 | "dev-master": "3.x-dev" 1650 | } 1651 | }, 1652 | "notification-url": "https://packagist.org/downloads/", 1653 | "license": [ 1654 | "BSD-3-Clause" 1655 | ], 1656 | "authors": [ 1657 | { 1658 | "name": "Greg Sherwood", 1659 | "role": "lead" 1660 | } 1661 | ], 1662 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 1663 | "homepage": "http://www.squizlabs.com/php-codesniffer", 1664 | "keywords": [ 1665 | "phpcs", 1666 | "standards" 1667 | ], 1668 | "time": "2018-02-20T21:35:23+00:00" 1669 | }, 1670 | { 1671 | "name": "theseer/tokenizer", 1672 | "version": "1.1.0", 1673 | "source": { 1674 | "type": "git", 1675 | "url": "https://github.com/theseer/tokenizer.git", 1676 | "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" 1677 | }, 1678 | "dist": { 1679 | "type": "zip", 1680 | "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", 1681 | "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", 1682 | "shasum": "" 1683 | }, 1684 | "require": { 1685 | "ext-dom": "*", 1686 | "ext-tokenizer": "*", 1687 | "ext-xmlwriter": "*", 1688 | "php": "^7.0" 1689 | }, 1690 | "type": "library", 1691 | "autoload": { 1692 | "classmap": [ 1693 | "src/" 1694 | ] 1695 | }, 1696 | "notification-url": "https://packagist.org/downloads/", 1697 | "license": [ 1698 | "BSD-3-Clause" 1699 | ], 1700 | "authors": [ 1701 | { 1702 | "name": "Arne Blankerts", 1703 | "email": "arne@blankerts.de", 1704 | "role": "Developer" 1705 | } 1706 | ], 1707 | "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", 1708 | "time": "2017-04-07T12:08:54+00:00" 1709 | }, 1710 | { 1711 | "name": "webmozart/assert", 1712 | "version": "1.3.0", 1713 | "source": { 1714 | "type": "git", 1715 | "url": "https://github.com/webmozart/assert.git", 1716 | "reference": "0df1908962e7a3071564e857d86874dad1ef204a" 1717 | }, 1718 | "dist": { 1719 | "type": "zip", 1720 | "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", 1721 | "reference": "0df1908962e7a3071564e857d86874dad1ef204a", 1722 | "shasum": "" 1723 | }, 1724 | "require": { 1725 | "php": "^5.3.3 || ^7.0" 1726 | }, 1727 | "require-dev": { 1728 | "phpunit/phpunit": "^4.6", 1729 | "sebastian/version": "^1.0.1" 1730 | }, 1731 | "type": "library", 1732 | "extra": { 1733 | "branch-alias": { 1734 | "dev-master": "1.3-dev" 1735 | } 1736 | }, 1737 | "autoload": { 1738 | "psr-4": { 1739 | "Webmozart\\Assert\\": "src/" 1740 | } 1741 | }, 1742 | "notification-url": "https://packagist.org/downloads/", 1743 | "license": [ 1744 | "MIT" 1745 | ], 1746 | "authors": [ 1747 | { 1748 | "name": "Bernhard Schussek", 1749 | "email": "bschussek@gmail.com" 1750 | } 1751 | ], 1752 | "description": "Assertions to validate method input/output with nice error messages.", 1753 | "keywords": [ 1754 | "assert", 1755 | "check", 1756 | "validate" 1757 | ], 1758 | "time": "2018-01-29T19:49:41+00:00" 1759 | }, 1760 | { 1761 | "name": "wp-coding-standards/wpcs", 1762 | "version": "0.14.0", 1763 | "source": { 1764 | "type": "git", 1765 | "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", 1766 | "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c" 1767 | }, 1768 | "dist": { 1769 | "type": "zip", 1770 | "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8cadf48fa1c70b2381988e0a79e029e011a8f41c", 1771 | "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c", 1772 | "shasum": "" 1773 | }, 1774 | "require": { 1775 | "php": ">=5.3", 1776 | "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2" 1777 | }, 1778 | "suggest": { 1779 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" 1780 | }, 1781 | "type": "phpcodesniffer-standard", 1782 | "notification-url": "https://packagist.org/downloads/", 1783 | "license": [ 1784 | "MIT" 1785 | ], 1786 | "authors": [ 1787 | { 1788 | "name": "Contributors", 1789 | "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors" 1790 | } 1791 | ], 1792 | "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", 1793 | "keywords": [ 1794 | "phpcs", 1795 | "standards", 1796 | "wordpress" 1797 | ], 1798 | "time": "2017-11-01T15:10:46+00:00" 1799 | } 1800 | ], 1801 | "aliases": [], 1802 | "minimum-stability": "stable", 1803 | "stability-flags": [], 1804 | "prefer-stable": false, 1805 | "prefer-lowest": false, 1806 | "platform": [], 1807 | "platform-dev": [] 1808 | } 1809 | -------------------------------------------------------------------------------- /gulpfile.babel.js: -------------------------------------------------------------------------------- 1 | // Project configuration 2 | const project = 'json-wp-post-parser'; 3 | 4 | const gulp = require('gulp'); 5 | const gprint = require('gulp-print').default; 6 | const del = require('del'); 7 | const vinylPaths = require('vinyl-paths'); 8 | const runSequence = require('run-sequence'); 9 | const webpack = require('webpack'); 10 | const webpackConfig = require('./webpack.config.js'); 11 | 12 | const paths = { 13 | src: './src/json-wp-post-parser/', 14 | build: './build/', 15 | entry: './src/json-wp-post-parser/skin/assets/application.js' 16 | }; 17 | 18 | gulp.task('clean', () => ( 19 | gulp.src(`${paths.build}*`) 20 | .pipe(gprint()) 21 | .pipe(vinylPaths(del)) 22 | )); 23 | 24 | gulp.task('webpack', () => ( 25 | new Promise((resolve, reject) => { 26 | webpack(webpackConfig, (err, stats) => { 27 | if (err) { 28 | reject(err); 29 | return; 30 | } 31 | resolve(stats); 32 | }); 33 | }) 34 | )); 35 | 36 | gulp.task('buildFiles', () => ( 37 | gulp.src(`${paths.src}**/*`) 38 | .pipe(gulp.dest(`${paths.build}/${project}/`)) 39 | )); 40 | 41 | gulp.task('cleanSkin', () => ( 42 | gulp.src(`${paths.build}/${project}/skin`) 43 | .pipe(vinylPaths(del)) 44 | )); 45 | 46 | gulp.task('copyAssets', () => ( 47 | gulp.src(`${paths.build}/assets/**/*`) 48 | .pipe(gulp.dest(`${paths.build}/${project}/assets/`)) 49 | )); 50 | 51 | gulp.task('removeAssets', () => ( 52 | gulp.src(`${paths.build}/assets/`) 53 | .pipe(vinylPaths(del)) 54 | )); 55 | 56 | 57 | 58 | gulp.task('build', (cb) => runSequence('clean', 'webpack', 'buildFiles', 'cleanSkin', 'copyAssets', 'removeAssets', cb)); 59 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-wp-post-parser", 3 | "description": "JSON Post Parser plugin parses your content and saves it as JSON available in REST posts and pages endpoints.", 4 | "version": "1.0.7", 5 | "author": "Infinum", 6 | "private": true, 7 | "main": "", 8 | "scripts": { 9 | "precommit": "eslint src/** && phpcs --standard=Infinum src/", 10 | "webpack": "webpack --progress", 11 | "build": "gulp build" 12 | }, 13 | "devDependencies": { 14 | "@infinumjs/eslint-config": "^1.1.0", 15 | "@infinumjs/stylelint-config": "^1.0.0", 16 | "babel-core": "^6.26.0", 17 | "babel-eslint": "^8.2.2", 18 | "babel-loader": "^7.1.4", 19 | "babel-preset-env": "^1.6.1", 20 | "css-loader": "^2.1.1", 21 | "del": "^3.0.0", 22 | "eslint": "^4.19.0", 23 | "eslint-plugin-import": "^2.9.0", 24 | "extract-text-webpack-plugin": "^3.0.2", 25 | "gulp-print": "^5.0.0", 26 | "node-sass": "^4.7.2", 27 | "run-sequence": "^2.2.1", 28 | "sass-loader": "^6.0.7", 29 | "style-loader": "^0.20.3", 30 | "stylelint": "^9.1.3", 31 | "uglifyjs-webpack-plugin": "^1.2.4", 32 | "vinyl-paths": "^2.1.0", 33 | "webpack": "^4.1.1", 34 | "webpack-stream": "^4.0.2" 35 | }, 36 | "dependencies": { 37 | "gulp": "^4.0.1", 38 | "jquery": "^3.3.1", 39 | "npm": "^6.9.0", 40 | "npm-check-updates": "^3.1.8" 41 | }, 42 | "browserslist": [ 43 | "android >= 4.2", 44 | "not ie < 11", 45 | "last 2 versions" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | ./tests/ 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/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. -------------------------------------------------------------------------------- /src/json-wp-post-parser/README.txt: -------------------------------------------------------------------------------- 1 | === JSON post parser === 2 | Contributors: dingo_bastard 3 | Tags: post, parser, content 4 | Requires at least: 4.4 5 | Tested up to: 4.9.4 6 | Stable tag: 1.0.7 7 | Requires PHP: 5.6 8 | License: GPLv2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | JSON Post Parser plugin parses your content and saves it as JSON available in REST posts and pages endpoints. 12 | 13 | == Description == 14 | 15 | When working on decoupled WordPress, while using one of the popular frameworks or libraries such as React, post content in pure HTML can be a bit of a problem. Having absolute links that point to the on-site resource would cause a page refresh. Which defeats the purpose of building with, for instance, React, which uses Link component to handle routes. 16 | This is where having post served as JSON simplifies things, in that you can find all the links, and then replace them with the appropriate router alternative. 17 | 18 | When you create a post and then save it, the parser will go through your rendered post and parse it in JSON, which will then be saved in `post_content_json` table in the `posts` table. 19 | Other than parsing the post, this plugin registers the additional REST field called `post_content_json` which you can fetch by going to `wp-json/wp/v2/posts/` or `wp-json/wp/v2/pages/`. 20 | 21 | If you want to expose your own custom post types to the REST endpoint, use the filter `json_wp_post_parser_add_post_types`. 22 | 23 | == Installation == 24 | 25 | 1. Place `json-wp-post-parser` folder in the `/wp-content/plugins/` directory 26 | 2. Activate the plugin through the 'Plugins' menu in WordPress 27 | 28 | == Other usages == 29 | 30 | You can use parse methods in other plugins if you want to. Once you install the plugin you can use the `parse_content_to_json()` method to parse HTML to json parsed content. 31 | 32 | ```php 33 | 34 | $parser = new \Json_WP_Post_Parser\Admin\Parse(); 35 | 36 | $parsed_content = $parser->parse_content_to_json( $html_content ); 37 | ``` 38 | 39 | == Frequently Asked Questions == 40 | 41 | = Will all my posts automatically be parsed? = 42 | 43 | No. Upon plugin activation, you will see a prompt that will ask you if you want to update all your posts, pages, custom post types. 44 | If you say yes, you'll be sent to a page where you'll see all your posts being resaved using AJAX. 45 | The reason for this is that someone can have 1000+ posts, and doing bulk upgrade would fail (exhausted memory, timeout etc.). 46 | By using AJAX we can trigger post saving asynchronously, which doesn't overload the system. 47 | 48 | = How can I add my custom post types, so that rest route has it as well? = 49 | 50 | There is a built in filter hook which you can use called `json_wp_post_parser_add_post_types`. Say you have custom post type called `books`, 51 | you'd add them like this: 52 | 53 | ```php 54 | add_filter( 'json_wp_post_parser_add_post_types', 'my_slug_add_cpt_to_parser' ); 55 | 56 | function my_slug_add_cpt_to_parser( $post_types ) { 57 | // the $post_types parameter is an array of all post_types from the api_fields_init() method. 58 | $post_types[] = 'books'; 59 | return $post_types; 60 | } 61 | ``` 62 | 63 | == Possible issues == 64 | 65 | When using post update to update all your posts, the default number of posts that are queried is 500. This is done to optimize query performance. Because you should never use `'posts_per_page' => -1`. If you have more than 500 posts then open `class-admin.php` and change this number on line 84. 66 | 67 | == Changelog == 68 | 69 | = 1.0.7 = 70 | 71 | * Autoload fix 72 | 73 | = 1.0.6 = 74 | 75 | * Minor class fixes 76 | 77 | = 1.0.5 = 78 | 79 | * Linter fixes 80 | * Class name fixes 81 | 82 | = 1.0.0 = 83 | 84 | * Initial release 85 | 86 | == Credits == 87 | 88 | JSON post parser is maintained and sponsored by 89 | [Infinum](https://www.infinum.co). 90 | 91 | 92 | 93 | == License == 94 | 95 | JSON post parser is Copyright © 2017 Infinum. It is free software, and may be redistributed under the terms specified in the LICENSE file. 96 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/admin/class-admin.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | class Admin { 23 | 24 | /** 25 | * The ID of this plugin. 26 | * 27 | * @since 1.0.0 28 | * @access private 29 | * @var string $plugin_name The ID of this plugin. 30 | */ 31 | private $plugin_name; 32 | 33 | /** 34 | * The version of this plugin. 35 | * 36 | * @since 1.0.0 37 | * @access private 38 | * @var string $version The current version of this plugin. 39 | */ 40 | private $version; 41 | 42 | /** 43 | * Initialize the class and set its properties. 44 | * 45 | * @since 1.0.0 46 | * @param string $plugin_name The name of this plugin. 47 | * @param string $version The version of this plugin. 48 | */ 49 | public function __construct( $plugin_name, $version ) { 50 | $this->plugin_name = $plugin_name; 51 | $this->version = $version; 52 | } 53 | 54 | /** 55 | * Add page that will display the button for resave action 56 | * 57 | * @since 1.0.0 58 | */ 59 | public function add_posts_parse_page() { 60 | add_options_page( 61 | esc_html__( 'Parse posts', 'json-wp-post-parser' ), 62 | esc_html__( 'Parse posts', 'json-wp-post-parser' ), 63 | 'manage_options', 64 | 'json_parser_posts', 65 | array( $this, 'render_parse_posts_page' ) 66 | ); 67 | } 68 | 69 | /** 70 | * Page that is used as a placeholder to show processed posts. 71 | * 72 | * @since 1.0.0 73 | */ 74 | public function render_parse_posts_page() { 75 | $post_types = array( 'post', 'page' ); 76 | 77 | if ( has_filter( 'json_wp_post_parser_add_post_types' ) ) { 78 | $post_types = apply_filters( 'json_wp_post_parser_add_post_types', $post_types ); 79 | } 80 | 81 | $all_posts_args = array( 82 | 'post_type' => $post_types, 83 | 'post_status' => 'publish', 84 | 'posts_per_page' => 500, 85 | ); 86 | 87 | $all_posts = new \WP_Query( $all_posts_args ); 88 | $posts_array = []; 89 | 90 | if ( $all_posts->have_posts() ) { 91 | while ( $all_posts->have_posts() ) { 92 | $all_posts->the_post(); 93 | $posts_array[] = get_the_ID(); 94 | } 95 | wp_reset_postdata(); 96 | } 97 | ?> 98 |
99 |

100 |
101 |
102 |
103 |
104 | 105 |
106 | plugin_name, plugins_url() . '/' . $this->plugin_name . '/assets/styles/application.css', array(), $this->version, 'all' ); 118 | wp_enqueue_script( $this->plugin_name, plugins_url() . '/' . $this->plugin_name . '/assets/scripts/application.js', array(), $this->version, false ); 119 | wp_localize_script( $this->plugin_name, 'wpApiSettings', array( 120 | 'root' => esc_url_raw( rest_url() ), 121 | 'nonce' => wp_create_nonce( 'wp_rest' ), 122 | 'processing' => esc_html__( 'Processing...', 'json-wp-post-parser' ), 123 | 'error' => esc_html__( 'Error', 'json-wp-post-parser' ), 124 | 'finished' => esc_html__( 'Finshed', 'json-wp-post-parser' ), 125 | ) ); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/admin/class-parse.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | class Parse { 23 | /** 24 | * Parse post content and store it in the custom table 25 | * 26 | * @param int $post_id Post ID. 27 | * @param object $post Post object. 28 | * @param bool $update Whether this is an existing post being updated or not. 29 | * @since 1.0.0 30 | */ 31 | public function update_post_json_content( $post_id, $post, $update ) { 32 | if ( $update ) { // Trigger only on post save or update, not on new post. 33 | global $wpdb; 34 | 35 | // Remove newlines. If we don't do this, json has tons of empty texts that notify the newlines. 36 | $post_content_lines = str_replace( array( "\r\n", "\r" ), "\n", apply_filters( 'the_content', $post->post_content ) ); 37 | 38 | $lines = explode( "\n", $post_content_lines ); 39 | $new_lines = array(); 40 | 41 | foreach ( $lines as $i => $line ) { 42 | if ( ! empty( $line ) ) { 43 | $new_lines[] = trim( $line ); 44 | } 45 | } 46 | 47 | $post_content = implode( $new_lines ); 48 | 49 | if ( ! empty( $post_content ) ) { 50 | // Remove hidden characters from the post content. 51 | $new_post_content = preg_replace( '/\s\s/', ' ', preg_replace( '/[^\x00-\x7F]/', ' ', $post_content ) ); 52 | $dom_json = $this->parse_content_to_json( $new_post_content ); 53 | $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_content_json = %s WHERE ID = %d", $dom_json, $post_id ) ); 54 | } 55 | } 56 | } 57 | 58 | /** 59 | * Parse post content and return json string 60 | * 61 | * DOMDocument uses HTML4 to parse the DOM, so HTML5 tags will throw out errors. 62 | * Currently the parser will report errors for such tags but the method for 63 | * loading HTML will work fine, and the content will be parsed. 64 | * 65 | * @param string $content Post content HTML string. 66 | * @return string JSON string. 67 | * @since 1.0.0 68 | */ 69 | public function parse_content_to_json( $content ) { 70 | $post_dom = new \DOMDocument(); 71 | libxml_use_internal_errors( true ); 72 | $post_dom->loadHTML( $content ); 73 | libxml_use_internal_errors( false ); 74 | libxml_clear_errors(); 75 | 76 | return wp_json_encode( $this->element_to_obj( $post_dom->documentElement ) ); 77 | } 78 | 79 | /** 80 | * Traverse through post html to create a post JSON 81 | * 82 | * @param object $element Post dom element. 83 | * @return string Post as JSON. 84 | */ 85 | public function element_to_obj( $element ) { 86 | // Document element doesn't like comments so we treat them separately. 87 | if ( $element->nodeType === XML_ELEMENT_NODE && $element->nodeName !== '#comment' ) { 88 | // Get all the html object tag names. E.g. div, h2, code etc. 89 | $node = $this->check_node_type( $element->nodeType ); 90 | 91 | $obj = array( 92 | 'node' => $node, 93 | 'tag' => $element->tagName, 94 | ); 95 | 96 | // Check the attributes, if there are any. 97 | foreach ( $element->attributes as $attribute ) { 98 | $obj['attr'][ $attribute->name ] = $attribute->value; 99 | } 100 | 101 | foreach ( $element->childNodes as $sub_element ) { // Child nodes. 102 | $obj['child'][] = $this->element_to_obj( $sub_element ); 103 | } 104 | } elseif ( $element->nodeType === XML_TEXT_NODE ) { 105 | $obj['node'] = 'text'; 106 | $obj['text'] = $element->wholeText; 107 | } else { 108 | $obj['tag'] = 'html-comment-tag'; 109 | $obj['html'] = $element->nodeValue; 110 | } 111 | 112 | return $obj; 113 | } 114 | 115 | /** 116 | * Check node type 117 | * 118 | * @param int $node_type Node type number. 119 | * @return string Type of node. 120 | */ 121 | public function check_node_type( $node_type ) { 122 | switch ( $node_type ) { 123 | case XML_ELEMENT_NODE: 124 | $node_type = 'element'; 125 | break; 126 | case XML_TEXT_NODE: 127 | $node_type = 'text'; 128 | break; 129 | default: 130 | $node_type = 'element'; 131 | break; 132 | } 133 | 134 | return $node_type; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/admin/class-rest-functionality.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | class Rest_Functionality { 22 | /** 23 | * Add additional rest routes and meta fields 24 | * 25 | * @since 1.0.0 26 | */ 27 | public function api_fields_init() { 28 | $post_types = array( 'post', 'page' ); 29 | 30 | if ( has_filter( 'json_wp_post_parser_add_post_types' ) ) { 31 | $post_types = apply_filters( 'json_wp_post_parser_add_post_types', $post_types ); 32 | } 33 | 34 | register_rest_field( 35 | $post_types, 36 | 'post_content_json', 37 | array( 38 | 'get_callback' => [ $this, 'get_post_json_content' ], 39 | 'schema' => null, 40 | ) 41 | ); 42 | 43 | register_rest_route( 44 | 'posts-parse-json/v1/', '/run', array( 45 | 'methods' => 'POST', 46 | 'callback' => [ $this, 'ajax_post_resave' ], 47 | ) 48 | ); 49 | } 50 | 51 | /** 52 | * Get json post content 53 | * 54 | * @param object $object Post object array. 55 | * @return [type] [description] 56 | */ 57 | public function get_post_json_content( $object ) { 58 | global $wpdb; 59 | $post_id = $object['id']; 60 | 61 | $json_content = $wpdb->get_col( $wpdb->prepare( "SELECT post_content_json FROM $wpdb->posts WHERE ID = %d", $post_id ) ); 62 | 63 | return $json_content[0]; 64 | } 65 | 66 | /** 67 | * Resave post callback 68 | * 69 | * @param \WP_REST_Request $request Full data about the request. 70 | * @since 1.0.0 71 | */ 72 | public function ajax_post_resave( \WP_REST_Request $request ) { 73 | $headers = $request->get_headers(); 74 | 75 | if ( ! wp_verify_nonce( $headers['x_wp_nonce'][0], 'wp_rest' ) ) { 76 | $message = esc_html__( 'Nonce error', 'json-wp-post-parser' ); 77 | $error = new \WP_Error( '-1', $message ); 78 | wp_send_json_error( $error ); 79 | } 80 | 81 | if ( isset( $_POST['postID'] ) && $_POST['postID'] !== '' ) { 82 | $post_id = intval( $_POST['postID'] ); 83 | 84 | wp_update_post( array( 85 | 'ID' => $post_id, 86 | ) ); 87 | 88 | wp_send_json( sprintf( esc_html__( '%1$s ID: #%2$d updated', 'json-wp-post-parser' ), ucfirst( get_post_type( $post_id ) ), intval( $post_id ) ) ); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/admin/index.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/includes/class-activator.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | class Activator { 23 | 24 | /** 25 | * Create post column if it doesn't exist. 26 | * 27 | * @since 1.0.0 28 | */ 29 | public static function activate() { 30 | $post_json_column_exists = get_option( 'post_json_column_exists' ); 31 | 32 | if ( empty( $post_json_column_exists ) || $post_json_column_exists === false ) { 33 | global $wpdb; 34 | 35 | $column_check = $wpdb->get_row( "SELECT * FROM $wpdb->posts" ); 36 | 37 | if ( empty( $column_check->post_content_json ) ) { 38 | $create_column = $wpdb->query( "ALTER TABLE $wpdb->posts ADD post_content_json LONGTEXT NOT NULL" ); 39 | // Store this info in the database for future use. 40 | add_option( 'post_json_column_exists', true ); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/includes/class-deactivator.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | class Deactivator { 23 | 24 | /** 25 | * Flush permalinks 26 | * 27 | * @since 1.0.0 28 | */ 29 | public static function deactivate() { 30 | delete_option( 'json_wp_post_parser_active' ); 31 | flush_rewrite_rules(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/includes/class-internationalization.php: -------------------------------------------------------------------------------- 1 | 25 | */ 26 | class Internationalization { 27 | 28 | /** 29 | * Load the plugin text domain for translation. 30 | * 31 | * @since 1.0.0 32 | */ 33 | public function load_plugin_textdomain() { 34 | load_plugin_textdomain( 35 | 'json-wp-post-parser', 36 | false, 37 | dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/includes/class-loader.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Loader { 24 | 25 | /** 26 | * The array of actions registered with WordPress. 27 | * 28 | * @since 1.0.0 29 | * @access protected 30 | * @var array $actions The actions registered with WordPress to fire when the plugin loads. 31 | */ 32 | protected $actions; 33 | 34 | /** 35 | * The array of filters registered with WordPress. 36 | * 37 | * @since 1.0.0 38 | * @access protected 39 | * @var array $filters The filters registered with WordPress to fire when the plugin loads. 40 | */ 41 | protected $filters; 42 | 43 | /** 44 | * Initialize the collections used to maintain the actions and filters. 45 | * 46 | * @since 1.0.0 47 | */ 48 | public function __construct() { 49 | $this->actions = array(); 50 | $this->filters = array(); 51 | } 52 | 53 | /** 54 | * Add a new action to the collection to be registered with WordPress. 55 | * 56 | * @since 1.0.0 57 | * @param string $hook The name of the WordPress action that is being registered. 58 | * @param object $component A reference to the instance of the object on which the action is defined. 59 | * @param string $callback The name of the function definition on the $component. 60 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10. 61 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. 62 | */ 63 | public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 64 | $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); 65 | } 66 | 67 | /** 68 | * Add a new filter to the collection to be registered with WordPress. 69 | * 70 | * @since 1.0.0 71 | * @param string $hook The name of the WordPress filter that is being registered. 72 | * @param object $component A reference to the instance of the object on which the filter is defined. 73 | * @param string $callback The name of the function definition on the $component. 74 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10. 75 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. 76 | */ 77 | public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 78 | $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); 79 | } 80 | 81 | /** 82 | * A utility function that is used to register the actions and hooks into a single 83 | * collection. 84 | * 85 | * @since 1.0.0 86 | * @access private 87 | * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). 88 | * @param string $hook The name of the WordPress filter that is being registered. 89 | * @param object $component A reference to the instance of the object on which the filter is defined. 90 | * @param string $callback The name of the function definition on the $component. 91 | * @param int $priority The priority at which the function should be fired. 92 | * @param int $accepted_args The number of arguments that should be passed to the $callback. 93 | * @return array The collection of actions and filters registered with WordPress. 94 | */ 95 | private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { 96 | $hooks[] = array( 97 | 'hook' => $hook, 98 | 'component' => $component, 99 | 'callback' => $callback, 100 | 'priority' => $priority, 101 | 'accepted_args' => $accepted_args, 102 | ); 103 | 104 | return $hooks; 105 | } 106 | 107 | /** 108 | * Register the filters and actions with WordPress. 109 | * 110 | * @since 1.0.0 111 | */ 112 | public function run() { 113 | foreach ( $this->filters as $hook ) { 114 | add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 115 | } 116 | 117 | foreach ( $this->actions as $hook ) { 118 | add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/includes/class-main.php: -------------------------------------------------------------------------------- 1 | 32 | */ 33 | class Main { 34 | 35 | /** 36 | * The loader that's responsible for maintaining and registering all hooks that power 37 | * the plugin. 38 | * 39 | * @since 1.0.0 40 | * @access protected 41 | * @var Json_WP_Post_Parser_Loader $loader Maintains and registers all hooks for the plugin. 42 | */ 43 | protected $loader; 44 | 45 | /** 46 | * The unique identifier of this plugin. 47 | * 48 | * @since 1.0.0 49 | * @access protected 50 | * @var string $plugin_name The string used to uniquely identify this plugin. 51 | */ 52 | protected $plugin_name; 53 | 54 | /** 55 | * The current version of the plugin. 56 | * 57 | * @since 1.0.0 58 | * @access protected 59 | * @var string $version The current version of the plugin. 60 | */ 61 | protected $version; 62 | 63 | /** 64 | * Define the core functionality of the plugin. 65 | * 66 | * Set the plugin name and the plugin version that can be used throughout the plugin. 67 | * Load the dependencies, define the locale, and set the hooks for the admin area and 68 | * the public-facing side of the site. 69 | * 70 | * @since 1.0.0 71 | */ 72 | public function __construct() { 73 | if ( defined( 'JWPP_PLUGIN_VERSION' ) ) { 74 | $this->version = JWPP_PLUGIN_VERSION; 75 | } else { 76 | $this->version = '1.0.7'; 77 | } 78 | 79 | if ( defined( 'JWPP_PLUGIN_NAME' ) ) { 80 | $this->plugin_name = JWPP_PLUGIN_NAME; 81 | } else { 82 | $this->plugin_name = 'json-wp-post-parser'; 83 | } 84 | 85 | $this->load_dependencies(); 86 | $this->set_locale(); 87 | $this->define_admin_hooks(); 88 | $this->register_rest_routes(); 89 | } 90 | 91 | /** 92 | * Load the required dependencies for this plugin. 93 | * 94 | * Create an instance of the loader which will be used to register the hooks 95 | * with WordPress. 96 | * 97 | * @since 1.0.0 98 | * @access private 99 | */ 100 | private function load_dependencies() { 101 | $this->loader = new Loader(); 102 | } 103 | 104 | /** 105 | * Define the locale for this plugin for internationalization. 106 | * 107 | * Uses the i18n class in order to set the domain and to register the hook 108 | * with WordPress. 109 | * 110 | * @since 1.0.0 111 | * @access private 112 | */ 113 | private function set_locale() { 114 | $plugin_i18n = new Internationalization(); 115 | 116 | $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); 117 | } 118 | 119 | /** 120 | * Register all of the hooks related to the admin area functionality 121 | * of the plugin. 122 | * 123 | * @since 1.0.0 124 | * @access private 125 | */ 126 | private function define_admin_hooks() { 127 | $plugin_admin = new Admin\Admin( $this->get_plugin_name(), $this->get_version() ); 128 | $plugin_parse = new Admin\Parse(); 129 | 130 | $this->loader->add_action( 'save_post', $plugin_parse, 'update_post_json_content', 10, 3 ); 131 | $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_posts_parse_page' ); 132 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); 133 | } 134 | 135 | /** 136 | * Register custom REST routes. 137 | * 138 | * @since 1.0.0 139 | * @access private 140 | */ 141 | private function register_rest_routes() { 142 | $plugin_rest = new Admin\Rest_Functionality(); 143 | 144 | $this->loader->add_action( 'rest_api_init', $plugin_rest, 'api_fields_init' ); 145 | } 146 | 147 | /** 148 | * Run the loader to execute all of the hooks with WordPress. 149 | * 150 | * @since 1.0.0 151 | */ 152 | public function run() { 153 | $this->loader->run(); 154 | } 155 | 156 | /** 157 | * The name of the plugin used to uniquely identify it within the context of 158 | * WordPress and to define internationalization functionality. 159 | * 160 | * @since 1.0.0 161 | * @return string The name of the plugin. 162 | */ 163 | public function get_plugin_name() { 164 | return $this->plugin_name; 165 | } 166 | 167 | /** 168 | * The reference to the class that orchestrates the hooks with the plugin. 169 | * 170 | * @since 1.0.0 171 | * @return Json_WP_Post_Parser_Loader Orchestrates the hooks of the plugin. 172 | */ 173 | public function get_loader() { 174 | return $this->loader; 175 | } 176 | 177 | /** 178 | * Retrieve the version number of the plugin. 179 | * 180 | * @since 1.0.0 181 | * @return string The version number of the plugin. 182 | */ 183 | public function get_version() { 184 | return $this->version; 185 | } 186 | 187 | } 188 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/includes/index.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/index.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/json-wp-post-parser.php: -------------------------------------------------------------------------------- 1 | 59 |
60 |

' . esc_html__( 'this page', 'json-wp-post-parser' ) . '', esc_url( admin_url( 'options-general.php?page=json_parser_posts' ) ) ); ?>

61 |
62 | run(); 99 | } 100 | 101 | run(); 102 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/lib/autoloader.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/skin/assets/application.js: -------------------------------------------------------------------------------- 1 | // Load Scripts 2 | import './scripts/scriptsAdmin'; 3 | 4 | // Load Styles 5 | import './styles/stylesAdmin.scss'; 6 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/skin/assets/scripts/ajax-helper.js: -------------------------------------------------------------------------------- 1 | /* global wpApiSettings */ 2 | import $ from 'jquery'; 3 | 4 | const ajax = { 5 | ajaxResavePost(ID, finished, $notifElement) { 6 | if (typeof $notifElement === 'undefined') { 7 | return false; 8 | } 9 | 10 | const ajaxData = { 11 | postID: ID, 12 | }; 13 | 14 | const $finishedElement = $('.js-finished'); 15 | const $processingElement = $('.js-processing'); 16 | 17 | $.ajax({ 18 | type: 'POST', 19 | url: `${wpApiSettings.root}posts-parse-json/v1/run`, 20 | data: ajaxData, 21 | beforeSend: (xhr) => { 22 | $notifElement.html(''); 23 | $finishedElement.html(''); 24 | $processingElement.html(wpApiSettings.processing); 25 | xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce); 26 | }, 27 | }) 28 | .done((data) => { 29 | $notifElement.append(`
${data}
`); 30 | }) 31 | .fail((xhr, status, error) => { 32 | $notifElement.append(`
${wpApiSettings.error} ${xhr.status} (${ID}): ${error}
`); 33 | }) 34 | .always(() => { 35 | if (finished) { 36 | $processingElement.html(''); 37 | $finishedElement.html(wpApiSettings.finished); 38 | } 39 | }); 40 | return false; 41 | }, 42 | }; 43 | 44 | export default ajax; 45 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/skin/assets/scripts/scriptsAdmin.js: -------------------------------------------------------------------------------- 1 | import $ from 'jquery'; 2 | import ajaxHelper from './ajax-helper'; 3 | 4 | $(function() { 5 | 6 | const $notificationElement = $('.js-processed-posts'); 7 | const allPosts = $notificationElement.data('posts'); 8 | 9 | $('.js-start-post-resave').on('click', function() { 10 | let finished = false; 11 | for (const ID in allPosts) { 12 | if (Object.prototype.hasOwnProperty.call(allPosts, ID)) { 13 | if (parseInt(ID, 10) === parseInt(allPosts.length - 1, 10)) { 14 | finished = true; 15 | } 16 | ajaxHelper.ajaxResavePost(allPosts[ID], finished, $notificationElement); 17 | } 18 | } 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/skin/assets/styles/stylesAdmin.scss: -------------------------------------------------------------------------------- 1 | $color-error: #BD0505; 2 | $color-finish: #19A500; 3 | 4 | .processed-posts { 5 | margin-bottom: 30px; 6 | 7 | &__process-info { 8 | margin-bottom: 20px; 9 | } 10 | 11 | &__process-data { 12 | padding: 5px 0; 13 | } 14 | 15 | &__process-error { 16 | color: $color-error; 17 | } 18 | 19 | &__process-finish { 20 | color: $color-finish; 21 | margin-bottom: 20px; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/json-wp-post-parser/uninstall.php: -------------------------------------------------------------------------------- 1 | query( $wpdb->prepare( "ALTER TABLE $wpdb->posts DROP COLUMN %s", 'post_content_json' ) ); 43 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | parse_content_to_json( '
This is a test.
' ); 26 | 27 | $this->assertTrue( is_string( $result ), 'Parsed content should be a JSON sting.' ); 28 | } 29 | 30 | /** 31 | * Test the parse_content_to_json method 32 | * 33 | * Test if the method parse_content_to_json exists. 34 | * 35 | * @since 1.0.0 36 | */ 37 | public function test_method_type() { 38 | 39 | $parser = new Admin\Parse(); 40 | 41 | $this->assertTrue( method_exists( $parser, 'parse_content_to_json' ) ); 42 | } 43 | 44 | /** 45 | * Test the content 46 | * 47 | * Test if the given HTML parses to a correct JSON. 48 | * 49 | * @param string $provided_json Provided json to the test method. 50 | * @param string $provided_html Provided html to the test method. 51 | * @since 1.0.0 52 | * 53 | * @dataProvider provider_test_return_json_content 54 | */ 55 | public function test_html_content( $provided_json, $provided_html ) { 56 | 57 | $parser = new Admin\Parse(); 58 | 59 | $result_json = $parser->parse_content_to_json( $provided_html ); 60 | 61 | $this->assertEquals( $provided_json, $result_json ); 62 | } 63 | 64 | /** 65 | * Data test provider 66 | * 67 | * @return array Array of provided data to test. 68 | * @since 1.0.0 69 | */ 70 | public function provider_test_return_json_content() { 71 | return array( 72 | array( '{"node":"element","tag":"html","child":[{"node":"element","tag":"body","child":[{"node":"element","tag":"div","attr":{"id":"1","class":"foo"},"child":[{"node":"element","tag":"h2","child":[{"node":"text","text":"sample text with "},{"node":"element","tag":"code","child":[{"node":"text","text":"inline tag"}]}]},{"node":"element","tag":"pre","attr":{"id":"demo","class":"foo bar"},"child":[{"node":"text","text":"foo"}]},{"node":"element","tag":"pre","attr":{"id":"output","class":"goo"},"child":[{"node":"text","text":"goo"}]},{"node":"element","tag":"input","attr":{"id":"execute","type":"button","value":"execute"}}]}]}]}', '

sample text with inline tag

foo
goo
' ), 73 | array( '{"node":"element","tag":"html","child":[{"node":"element","tag":"body","child":[{"node":"element","tag":"div"}]}]}', '
' ), 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const webpack = require('webpack'); 4 | const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); 5 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); 6 | 7 | const appPath = `${path.resolve(__dirname)}`; 8 | 9 | // Entry 10 | const pluginPath = '/src/json-wp-post-parser/skin'; 11 | const pluginFullPath = `${appPath}${pluginPath}`; 12 | const pluginEntry = `${pluginFullPath}/assets/application.js`; 13 | const pluginPublicPath = `${appPath}/build/assets`; 14 | 15 | // Outputs 16 | const outputJs = 'scripts/[name].js'; 17 | const outputCss = 'styles/[name].css'; 18 | 19 | const allModules = { 20 | rules: [ 21 | { 22 | test: /\.(js|jsx)$/, 23 | use: 'babel-loader', 24 | exclude: /node_modules/ 25 | }, 26 | { 27 | test: /\.json$/, 28 | use: 'json-loader' 29 | }, 30 | { 31 | test: /\.scss$/, 32 | use: ExtractTextPlugin.extract({ 33 | fallback: 'style-loader', 34 | use: ['css-loader', 'sass-loader'] 35 | }) 36 | } 37 | ] 38 | }; 39 | 40 | const allPlugins = [ 41 | new webpack.optimize.ModuleConcatenationPlugin(), 42 | new ExtractTextPlugin(outputCss), 43 | new webpack.optimize.UglifyJsPlugin({ 44 | output: { 45 | comments: false, 46 | }, 47 | compress: { 48 | warnings: false, 49 | drop_console: true, // eslint-disable-line camelcase 50 | }, 51 | sourceMap: true, 52 | }), 53 | ]; 54 | 55 | module.exports = [ 56 | { 57 | devServer: { 58 | outputPath: path.join(__dirname, 'build') 59 | }, 60 | entry: { 61 | application: [pluginEntry] 62 | }, 63 | output: { 64 | path: pluginPublicPath, 65 | publicPath: '', 66 | filename: outputJs 67 | }, 68 | 69 | module: allModules, 70 | 71 | plugins: allPlugins 72 | } 73 | ]; 74 | --------------------------------------------------------------------------------