-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
86 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,16 @@ | ||
<?php declare( strict_types=1 ); | ||
|
||
/** | ||
* ASMP WordPress Integration Plugin. | ||
* | ||
* @package ASMP\WordPressIntegration | ||
* @license MIT | ||
* @link https://www.alainschlesser.com/asmp | ||
*/ | ||
|
||
namespace ASMP\WordPressIntegration; | ||
|
||
interface ASMP { | ||
public const VERSION = 'ASMP_DISCOVERY_VERSION'; | ||
public const ENDPOINT = 'ASMP_DISCOVERY_ENDPOINT'; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* ASMP WordPress Integration Plugin. | ||
* | ||
* @package ASMP\WordPressIntegration | ||
* @license MIT | ||
* @link https://www.alainschlesser.com/asmp | ||
*/ | ||
|
||
namespace ASMP\WordPressIntegration; | ||
|
||
use ASMP\WordPressIntegration\Infrastructure\Registerable; | ||
use ASMP\WordPressIntegration\Infrastructure\Service; | ||
use ASMP\WordPressIntegration\Infrastructure\ViewFactory; | ||
|
||
/** | ||
* | ||
*/ | ||
final class SettingsGeneralService implements Service, Registerable { | ||
|
||
/** @var ViewFactory */ | ||
private $view_factory; | ||
|
||
/** | ||
* Instantiate a SampleService object. | ||
* | ||
* @param ViewFactory $view_factory View factory to use for instantiating | ||
* the views. | ||
*/ | ||
public function __construct( ViewFactory $view_factory ) { | ||
$this->view_factory = $view_factory; | ||
} | ||
|
||
/** | ||
* Register the service. | ||
* | ||
* @return void | ||
*/ | ||
public function register(): void { | ||
if ( ! isset( $_SERVER[ ASMP::VERSION ] ) ) { | ||
// TODO return; | ||
} | ||
|
||
// TODO | ||
$_SERVER[ ASMP::ENDPOINT ] = [ '5.6', '7.0', '7.2' ]; | ||
|
||
add_action( 'admin_init', function() { | ||
\add_settings_field( 'asmp', esc_html__( 'PHP Versions', 'asmp' ), [ $this, 'render' ], 'general' ); | ||
} ); | ||
} | ||
|
||
/** | ||
* Render the admin notice. | ||
* | ||
* @return void | ||
*/ | ||
public function render(): void { | ||
echo $this->view_factory->create( 'views/setting' ) | ||
->render(); | ||
} | ||
} | ||
|
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,7 @@ | ||
<select id="php_version" name="php_version"> | ||
<?php | ||
foreach ( $_SERVER[ ASMP\WordPressIntegration\ASMP::ENDPOINT ] as $version ) : | ||
printf( '<option value="%1$s">%1$s</option>', $version ); | ||
endforeach; | ||
?> | ||
</select> |