Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
2,069 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* @package AlecadddPlugin | ||
*/ | ||
/* | ||
Plugin Name: Alecaddd Plugin | ||
Plugin URI: http://alecaddd.com/plugin | ||
Description: This is my first attempt on writing a custom Plugin for this amazing tutorial series. | ||
Version: 1.0.0 | ||
Author: Alessandro "Alecaddd" Castellani | ||
Author URI: http://alecaddd.com | ||
License: GPLv2 or later | ||
Text Domain: alecaddd-plugin | ||
*/ | ||
|
||
/* | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
Copyright 2005-2015 Automattic, Inc. | ||
*/ | ||
|
||
// If this file is called firectly, abort!!! | ||
defined( 'ABSPATH' ) or die( 'Hey, what are you doing here? You silly human!' ); | ||
|
||
// Require once the Composer Autoload | ||
if ( file_exists( dirname( __FILE__ ) . '/vendor/autoload.php' ) ) { | ||
require_once dirname( __FILE__ ) . '/vendor/autoload.php'; | ||
} | ||
|
||
/** | ||
* The code that runs during plugin activation | ||
*/ | ||
function activate_alecaddd_plugin() { | ||
Inc\Base\Activate::activate(); | ||
} | ||
register_activation_hook( __FILE__, 'activate_alecaddd_plugin' ); | ||
|
||
/** | ||
* The code that runs during plugin deactivation | ||
*/ | ||
function deactivate_alecaddd_plugin() { | ||
Inc\Base\Deactivate::deactivate(); | ||
} | ||
register_deactivation_hook( __FILE__, 'deactivate_alecaddd_plugin' ); | ||
|
||
/** | ||
* Initialize all the core classes of the plugin | ||
*/ | ||
if ( class_exists( 'Inc\\Init' ) ) { | ||
Inc\Init::register_services(); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "alecaddd/alecaddd-plugin", | ||
"description": "Awesome starter plugin example", | ||
"type": "project", | ||
"license": "GPL-3.0", | ||
"authors": [ | ||
{ | ||
"name": "Alecaddd", | ||
"email": "castellani.ale@gmail.com" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": {}, | ||
"autoload": { | ||
"psr-4": {"Inc\\": "./inc"} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Load Gulp...of course | ||
var gulp = require( 'gulp' ); | ||
|
||
// CSS related plugins | ||
var sass = require( 'gulp-sass' ); | ||
var autoprefixer = require( 'gulp-autoprefixer' ); | ||
var minifycss = require( 'gulp-uglifycss' ); | ||
|
||
// JS related plugins | ||
var concat = require( 'gulp-concat' ); | ||
var uglify = require( 'gulp-uglify' ); | ||
var babelify = require( 'babelify' ); | ||
var browserify = require( 'browserify' ); | ||
var source = require( 'vinyl-source-stream' ); | ||
var buffer = require( 'vinyl-buffer' ); | ||
var stripDebug = require( 'gulp-strip-debug' ); | ||
|
||
// Utility plugins | ||
var rename = require( 'gulp-rename' ); | ||
var sourcemaps = require( 'gulp-sourcemaps' ); | ||
var notify = require( 'gulp-notify' ); | ||
var plumber = require( 'gulp-plumber' ); | ||
var options = require( 'gulp-options' ); | ||
var gulpif = require( 'gulp-if' ); | ||
|
||
// Browers related plugins | ||
var browserSync = require( 'browser-sync' ).create(); | ||
var reload = browserSync.reload; | ||
|
||
// Project related variables | ||
var projectURL = 'https://test.dev'; | ||
|
||
var styleSRC = 'src/scss/mystyle.scss'; | ||
var styleURL = './assets/'; | ||
var mapURL = './'; | ||
|
||
var jsSRC = 'src/js/myscript.js'; | ||
var jsURL = './assets/'; | ||
|
||
var styleWatch = 'src/scss/**/*.scss'; | ||
var jsWatch = 'src/js/**/*.js'; | ||
var phpWatch = '**/*.php'; | ||
|
||
// Tasks | ||
gulp.task( 'browser-sync', function() { | ||
browserSync.init({ | ||
proxy: projectURL, | ||
https: { | ||
key: '/Users/alecaddd/.valet/Certificates/test.dev.key', | ||
cert: '/Users/alecaddd/.valet/Certificates/test.dev.crt' | ||
}, | ||
injectChanges: true, | ||
open: false | ||
}); | ||
}); | ||
|
||
gulp.task( 'styles', function() { | ||
gulp.src( styleSRC ) | ||
.pipe( sourcemaps.init() ) | ||
.pipe( sass({ | ||
errLogToConsole: true, | ||
outputStyle: 'compressed' | ||
}) ) | ||
.on( 'error', console.error.bind( console ) ) | ||
.pipe( autoprefixer({ browsers: [ 'last 2 versions', '> 5%', 'Firefox ESR' ] }) ) | ||
.pipe( sourcemaps.write( mapURL ) ) | ||
.pipe( gulp.dest( styleURL ) ) | ||
.pipe( browserSync.stream() ); | ||
}); | ||
|
||
gulp.task( 'js', function() { | ||
return browserify({ | ||
entries: [jsSRC] | ||
}) | ||
.transform( babelify, { presets: [ 'env' ] } ) | ||
.bundle() | ||
.pipe( source( 'myscript.js' ) ) | ||
.pipe( buffer() ) | ||
.pipe( gulpif( options.has( 'production' ), stripDebug() ) ) | ||
.pipe( sourcemaps.init({ loadMaps: true }) ) | ||
.pipe( uglify() ) | ||
.pipe( sourcemaps.write( '.' ) ) | ||
.pipe( gulp.dest( jsURL ) ) | ||
.pipe( browserSync.stream() ); | ||
}); | ||
|
||
function triggerPlumber( src, url ) { | ||
return gulp.src( src ) | ||
.pipe( plumber() ) | ||
.pipe( gulp.dest( url ) ); | ||
} | ||
|
||
gulp.task( 'default', ['styles', 'js'], function() { | ||
gulp.src( jsURL + 'myscript.min.js' ) | ||
.pipe( notify({ message: 'Assets Compiled!' }) ); | ||
}); | ||
|
||
gulp.task( 'watch', ['default', 'browser-sync'], function() { | ||
gulp.watch( phpWatch, reload ); | ||
gulp.watch( styleWatch, [ 'styles' ] ); | ||
gulp.watch( jsWatch, [ 'js', reload ] ); | ||
gulp.src( jsURL + 'myscript.min.js' ) | ||
.pipe( notify({ message: 'Gulp is Watching, Happy Coding!' }) ); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* @package AlecadddPlugin | ||
*/ | ||
namespace Inc\Api\Callbacks; | ||
|
||
use Inc\Base\BaseController; | ||
|
||
class AdminCallbacks extends BaseController | ||
{ | ||
public function adminDashboard() | ||
{ | ||
return require_once( "$this->plugin_path/templates/admin.php" ); | ||
} | ||
|
||
public function adminCpt() | ||
{ | ||
return require_once( "$this->plugin_path/templates/cpt.php" ); | ||
} | ||
|
||
public function adminTaxonomy() | ||
{ | ||
return require_once( "$this->plugin_path/templates/taxonomy.php" ); | ||
} | ||
|
||
public function adminWidget() | ||
{ | ||
return require_once( "$this->plugin_path/templates/widget.php" ); | ||
} | ||
|
||
public function adminGallery() | ||
{ | ||
echo "<h1>Gallery Manager</h1>"; | ||
} | ||
|
||
public function adminTestimonial() | ||
{ | ||
echo "<h1>Testimonial Manager</h1>"; | ||
} | ||
|
||
public function adminTemplates() | ||
{ | ||
echo "<h1>Templates Manager</h1>"; | ||
} | ||
|
||
public function adminAuth() | ||
{ | ||
echo "<h1>Templates Manager</h1>"; | ||
} | ||
|
||
public function adminMembership() | ||
{ | ||
echo "<h1>Membership Manager</h1>"; | ||
} | ||
|
||
public function adminChat() | ||
{ | ||
echo "<h1>Chat Manager</h1>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* @package AlecadddPlugin | ||
*/ | ||
namespace Inc\Api\Callbacks; | ||
|
||
class CptCallbacks | ||
{ | ||
|
||
public function cptSectionManager() | ||
{ | ||
echo 'Create as many Custom Post Types as you want.'; | ||
} | ||
|
||
public function cptSanitize( $input ) | ||
{ | ||
$output = get_option('alecaddd_plugin_cpt'); | ||
|
||
if ( isset($_POST["remove"]) ) { | ||
unset($output[$_POST["remove"]]); | ||
|
||
return $output; | ||
} | ||
|
||
if ( count($output) == 0 ) { | ||
$output[$input['post_type']] = $input; | ||
|
||
return $output; | ||
} | ||
|
||
foreach ($output as $key => $value) { | ||
if ($input['post_type'] === $key) { | ||
$output[$key] = $input; | ||
} else { | ||
$output[$input['post_type']] = $input; | ||
} | ||
} | ||
|
||
return $output; | ||
} | ||
|
||
public function textField( $args ) | ||
{ | ||
$name = $args['label_for']; | ||
$option_name = $args['option_name']; | ||
$value = ''; | ||
|
||
if ( isset($_POST["edit_post"]) ) { | ||
$input = get_option( $option_name ); | ||
$value = $input[$_POST["edit_post"]][$name]; | ||
} | ||
|
||
echo '<input type="text" class="regular-text" id="' . $name . '" name="' . $option_name . '[' . $name . ']" value="' . $value . '" placeholder="' . $args['placeholder'] . '" required>'; | ||
} | ||
|
||
public function checkboxField( $args ) | ||
{ | ||
$name = $args['label_for']; | ||
$classes = $args['class']; | ||
$option_name = $args['option_name']; | ||
$checked = false; | ||
|
||
if ( isset($_POST["edit_post"]) ) { | ||
$checkbox = get_option( $option_name ); | ||
$checked = isset($checkbox[$_POST["edit_post"]][$name]) ?: false; | ||
} | ||
|
||
echo '<div class="' . $classes . '"><input type="checkbox" id="' . $name . '" name="' . $option_name . '[' . $name . ']" value="1" class="" ' . ( $checked ? 'checked' : '') . '><label for="' . $name . '"><div></div></label></div>'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* @package AlecadddPlugin | ||
*/ | ||
namespace Inc\Api\Callbacks; | ||
|
||
use Inc\Base\BaseController; | ||
|
||
class ManagerCallbacks extends BaseController | ||
{ | ||
public function checkboxSanitize( $input ) | ||
{ | ||
$output = array(); | ||
|
||
foreach ( $this->managers as $key => $value ) { | ||
$output[$key] = isset( $input[$key] ) ? true : false; | ||
} | ||
|
||
return $output; | ||
} | ||
|
||
public function adminSectionManager() | ||
{ | ||
echo 'Manage the Sections and Features of this Plugin by activating the checkboxes from the following list.'; | ||
} | ||
|
||
public function checkboxField( $args ) | ||
{ | ||
$name = $args['label_for']; | ||
$classes = $args['class']; | ||
$option_name = $args['option_name']; | ||
$checkbox = get_option( $option_name ); | ||
$checked = isset($checkbox[$name]) ? ($checkbox[$name] ? true : false) : false; | ||
|
||
echo '<div class="' . $classes . '"><input type="checkbox" id="' . $name . '" name="' . $option_name . '[' . $name . ']" value="1" class="" ' . ( $checked ? 'checked' : '') . '><label for="' . $name . '"><div></div></label></div>'; | ||
} | ||
} |
Oops, something went wrong.