meilisearch-wordpress icon indicating copy to clipboard operation
meilisearch-wordpress copied to clipboard

Given the plugin a shape

Open szepeviktor opened this issue 4 years ago β€’ 26 comments

  • PSR-4
  • PSR-12
  • HookAnnotation

Closes #18

Please like, share and subscribe!

szepeviktor avatar Feb 15 '21 23:02 szepeviktor

Hello again @szepeviktor Remove the Draft PR status when you will need a review πŸš€ We will try to be as reactive as possible, we are sorry if it takes time sometimes, it's often the rush for our team! πŸ˜„

curquiza avatar Feb 16 '21 10:02 curquiza

@timothyjensen Look! πŸ‘€ It is like a rebirth.

szepeviktor avatar Feb 17 '21 15:02 szepeviktor

Development continues πŸš€ e.g. with a search for container ...

szepeviktor avatar Feb 20 '21 13:02 szepeviktor

@curquiza I was struggling with the injector for days. Now it is in place.

Could you read my code?

szepeviktor avatar Mar 06 '21 14:03 szepeviktor

Please be aware that I've already received feedback like

Viktor, this is a WordPress site not a Symfony application

:)

szepeviktor avatar Mar 06 '21 18:03 szepeviktor

Hello @szepeviktor I'll let @eskombro check this PR since he was one of the authors of this repo. He has a lot to do before so it might take time πŸ™‚

curquiza avatar Mar 09 '21 21:03 curquiza

I just want a confirmation that this code meets your expectations.

szepeviktor avatar Mar 09 '21 21:03 szepeviktor

All right - all right. I'm not a developer, I support development with technologies.

Running the plugin is the last step of me writing code. I was just afraid that OOP technologies won't be accepted in a WordPress plugin.

szepeviktor avatar Mar 11 '21 12:03 szepeviktor

Running the plugin is the last step of me writing code.

Oh, that's fine, I just wanted to be sure that I wasn't missing something :)

I was just afraid that OOP technologies won't be accepted in a WordPress plugin.

I don't see any reason why it wouldn't work, and I have seen a few examples (even some small articles talking about it like this one)but this is why I think it would be better to try and run a very basic version of it and make sure everything works together, and then add all the specific functionality, so in case there is a problem with the main plugin structure or some other issue we are not thinking about, we can realize that and correct it early enough!

eskombro avatar Mar 11 '21 13:03 eskombro

I am very 😒 sad, Samuel.

That article.

function __construct( $config ) {
	$this->api_key = $config['api_key'];

	add_filter( 'the_content', array( $this, 'form' ) );
	add_action( 'wp_enqueue_scripts', array( $this, 'assets' ) );
	add_action( 'wp_ajax_msf_form_submit', array( $this, 'submissionHandler' ) );
	add_action( 'wp_ajax_nopriv_msf_form_submit', array( $this, 'submissionHandler' ) );
}

This is also procedural code masqueraded in a class.

Very sad. People are unable to think.

szepeviktor avatar Mar 11 '21 14:03 szepeviktor

so in case there is a problem with the main plugin structure or some other issue we are not thinking about

Before writing code I've made sure I rule the plugin. All its functionality is in my hand, in a tight grip. That is prerequisite of sustainable software.

szepeviktor avatar Mar 11 '21 14:03 szepeviktor

I am very 😒 sad, Samuel. That article.

This is also procedural code masqueraded in a class.

Don't be sad :D

This article is indeed just a guide for people who want to transform their procedural way of coding plugins into OOP, so it is focused on that transition. But it just a simple example.

I don't see any reason to be worried about any OOP principles causing problems on Wordpress plugin development, I have seen polymorphism, inheritance, interfaces, association, abstraction... So it feels safe to me, do you have any specific concern?

Also, don't be sad :)

eskombro avatar Mar 11 '21 17:03 eskombro

do you have any specific concern?

Yes. Reader are made believe that putting functions into a class is called OOP.

An object is a sovereign entity able to do all of its duties without any outside help.

szepeviktor avatar Mar 11 '21 17:03 szepeviktor

do you have any specific concern?

Yes. Reader are made believe that putting functions into a class is called OOP.

An object is a sovereign entity able to do all of its duties without any outside help.

Hahaha, I agree, but let me rephrase:

Do you have any concern regarding the MeiliSearch plugin implementation concerning OOP? :)

eskombro avatar Mar 11 '21 17:03 eskombro

See the immutable configuration class, that is OOP.

szepeviktor avatar Mar 11 '21 17:03 szepeviktor

Do you have any concern regarding the MeiliSearch plugin implementation concerning OOP? :)

No, I strive to eliminate all traces of "WordPress programing" as much as I can. The hook (filter/action) system is inherently procedural so we will have fake classes with hooked methods.

szepeviktor avatar Mar 11 '21 17:03 szepeviktor

Hello @szepeviktor! Do you need help to finalize your PR? You can pass it as Ready for review when you think this is over πŸ™‚

curquiza avatar Apr 06 '21 13:04 curquiza

Yes, I need to wake up!!

szepeviktor avatar Apr 06 '21 13:04 szepeviktor

Take your time, it's ok πŸ™‚ I just needed to know!

curquiza avatar Apr 06 '21 17:04 curquiza

I have no schedule βŒπŸ“† Everything is ASAP.

szepeviktor avatar Apr 06 '21 17:04 szepeviktor

Added missing bits and pieces. Tomorrow I will run the code for the 1st time πŸ₯‡

kΓ©p

szepeviktor avatar Apr 07 '21 01:04 szepeviktor

Should the post not be deleted when it is changes from published to draft?

if ($post->post_status !== 'publish') {
    return $this->deletePostFromIndex($post->ID);
}

$this->indexPost($post);

thijndehaas avatar Mar 28 '22 21:03 thijndehaas

Should the post not be deleted when it is changes from published to draft?

You are right. I've sent this PR without knowing what is the goal of this plugin. When I work I always make plans (docs) before writing code.

szepeviktor avatar Mar 28 '22 22:03 szepeviktor

Hello @szepeviktor and @thijndehaas

FYI we chose to stop working on the meilisearch-wordpress plugin. It does not mean we will not continue the work in the future, but this is currently not the priority :)

Sorry for this, and thanks for your work and comments :)

curquiza avatar Mar 29 '22 09:03 curquiza

Thank you for that ClΓ©mentine! It opens up the possibility for me to publish a plugin.

szepeviktor avatar Mar 29 '22 09:03 szepeviktor

Feel completely free to publish the plugin on your side! πŸ˜„ We appreciate our community's work around Meilisearch!

curquiza avatar Mar 29 '22 09:03 curquiza