*/ public function add_advanced_fields() { if ( ! charitable_is_settings_view( 'advanced' ) ) { return array(); } return array( 'section' => array( 'title' => '', 'type' => 'hidden', 'priority' => 10000, 'value' => 'advanced', ), 'section_dangerous' => array( 'title' => __( 'Dangerous Settings', 'charitable' ), 'type' => 'heading', 'class' => 'section-heading dangerous-settings', 'priority' => 100, ), 'delete_data_on_uninstall' => array( 'label_for' => __( 'Reset Data', 'charitable' ), 'type' => 'checkbox', 'help' => __( 'DELETE ALL DATA when uninstalling the plugin.', 'charitable' ), 'priority' => 105, ), 'section' => array( 'title' => '', 'type' => 'hidden', 'priority' => 10000, 'value' => 'licenses', 'save' => false, ), 'section_licenses' => array( 'title' => __( 'Legacy Licenses', 'charitable' ), 'type' => 'heading', 'class' => 'section-heading', 'priority' => 202, ), 'licenses' => array( 'title' => false, 'callback' => array( $this, 'render_licenses_table' ), 'priority' => 204, ), ); foreach ( charitable_get_helper( 'licenses' )->get_products() as $key => $product ) { $fields[ $key ] = array( 'type' => 'text', 'render' => false, 'priority' => 206, ); } } /** * Add the licenses group. * * @since 1.0.0 * * @param string[] $groups Settings groups. * @return string[] */ public function add_licenses_group( $groups ) { $groups['licenses'] = array(); return $groups; } /** * Render the licenses table. * * @since 1.0.0 * * @return void */ public function render_licenses_table() { charitable_admin_view( 'settings/licenses' ); } /** * Checks for updated license and invalidates status field if not set. * * @since 1.0.0 * * @param mixed[] $values The parsed values combining old values & new values. * @param mixed[] $new_values The newly submitted values. * @return mixed[] */ public function save_license( $values, $new_values ) { /* If we didn't just submit licenses, stop here. */ if ( ! isset( $new_values['licenses'] ) ) { return $values; } $re_check = array_key_exists( 'recheck', $_POST ); $licenses = $new_values['licenses']; foreach ( $licenses as $product_key => $license ) { $license = trim( $license ); if ( empty( $license ) ) { $values['licenses'][ $product_key ] = ''; continue; } $license_data = charitable_get_helper( 'licenses' )->verify_license( $product_key, $license, $re_check ); if ( empty( $license_data ) ) { continue; } $values['licenses'][ $product_key ] = $license_data; } return $values; } } endif;