Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

You forgot to include screen.php #435

Closed
danieleftodi opened this issue Jun 27, 2019 · 3 comments
Closed

You forgot to include screen.php #435

danieleftodi opened this issue Jun 27, 2019 · 3 comments

Comments

@danieleftodi
Copy link

Solution:

require_once(ABSPATH . 'wp-admin/includes/screen.php');

add it to:

/wp-content/plugins/woo-poly-integration/src/Hyyan/WPI/Emails.php

Three days ago you update the plugin ... and our Gift Card implementation with Yith Gift Cards couldn't send out any e-mails ...

as on line 270 you where refering to an undeclared function ...

$screen = get_current_screen();

Found the solution online, and allied it to screen.php ... and it works again....

@danieleftodi danieleftodi changed the title You for got to include screen.php You forgot to include screen.php Jun 27, 2019
@Jon007
Copy link
Contributor

Jon007 commented Jun 27, 2019

Hi @danieleftodi in what circumstance is this, on which screen?

in admin mode get_current_screen() is normally defined,
the correct fix may probably be to test function_exists( 'get_current_screen') rather than requiring it since on the orders screen where we are sending the emails it is defined..

are you saying that YITH Gift Cards has an admin screen which sends emails and where get_current_screen is not defined?

there are several places in the plugin where get_current_screen() is used and not all of them test for the existence of the function, but they are expected to be called from a standard admin screen which does have the function enabled.

@danieleftodi
Copy link
Author

danieleftodi commented Jun 27, 2019

@Jon007

in admin mode get_current_screen() is normally defined,
the correct fix may probably be to test function_exists( 'get_current_screen') rather than requiring it since on the orders screen where we are sending the emails it is defined..

Well, your plugin has been working for us, but since the last week or so, after all the updates in all the plugins related to "WooCommerce" & Polylang ... it has failed.

are you saying that YITH Gift Cards has an admin screen which sends emails and where get_current_screen is not defined?

In this "Screen" ... when clicking "Send now"

Screenshot 2019-06-27 at 22 08 52

Also, I don't know, but I'm guessing when the system is automatically sending out the "Gift Card" order... when the order is marked as "Payed" in WooCommerce ... it is using the same email function.

there are several places in the plugin where get_current_screen() is used and not all of them test for the existence of the function, but they are expected to be called from a standard admin screen which does have the function enabled.

Could the issue happen since we are using the WP-Security plugin, to change the default /wp-admin/ URL to something else? (this, to make it harder for "crackers" to brute force crack our site...)

@Jon007
Copy link
Contributor

Jon007 commented Jun 27, 2019

@danieleftodi

the WP-Security plugin
I don't know, I have not tried this one..

What this piece of code does is, for any email using standard woocommerce footer text, from address and from name, if we are in admin mode, only attempt to translate these values if the current screen is the order detail screen... .. the reason for doing this is that we can only reliably tell the language when in the current order screen by detecting the language of the global $post object.

These filters are generic - for example also called from the password reminder screen - so do not include any information about the current order as this may not be an order email.

Basically there are several possible solutions and I am trying to understand which is the best one:

  1. simply exit and ignore if get_current_screen is not defined (in admin mode, only translate if on the expected order detail screen viewing a single order)
  2. ignore current screen and get more clever about language detection (check if there is a global post object and it has a language, if not check if Polylang filtered language admin view is set and use the filtered language..) or use the current admin language if no post language available
  3. ..

@Jon007 Jon007 closed this as completed in 7d42820 Jun 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants