Instructor profile php error
-
Hi
When I click “View Full Profile” for the instructor, I see a page with
Warning: DOMDocument::loadHTML(): Empty string supplied as input in /Users/stevep/Documents/overseas/isv/wordpress/wordpress 2/wp-content/plugins/coursepress/includes/classes/class.shortcodes.php on line 2327
WP4, latest CoursePress, CoursePress theme, MarketPress lite active.
thanks
-
Hi @pavarnos,
Thanks for posting on the forum.
As described on your following topic that this is only a simple PHP warning message and not an error therefore it is nothing to worry about.
https://wordpress.org/support/topic/php-error-in-content-course-overviewphp
I have tested it on my test site by setting wp debug on but didn’t get the same warning message that you are getting.
It seems from your both above warning messages that it’s related with instructor avatar.
Have you set the instructor avatar or not?
Are you getting any default avatar as instructor avatar?
Please advise.
Kind Regards,
WPMU DEVHi
Thanks for the quick response. I have disabled avatars. Seems to work OK without avatars on the summary screen.
I disagree with you that warnings can be ignored. Warnings highlight potential issues in your code. They fill up server log files. Quality PHP code runs clean and silent even with its warning level turned up to the maximum
http://programmers.stackexchange.com/questions/139860/what-is-best-practice-for-log-level-in-phpSo if you change your PHP settings to E_ALL | E_STRICT with display_errors on you will see the message and the stack trace. An the other message i mentioned in my earlier post.
The full trace is below. It is too long to fit in a screenshot because it is wrapping in the right column
Warning: DOMDocument::loadHTML(): Empty string supplied as input in /Users/stevep/Documents/overseas/isv/wordpress/wordpress 2/wp-content/plugins/coursepress/themes/coursepress/content-course-overview.php on line 105
Call Stack
# Time Memory Function Location
1 0.0010 232560 {main}( ) ../index.php:0
2 0.0013 235440 require( ‘/Users/stevep/Documents/overseas/isv/wordpress/wordpress 2/wp-blog-header.php’ ) ../index.php:17
3 0.5432 28751392 require_once( ‘/Users/stevep/Documents/overseas/isv/wordpress/wordpress 2/wp-includes/template-loader.php’ ) ../wp-blog-header.php:16
4 0.5649 29063928 include( ‘/Users/stevep/Documents/overseas/isv/wordpress/wordpress 2/wp-content/plugins/coursepress/themes/coursepress/single-course.php’ ) ../template-loader.php:74
5 0.6086 29189800 get_template_part( ) ../single-course.php:14
6 0.6086 29190720 locate_template( ) ../general-template.php:179
7 0.6087 29190928 load_template( ) ../template.php:477
8 0.6092 29245264 require( ‘/Users/stevep/Documents/overseas/isv/wordpress/wordpress 2/wp-content/plugins/coursepress/themes/coursepress/content-course-overview.php’ ) ../template.php:503
9 0.7367 29379272 loadHTML ( ) ../content-course-overview.php:105thanks for your help.
its an excellent plugin: way more usable than many other similar plugins i’ve looked at.Hi @pavarnos,
Thank you for your detailed reply.
I don’t want you to ignore warnings and also we will not ignore it but will fix it. What i was telling you that not to worry because severity of warning is lesser than error and warning is not error, most users confused between these two.
You will find more information about warning, notices and errors on the following page.
http://php.net/manual/en/errorfunc.constants.php
I could reproduce this warning message on my test site by disabling avatar from Discussion Settings therefore i have notified the plugin developer to fix it.
In the meanwhile to resolve this warning message could you please try editing the following code on line number 2325 in the following coursepress plugin file.
Coursepress plugin file :
plugins\coursepress\includes\classes\class.shortcodes.phpBefore Editing :
$doc = new DOMDocument(); $doc->loadHTML( get_avatar( $instructor_id, $thumb_size ) ); $imageTags = $doc->getElementsByTagName( 'img' ); $content = ''; foreach ( $imageTags as $tag ) { $avatar_url = $tag->getAttribute( 'src' ); } ?> <?php $content .= '<div class="instructor-avatar">'; $content .= '<div class="' . $class . '" style="background: url( ' . $avatar_url . ' );"></div>'; $content .= '</div>';After Editing :
if(get_avatar( $instructor_id, $thumb_size ) != ''){ $doc = new DOMDocument(); $doc->loadHTML( get_avatar( $instructor_id, $thumb_size ) ); $imageTags = $doc->getElementsByTagName( 'img' ); $content = ''; foreach ( $imageTags as $tag ) { $avatar_url = $tag->getAttribute( 'src' ); } ?> <?php $content .= '<div class="instructor-avatar">'; $content .= '<div class="' . $class . '" style="background: url( ' . $avatar_url . ' );"></div>'; $content .= '</div>'; }Best Regards,
WPMU DEVthanks. that should work. will look forward to this fix in your next version or so?
Hi @pavarnos,
Yes it will be fixed in the future version of plugin as i have already notified this to the CoursePress plugin developer.
Have a nice day!
Cheers,
WPMU DEV
The topic ‘Instructor profile php error’ is closed to new replies.