Commit f8b497c5 authored by Michael Iseard's avatar Michael Iseard
Browse files

Initial commit

parents
Pipeline #24 failed with stages
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.php]
indent_size = 4
[resources/views/**.php]
indent_size = 2
module.exports = {
'root': true,
'extends': 'eslint:recommended',
'globals': {
'wp': true,
},
'env': {
'node': true,
'es6': true,
'amd': true,
'browser': true,
'jquery': true,
},
'parserOptions': {
'ecmaFeatures': {
'globalReturn': true,
'generators': false,
'objectLiteralDuplicateProperties': false,
'experimentalObjectRestSpread': true,
},
'ecmaVersion': 2017,
'sourceType': 'module',
},
'plugins': [
'import',
],
'settings': {
'import/core-modules': [],
'import/ignore': [
'node_modules',
'\\.(coffee|scss|css|less|hbs|svg|json)$',
],
},
'rules': {
'no-console': 0,
'quotes': ['error', 'single'],
'comma-dangle': [
'error',
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'ignore',
},
],
},
};
# Include your project-specific ignores in this file
# Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
.cache-loader
dist
node_modules
npm-debug.log
yarn-error.log
/vendor
resources/assets/config-local.json
module.exports = {
'extends': 'stylelint-config-standard',
'rules': {
'no-empty-source': null,
'string-quotes': 'double',
'at-rule-no-unknown': [
true,
{
'ignoreAtRules': [
'extend',
'at-root',
'debug',
'warn',
'error',
'if',
'else',
'for',
'each',
'while',
'mixin',
'include',
'content',
'return',
'function',
'tailwind',
'apply',
'responsive',
'variants',
'screen',
],
},
],
},
};
This diff is collapsed.
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at team@roots.io. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
Copyright (c) Ben Word and Scott Walkinshaw
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# [Sage](https://roots.io/sage/)
[![Packagist](https://img.shields.io/packagist/vpre/roots/sage.svg?style=flat-square)](https://packagist.org/packages/roots/sage)
[![devDependency Status](https://img.shields.io/david/dev/roots/sage.svg?style=flat-square)](https://david-dm.org/roots/sage#info=devDependencies)
[![Build Status](https://img.shields.io/travis/roots/sage.svg?style=flat-square)](https://travis-ci.org/roots/sage)
Sage is a WordPress starter theme with a modern development workflow.
## Features
* Sass for stylesheets
* Modern JavaScript
* [Webpack](https://webpack.github.io/) for compiling assets, optimizing images, and concatenating and minifying files
* [Browsersync](http://www.browsersync.io/) for synchronized browser testing
* [Blade](https://laravel.com/docs/5.6/blade) as a templating engine
* [Controller](https://github.com/soberwp/controller) for passing data to Blade templates
* CSS framework (optional): [Bootstrap 4](https://getbootstrap.com/), [Bulma](https://bulma.io/), [Foundation](https://foundation.zurb.com/), [Tachyons](http://tachyons.io/), [Tailwind](https://tailwindcss.com/)
See a working example at [roots-example-project.com](https://roots-example-project.com/).
## Requirements
Make sure all dependencies have been installed before moving on:
* [WordPress](https://wordpress.org/) >= 4.7
* [PHP](https://secure.php.net/manual/en/install.php) >= 7.1.3 (with [`php-mbstring`](https://secure.php.net/manual/en/book.mbstring.php) enabled)
* [Composer](https://getcomposer.org/download/)
* [Node.js](http://nodejs.org/) >= 8.0.0
* [Yarn](https://yarnpkg.com/en/docs/install)
## Theme installation
Install Sage using Composer from your WordPress themes directory (replace `your-theme-name` below with the name of your theme):
```shell
# @ app/themes/ or wp-content/themes/
$ composer create-project roots/sage your-theme-name
```
To install the latest development version of Sage, add `dev-master` to the end of the command:
```shell
$ composer create-project roots/sage your-theme-name dev-master
```
During theme installation you will have options to update `style.css` theme headers, select a CSS framework, and configure Browsersync.
## Theme structure
```shell
themes/your-theme-name/ # → Root of your Sage based theme
├── app/ # → Theme PHP
│ ├── Controllers/ # → Controller files
│ ├── admin.php # → Theme customizer setup
│ ├── filters.php # → Theme filters
│ ├── helpers.php # → Helper functions
│ └── setup.php # → Theme setup
├── composer.json # → Autoloading for `app/` files
├── composer.lock # → Composer lock file (never edit)
├── dist/ # → Built theme assets (never edit)
├── node_modules/ # → Node.js packages (never edit)
├── package.json # → Node.js dependencies and scripts
├── resources/ # → Theme assets and templates
│ ├── assets/ # → Front-end assets
│ │ ├── config.json # → Settings for compiled assets
│ │ ├── build/ # → Webpack and ESLint config
│ │ ├── fonts/ # → Theme fonts
│ │ ├── images/ # → Theme images
│ │ ├── scripts/ # → Theme JS
│ │ └── styles/ # → Theme stylesheets
│ ├── functions.php # → Composer autoloader, theme includes
│ ├── index.php # → Never manually edit
│ ├── screenshot.png # → Theme screenshot for WP admin
│ ├── style.css # → Theme meta information
│ └── views/ # → Theme templates
│ ├── layouts/ # → Base templates
│ └── partials/ # → Partial templates
└── vendor/ # → Composer packages (never edit)
```
## Theme setup
Edit `app/setup.php` to enable or disable theme features, setup navigation menus, post thumbnail sizes, and sidebars.
## Theme development
* Run `yarn` from the theme directory to install dependencies
* Update `resources/assets/config.json` settings:
* `devUrl` should reflect your local development hostname
* `publicPath` should reflect your WordPress folder structure (`/wp-content/themes/sage` for non-[Bedrock](https://roots.io/bedrock/) installs)
### Build commands
* `yarn start` — Compile assets when file changes are made, start Browsersync session
* `yarn build` — Compile and optimize the files in your assets directory
* `yarn build:production` — Compile assets for production
## Documentation
* [Sage documentation](https://roots.io/sage/docs/)
* [Controller documentation](https://github.com/soberwp/controller#usage)
## Contributing
Contributions are welcome from everyone. We have [contributing guidelines](https://github.com/roots/guidelines/blob/master/CONTRIBUTING.md) to help you get started.
## Sage sponsors
Help support our open-source development efforts by [becoming a patron](https://www.patreon.com/rootsdev).
<a href="https://kinsta.com/?kaid=OFDHAJIXUDIV"><img src="https://cdn.roots.io/app/uploads/kinsta.svg" alt="Kinsta" width="200" height="150"></a> <a href="https://k-m.com/"><img src="https://cdn.roots.io/app/uploads/km-digital.svg" alt="KM Digital" width="200" height="150"></a> <a href="https://www.itineris.co.uk/"><img src="https://cdn.roots.io/app/uploads/itineris.svg" alt="itineris" width="200" height="150"></a> <a href="http://www.hbgdesignlab.se/"><img src="https://cdn.roots.io/app/uploads/helsingborgdesignlab.png" alt="Helsingborg Design LAB" with="200" height="150">
## Community
Keep track of development and community news.
* Participate on the [Roots Discourse](https://discourse.roots.io/)
* Follow [@rootswp on Twitter](https://twitter.com/rootswp)
* Read and subscribe to the [Roots Blog](https://roots.io/blog/)
* Subscribe to the [Roots Newsletter](https://roots.io/subscribe/)
* Listen to the [Roots Radio podcast](https://roots.io/podcast/)
<?php
namespace App\Controllers;
use Sober\Controller\Controller;
use function App\asset_path;
class App extends Controller
{
public function siteName()
{
return get_bloginfo('name');
}
public static function title()
{
if (is_home()) {
if ($home = get_option('page_for_posts', true)) {
return get_the_title($home);
}
return __('Latest Posts', 'sage');
}
if (is_archive()) {
return get_the_archive_title();
}
if (is_search()) {
return sprintf(__('Search Results for %s', 'sage'), get_search_query());
}
if (is_404()) {
return __('Not Found', 'sage');
}
return get_the_title();
}
public static function logos($size)
{
if(is_front_page()) {
switch($size) {
case 'small':
return asset_path('images/logo-light.svg');
break;
case 'full':
return asset_path('images/logo-light-full.svg');
break;
}
}
switch($size) {
case 'small':
return asset_path('images/logo-dark.svg');
break;
case 'full':
return asset_path('images/logo-dark-full.svg');
break;
}
return false;
}
}
<?php
namespace App\Controllers;
use Sober\Controller\Controller;
use WP_Post;
class FrontPage extends Controller
{
/**
* @var mixed
*/
private $intro_image_id;
/**
* @var mixed
*/
private $intro_content;
/**
* @var array|WP_Post|null
*/
private $intro_image;
function __construct()
{
$intro_gallery = carbon_get_theme_option('intro_gallery');
if($intro_gallery) {
$this->intro_image_id = $intro_gallery[rand(0, (count($intro_gallery) - 1))];
$this->intro_image = get_post($this->intro_image_id);
}
$this->intro_content = carbon_get_theme_option('intro_text');
}
public function intro_image($size='full') {
$intro_image_id = $this->intro_image_id;
if($intro_image_id) {
return wp_get_attachment_image_url($intro_image_id, $size);
}
return false;
}
public function intro_image_caption() {
$intro_image = $this->intro_image;
if($intro_image) {
return $intro_image->post_excerpt;
}
return false;
}
public function intro_image_description() {
$intro_image = $this->intro_image;
if($intro_image) {
return $intro_image->post_content;
}
return false;
}
public function intro_content() {
return $this->intro_content;
}
}
<?php
namespace App\Controllers;
use Sober\Controller\Controller;
use WP_Query;
class TemplateFaq extends Controller
{
public function current_category() {
return get_query_var( 'category' );
}
/**
* @param null $category
* @param null $keyword
* @return WP_Query
*/
public function questions($category=null, $keyword=null) {
if(!$category) {
$category=$this->current_category();
}
// WP_Query arguments
$args = [
'post_type' => ['faq'],
'post_status' => ['publish'],
'nopaging' => true,
'order' => 'ASC',
'orderby' => 'menu_order',
];
if($category) {
$args['category_name'] = $category;
}
if($keyword) {
$args['s'] = $keyword;
}
// The Query
return new WP_Query( $args );
}
/**
* @return array
*/
public function categories() {
$args = [
'type' => 'faq',
'taxonomy' => 'category',
'orderby' => 'name',
'order' => 'ASC'
];
$categories = get_categories($args);
// Add "All" option
array_unshift($categories, (object) [
'slug' => null,
'name' => __('All', 'wisselenergie')
]
);
return $categories;
}
}
<?php
namespace App;
/**
* Theme customizer
*/
add_action('customize_register', function (\WP_Customize_Manager $wp_customize) {
// Add postMessage support
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial('blogname', [
'selector' => '.brand',
'render_callback' => function () {
bloginfo('name');
}
]);
});
/**
* Customizer JS
*/
add_action('customize_preview_init', function () {
wp_enqueue_script('sage/customizer.js', asset_path('scripts/customizer.js'), ['customize-preview'], null, true);
});
<?php
namespace App;
use App\Controllers\TemplateFaq;
class Ajax
{
public function __construct()
{
add_action('wp_ajax_get_questions', [$this, 'get_questions']);
add_action('wp_ajax_nopriv_get_questions', [$this, 'get_questions']);
}
public function get_questions()
{
// Check for nonce security
if ( ! wp_verify_nonce( $_POST['nonce'], 'ajax-nonce' ) ) die ( 'Nonce verification failed!');
$category = isset($_POST['category']) ? $_POST['category'] : null;
$keywords = isset($_POST['keywords']) ? $_POST['keywords'] : null;
$out = '<p>' . __('Sorry, no results were found.', 'wisselenergie') . '</p>';
$templateFaq = new TemplateFaq();
$questions = $templateFaq->questions($category, $keywords);
if($questions->have_posts()) :
$out = '';
while($questions->have_posts()) : $questions->the_post();
$out .= template("partials.content-faq");
endwhile;
endif;
wp_send_json($out);
wp_die();
}
}
new Ajax();
\ No newline at end of file
<?php
use Carbon_Fields\Carbon_Fields;
use Carbon_Fields\Container;
use Carbon_Fields\Field;
use Carbon_Fields\Block;
add_action( 'carbon_fields_register_fields', 'we_theme_options' );
function we_theme_options() {
Container::make_post_meta('review_rating', __('Rating', 'wisselenergie'))
->set_context('side')
->where( 'post_type', '=', 'reviews' )
->add_fields([
Field::make( 'radio', 'review_stars', __( 'Choose Number of Stars', 'wisselenergie' ) )
->set_options( [
'1' => 1,
'2' => 2,
'3' => 3,
'4' => 4,
'5' => 5,
])
->set_default_value(5),
Field::make('checkbox', 'show_reviewer_name', __('Show reviewer\'s name', 'wisselenergie'))
->set_default_value(true)
])
;
// Add second options page under 'Basic Options'
Container::make( 'theme_options', __( 'Site Options' ) )
->add_tab(__('Homepage', 'wisselenergie'), [
Field::make( 'media_gallery', 'intro_gallery', __( 'Gallery', 'wisselenergie' ) ),
Field::make( 'rich_text', 'intro_text', __( 'Intro Text', 'wisselenergie' ) )
])
->add_tab(__('Site news', 'wisselenergie'), [
Field::make('checkbox'