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

Wordpress Core Settings Patch #661

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

kidunot89
Copy link
Member

@kidunot89 kidunot89 commented Jan 23, 2019

Your checklist for this pull request

Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

What does this implement/fix? Explain your changes.

Registers the following options as settings using the WordPress Settings API, so they can be loaded to the $wp_registered_settings object and read by DataSource::get_allowed_settings_by_group and DataSource::get_allowed_settings functions.

Discussion Settings

  • default_pingback_flag
  • comments_notify
  • moderation_notify
  • comment_moderation
  • require_name_email
  • comment_whitelist
  • comment_max_links
  • moderation_keys
  • blacklist_keys
  • show_avatars
  • avatar_rating
  • avatar_default
  • close_comments_for_old_posts
  • close_comments_days_old
  • thread_comments
  • thread_comments_depth
  • page_comments
  • comments_per_page
  • default_comments_page
  • comment_order
  • comment_registration
  • show_comments_cookies_opt_in

Media Settings

  • thumbnail_size_w
  • thumbnail_size_h
  • thumbnail_crop
  • medium_size_w
  • medium_size_h
  • large_size_w
  • large_size_h

Permalink Settings

  • permalink_structure
  • category_base
  • tag_base

Privacy Settings

  • wp_page_for_privacy_policy

Reading Settings

  • posts_per_rss
  • rss_use_excerpt
  • show_on_front
  • page_on_front
  • page_for_posts
  • blog_public

Writing Settings

  • default_email_category
  • default_link_category

Does this close any currently open issues?

Any relevant logs, error output, GraphiQL screenshots, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?

Where has this been tested?

Operating System: Ubuntu 18.04

WordPress Version: 5.0.3

@codecov
Copy link

codecov bot commented Jan 23, 2019

Codecov Report

Merging #661 into develop will decrease coverage by 0.29%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop     #661     +/-   ##
==========================================
- Coverage     60.4%   60.11%   -0.3%     
==========================================
  Files          109      110      +1     
  Lines         6678     6739     +61     
==========================================
+ Hits          4034     4051     +17     
- Misses        2644     2688     +44
Impacted Files Coverage Δ
wp-graphql.php 50% <0%> (-0.36%) ⬇️
src/Data/ConnectionResolver.php 77.66% <0%> (-7.77%) ⬇️
src/Server/WPHelper.php 92.3% <0%> (-7.7%) ⬇️
src/Type/Object/MenuItem.php 46.59% <0%> (-6.82%) ⬇️
src/Connection/MenuItems.php 62.96% <0%> (-3.71%) ⬇️
src/Connection/PostObjects.php 43.6% <0%> (-2.6%) ⬇️
src/Mutation/TermObjectUpdate.php 64.44% <0%> (-2.23%) ⬇️
src/Utils/InstrumentSchema.php 94.44% <0%> (-1.86%) ⬇️
src/Data/PostObjectConnectionResolver.php 68.29% <0%> (-1.13%) ⬇️
src/Connection/Users.php 32.97% <0%> (-1.07%) ⬇️
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ca0580...7f89d70. Read the comment docs.

'description' => __( 'Maximum height for large-sized content in pixels to use when adding an image to the Media Library', 'wp-graphql' )
),
/**
* TODO: Get more info on these three options
Copy link
Collaborator

Choose a reason for hiding this comment

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

@kidunot89 I'll have to look into this as well 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kidunot89 looks like image_default_size should be an Enum of registered image sizes, eh? 🤔

public function testPatchSettingsQuery()
{
$mock_options = [
'default_pingback_flag' => 1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

spacing looks weird on this line 🤷‍♂️

showCommentsCookiesOptIn
}
mediaSettings {
thumbnailSizeW
Copy link
Collaborator

Choose a reason for hiding this comment

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

not that big of a deal, but it kinda bugs me that this is named thumbailSizeW instead of thumbnailSizeWidth 🤔

how are other image sizes handled, like when you add_image_size() (https://developer.wordpress.org/reference/functions/add_image_size/)

Copy link
Collaborator

Choose a reason for hiding this comment

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

wait, actually, there aren't settings for additional sizes, because you register them statically. . .duh. . .lol

disregard. 🤦‍♂️

Copy link
Collaborator

@jasonbahl jasonbahl left a comment

Choose a reason for hiding this comment

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

@kidunot89 I think my only complaint is with the naming of the image sizes using W and H instead of Width and Height.

I understand why that's the case, but just bugs me.

Wonder if we should allow register_setting() to add an additional field like graphql_field_name or something like that, similar to how we have graphql_single_name for register_post_type

🤔

jasonbahl
jasonbahl previously approved these changes Jan 26, 2019
Copy link
Collaborator

@jasonbahl jasonbahl left a comment

Choose a reason for hiding this comment

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

Another quick glance from my phone and this looks good. I’ll approve but want to pull it locally and run through a few things before I merge. But looks good!

@CodeProKid CodeProKid added this to the 0.2.2 milestone Jan 29, 2019
@jasonbahl
Copy link
Collaborator

I pulled this locally and I'm getting a lot of PHP errors. Looking into it 👀

'description' => __( 'Base Tag URLs', 'wp-graphql' )
),
),
'privacy' => array(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get the following php error:

( ! ) Notice: register_setting was called with an argument that is <strong>deprecated</strong> since version 3.5.0! The "privacy" options group has been removed. Use another settings group. in /app/public/wp-includes/functions.php on line 4115

It also looks like the privacy options have their own capabilities associated: https://github.com/WordPress/WordPress/blob/47e29ccba94fe9342785585b80ddc9b4a8039aa2/wp-admin/privacy.php#L12

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't gonna that error, but I have used it in production yet. I'll also look into it when I can

'description' => __( 'Maximum height for large-sized content in pixels to use when adding an image to the Media Library', 'wp-graphql' )
),
/**
* TODO: Get more info on these three options
Copy link
Collaborator

Choose a reason for hiding this comment

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

@kidunot89 looks like image_default_size should be an Enum of registered image sizes, eh? 🤔

'comment_order' => array(
'show_in_rest' => array(
'schema' => array(
'enum' => array( 'asc', 'desc' ),
Copy link
Collaborator

Choose a reason for hiding this comment

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

so for fields like this that are exposed as an Enum in REST should probably also be exposed in GraphQL as an enum.

No reason this should be a String in GraphQL if we have the power to validate against a static enum already 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

register_setting doesn't have any enum type to my knowledge. string, integer, and boolean are the only types as far as I know. I used register_initial_setting as an example.

@jasonbahl
Copy link
Collaborator

Related: #674

@CodeProKid CodeProKid modified the milestones: 0.2.2, 0.2.3 Feb 7, 2019
@jasonbahl jasonbahl modified the milestones: 0.2.3, v0.2.4 Mar 18, 2019
@CodeProKid CodeProKid removed this from the 0.3.1 milestone Apr 16, 2019
@jasonbahl jasonbahl added this to To Prioritize in 4: Actionable Issues Aug 7, 2019
@stale
Copy link

stale bot commented Aug 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 2, 2022
@stale
Copy link

stale bot commented Sep 1, 2022

This issue has been automatically closed because it has not had recent activity. If you believe this issue is still valid, please open a new issue and mark this as a related issue.

@stale stale bot closed this Sep 1, 2022
@justlevine justlevine reopened this Sep 2, 2022
@stale stale bot removed the stale label Sep 2, 2022
/**
* Registers WordPress options not loaded by Settings API by default
*/
function patch_whitelist_options() {
Copy link

Choose a reason for hiding this comment

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

Method patch_whitelist_options has 286 lines of code (exceeds 25 allowed). Consider refactoring.

'type' => 'boolean',
'description' => __( 'Discourage search engines from indexing this site', 'wp-graphql' )
),
),
Copy link

Choose a reason for hiding this comment

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

Spaces must be used for alignment; tabs are not allowed

@@ -225,6 +225,9 @@ private function includes() {
// Required non-autoloaded classes
require_once( WPGRAPHQL_PLUGIN_DIR . 'access-functions.php' );

// Required wordpress core patches
Copy link

Choose a reason for hiding this comment

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

Spaces must be used to indent lines; tabs are not allowed

@@ -225,6 +225,9 @@ private function includes() {
// Required non-autoloaded classes
require_once( WPGRAPHQL_PLUGIN_DIR . 'access-functions.php' );

// Required wordpress core patches
require_once( WPGRAPHQL_PLUGIN_DIR . 'settings-patch.php' );
Copy link

Choose a reason for hiding this comment

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

Spaces must be used to indent lines; tabs are not allowed

@@ -225,6 +225,9 @@ private function includes() {
// Required non-autoloaded classes
require_once( WPGRAPHQL_PLUGIN_DIR . 'access-functions.php' );

// Required wordpress core patches
require_once( WPGRAPHQL_PLUGIN_DIR . 'settings-patch.php' );
Copy link

Choose a reason for hiding this comment

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

Space after opening parenthesis of function call prohibited

@codeclimate
Copy link

codeclimate bot commented Sep 2, 2022

Code Climate has analyzed commit 7f89d70 and detected 462 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 3
Style 458
Bug Risk 1

View more on Code Climate.

@stale
Copy link

stale bot commented Dec 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale? May need to be revalidated due to prolonged inactivity label Dec 1, 2022
@stale
Copy link

stale bot commented Mar 1, 2023

This issue has been automatically closed because it has not had recent activity. If you believe this issue is still valid, please open a new issue and mark this as a related issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale? May need to be revalidated due to prolonged inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants