Merged in feature/MAW-855-import-code-into-aws (pull request #2)

code import from pantheon

* code import from pantheon
This commit is contained in:
Tony Volpe
2023-12-04 23:08:14 +00:00
parent 8c9b1312bc
commit 8f4b5efda6
4766 changed files with 185592 additions and 239967 deletions

View File

@@ -58,19 +58,13 @@ class First_Time_Configuration_Action {
* @return object The response object.
*/
public function set_site_representation( $params ) {
$failures = [];
$failures = [];
$old_values = $this->get_old_values( self::SITE_REPRESENTATION_FIELDS );
foreach ( self::SITE_REPRESENTATION_FIELDS as $field_name ) {
if ( isset( $params[ $field_name ] ) ) {
if ( $field_name === 'description' && \current_user_can( 'manage_options' ) ) {
$result = \update_option( 'blogdescription', $params['description'] );
if ( ! $result && $params['description'] === \get_option( 'blogdescription' ) ) {
$result = true;
}
}
else {
$result = $this->options_helper->set( $field_name, $params[ $field_name ] );
}
$result = $this->options_helper->set( $field_name, $params[ $field_name ] );
if ( ! $result ) {
$failures[] = $field_name;
}
@@ -81,6 +75,17 @@ class First_Time_Configuration_Action {
$this->options_helper->set( 'company_logo_meta', false );
$this->options_helper->set( 'person_logo_meta', false );
/**
* Action: 'wpseo_post_update_site_representation' - Allows for Hiive event tracking.
*
* @param array The new values of the options.
* @param array The old values of the options.
* @param array The options that failed to be saved.
*
* @internal
*/
\do_action( 'wpseo_ftc_post_update_site_representation', $params, $old_values, $failures );
if ( \count( $failures ) === 0 ) {
return (object) [
'success' => true,
@@ -104,7 +109,19 @@ class First_Time_Configuration_Action {
* @return object The response object.
*/
public function set_social_profiles( $params ) {
$failures = $this->social_profiles_helper->set_organization_social_profiles( $params );
$old_values = $this->get_old_values( \array_keys( $this->social_profiles_helper->get_organization_social_profile_fields() ) );
$failures = $this->social_profiles_helper->set_organization_social_profiles( $params );
/**
* Action: 'wpseo_post_update_social_profiles' - Allows for Hiive event tracking.
*
* @param array The new values of the options.
* @param array The old values of the options.
* @param array The options that failed to be saved.
*
* @internal
*/
\do_action( 'wpseo_ftc_post_update_social_profiles', $params, $old_values, $failures );
if ( empty( $failures ) ) {
return (object) [
@@ -186,6 +203,18 @@ class First_Time_Configuration_Action {
$success = $this->options_helper->set( 'tracking', $params['tracking'] );
}
/**
* Action: 'wpseo_post_update_enable_tracking' - Allows for Hiive event tracking.
*
* @param array The new value.
* @param array The old value.
* @param bool Whether the option failed to be stored.
*
* @internal
*/
// $success is negated to be aligned with the other two actions which pass $failures.
\do_action( 'wpseo_ftc_post_update_enable_tracking', $params['tracking'], $option_value, ! $success );
if ( $success ) {
return (object) [
'success' => true,
@@ -295,4 +324,21 @@ class First_Time_Configuration_Action {
private function can_edit_profile( $person_id ) {
return \current_user_can( 'edit_user', $person_id );
}
/**
* Gets the old values for the given fields.
*
* @param array $fields_names The fields to get the old values for.
*
* @return array The old values.
*/
private function get_old_values( array $fields_names ) : array {
$old_values = [];
foreach ( $fields_names as $field_name ) {
$old_values[ $field_name ] = $this->options_helper->get( $field_name );
}
return $old_values;
}
}