Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acf register field to make it available in eg. REST #60

Open
wants to merge 2 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions acf-country.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Advanced Custom Fields: ACF Country
Plugin URI: https://github.com/nlemoine/acf-country
Description: Display a select field of all countries, in any language.
Version: 2.1.0
Version: 2.1.1
Author: Nicolas Lemoine
Author URI: https://helloni.co/
GitHub Plugin URI: https://github.com/nlemoine/acf-country
Expand Down Expand Up @@ -32,7 +32,7 @@ class FieldLoader {
*/
public function __construct() {
$this->settings = array(
'version' => '2.0.2',
'version' => '2.1.1',
'url' => plugin_dir_url( __FILE__ ),
'path' => plugin_dir_path( __FILE__ ),
);
Expand Down Expand Up @@ -159,7 +159,9 @@ public function add_graphql_field_support( $supported_fields ) {
* @return void
*/
public function fields( $version = 5 ) {
include_once 'fields/acf-country.php';
require_once 'fields/acf-country.php';
$field = new AcfCountry( $this->settings );
acf_register_field_type( $field );
}
}

Expand Down
6 changes: 1 addition & 5 deletions fields/acf-country.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
return;
}

use acf_field;

/**
* ACF Country field
*/
class AcfCountry extends acf_field {
class AcfCountry extends \acf_field {

/**
* Constructor
Expand Down Expand Up @@ -277,5 +275,3 @@ private function get_countries() {
return apply_filters( 'acf/country/countries', $countries );
}
}

new AcfCountry( $this->settings );