-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmakefile
28 lines (27 loc) · 1.65 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
PLUGIN := 3-word-address-validation-field
.PHONY: check_wp_compatibility
check_wp_compatibility:
@echo "Checking plugin: $(PLUGIN)"
@PLUGIN_INFO=$$(curl -s "https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request%5Bslug%5D=$(PLUGIN)"); \
PLUGIN_INFO_CLEAN=$$(echo $$PLUGIN_INFO | sed 's/"sections":{[^}]*},//g'); \
CURRENT_WP_VERSION=$$(curl -s "https://api.wordpress.org/core/version-check/1.7/" | grep -o '"current":"[^"]*"' | cut -d '"' -f 4 | head -n 1); \
TESTED_VERSION=$$(echo $$PLUGIN_INFO_CLEAN | grep -o '"tested":"[^"]*"' | cut -d '"' -f 4); \
LATEST_VERSION=$$(echo $$PLUGIN_INFO_CLEAN | grep -o '"version":"[^"]*"' | cut -d '"' -f 4); \
if [ -z "$$TESTED_VERSION" ] || [ "$$TESTED_VERSION" = "null" ]; then \
echo "Could not retrieve plugin information for $(PLUGIN) or the plugin has not been tested."; \
elif [ -z "$$LATEST_VERSION" ] || [ "$$LATEST_VERSION" = "null" ]; then \
echo "Could not retrieve the latest version for $(PLUGIN)."; \
else \
echo "Plugin version: $$LATEST_VERSION"; \
echo "Tested up to: $$TESTED_VERSION"; \
echo "Current WordPress version: $$CURRENT_WP_VERSION"; \
if [ "$$(echo $$CURRENT_WP_VERSION | cut -d '.' -f 1)" -gt "$$(echo $$TESTED_VERSION | cut -d '.' -f 1)" ]; then \
echo "Warning: The plugin hasn't been tested with the latest WordPress major release."; \
exit 1; \
elif [ "$$(echo $$CURRENT_WP_VERSION | cut -d '.' -f 2)" -gt "$$(echo $$TESTED_VERSION | cut -d '.' -f 2)" ]; then \
echo "Warning: The plugin hasn't been tested with the latest minor release of WordPress."; \
exit 1; \
else \
echo "The plugin is tested with your current version of WordPress."; \
fi; \
fi