src/AcfExportManager.php
public function export(array $fieldgroup, bool $restrictToExportPosts = true, bool $translate = true) : array
    {
        global $locale;
        $locale = "en_US";

        // Bail if the fieldgroup shouldn't be exported
        if ($restrictToExportPosts && !in_array($fieldgroup['key'], $this->exportPosts)) {
            return array();
        }

        $this->maybeCreateExportFolders();

        if ($this->textdomain) {
            acf_update_setting('l10n', true);
            acf_update_setting('l10n_textdomain', $this->textdomain);
            acf_update_setting('l10n_var_export', true);
        }

        $filename = $this->getExportFilename($fieldgroup);

        // Export php file
        $this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']);
        $code = $this->generatePhp($fieldgroup['ID'], $translate);
        $phpFile = fopen($this->exportFolder . 'php/' . $filename['php'], 'w');
        fwrite($phpFile, $code);
        fclose($phpFile);

        // Export json file
        $this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']);
        $jsonFile = fopen($this->exportFolder . 'json/' . $filename['json'], 'w');
        $json = $this->getJson($this->getFieldgroupParams($fieldgroup['ID'], false));
        fwrite($jsonFile, $json);
        fclose($jsonFile);

        return array(
            'php' => $this->exportFolder . 'php/' . $filename['php'],
            'json' => $this->exportFolder . 'json/' . $filename['json']
        );
    }
public function export(array $fieldgroup, bool $restrictToExportPosts = true, bool $translate = true) : array
    {
        global $locale;
        $locale = "en_US";

        // Bail if the fieldgroup shouldn't be exported
        if ($restrictToExportPosts && !in_array($fieldgroup['key'], $this->exportPosts)) {
            return array();
        }

        $this->maybeCreateExportFolders();

        if ($this->textdomain) {
            acf_update_setting('l10n', true);
            acf_update_setting('l10n_textdomain', $this->textdomain);
            acf_update_setting('l10n_var_export', true);
        }

        $filename = $this->getExportFilename($fieldgroup);

        // Export php file
        $this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']);
        $code = $this->generatePhp($fieldgroup['ID'], $translate);
        $phpFile = fopen($this->exportFolder . 'php/' . $filename['php'], 'w');
        fwrite($phpFile, $code);
        fclose($phpFile);

        // Export json file
        $this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']);
        $jsonFile = fopen($this->exportFolder . 'json/' . $filename['json'], 'w');
        $json = $this->getJson($this->getFieldgroupParams($fieldgroup['ID'], false));
        fwrite($jsonFile, $json);
        fclose($jsonFile);

        return array(
            'php' => $this->exportFolder . 'php/' . $filename['php'],
            'json' => $this->exportFolder . 'json/' . $filename['json']
        );
    }
public function export ( array $ fieldgroup , bool $ restrictToExportPosts = true , bool $ translate = true ) : array { global $ locale ; $ locale = "en_US" ; // Bail if the fieldgroup shouldn't be exported if ( $ restrictToExportPosts && ! in_array ( $ fieldgroup [ 'key' ] , $ this -> exportPosts ) ) { return array ( ) ; } $ this -> maybeCreateExportFolders ( ) ; if ( $ this -> textdomain ) { acf_update_setting ( 'l10n' , true ) ; acf_update_setting ( 'l10n_textdomain' , $ this -> textdomain ) ; acf_update_setting ( 'l10n_var_export' , true ) ; } $ filename = $ this -> getExportFilename ( $ fieldgroup ) ; // Export php file $ this -> maybeUnlink ( $ this -> exportFolder . 'php/' . $ filename [ 'php' ] ) ; $ code = $ this -> generatePhp ( $ fieldgroup [ 'ID' ] , $ translate ) ; $ phpFile = fopen ( $ this -> exportFolder . 'php/' . $ filename [ 'php' ] , 'w' ) ; fwrite ( $ phpFile , $ code ) ; fclose ( $ phpFile ) ; // Export json file $ this -> maybeUnlink ( $ this -> exportFolder . 'json/' . $ filename [ 'json' ] ) ; $ jsonFile = fopen ( $ this -> exportFolder . 'json/' . $ filename [ 'json' ] , 'w' ) ; $ json = $ this -> getJson ( $ this -> getFieldgroupParams ( $ fieldgroup [ 'ID' ] , false ) ) ; fwrite ( $ jsonFile , $ json ) ; fclose ( $ jsonFile ) ; return array ( 'php' => $ this -> exportFolder . 'php/' . $ filename [ 'php' ] , 'json' => $ this -> exportFolder . 'json/' . $ filename [ 'json' ] ) ; }
Does the actual export of the php fields
@param  array $fieldgroup  Fieldgroup data
@return array              Paths to exported files
Does the actual export of the php fields