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

Hide the override settings #362

Merged
merged 2 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions includes/classes/SiteAutomation/EndPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ public function site_automation( $request ) {
}

$curated_posts_new = [];
foreach ( $curated_posts as $index => $curated_post ) {
$curated_posts_new[ $index ] = $this->get_post_details( $curated_post, $rules );
if ( is_array( $curated_posts ) ) {
foreach ( $curated_posts as $index => $curated_post ) {
$curated_posts_new[ $index ] = $this->get_post_details( $curated_post, $rules );
}
}
$curated_posts = $curated_posts_new;

Expand Down Expand Up @@ -209,8 +211,8 @@ public function site_automation_params() {
*/
public function site_automation_permission(){
$current_user = wp_get_current_user();
if ( ! $current_user->exists() ) {

if ( ! $current_user->exists() ) {
return new \WP_Error(401, __( 'Unauthorised user, please log in.', 'sophi-wp' ) );
}

Expand Down Expand Up @@ -366,4 +368,4 @@ public function site_automation_override_params() {
*/
return apply_filters( 'site_automation_override_params', $params );
}
}
}
23 changes: 17 additions & 6 deletions includes/functions/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function fields_setup() {
SETTINGS_GROUP,
'collector_settings',
[
'label_for' => 'collector_url',
'label_for' => 'collector_url',
'description' => __( 'Please use URL without http(s) scheme.', 'sophi-wp' ),
]
);
Expand Down Expand Up @@ -200,6 +200,9 @@ function fields_setup() {
]
);

/* // phpcs:ignore
Commenting out the Sophi Override settings for now.

// Add Auth settings section.
add_settings_section(
'sophi_api_auth',
Expand Down Expand Up @@ -241,6 +244,7 @@ function fields_setup() {
'description' => __( 'For example, https://xyz.sophi.io/v1/, please add a slash (/) in the end.', 'sophi-wp' ),
]
);
*/

// Add Advanced settings section.
add_settings_section(
Expand Down Expand Up @@ -325,13 +329,13 @@ function sanitize_settings( $settings ) {
$settings['query_integration'] = 0;
}

if ( empty( $settings['site_automation_url']) ) {
if ( empty( $settings['site_automation_url'] ) ) {
add_settings_error(
SETTINGS_GROUP,
SETTINGS_GROUP,
__( 'Site Automation URL is required for Site Automation integration.', 'sophi-wp' )
);
} else if ( ! filter_var( $settings['site_automation_url'], FILTER_VALIDATE_URL ) ) {
} elseif ( ! filter_var( $settings['site_automation_url'], FILTER_VALIDATE_URL ) ) {
add_settings_error(
SETTINGS_GROUP,
SETTINGS_GROUP,
Expand All @@ -343,26 +347,30 @@ function sanitize_settings( $settings ) {
add_settings_error(
SETTINGS_GROUP,
SETTINGS_GROUP,
/* translators: %s is replaced with the tracker URL */
sprintf( __( 'Tracker Address URL is invalid: %s', 'sophi-wp' ), $settings['tracker_address'] )
);
unset( $settings['tracker_address'] );
}

if ( empty( $settings['sophi_override_url']) ) {
/* // phpcs:ignore
Commenting out the Sophi Override settings for now.
if ( empty( $settings['sophi_override_url'] ) ) {
add_settings_error(
SETTINGS_GROUP,
SETTINGS_GROUP,
__( 'Sophi Override URL is required for Override actions.', 'sophi-wp' )
);
} else if ( ! filter_var( $settings['sophi_override_url'], FILTER_VALIDATE_URL ) ) {
} elseif ( ! filter_var( $settings['sophi_override_url'], FILTER_VALIDATE_URL ) ) {
add_settings_error(
SETTINGS_GROUP,
SETTINGS_GROUP,
__( 'Sophi Override URL is invalid.', 'sophi-wp' )
);
}
*/

if ( empty( $settings['collector_url']) ) {
if ( empty( $settings['collector_url'] ) ) {
add_settings_error(
SETTINGS_GROUP,
SETTINGS_GROUP,
Expand All @@ -383,13 +391,16 @@ function sanitize_settings( $settings ) {
);
}

/* // phpcs:ignore
Commenting out the Sophi Override settings for now.
if ( empty( $settings['sophi_override_client_id'] ) || empty( $settings['sophi_override_client_secret'] ) ) {
add_settings_error(
SETTINGS_GROUP,
SETTINGS_GROUP,
__( 'Both Client ID and Client Secret are required to generate a token for API.', 'sophi-wp' )
);
}
*/

if ( isset( $settings['client_id'] ) ) {
unset( $settings['client_id'] );
Expand Down