10up / classifai

Supercharge WordPress Content Workflows and Engagement with Artificial Intelligence.
https://classifaiplugin.com
GNU General Public License v2.0
579 stars 53 forks source link

Potential enhancements to the Smart 404 Feature #802

Open dkotter opened 1 month ago

dkotter commented 1 month ago

Is your enhancement related to a problem? Please describe.

In #801, a new Smart 404 Feature was added. As mentioned in a comment, I think there are a few additional things we can look to do.

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct

jeffpaul commented 1 month ago

@felipeelia any advice on?:

Add better check to ensure ElasticPress isn't just installed and active but is actually configured properly. I don't think we need to go so far as to check that our mapping exists (and thus a sync has run) but ensuring it's actually connected to elasticsearch before we allow the Feature to be set up would be nice. I'd suggest we look at the ElasticPress code to see if there's a helper function or method we can use

felipeelia commented 1 month ago

If you simply want to check if the plugin connected to ES at some point in the recent past, you can use Elasticsearch::factory()->get_elasticsearch_version( false );, as seen here.

To check if a mapping exists, you can use Indexables::factory()->get( 'post' )->get_mapping() (which will actually send a request to ES) or Indexables::factory()->get( 'post' )->determine_mapping_version() to use a cached value.