get_setting() public method

Accessor for a plugin setting with conditions to defaults and upgrades
public get_setting ( string $key, mixed $default = '' ) : integer | mixed | string | WP_Error
$key string
$default mixed
return integer | mixed | string | WP_Error
 /**
  * Should filter content.
  *
  * @return bool
  */
 protected function should_filter_content()
 {
     if ($this->as3cf->is_plugin_setup() && $this->as3cf->get_setting('serve-from-s3')) {
         return true;
     }
     return false;
 }
 /**
  * Replace local URLs with S3 ones for srcset image sources
  *
  * @param array  $sources
  * @param array  $size_array
  * @param string $image_src
  * @param array  $image_meta
  * @param int    $attachment_id
  *
  * @return array
  */
 public function wp_calculate_image_srcset($sources, $size_array, $image_src, $image_meta, $attachment_id)
 {
     if (!$this->as3cf->get_setting('serve-from-s3')) {
         // S3 URLs disabled, abort
         return $sources;
     }
     if (!($s3object = $this->as3cf->get_attachment_s3_info($attachment_id))) {
         // Attachment not uploaded to S3, abort
         return $sources;
     }
     foreach ($sources as $width => $source) {
         $size = $this->find_image_size_from_width($image_meta['sizes'], $width);
         $s3_url = $this->as3cf->get_attachment_s3_url($attachment_id, $s3object, null, $size, $image_meta);
         if (false === $s3_url || is_wp_error($s3_url)) {
             continue;
         }
         $sources[$width]['url'] = $s3_url;
     }
     return $sources;
 }
 /**
  * Get the saved upgrade ID
  *
  * @return int|mixed|string|WP_Error
  */
 protected function get_saved_upgrade_id()
 {
     return $this->as3cf->get_setting($this->settings_key, 0);
 }
 /**
  * Cron jon to update the region of the bucket in s3 metadata
  */
 function do_upgrade()
 {
     // Check if the cron should even be running
     if ($this->as3cf->get_setting($this->settings_key, 0) >= $this->upgrade_id || $this->get_upgrade_status() !== self::STATUS_RUNNING) {
         $this->as3cf->clear_scheduled_event($this->cron_hook);
         return;
     }
     // set the batch size limit for the query
     $limit = apply_filters('as3cf_update_' . $this->upgrade_name . '_batch_size', 500);
     $all_limit = $limit;
     // only process the loop for a certain amount of time
     $minutes = $this->cron_interval_in_minutes * 60;
     // smaller time limit so won't run into another instance of cron
     $minutes = $minutes * 0.8;
     $finish = time() + $minutes;
     $session = $this->get_session();
     // find the blog IDs that have been processed so we can skip them
     $processed_blog_ids = isset($session['processed_blog_ids']) ? $session['processed_blog_ids'] : array();
     $this->error_count = isset($session['error_count']) ? $session['error_count'] : 0;
     // get the table prefixes for all the blogs
     $table_prefixes = $this->as3cf->get_all_blog_table_prefixes($processed_blog_ids);
     $all_attachments = array();
     $all_count = 0;
     foreach ($table_prefixes as $blog_id => $table_prefix) {
         $attachments = $this->get_attachments_to_process($table_prefix, $limit);
         $count = count($attachments);
         if (0 === $count) {
             // no more attachments, record the blog ID to skip next time
             $processed_blog_ids[] = $blog_id;
         } else {
             $all_count += $count;
             $all_attachments[$blog_id] = $attachments;
         }
         if ($all_count >= $all_limit) {
             break;
         }
         $limit = $limit - $count;
     }
     if (0 === $all_count) {
         $this->upgrade_finished();
         return;
     }
     // loop through and update s3 meta with region
     foreach ($all_attachments as $blog_id => $attachments) {
         $this->as3cf->switch_to_blog($blog_id);
         foreach ($attachments as $attachment) {
             if ($this->error_count >= $this->error_threshold) {
                 $this->upgrade_error($session);
                 return;
             }
             // Do the actual upgrade to the attachment
             $this->upgrade_attachment($attachment);
             if (time() >= $finish || $this->as3cf->memory_exceeded('as3cf_update_' . $this->upgrade_name . '_memory_exceeded')) {
                 // Batch limits reached
                 break 2;
             }
         }
     }
     $this->as3cf->restore_current_blog($blog_id);
     $session['processed_blog_ids'] = $processed_blog_ids;
     $session['error_count'] = $this->error_count;
     $this->save_session($session);
 }