Skip to content

Commit

Permalink
Merge pull request #8 from joanrodas/dev
Browse files Browse the repository at this point in the history
Roles
  • Loading branch information
joanrodas authored Apr 24, 2022
2 parents 3055625 + 2f472b9 commit 9d9103f
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 64 deletions.
2 changes: 1 addition & 1 deletion General/ApiEndpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApiEndpoints {
public function __construct( $plugin_name, $plugin_version ) {
$this->plugin_name = $plugin_name;
$this->plugin_version = $plugin_version;
add_filter( 'plubo/routes', array($this, 'add_endpoints') );
add_filter( 'plubo/endpoints', array($this, 'add_endpoints') );
}

public function add_endpoints($endpoints) {
Expand Down
16 changes: 16 additions & 0 deletions General/Roles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace PluginPlaceholder\General;

class Roles {
public function __construct()
{
add_filter('plubo/roles', array($this, 'update_roles'));
}

public function update_roles($roles)
{
// $roles[] = pb_role('test', 'Rol test')->extend('subscriber');
$roles[] = pb_role('subscriber')->rename('Patata');
return $roles;
}
}
6 changes: 3 additions & 3 deletions General/Shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class Shortcodes {

private $blade;

public function __construct( $plugin_name, $plugin_version ) {
public function __construct( $plugin_name, $plugin_version ) {
$this->plugin_name = $plugin_name;
$this->plugin_version = $plugin_version;
$this->blade = BladeLoader::getInstance();

add_action( 'init', array($this, 'add_shortcodes') );
add_action( 'init', array($this, 'add_shortcodes') );
}

public function add_shortcodes() {
add_shortcode( 'test', array($this, 'example_function') );
//add_shortcode( 'test', array($this, 'example_function') );
return;
}

Expand Down
31 changes: 17 additions & 14 deletions Includes/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PluginPlaceholder\General\CustomFields;
use PluginPlaceholder\General\CustomPostTypes;
use PluginPlaceholder\General\Routes;
use PluginPlaceholder\General\Roles;
use PluginPlaceholder\General\Shortcodes;
use PluginPlaceholder\General\Taxonomies;

Expand All @@ -22,39 +23,41 @@ class Loader {
public function __construct() {
$this->plugin_version = defined( 'PLUGIN_PLACEHOLDER_VERSION' ) ? PLUGIN_PLACEHOLDER_VERSION : '1.0.0';
$this->plugin_name = 'plugin-placeholder';
$this->load_dependencies();
$this->load_dependencies();
}

private function load_dependencies() {
\PluboRoutes\RoutesProcessor::init();
\PluboRoles\RolesProcessor::init();

$plugin_i18n = new Languages();

$react = new ReactLoader( $this->plugin_name, $this->plugin_version );

$admin_menus = new AdminMenus($this->plugin_name, $this->plugin_version);
$ajax_actions = new AjaxActions($this->plugin_name, $this->plugin_version);
$post_actions = new PostActions($this->plugin_name, $this->plugin_version);
$ajax_actions = new AjaxActions($this->plugin_name, $this->plugin_version);
$post_actions = new PostActions($this->plugin_name, $this->plugin_version);

$api_endpoints = new ApiEndpoints($this->plugin_name, $this->plugin_version);
$custom_fields = new CustomFields($this->plugin_name, $this->plugin_version);
$custom_post_types = new CustomPostTypes($this->plugin_name, $this->plugin_version);
$routes = new Routes($this->plugin_name, $this->plugin_version);
$shortcodes = new Shortcodes($this->plugin_name, $this->plugin_version);
$taxonomies = new Taxonomies($this->plugin_name, $this->plugin_version);
$custom_fields = new CustomFields($this->plugin_name, $this->plugin_version);
$custom_post_types = new CustomPostTypes($this->plugin_name, $this->plugin_version);
$routes = new Routes($this->plugin_name, $this->plugin_version);
$roles = new Roles();
$shortcodes = new Shortcodes($this->plugin_name, $this->plugin_version);
$taxonomies = new Taxonomies($this->plugin_name, $this->plugin_version);

add_filter( 'do_shortcode_tag', function($output, $tag, $attr) {
return "<span style='display: none;' class='plubo-shortcode' data-tag='$tag'></span>" . $output;
}, 22, 3);

add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('plugin-placeholder/app.css', PLUGIN_PLACEHOLDER_URL . 'dist/app.css', false, null);
wp_enqueue_script('plugin-placeholder/app.js', PLUGIN_PLACEHOLDER_URL . 'dist/app.js', [], null, true);
wp_enqueue_style('plugin-placeholder/app.css', PLUGIN_PLACEHOLDER_URL . 'dist/app.css', false, null);
wp_enqueue_script('plugin-placeholder/app.js', PLUGIN_PLACEHOLDER_URL . 'dist/app.js', [], null, true);

wp_localize_script( 'plugin-placeholder/app.js', 'plugin_placeholder_ajax', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'ajax-nonce' ),
) );
wp_localize_script( 'plugin-placeholder/app.js', 'plugin_placeholder_ajax', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'ajax-nonce' ),
) );
}, 100);
}
}
4 changes: 2 additions & 2 deletions React/ReactLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function load_react() {
global $apps;
foreach ($apps as $script_handle) {
$script_path = 'apps/'.$script_handle.'/build/index.js';
$script_asset_path = PLUGIN_PLACEHOLDER_PATH . 'react/apps/' . $script_handle.'/build/index.asset.php';
$script_asset_path = PLUGIN_PLACEHOLDER_PATH . 'React/apps/' . $script_handle.'/build/index.asset.php';
$script_asset = file_exists( $script_asset_path )
? require $script_asset_path
: array(
Expand All @@ -37,7 +37,7 @@ public function load_react() {
foreach ($apps as $script_handle) {
add_shortcode( $script_handle, function($atts, $content, $script_handle) {
wp_enqueue_script( $script_handle );
return "<div id='$script_handle'></div>";
return "<div id='react-$script_handle'></div>";
} );
}
} );
Expand Down
41 changes: 21 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,32 @@
"homepage": "https://github.com/joanrodas/plubo",
"license": "GPL-3.0+",
"authors": [
{
"name": "Joan Rodas Cusidó",
"email": "joan@sirvelia.com",
"homepage": "https://sirvelia.com",
"role": "Developer"
}
{
"name": "Joan Rodas Cusidó",
"email": "joan@sirvelia.com",
"homepage": "https://sirvelia.com",
"role": "Developer"
}
],
"autoload": {
"psr-4": {
"PluginPlaceholder\\": ""
}
"psr-4": {
"PluginPlaceholder\\": ""
}
},
"require": {
"php": ">=7.4",
"jenssegers/blade": "1.4.0",
"htmlburger/carbon-fields": "3.3.2",
"joanrodas/plubo-routes": "0.5.1"
"php": ">=7.4",
"jenssegers/blade": "1.4.0",
"htmlburger/carbon-fields": "3.3.2",
"joanrodas/plubo-routes": "0.5.1",
"joanrodas/plubo-roles": "0.1.2"
},
"scripts": {
"post-create-project-cmd": [
"chmod +x plubo.sh && ./plubo.sh",
"chmod +x plubo && php -f plubo init"
],
"zip": [
"PLUGIN_DIR=${PWD##*/} && cd .. && zip -r $PLUGIN_DIR/$PLUGIN_DIR.zip $PLUGIN_DIR -x $PLUGIN_DIR/plubo $PLUGIN_DIR/plubo.sh $PLUGIN_DIR/package.json $PLUGIN_DIR/package-lock.json $PLUGIN_DIR/composer.json $PLUGIN_DIR/composer.lock $PLUGIN_DIR/tailwind.config.js $PLUGIN_DIR/yarn.lock $PLUGIN_DIR/.git/\\* $PLUGIN_DIR/.gitignore $PLUGIN_DIR/.eslintrc.js $PLUGIN_DIR/.stylelintrc.js $PLUGIN_DIR/.editorconfig $PLUGIN_DIR/vendor/\\* $PLUGIN_DIR/node_modules/\\*"
]
"post-create-project-cmd": [
"chmod +x plubo.sh && ./plubo.sh",
"chmod +x plubo && php -f plubo init"
],
"zip": [
"PLUGIN_DIR=${PWD##*/} && cd .. && zip -r $PLUGIN_DIR/$PLUGIN_DIR.zip $PLUGIN_DIR -x $PLUGIN_DIR/plubo $PLUGIN_DIR/plubo.sh $PLUGIN_DIR/package.json $PLUGIN_DIR/package-lock.json $PLUGIN_DIR/composer.json $PLUGIN_DIR/composer.lock $PLUGIN_DIR/tailwind.config.js $PLUGIN_DIR/yarn.lock $PLUGIN_DIR/.git/\\* $PLUGIN_DIR/.gitignore $PLUGIN_DIR/.eslintrc.js $PLUGIN_DIR/.stylelintrc.js $PLUGIN_DIR/.editorconfig $PLUGIN_DIR/vendor/\\* $PLUGIN_DIR/node_modules/\\*"
]
}
}
86 changes: 71 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9d9103f

Please sign in to comment.