{"id":17696833,"url":"https://github.com/datashaman/wp-controller","last_synced_at":"2025-06-11T14:35:51.230Z","repository":{"id":709833,"uuid":"356505","full_name":"datashaman/wp-controller","owner":"datashaman","description":"WordPress Controller and Plugin classes","archived":false,"fork":false,"pushed_at":"2009-12-10T10:53:53.000Z","size":76,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T00:41:17.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datashaman.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-10-31T20:40:05.000Z","updated_at":"2014-05-22T08:56:06.000Z","dependencies_parsed_at":"2022-07-07T15:08:19.925Z","dependency_job_id":null,"html_url":"https://github.com/datashaman/wp-controller","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Fwp-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Fwp-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Fwp-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Fwp-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datashaman","download_url":"https://codeload.github.com/datashaman/wp-controller/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Fwp-controller/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259280660,"owners_count":22833434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-24T14:45:29.415Z","updated_at":"2025-06-11T14:35:51.207Z","avatar_url":"https://github.com/datashaman.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"WP_Controller: A convenience class which uses the PHP __call method to dynamically define hooks for filters, actions and shortcodes, amongst other things.\n\nFor example:\n\n    class MyController extends WP_Controller\n    {\n      // This is the root of the views folder, which helps the controller\n      // find views when using the render() method\n      public $viewPath = 'somepath';\n\n      public function someOtherMethod()\n      {\n        // Do something with your settings\n        // All settings are available as properties on the controller\n        // using PHP __get and __set. Settings are stored in WP\n        // as \"optionGroup-optionName\" and can be retrieved by the\n        // standard method as get_option(\"optionGroup-optionName\")\n\n        $this-\u003esetting1 = 'blah';\n        echo $this-\u003esetting1;\n        ...\n      }\n\n      public function settings()\n      {\n        // Renders somepath/settings.php with assoc array $data provided as local variables in the view\n        // The view is rendered in the context of the controller, so views can access the controller\n        // as $this.\n        // You can specify a third boolean parameter, which controls if it returns the value or echoes it.\n        // It echoes by default.\n        $data = array(\n          'user' =\u003e 'bob',\n          ...\n        );\n        $this-\u003erender('settings', $data);\n      }\n\n      // Any methods defined as action_* become action hooks\n      public function action_admin_menu()\n      {\n        add_options_page('MyController Settings', 'MyController', 1, 'MyController', array($this, 'settings'));\n      }\n\n      // Any methods defined as filter_* become filter hooks\n      public function filter_the_title($title)\n      {\n        return 'New Title';\n      }\n\n      // Any methods defined as shortcode_* become shortcode hooks\n      public function shortcode_sometag($attributes)\n      {\n        ...\n      }\n    }\n\n    // Subclass and set the properties\n    class MyController extends WP_Controller\n    {\n      public $optionGroup = 'MyController';\n      public $options =\u003e array(\n        'setting1',\n        'setting2',\n      );\n    }\n\n    // or configure using an array\n    $controller = new MyController(array(\n      'optionGroup' =\u003e 'MyController',\n      'options' =\u003e array(\n        'setting1',\n        'setting2',\n      ),\n    ));\n\n    // Or configure with an included file which returns an array\n    $controller = new MyController('config.php');\n    \n    config.php\n    ==========\n    return array(\n      'optionGroup' =\u003e 'MyController',\n      'options' =\u003e array(\n        'setting1',\n        'setting2',\n      ),\n    );\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatashaman%2Fwp-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatashaman%2Fwp-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatashaman%2Fwp-controller/lists"}