/** * Test the plugin configuration. */ function testConfiguration() { // #43: https://github.com/insideout10/wordlift-plugin/issues/43 // We're using WordLift Server, we do not require a Redlink Key nor a Dataset Name to be set: // we now require a WordLift key to be set. In turn, setting WordLift key should set the dataset URI, // that we'll continue to check. // $this->assertNotNull(wl_configuration_get_redlink_key()); // $this->assertNotNull( wl_configuration_get_redlink_dataset_name() ); // $this->assertNotNull( wl_configuration_get_redlink_user_id() ); $this->assertNotNull(wl_configuration_get_key()); $this->assertNotNull(wl_configuration_get_redlink_dataset_uri()); $this->assertEquals(WL_CONFIG_DEFAULT_SITE_LANGUAGE, wl_configuration_get_site_language()); }
function test_wl_configuration_key() { $value = uniqid(); wl_configuration_set_key($value); $this->assertEquals($value, wl_configuration_get_key()); }
/** * Get the URL to perform indexing operations. * * @since 3.0.0 * * @return string The URL to call to perform the indexing operation. */ function wl_configuration_get_dataset_index_url() { // If the WordLift Key is set, we use WordLift. $key = wl_configuration_get_key(); if (!empty($key)) { return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "datasets/key={$key}/index"; } // get the configuration. $redlink_dataset = wl_configuration_get_redlink_dataset_name(); $redlink_key = wl_configuration_get_redlink_key(); // construct the API URL. return wl_configuration_get_api_url() . "/data/{$redlink_dataset}/release?key={$redlink_key}"; }
/** * Hide the WordLift Key from the provided text. * * @since 3.0.0 * * @param $text string A text that may potentially contain a WL key. * * @return string A text with the key hidden. */ function wl_write_log_hide_key($text) { return str_ireplace(wl_configuration_get_key(), '<hidden>', $text); }
/** * Check WordLift's configuration. * * @since 3.0.0 * * @return bool True if the configuration is set otherwise false. */ function wl_configuration_validate() { // Check that the WordLift key has been set or show a notice. if ('' !== wl_configuration_get_key()) { return; } Wordlift_Notice_Service::get_instance()->add_error(sprintf(__('application-key-not-set', 'wordlift'), 'http://join.wordlift.it')); }
/** * Check WordLift's configuration. * * @since 3.0.0 * * @return bool True if the configuration is set otherwise false. */ function wl_configuration_validate() { return !('' === wl_configuration_get_key() && '' === wl_configuration_get_redlink_key()); }
/** * Install Wordlift in WordPress. */ function wl_core_install() { // Create a blank application key if there is none $key = wl_configuration_get_key(); if (empty($key)) { wl_configuration_set_key(''); } wl_core_install_entity_type_data(); wl_core_install_create_relation_instance_table(); }