AnsPress_Admin::save_addon_options()
Description #
Saves addons options and redirect back to addon form.
Source #
File: admin/anspress-admin.php
public static function save_addon_options() { // Bail if no permission. if ( ! current_user_can( 'manage_options' ) ) { exit; } $form_name = ap_sanitize_unslash( 'ap_form_name', 'r' ); $addon_name = ap_sanitize_unslash( 'active_addon', 'r' ); $addon = ap_get_active_addons( $addon_name ); $updated = false; // Process submit form. if ( ! empty( $form_name ) && anspress()->get_form( $form_name )->is_submitted() ) { $form = anspress()->get_form( $form_name ); $values = $form->get_values(); if ( ! $form->have_errors() ) { $options = get_option( 'anspress_opt', array() ); foreach ( $values as $key => $opt ) { $options[ $key ] = $opt['value']; } update_option( 'anspress_opt', $options ); wp_cache_delete( 'anspress_opt', 'ap' ); wp_cache_delete( 'anspress_opt', 'ap' ); $updated = true; // Flush rewrite rules. ap_opt( 'ap_flush', 'true' ); } } wp_redirect( admin_url( 'admin.php?action=ap_addon_options&addon=' . $addon_name . '&updated=' . $updated ) ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect exit; }
Expand full source code Collapse full source code View on GitHub: admin/anspress-admin.php:1517
Add your comment