Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Font Library: load collection JSON data from a URL in the collection …
…config (#54067) * Adding Font Collection class * php formatting and linting * Adding tests for collections routes * Adding tests for WP_Font_Collection constructor * adding tests for WP_Font_Collection get_data() * adding tests for WP_Font_Library register_font_collection() * get font collection tests * adding 'wp_' prefix to the 'register_font_collection' filter name * fix callback name * making class property private * registering filter from font-library.php file * removing superfluous comment * moving files to according changes in trunk * config without a json file should fail * fix property name in tests * name fix Co-authored-by: Tonya Mork <tonya.mork@automattic.com> * comment update Co-authored-by: Tonya Mork <tonya.mork@automattic.com> * Adds WP_Error to return type * Improves contructor error handling. * Ensures each required param is of the right data type. * Improves each param check error to include expected data type. * FontCollection::get_data(): Improves error handling * Rechecking if "data_json_file" exists in the $config property shouldn't be necessary, as it's checked in the constructor. * If the file does not exist, bail out immediately as there's nothing more to do. * Adds a check and WP_Error for file_get_contents(): file_get_contents() returns false on failure. If there's nothing in the file, an empty string is returned. This change checks for both of these conditions and returns a WP_Error if either happens. * Internationalizes WP_Error error message for consistency in Core. * Removes empty space for wpcs * adding filter in a simpler way Co-authored-by: Tonya Mork <tonya.mork@automattic.com> * micro-optimization Co-authored-by: Tonya Mork <tonya.mork@automattic.com> * reuse WP_Error response instead of creating a new one Co-authored-by: Tonya Mork <tonya.mork@automattic.com> * Eliminates try/catch * Revert "Eliminates try/catch" commit This reverts commit 0e6c026. * Remove wp_register_font_collection and replace it by a global function, remove try catch and raise the error if needed * adding function comment and guard agains re-declaration * php format * fixing docblock coments * removing param comment * re-adding parameter comment removed by mistake * format php * updating WP_Font_Collection __construct tests * updating WP_Font_Collection get_data tests * updating tests * php format * array check Co-authored-by: Tonya Mork <tonya.mork@automattic.com> * Documents config array structure * adding tests for /fonts/collections endpoint * adding /fonts/collections/<id> endpoint test * format * format * add test for missing collection * removing not needed variables * Add more tests and split the test for WP_REST_Font_Library_Controller * lint * try to create dir for tests in CI * renane config property to src and handle URLs apart from file paths * Add the ability to load collection JSON data from a URL * remove unwanted comment * fix missing merge * fix merge with trunk * removing test file after merge with trunk * removing duplicated test files after merge with trunk * decode data to make availanle in the client as json * update google fonts collection source * format php' * removing the default font collection (google fonts) json file from repo * fixing logic to get data from url * add tests to try the font collection fetching from url * update test * format comments * replacing existing url in test with a mock url * early return Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com> * remove not needed filter Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com> * rewording error message Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com> --------- Co-authored-by: Tonya Mork <tonya.mork@automattic.com> Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>
- Loading branch information