• Resolved d

    (@dnicinski)


    With 1000+ pages the Post Object Field is very buggy. Can this search field be ignored in the plugin?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @dnicinski ,

    Thank you for your message. Unfortunately, I don’t understand much. Could you explain what’s going on? Exactly, step by step.

    Thread Starter d

    (@dnicinski)

    When using the ACF Post Object it has a search box to filter through posts/pages.

    Example – https://i.imgur.com/N3HpZAj.png

    When your plugin is activated the search results are not accurate. When the plugin is deactivated the search works again.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @dnicinski,

    Thank you for your waiting time.

    Please download the latest version of the plugin, then try adding the following code to your theme:

    add_filter('acfbs_is_available', function($status) {
      if (!isset($_POST['action']) || !in_array($_POST['action'], ['acf/fields/post_object/query'])) return $status;
      return false;
    });

    Thanks to this you will be able to turn off search engine at any time. Let me know if this solves your problem?

    Thread Starter d

    (@dnicinski)

    Hi @mateuszgbiorczyk

    That is throwing a lot of errors with PHP_CodeSniffer in WordPress. https://github.com/squizlabs/PHP_CodeSniffer

    FOUND 22 ERRORS AFFECTING 4 LINES
    ———————————————————————-
    500 | ERROR | [x] Opening parenthesis of a multi-line function call
    | | must be the last content on the line
    500 | ERROR | [x] Only one argument is allowed per line in a
    | | multi-line function call
    500 | ERROR | [x] No space after opening parenthesis is prohibited
    500 | ERROR | [x] Expected 1 spaces after opening parenthesis; 0
    | | found
    500 | ERROR | [x] No space before closing parenthesis is prohibited
    501 | ERROR | [x] Multi-line function call not indented correctly;
    | | expected 4 spaces but found 2
    501 | ERROR | [x] Line indented incorrectly; expected at least 1
    | | tabs, found 0
    501 | ERROR | [x] Inline control structures are not allowed
    501 | ERROR | [x] Expected 1 space before “!”; 0 found
    501 | ERROR | [x] Expected 1 space after “!”; 0 found
    501 | ERROR | [x] Expected 1 spaces after opening bracket; 0 found
    501 | ERROR | [x] Expected 1 spaces before closing bracket; 0 found
    501 | ERROR | [ ] Processing form data without nonce verification.
    501 | ERROR | [x] Expected 1 space after “!”; 0 found
    501 | ERROR | [x] Expected 1 spaces after opening bracket; 0 found
    501 | ERROR | [x] Expected 1 spaces before closing bracket; 0 found
    501 | ERROR | [ ] Processing form data without nonce verification.
    501 | ERROR | [x] Missing space after array opener.
    501 | ERROR | [x] Missing space before array closer.
    502 | ERROR | [x] Multi-line function call not indented correctly;
    | | expected 4 spaces but found 2
    502 | ERROR | [x] Line indented incorrectly; expected at least 1
    | | tabs, found 0
    503 | ERROR | [x] Closing parenthesis of a multi-line function call
    | | must be on a line by itself

    How about this instead? ??

    /**
     * ACF Better Search plugin: Turn off search for Post Object field.
     *
     * @param string $status Status.
     */
    function object_acfbs_is_available( $status ) {
    	if ( ! empty( wp_verify_nonce( sanitize_key( $_POST['action'] ) ) ) || ! in_array( $_POST['action'], [ 'acf/fields/post_object/query' ], true ) ) {
    		return $status;
    	} else {
    		return false;
    	}
    }
    add_filter( 'acfbs_is_available', 'object_acfbs_is_available', 10, 2 );
    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Of course. If you use PHP_CodeSniffer standards then this version will be appropriate. Does it work properly for you?

    Thread Starter d

    (@dnicinski)

    Yes. Seems to be working just fine.

    I’ll let you know if any other issues come up.

    Thanks

    Thread Starter d

    (@dnicinski)

    Hi again,

    We ran into the same exact issue with the relationship field – ‘acf/fields/relationship/query’

    Can you send a fix to ignore this field too? https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/

    Thank you!

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @dnicinski, I sent you a filter that you can use.

    Customize it so that it also works for this field.

    Thread Starter d

    (@dnicinski)

    Hi @mateuszgbiorczyk

    The filter seems to be working for both post_object and relationship field together.

    Here’s the code for anyone else if needed…

    if ( ! empty( wp_verify_nonce( sanitize_key( $_POST[‘action’] ) ) ) || ( ! in_array( $_POST[‘action’], [ ‘acf/fields/post_object/query’ ], true ) && ! in_array( $_POST[‘action’], [ ‘acf/fields/relationship/query’ ], true ) ) ) {

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘ACF Post Object Field’ is closed to new replies.