I am getting an HTTP ERROR when trying to upload images from the wordpress backend.
Tried a few suggestions of finding the php.ini file but unable to do so via SSH.
Also tried adding the below code
function ms_image_editor_default_to_gd( $editors ) {
$gd_editor = 'WP_Image_Editor_GD';
$editors = array_diff( $editors, array( $gd_editor ) );
array_unshift( $editors, $gd_editor );
return $editors;
}
add_filter( 'wp_image_editors', 'ms_image_editor_default_to_gd' );
Which did not help.
I am using an Ubuntu instance on Amazon Lightsail, Any help will be appreciated.
Related
I am working on a theme (http://lillykauffman.com/wordpress/2017/06/26/hello-world/), which I've done before, but if you try to post a comment, you will be redirected to a blank page. This also happens on the other WP themes such as twentysixteen. Here is the code I have on wp-comments-post.php:
<?php
/**
* Handles Comment Post to WordPress and prevents duplicate comment posting.
*
* #package WordPress
*/
if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
$protocol = $_SERVER['SERVER_PROTOCOL'];
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
$protocol = 'HTTP/1.0';
}
header('Allow: POST');
header("$protocol 405 Method Not Allowed");
header('Content-Type: text/plain');
exit;
}
/** Sets up the WordPress Environment. */
require( dirname(__FILE__) . '/wp-load.php' );
nocache_headers();
$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
if ( is_wp_error( $comment ) ) {
$data = intval( $comment->get_error_data() );
if ( ! empty( $data ) ) {
wp_die( '<p>' . $comment->get_error_message() . '</p>', __( 'Comment Submission Failure' ), array( 'response' => $data, 'back_link' => true ) );
} else {
exit;
}
}
$user = wp_get_current_user();
/**
* Perform other actions when comment cookies are set.
*
* #since 3.4.0
*
* #param WP_Comment $comment Comment object.
* #param WP_User $user User object. The user may not exist.
*/
do_action( 'set_comment_cookies', $comment, $user );
$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) :
$_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
/**
* Filters the location URI to send the commenter after posting.
*
* #since 2.0.5
*
* #param string $location The 'redirect_to' URI sent via $_POST.
* #param WP_Comment $comment Comment object.
*/
$location = apply_filters( 'comment_post_redirect', $location, $comment );
wp_safe_redirect( $location );
exit;
I don't know why this isn't working since it's straight from WP, and other people online had this error because their file was blank, which is not my case. And all of this code looks to be in order. My MySQL version is 5.7 so that shouldn't be the issue, but at this point, I don't even know what's wrong anymore - the code, the installation, my hosting. Any help would be greatly appreciated.
Update: My host advertises full blog, comment and discussion board functionality but I contacted them and they were like, "not really." Apparently they don't support comments or email sending. What a waste. Thanks for everyone's help!
When you look your problem page with inspect manager, you can see that your problem is a 410 code error.
410 Gone
Indicates that the resource requested is no longer available at the server and will not be available again.
This error can occur in several ways.
Here it's the list of somes checkpoint to help you to find the problem:
1. Enable debugging in wp-config.php
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
// Enable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', true );
#ini_set( 'display_errors', 1 );
And test to know if your error appear. You'll be able to fix it quickly.
2. Reset permalink
Don't know why but, sometimes, Wordpress have some weird error du to a old permalink.
I suggest you to
Going to Settings -> Permalinks
Switch permalink setting,
Save,
Replace it to your current configuration,
save it again.
3. Deactivating all plugins.
if its works, activate plugin one by one to be able to detect which one create this error.
4. Refresh your .htaccess
place the basic wordpress .htaccess. Sometimes, some plugins change rules from your .htaccess and provoke many redirections error.
5. Switch your theme for a default theme without modification
It help you to know if a custom rules in your theme create this error.
6. Re-upload the wp-admin and wp-includes from fresh install
7. Reset folders write/read permissions
you can read Changing File permissions in Wordpress to help you to know what you should change and what it should do.
8. ULTIMATELY, Create a fresh install of Wordpress
On my blog when I add some functions for some hooks in functions.php then set feature image not work properly. When I upload the images it says
"An error occurred in the upload. Please try again later"
My added function code to functions.php file
add_action('transition_post_status', 'send_new_post', 10, 3);
// Listen for publishing of a new post
function send_new_post($new_status, $old_status, $post) {
if('publish' === $new_status && 'publish' !== $old_status) {
$post_id = $post->ID;
echo "<script>postId = console.log(".$post_id.")</script>";
}
}
When I remove this function from functions.php file set feature image start working properly.
It's working after giving writable permission to wp-content/uploads folder
When I try to access the plugins or themes section of my wordpress site from the admin panel I am presented with a blank screen. When I run the logs I get the following error:
Navigating to wp-admin/plugins.php:
PHP Fatal error: Call to undefined function wp_json_encode() in /var/lib/openshift/{userID}/app-root/data/current/wp-includes/update.php on line 277
Navigating to wp-admin/themes.php:
PHP Fatal error: Call to undefined function wp_json_encode() in /var/lib/openshift/{userID}/app-root/data/current/wp-includes/update.php on line 440
Solutions online indicated that I should re-add the function, or re-install Wordpress. Without access to the core files, I downloaded a local repository of the application (but noticed it did not contain any of the plugins or themes I had uploaded via the admin interface).
I extracted a plugin and theme (placing them in the respective directories) then pushed the changes to production in the hopes that it would extract and re-install an updated version of wordpress. I then restarted the app.
The error still persists and I can not validate if the plugin or theme I uploaded were installed. Is there a way to refresh or reinstall a wordpress instance on Openshift?
I'm wondering how I can fix this issue without creating a new gear and migrating my data via the database. Note: Front end is working fine.
Version of Wordpress: 4.1.1
I ended up connecting to the app via SFTP and modified the file the following directly
/var/lib/openshift/{userID}/app-root/data/current/wp-includes/functions.php
and added the following function:
function wp_json_encode( $data, $options = 0, $depth = 512 ) {
/*
* json_encode() has had extra params added over the years.
* $options was added in 5.3, and $depth in 5.5.
* We need to make sure we call it with the correct arguments.
*/
if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
$args = array( $data, $options, $depth );
} elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
$args = array( $data, $options );
} else {
$args = array( $data );
}
$json = call_user_func_array( 'json_encode', $args );
// If json_encode() was successful, no need to do more sanity checking.
// ... unless we're in an old version of PHP, and json_encode() returned
// a string containing 'null'. Then we need to do more sanity checking.
if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) {
return $json;
}
try {
$args[0] = _wp_json_sanity_check( $data, $depth );
} catch ( Exception $e ) {
return false;
}
return call_user_func_array( 'json_encode', $args );
}
Ref: https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-wp_json_encode-in
I've inherited a Wordpress project and I am trying to get it set up. I have zero experience in Wordpress and may as well say I have zero PHP experience. So far I've managed to get the environment set up on my local machine but I am stuck on a PHP parse error which I cannot find a solution for by googling. I'd like to at least get the existing project running on my machine.
When I open up my site locally I get redirected to $ROOT/wp-admin/install.php and I get this error in the apache error_log:
[Wed Oct 22 22:32:42 2014] [error] [client ::1] PHP Parse error: parse error in /path/to/project/wp-content/mu-plugins/wpengine-common/plugin.php on line 788
Line 788 is
public function disable_indiv_plugin_update_notices( $value ) {
and the surrounding code is
function wpengine_credits() {
if ( get_option( 'stylesheet' ) != 'twentyeleven' && get_option( 'template' ) != 'twentyeleven' )
return false;
if ( !defined('WPE_FOOTER_HTML') OR !WPE_FOOTER_HTML OR $this->already_emitted_powered_by == true )
return false;
//to prevent repeating
$this->already_emitted_powered_by = true; ?>
<div id="site-host">
WP Engine <?php printf( __( '%s.', 'wpengine' ), 'WordPress Hosting' ); ?>
</div>
<?php
}
public function disable_indiv_plugin_update_notices( $value ) {
$plugins_to_disable_notices_for = array();
$basename = '';
foreach ( $plugins_to_disable_notices_for as $plugin )
$basename = plugin_basename( $plugin );
if ( isset( $value->response[#$basename] ) )
unset( $value->response[$basename] );
return $value;
}
public function get_powered_by_html( $affiliate_code = null ) {
if ( ( ! defined('WPE_FOOTER_HTML') OR !WPE_FOOTER_HTML ) AND !$this->is_widget ) return "";
$this->already_emitted_powered_by = true;
if(WPE_FOOTER_HTML !== "") {
$html = WPE_FOOTER_HTML;
} else {
$html = $this->view('general/powered-by',array('affiliate_code'=>$affiliate_code),false);
}
return "<span class=\"wpengine-promo\">$html</span>";
}
I have a feeling it has to do with my PHP version. I am running PHP 5.4.30. Other solutions to similar problems suggested using
Any suggestions would be appreciated.
Delete the mu-plugins folder in you LOCAL environment... the error you are seeing is a special plugin run by WP Engine on their servers for internal use. It will, as you can see, fail if run outside the WP Engine environment.
Just make sure you don't delete the mu-plugins folder on the WP Engine server when you are putting the local environment back up to production!
I connect to Mongodb using the PECL PHP module Mongo. But I'm unable to find a solution to perform a custom server side sorting by passing an own Javascript function to the server.
$client = new \MongoClient( 'mongodb://localhost:27017', array() );
$collection = $client->selectCollection( 'mydata', 'users' );
$cursor = $collection->find( <my-query> );
$cursor->sort( <custom-sorting> );
In the Mongodb console this command works fine:
db.eval(
function() {
return db.users.find().toArray().sort(
function( doc1, doc2 ) {
return doc1.email < doc2.email;
}
)
}
);
But I'm unable to pass such a sorting function to the server using the PECL module. I found nothing in the documentation until yet.