Download the PHP package mehrshaddarzi/wp-trait without Composer

On this page you can find all versions of the php package mehrshaddarzi/wp-trait. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-trait

Fast and standard development of WordPress plugins

Packagist Packagist Version GitHub repo size

WP-Trait is an easy framework for Standard and Fast development of WordPress plugins according php MVC model.

Table of Contents

Installation

install with WP-CLI

You Can Generate new plugin with WP-Trait Structure:

And fill Your Plugin information e.g. slug and namespace:

Read More About wp-cli-trait-command Package.

install with Composer

1) First Create a new directory in your WordPress plugins dir e.g. wp-content/plugins/wp-user-mobile.

3) Run This Command in your directory:

3) Create plugin main file e.g. wp-user-mobile.php and write:

4) You can add PSR-4 namespace in your Composer.json file:

Create New Model

Generate Model in Command Line

You Can Create new Model With Custom namespace in WP-CLI:

For Example:

or

Generate New Post-Type Model

Generate New Taxonomy Model

Read More Options wp-cli-trait-command Package.

Generate Model manually

1) Add new Admin.php file in src/ dir:

2) For Create new instance from this Class add to plugin main file in instantiate method:

Global Function

You can access to all classes method with global template function by your plugin slug. for example if your plugin slug is wp-user-mobile, you can call method from Admin class:

or use global variables:

This function show Code is Poetry.

How to Change Global variable and function name

You can add global parameters in PHP Main WordPress File:

and Usage:

Also for disable global function set null.

List of arguments when Create new Plugin object:

Model Properties

WordPress Hooks

You can use $actions and $filters property in all class, for example:

Use WPDB

use $this->db for run Query in WordPress Database:

Current Plugin information

For get current plugin information use $this->plugin variable:

Get WordPress default Constants

For get WordPress default Constants use $this->constant variable:

Get WordPress default urls and path:

Time in Seconds and Debug Constants:

Get WordPress Global Variables

For get WordPress global variables use $this->global variable:

WordPress URL Generation

Use $this->url variable:

Get Current User data

for get Current User data use $this->user variable:

Collection Class

This package has list of WordPress helper class, that you can use it.

Post

Attachment

User

Term

Option

Comment

Meta

Meta data list: post, user, term, comment.

Request

Handle Error

Cache and Transient

REST API

Cookie

Session

How to start session in WordPress?

Event

Nonce

File System

List of Methods File Systems {See Collection}:

Email

Log

Collections Lists are available under /Collection.

Views Templates

For use template engine in this package, use Views Collection. Create a folder with name templates in your plugin and put your php file, for example:

For Load students/table.php files in your Model, use render Method:

Overriding templates via a theme

By default, Users who use your plugin can change plugin templates in your active WordPress theme.

For disable Overriding templates in custom file, set false in render method:

Set template attribute

There is several Ways for set attribute:

Trait For WordPress Hooks

This package has list of php trait for WordPress Hooks, that you can uses. trait Lists are available under /Hook.

How To Work Trait Hooks

1) First add trait in your class.

2) every method in your class that have init prefix in method name call in this action:

List Of Trait With Prefix Method Name

Usage Method Prefix Variable option on your model
use Init; init_ public $init;
use AdminAssets; admin_enqueue_scripts_ public $adminAssets;
use AdminFooter; admin_footer_ public $adminFooter;
use AdminInit; admin_init_ public $adminInit;
use AdminMenu; admin_menu_ public $adminMenu;
use AdminSearchBox; get_search_fields_ public $adminSearchBox;
use Ajax; admin_ajax_{$method_name} public $ajax;
use BulkActions; bulk_actions_ & handle_bulk_actions_ public $bulkActions;
use FrontAssets; wp_enqueue_scripts_ public $frontAssets;
use ImageSize; setup_image_size_ public $imageSize;
use Notice; admin_notices_ public $notice;
use PostTypeColumns; columns_ & content_columns_ public $postTypeColumns;
use PreGetQuery; pre_get_posts_ & pre_get_users_ & pre_get_terms_ public $preGetQuery;
use RestAPI; rest_api_init_ public $restAPI;
use RowActions; row_actions_ public $rowActions;
use Shortcode; add_shortcode_ public $shortcode;
use SortableColumns; sortable_columns_ public $sortableColumns;
use TaxonomyColumns; columns_ & content_columns_ public $taxonomyColumns;
use UserColumns; columns_ & content_columns_ public $userColumns;
use UserProfileFields; admin_user_profile_fields_ & save_admin_user_profile_fields_ public $userProfileFields;
use ViewsSub; views_edit_sub_ public $viewsSub;

Example Create Ajax Request with Trait

You can access top ajax request:

Utility

Singleton Design Pattern

For Create a Singleton Design Pattern, use Singleton trait in your Class:

Starter Plugin

You Can read example folder ReadMe.md files /example. and start your project very fast.

Contributing

We appreciate you taking the initiative to contribute to this project. Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

License

The WP-Trait is open-sourced software licensed under the MIT license.


All versions of wp-trait with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-json Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mehrshaddarzi/wp-trait contains the following files

Loading the files please wait ....