{"id":22,"date":"2009-06-23T01:50:08","date_gmt":"2009-06-23T00:50:08","guid":{"rendered":"http:\/\/www.hughdenman.com\/blog\/?p=22"},"modified":"2009-06-23T01:50:08","modified_gmt":"2009-06-23T00:50:08","slug":"error-adding-theme-to-wordpress-28","status":"publish","type":"post","link":"http:\/\/www.hughdenman.com\/blog\/?p=22","title":{"rendered":"Error adding theme to WordPress 2.8"},"content":{"rendered":"<p>I was getting this error:<\/p>\n<p><code>PHP Fatal error:  Call to a member function read() on a non-object in ... \\\\wp-includes\\\\theme.php on line 387<\/code><\/p>\n<p>Fixed it by editing wp-includes\/theme.php, adding &#8216;is_object&#8217; check at line 387 as follows :<\/p>\n<pre>\r\n$template_dir = @ dir(\"$theme_root\/$template\");\r\nif ( $template_dir ) {\r\n\twhile ( ($file = $template_dir->read()) !== false ) {\r\n\t\tif ( preg_match('|^\\.+$|', $file) )\r\n\t\t\tcontinue;\r\n\t\tif ( preg_match('|\\.php$|', $file) ) {\r\n\t\t\t$template_files[] = \"$theme_loc\/$template\/$file\";\r\n\t\t} elseif ( is_dir(\"$theme_root\/$template\/$file\") ) {\r\n\t\t\t$template_subdir = @ dir(\"$theme_root\/$template\/$file\");\r\n                if ( is_object($template_subdir) ) {\r\n                        while ( ($subfile = $template_subdir->read()) !== false ) {\r\n                             if ( preg_match('|^\\.+$|', $subfile) )\r\n                                continue;\r\n                            if ( preg_match('|\\.php$|', $subfile) )\r\n                                $template_files[] = \"$theme_loc\/$template\/$file\/$subfile\";\r\n                        }\r\n                        @ $template_subdir->close();\r\n                    }\r\n                }\r\n\t}\r\n\t@ $template_dir->close();\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I was getting this error: PHP Fatal error: Call to a member function read() on a non-object in &#8230; \\\\wp-includes\\\\theme.php on line 387 Fixed it by editing wp-includes\/theme.php, adding &#8216;is_object&#8217; check at line 387 as follows : $template_dir = @ dir(&#8220;$theme_root\/$template&#8221;); if ( $template_dir ) { while ( ($file = $template_dir->read()) !== false ) { [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/22"}],"collection":[{"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22"}],"version-history":[{"count":7,"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":29,"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions\/29"}],"wp:attachment":[{"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hughdenman.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}