コード例 #1
0
 public function testEnqueueScripts()
 {
     $jspath = Core\Registry::instance()->getPluginDir() . "admin/assets/scripts/open-search-functions.js";
     $this->assertFileExists($jspath);
     $csspath = Core\Registry::instance()->getPluginDir() . "admin/assets/styles/settings.css";
     $this->assertFileExists($csspath);
 }
コード例 #2
0
 /**
  *
  */
 public function __construct()
 {
     if (Registry::instance()->isEnabled()) {
         // Delete the post in the index when it was deleted in the site
         add_action('deleted_post', array(&$this, 'postDeleted'));
         // Delete the post in the index when it was unpublished
         add_action('transition_post_status', array(&$this, 'postUnpublished'), 10, 3);
         // Update the post in the index when it was updated
         // JUST WHEN IT IS publish
         add_action('save_post', array(&$this, 'postUpdated'), 11, 3);
         // Update the term in the index when the counter was updated in WP
         add_action("edited_term_taxonomy", array(&$this, 'termTaxonomyUpdated'), 10, 2);
     }
 }
コード例 #3
0
 public function testLoadFile()
 {
     $registry = Core\Registry::instance();
     $settings = Controllers\Settings::instance();
     $indexer = Controllers\Indexer::instance();
     $doc = new Core\Doc();
     $search = new Core\Search();
     $this->assertTrue(class_exists('Registry'));
     $this->assertTrue(class_exists('Settings'));
     $this->assertTrue(class_exists('Indexer'));
     $this->assertTrue(class_exists('Doc'));
     $this->assertTrue(class_exists('Search'));
     $this->assertTrue(class_exists('CloudsearchClient'));
     $this->assertTrue(class_exists('CloudsearchDoc'));
     $this->assertTrue(class_exists('CloudsearchSearch'));
 }
コード例 #4
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));
 }
コード例 #5
0
<?php

use OpenSearch\Admin\Controllers\Settings;
use OpenSearch\Core;
$registry = Core\Registry::instance();
$langDomain = $registry->getPluginShortName();
?>
<div id="opSouSettings" class="wrap">
	<div id="icon-options-general" class="icon32"><br></div>
	<h2><a href="http://opensearch.console.aliyun.com/" target="_blank">AliYun Open Search Settings</a>&nbsp;&nbsp;</h2>
	<form action="" method="post" id="opSou_form">
		<p>
		IF you have not got this template, please first download it for "AliYun OpenSearch". &nbsp;
		<input type="hidden" value="1" name="<?php 
echo Settings::settingsField;
?>
[accessTemplateValid]">
		<input type="submit" value="<?php 
esc_attr_e('Download Template', $langDomain);
?>
" id="opSou_dlTemplate" class="button button-primary">&nbsp;
		Then refresh this page when this template has been downloaded.
		</p>
		<?php 
if (Core\Utils::readyForTemplate()) {
    ?>
		<div id="opSoutabs">
			<ul>
				<!-- <li><a class="nav-tab nav-tab-active" href="#tab-general"><?php 
    esc_html_e('Account', $langDomain);
    ?>
コード例 #6
0
 public static function readyForTemplate()
 {
     return Registry::instance()->isValidAccessTemplate();
 }
コード例 #7
0
 public function testEnqueueScripts()
 {
     $csspath = Core\Registry::instance()->getPluginDir() . "front/assets/styles/opensearch.css";
     $this->assertFileExists($csspath);
 }
コード例 #8
0
 /**
  * Hook with wordpress 'wp_enqueue_scripts' action
  * @return void
  */
 public function enqueueScripts()
 {
     $csspath = Registry::instance()->getPluginUrl() . "front/assets/styles/opensearch.css";
     wp_enqueue_style('openSearchFrontSettings', $csspath, array(), Registry::instance()->getPluginVersion());
 }
コード例 #9
0
 public function testGetSettingKey()
 {
     $settingKey = Registry::instance()->getSettingKey();
     $this->assertNotEmpty($settingKey);
 }
コード例 #10
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');
 }
コード例 #11
0
 public function getDocHandler()
 {
     $client = new SDK\CloudsearchClient(Registry::instance()->getAccessKeyId(), Registry::instance()->getAccessKeySecret(), array("host" => Registry::instance()->getAccessHost(), "debug" => true), Registry::instance()->getAccessKeyType());
     $docHandler = new SDK\CloudsearchDoc(Registry::instance()->getAppName(), $client);
     return $docHandler;
 }