$size_value ) { if ( strpos( $size_key , '-hidden' ) ) { $key = str_replace( '-hidden', '', $size_key ); if ( ! isset( $value['sizes'][ $key ] ) ) { $value['disallowed-sizes'][ $key ] = '1'; } } } } // The max width for the "Resize larger images" option can't be 0 if ( (bool) ! $value['resize_larger_w'] ) { $value['resize_larger_w'] = ''; $value['resize_larger'] = 0; } // The max width for the "Resize larger images" option can't be less than the largest thumbnail width $max_sizes = get_imagify_max_intermediate_image_size(); if ( (bool) $value['resize_larger_w'] && $value['resize_larger_w'] < $max_sizes['width'] ) { $value['resize_larger_w'] = $max_sizes['width']; } unset( $value['sizes'] ); return $value; } /** * Used to launch some actions after saving the options * * @since 1.0 */ add_action( 'update_option_' . IMAGIFY_SETTINGS_SLUG, '_imagify_after_save_options', 10, 2 ); add_action( 'update_site_option_' . IMAGIFY_SETTINGS_SLUG, '_imagify_after_save_options', 10, 2 ); function _imagify_after_save_options( $oldvalue, $value ) { if ( ! ( (bool) $oldvalue && (bool) $value ) ) { return; } if ( ! isset( $oldvalue['api_key'] ) || $oldvalue['api_key'] != $value['api_key'] ) { $api = new Imagify(); if ( is_wp_error( $api->getUser() ) ) { imagify_renew_notice( 'wrong-api-key' ); delete_site_transient( 'imagify_check_licence_1' ); } else { imagify_dismiss_notice( 'wrong-api-key' ); } } } if ( imagify_is_active_for_network() ) : /** * !options.php do not handle site options. Let's use admin-post.php for multisite installations. * * @since 1.0 */ add_action( 'admin_post_update', '_imagify_update_site_option_on_network' ); function _imagify_update_site_option_on_network() { $option_group = IMAGIFY_SLUG; if ( ! isset( $_POST['option_page'] ) || $_POST['option_page'] !== $option_group ) { return; } $capability = apply_filters( "option_page_capability_{$option_group}", 'manage_network_options' ); if ( ! current_user_can( $capability ) ) { wp_die( __( 'Cheatin’ uh?' ), 403 ); } check_admin_referer( $option_group . '-options' ); $whitelist_options = apply_filters( 'whitelist_options', array() ); if ( ! isset( $whitelist_options[ $option_group ] ) ) { wp_die( __( 'ERROR: options page not found.' ) ); } $options = $whitelist_options[ $option_group ]; if ( $options ) { foreach ( $options as $option ) { $option = trim( $option ); $value = null; if ( isset( $_POST[ $option ] ) ) { $value = $_POST[ $option ]; if ( ! is_array( $value ) ) { $value = trim( $value ); } $value = wp_unslash( $value ); } update_site_option( $option, $value ); } } /** * Redirect back to the settings page that was submitted */ $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); wp_redirect( $goback ); exit; } endif;