Hotel Raxa - Advanced Booking System Implementation

🏨 Hotel Booking Enhancements:
- Implemented Eagle Booking Advanced Pricing add-on
- Added Booking.com-style rate management system
- Created professional calendar interface for pricing
- Integrated deals and discounts functionality

💰 Advanced Pricing Features:
- Dynamic pricing models (per room, per person, per adult)
- Base rates, adult rates, and child rates management
- Length of stay discounts and early bird deals
- Mobile rates and secret deals implementation
- Seasonal promotions and flash sales

📅 Availability Management:
- Real-time availability tracking
- Stop sell and restriction controls
- Closed to arrival/departure functionality
- Minimum/maximum stay requirements
- Automatic sold-out management

💳 Payment Integration:
- Maintained Redsys payment gateway integration
- Seamless integration with existing Eagle Booking
- No modifications to core Eagle Booking plugin

🛠️ Technical Implementation:
- Custom database tables for advanced pricing
- WordPress hooks and filters integration
- AJAX-powered admin interface
- Data migration from existing Eagle Booking
- Professional calendar view for revenue management

📊 Admin Interface:
- Booking.com-style management dashboard
- Visual rate and availability calendar
- Bulk operations for date ranges
- Statistics and analytics dashboard
- Modal dialogs for quick editing

🔧 Code Quality:
- WordPress coding standards compliance
- Secure database operations with prepared statements
- Proper input validation and sanitization
- Error handling and logging
- Responsive admin interface

🤖 Generated with Claude Code (https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Hotel Raxa Dev
2025-07-11 07:43:22 +02:00
commit 5b1e2453c7
9816 changed files with 2784509 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
# Travis CI (MIT License) configuration file
# @link https://travis-ci.org/
# Use new container based environment
sudo: false
# Declare project language.
# @link http://about.travis-ci.org/docs/user/languages/php/
language: php
# Declare versions of PHP to use. Use one decimal max.
matrix:
fast_finish: true
include:
# aliased to 5.3.29
- php: '5.3'
# aliased to a recent 5.4.x version
- php: '5.4'
# aliased to a recent 5.5.x version
- php: '5.5'
env: SNIFF=1
# aliased to a recent 5.6.x version
- php: '5.6'
# aliased to a recent 7.0.x version
- php: '7.0'
# aliased to a recent 7.1.x version
- php: '7.1'
# aliased to a recent hhvm version
- php: 'hhvm'
allow_failures:
- php: 'hhvm'
before_script:
- export PHPCS_DIR=/tmp/phpcs
- export SNIFFS_DIR=/tmp/sniffs
# Install CodeSniffer for WordPress Coding Standards checks.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi
# Install WordPress Coding Standards.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $SNIFFS_DIR; fi
# Install PHP Compatibility sniffs.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $SNIFFS_DIR/PHPCompatibility; fi
# Set install path for WordPress Coding Standards.
# @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs --config-set installed_paths $SNIFFS_DIR; fi
# After CodeSniffer install you should refresh your path.
- if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi
# Run test script commands.
# All commands must exit with code 0 on success. Anything else is considered failure.
script:
# Search for PHP syntax errors.
- find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
# WordPress Coding Standards.
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
# @link http://pear.php.net/package/PHP_CodeSniffer/
# -p flag: Show progress of the run.
# -s flag: Show sniff codes in all reports.
# -v flag: Print verbose output.
# -n flag: Do not print warnings. (shortcut for --warning-severity=0)
# --standard: Use WordPress as the standard.
# --extensions: Only sniff PHP files.
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs -p -s -v -n . --standard=./phpcs.xml --extensions=php; fi
# Receive notifications for build results.
# @link http://docs.travis-ci.com/user/notifications/#Email-notifications
notifications:
email: false

View File

@@ -0,0 +1,25 @@
<?php
namespace Cmb2Grid\Cmb2;
/**
* Description of Utils.
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
*/
if ( ! class_exists( '\Cmb2Grid\Cmb2\Utils' ) ) {
class Utils {
public static function initializeFieldArg( \CMB2_Field $field, $arg ) {
if ( ! isset( $field->args[ $arg ] ) ) {
$field->args[ $arg ] = '';
}
return $field;
}
public static function initializeGroupFieldArg( \CMB2_Field $field, $arg ) {
if ( ! isset( $field[ $arg ] ) ) {
$field[ $arg ] = '';
}
return $field;
}
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,158 @@
<?php
namespace Cmb2Grid;
if ( ! defined( 'CMB2GRID_DIR' ) ) {
define( 'CMB2GRID_DIR', trailingslashit( dirname( __FILE__ ) ) );
}
if ( ! class_exists( '\Cmb2Grid\Cmb2GridPlugin' ) ) {
require_once dirname( __FILE__ ) . '/DesignPatterns/Singleton.php';
class Cmb2GridPlugin extends DesignPatterns\Singleton {
const VERSION = '1.0';
private $url;
protected function __construct() {
spl_autoload_register( array( $this, 'auto_load' ) );
add_action( 'admin_head', array( $this, 'wpHead' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
//$this->test();
}
private function test() {
new Test\Test();
}
/**
* Auto load our class files.
*
* @param string $class Class name.
*
* @return void
*/
public function auto_load( $class ) {
static $prefix;
static $base_dir;
static $sep;
static $length;
if ( ! isset( $prefix, $base_dir, $sep ) ) {
// Project-specific namespace prefix.
$prefix = __NAMESPACE__ . '\\';
// Base directory for the namespace prefix.
$base_dir = plugin_dir_path( __FILE__ ); // Has trailing slash.
// Set directory separator.
$sep = '/';
if ( defined( 'DIRECTORY_SEPARATOR' ) ) {
$sep = DIRECTORY_SEPARATOR;
}
$length = strlen( $prefix );
}
// Does the class use the namespace prefix?
if ( strncmp( $prefix, $class, $length ) !== 0 ) {
// No, move to the next registered autoloader.
return;
}
// Get the relative class name.
$relative_class = substr( $class, $length );
/*
* Add the base directory, replace namespace separators with directory
* separators in the relative class name and append with .php.
*/
$file = $base_dir . str_replace( '\\', $sep, $relative_class ) . '.php';
// If the file exists, require it.
if ( file_exists( $file ) ) {
require_once $file;
}
}
public function admin_enqueue_scripts() {
$suffix = ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' );
wp_enqueue_style( 'cmb2_grid_bootstrap_light', $this->url( 'assets/css/bootstrap' . $suffix . '.css' ), null, self::VERSION );
}
public function wpHead() {
?>
<style>
.cmb2GridRow .cmb-row{border:none !important;padding:0 !important}
.cmb2GridRow .cmb-th label:after{border:none !important}
.cmb2GridRow .cmb-th{width:100% !important}
.cmb2GridRow .cmb-td{width:100% !important}
.cmb2GridRow input[type="text"]:not( '.hasDatepicker' ), .cmb2GridRow textarea, .cmb2GridRow select{width:100%}
.cmb2GridRow .cmb-repeat-group-wrap{max-width:100% !important;}
.cmb2GridRow .cmb-group-title{margin:0 !important;}
.cmb2GridRow .cmb-repeat-group-wrap .cmb-row .cmbhandle, .cmb2GridRow .postbox-container .cmb-row .cmbhandle{right:0 !important}
.cmb2GridRow .cmb-type-group .cmb-remove-field-row{padding-bottom: 1.8em !important;padding-top: 1.8em !important;}
.cmb2GridRow .cmb-td.cmb-nested{padding-left: 15px;padding-right: 15px;}
</style>
<?php
}
// Based on CMB2_Utils url() method.
public function url( $path = '' ) {
if ( isset( $this->url ) ) {
return $this->url . $path;
}
if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) {
// Windows
$content_dir = str_replace( '/', DIRECTORY_SEPARATOR, WP_CONTENT_DIR );
$content_url = str_replace( $content_dir, WP_CONTENT_URL, CMB2GRID_DIR );
$cmb2_url = str_replace( DIRECTORY_SEPARATOR, '/', $content_url );
} else {
$cmb2_url = str_replace(
array( WP_CONTENT_DIR, WP_PLUGIN_DIR ),
array( WP_CONTENT_URL, WP_PLUGIN_URL ),
CMB2GRID_DIR
);
}
/**
* Filter the CMB location url.
*
* @param string $cmb2_url Currently registered url.
*/
$this->url = trailingslashit( apply_filters( 'cmb2_meta_box_url', set_url_scheme( $cmb2_url ), CMB2_VERSION ) );
return $this->url . $path;
}
}
}
/* Instantiate the class on plugins_loaded. */
// wp_installing() function was introduced in WP 4.4.
if ( ( function_exists( 'wp_installing' ) && wp_installing() === false ) || ( ! function_exists( 'wp_installing' ) && ( ! defined( 'WP_INSTALLING' ) || WP_INSTALLING === false ) ) ) {
add_action( 'plugins_loaded', '\\' . __NAMESPACE__ . '\init' );
}
if ( ! function_exists( '\Cmb2Grid\init' ) ) {
/**
* Initialize the class only if CMB2 is detected.
*
* @return void
*/
function init() {
if ( defined( 'CMB2_LOADED' ) ) {
if ( ! defined( 'CMB2GRID_DIR' ) ) {
define( 'CMB2GRID_DIR', trailingslashit( dirname( __FILE__ ) ) );
}
Cmb2GridPlugin::getInstance();
}
}
}
add_action( 'cmb2_init', '\Cmb2Grid\init' );

View File

@@ -0,0 +1,30 @@
<?php
namespace Cmb2Grid\DesignPatterns;
/**
* Description of Singleton.
*
* Pablo Pacheco <pablo.pacheco@origgami.com.br>
*/
if ( ! class_exists( '\Cmb2Grid\DesignPatterns\Singleton' ) ) {
abstract class Singleton {
abstract protected function __construct();
/**
* Returns the *Singleton* instance of this class.
*
* @staticvar Singleton $instance The *Singleton* instances of this class.
*
* @return Current_Class_Name
*/
public static function getInstance() {
static $instance = null;
if ( null === $instance ) {
$instance = new static();
}
return $instance;
}
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,84 @@
<?php
namespace Cmb2Grid\Grid;
/**
* Description of Cmb2Grid.
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
*/
if ( ! class_exists( '\Cmb2Grid\Grid\Cmb2Grid' ) ) {
class Cmb2Grid {
private $cmb2Obj;
private $cmb2Id;
private $metaBoxConfig;
private $rows = array();
public function __construct( $meta_box_config ) {
$this->setMetaBoxConfig( $meta_box_config );
$this->setCmb2Obj( \cmb2_get_metabox( $this->getMetaBoxConfig() ) );
//$cmb2Obj = $this->getCmb2Obj();
//error_log( '--- DEBUG: $cmb2Obj ---' );
//error_log( print_r( $cmb2Obj, true ) );
//add_action( 'admin_init', array( $this, 'adminInit' ), 15 );
}
/**
*
* @param type $field
* @return \Cmb2Grid\Grid\Group\Cmb2GroupGrid
*/
public function addCmb2GroupGrid( $field ) {
$cmb2GroupGrid = new Group\Cmb2GroupGrid( $this->getMetaBoxConfig() );
$cmb2GroupGrid->setParentFieldId( $field );
return $cmb2GroupGrid;
}
public function addRow() {
$rows = $this->getRows();
$newRow = new Row( $this );
$rows[] = $newRow;
$this->setRows( $rows );
return $newRow;
}
/**
*
* @return \CMB2
*/
function getCmb2Obj() {
return $this->cmb2Obj;
}
function setCmb2Obj( $cmb2Obj ) {
$this->cmb2Obj = $cmb2Obj;
}
function getCmb2Id() {
return $this->cmb2Id;
}
function setCmb2Id( $cmb2Id ) {
$this->cmb2Id = $cmb2Id;
}
function getMetaBoxConfig() {
return $this->metaBoxConfig;
}
function setMetaBoxConfig( $metaBoxConfig ) {
$this->metaBoxConfig = $metaBoxConfig;
}
function getRows() {
return $this->rows;
}
function setRows( $rows ) {
$this->rows = $rows;
}
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace Cmb2Grid\Grid;
/**
* Description of Cmb2GridColumn.
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
*/
if ( ! class_exists( '\Cmb2Grid\Grid\Column' ) ) {
class Column {
private $field;
private $fieldId;
private $grid;
private $columnClassWidth;
private $columnClass;
public function __construct( $field, Cmb2Grid $grid ) {
$this->setGrid( $grid );
if ( is_string( $field ) ) {
$this->setFieldId( $field );
} elseif ( is_array( $field ) ) {
$this->setFieldId( $field[0] );
} elseif ( is_a( $field, '\Cmb2Grid\Grid\Group\Cmb2GroupGrid' ) ) {
$this->setFieldId( $field->getParentFieldId() );
}
$fieldId = $this->getFieldId();
$finalField = cmb2_get_field( $grid->getCmb2Obj(), $fieldId );
$this->setField( $finalField );
if ( is_array( $field ) ) {
if ( isset( $field['class'] ) ) {
$this->setColumnClass( $field['class'] );
}
}
}
function getColumnClassWidth() {
return $this->columnClassWidth;
}
public function setColumnClassCmb2() {
$columnClass = $this->getColumnClass();
$field = $this->getField();
//error_log( print_r( $field, true ) );
if ( $field->args['type'] === 'group' ) {
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'before_group' );
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'after_group' );
$field->args['before_group'] .= "<div class=\"{$columnClass}\">";
$field->args['after_group'] .= '</div>';
} else {
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'before_row' );
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'after_row' );
$field->args['before_row'] .= "<div class=\"{$columnClass}\">";
$field->args['after_row'] .= '</div>';
}
}
function setColumnClass( $columnClass ) {
$this->columnClass = $columnClass;
}
function setBootstrapColumnClass( $columnClassNum, $prefix = 'col-md' ) {
$this->columnClassWidth = $columnClassNum;
$this->setColumnClass( "{$prefix}-{$columnClassNum}" );
$this->setColumnClassCmb2();
}
function getField() {
return $this->field;
}
/**
*
* @return CMB2_Field
*/
function getFieldId() {
return $this->fieldId;
}
function setField( $field ) {
$this->field = $field;
}
function setFieldId( $fieldId ) {
$this->fieldId = $fieldId;
}
/**
*
* @return Cmb2Grid
*/
function getGrid() {
return $this->grid;
}
function setGrid( $grid ) {
$this->grid = $grid;
}
function getColumnClass() {
return $this->columnClass;
}
}
}

View File

@@ -0,0 +1,40 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Cmb2Grid\Grid\Group;
if ( ! class_exists( '\Cmb2Grid\Grid\Group\Cmb2GroupGrid' ) ) {
/**
* Description of Cmb2GroupGrid.
*
* @author Pablo
*/
class Cmb2GroupGrid extends \Cmb2Grid\Grid\Cmb2Grid {
protected $parentFieldId;
public function addRow() {
//parent::addRow();
$rows = $this->getRows();
$newRow = new GroupRow( $this );
$newRow->setParentFieldId( $this->getParentFieldId() );
$rows[] = $newRow;
$this->setRows( $rows );
return $newRow;
}
function getParentFieldId() {
return $this->parentFieldId;
}
function setParentFieldId( $parentFieldId ) {
$this->parentFieldId = $parentFieldId;
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Cmb2Grid\Grid\Group;
if ( ! class_exists( '\Cmb2Grid\Grid\Group\GroupColumn' ) ) {
/**
* Description of GroupColumn.
*
* @author Pablo
*/
class GroupColumn extends \Cmb2Grid\Grid\Column {
protected $parentFieldId;
public function setColumnClassCmb2() {
$columnClass = $this->getColumnClass();
$field = $this->getField();
$fieldID = $this->getFieldId();
//\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field->args['fields'][$fieldID], 'before_row' );
//\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field->args['fields'][$fieldID], 'after_row' );
if ( ! empty( $fieldID['before_row'] ) && ! empty( $fieldID['after_row'] ) ) {
$field->args['fields'][ $fieldID ]['before_row'] .= "<div class=\"{$columnClass}\">";
$field->args['fields'][ $fieldID ]['after_row'] .= '</div>';
}
}
public function __construct( $field, \Cmb2Grid\Grid\Cmb2Grid $grid ) {
$this->setParentFieldId( $field[0] );
$this->setFieldId( $field[1] );
$field = cmb2_get_field( $grid->getCmb2Obj(), $this->getParentFieldId() );
$this->setField( $field );
//parent::__construct( $field, $grid );
/* $this->setGrid( $grid );
if ( is_string( $field ) ) {
$this->setFieldId( $field );
} elseif ( is_array( $field ) ) {
$this->setFieldId( $field[0] );
}
$fieldId = $this->getFieldId();
$field = cmb2_get_field( $grid->getCmb2Obj(), $fieldId );
$this->setField( $field );
if ( is_array( $field ) ) {
if ( isset( $field['class'] ) ) {
$this->setColumnClass( $field['class'] );
}
} */
}
function getParentFieldId() {
return $this->parentFieldId;
}
function setParentFieldId( $parentFieldId ) {
$this->parentFieldId = $parentFieldId;
}
}
}

View File

@@ -0,0 +1,95 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Cmb2Grid\Grid\Group;
if ( ! class_exists( '\Cmb2Grid\Grid\Group\GroupRow' ) ) {
/**
* Description of GroupRow.
*
* @author Pablo
*/
class GroupRow extends \Cmb2Grid\Grid\Row {
protected $parentFieldId;
/* protected function openRow( \CMB2_Field $field ) {
//error_log( print_r( $field, true ) );
//$fieldID = $field[1];
//@$field->args['fields'][ $fieldID ]['before_row'] .= "<div class=\"{$columnClass}\">";
//@$field->args['fields'][ $fieldID ]['after_row'] .= '</div>';
//\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'before_row' );
@$field->args['fields'][ $fieldID ]['before_row'] .= '<div class="row cmb2GridRow">';
}
protected function closeRow( \CMB2_Field $field ) {
//error_log( print_r( $field, true ) );
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'after_row' );
$field->args['after_row'].= '</div>';
} */
protected function closeGroupRow( \CMB2_Field $field, $fieldID ) {
if ( !empty( $fieldID['after_row'] ) ) {
@$field->args['fields'][ $fieldID ]['after_row'] .= '</div>';
}
}
protected function openGroupRow( \CMB2_Field $field, $fieldID ) {
if ( !empty( $fieldID['before_row'] ) ) {
@$field->args['fields'][ $fieldID ]['before_row'] .= '<div class="row cmb2GridRow">';
}
}
protected function handleRow() {
$columns = $this->getColumns();
/* @var $firstColumn GroupColumn */
$firstColumn = $columns[0];
$field = $firstColumn->getField();
$fieldID = $firstColumn->getFieldId();
$this->openGroupRow( $field, $fieldID );
$lastColumn = $columns[ ( count( $columns ) - 1 ) ];
$field = $lastColumn->getField();
$fieldID = $lastColumn->getFieldId();
$this->closeGroupRow( $field, $fieldID );
}
protected function addColumn( $field ) {
//parent::addColumn( $field );
$column = new GroupColumn( $field, $this->getGrid() );
$columns = $this->getColumns();
$columns[] = $column;
$this->setColumns( $columns );
return $column;
}
public function addColumns( array $fields = array() ) {
//parent::addColumns($fields);
foreach ( $fields as $key => $field ) {
$this->addColumn( $field );
}
//$this->handleColumnsCssClasses();
$this->handleRow();
$this->handleColumnsCssClasses();
}
function getParentFieldId() {
return $this->parentFieldId;
}
function setParentFieldId( $parentFieldId ) {
$this->parentFieldId = $parentFieldId;
}
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,110 @@
<?php
namespace Cmb2Grid\Grid;
/**
* Description of Cmb2GridRow.
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
*/
if ( ! class_exists( '\Cmb2Grid\Grid\Row' ) ) {
class Row {
private $grid;
private $columns = array();
public function __construct( Cmb2Grid $grid ) {
$this->setGrid( $grid );
}
protected function openRow( \CMB2_Field $field ) {
//error_log( print_r( $field, true ) );
if ( $field->args['type'] === 'group' ) {
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'before_group' );
$field->args['before_group'] .= '<div class="row cmb2GridRow">';
} else {
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'before_row' );
$field->args['before_row'] .= '<div class="cmb-th"><label for="room_price_mon">Week Price</label></div><div class="row cmb2GridRow">';
}
}
protected function closeRow( \CMB2_Field $field ) {
//error_log( print_r( $field, true ) );
if ( $field->args['type'] === 'group' ) {
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'after_group' );
$field->args['after_group'] .= '</div>';
} else {
\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'after_row' );
$field->args['after_row'] .= '</div>';
}
/*\Cmb2Grid\Cmb2\Utils::initializeFieldArg( $field, 'after_row' );
$field->args['after_row'].= '</div>';*/
}
protected function handleRow() {
$columns = $this->getColumns();
/* @var $firstColumn Column */
$firstColumn = $columns[0];
$field = $firstColumn->getField();
$this->openRow( $field );
$lastColumn = $columns[ ( count( $columns ) - 1 ) ];
$field = $lastColumn->getField();
$this->closeRow( $field );
}
public function addColumns( array $fields = array() ) {
foreach ( $fields as $key => $field ) {
$this->addColumn( $field );
}
$this->handleRow();
$this->handleColumnsCssClasses();
}
protected function handleColumnsCssClasses() {
$columns = $this->getColumns();
$columnsCount = count( $columns );
$columnWidth = round( 12 / $columnsCount );
/*@var $column Column*/
foreach ( $columns as $key => $column ) {
if ( ! $column->getColumnClass() ) {
$column->setBootstrapColumnClass( $columnWidth );
} else {
$column->setColumnClassCmb2();
}
}
}
protected function addColumn( $field ) {
$column = new Column( $field,$this->getGrid() );
$columns = $this->getColumns();
$columns[] = $column;
$this->setColumns( $columns );
return $column;
}
/*protected function handleRow( $column ) {
}*/
function getGrid() {
return $this->grid;
}
function setGrid( $grid ) {
$this->grid = $grid;
}
function getColumns() {
return $this->columns;
}
function setColumns( $columns ) {
$this->columns = $columns;
}
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,78 @@
# CMB2-grid
A grid system for Wordpress [CMB2](https://github.com/WebDevStudios/cmb2) library that allows the creation of columns for a better layout in the admin.
## Installation
For now you have to install this as a WordPress plugin:
1. Download the plugin
2. Place the plugin folder in your `/wp-content/plugins/` directory
3. Activate the plugin in the Plugin dashboard
## Usage
Create your cmb2 metabox like you always do:
```php
$prefix = '_yourprefix_demo_';
$cmb = new_cmb2_box(array(
'id' => $prefix . 'metabox',
'title' => __('Test Metabox', 'cmb2'),
'object_types' => array('page',), // Post type
));
$field1 = $cmb->add_field(array(
'name' => __('Test Text', 'cmb2'),
'desc' => __('field description (optional)', 'cmb2'),
'id' => $prefix . 'text',
'type' => 'text',
));
$field2 = $cmb->add_field(array(
'name' => __('Test Text2', 'cmb2'),
'desc' => __('field description2 (optional2)', 'cmb2'),
'id' => $prefix . 'text2',
'type' => 'text',
));
```
Now, create your columns like this:
```php
if(!is_admin()){
return;
}
$cmb2Grid = new \Cmb2Grid\Grid\Cmb2Grid($cmb);
$row = $cmb2Grid->addRow();
$row->addColumns(array($field1, $field2));
```
You can also use custom bootstrap column classes if you want, like this
```
$row->addColumns(array(
array($field1, 'class' => 'col-md-8'),
array($field2, 'class' => 'col-md-4')
));
```
**FAQ**
- It works on [group fields](https://github.com/origgami/CMB2-grid/wiki/Group-fields) also
- If you want, you can opt to use the metabox and the field IDs also.
- Currently the grid system is using a lite version of Twitter Bootstrap
- You can create as much rows as you want
- You have to put the fields in the columns in the same order they were created
- You can follow exactly what is in [Test/Test.php](https://github.com/origgami/CMB2-grid/blob/master/Test/Test.php) file to see it in action
## Screenshots
**This is what you get using columns**
![Image](assets/imgs/screenshot1.jpg)

View File

@@ -0,0 +1,147 @@
<?php
namespace Cmb2Grid\Test;
/**
* Description of Test.
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
*/
if ( ! class_exists( '\Cmb2Grid\Test\Test' ) ) {
class Test {
public function __construct() {
$this->addTestCmb2();
}
private function addTestCmb2() {
add_action( 'cmb2_admin_init', array( $this, 'testCmb' ) );
add_action( 'cmb2_admin_init', array( $this, 'testGroupCmb' ) );
}
public function testGroupCmb() {
$prefix = '_yourgridprefix_group_';
$cmb_group = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => __( 'Repeating Field Group using a Grid', 'cmb2' ),
'object_types' => array( 'page' ),
) );
$field1 = $cmb_group->add_field( array(
'name' => __( 'Test Text', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'text',
'type' => 'text',
) );
$field2 = $cmb_group->add_field( array(
'name' => __( 'Test Text Small', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'textsmall',
'type' => 'text',
) );
// $group_field_id is the field id string, so in this case: $prefix . 'demo'
$group_field_id = $cmb_group->add_field( array(
'id' => $prefix . 'demo',
'type' => 'group',
'options' => array(
'group_title' => __( 'Entry {#}', 'cmb2' ), // {#} gets replaced by row number.
'add_button' => __( 'Add Another Entry', 'cmb2' ),
'remove_button' => __( 'Remove Entry', 'cmb2' ),
'sortable' => true,
),
) );
$gField1 = $cmb_group->add_group_field( $group_field_id, array(
'name' => __( 'Entry Title', 'cmb2' ),
'id' => 'title',
'type' => 'text',
) );
$gField2 = $cmb_group->add_group_field( $group_field_id, array(
'name' => __( 'Description', 'cmb2' ),
'description' => __( 'Write a short description for this entry', 'cmb2' ),
'id' => 'description',
'type' => 'textarea_small',
));
// Create a default grid.
$cmb2Grid = new \Cmb2Grid\Grid\Cmb2Grid( $cmb_group );
// Create now a Grid of group fields.
$cmb2GroupGrid = $cmb2Grid->addCmb2GroupGrid( $group_field_id );
$row = $cmb2GroupGrid->addRow();
$row->addColumns( array(
$gField1,
$gField2,
) );
// Now setup your columns like you generally do, even with group fields.
$row = $cmb2Grid->addRow();
$row->addColumns( array(
$field1,
$field2,
) );
$row = $cmb2Grid->addRow();
$row->addColumns( array(
$cmb2GroupGrid, // Can be $group_field_id also.
) );
}
public function testCmb() {
// Start with an underscore to hide fields from custom fields list.
$prefix = '_yourgridprefix_demo_';
/**
* Sample metabox to demonstrate each field type included.
*/
$cmb = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => __( 'Test Metabox using a Grid', 'cmb2' ),
'object_types' => array( 'page' ), // Post type.
));
$field1 = $cmb->add_field( array(
'name' => __( 'Test Text', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'text',
'type' => 'text',
));
$field2 = $cmb->add_field( array(
'name' => __( 'Test Text Small', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'textsmall',
'type' => 'text',
));
$field3 = $cmb->add_field( array(
'name' => __( 'Test Text Medium', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'textmedium',
'type' => 'text',
));
$field4 = $cmb->add_field( array(
'name' => __( 'Website URL', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'url',
'type' => 'text',
));
$field5 = $cmb->add_field( array(
'name' => __( 'Test Text Email', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'email',
'type' => 'text',
));
$cmb2Grid = new \Cmb2Grid\Grid\Cmb2Grid( $cmb );
$row = $cmb2Grid->addRow();
$row->addColumns( array(
//$field1,
//$field2
array( $field1, 'class' => 'col-md-8' ),
array( $field2, 'class' => 'col-md-4' ),
));
$row = $cmb2Grid->addRow();
$row->addColumns( array(
$field3,
$field4,
$field5,
) );
}
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,680 @@
/*!
* Bootstrap v3.3.5 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*!
* Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=bf4843be8d63248ed843)
* Config saved to config.json and https://gist.github.com/bf4843be8d63248ed843
*/
/*!
* Bootstrap v3.3.5 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
.cmb2-wrap *, .cmb2-wrap {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.cmb2-wrap *:before,
.cmb2-wrap *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.row {
margin-left: -15px;
margin-right: -15px;
}
.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
position: relative;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
}
.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
float: left;
}
.col-xs-12 {
width: 100%;
}
.col-xs-11 {
width: 91.66666667%;
}
.col-xs-10 {
width: 83.33333333%;
}
.col-xs-9 {
width: 75%;
}
.col-xs-8 {
width: 66.66666667%;
}
.col-xs-7 {
width: 58.33333333%;
}
.col-xs-6 {
width: 50%;
}
.col-xs-5 {
width: 41.66666667%;
}
.col-xs-4 {
width: 33.33333333%;
}
.col-xs-3 {
width: 25%;
}
.col-xs-2 {
width: 16.66666667%;
}
.col-xs-1 {
width: 8.33333333%;
}
.col-xs-pull-12 {
right: 100%;
}
.col-xs-pull-11 {
right: 91.66666667%;
}
.col-xs-pull-10 {
right: 83.33333333%;
}
.col-xs-pull-9 {
right: 75%;
}
.col-xs-pull-8 {
right: 66.66666667%;
}
.col-xs-pull-7 {
right: 58.33333333%;
}
.col-xs-pull-6 {
right: 50%;
}
.col-xs-pull-5 {
right: 41.66666667%;
}
.col-xs-pull-4 {
right: 33.33333333%;
}
.col-xs-pull-3 {
right: 25%;
}
.col-xs-pull-2 {
right: 16.66666667%;
}
.col-xs-pull-1 {
right: 8.33333333%;
}
.col-xs-pull-0 {
right: auto;
}
.col-xs-push-12 {
left: 100%;
}
.col-xs-push-11 {
left: 91.66666667%;
}
.col-xs-push-10 {
left: 83.33333333%;
}
.col-xs-push-9 {
left: 75%;
}
.col-xs-push-8 {
left: 66.66666667%;
}
.col-xs-push-7 {
left: 58.33333333%;
}
.col-xs-push-6 {
left: 50%;
}
.col-xs-push-5 {
left: 41.66666667%;
}
.col-xs-push-4 {
left: 33.33333333%;
}
.col-xs-push-3 {
left: 25%;
}
.col-xs-push-2 {
left: 16.66666667%;
}
.col-xs-push-1 {
left: 8.33333333%;
}
.col-xs-push-0 {
left: auto;
}
.col-xs-offset-12 {
margin-left: 100%;
}
.col-xs-offset-11 {
margin-left: 91.66666667%;
}
.col-xs-offset-10 {
margin-left: 83.33333333%;
}
.col-xs-offset-9 {
margin-left: 75%;
}
.col-xs-offset-8 {
margin-left: 66.66666667%;
}
.col-xs-offset-7 {
margin-left: 58.33333333%;
}
.col-xs-offset-6 {
margin-left: 50%;
}
.col-xs-offset-5 {
margin-left: 41.66666667%;
}
.col-xs-offset-4 {
margin-left: 33.33333333%;
}
.col-xs-offset-3 {
margin-left: 25%;
}
.col-xs-offset-2 {
margin-left: 16.66666667%;
}
.col-xs-offset-1 {
margin-left: 8.33333333%;
}
.col-xs-offset-0 {
margin-left: 0%;
}
@media (min-width: 768px) {
.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
float: left;
}
.col-sm-12 {
width: 100%;
}
.col-sm-11 {
width: 91.66666667%;
}
.col-sm-10 {
width: 83.33333333%;
}
.col-sm-9 {
width: 75%;
}
.col-sm-8 {
width: 66.66666667%;
}
.col-sm-7 {
width: 58.33333333%;
}
.col-sm-6 {
width: 50%;
}
.col-sm-5 {
width: 41.66666667%;
}
.col-sm-4 {
width: 33.33333333%;
}
.col-sm-3 {
width: 25%;
}
.col-sm-2 {
width: 16.66666667%;
}
.col-sm-1 {
width: 8.33333333%;
}
.col-sm-pull-12 {
right: 100%;
}
.col-sm-pull-11 {
right: 91.66666667%;
}
.col-sm-pull-10 {
right: 83.33333333%;
}
.col-sm-pull-9 {
right: 75%;
}
.col-sm-pull-8 {
right: 66.66666667%;
}
.col-sm-pull-7 {
right: 58.33333333%;
}
.col-sm-pull-6 {
right: 50%;
}
.col-sm-pull-5 {
right: 41.66666667%;
}
.col-sm-pull-4 {
right: 33.33333333%;
}
.col-sm-pull-3 {
right: 25%;
}
.col-sm-pull-2 {
right: 16.66666667%;
}
.col-sm-pull-1 {
right: 8.33333333%;
}
.col-sm-pull-0 {
right: auto;
}
.col-sm-push-12 {
left: 100%;
}
.col-sm-push-11 {
left: 91.66666667%;
}
.col-sm-push-10 {
left: 83.33333333%;
}
.col-sm-push-9 {
left: 75%;
}
.col-sm-push-8 {
left: 66.66666667%;
}
.col-sm-push-7 {
left: 58.33333333%;
}
.col-sm-push-6 {
left: 50%;
}
.col-sm-push-5 {
left: 41.66666667%;
}
.col-sm-push-4 {
left: 33.33333333%;
}
.col-sm-push-3 {
left: 25%;
}
.col-sm-push-2 {
left: 16.66666667%;
}
.col-sm-push-1 {
left: 8.33333333%;
}
.col-sm-push-0 {
left: auto;
}
.col-sm-offset-12 {
margin-left: 100%;
}
.col-sm-offset-11 {
margin-left: 91.66666667%;
}
.col-sm-offset-10 {
margin-left: 83.33333333%;
}
.col-sm-offset-9 {
margin-left: 75%;
}
.col-sm-offset-8 {
margin-left: 66.66666667%;
}
.col-sm-offset-7 {
margin-left: 58.33333333%;
}
.col-sm-offset-6 {
margin-left: 50%;
}
.col-sm-offset-5 {
margin-left: 41.66666667%;
}
.col-sm-offset-4 {
margin-left: 33.33333333%;
}
.col-sm-offset-3 {
margin-left: 25%;
}
.col-sm-offset-2 {
margin-left: 16.66666667%;
}
.col-sm-offset-1 {
margin-left: 8.33333333%;
}
.col-sm-offset-0 {
margin-left: 0%;
}
}
@media (min-width: 992px) {
.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
float: left;
}
.col-md-12 {
width: 100%;
}
.col-md-11 {
width: 91.66666667%;
}
.col-md-10 {
width: 83.33333333%;
}
.col-md-9 {
width: 75%;
}
.col-md-8 {
width: 66.66666667%;
}
.col-md-7 {
width: 58.33333333%;
}
.col-md-6 {
width: 50%;
}
.col-md-5 {
width: 41.66666667%;
}
.col-md-4 {
width: 33.33333333%;
}
.col-md-3 {
width: 25%;
}
.col-md-2 {
width: 16.66666667%;
}
.col-md-1 {
width: 8.33333333%;
}
.col-md-pull-12 {
right: 100%;
}
.col-md-pull-11 {
right: 91.66666667%;
}
.col-md-pull-10 {
right: 83.33333333%;
}
.col-md-pull-9 {
right: 75%;
}
.col-md-pull-8 {
right: 66.66666667%;
}
.col-md-pull-7 {
right: 58.33333333%;
}
.col-md-pull-6 {
right: 50%;
}
.col-md-pull-5 {
right: 41.66666667%;
}
.col-md-pull-4 {
right: 33.33333333%;
}
.col-md-pull-3 {
right: 25%;
}
.col-md-pull-2 {
right: 16.66666667%;
}
.col-md-pull-1 {
right: 8.33333333%;
}
.col-md-pull-0 {
right: auto;
}
.col-md-push-12 {
left: 100%;
}
.col-md-push-11 {
left: 91.66666667%;
}
.col-md-push-10 {
left: 83.33333333%;
}
.col-md-push-9 {
left: 75%;
}
.col-md-push-8 {
left: 66.66666667%;
}
.col-md-push-7 {
left: 58.33333333%;
}
.col-md-push-6 {
left: 50%;
}
.col-md-push-5 {
left: 41.66666667%;
}
.col-md-push-4 {
left: 33.33333333%;
}
.col-md-push-3 {
left: 25%;
}
.col-md-push-2 {
left: 16.66666667%;
}
.col-md-push-1 {
left: 8.33333333%;
}
.col-md-push-0 {
left: auto;
}
.col-md-offset-12 {
margin-left: 100%;
}
.col-md-offset-11 {
margin-left: 91.66666667%;
}
.col-md-offset-10 {
margin-left: 83.33333333%;
}
.col-md-offset-9 {
margin-left: 75%;
}
.col-md-offset-8 {
margin-left: 66.66666667%;
}
.col-md-offset-7 {
margin-left: 58.33333333%;
}
.col-md-offset-6 {
margin-left: 50%;
}
.col-md-offset-5 {
margin-left: 41.66666667%;
}
.col-md-offset-4 {
margin-left: 33.33333333%;
}
.col-md-offset-3 {
margin-left: 25%;
}
.col-md-offset-2 {
margin-left: 16.66666667%;
}
.col-md-offset-1 {
margin-left: 8.33333333%;
}
.col-md-offset-0 {
margin-left: 0%;
}
}
@media (min-width: 1200px) {
.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
float: left;
}
.col-lg-12 {
width: 100%;
}
.col-lg-11 {
width: 91.66666667%;
}
.col-lg-10 {
width: 83.33333333%;
}
.col-lg-9 {
width: 75%;
}
.col-lg-8 {
width: 66.66666667%;
}
.col-lg-7 {
width: 58.33333333%;
}
.col-lg-6 {
width: 50%;
}
.col-lg-5 {
width: 41.66666667%;
}
.col-lg-4 {
width: 33.33333333%;
}
.col-lg-3 {
width: 25%;
}
.col-lg-2 {
width: 16.66666667%;
}
.col-lg-1 {
width: 8.33333333%;
}
.col-lg-pull-12 {
right: 100%;
}
.col-lg-pull-11 {
right: 91.66666667%;
}
.col-lg-pull-10 {
right: 83.33333333%;
}
.col-lg-pull-9 {
right: 75%;
}
.col-lg-pull-8 {
right: 66.66666667%;
}
.col-lg-pull-7 {
right: 58.33333333%;
}
.col-lg-pull-6 {
right: 50%;
}
.col-lg-pull-5 {
right: 41.66666667%;
}
.col-lg-pull-4 {
right: 33.33333333%;
}
.col-lg-pull-3 {
right: 25%;
}
.col-lg-pull-2 {
right: 16.66666667%;
}
.col-lg-pull-1 {
right: 8.33333333%;
}
.col-lg-pull-0 {
right: auto;
}
.col-lg-push-12 {
left: 100%;
}
.col-lg-push-11 {
left: 91.66666667%;
}
.col-lg-push-10 {
left: 83.33333333%;
}
.col-lg-push-9 {
left: 75%;
}
.col-lg-push-8 {
left: 66.66666667%;
}
.col-lg-push-7 {
left: 58.33333333%;
}
.col-lg-push-6 {
left: 50%;
}
.col-lg-push-5 {
left: 41.66666667%;
}
.col-lg-push-4 {
left: 33.33333333%;
}
.col-lg-push-3 {
left: 25%;
}
.col-lg-push-2 {
left: 16.66666667%;
}
.col-lg-push-1 {
left: 8.33333333%;
}
.col-lg-push-0 {
left: auto;
}
.col-lg-offset-12 {
margin-left: 100%;
}
.col-lg-offset-11 {
margin-left: 91.66666667%;
}
.col-lg-offset-10 {
margin-left: 83.33333333%;
}
.col-lg-offset-9 {
margin-left: 75%;
}
.col-lg-offset-8 {
margin-left: 66.66666667%;
}
.col-lg-offset-7 {
margin-left: 58.33333333%;
}
.col-lg-offset-6 {
margin-left: 50%;
}
.col-lg-offset-5 {
margin-left: 41.66666667%;
}
.col-lg-offset-4 {
margin-left: 33.33333333%;
}
.col-lg-offset-3 {
margin-left: 25%;
}
.col-lg-offset-2 {
margin-left: 16.66666667%;
}
.col-lg-offset-1 {
margin-left: 8.33333333%;
}
.col-lg-offset-0 {
margin-left: 0%;
}
}
.row:before,
.row:after {
content: " ";
display: table;
}
.row:after {
clear: both;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,38 @@
<?php
/**
* Show admin notice & de-activate itself if PHP < 5.3 is detected.
*/
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
add_action( 'admin_init', 'cmb2_grid_deactivate' );
if ( ! function_exists( 'cmb2_grid_deactivate' ) ) {
/**
* Check for parent plugin.
*/
function cmb2_grid_deactivate() {
$file = plugin_basename( __FILE__ );
if ( is_admin() && current_user_can( 'activate_plugins' ) && is_plugin_active( plugin_basename( $file ) ) ) {
add_action( 'admin_notices', create_function( null, 'echo \'<div class="error"><p>\', __( \'Activation failed: The CMB2 Grid plugin requires PHP 5.3+. Please contact your webhost and ask them to upgrade the PHP version for your webhosting account.\', \'cmb2-grid\' ), \'</a></p></div>\';' ) );
deactivate_plugins( $file, false, is_network_admin() );
// Add to recently active plugins list.
if ( ! is_network_admin() ) {
update_option( 'recently_activated', array( $file => time() ) + (array) get_option( 'recently_activated' ) );
} else {
update_site_option( 'recently_activated', array( $file => time() ) + (array) get_site_option( 'recently_activated' ) );
}
// Prevent trying again on page reload.
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
}
}
} else {
/* PHP 5.3+, so load the plugin. */
include_once dirname( __FILE__ ) . '/Cmb2GridPluginLoad.php';
}

View File

@@ -0,0 +1,7 @@
{
"name": "origgami/cmb2-grid",
"type": "wordpress-plugin",
"require": {
"composer/installers": ">=v1.1.0"
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<ruleset name="CMB2 Grid">
<description>The code standard for CMB2 Grid is WordPress.</description>
<!-- PHP cross-version compatibility -->
<config name="testVersion" value="5.3-99.0"/>
<rule ref="PHPCompatibility"/>
<!-- Code style -->
<rule ref="WordPress">
<exclude name="Generic.Files.LowercasedFilename" />
<exclude name="WordPress.NamingConventions" />
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" />
<exclude name="WordPress.PHP.YodaConditions.NotYoda" />
<!-- Temporarily exclude documentation checks until all classes, methods and properties have been documented. -->
<exclude name="WordPress-Docs" />
</rule>
<!-- exclude the 'empty' index files from some documentation checks -->
<rule ref="Squiz.Commenting.FileComment.WrongStyle">
<exclude-pattern>*/index.php</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.InlineComment.SpacingAfter">
<exclude-pattern>*/index.php</exclude-pattern>
</rule>
</ruleset>