WordPressMVC

  1. Get Started
  2. Documentation
  3. Tutorials
  4. Blog
  1. Documentation
  2. Tutorials
v1.0.8 Login
  • Blog
  • Download
  • Get Started
  • The Basics
    • Ayuco
    • Main Class
    • Configuration
  • Hooks
    • Actions
    • Filters
    • Widgets
    • Shortcodes
  • MVC
    • Models
    • Post Models
    • Option Models
    • Term Models
    • User Models
    • Views
    • Controllers
  • Resources
    • Assets
    • Styles
    • Scripts
  • Advanced
    • Request
    • Response
    • Localization
    • Cache
    • Logger
    • Database
    • Testing
    • Deployment
    • Functions
    • Add-ons

MVC

Last updated: January 12, 2020

Model–view–controller (MVC) is a software design pattern for implementing user interfaces on computers. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.

[wikipedia]

How does it work?

The MVC implemented in the framework is a modified and improved version of a forked project named Lightweight MVC; it utilizes existing WordPress functionality to prevent overloading the already heavy loaded WordPress core.

Usage

MVC is integrated into the Main Class and can be accessed by calling to the property $this->mvc.

class Main extends Bridge
{
    public function on_admin()
    {
        // Hook "save_post" added using legacy function instead
        // of Main Class definition.
        add_action( 'save_post', array( &$this, 'custom_save_post' ) );
    }
    
    /**
     * Legacy handler for action "save_post".
     * Use of MVC engine.
     */
    public function custom_save_post( $post_id )
    {
        $this->mvc->call( 'PostController@save', $post_id );
    }
}

In the sample above, a WordPress action hook is added to the Main Class using legacy functions (WordPress very own add_action) and in the handler, the MVC property is called.

For more information about how the engine works, see Lightweight MVC documentation.
© 2023 10 Quality Studio . All rights reserved.
Search in: