How do I add more than one action to the same plugin?

Source: Internet
Author: User
For example, I have a plugin called Test

class Test_Plugin implements Typecho_Plugin_Interface {    public static function activate() {        Helper::addAction('Test', 'Test_Action');   //Action.php        Helper::addAction('Custom', 'Custom_Action'); //Custom.php    }    ...    ..    .}

I want to add two action, which are test and custom.
This write, access to Action/test is normal, but access Action/custom but error, said can not find.

Could you please add two action to a plugin? If so, how do you write the code?

Reply content:

For example, I have a plugin calledTest

class Test_Plugin implements Typecho_Plugin_Interface {    public static function activate() {        Helper::addAction('Test', 'Test_Action');   //Action.php        Helper::addAction('Custom', 'Custom_Action'); //Custom.php    }    ...    ..    .}

I want to add two action, which are test and custom.
This write, access to Action/test is normal, but access Action/custom but error, said can not find.

Could you please add two action to a plugin? If so, how do you write the code?

widget/do.php Code

if (isset($widgetName) && class_exists($widgetName)) {    $reflectionWidget =  new ReflectionClass($widgetName);    if ($reflectionWidget->implementsInterface('Widget_Interface_Do')) {        $this->widget($widgetName)->action();        return;    }}

Indeed, the Custom_action file include path is custom/action.php, and the class name is Custom_action

One action can handle everything, and if you need to add an action, depending on how the action is accessed, you can only add a new plugins to define it.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.