コード例 #1
0
 /**
  *
  * @return \OpenSearch\Core\Registry
  */
 static function instance()
 {
     if (Core\Utils::readyForClient() && Core\Utils::readyToIndex() && Core\Utils::readyForTemplate() && empty(self::$doc)) {
         self::$doc = new Core\Doc();
     }
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #2
0
    ?>
[accessHost]"></td>
						</tr>
						<tr>
							<td>
								<p class="submit"><input type="submit" value="<?php 
    esc_attr_e('Save Changes', $langDomain);
    ?>
" class="button button-primary" id="submit" name="submit"></p>
							</td>
						</tr>
					</tbody>
				</table>

				<?php 
    if (Core\Utils::readyForClient()) {
        ?>
				<table class="widefat" style="margin-top: 30px; width: 50%; ">
					<thead>
						<tr>
							<th class="row-title" colspan="2"><strong><?php 
        esc_html_e('Upload Your Document', $langDomain);
        ?>
</strong></th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<th scope="row"><label for="opSou_appName"><?php 
        esc_html_e('App Name', $langDomain);
        ?>
コード例 #3
0
 public function testIndex()
 {
     $client = Core\Utils::client(Core\Registry::instance()->getAccessKeyId(), Core\Registry::instance()->getAccessKeySecret(), Core\Registry::instance()->getAccessHost());
     $index = new SDK\CloudsearchIndex('wp', $client);
     $this->assertInstanceOf('CloudsearchIndex', get_class($index));
 }
コード例 #4
0
 /**
  * Save settings modified by the user
  */
 public function updateOptions()
 {
     if (!current_user_can('manage_options') || !isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], Settings::updateAction)) {
         return;
     }
     // Get all the settings
     $options = Registry::instance()->getOptions();
     foreach ($options as $option => $value) {
         if (!isset($_POST[self::settingsField]) || !isset($_POST[self::settingsField][$option])) {
             continue;
         }
         if (is_array($_POST[self::settingsField][$option])) {
             $options[$option] = array_map('sanitize_text_field', $_POST[self::settingsField][$option]);
         } else {
             $options[$option] = sanitize_text_field($_POST[self::settingsField][$option]);
         }
     }
     if (!empty($options['accessKeyId']) && !empty($options['accessKeySecret']) && !empty($options['accessHost'])) {
         static::$client = Core\Utils::client($options['accessKeyId'], $options['accessKeySecret'], $options['accessHost']);
     }
     // If there is a CloudsearchClient instance validate it
     $options['accessValid'] = 0;
     if (!empty(static::$client)) {
         $validAccess = Core\Utils::validAccess(static::$client);
         if (!is_wp_error($validAccess)) {
             $options['accessValid'] = 1;
         } else {
             $options['accessValid'] = 0;
         }
     }
     // If there is an appName and a cloudsearchClient instance validate them
     $options['accessIndexValid'] = 0;
     if (!empty($options['appName']) && !empty(static::$client)) {
         $validIndex = Core\Utils::validAccessIndex($options['appName'], static::$client);
         if (!is_wp_error($validIndex)) {
             $options['accessIndexValid'] = 1;
         } else {
             $options['accessIndexValid'] = 0;
         }
     }
     // pre($options);
     // exit;
     Registry::instance()->saveOptions($options);
     $referer = add_query_arg(array('opSouMessage' => 'settingsUpdated'), wp_get_referer());
     //Redirect back to the settings page that was submitted
     wp_safe_redirect($referer);
     die('Failed redirect saving settings');
 }