Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionI've wrote a Wordpress plugin, it works well offline on my local website, but not when I put it in production ? The installation works very well but the activation button is not working... Is someone know how to fix this issue ?
Thanks for futures answer !
More Information maybe, the plugin uses composer and PhpSpreadReader, I know it need some particular php library, i'm hosted at OVH ! Maybe there is no the library installed on the server ?
Closed. This question is off-topic. It is not currently accepting answers.if (!defined('EXCELREADER_TEMPLATE_URL')) define('EXCELREADER_TEMPLATE_URL', dirname(FILE) . "/templates");
if (!defined('EXCELREADER_URL')) define('EXCELREADER_URL', plugin_dir_url(FILE));
if (!defined('EXCELREADER_COMPOSER_URL')) define('EXCELREADER_COMPOSER_URL', dirname(FILE) . "/vendor");
ini_set('max_execution_time', 300);
include 'vendor/autoload.php'; require 'includes/class-php-spread-reader.php'; require 'includes/widget-excel-reader.php';
add_action('plugins_loaded', 'excelreader');
add_filter('admin_init', 'check_if_we_should_change_upload_dir', 999);
//This goes inside Plugin A. //When A is activated. activate B. register_activation_hook(FILE, 'excelreader_activate'); function excelreader_activate() { $dependent = 'excelreader.php'; if (is_plugin_inactive($dependent)) { add_action('update_option_active_plugins', 'my_activate_dependent_excelreader'); } }
function my_activate_dependent_excelreader() { $dependent = 'excelreader.php'; activate_plugin($dependent); }
// Register and load the widget function wpb_load_widget() { register_widget('excelreader_widget'); }
add_action('widgets_init', 'wpb_load_widget');
class ExcelReader { /** * * Chemin du dossier où sont sauvegarder les xlsx déja entrée * */ private $dirfxlxs;
/**
* * Instance de la classe PhpSpreadReader * */ private $phpspread;
protected static $instance; public static function get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; } /**
* * Constructeur * */ public function construct() { // Admin page calls: sql_install(); add_action('admin_menu', array(&$this, 'addAdminMenu')); add_action('wp_ajax_store_admin_data', array(&$this, 'storeAdminData')); add_action('admin_enqueue_scripts', array(&$this, 'addAdminScripts')); register_activation_hook(__FILE, array(&$this, 'plugin_activate')); //add_action( 'init', array($this,'load_translation') ); }
public function plugin_activate() { if (version_compare(get_bloginfo('version'), '1.0', ' < ')) { deactivate_plugins(basename(__FILE__)); } else { $rlm_rsvplus_options = array( 'db_version' => '1.0', 'event_name' => '', 'end_date' => '', ); update_option('rlm_myplugin_options', $rlm_myplugin_options); } } /**
* * Display the Plugin on admin menu panel * @return void * **/ public function addAdminMenu() { add_menu_page( __('ExcelReader', 'excelreader'), __('ExcelReader', 'excelreader'), 'manage_options', 'excelreader', array($this, 'adminLayout'), '' ); }
/**
* Outputs the Admin Dashboard layout containing the form with all its options * Display on Admin Page * @return void */
public function adminLayout() { $this->display_enter_a_file(); /*if(isset($this->phpspread)) $this->phpspread->display_excelfile();*/ // $this->display_wc_categories(); } /**
* * Affichage du formulaire pour le fichier * @return void **/
public function display_enter_a_file() {
// SOME CODE HERE NOT IMPORTANT CAUSE ALL IS WORKING AT THIS LVL }
/** * * Date pour le fichier XLS Sauvegarde * @return string **/
public function getDateAndTime() { $now = new DateTime(); return $now->getTimestamp(); }
/** * * Sauvergarde du fichier dans wp-content/uploads * @return true **/
public function upload_user_file(array $file) { // Check that the nonce is valid, and the user can edit this post. if ( isset($_POST['my_image_upload_nonce'], $_POST['post_id']) && wp_verify_nonce($_POST['my_image_upload_nonce'], 'my_image_upload') ) { // Let WordPress handle the upload. // Remember, 'my_image_upload' is the name of our file input in our form above. $this->clean_folder(); $attachment_id = media_handle_upload('my_image_upload', $_POST['post_id']);
if (is_wp_error($attachment_id)) { // There was an error uploading the image. echo "Une erreur est survenu a l'upload"; ?><br><?php } else { echo "Fichier Upload"; ?><br><?php $this->phpspread = new PhpSpreadReader(); $this->phpspread->read_file_php_spread(); } } else { echo "Probleme durant l'upload "; ?><br><?php
// The security check failed, maybe show the user an error. } }
/** * * Nettoyer le répertoire du dossier wordpress * @return void **/ public function clean_folder() { $files = glob(wp_upload_dir()['path'] . "/*"); // get all file names foreach ($files as $file) { // iterate files if (is_file($file)) unlink($file); // delete file } }
/** * * Appel des fonctions dans le panel admin * @return void **/ public function addAdminScripts() { } }
ExcelReader::get_instance();
Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionI've wrote a Wordpress plugin, it works well offline on my local website, but not when I put it in production ? The installation works very well but the activation button is not working... Is someone know how to fix this issue ?
Thanks for futures answer !
More Information maybe, the plugin uses composer and PhpSpreadReader, I know it need some particular php library, i'm hosted at OVH ! Maybe there is no the library installed on the server ?
Share Improve this question edited Mar 21, 2019 at 15:49 Oliver asked Mar 21, 2019 at 13:52 OliverOliver 152 silver badges11 bronze badges 5if (!defined('EXCELREADER_TEMPLATE_URL')) define('EXCELREADER_TEMPLATE_URL', dirname(FILE) . "/templates");
if (!defined('EXCELREADER_URL')) define('EXCELREADER_URL', plugin_dir_url(FILE));
if (!defined('EXCELREADER_COMPOSER_URL')) define('EXCELREADER_COMPOSER_URL', dirname(FILE) . "/vendor");
ini_set('max_execution_time', 300);
include 'vendor/autoload.php'; require 'includes/class-php-spread-reader.php'; require 'includes/widget-excel-reader.php';
add_action('plugins_loaded', 'excelreader');
add_filter('admin_init', 'check_if_we_should_change_upload_dir', 999);
//This goes inside Plugin A. //When A is activated. activate B. register_activation_hook(FILE, 'excelreader_activate'); function excelreader_activate() { $dependent = 'excelreader.php'; if (is_plugin_inactive($dependent)) { add_action('update_option_active_plugins', 'my_activate_dependent_excelreader'); } }
function my_activate_dependent_excelreader() { $dependent = 'excelreader.php'; activate_plugin($dependent); }
// Register and load the widget function wpb_load_widget() { register_widget('excelreader_widget'); }
add_action('widgets_init', 'wpb_load_widget');
class ExcelReader { /** * * Chemin du dossier où sont sauvegarder les xlsx déja entrée * */ private $dirfxlxs;
/**
* * Instance de la classe PhpSpreadReader * */ private $phpspread;
protected static $instance; public static function get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; } /**
* * Constructeur * */ public function construct() { // Admin page calls: sql_install(); add_action('admin_menu', array(&$this, 'addAdminMenu')); add_action('wp_ajax_store_admin_data', array(&$this, 'storeAdminData')); add_action('admin_enqueue_scripts', array(&$this, 'addAdminScripts')); register_activation_hook(__FILE, array(&$this, 'plugin_activate')); //add_action( 'init', array($this,'load_translation') ); }
public function plugin_activate() { if (version_compare(get_bloginfo('version'), '1.0', ' < ')) { deactivate_plugins(basename(__FILE__)); } else { $rlm_rsvplus_options = array( 'db_version' => '1.0', 'event_name' => '', 'end_date' => '', ); update_option('rlm_myplugin_options', $rlm_myplugin_options); } } /**
* * Display the Plugin on admin menu panel * @return void * **/ public function addAdminMenu() { add_menu_page( __('ExcelReader', 'excelreader'), __('ExcelReader', 'excelreader'), 'manage_options', 'excelreader', array($this, 'adminLayout'), '' ); }
/**
* Outputs the Admin Dashboard layout containing the form with all its options * Display on Admin Page * @return void */
public function adminLayout() { $this->display_enter_a_file(); /*if(isset($this->phpspread)) $this->phpspread->display_excelfile();*/ // $this->display_wc_categories(); } /**
* * Affichage du formulaire pour le fichier * @return void **/
public function display_enter_a_file() {
// SOME CODE HERE NOT IMPORTANT CAUSE ALL IS WORKING AT THIS LVL }
/** * * Date pour le fichier XLS Sauvegarde * @return string **/
public function getDateAndTime() { $now = new DateTime(); return $now->getTimestamp(); }
/** * * Sauvergarde du fichier dans wp-content/uploads * @return true **/
public function upload_user_file(array $file) { // Check that the nonce is valid, and the user can edit this post. if ( isset($_POST['my_image_upload_nonce'], $_POST['post_id']) && wp_verify_nonce($_POST['my_image_upload_nonce'], 'my_image_upload') ) { // Let WordPress handle the upload. // Remember, 'my_image_upload' is the name of our file input in our form above. $this->clean_folder(); $attachment_id = media_handle_upload('my_image_upload', $_POST['post_id']);
if (is_wp_error($attachment_id)) { // There was an error uploading the image. echo "Une erreur est survenu a l'upload"; ?><br><?php } else { echo "Fichier Upload"; ?><br><?php $this->phpspread = new PhpSpreadReader(); $this->phpspread->read_file_php_spread(); } } else { echo "Probleme durant l'upload "; ?><br><?php
// The security check failed, maybe show the user an error. } }
/** * * Nettoyer le répertoire du dossier wordpress * @return void **/ public function clean_folder() { $files = glob(wp_upload_dir()['path'] . "/*"); // get all file names foreach ($files as $file) { // iterate files if (is_file($file)) unlink($file); // delete file } }
/** * * Appel des fonctions dans le panel admin * @return void **/ public function addAdminScripts() { } }
ExcelReader::get_instance();
- At the moment it does not appear you have the plugin activation code. – Max Yudin Commented Mar 21, 2019 at 14:15
- Thx for your answer MaxYudin have you a documentation for get this code ? – Oliver Commented Mar 21, 2019 at 14:38
- Time delay happened between my comment and your code publications. Now there is the code to scrutinize. – Max Yudin Commented Mar 21, 2019 at 14:55
- I've found the documentation and the register code was here, sorry for my bad copy/pasta ! – Oliver Commented Mar 21, 2019 at 14:58
- I've always the proplem, if i've found a solution i put it... Please if someone can help i will be very gratefull... – Oliver Commented Mar 21, 2019 at 15:46
1 Answer
Reset to default 1Alright the problem was from my hosting and more of that my stupidity, wrong version of php used in production...