diff --git a/Dockerfile b/Dockerfile index 27b27f5..74f666c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM wordpress:5.8 +FROM wordpress:6 COPY ./entrypoint.sh /usr/local/bin/apache2-custom.sh RUN chmod 755 /usr/local/bin/apache2-custom.sh diff --git a/README.md b/README.md index 78ff8f6..b757b68 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Set Advanced Custom Fields (ACF) empty field value as `null` instead of `false` to avoid GraphQL error in GatsbyJS. -## WordPress plugins +## WordPress plugins https://wordpress.org/plugins/wp-acf-nullify-gatsby/ @@ -16,6 +16,6 @@ If you would like to report an issue then report it at [GitHub issues](https://g MIT License -© Jabran Rafique – 2020 +© Jabran Rafique – since 2020 [![Analytics](https://ga-beacon.appspot.com/UA-50688851-1/nullify-empty-fields-for-acf)](https://github.com/igrigorik/ga-beacon) diff --git a/docker-compose.yml b/docker-compose.yml index 0db3d2c..ed47981 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,18 @@ version: "3.2" services: + db: + image: mysql + restart: always + container_name: mysql + environment: + MYSQL_DATABASE: exampledb + MYSQL_USER: exampleuser + MYSQL_PASSWORD: examplepass + MYSQL_RANDOM_ROOT_PASSWORD: "1" + volumes: + - db:/var/lib/mysql + wordpress: build: . restart: always @@ -18,18 +30,6 @@ services: - plugins:/var/www/html/wp-content/plugins - ./src:/var/www/html/wp-content/plugins/nullify-empty-fields-for-acf - db: - image: mysql:5.7 - restart: always - container_name: mysql - environment: - MYSQL_DATABASE: exampledb - MYSQL_USER: exampleuser - MYSQL_PASSWORD: examplepass - MYSQL_RANDOM_ROOT_PASSWORD: "1" - volumes: - - db:/var/lib/mysql - volumes: wordpress: plugins: diff --git a/src/index.php b/src/index.php index f6a7aa4..3547571 100644 --- a/src/index.php +++ b/src/index.php @@ -1,10 +1,11 @@ null instead of false to avoid GraphQL error in GatsbyJS. * Author: Jabran Rafique - * Version: 1.2.2 + * Version: 1.2.3 * Author URI: https://jabran.me?utm_source=nullify-empty-fields-for-acf * License: MIT License * @@ -22,9 +23,10 @@ /** * Add settings link */ -function nullify_empty_fields_for_acf_settings_link( $links ) { +function nullify_empty_fields_for_acf_settings_link($links) +{ $links[] = sprintf('%s', admin_url('plugins.php?page=nullify-empty-fields-for-acf'), __('Settings')); - return $links; + return $links; } /** @@ -37,7 +39,8 @@ function nullify_empty_fields_for_acf_settings_link( $links ) { * @link https://www.gatsbyjs.org/packages/gatsby-source-wordpress/#graphql-error---unknown-field-on-acf * @return mixed */ -function nullify_empty_fields_for_acf_empty($value, $post_id, $field) { +function nullify_empty_fields_for_acf_empty($value, $post_id, $field) +{ if (empty($value)) { return null; } @@ -48,7 +51,8 @@ function nullify_empty_fields_for_acf_empty($value, $post_id, $field) { /** * Uninstall hook callback function */ -function nullify_empty_fields_for_acf_uninstall() { +function nullify_empty_fields_for_acf_uninstall() +{ $nullifyTypes = get_option('nullify_empty_fields_for_acf_types'); if (empty($nullifyTypes)) { @@ -56,7 +60,7 @@ function nullify_empty_fields_for_acf_uninstall() { } else { $nullifyTypes = explode(',', $nullifyTypes); - foreach($nullifyTypes as $nullifyType) { + foreach ($nullifyTypes as $nullifyType) { if ($remove) { remove_filter('acf/format_value/type=' . $nullifyType, 'nullify_empty_fields_for_acf_empty', 100, 3); } @@ -71,7 +75,8 @@ function nullify_empty_fields_for_acf_uninstall() { * * @param $remove boolean */ -function nullify_empty_fields_for_acf_toggle($remove = false) { +function nullify_empty_fields_for_acf_toggle($remove = false) +{ $nullifyTypes = get_option('nullify_empty_fields_for_acf_types'); if (empty($nullifyTypes)) { @@ -83,7 +88,7 @@ function nullify_empty_fields_for_acf_toggle($remove = false) { } else { $nullifyTypes = explode(',', $nullifyTypes); - foreach($nullifyTypes as $nullifyType) { + foreach ($nullifyTypes as $nullifyType) { if ($remove) { remove_filter('acf/format_value/type=' . trim($nullifyType), 'nullify_empty_fields_for_acf_empty', 100, 3); } else { @@ -92,20 +97,22 @@ function nullify_empty_fields_for_acf_toggle($remove = false) { } } - add_filter('plugin_action_links_'. plugin_basename(__FILE__), 'nullify_empty_fields_for_acf_settings_link', 100, 3); + add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'nullify_empty_fields_for_acf_settings_link', 100, 3); } /** * Deactivate hook callback function */ -function nullify_empty_fields_for_acf_deactivate() { +function nullify_empty_fields_for_acf_deactivate() +{ nullify_empty_fields_for_acf_toggle(true); } /** * Activate hook callback function */ -function nullify_empty_fields_for_acf_activate() { +function nullify_empty_fields_for_acf_activate() +{ if (!nullify_empty_fields_for_acf_is_acf_active()) { wp_die(sprintf('This plugin only works with Advanced Custom Fields (ACF). Please install and activate ACF before using this plugin.', 'https://wordpress.org/plugins/advanced-custom-fields/?utm_source=nullify-empty-fields-for-acf')); } @@ -117,6 +124,6 @@ function nullify_empty_fields_for_acf_activate() { nullify_empty_fields_for_acf_toggle(); // hooks -register_activation_hook( __FILE__, 'nullify_empty_fields_for_acf_activate' ); -register_deactivation_hook( __FILE__, 'nullify_empty_fields_for_acf_deactivate' ); -register_uninstall_hook( __FILE__, 'nullify_empty_fields_for_acf_uninstall' ); +register_activation_hook(__FILE__, 'nullify_empty_fields_for_acf_activate'); +register_deactivation_hook(__FILE__, 'nullify_empty_fields_for_acf_deactivate'); +register_uninstall_hook(__FILE__, 'nullify_empty_fields_for_acf_uninstall'); diff --git a/src/readme.txt b/src/readme.txt index c2dcac6..2af7968 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -3,8 +3,8 @@ Contributors: jabranr Donate link: https://paypal.me/jabranr Tags: gatsby, graphql, acf, advanced-custom-fields, wordpress Requires at least: 5.0 -Tested up to: 5.8 -Stable tag: 1.2.2 +Tested up to: 6 +Stable tag: 1.2.3 Requires PHP: 7.1 License: MIT License License URI: https://opensource.org/licenses/MIT @@ -27,6 +27,9 @@ Set Advanced Custom Fields (ACF) empty field value as `null` instead of `false` == Changelog == += 1.2.3 = +* Support for WordPress 6.x + = 1.2.2 = * Support for WordPress 5.8