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

When this plugin is active then there is an issue with the Elementor WordPress plugin #120

Open
Roioo7 opened this issue Oct 7, 2020 · 8 comments
Assignees
Labels

Comments

@Roioo7
Copy link

Roioo7 commented Oct 7, 2020

It seems that that once activating the Multisie Global Media plugin then the "Edit with Elementor" fuction does not work, so pages can not be adited in front end easy way. Every time that I want to edit the Homepage with Elementor, I first need to deactivate this plugin.

@widoz
Copy link
Collaborator

widoz commented Oct 7, 2020

@Roioo7 Could you kindly give us some more context and if it's possible a copy/paste of the console output?
It's possible to open the console in chrome by mouse with right click + Inspect then click on Console tab.

@Roioo7
Copy link
Author

Roioo7 commented Oct 10, 2020 via email

@roperscrossroads
Copy link

roperscrossroads commented Oct 12, 2020

@widoz I am having the same issue using Elementor 3.0.11, Multisite Global Media 0.1.1 and Wordpress 5.5.1.

If I disable Multisite Global Media, I am able to edit pages with Elementor. This is what I see on the console when it is enabled:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
/wp-json/elementor/v1/globals:1

Fatal error: Uncaught Error: Cannot use object of type Closure as array in /var/www/clients/client3/web7/web/wordpress/wp-content/plugins/multisite-global-media/src/Rest/Rest.php:76 Stack trace: #0 /var/www/clients/client3/web7/web/wordpress/wp-includes/class-wp-hook.php(287): MultisiteGlobalMedia\Rest\Rest->restRequestAfterCallbacks(Object(WP_Error), Array, Object(WP_REST_Request)) #1 /var/www/clients/client3/web7/web/wordpress/wp-includes/plugin.php(206): WP_Hook->apply_filters(Object(WP_Error), Array) #2 /var/www/clients/client3/web7/web/wordpress/wp-includes/rest-api/class-wp-rest-server.php(1074): apply_filters('rest_request_af...', Object(WP_Error), Array, Object(WP_REST_Request)) #3 /var/www/clients/client3/web7/web/wordpress/wp-includes/rest-api/class-wp-rest-server.php(376): WP_REST_Server->dispatch(Object(WP_REST_Request)) #4 /var/www/clients/client3/web7/web/wordpress/wp-includes/rest-api.php(339): WP_REST_Server->serve_request('/elementor/v1/g...') #5 /var/www/clients/client3/web7/web/wordpress/wp-includes/cla in /var/www/clients/client3/web7/web/wordpress/wp-content/plugins/multisite-global-media/src/Rest/Rest.php on line 76

There has been a critical error on your website.

I hope this helps!

@widoz
Copy link
Collaborator

widoz commented Oct 13, 2020

@kyushuadamu Thanks for reporting the Error output.

Based on your error the problem seems located at this line https://github.com/bueltge/multisite-global-media/blob/master/src/Rest/Rest.php#L76

!isset($handler['callback'][0]) || !($handler['callback'][0] instanceof WP_REST_Posts_Controller)

Where the $handler['callback'][0] is expected to be $handler['callback'] because it's a callable and not an array.
I had a look at the WordPress code and based on the endpoints initialization here https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-api/class-wp-rest-server.php#L95-L106 where the callback entry is 'callback' => array( $this, 'get_index' ) obviously a callback.

I do not know why the plugin is looking for $handler['callback'][0], need to investigate since it's just used for the conditional and anything else.

cc @oxyc

@oxyc
Copy link
Contributor

oxyc commented Oct 13, 2020

Can't recall unfortunately and don't have access to test it at the moment.

There's quite a few plugins that does this too so I'm guessing it was just from inspecting what was given in the $handler argument and writing a conditional for the particular case–without following docs on the filter.

@widoz widoz added bug 🪲 good first issue Good for newcomers labels Oct 15, 2020
@widoz widoz self-assigned this Oct 15, 2020
@widoz
Copy link
Collaborator

widoz commented Oct 16, 2020

I'll try to work on it this weekend. Basically what's need to be done is to add a proper condition to allow performing the action only for that specific context.

@aldemos
Copy link

aldemos commented Nov 13, 2020

Same here. We are deactivating the plugin in the meantime, I hope you can come out with a solution, we are pretty happy with it otherwise.

@widoz
Copy link
Collaborator

widoz commented Nov 29, 2020

I have made a little research and now it's clear the reason of having the condition (https://github.com/bueltge/multisite-global-media/blob/master/src/Rest/Rest.php#L76).

We want to ensure the REST API request is for Posts and perform the actions only in that case.
I think therefore the PR made by @tecking 👉 #121 make totally sense.

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

No branches or pull requests

5 participants