-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update option page generation & add a new api route /terms - Version …
…bump to 3.0.6
- Loading branch information
Alberto Parziale
committed
Oct 14, 2019
1 parent
087ad83
commit 3d97101
Showing
8 changed files
with
125 additions
and
34 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
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
use Aeria\Taxonomy\Taxonomy; | ||
use Aeria\Kernel\Loader; | ||
use Aeria\Kernel\Tasks\{ | ||
CreateAdminScripts, | ||
CreateControllers, | ||
CreateField, | ||
CreateMeta, | ||
|
@@ -23,7 +24,7 @@ | |
|
||
/** | ||
* KernelServiceProvider is in charge of registering the Kernel to the container | ||
* | ||
* | ||
* @category Kernel | ||
* @package Aeria | ||
* @author Jacopo Martinelli <[email protected]> | ||
|
@@ -63,6 +64,7 @@ public function boot(Container $container): bool | |
$kernel = $container->make('kernel'); | ||
$config = $container->make('config'); | ||
Loader::loadConfig($config, $container); | ||
$kernel->register(new CreateAdminScripts()); | ||
$kernel->register(new CreateControllers()); | ||
$kernel->register(new CreateField()); | ||
$kernel->register(new CreateMeta()); | ||
|
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,42 @@ | ||
<?php | ||
|
||
namespace Aeria\Kernel\Tasks; | ||
|
||
use Aeria\Kernel\AbstractClasses\Task; | ||
|
||
/** | ||
* This task is in charge of creating options pages. | ||
* | ||
* @category Kernel | ||
* @package Aeria | ||
* @author Simone Montali <[email protected]> | ||
* @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license | ||
* @link https://github.com/caffeinalab/aeria | ||
*/ | ||
class CreateAdminScripts extends Task | ||
{ | ||
public $priority = 6; | ||
public $admin_only = true; | ||
/** | ||
* The main task method. It registers the option pages. | ||
* | ||
* @param array $args the arguments to be passed to the Task | ||
* | ||
* @return void | ||
* | ||
* @access public | ||
* @since Method available since Release 3.0.0 | ||
*/ | ||
public function do(array $args) | ||
{ | ||
add_action( | ||
'admin_head', | ||
function () use ($args) { | ||
global $_wp_admin_css_colors; | ||
$admin_colors = $_wp_admin_css_colors; | ||
$aeria_colors = $admin_colors[get_user_option('admin_color')]->colors; | ||
$args['service']['render_engine']->render('color_encoder_template', ['colors' => $aeria_colors]); | ||
} | ||
); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
/** | ||
* This task is in charge of creating options pages. | ||
* | ||
* | ||
* @category Kernel | ||
* @package Aeria | ||
* @author Simone Montali <[email protected]> | ||
|
@@ -32,7 +32,7 @@ public function do(array $args) | |
$default_icon_data = file_get_contents(dirname(__DIR__, 2).'/aeria.svg'); | ||
$default_icon = 'data:image/svg+xml;base64,'.base64_encode($default_icon_data); | ||
if (isset($args['config']['aeria']['options'])) { | ||
$section_config = isset($args['config']['aeria']['section']) ? $args['config']['aeria']['section'] : null; | ||
$section_config = isset($args['config']['aeria']['section']) ? $args['config']['aeria']['section'] : []; | ||
|
||
foreach ($args['config']['aeria']['options'] as $name => $data) { | ||
$config =[]; | ||
|
@@ -65,4 +65,4 @@ function () use ($args) { | |
); | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
/** | ||
* This task is in charge of creating the router and its routes. | ||
* | ||
* | ||
* @category Kernel | ||
* @package Aeria | ||
* @author Simone Montali <[email protected]> | ||
|
@@ -55,6 +55,13 @@ public function do(array $args) | |
return $args['service']['query']->getTaxonomies($wp_req->get_params()); | ||
} | ||
); | ||
$args['service']['router']->get( | ||
'/terms', function ($request) use ($args) { | ||
$wp_req = $request->wp_request; | ||
|
||
return $args['service']['query']->getTerms($wp_req->get_params()); | ||
} | ||
); | ||
$args['service']['router']->get( | ||
"/validate-by-id", function ($request) use ($args) { | ||
$wp_req = $request->wp_request; | ||
|
@@ -74,4 +81,4 @@ public function do(array $args) | |
} | ||
$args['service']['router']->boot(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
use Aeria\Field\FieldError; | ||
use Aeria\RenderEngine\RenderEngine; | ||
/** | ||
* OptionsPage is in charge of generating pages in WP's options | ||
* | ||
* OptionsPage is in charge of generating pages in WP's options | ||
* | ||
* @category Options | ||
* @package Aeria | ||
* @author Simone Montali <[email protected]> | ||
|
@@ -56,7 +56,7 @@ public function register($option_page) | |
&&isset($option_page["validator_service"]) | ||
&&isset($option_page["query_service"]) | ||
) | ||
$this->optionPages[]=$option_page; | ||
$this->option_pages[]=$option_page; | ||
return null; | ||
} | ||
/** | ||
|
@@ -72,35 +72,37 @@ public function register($option_page) | |
*/ | ||
public function boot($aeria_config, $render_service) | ||
{ | ||
$editor_enabled = false; | ||
$default_icon_data = file_get_contents(dirname(__DIR__).'/aeria.svg'); | ||
$default_icon = 'data:image/svg+xml;base64,'.base64_encode($default_icon_data); | ||
// Registering aeria's editor page | ||
if (empty($GLOBALS['admin_page_hooks']["aeria_options"])) { | ||
if ($editor_enabled) { | ||
add_menu_page( | ||
"Aeria editor", | ||
"Aeria", | ||
"manage_options", | ||
"aeria_options", | ||
'', | ||
$default_icon | ||
); | ||
); | ||
add_submenu_page( | ||
"aeria_options", | ||
"Editor", | ||
"Editor", | ||
"manage_options", | ||
"aeria_options", | ||
function () use ($aeria_config, $render_service) { | ||
static::renderHTML( | ||
"aeria_editor", | ||
$aeria_config, | ||
$render_service | ||
); | ||
} | ||
); | ||
} | ||
add_submenu_page( | ||
"aeria_options", | ||
"Editor", | ||
"Editor", | ||
"manage_options", | ||
"aeria_options", | ||
function () use ($aeria_config, $render_service) { | ||
static::renderHTML( | ||
"aeria_editor", | ||
$aeria_config, | ||
$render_service | ||
); | ||
} | ||
); | ||
|
||
// Registering other option pages | ||
foreach ($this->optionPages as $singleOptionPage) { | ||
foreach ($this->option_pages as $singleOptionPage) { | ||
// Check if nav menu parent exists | ||
if (empty($GLOBALS['admin_page_hooks'][$singleOptionPage["parent"]])) { | ||
add_menu_page( | ||
|
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
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