For example, I have a plug-in named Test {code...}. I want to add two actions: Test and Custom .. In this way, it is normal to access actionTest, but an error is reported when you access actionCustom, indicating that no action can be found. Can I add two actions to a plug-in? If you can... for example, I have a plug-in 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 actions: Test and Custom ..
In this way, it is normal to access action/Test, but an error is reported when you access action/Custom, indicating that no action can be found.
Can I add two actions to a plug-in? If yes, how do I write code?
Reply content:
For example, I have a plug-in 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 actions: Test and Custom ..
In this way, it is normal to access action/Test, but an error is reported when you access action/Custom, indicating that no action can be found.
Can I add two actions to a plug-in? If yes, how do I write 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; }}
No. The include path of the Custom_Action file is Custom/Action. php, and the class name is Custom_Action.
A single action can handle everything. If you need to add an action, you can only add a new plugins to define it based on the action access principle.