定制 wordpress-phoenix/abstract-theme-base 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

wordpress-phoenix/abstract-theme-base

Composer 安装命令:

composer require wordpress-phoenix/abstract-theme-base

包简介

PHP class to extend when building a WordPress theme allowing you to follow smart theme setup standards.

README 文档

README

Used as a base class to help standardize the way we build WordPress themes.

CircleCI Build: CircleCI

Table of Contents

Installation

You can use this library to start a new theme from scratch, or you can enhance your existing themes with this library. Once you have read over the installation instructions it should make sense which direction to go.

Composer style (recommended)

  1. Confirm that composer is installed in your development environment using which composer. If CLI does not print any path, you need to install Composer.
  2. Set CLI working directory to wp-content/themes/{your-theme-name}
  3. Install Abstract_Theme class via composer command line like
    composer require wordpress-phoenix/abstract-theme-base
  4. Look at sample code below to see how to include this library in your theme.

Manual Installation

  1. Download the most updated copy of this repository from https://api.github.com/repos/WordPress-Phoenix/abstract-theme-base/zipball
  2. Extract the zip file, and copy the PHP file into your theme project.
  3. Include the file in your theme.

Usage

Why should you use this library when building your theme?

By building your theme using OOP principals, and extending this Theme_Base class object, you will be able to quickly and efficiently build your theme, allowing it to be simple to start, but giving it the ability to grow complex without changing its architecture.

Immediate features include:

  • Built in SPL Autoload for your includes folder, should you follow WordPress codex naming standards for class files.
  • Template class provides you all the best practices for standard theme initialization
  • Minimizes code needed / maintenance of your main theme file.
  • Assists developers new to WordPress theme development in file / folder architecture.
  • By starting all your themes with the same architecture, we create a standard that is better for the dev community.

Simplest example of the main theme functions file, and required theme class file

custom-my-theme.php:

<?php
// Avoid direct calls to this file, because now WP core and framework has been used
if ( ! function_exists( 'add_filter' ) ) {
	header( 'Status: 403 Forbidden' );
	header( 'HTTP/1.1 403 Forbidden' );
	exit();
}

$current_dir = trailingslashit( dirname( __FILE__ ) );

/**
 * 3RD PARTY DEPENDENCIES
 * (manually include_once dependencies installed via composer for safety)
 */
if ( ! class_exists( 'WPAZ_Theme_Base\\V_2_6\\Abstract_Plugin' ) ) {
	include_once $current_dir . 'class-abstract-theme.php';
}

// Maybe load vendor director from theme, if it exists.
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
	include_once( __DIR__ . '/vendor/autoload.php' );
}

/**
 * Load in the main theme application and initialize it.
 */
include_once $current_dir . 'app/class-theme.php';
Mynamespace\Custom_Theme\Theme::run( __FILE__ );

app/class-theme.php:

<?php

namespace Custom\My_theme;

use WPAZ_Theme_Base\V_2_6\Abstract_Theme;

/**
 * Class App
 */
class Theme extends Abstract_Theme {

	public static $autoload_class_prefix = __NAMESPACE__;

	// Set to 2 when you use 2 namespaces in the main app file
	public static $autoload_ns_match_depth = 2;

	public function onload( $instance ) {
		// Nothing yet
	}

	public function init() {
		do_action( static::class . '_before_init' );

		// Do theme stuff usually looks something like
		// $subclass = new OptionalAppSubfolder\Custom_Class_Subclass();
		// $subclass->custom_theme_function();

		do_action( static::class . '_after_init' );
	}

	public function authenticated_init() {
		if ( ! is_user_logged_in() ) {
			return;
		}

		// Ready for wp-admin - but not required
		//$this->admin = new Admin\App( $this );
	}

	protected function defines_and_globals() {
		// None yet.
	}

}

wordpress-phoenix/abstract-theme-base 适用场景与选型建议

wordpress-phoenix/abstract-theme-base 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「theme」 「wordpress」 「boilerplate」 「abstract」 「standardize」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wordpress-phoenix/abstract-theme-base 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wordpress-phoenix/abstract-theme-base 我们能提供哪些服务?
定制开发 / 二次开发

基于 wordpress-phoenix/abstract-theme-base 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2020-03-06