shinepress/framework 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shinepress/framework

最新稳定版本:1.0.0

Composer 安装命令:

composer require shinepress/framework

包简介

Framework for building Wordpress plugins and themes.

README 文档

README

License Latest Version PHP Version Main Status Release Status Develop Status

Description

A framework for creating Wordpress plugins and themes.

Installation

The recommendend installation method is with composer:

$ composer require shinepress/framework

Usage

The core of the framework is the Module class, create registerable modules for plugins and themes by extending it. The configure/initialize/finalize hooks can be overriden to run at specific times.

use ShinePress\Framework\Module;

class MyModule extends Module {
	
	protected function initialize(): void {
		// runs during constructor
	}

	protected function prepare(): void {
		// runs before registration
	}

	protected function cleanup(): void {
		// runs after registration
	}
}

// register the module
MyModule::register();

Attributes

The primary purpose of the framework is to allow the configuration of a plugin/theme component using attributes.

Note: this is an example only, for actions and filters the shinepress/hooks package is recommended.

use ShinePress\Framework\Attribute\MethodAttributeInterface;
use ShinePress\Framework\Module;
use Attribute;
use ReflectionMethod;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class ActionHook implements MethodAttributeInterface {
	private string $name;
	private int $priority;

	public function __construct(string $name, int $priority = 10) {
		$this->name = $name;
		$this->priority = $priority;
	}

	public function register(Module $module, ReflectionMethod $method): void;
		add_action(
			$this->name,
			[$module, $method->getName()],
			$this->priority,
			$method->getNumberOfParameters(),
		);
	}
}

class MyModule extends Module {

	#[ActionHook('save_post', 20)]
	public function onSavePost($post_id, $post, $update): void {
		// do something...
	}
}

MyModule::register();

统计信息

  • 总下载量: 277
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-14