{"id":20663259,"url":"https://github.com/sitepilot/sitepilot-plugin","last_synced_at":"2025-12-24T04:35:20.355Z","repository":{"id":43467974,"uuid":"464083940","full_name":"sitepilot/sitepilot-plugin","owner":"sitepilot","description":"Brings the powers of Sitepilot directly to your WordPress website. It will revolutionize the way you use, manage and develop WordPress sites.","archived":false,"fork":false,"pushed_at":"2022-11-16T16:05:11.000Z","size":1331,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"1.x","last_synced_at":"2025-03-09T07:02:23.159Z","etag":null,"topics":["framework","laravel","wordpress","wordpress-plugin"],"latest_commit_sha":null,"homepage":"https://sitepilot.io","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sitepilot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-27T08:50:38.000Z","updated_at":"2022-02-27T08:53:27.000Z","dependencies_parsed_at":"2023-01-21T15:17:05.897Z","dependency_job_id":null,"html_url":"https://github.com/sitepilot/sitepilot-plugin","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitepilot%2Fsitepilot-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitepilot%2Fsitepilot-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitepilot%2Fsitepilot-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitepilot%2Fsitepilot-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sitepilot","download_url":"https://codeload.github.com/sitepilot/sitepilot-plugin/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242821486,"owners_count":20190654,"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":["framework","laravel","wordpress","wordpress-plugin"],"created_at":"2024-11-16T19:17:10.670Z","updated_at":"2025-12-24T04:35:20.310Z","avatar_url":"https://github.com/sitepilot.png","language":"PHP","readme":"# Sitepilot\n\n\u003cp\u003e\n    \u003cimg src=\"https://img.shields.io/github/workflow/status/sitepilot/sitepilot-plugin/build\" alt=\"Build Status\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/sitepilot/sitepilot-plugin\" alt=\"Latest Release\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/sitepilot/sitepilot-plugin\" alt=\"License\"\u003e\n\u003c/p\u003e\n\nBrings the powers of Sitepilot directly to your WordPress website. It will revolutionize the way you use, manage and develop WordPress sites. This plugin is optimized for use on the [Sitepilot](https://sitepilot.io) managed WordPress hosting platform but should also work on other platforms.\n\n[🚀 Download the latest release here.](https://github.com/sitepilot/sitepilot-plugin/releases)\n\n![Screenshot](./screenshot.png)\n\n## Plugin \u0026 Theme Development\n\nThis plugin implements the Laravel 8 [service container](https://laravel.com/docs/8.x/container). The service container is a powerful tool for managing class dependencies and performing dependency injection. Dependency injection is a fancy phrase that essentially means this: class dependencies are \"injected\" into the class via the constructor or, in some cases, \"setter\" methods.\n\nYou can use this container in your plugin or theme development workflow by creating a new [Application](./framework/Foundation/Application.php) instance and registering [Service Providers](https://laravel.com/docs/8.x/providers).\n\n```php\nuse Sitepilot\\Framework\\Foundation\\Application;\n\nnew Application('\u003cnamespace\u003e', __FILE__, [\n    \\Sitepilot\\Plugin\\Providers\\BrandingServiceProvider::class,\n]);\n```\n\nA full example of how to implement the service container in your plugin  can be found in [sitepilot.php](./sitepilot.php) and the [app](./app) folder of this plugin. An example of the implementation in a theme can be found [here](https://github.com/sitepilot/theme).\n\n### Namespace\n\nEach application runs in its own unique namespace to prevent conflicts with other registered applications. The namespace is a required parameter of the class constructor and must be the same as the theme or plugin name.\n\n### Service Providers\n\nService providers are the central place of all application bootstrapping. Your own plugin or theme, as well as all of Sitepilot's core services, are bootstrapped via service providers.\n\nAll service providers extend the `Sitepilot\\Framework\\Support\\ServiceProvider` class. Most service providers contain a register and a boot method. Within the register method, you should only bind things into the service container. You should never attempt to register any other piece of functionality within the register method. Otherwise, you may accidentally use a service that is provided by a service provider which has not loaded yet.\n\n#### The register method\n\nLet's take a look at a basic service provider. Within any of your service provider methods, you always have access to the `$app` property which provides access to the service container:\n\n```php \nnamespace Sitepilot\\Plugin\\Branding;\n\nuse Sitepilot\\Plugin\\Services\\BrandingService;\nuse Sitepilot\\Framework\\Support\\ServiceProvider;\n\nclass BrandingServiceProvider extends ServiceProvider\n{\n    public function register(): void\n    {\n        $this-\u003eapp-\u003ealias(BrandingService::class, 'branding');\n    }\n}\n```\n\nThis service provider only defines a `register` method, and uses that method to define an alias for Sitepilot\\Plugin\\Services\\BrandingService in the service container. Now you can access this service using the `branding` property on the application instance. If you're not familiar with Laravel's service container, check out its [documentation](https://laravel.com/docs/8.x/providers).\n\n#### The boot method\n\nSo, what if we need to register WordPress hooks, filters and shortcodes within our service provider? This should be done within the boot method. This method is called after all other service providers have been registered, meaning you have access to all other services that have been registered by the framework. You may type-hint dependencies for your service provider's boot method. The service container will automatically inject any dependencies you need.\n\n```php\nnamespace Sitepilot\\Plugin\\Providers;\n\nuse Sitepilot\\Plugin\\Services\\BrandingService;\nuse Sitepilot\\Framework\\Support\\ServiceProvider;\n\nclass BrandingServiceProvider extends ServiceProvider\n{\n    protected BrandingService $branding;\n\n    public function boot(BrandingService $branding): void\n    {\n        $this-\u003ebranding = $branding;\n    }\n}\n```\n\n_Also the [branding service](./app/Services/BrandingService.php) automatically receives it's dependencies using constructor dependency injection._\n\n#### Hooks \u0026 Shortcodes\n\nEach service provider can register WordPress hooks and shortcodes. The hook and shortcode names are automatically namespaced within the application's namespace and the callbacks are bound the instance of the service provider.\n\n##### Actions\n\n```php\nclass UpdateServiceProvider extends ServiceProvider\n{\n    public function boot(): void\n    {\n        $this-\u003eadd_action('init', '@build_update_checker', 99);\n\n        $this-\u003eapp-\u003eaction('update/booted');\n    }\n\n    public function build_update_checker(UpdateService $update): void\n    {\n        //\n    }\n}\n```\n\nThis service provider registers an action to the WordPress `init` action hook. The `build_update_checker` method automatically recieves it's dependencies because the action callback is prefixed with an @ sign.\n\nAfter all booting methods are executed the service provider runs all callbacks registered to the `\u003capp-namespace\u003e/update/booted` action hook.\n\n_Note: prefixing action callback with an @ sign only works for actions without arguments. The service container does not know how to resolve these arguments._\n\n##### Filters\n\n```php\nclass BrandingServiceProvider extends ServiceProvider\n{\n    public function boot(BrandingService $branding): void\n    {\n        $website = $this-\u003eapp-\u003efilter('branding/website', 'https://sitepilot.io');\n\n        $this-\u003eadd_filter('update_footer', 'filter_admin_footer_version', 11);\n        $this-\u003eadd_filter_value('login_headerurl', $website);\n    }\n\n    public function filter_admin_footer_version(): string \n    {\n        //\n    }\n}\n```\n\nThis service provider registers a filter to the WordPress `update_footer` and `login_headerurl` filter hook. The `\u003capp-namespace\u003e/branding/website` filter is applied to the value of `$website` and the `login_headerurl` filter automatically receives the value of `$website` instead of running a callback. \n\n##### Shortcodes\n\n```php\nclass BrandingServiceProvider extends ServiceProvider\n{\n    public function boot(): void\n    {\n        $this-\u003eadd_shortcode('copyright', 'copyright_shortcode');\n    }\n\n    public function copyright_shortcode($atts): string \n    {\n        $atts = shortcode_atts([\n            // defaults\n        ], $atts);\n\n        return sprintf('\u0026copy; %s %s', get_bloginfo('name'), date('Y'));\n    }\n}\n```\n\nThis service provider registers the shortcode `\u003capp-namespace\u003e_copyright` and the provider's `copyright_shortcode` method is called when the shortcode is rendered.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitepilot%2Fsitepilot-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsitepilot%2Fsitepilot-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitepilot%2Fsitepilot-plugin/lists"}