| 1 |
<?php |
| 2 |
/** |
| 3 |
* Module Name: JSON API |
| 4 |
* Module Description: Allow applications to securely access your content through the cloud. |
| 5 |
* Sort Order: 19 |
| 6 |
* First Introduced: 1.9 |
| 7 |
* Requires Connection: Yes |
| 8 |
* Auto Activate: Public |
| 9 |
* Module Tags: Writing, Developers |
| 10 |
*/ |
| 11 |
|
| 12 |
add_action( 'jetpack_activate_module_json-api', array( Jetpack::init(), 'toggle_module_on_wpcom' ) ); |
| 13 |
add_action( 'jetpack_deactivate_module_json-api', array( Jetpack::init(), 'toggle_module_on_wpcom' ) ); |
| 14 |
|
| 15 |
add_action( 'jetpack_modules_loaded', 'jetpack_json_api_load_module' ); |
| 16 |
|
| 17 |
$theme_slug = get_option( 'stylesheet' ); |
| 18 |
|
| 19 |
Jetpack_Sync::sync_options( __FILE__, |
| 20 |
'stylesheet', |
| 21 |
"theme_mods_{$theme_slug}" |
| 22 |
); |
| 23 |
|
| 24 |
function jetpack_json_api_load_module() { |
| 25 |
Jetpack::enable_module_configurable( __FILE__ ); |
| 26 |
Jetpack::module_configuration_load( __FILE__, 'jetpack_json_api_configuration_load' ); |
| 27 |
Jetpack::module_configuration_screen( __FILE__, 'jetpack_json_api_configuration_screen' ); |
| 28 |
} |
| 29 |
|
| 30 |
function jetpack_json_api_configuration_load() { |
| 31 |
if ( isset( $_POST['action'] ) && $_POST['action'] == 'save_options' && wp_verify_nonce( $_POST['_wpnonce'], 'json-api' ) ) { |
| 32 |
Jetpack_Options::update_option( 'json_api_full_management', isset( $_POST['json_api_full_management'] ) ); |
| 33 |
Jetpack::state( 'message', 'module_configured' ); |
| 34 |
wp_safe_redirect( Jetpack::module_configuration_url( 'json-api' ) ); |
| 35 |
exit; |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
function jetpack_json_api_configuration_screen() { |
| 40 |
?> |
| 41 |
<div class="narrow"> |
| 42 |
<form method="post"> |
| 43 |
<input type='hidden' name='action' value='save_options' /> |
| 44 |
<?php wp_nonce_field( 'json-api' ); ?> |
| 45 |
<table id="menu" class="form-table"> |
| 46 |
<tr valign="top"><th scope="row"><label for="json_api_full_management"><?php _e( 'Allow management' , 'jetpack' ); ?></label></th> |
| 47 |
<td><label><input type='checkbox'<?php checked( Jetpack_Options::get_option( 'json_api_full_management' ) ); ?> name='json_api_full_management' id='json_api_full_management' /> <?php printf( __( 'Allow remote management of themes, plugins, and WordPress via the JSON API. (<a href="%s" title="Learn more about JSON API">More info</a>).', 'jetpack') , '//jetpack.me/support/json-api' ); ?></label></td></tr> |
| 48 |
|
| 49 |
</table> |
| 50 |
<p class="submit"><input type='submit' class='button-primary' value='<?php echo esc_attr( __( 'Save configuration', 'jetpack' ) ); ?>' /></p> |
| 51 |
</form> |
| 52 |
</div> |
| 53 |
<?php |
| 54 |
} |
| 55 |
|