Changeset 2174745
- Timestamp:
- 10/17/2019 08:28:08 AM (6 years ago)
- Location:
- swiftype-search/trunk
- Files:
-
- 13 edited
-
AbstractSwiftypeComponent.php (modified) (1 diff)
-
Admin/Action.php (modified) (4 diffs)
-
Admin/Page.php (modified) (3 diffs)
-
Cli/Command.php (modified) (1 diff)
-
Document/Indexer.php (modified) (1 diff)
-
Engine/Manager.php (modified) (2 diffs)
-
README.txt (modified) (2 diffs)
-
scripts/publish.sh (modified) (1 diff)
-
swiftype.php (modified) (1 diff)
-
templates/admin/authorize.php (modified) (1 diff)
-
templates/admin/choose-engine.php (modified) (2 diffs)
-
templates/admin/controls/dangerous-settings.php (modified) (1 diff)
-
tests/bootstrap.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
swiftype-search/trunk/AbstractSwiftypeComponent.php
r2056911 r2174745 71 71 return $this->client; 72 72 } 73 74 /** 75 * Check if currently executing WP_CLI. 76 * 77 * @return boolean 78 */ 79 public function isWpCLI() 80 { 81 return (defined('WP_CLI') && WP_CLI == true) || php_sapi_name () == 'cli'; 82 } 73 83 } -
swiftype-search/trunk/Admin/Action.php
r2056911 r2174745 24 24 parent::__construct(); 25 25 26 if ($this->isWpCLI()) { 27 $this->installHooks(); 28 } 29 30 \add_action('admin_init', function() { 31 if (\current_user_can('manage_options')) { 32 $this->installHooks(); 33 } 34 }); 35 } 36 37 /** 38 * Install hooks for the admin actions. 39 */ 40 public function installHooks() { 26 41 \add_action('wp_ajax_index_batch_of_posts', [$this, 'asyncIndexBatchOfPosts']); 27 42 \add_action('wp_ajax_delete_batch_of_trashed_posts', [$this, 'asyncDeleteBatchOfTrashedPosts']); … … 107 122 public function setApiKey() 108 123 { 124 \check_ajax_referer('swiftype-ajax-nonce'); 125 109 126 $this->getConfig()->reset(); 110 127 $this->getConfig()->setApiKey(trim($_POST['api_key'])); … … 126 143 public function createEngine() 127 144 { 145 \check_ajax_referer('swiftype-ajax-nonce'); 146 128 147 $this->getConfig()->setLanguage(isset($_POST['language']) ? $_POST['language'] : null); 129 148 $this->getConfig()->setEngineSlug(trim($_POST['engine_name'])); … … 143 162 public function clearConfig() 144 163 { 164 \check_ajax_referer('swiftype-ajax-nonce'); 165 145 166 $this->getConfig()->reset(); 146 167 $this->redirect(); -
swiftype-search/trunk/Admin/Page.php
r2056911 r2174745 49 49 { 50 50 parent::__construct(); 51 51 52 \add_action('admin_menu', [$this, 'addMenu']); 52 53 \add_action('admin_enqueue_scripts', [$this, 'enqueueAdminAssets']); … … 63 64 public function getContent() 64 65 { 65 $isAuth = $this->getConfig()->getApiKey() && $this->getClient() !== null; 66 if (\current_user_can('manage_options')) { 67 $isAuth = $this->getConfig()->getApiKey() && $this->getClient() !== null; 66 68 67 if($this->error) { 68 $this->renderTemplate('error.php'); 69 } else if (!$isAuth) { 70 $this->renderTemplate('authorize.php'); 71 } else if (!$this->getConfig()->getEngineSlug() || null === $this->engine) { 72 $this->renderTemplate('choose-engine.php'); 73 } else { 74 $this->renderTemplate('controls.php'); 69 if($this->error) { 70 $this->renderTemplate('error.php'); 71 } else if (!$isAuth) { 72 $this->renderTemplate('authorize.php'); 73 } else if (!$this->getConfig()->getEngineSlug() || null === $this->engine) { 74 $this->renderTemplate('choose-engine.php'); 75 } else { 76 $this->renderTemplate('controls.php'); 77 } 75 78 } 76 79 } … … 90 93 public function addMenu() 91 94 { 92 \add_menu_page(self::MENU_TITLE, SELF::MENU_TITLE, 'manage_options', SELF::MENU_SLUG, [$this, 'getContent'], $this->getIconUrl()); 95 if (\current_user_can('manage_options')) { 96 \add_menu_page(self::MENU_TITLE, SELF::MENU_TITLE, 'manage_options', SELF::MENU_SLUG, [$this, 'getContent'], $this->getIconUrl()); 97 } 93 98 } 94 99 -
swiftype-search/trunk/Cli/Command.php
r2056911 r2174745 108 108 if ($this->client == null) { 109 109 \WP_CLI::error("Unable to connect to Site Search : check your API key is valid."); 110 } 111 112 if ($this->engine == null) { 113 \do_action('swiftype_create_engine'); 110 114 } 111 115 -
swiftype-search/trunk/Document/Indexer.php
r2056911 r2174745 32 32 public function installHooks() 33 33 { 34 \add_action('future_to_publish', [$this, 'handleFutureToPublish']); 35 36 foreach ($this->getConfig()->allowedPostTypes() as $postType) { 37 \add_action("rest_after_insert_{$postType}", [$this, 'handleRestUpdatePost']); 38 } 39 40 \add_action('save_post', [$this, 'handleSavePost'], 99, 1); 41 42 \add_action('transition_post_status', [$this, 'handleTransitionPostStatus'], 99, 3); 43 \add_action('trashed_post', [$this, 'handleTrashedPost']); 44 45 46 add_action('swiftype_batch_post_index', [$this, 'handlePostBatchIndex']); 47 add_action('swiftype_batch_post_delete', [$this, 'handlePostBatchDelete']); 34 if (\current_user_can('edit_posts') || $this->isWpCLI()) { 35 \add_action('future_to_publish', [$this, 'handleFutureToPublish']); 36 37 foreach ($this->getConfig()->allowedPostTypes() as $postType) { 38 \add_action("rest_after_insert_{$postType}", [$this, 'handleRestUpdatePost']); 39 } 40 41 \add_action('save_post', [$this, 'handleSavePost'], 99, 1); 42 43 \add_action('transition_post_status', [$this, 'handleTransitionPostStatus'], 99, 3); 44 \add_action('trashed_post', [$this, 'handleTrashedPost']); 45 46 47 add_action('swiftype_batch_post_index', [$this, 'handlePostBatchIndex']); 48 add_action('swiftype_batch_post_delete', [$this, 'handlePostBatchDelete']); 49 } 48 50 } 49 51 -
swiftype-search/trunk/Engine/Manager.php
r2056911 r2174745 20 20 parent::__construct(); 21 21 22 if ($this->isWpCLI()) { 23 $this->installHooks(); 24 } 25 26 \add_action('admin_init', function() { 27 if (\current_user_can('manage_options')) { 28 $this->installHooks(); 29 } 30 }); 31 32 \add_action('swiftype_client_loaded', [$this, 'loadEngine']); 33 } 34 35 /** 36 * Install hooks for the admin actions. 37 */ 38 public function installHooks() { 22 39 \add_action('swiftype_create_engine', [$this, 'createEngine']); 23 \add_action('swiftype_client_loaded', [$this, 'loadEngine']);24 40 \add_action('wp_ajax_check_engine_exists', [$this, 'asyncCheckEngineExists']); 25 41 } … … 42 58 43 59 $language = $this->getConfig()->getLanguage(); 60 44 61 $engine = $this->getClient()->createEngine($engineSlug, $language); 45 62 $this->getConfig()->setEngineSlug($engine['slug']); -
swiftype-search/trunk/README.txt
r2061675 r2174745 4 4 Tags: search, better search, custom search, relevant search, search by category, autocomplete, suggest, typeahead 5 5 Requires at least: 3.3 6 Tested up to: 5. 1.07 Stable tag: 2.0. 16 Tested up to: 5.2.4 7 Stable tag: 2.0.2 8 8 License: Apache 2.0 9 9 License URI: https://github.com/swiftype/swiftype-wordpress/blob/master/LICENSE … … 66 66 67 67 == Changelog == 68 69 = 2.0.2 = 70 * WP-CLI fixes and action refactoring 68 71 69 72 = 2.0.1 = -
swiftype-search/trunk/scripts/publish.sh
r795116 r2174745 32 32 echo " done" 33 33 34 echo -n "Copying current git state to svn trunk..."34 echo -n "Copying current git state to svn assets & trunk..." 35 35 find $svn_directory/trunk -type lf ! -path '*.svn*' -exec rm {} \; 36 cp $git_directory/assets/banner-* $git_directory/assets/screenshot-* $svn_directory/assets 36 37 cp -R $git_directory/* $svn_directory/trunk/ 37 38 cd $svn_directory -
swiftype-search/trunk/swiftype.php
r2061691 r2174745 10 10 */ 11 11 12 define('SWIFTYPE_VERSION', '2.0. 1');12 define('SWIFTYPE_VERSION', '2.0.2'); 13 13 14 14 require_once('vendor/autoload.php'); -
swiftype-search/trunk/templates/admin/authorize.php
r2056911 r2174745 41 41 <p><?= __("Enter your API key in the field below and click 'Authorize' to get started."); ?></p> 42 42 <form name="swiftype_settings" method="post" action="<?php echo \esc_url(\admin_url()); ?>"> 43 <?php wp_nonce_field('swiftype- nonce'); ?>43 <?php wp_nonce_field('swiftype-ajax-nonce'); ?> 44 44 <input type="hidden" name="action" value="swiftype_set_api_key"> 45 45 <ul> -
swiftype-search/trunk/templates/admin/choose-engine.php
r2061670 r2174745 12 12 <div class="card"> 13 13 <form name="swiftype_settings" id="engine-chooser-form" method="post" action="<?php echo \esc_url(\admin_url()); ?>"> 14 <?php wp_nonce_field('swiftype- nonce'); ?>14 <?php wp_nonce_field('swiftype-ajax-nonce'); ?> 15 15 <input type="hidden" name="action" value="swiftype_create_engine"> 16 16 <?php if (isset($_REQUEST['error'])): ?> … … 83 83 84 84 <form name="swiftype_reset" method="post" action="<?php echo \esc_url(\admin_url()); ?>"> 85 <?php wp_nonce_field('swiftype- nonce'); ?>85 <?php wp_nonce_field('swiftype-ajax-nonce'); ?> 86 86 <input type="hidden" name="action" value="swiftype_clear_config"> 87 87 </form> -
swiftype-search/trunk/templates/admin/controls/dangerous-settings.php
r2056911 r2174745 9 9 <td> 10 10 <form name="swiftype_settings_reset" method="post" action="<?php echo \esc_url(\admin_url()); ?>"> 11 <?php wp_nonce_field('swiftype- nonce'); ?>11 <?php wp_nonce_field('swiftype-ajax-nonce'); ?> 12 12 <input type="hidden" name="action" value="swiftype_clear_config"> 13 13 <input type="submit" name="Submit" value="Reset Configuration" class="button-primary" /> -
swiftype-search/trunk/tests/bootstrap.php
r2056911 r2174745 26 26 require_once dirname(dirname(__FILE__)) . '/swiftype.php'; 27 27 } 28 28 29 tests_add_filter('muplugins_loaded', '_manually_load_plugin'); 29 30 30 31 // Start up the WP testing environment. 31 32 require $testsDir . '/includes/bootstrap.php'; 32
Note: See TracChangeset
for help on using the changeset viewer.