getolympus/olympus-hera

此软件包已被废弃且不再维护。作者建议使用 getolympus/olympus-zeus-core 软件包。

Olympus Zeus 框架核心系统,使您的所有 WordPress 插件和主题开发变得更加简单高效。

资助软件包维护!
Issuehunt

安装: 175

依赖: 0

建议者: 0

安全: 0

星标: 8

关注者: 2

分支: 0

开放问题: 4

类型:框架


README

Olympus Zeus Core 是一个框架,使您所有 WordPress 插件和主题的开发更加简单高效。

composer require getolympus/olympus-zeus-core

Olympus Component CodeFactor Grade Packagist Version Travis Status MIT

特性

With Composer

初始化

要从 WordPress 主题的 functions.php 文件或主插件 php 文件初始化 Zeus Core

// file: functions.php
namespace MyThemeName;

/**
 * Everything starts here.
 *
 * @package MyThemeName
 * @author  Your Name <yourmail@domain-name.ext>
 * @since   x.y.z
 *
 */

// Directory separator and Vendor path.
defined('S')          or define('S', DIRECTORY_SEPARATOR); // Provided by Olympus container
defined('VENDORPATH') or define('VENDORPATH', realpath(dirname(__DIR__)).S.'vendor'.S); // Provided by Olympus container

/**
 * MyThemeName class definition
 */

if (!class_exists('MyThemeName')) {
    /**
     * Use of Zeus abstract PHP class to initialize everything.
     */
    class MyThemeName extends \GetOlympus\Zeus\Zeus
    {
        /**
         * Define all useful folders
         */
        // Load option admin pages
        protected $adminpages = __DIR__.S.'controllers'.S.'adminpages';
        // Load scheduled actions
        protected $crons      = __DIR__.S.'controllers'.S.'crons';
        // Load custom post types
        protected $posttypes  = __DIR__.S.'controllers'.S.'posttypes';
        // Load custom terms
        protected $terms      = __DIR__.S.'controllers'.S.'terms';
        // Load options for users
        protected $users      = __DIR__.S.'controllers'.S.'users';
        // Load custom widgets
        protected $widgets    = __DIR__.S.'controllers'.S.'widgets';

        /**
         * Define WordPress optimizations and configurations in a single var.
         */
        protected $configurations = [
            'AccessManagement' => [/*...*/],
            'Assets'           => [/*...*/],
            'Clean'            => [/*...*/],
            'Menus'            => [/*...*/],
            'Settings'         => [/*...*/],
            'Shortcodes'       => [/*...*/],
            'Sidebars'         => [/*...*/],
            'Sizes'            => [/*...*/],
            'Supports'         => [/*...*/],
        ];

        /**
         * Main function which defines vendors path
         * and some useful actions needed by your application
         */
        protected function setVars()
        {
            // Load Zeus framework vendors.
            if (file_exists($autoload = VENDORPATH.'autoload.php')) {
                include $autoload;
            }

            // Add custom actions.
        }
    }
}

// Instanciate MyThemeName
return new MyThemeName();

自定义帖子类型示例

假设您需要一个新的 Movie 自定义帖子类型,以下是 controllers/posttypes/MoviePosttype.php 内容文件

// file: controllers/posttypes/MoviePosttype.php
namespace MyThemeName\Controllers\Posttypes;

/**
 * Extends main \GetOlympus\Zeus\Posttype\Posttype class to use all functionalities
 */
class MoviePosttype extends \GetOlympus\Zeus\Posttype\Posttype
{
    /**
     * @var array
     */
    protected $args = [
        'menu_icon'     => 'dashicons-video-alt3',
        'supports'      => ['title', 'excerpt', 'thumbnail'],
        'taxonomies'    => ['post_tag'],
        'rewrite'       => [
            'slug'          => 'movie',
            'with_front'    => true,
        ],
    ];

    /**
     * @var string
     */
    protected $slug = 'movie';

    /**
     * Prepare variables.
     */
    public function setVars()
    {
        // Update labels
        $this->setLabels([
            'name'          => __('Movies', 'mythemename'),
            'singular_name' => __('Movie', 'mythemename'),
        ]);

        // Add metabox
        $this->addMetabox(__('Details', 'mythemename'), [
            \GetOlympus\Dionysos\Field\Text::build('link', [
                'title' => __('Movie source URL', 'mythemename'),
            ]),
            \GetOlympus\Dionysos\Field\Text::build('length', [
                'title' => __('Length in seconds', 'mythemename'),
            ]),
            \GetOlympus\Dionysos\Field\Text::build('author', [
                'title' => __('Author name', 'mythemename'),
            ]),
            // (...)
        ]);
    }
}

发布历史

查看 CHANGELOG.md 了解所有详细信息。

贡献

  1. 分叉它 (https://github.com/GetOlympus/Zeus-Core/fork)
  2. 创建您的功能分支 (git checkout -b feature/fooBar)
  3. 提交您的更改 (git commit -am 'Add some fooBar')
  4. 将更改推送到分支 (git push origin feature/fooBar)
  5. 创建一个新的拉取请求

Achraf Chouk 建造,自很久以前以来。