将值作为文本返回到textarea

时间:2019-05-04 04:24:58

标签: php wordpress return-value advanced-custom-fields

我已经尝试了几天,我觉得我的大脑感觉不好。

我正在从ACF文件上传字段中进行pdf解析功能,并且我需要将返回值放入textarea字段中。

function extract_pdf_content( $value, $post_id, $field ) {
    // make sure the file exists and the Xpdf path was provided
    $xpdfPath = '/Users/michael/Sites/play/wp-content/pdftotext';

    // make sure it's a PDF
    $checkFileType = wp_check_filetype( $post_id );
    if ( 'pdf' !== strtolower( $checkFileType['ext'] ) ) {
        return $value;
    }

    // generate the full command to Xpdf's pdftotext binary
    $cmd = $xpdfPath . ' "' . $post_id . '" - -enc UTF-8';

    // @codingStandardsIgnoreStart
    // fire Xpdf
    @exec( $cmd, $output, $exitCode );
    // @codingStandardsIgnoreEnd

    // grab the content
    $value = isset( $exitCode ) && 0 === $exitCode ? implode( ' ', $output ) : '';

    // clean up a little bit
    $value = trim( str_replace( "\n", ' ', $value ) );
    $value = sanitize_text_field( $value );


    function cv_update_value( $value ) {
    return $value;
    }
    add_filter('acf/update_value/name=cv', 'cv_update_value', 10, 3);

}
add_filter( 'acf/load_value/name=resume', 'extract_pdf_content', 10, 3 );

这怎么可能?

simple explanation

谢谢!

0 个答案:

没有答案
相关问题