-
Notifications
You must be signed in to change notification settings - Fork 805
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
|
||
namespace Automattic\Jetpack\Publicize\Social_Image_Generator; | ||
|
||
use Automattic\Jetpack\Publicize\Jetpack_Social_Settings\Settings; | ||
|
||
/** | ||
* Class for setting up Social Image Generator-related functionality. | ||
*/ | ||
|
@@ -15,15 +17,14 @@ class Setup { | |
* Initialise SIG-related functionality. | ||
*/ | ||
public function init() { | ||
if ( ! ( new Settings() )->is_available() ) { | ||
if ( ! ( new Settings() )->is_sig_available() ) { | ||
return; | ||
} | ||
|
||
// Be wary of any code that you add to this file, since this function is called on plugin load. | ||
// We're using the `wp_after_insert_post` hook because we need access to the updated post meta. By using the default priority | ||
// of 10 we make sure that our code runs before Sync processes the post. | ||
add_action( 'wp_after_insert_post', array( $this, 'generate_token_on_save' ), 10, 3 ); | ||
add_action( 'rest_api_init', array( new REST_Settings_Controller(), 'register_routes' ) ); | ||
add_action( 'rest_api_init', array( new REST_Token_Controller(), 'register_routes' ) ); | ||
} | ||
|
||
|
@@ -75,7 +76,7 @@ public function generate_token_on_save( $post_id, $post, $update ) { | |
|
||
$settings = new Settings(); | ||
|
||
if ( ! $settings->is_available() ) { | ||
if ( ! $settings->is_sig_available() ) { | ||
return; | ||
} | ||
|
||
|
@@ -88,7 +89,7 @@ public function generate_token_on_save( $post_id, $post, $update ) { | |
if ( | ||
! $update && | ||
'auto-draft' === $post->post_status && | ||
$settings->is_enabled() && | ||
$settings->get_settings()['socialImageGeneratorSettings']['enabled'] && | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
pablinos
Contributor
|
||
empty( $post_settings->get_settings( true ) ) | ||
) { | ||
$post_settings->update_setting( 'enabled', true ); | ||
|
Do you think we should put this in a helper function on the settings class?
is_social_image_generator_enabled
or something? It would mean we wouldn't have to remember the structure.