src/CoreOptions.php
/**
     * Save all options POST'ed via UI
     */
Save all options POST'ed via UI
Save all options POST ' ed via UI
public static function savePosted( string $screen = 'core' ) : void {
        global $wpdb;
        $table_name = $wpdb->prefix . self::$table_name;
        switch ( $screen ) {
            case 'core':
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['detectCustomPostTypes'] ) ? 1 : 0 ],
                    [ 'name' => 'detectCustomPostTypes' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['detectPosts'] ) ? 1 : 0 ],
                    [ 'name' => 'detectPosts' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['detectPages'] ) ? 1 : 0 ],
                    [ 'name' => 'detectPages' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['detectUploads'] ) ? 1 : 0 ],
                    [ 'name' => 'detectUploads' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => esc_url_raw( $_POST['deploymentURL'] ) ],
                    [ 'name' => 'deploymentURL' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => sanitize_text_field( $_POST['basicAuthUser'] ) ],
                    [ 'name' => 'basicAuthUser' ]
                );
                $wpdb->update(
                    $table_name,
                    [
                        'value' =>
                        self::encrypt_decrypt(
                            'encrypt',
                            sanitize_text_field( $_POST['basicAuthPassword'] )
                        ),
                    ],
                    [ 'name' => 'basicAuthPassword' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['useCrawlCaching'] ) ? 1 : 0 ],
                    [ 'name' => 'useCrawlCaching' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => sanitize_email( $_POST['completionEmail'] ) ],
                    [ 'name' => 'completionEmail' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => esc_url_raw( $_POST['completionWebhook'] ) ],
                    [ 'name' => 'completionWebhook' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => sanitize_text_field( $_POST['completionWebhookMethod'] ) ],
                    [ 'name' => 'completionWebhookMethod' ]
                );
                break;
            case 'jobs':
                $queue_on_post_save = isset( $_POST['queueJobOnPostSave'] ) ? 1 : 0;
                $queue_on_post_delete = isset( $_POST['queueJobOnPostDelete'] ) ? 1 : 0;
                $process_queue_immediately = isset( $_POST['processQueueImmediately'] ) ? 1 : 0;
                $wpdb->update(
                    $table_name,
                    [ 'value' => $queue_on_post_save ],
                    [ 'name' => 'queueJobOnPostSave' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => $queue_on_post_delete ],
                    [ 'name' => 'queueJobOnPostDelete' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => $process_queue_immediately ],
                    [ 'name' => 'processQueueImmediately' ]
                );
                $process_queue_interval =
                    isset( $_POST['processQueueInterval'] ) ?
                     $_POST['processQueueInterval'] : 0;
                $wpdb->update(
                    $table_name,
                    [ 'value' => $process_queue_interval ],
                    [ 'name' => 'processQueueInterval' ]
                );
                WPCron::setRecurringEvent( $process_queue_interval );
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['autoJobQueueDetection'] ) ? 1 : 0 ],
                    [ 'name' => 'autoJobQueueDetection' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['autoJobQueueCrawling'] ) ? 1 : 0 ],
                    [ 'name' => 'autoJobQueueCrawling' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['autoJobQueuePostProcessing'] ) ? 1 : 0 ],
                    [ 'name' => 'autoJobQueuePostProcessing' ]
                );
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['autoJobQueueDeployment'] ) ? 1 : 0 ],
                    [ 'name' => 'autoJobQueueDeployment' ]
                );
                break;
            case 'advanced':
                $wpdb->update(
                    $table_name,
                    [ 'value' => isset( $_POST['skipURLRewrite'] ) ? 1 : 0 ],
                    [ 'name' => 'skipURLRewrite' ]
                );
                $hosts_to_rewrite = preg_replace(
                    '/^\s+|\s+$/m',
                    '',
                    $_POST['hostsToRewrite']
                );
                $wpdb->update(
                    $table_name,
                    [ 'blob_value' => $hosts_to_rewrite ],
                    [ 'name' => 'hostsToRewrite' ]
                );
                break;
        }
    }
public static function savePosted ( string $ screen = 'core' ) : void { global $ wpdb ; $ table_name = $ wpdb -> prefix . self :: $ table_name ; switch ( $ screen ) { case 'core' : $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'detectCustomPostTypes' ] ) ? 1 : 0 ] , [ 'name' => 'detectCustomPostTypes' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'detectPosts' ] ) ? 1 : 0 ] , [ 'name' => 'detectPosts' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'detectPages' ] ) ? 1 : 0 ] , [ 'name' => 'detectPages' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'detectUploads' ] ) ? 1 : 0 ] , [ 'name' => 'detectUploads' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => esc_url_raw ( $ _POST [ 'deploymentURL' ] ) ] , [ 'name' => 'deploymentURL' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => sanitize_text_field ( $ _POST [ 'basicAuthUser' ] ) ] , [ 'name' => 'basicAuthUser' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => self :: encrypt_decrypt ( 'encrypt' , sanitize_text_field ( $ _POST [ 'basicAuthPassword' ] ) ) , ] , [ 'name' => 'basicAuthPassword' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'useCrawlCaching' ] ) ? 1 : 0 ] , [ 'name' => 'useCrawlCaching' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => sanitize_email ( $ _POST [ 'completionEmail' ] ) ] , [ 'name' => 'completionEmail' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => esc_url_raw ( $ _POST [ 'completionWebhook' ] ) ] , [ 'name' => 'completionWebhook' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => sanitize_text_field ( $ _POST [ 'completionWebhookMethod' ] ) ] , [ 'name' => 'completionWebhookMethod' ] ) ; break ; case 'jobs' : $ queue_on_post_save = isset ( $ _POST [ 'queueJobOnPostSave' ] ) ? 1 : 0 ; $ queue_on_post_delete = isset ( $ _POST [ 'queueJobOnPostDelete' ] ) ? 1 : 0 ; $ process_queue_immediately = isset ( $ _POST [ 'processQueueImmediately' ] ) ? 1 : 0 ; $ wpdb -> update ( $ table_name , [ 'value' => $ queue_on_post_save ] , [ 'name' => 'queueJobOnPostSave' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => $ queue_on_post_delete ] , [ 'name' => 'queueJobOnPostDelete' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => $ process_queue_immediately ] , [ 'name' => 'processQueueImmediately' ] ) ; $ process_queue_interval = isset ( $ _POST [ 'processQueueInterval' ] ) ? $ _POST [ 'processQueueInterval' ] : 0 ; $ wpdb -> update ( $ table_name , [ 'value' => $ process_queue_interval ] , [ 'name' => 'processQueueInterval' ] ) ; WPCron :: setRecurringEvent ( $ process_queue_interval ) ; $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'autoJobQueueDetection' ] ) ? 1 : 0 ] , [ 'name' => 'autoJobQueueDetection' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'autoJobQueueCrawling' ] ) ? 1 : 0 ] , [ 'name' => 'autoJobQueueCrawling' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'autoJobQueuePostProcessing' ] ) ? 1 : 0 ] , [ 'name' => 'autoJobQueuePostProcessing' ] ) ; $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'autoJobQueueDeployment' ] ) ? 1 : 0 ] , [ 'name' => 'autoJobQueueDeployment' ] ) ; break ; case 'advanced' : $ wpdb -> update ( $ table_name , [ 'value' => isset ( $ _POST [ 'skipURLRewrite' ] ) ? 1 : 0 ] , [ 'name' => 'skipURLRewrite' ] ) ; $ hosts_to_rewrite = preg_replace ( '/^\s+|\s+$/m' , '' , $ _POST [ 'hostsToRewrite' ] ) ; $ wpdb -> update ( $ table_name , [ 'blob_value' => $ hosts_to_rewrite ] , [ 'name' => 'hostsToRewrite' ] ) ; break ; } }
Save all options POST'ed via UI
Save all options POST ' ed via UI