Within /wp-admin/theme-editor.php, I added some PHP in an attempt to create my own shortcode. When I clicked save:
Parse error: syntax error, unexpected 'post' (T_STRING) in .../wp-content/themes/phenomenon/functions.php on line 21
Indeed, this same error appeared if I tried to go even to the main page of my site. Having no way to go back into the editor and remove the newly added code, I uploaded a backup copy of functions.php via FTP. My site started loading again. Yet when I went into /wp-admin/theme-editor.php, this error still appeared, even though functions.php doesn't have 21 lines of code.
Here is the current / original functions.php:
<?php ?><?php
require_once (TEMPLATEPATH."/scripts/theme-js.php");
include (TEMPLATEPATH."/scripts/custom-scripts.php");
include (TEMPLATEPATH."/scripts/breadcrumbs.php");
include (TEMPLATEPATH."/scripts/write-panels.php");
include (TEMPLATEPATH."/bluzpanel/theme_options.php");
include (TEMPLATEPATH."/includes/shortcodes.php");
include (TEMPLATEPATH."/includes/wp-pagenavi.php");
include (TEMPLATEPATH."/includes/custom-widgets.php");
include (TEMPLATEPATH."/includes/register-sidebars.php");
?>
EDIT: I have verified that I can still use /wp-admin/theme-editor.php when I test it on another computer. Therefore the problem might be unique to my main computer, where I made the changes to function.php.
Magically, /wp-admin/theme-editor.php started working again. It might have been related to my browser somehow caching the the page with the error message, though I believe tried another browser on the same computer and got the same error. Anyway, refreshing the page several times might be the solution.
Related
I have to debug a wordpress site. The backend throws an 404 error on an existing file. (permissions checked, 777 on it did't help)
I can call the url in my browser, the script is shown, but the console still shows the 404 error.
The problem presumably exists since a redesign, where the previous template was copied and edited, but I did not touch the certain files. I can still call the script url from the previous template, it works fine.
The url where the error occurs is: https://sunball-tennis.de/wp-content/themes/sunball%20blue/assets/js/admin.js.php
I'd appreciate any help.
Update 1:
This is how the script is called:
<script type='text/javascript' src='https://www.sunball-tennis.de/wp-content/themes/sunball%20blue/assets/js/admin.js.php?ver=5.0.2'></script>
Update 2:
The call for the script is generated with this code:
wp_register_script('frontact_admin_js', get_bloginfo('template_url').'/assets/js/admin.js.php', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-sortable', 'media-upload', 'thickbox', 'farbtastic', 'jquery-tools-tooltip', 'jquery-uniform'), false, true);
But as I said: It was exactly the same code and files in the previous template and it also still works when I activate the previous template, but not in the actual one. Driving me nuts.
All right I've found an answer. In the beginning of the admin.js.php script was a request for wp-blog-header.php which did not work for unknown reasons. Fixed it with adding
status_header(200);
nocache_headers();
after the request.
Got the solution from: https://wordpress.org/support/topic/integrating-wp-in-external-php-pages/?replies=22 and https://wordpress.stackexchange.com/questions/85384/mysterious-http-404-header-in-my-own-scripts
Cheers!
I have got a WP website running version 4.8.2.
I have created, in the root folder of my theme, a custom php page that includes Wordpress functions with the following code:
<?php
echo 'ralph';
clearstatcache();
echo file_exists('../../../wp-load.php');
require_once('../../../wp-load.php');
echo 'joe';
?>
The end result should be displaying on the page the string 'ralph1joe' (1 stands for the fact that wp-load.php actually exists).
Problem is: when I launch the custom page only the string 'ralph1' is visualized. Any instruction after the require_once line, is ignored. I cannot see any error both on the page and in the log files. The process of the page is simply interrupted.
Is there anything I can do for having the require_once line to work properly ?
I think the problem is with wp_load.php or maybe you haven't read the wp_load.php file correctly.
Wp_load always requires wp_config.php If it doesn't get it it will die with an error. See the below code in wp_load.php file
$die = __( "There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started." ) . '</p>';
With some more identical code like this and error associated with it.
so when you require_once 'wp_load.php' and It doesn't get wp_config.php It will die and stop the execution and you won't get any further print statement
Hope it clarifies you.
I solved the problem. A plugin I had installed caused evidently a conflict.
The plugin is called All 404 Redirect to Homepage
Deactivating it caused my custom page to work properly again.
In my code this error was caused by the required line inside a function. I removed and placed this line at the main code.
I have a WP site, I installed Insert-PHP plugin. (I am really new to WP).
On a new page I wrote in the "text" tab:
[insert_php]
require_once(realpath($_SERVER["DOCUMENT_ROOT"]) ."/firstfolder/nextfolder/test-1.php");
[/insert_php]
Then, in "/firstfolder/nextfolder/test-1_1.php" I have:
<?php
print 'something';
?>
At first I had problems w/ require_once because the path wasn't good. Then I managed and the page was working fine, displaying the word "something" as content.
A few hours later it's not working anymore. If I write PHP code between [insert_php] tags it's doing fine, but if I do the same thing in "test-1.php" nothing happens. No errors or warnings, nothing, just a blank page.
I even tried to write code to force an error and nothing happened. I cleared the cache, I tried created another file w/ that code ... nothing. I intentionally misspelled the path in require_once and that did produce an error.
The only thing happened between the time the code was executing and now is that I installed a "Yoast SEO" plugin.
What could have possibly happen? :(
So, thank you very much for support :| that was great.
I must say that I did not solve the mystery. Maybe I did something wrong somewhere or there is an issue with the "Insert PHP" plugin.
I'll write here what solution I came up with, maybe someone in the future will find a similar problem.
I installed another plugin called "Include Me". I used that to enter the path to the needed php file and after that everything was fine.
I Changed in my address.tpl and errors.tpl file code is not updated Front-End Office.
I am not sure how this happened, but all of a sudden when I make some changes to address.tpl, it doesn't show in front -end.
For example,
I deleted {include file="$tpl_dir./errors.tpl"} line inside address.tpl file and saved the file but when I refresh my browser, no changes there.
Under
Preferences > Performance
Force compile: yes
Cache: no
I am not sure what is causing this problem.
You must be editing a wrong file or are expecting the changes in a wrong page. Try adding something and see if that appears in the source in front-end, if it doesn't then you are doing something wrong.
Moreover the line you are editing (i.e. {include file="$tpl_dir./errors.tpl"}) effect the page only if there are some errors on the page you are expecting the changes.
I have a form that submits to itself and when I submit I get a header and the background but no content on the page, nothing below title in the html. It doesnt write to my database either, no errors, and the styles are there.
I think it has to do with my mysql connection.
I've uploaded everything here https://www.yousendit.com/download/bHlCVWRuTkFTRTUzZUE9PQ
This is for my project as I learn php and mysql and this is a wall I cant get past. Please help!
In index.php file you have:
require_once "quoteit-functions.php";
require_once "quoteit-post.php";
and than you have in quoteit-post.php file:
require_once "quoteit-functions.php";
remove that line because that file is automatic included in that file, instance is used from index.php file.
This was the solution via my teacher late last night:
The main problem that you don't see anything displayed was because you close the connection in quoteit-post.php - and that's before you attempt to reuse "$db" to display and do the count. I moved it out to index.php.