Skip to content

Commit

Permalink
Merge branch 'elasticpress_only_once' into 'beta'
Browse files Browse the repository at this point in the history
up

See merge request WordPress/plugin-hacks!20
  • Loading branch information
Helmut Januschka committed Sep 10, 2019
2 parents 09eb466 + 0ea36ec commit c3be66a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ public function add_actions()
//workaround: https://github.com/10up/ElasticPress/pull/1158
add_filter('ep_post_sync_args', [$this, 'ep_post_sync_args'], 10, 2);

add_filter('ep_post_sync_kill', function ($v, $args, $id) {
return true;
}, 999, 3);

add_filter('save_post', [$this, 'krn_index_object'], 9999, 1);
//add_action( 'wp_insert_post', array( $this, 'krn_index_object_w' ), 999, 3 );
add_action('add_attachment', [$this, 'krn_index_object_w'], 999, 3);
add_action('edit_attachment', [$this, 'krn_index_object_w'], 999, 3);

/// ELASITC PRESS

add_filter('acp/filtering/cache/seconds', function ($seconds) {
Expand Down Expand Up @@ -132,6 +141,28 @@ public function add_actions()
});
}

public function krn_index_object_w($a, $b = null, $c = null)
{
$this->krn_index_object($a);
}

public function krn_index_object($post_id)
{
$blocking = true;
$post = get_post($post_id);
if ($post->post_status == 'auto-draft') {
return;
}
if ($post->post_status == 'draft') {
return;
}
if (empty($post)) {
return false;
}
$post_args = ep_prepare_post($post_id);
$response = ep_index_post($post_args, $blocking);
}

public function acf_load_value($value, $post_id, $field)
{
return maybe_unserialize($value);
Expand Down

0 comments on commit c3be66a

Please sign in to comment.