$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>wp plugin not working after website live|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

wp plugin not working after website live

matteradmin9PV0评论

Im trying to understand Wordpress plugins, i made a nice little plugin that lets you upload an image to media.

However, this only works on localhost, after i moved the files to my host it stopped working.

The button of my plugin still works, when i click it it redirects me to an empty page.

How should i resolve this issue?

Heres my index: Heres the button:

Tips would be really appreciated.

Im trying to understand Wordpress plugins, i made a nice little plugin that lets you upload an image to media.

However, this only works on localhost, after i moved the files to my host it stopped working.

The button of my plugin still works, when i click it it redirects me to an empty page.

How should i resolve this issue?

Heres my index: https://pastebin/CU7AeGWD Heres the button: https://pastebin/bLG50tJp

Tips would be really appreciated.

Share Improve this question asked Dec 12, 2018 at 8:09 NlsNls 12 bronze badges 2
  • Welcome to this site and plugin development in general! "stopped working" isn't really telling much, have you tried debugging this further? – kero Commented Dec 12, 2018 at 11:00
  • thank you, yes ive done something and now the only error im getting has to do with this: function _custom_menu_page(), so i think i didnt link it correctly , i might be wrong though – Nls Commented Dec 12, 2018 at 11:03
Add a comment  | 

3 Answers 3

Reset to default 0

Please check the following

  • You have checked the URL of your Wordpress installation
  • You have checked that your webhosting is compatible with uploading (file permissions, user rights)
  • You re-saved the permalinks (to make sure that URLs are used correctly)

Edit: This little amount of information gives us little space to work with. Also, please check that you have WP Debug set to true as it might provide you with information that you would normally not get.

First of all, you don't need to include WordPress files from wp-admin folder because you are using media_handle_upload in admin side. They are necessary only when you want to upload from front-end.

So you can remove these lines of codes:

$path = get_home_path();

require_once( $path . 'wp-admin/includes/image.php' );
require_once( $path . 'wp-admin/includes/file.php' );
require_once( $path . 'wp-admin/includes/media.php' );

Then, please try to fill the action attribute of your form using # because the empty value is not valid and it could make issues while submitting form.

Also non of your debug log is related to your codes.

Check media_handle_upload documentation for sample codes.

Edit: In order to debug your code and see what is result of upload, you can use error_log function after activating WP_DEBUG_LOG.

$attachment_id = media_handle_upload( 'fileToUpload', 0);
// Log results.
ob_start();
var_dump( $attachment_id );
error_log( ob_get_clean() );

Then you can check wp-content/debug.log file to see what is happening.

Thanks everyone for helping me and making my code better! This is the solution: function _custom_menu_page(){ include_once DIR . '/index.php'; } It finally works!

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far