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

See if filter simple_history/log_query_inner_where can be brought back #455

Closed
bonny opened this issue Aug 1, 2024 · 2 comments
Closed
Assignees

Comments

@bonny
Copy link
Owner

bonny commented Aug 1, 2024

This was probably removed when doing the big sql query rewrite
#409

Related: #341

@bonny
Copy link
Owner Author

bonny commented Aug 1, 2024

The format has changed, so the inner query can be modified with a new filter:

// Modify query so it returns nothing.
add_filter('simple_history/log_query_inner_where_array', function($inner_where, $args) {
  $inner_where[] = "1 = 0";
  return $inner_where;
}, 10, 2);

@1ucay
Copy link

1ucay commented Aug 1, 2024

Nice, thank you, working ok!

add_filter( 'simple_history/log_query_inner_where_array', function( $inner_where, $args ) {

    $simple_history = \Simple_History\Simple_History::get_instance();
    $contexts_table_name = $simple_history->get_contexts_table_name();

    $inner_where[] = sprintf(
        'id IN ( SELECT history_id FROM %1$s AS c WHERE c.key = "_user_id" AND c.value != "%2$s" )',
        $contexts_table_name,
        1
    );

    $inner_where[] = sprintf(
        'id IN ( SELECT history_id FROM %1$s AS c WHERE c.key = "post_type" AND c.value IN ("%2$s") )',
        $contexts_table_name,
        implode( '","', array( 'post', 'page', 'event' ) )
    );

    return $inner_where;
}, 10, 2 );     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants