in Education by
I've built my own CMS for learning purposes (and also just for fun), but now I would like to expand it, so that it supports some basic form of extensions (plugins). I would like to work with some kind of observer-pattern where extensions register themselves by the ExtensionManager for certain updates (for example onRenderTitle()). Every extension would consist of one mandatory class ExtensionData that would be executed for every extension in the system. The extensions could register themselves in this class by using a callback (the ExtensionManager would be passed on to every ExtensionData class). But now every extension has to register itself with every page load (because PHP loses state between every page load), causing potential performance problems. Am I doing this completely wrong? Or is this the way to go? I have no experience in writing a CMS that supports extensions (that's what I'm trying to learn). I looked at how Wordpress works with extensions, but I haven't found how it loads them up. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Plugins in Wordpress are registered just by being placed in the wp-content/plugins folder, and they have to have the necessary docblocks in its main file. It is also a convention in WP that your plugin's main file has the same name as your plugin plus the .php extension, e.g. plugins/myplugin/myplugin.php. As far as interaction with the core of your CMS goes, you can have your system to fire events and the plugins would then listen for them. WP uses actions and filters for it. Your code for a simple event listener could look following then: action('action_name', function() { // some code to be executed after event is fired }); Your action() function could just update a global array of actions. When you want to fire the event, you just filter through the array of assigned actions. foreach ($actions['action_name'] as $func) { call_user_func($func); }

Related questions

0 votes
    omar owns a stall selling homemade cosmetics ans wants to launch an e - commerce site. he has lots of ... his business online? Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    I'd like to add a CMS and blog to a web app. One that won't get in the way. There's ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    I know this appears subjective and is likely to be closed but I'll ask anyway. When you use a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I know this appears subjective and is likely to be closed but I'll ask anyway. When you use a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I need a standard deviation function in SQLite. I have found one here: http://www.sqlite.org/contrib ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I have a piece of code which is using Parallel.ForEach, probably based on a old version of Rx ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I would like to get some ideas on to properly handle Salesforce OAuth Consumer Key and Secret in Chrome ... .0 implementation? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Sumit's computer is not working properly. The executable files and programs with extensions, like .com, .exe, ovl, ... his computer? e Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    Sumit's computer is not working properly. The executable files and programs with extensions, like .com, .exe, ... into his computer? Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    Which of the following extensions suggest that the file is a backup copy– (a) Bak (b) Bas (c) Com (d) Txt (e) None of these Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    You want to show file extensions in Windows operating system. How will you do so? Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    What are Reactive Extensions in Microservices?...
asked Jul 24, 2021 in Technology by JackTerrance
0 votes
    What are the correct extensions for saving an HTML file? 1. .hml 2. .xml 3. .html 4. .htm 5. option a and c 6. option c and d...
asked Jul 12, 2021 in Technology by JackTerrance
0 votes
    What is the difference between file extensions .twb and .twbx?...
asked Feb 5, 2021 in Technology by JackTerrance
0 votes
    What are the extensions used by Oracle reports?...
asked Dec 18, 2020 in Technology by JackTerrance
...