Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin settings refactor - WP_Auth0_Admin_Generic #416

Merged
merged 1 commit into from
Mar 26, 2018

Conversation

joshcanhelp
Copy link
Contributor

@joshcanhelp joshcanhelp commented Mar 26, 2018

Admin settings have confusing wording, inconsistent behavior, and
broken links and translation. This first PR refactors the description
system to be more straight-forward, adds HTML generation functions for
consistent field outputs (used in future commits), adds settings page
description translation, and fixes a few other minor code issues.

First of a few smaller PRs to replace #396

Admins settings have confusing wording, inconsistent behavior, and
broken links and translation. This first PR refactors the description
system to be more straight-forward, adds HTML generation functions for
consistent field outputs (used in future commits), adds settings page
description translation, and fixes a few other minor code issues.

First of a few smaller PRs to replace #396
@joshcanhelp joshcanhelp added this to the v3-Next milestone Mar 26, 2018
@joshcanhelp joshcanhelp self-assigned this Mar 26, 2018
@@ -3,7 +3,7 @@ class WP_Auth0_Api_Operations {

protected $a0_options;

public function __construct( WP_Auth0_Options $a0_options ) {
public function __construct( WP_Auth0_Options_Generic $a0_options ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, WP_Auth0_Options extends WP_Auth0_Options_Generic

public function __construct( WP_Auth0_Options_Generic $options, WP_Auth0_Routes $router ) {
parent::__construct( $options );
$this->router = $router;
$this->_description = __( 'Settings related to specific scenarios.', 'wp-auth0' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be localized (i18n)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__() is the WP localizing function

@@ -2,12 +2,25 @@

class WP_Auth0_Admin_Basic extends WP_Auth0_Admin_Generic {

// TODO: Deprecate
const BASIC_DESCRIPTION = 'Basic settings related to Auth0 credentials and basic WordPress integration.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this public or why can't it be deleted instead of deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants are public, can't be anything but. Unlikely that anyone would be using it but ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you change the content of the constant but keep it named like that? and then use it from the description at line 21.

const BASIC_DESCRIPTION = 'Basic settings related to the Auth0 integration.';

//....

$this->_description = __( BASIC_DESCRIPTION, 'wp-auth0' );

that way you don't need to deprecate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice but __() does not accept a variable for a string to translate because of how those are generated

*/
public function __construct( WP_Auth0_Options_Generic $options ) {
parent::__construct( $options );
$this->_description = __( 'Basic settings related to the Auth0 integration.', 'wp-auth0' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be localized (i18n)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@@ -3,20 +3,29 @@
class WP_Auth0_Admin_Generic {

protected $options;
protected $_option_name;
protected $_description;
protected $_textarea_rows = 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be _text_area_rows or what is the convention you are following?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textarea like the HTML element

* Render description at the top of the settings block
*/
public function render_description() {
if ( ! empty( $this->_description ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._description is never set. On the contrary, _option_name is set on the __construct method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extending classes set this, parent class doesn't need one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm OK. It's a little weird to me, but if this is they way you do it on php I'm fine.

* Wrapper for add_settings_error
*
* @param string $error - translated error message
*/
protected function add_validation_error( $error ) {
add_settings_error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this method? add_settings_error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core WP

Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions sorted

@joshcanhelp joshcanhelp merged commit b8b2acb into dev Mar 26, 2018
@joshcanhelp joshcanhelp deleted the add-settings-page-output-func branch March 26, 2018 19:01
@joshcanhelp joshcanhelp mentioned this pull request Jun 5, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants