Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebkay/oop-wp
A library of OOP style helper classes for WordPress theme and plugin development.
https://github.com/sebkay/oop-wp
oop wordpress wordpress-object-oriented-php wordpress-oop wordpress-php-library
Last synced: about 2 months ago
JSON representation
A library of OOP style helper classes for WordPress theme and plugin development.
- Host: GitHub
- URL: https://github.com/sebkay/oop-wp
- Owner: SebKay
- License: mit
- Created: 2020-06-11T12:08:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-13T08:28:32.000Z (over 2 years ago)
- Last Synced: 2024-10-17T08:51:21.382Z (2 months ago)
- Topics: oop, wordpress, wordpress-object-oriented-php, wordpress-oop, wordpress-php-library
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# OOP WP
[![Test PHP](https://github.com/SebKay/oop-wp/actions/workflows/php.yml/badge.svg)](https://github.com/SebKay/oop-wp/actions/workflows/php.yml)
A simple library of OOP style helper classes for WordPress theme and plugin development.
Most methods in this package are wrappers for already existing functionality like `get_the_title()` or `get_user_meta()`, but they give you a much cleaner (and more modern) way to do so!
## Installation
It's recommended you install this package via [Composer](https://getcomposer.org/).
```bash
composer require sebkay/oop-wp
```You'll need to include the Composer autoloader so you have access to the package. Add the following to the top of your `functions.php` file:
```php
require get_template_directory() . '/vendor/autoload.php';
```## Usage
Wherever you want to use one of the OOP implementations, you can do so like this:
```php
use OOPWP\PostTypes\Post;$blog_post = new Post(get_the_ID());
$blog_post->title();
```### Dates with `nesbot/carbon`
All dates use the [Carbon](https://github.com/briannesbitt/Carbon) PHP library.
```php
use OOPWP\PostTypes\Post;$blog_post = new Post(get_the_ID());
# date() is \Carbon\Carbon object
$blog_post->date()->format('j F Y);
```## Available Classes
### Posts
- `OOPWP\PostTypes\Post`
### Users
- `OOPWP\Users`