开发者

Template php code for calling class within template

开发者 https://www.devze.com 2023-02-15 02:17 出处:网络
I have just developed a Wordpress plugin and it is all structured within a class called isimpledesign_feeds_class() so everything works fine and i am calling a function out from the class using.

I have just developed a Wordpress plugin and it is all structured within a class called isimpledesign_feeds_class() so everything works fine and i am calling a function out from the class using.

<?php 
$isimpledesign = new isimpledesign_feeds_class(); 
$isimpledesign->isimpledesign_feeds(); 
?>
开发者_Go百科

i was just wondering if their is a problem calling it like this because from previous plugins i have always used

<?php 
if (function_exists('isimpledesign_feeds')) { 
    isimpledesign_feeds(); 
}
?>

to call a function in the theme files.

Just wondering if anyone has any suggestions?

Is this the correct way to call a function from a class in Wordpress?

Thanks


The first call is more object oriented the second seems to be a "old-school" version of the same plugin. If the first version works there is no problem!


Usually theme files of Wordpress do not have classes in it. So it was working.

But in your plugin you are using Class. So it is not possible to call any function of class without using object of that class or using classname.

0

精彩评论

暂无评论...
验证码 换一张
取 消