Example #1
0
 /**
  * During activation this will initiate the options.
  */
 private function initOptions()
 {
     $version = $this->options->getVersion();
     switch (TRUE) {
         /** @noinspection PhpMissingBreakStatementInspection */
         case version_compare($version, '0.7.3', '<'):
             /*
              * Retrieve the settings stored prior to 0.7.3 and migrate them
              * so they will be accessible in the structure supported by the
              * Connections WordPress Settings API Wrapper Class.
              */
             if (FALSE !== get_option('connections_options')) {
                 $options = get_option('connections_options');
                 if (FALSE === get_option('connections_login')) {
                     update_option('connections_login', array('required' => $options['settings']['allow_public'], 'message' => 'Please login to view the directory.'));
                 }
                 if (FALSE === get_option('connections_visibility')) {
                     update_option('connections_visibility', array('allow_public_override' => $options['settings']['allow_public_override'], 'allow_private_override' => $options['settings']['allow_private_override']));
                 }
                 if (FALSE === get_option('connections_image_thumbnail')) {
                     update_option('connections_image_thumbnail', array('quality' => $options['settings']['image']['thumbnail']['quality'], 'width' => $options['settings']['image']['thumbnail']['x'], 'height' => $options['settings']['image']['thumbnail']['y'], 'ratio' => $options['settings']['image']['thumbnail']['crop']));
                 }
                 if (FALSE === get_option('connections_image_medium')) {
                     update_option('connections_image_medium', array('quality' => $options['settings']['image']['entry']['quality'], 'width' => $options['settings']['image']['entry']['x'], 'height' => $options['settings']['image']['entry']['y'], 'ratio' => $options['settings']['image']['entry']['crop']));
                 }
                 if (FALSE === get_option('connections_image_large')) {
                     update_option('connections_image_large', array('quality' => $options['settings']['image']['profile']['quality'], 'width' => $options['settings']['image']['profile']['x'], 'height' => $options['settings']['image']['profile']['y'], 'ratio' => $options['settings']['image']['profile']['crop']));
                 }
                 if (FALSE === get_option('connections_image_logo')) {
                     update_option('connections_image_logo', array('quality' => $options['settings']['image']['logo']['quality'], 'width' => $options['settings']['image']['logo']['x'], 'height' => $options['settings']['image']['logo']['y'], 'ratio' => $options['settings']['image']['logo']['crop']));
                 }
                 if (FALSE === get_option('connections_compatibility')) {
                     update_option('connections_compatibility', array('google_maps_api' => $options['settings']['advanced']['load_google_maps_api'], 'javascript_footer' => $options['settings']['advanced']['load_javascript_footer']));
                 }
                 if (FALSE === get_option('connections_debug')) {
                     update_option('connections_debug', array('debug_messages' => $options['debug']));
                 }
                 unset($options);
             }
             /** @noinspection PhpMissingBreakStatementInspection */
         /** @noinspection PhpMissingBreakStatementInspection */
         case version_compare($version, '0.7.4', '<'):
             /*
              * The option to disable keyword search was added in version 0.7.4. Set this option to be enabled by default.
              */
             $options = get_option('connections_search');
             $options['keyword_enabled'] = 1;
             update_option('connections_search', $options);
             unset($options);
             /** @noinspection PhpMissingBreakStatementInspection */
         /** @noinspection PhpMissingBreakStatementInspection */
         case version_compare($version, '0.8', '<'):
             /*
              * The option to disable keyword search was added in version 0.7.4. Set this option to be enabled by default.
              */
             $options = get_option('connections_compatibility');
             $options['css'] = 1;
             update_option('connections_compatibility', $options);
             unset($options);
             $options = get_option('connections_display_results');
             $options['search_message'] = 1;
             update_option('connections_display_results', $options);
             unset($options);
     }
     if (NULL === $this->options->getDefaultTemplatesSet()) {
         $this->options->setDefaultTemplates();
     }
     // Class used for managing role capabilities.
     if (!class_exists('cnRole')) {
         require_once CN_PATH . 'includes/admin/class.capabilities.php';
     }
     if (TRUE != $this->options->getCapabilitiesSet()) {
         cnRole::reset();
         $this->options->defaultCapabilitiesSet(TRUE);
     }
     // Increment the version number.
     $this->options->setVersion(CN_CURRENT_VERSION);
     // Save the options
     $this->options->saveOptions();
     /*
      * This option is added for a check that will force a flush_rewrite() in connectionsLoad::adminInit() once.
      * Should save the user from having to "save" the permalink settings.
      */
     update_option('connections_flush_rewrite', '1');
 }