PHP Fatal error: Cannot declare class Emogrifier, because the name is already in use
I'm currently trying to inline css with a html content which works perfect but only once. When I try it multiple times I'm getting this error:
PHP Fatal error: Cannot declare class Emogrifier, because the name is
already in use
The error is thrown in the email-functions.php wich gets included in my Wordpress child theme functions.php file:
/**
* Include email functions for ultimate member
*/
require 'ultimate-member/functions/email-functions.php';
This is the function in the email-functions.php file which causes the problem:
/**
* Apply css to UM email message from template
*/
add_filter( 'um_email_send_message_content', 'apply_style_to_email', 10, 99);
function apply_style_to_email($message, $slug, $args )
//Get Emogrifier class
include_once get_home_path() . 'wp-content/themes/DiviChild/ultimate-member/libraries/class-emogrifier.php';
ob_start();
include_once get_home_path() . 'wp-content/themes/DiviChild/woocommerce/emails/email-styles.php';
$css = apply_filters( 'woocommerce_email_styles', ob_get_clean() );
// apply CSS styles inline for picky email clients.
try
$emogrifier = new Emogrifier( $message, $css );
$message = $emogrifier->emogrify();
catch ( Exception $e )
$logger = wc_get_logger();
$logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );
return $message;
As you can see I'm using include_once to get the Emogrifier class. I really don't know what I'm doing wrong here.
This is the Emogrifier class: https://codeshare.io/50B0ml
php wordpress woocommerce
add a comment |
I'm currently trying to inline css with a html content which works perfect but only once. When I try it multiple times I'm getting this error:
PHP Fatal error: Cannot declare class Emogrifier, because the name is
already in use
The error is thrown in the email-functions.php wich gets included in my Wordpress child theme functions.php file:
/**
* Include email functions for ultimate member
*/
require 'ultimate-member/functions/email-functions.php';
This is the function in the email-functions.php file which causes the problem:
/**
* Apply css to UM email message from template
*/
add_filter( 'um_email_send_message_content', 'apply_style_to_email', 10, 99);
function apply_style_to_email($message, $slug, $args )
//Get Emogrifier class
include_once get_home_path() . 'wp-content/themes/DiviChild/ultimate-member/libraries/class-emogrifier.php';
ob_start();
include_once get_home_path() . 'wp-content/themes/DiviChild/woocommerce/emails/email-styles.php';
$css = apply_filters( 'woocommerce_email_styles', ob_get_clean() );
// apply CSS styles inline for picky email clients.
try
$emogrifier = new Emogrifier( $message, $css );
$message = $emogrifier->emogrify();
catch ( Exception $e )
$logger = wc_get_logger();
$logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );
return $message;
As you can see I'm using include_once to get the Emogrifier class. I really don't know what I'm doing wrong here.
This is the Emogrifier class: https://codeshare.io/50B0ml
php wordpress woocommerce
add a comment |
I'm currently trying to inline css with a html content which works perfect but only once. When I try it multiple times I'm getting this error:
PHP Fatal error: Cannot declare class Emogrifier, because the name is
already in use
The error is thrown in the email-functions.php wich gets included in my Wordpress child theme functions.php file:
/**
* Include email functions for ultimate member
*/
require 'ultimate-member/functions/email-functions.php';
This is the function in the email-functions.php file which causes the problem:
/**
* Apply css to UM email message from template
*/
add_filter( 'um_email_send_message_content', 'apply_style_to_email', 10, 99);
function apply_style_to_email($message, $slug, $args )
//Get Emogrifier class
include_once get_home_path() . 'wp-content/themes/DiviChild/ultimate-member/libraries/class-emogrifier.php';
ob_start();
include_once get_home_path() . 'wp-content/themes/DiviChild/woocommerce/emails/email-styles.php';
$css = apply_filters( 'woocommerce_email_styles', ob_get_clean() );
// apply CSS styles inline for picky email clients.
try
$emogrifier = new Emogrifier( $message, $css );
$message = $emogrifier->emogrify();
catch ( Exception $e )
$logger = wc_get_logger();
$logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );
return $message;
As you can see I'm using include_once to get the Emogrifier class. I really don't know what I'm doing wrong here.
This is the Emogrifier class: https://codeshare.io/50B0ml
php wordpress woocommerce
I'm currently trying to inline css with a html content which works perfect but only once. When I try it multiple times I'm getting this error:
PHP Fatal error: Cannot declare class Emogrifier, because the name is
already in use
The error is thrown in the email-functions.php wich gets included in my Wordpress child theme functions.php file:
/**
* Include email functions for ultimate member
*/
require 'ultimate-member/functions/email-functions.php';
This is the function in the email-functions.php file which causes the problem:
/**
* Apply css to UM email message from template
*/
add_filter( 'um_email_send_message_content', 'apply_style_to_email', 10, 99);
function apply_style_to_email($message, $slug, $args )
//Get Emogrifier class
include_once get_home_path() . 'wp-content/themes/DiviChild/ultimate-member/libraries/class-emogrifier.php';
ob_start();
include_once get_home_path() . 'wp-content/themes/DiviChild/woocommerce/emails/email-styles.php';
$css = apply_filters( 'woocommerce_email_styles', ob_get_clean() );
// apply CSS styles inline for picky email clients.
try
$emogrifier = new Emogrifier( $message, $css );
$message = $emogrifier->emogrify();
catch ( Exception $e )
$logger = wc_get_logger();
$logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );
return $message;
As you can see I'm using include_once to get the Emogrifier class. I really don't know what I'm doing wrong here.
This is the Emogrifier class: https://codeshare.io/50B0ml
php wordpress woocommerce
php wordpress woocommerce
edited Nov 12 at 14:36
Johnny97
332319
332319
asked Nov 12 at 13:40
Mr. Jo
550114
550114
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The error describes your problem quite well. It looks like there are 2 classes with the same name in your project. Here a NameSpace could help you.
It's best to search your project files for the keyword "emogrifier", maybe you have the class 2 times in the project. Or the class comes from one of the vendor directories via Composer, but that should not happen with the Composer Packages NameSpaces.
http://php.net/manual/de/language.namespaces.php
Thanks! You were right. Found a duplicate.
– Mr. Jo
Nov 12 at 21:00
add a comment |
You probably need to use require_once(), which does exactly what it says.
If you require() a file that has already been required, PHP doesn't care: it reads the source-file again, leading to this error. Whereas, require_once() will read the source-file only if it hasn't already been read before.
Replace include_one with require_one but the issue is still there: [12-Nov-2018 14:34:49 UTC] PHP Fatal error: Cannot declare class Emogrifier, because the name is already in use
– Mr. Jo
Nov 12 at 14:36
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263433%2fphp-fatal-error-cannot-declare-class-emogrifier-because-the-name-is-already-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The error describes your problem quite well. It looks like there are 2 classes with the same name in your project. Here a NameSpace could help you.
It's best to search your project files for the keyword "emogrifier", maybe you have the class 2 times in the project. Or the class comes from one of the vendor directories via Composer, but that should not happen with the Composer Packages NameSpaces.
http://php.net/manual/de/language.namespaces.php
Thanks! You were right. Found a duplicate.
– Mr. Jo
Nov 12 at 21:00
add a comment |
The error describes your problem quite well. It looks like there are 2 classes with the same name in your project. Here a NameSpace could help you.
It's best to search your project files for the keyword "emogrifier", maybe you have the class 2 times in the project. Or the class comes from one of the vendor directories via Composer, but that should not happen with the Composer Packages NameSpaces.
http://php.net/manual/de/language.namespaces.php
Thanks! You were right. Found a duplicate.
– Mr. Jo
Nov 12 at 21:00
add a comment |
The error describes your problem quite well. It looks like there are 2 classes with the same name in your project. Here a NameSpace could help you.
It's best to search your project files for the keyword "emogrifier", maybe you have the class 2 times in the project. Or the class comes from one of the vendor directories via Composer, but that should not happen with the Composer Packages NameSpaces.
http://php.net/manual/de/language.namespaces.php
The error describes your problem quite well. It looks like there are 2 classes with the same name in your project. Here a NameSpace could help you.
It's best to search your project files for the keyword "emogrifier", maybe you have the class 2 times in the project. Or the class comes from one of the vendor directories via Composer, but that should not happen with the Composer Packages NameSpaces.
http://php.net/manual/de/language.namespaces.php
answered Nov 12 at 14:51
episch
304114
304114
Thanks! You were right. Found a duplicate.
– Mr. Jo
Nov 12 at 21:00
add a comment |
Thanks! You were right. Found a duplicate.
– Mr. Jo
Nov 12 at 21:00
Thanks! You were right. Found a duplicate.
– Mr. Jo
Nov 12 at 21:00
Thanks! You were right. Found a duplicate.
– Mr. Jo
Nov 12 at 21:00
add a comment |
You probably need to use require_once(), which does exactly what it says.
If you require() a file that has already been required, PHP doesn't care: it reads the source-file again, leading to this error. Whereas, require_once() will read the source-file only if it hasn't already been read before.
Replace include_one with require_one but the issue is still there: [12-Nov-2018 14:34:49 UTC] PHP Fatal error: Cannot declare class Emogrifier, because the name is already in use
– Mr. Jo
Nov 12 at 14:36
add a comment |
You probably need to use require_once(), which does exactly what it says.
If you require() a file that has already been required, PHP doesn't care: it reads the source-file again, leading to this error. Whereas, require_once() will read the source-file only if it hasn't already been read before.
Replace include_one with require_one but the issue is still there: [12-Nov-2018 14:34:49 UTC] PHP Fatal error: Cannot declare class Emogrifier, because the name is already in use
– Mr. Jo
Nov 12 at 14:36
add a comment |
You probably need to use require_once(), which does exactly what it says.
If you require() a file that has already been required, PHP doesn't care: it reads the source-file again, leading to this error. Whereas, require_once() will read the source-file only if it hasn't already been read before.
You probably need to use require_once(), which does exactly what it says.
If you require() a file that has already been required, PHP doesn't care: it reads the source-file again, leading to this error. Whereas, require_once() will read the source-file only if it hasn't already been read before.
answered Nov 12 at 14:10
Mike Robinson
4,00421021
4,00421021
Replace include_one with require_one but the issue is still there: [12-Nov-2018 14:34:49 UTC] PHP Fatal error: Cannot declare class Emogrifier, because the name is already in use
– Mr. Jo
Nov 12 at 14:36
add a comment |
Replace include_one with require_one but the issue is still there: [12-Nov-2018 14:34:49 UTC] PHP Fatal error: Cannot declare class Emogrifier, because the name is already in use
– Mr. Jo
Nov 12 at 14:36
Replace include_one with require_one but the issue is still there: [12-Nov-2018 14:34:49 UTC] PHP Fatal error: Cannot declare class Emogrifier, because the name is already in use
– Mr. Jo
Nov 12 at 14:36
Replace include_one with require_one but the issue is still there: [12-Nov-2018 14:34:49 UTC] PHP Fatal error: Cannot declare class Emogrifier, because the name is already in use
– Mr. Jo
Nov 12 at 14:36
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263433%2fphp-fatal-error-cannot-declare-class-emogrifier-because-the-name-is-already-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown