suomato/base-camp

一款出色的WordPress起始主题,开发者基于现代网络技术,拥有自己的CLI(命令行界面)。

安装: 489

依赖项: 0

建议者: 0

安全性: 0

星标: 144

关注者: 12

分支: 23

开放问题: 21

类型:wordpress-theme

v1.9.0 2018-11-21 21:21 UTC

README

Dependency Status Dependency Status License

关于Base Camp

一款出色的WordPress起始主题,开发者基于现代网络技术,拥有自己的CLI(命令行界面)。

特性

  • Bulma(基于Flexbox的响应式CSS框架)
  • Timber
    • Twig模板引擎
    • 更干净、更好的代码
    • 将逻辑与展示分离
  • Webpack
    • Sass / Scss用于样式表(生产中最小化)
    • ES6用于JavaScript(生产中最小化)
    • 自动缓存清除
    • 将JavaScript代码拆分为两个块,app.js和vendor.js
    • Vuejs用于加速前端开发
    • BrowserSync用于同步浏览器测试
  • Luna(Base Camp中包含的命令行界面)
  • WooCommerce支持基本脚手架。

要求

安装

  • 进入您的主题文件夹,并运行composer create-project suomato/base-camp
  • cd base-camp
  • yarn npm install
  • 将自定义webpack配置定义到build/config.js文件中
  • yarn watch npm run watch
  • 快乐开发 :)

结构

base-camp/                                          # Theme root
├── app/                                            # Theme logic
│   ├── config/                                     # Theme config
│   │   ├── wp/                                     # WordPress specific config
│   │   │   ├── admin-page.php                      # Register here WordPress Admin Page config
│   │   │   ├── image-sizes.php                     # Register here WordPress Custom image sizes
│   │   │   ├── login-page.php                      # Register here WordPress Login Page config
│   │   │   ├── maintenance.php                     # Maintenance mode config
│   │   │   ├── menus.php                           # Register here WordPress navigation menus
│   │   │   ├── scripts-and-styles.php              # Register here WordPress scripts and styles
│   │   │   ├── security.php                        # Things that increase the site security
│   │   │   ├── sidebars.php                        # Register here WordPress sidebars
│   │   │   └── theme-supports.php                  # Register here WordPress theme features
│   │   ├── autoload.php                            # Includes all config files (DON'T REMOVE THIS)
│   │   ├── timber.php                              # Timber specific config
│   │   └── woocommerce.php                         # Init woocommerce support
│   ├── models/                                     # Wrappers for Timber Classes
│   ├── timber-extends/                             # Extended Timber Classes
│   │   └── BaseCampSite.php                        # Extended TimberSite Class
│   ├── bootstrap.php                               # Bootstrap theme
│   ├── helpers.php                                 # Common helper functions
├── build/                                          # Theme assets and views
│   ├── config.js                                   # Custom webpack config
│   ├── webpack.config.js                           # Webpack config
├── resources/                                      # Theme assets and views
│   ├── assets/                                     # Front-end assets
│   │   ├── js/                                     # Javascripts
│   │   │   └── components/                         # Vue Components
│   │   ├── sass/                                   # Styles
│   │   │   └── components/                         # Partials
│   ├── languages/                                  # Language features
│   │   ├── base-camp.pot                           # Template for translation
│   │   └── messages.php                            # Language strings
│   ├── views/                                      # Theme Twig files
│   │   ├── components/                             # Partials
│   │   ├── footer/                                 # Theme footer templates
│   │   └── header/                                 # Theme header templates

模型

模型是Wordpress文章类型和分类的包装类。它们提供了与数据库交互的非常简单的接口。

如何使用

// index.php

<?php

use Basecamp\Models\Post;

// returns an array of TimberPost objects
Post::all();

// returns TimberPost object with the ID 1 (if it exists)
Post::find(1);

// returns first two posts;
Post::take(2)->get();

// skips first two posts;
Post::skip(2)->get();

// returns published posts;
// Supported values: https://codex.wordpress.org/Post_Status#Default_Statuses
Post::status('publish')->get();

// returns all posts except post with ID 1;
Post::exclude([1])->get();

// returns only posts with ID 1;
Post::include([1])->get();

// returns an array of posts descending order by author;
// Supported Values: https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
Post::orderby('author', 'desc')->get();

// returns an array of posts authored by admin;
Post::author('admin')->get();

// returns an array of posts which are in category 'cars' or 'vehicles';
Post::inCategory(['cars', 'vehicles'])->get();

所有查询都是链式调用的。例如,您可以获取由管理员创建的前三个不完整的文章

Post::status('draft')->author('admin')->take(3)->get();

所有模型几乎都能使用每种方法。然而,也有一些例外

  • 只有Post模型有inCategory()方法
  • 分类(分类、标签)有hideEmpty()方法

Luna(命令行界面)

文档