Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
533 views
in Plugins by
edited by

I need some help about PHP deprecated methods. To be more specific i am using a Q2A plugin on my website called "Ajax Page Loader". Everything works fine except an annoying message/warning at the top of the page which is:

"Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; qa_layer_1_from_qa_ajax_layer_php has a deprecated constructor in xxxxxxxx\qa-include\qa-base.php(595) : eval()'d code on line 2
of xxxxxxxx/qa-plugin/ajax-page-loader/qa-ajax-layer.php "

I checked the plugin's file qa-ajax-layer.php and in there exist indeed the same class and function which is "qa_html_theme_layer".

class qa_html_theme_layer extends qa_html_theme_base
{
    var $plugin_directory;
    var $plugin_url;
    function qa_html_theme_layer($template, $content, $rooturl, $request)
    {
        global $qa_layers;
        $this->plugin_directory = $qa_layers['APL - Ajax Layer']['directory'];
        $this->plugin_url = $qa_layers['APL - Ajax Layer']['urltoroot'];
        qa_html_theme_base::qa_html_theme_base($template, $content, $rooturl, $request);
    }

A tried to change this line from:

qa_html_theme_layer($template, $content, $rooturl, $request)

to

qa_my_function($template, $content, $rooturl, $request)

But the plugin doesnt work. What i have to do so the plugin work and at the same time get rid of the error/warning message about PHP deprecated Methods ? I really dont want to downgrade my PHP back to 5.4!!

@sama55 @scott i need your advices. Thanks

Q2A version: 1.7.4

1 Answer

+3 votes
by
selected by
 
Best answer

Details of this warning is here. I am not confident, but how about this change?

class qa_html_theme_layer extends qa_html_theme_base 

    var $plugin_directory; 
    var $plugin_url; 
    public function __construct($template, $content, $rooturl, $request) 
    { 
        global $qa_layers; 
        $this->plugin_directory = $qa_layers['APL - Ajax Layer']['directory']; 
        $this->plugin_url = $qa_layers['APL - Ajax Layer']['urltoroot']; 
        parent::qa_html_theme_base($template, $content, $rooturl, $request); 
    }

by
I just tried your solution and it works pretty fine @sama55
...