| @@ -17,8 +17,13 @@ | ||
| 17 | 17 | */ |
| 18 | 18 | class Api { |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | + * Elementor library option key. | |
| 22 | + */ | |
| 23 | + const LIBRARY_OPTION_KEY = 'elementor_remote_info_library'; | |
| 24 | + | |
| 25 | + /** | |
| 21 | 26 | * Elementor feed option key. |
| 22 | 27 | */ |
| 23 | 28 | const FEED_OPTION_KEY = 'elementor_remote_info_feed_data'; |
| 24 | 29 | |
| @@ -218,9 +223,24 @@ | ||
| 218 | 223 | } |
| 219 | 224 | |
| 220 | 225 | $library_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
| 221 | 226 | |
| 222 | - return empty( $library_data ) ? [] : $library_data; | |
| 227 | + /** | |
| 228 | + * Filters the library data to allow 3rd party extending the response data. | |
| 229 | + * | |
| 230 | + * @since 3.32.2 | |
| 231 | + * @param-out array $library_data an array of templates data. | |
| 232 | + */ | |
| 233 | + $library_data = apply_filters( 'elementor/remote/library/data', $library_data ); | |
| 234 | + | |
| 235 | + if ( empty( $library_data ) || ! is_array( $library_data ) ) { | |
| 236 | + return []; | |
| 237 | + } | |
| 238 | + | |
| 239 | + // the following update & get are a temporary measure, to allow 3rd party plugins inject more templates: | |
| 240 | + update_option( self::LIBRARY_OPTION_KEY, $library_data, 'no' ); | |
| 241 | + | |
| 242 | + return get_option( self::LIBRARY_OPTION_KEY, $library_data ); | |
| 223 | 243 | } |
| 224 | 244 | |
| 225 | 245 | /** |
| 226 | 246 | * Get feed data. |