Skip to content

Commit

Permalink
Initial commit from old name
Browse files Browse the repository at this point in the history
  • Loading branch information
Inggo committed Jan 26, 2016
0 parents commit 17abf9d
Show file tree
Hide file tree
Showing 13 changed files with 27,796 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
node_modules/
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# wp-admin React

Readme Soon™.

## Original Author

[Inggo Espinosa](https://github.com/inggo)
12 changes: 12 additions & 0 deletions classes/Loader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php namespace Inggo\WPAR;

class Loader
{
public function __construct($plugin_dir)
{
if (!class_exists('Inggo\WPAR\TemplateOverrider')) {
include_once($plugin_dir . 'classes/TemplateOverrider.php');
}
$this->template_overrider = new TemplateOverrider($plugin_dir);
}
}
31 changes: 31 additions & 0 deletions classes/TemplateOverrider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php namespace Inggo\WPAR;

class TemplateOverrider
{
protected $plugin_dir;

public function __construct($plugin_dir)
{
$this->plugin_dir = $plugin_dir;

add_filter('template_include', array($this, 'load_template'), 99);
}

public function load_template($template)
{
if ($this->maybe_load_template()) {
$react_template = locate_template(array('wp-react.php'));
if ($react_template !== '') {
return $react_template;
} else {
return load_template($this->plugin_dir . '/templates/wp-react.php');
}
}
return $template;
}

public function maybe_load_template()
{
return get_query_var('name') === 'react-admin';
}
}
20 changes: 20 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');

gulp.task('build', function () {
return browserify('./src/js/app.jsx', { extensions: ['.jsx'], debug: true })
.transform("babelify", {
presets: ['es2015', 'react']
})
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('js'));
});

gulp.task('watch', ['build'], function () {
gulp.watch('./src/**/*.jsx', ['build']);
});

gulp.task('default', ['watch']);
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Looking for something to read? Try http://eat.nyo.me :)
Loading

0 comments on commit 17abf9d

Please sign in to comment.