{"id":15663644,"url":"https://github.com/alesanchezr/wpas-wordpress-dash","last_synced_at":"2025-05-05T23:17:38.776Z","repository":{"id":56944197,"uuid":"97335911","full_name":"alesanchezr/wpas-wordpress-dash","owner":"alesanchezr","description":"WordPress development made easy: AJAX requests, Model-View-Controller, Restrict User Access, Performance Tuning, Manage Roles, Custom Post Types, etc.","archived":false,"fork":false,"pushed_at":"2020-11-03T05:03:56.000Z","size":236,"stargazers_count":17,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-05T23:17:33.521Z","etag":null,"topics":["wordpress-php-library","wordpress-plugin"],"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/alesanchezr.png","metadata":{"files":{"readme":"README.md","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":"2017-07-15T18:51:47.000Z","updated_at":"2024-02-20T16:52:57.000Z","dependencies_parsed_at":"2022-08-21T02:40:22.067Z","dependency_job_id":null,"html_url":"https://github.com/alesanchezr/wpas-wordpress-dash","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesanchezr%2Fwpas-wordpress-dash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesanchezr%2Fwpas-wordpress-dash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesanchezr%2Fwpas-wordpress-dash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesanchezr%2Fwpas-wordpress-dash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alesanchezr","download_url":"https://codeload.github.com/alesanchezr/wpas-wordpress-dash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252590635,"owners_count":21772941,"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":["wordpress-php-library","wordpress-plugin"],"created_at":"2024-10-03T13:39:06.760Z","updated_at":"2025-05-05T23:17:38.745Z","avatar_url":"https://github.com/alesanchezr.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# WPAS-Wordpress-Dash\n\nAre you a WordPress developer? Then you are probably struggling with the same stuff that I use too truggle every day.\n\n1. MVC Pattern implementation (Model-View-Controller) in WordPress.\n2. Create API's with WordPress very fast.\n\n## Installation\n\n1. Require the library with composer (NOTE: You must be in your Wordpress directory before running this command. The installer will attempt to create your theme in ./wp-content/\u003cyour_theme_directory_name\u003e )\n```sh\n$ composer require alesanchezr/wpas-wordpress-dash:dev-master\n```\n\n2. Create a new theme using the installation script. Or select an already created theme (it will try to create the folder structure automatically)\n```sh\n$ php vendor/alesanchezr/wpas-wordpress-dash/run.php \u003cyour_theme_directory_name\u003e\n```\n\n4. Update the WPASController according to your needs in functions.php\n```php\nuse \\WPAS\\Controller\\WPASController;\n$controller = new WPASController([\n        //Here you specify the path to your consollers folder\n        'namespace' =\u003e 'php\\\\Controllers\\\\'\n    ]);\n```\n\n**Note:** This library expects your theme to load the _vendor/autoload.php_ file in your _functions.php_. A good way of doing that is:\n\n```php\n/**\n* Autoload for PHP Composer and definition of the ABSPATH\n*/\n\n//defining the absolute path for the wordpress instalation.\nif ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');\n\n//including composer autoload\nrequire ABSPATH.\"vendor/autoload.php\";\n```\n\nIf you are working with Flywheel hosting (and/or Flywheel Local), you will need to require the path in the following way:\n\n```php\nif(!strpos($_SERVER['SERVER_NAME'], '.local')){\n  require 'vendor/autoload.php';\n}else{\n  require ABSPATH . 'vendor/autoload.php';\n}\n```\n\nThis is due to the fact that their folder structure separates your content and plugins from the root Wordpress install after you push your site live.\n\n\n## Working with the MVC Pattern\n\n### The Models (Custom Types)\n\nInstanciate the PostTypeManager:\n```php\n    $typeManager = new \\WPAS\\Types\\PostTypesManager([\n        'namespace' =\u003e '\\php\\Types\\\\' \\\\this will be the path to your models folder\n    ]);\n```\nDefine your type in functions.php\n```php\n    //You can react a new custom post type and specify his class\n    $typeManager-\u003enewType(['type' =\u003e 'your_type_slug', 'class' =\u003e 'AnyPostTypeModelClass'])-\u003eregister();\n```\nDefine your type class in the types folder:\n```php\n    namespace php\\Types;\n\n    class AnyPostTypeModelClass extends \\WPAS\\Types\\BasePostType{\n    \n        //any method here\n    }\n```\nNote: you HAVE to extend from the BasePostType class, that is not optional.\n\n[Continue reading about the models](https://github.com/alesanchezr/wpas-wordpress-dash/tree/master/src/WPAS/Types)\n\n### The Controllers\n\nCreate your ***Controller*** classes and bind them to your views, pages, categories, posts, etc.\n```php\n//Here we are saying that we have a class Course.php with a function getCourseInfo that fetches the data needed to render any custom post tipe course\n$controller-\u003eroute([ 'slug' =\u003e 'Single:course', 'controller' =\u003e 'Course' ]);  \n```\nOur Course.php controller class will look like this:\n\n```php\nnamespace php\\Controllers;\n\nclass Course{\n    \n    public function renderCourse(){\n        \n        $args = [];\n        $args['course'] = WP_Query(['post_type' =\u003e 'course', 'param2' =\u003e 'value2', ...);\n        return $args; //Always return an Array type\n    }\n    \n}\n```\n[Continue reading about implementing MVC on your wordpress](https://github.com/alesanchezr/wpas-wordpress-dash/tree/master/src/WPAS/Controller)\n\n## Debugging\n\nOn you wo-config.php file add the following constant:\n```php\ndefine('WP_DEBUG_CONTEXT', true);\n```\nIt will add a top bar with the current template being used.\n\n## Upcomming Experimental Features (Not Stable)\n\n1. Add WordPress roles programatically.\n2. Restrict Role Access to particular pages, posts, categories, etc.\n3. Create and manage all your custom post types in just a few lines of code.\n4. Hit 100% on the [Google Page Speed test](https://developers.google.com/speed/pagespeed/insights/).\n5. Messaging notification system for the WordPress admin user, using the WordPress standards.\n6. Create new [Visual Composer](https://vc.wpbakery.com/) components for your theme in just 5 lines fo code.\n7. Extend [Gravity Forms](http://www.gravityforms.com/) functionality.\n\n### Author\n\n**Alejandro Sanchez**\n\n  *Repository website:* [https://github.com/alesanchezr/wpas-wordpress-dash](https://github.com/alesanchezr/wpas-wordpress-dash)\n  \n  *About me:* [alesanchezr.com](http://alesanchezr.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falesanchezr%2Fwpas-wordpress-dash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falesanchezr%2Fwpas-wordpress-dash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falesanchezr%2Fwpas-wordpress-dash/lists"}