WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin dev] Plugin activation issue : unexpected behavior (1 post)

  1. primo411
    Member
    Posted 6 years ago #

    Hi! I am encounterig problems developping a plugin. I use a hook to call a function when the plugin is activated, it seems to work but it doesn't call the sub-functions called in this function. Let me show you the structure of my code:

    class aixorder{
    
    	function aixorder(){
    		register_activation_hook(__FILE__, array(&$this, 'aixorder_activate'));
    		return true;
    	}
    
    	/* Plugin installation */
    	function aixorder_activate() {
    
                    /* some actions that are well executed */
    
                    /* this call is not done ! */
    		$result = $this->calculate_all_scores();
    
    		return $result;
            }
    
            function calculate_all_scores(){
            /*blabla...*/
            }
    }
    $aixorder = new aixorder;

    It seems that activate_aixorder() is called and executed, but then calculate_all_scores() is not !
    I really don't understand, because when I call it manually by doing this, it works fine and calculate_all_score() is well executed:

    class aixorder{
    
    	function aixorder(){
    		register_activation_hook(__FILE__, array(&$this, 'aixorder_activate'));
    		return true;
    	}
    
    	/* Plugin installation */
    	function aixorder_activate() {
    
                    /* some actions that are well executed */
    
                    /* this call is done ! */
    		$result = $this->calculate_all_scores();
    
    		return $result;
            }
    
            function calculate_all_scores(){
            /*blabla...*/
            }
    }
    $aixorder = new aixorder;
    $aixorder->aixorder_activate();

    So I guess there is something in the activation context I did not understand, as anyone an idea ?

    Thank you for your help !

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags