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

PRESS2 331 Maintain State for colors and typography steps #102

Merged
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion includes/RestApi/Themes/ThemeVariationsController.php
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ public function register_routes() {
),
array(
'methods' => \WP_REST_Server::EDITABLE,
'args' => $this->set_pattern_args(),
'callback' => array($this, 'set_theme_variation'),
'permission_callback' => array(Permissions::class, 'rest_is_authorized_admin'),
),
@@ -66,6 +67,21 @@ public function get_pattern_args()
);
}

public function set_pattern_args()
{
// This is the latest modified Global Style to be saved in the db
return array(
'title' => array(
'type' => 'string',
'required' => true,
),
'settings' => array(
'type' => 'array',
'required' => true,
)
);
}

/**
* Retrieves the active themes variations.
*
@@ -108,7 +124,7 @@ public function set_theme_variation(\WP_REST_Request $request)
// The theme data with the new Colors and Fonts
$theme_data = json_decode($request->get_body(), true);
arunshenoy99 marked this conversation as resolved.
Show resolved Hide resolved

if($theme_data && isset($theme_data['settings'])){
if($theme_data){

// Save the new Theme style into the db
\update_option(Options::get_option_name('theme_settings'), $theme_data);