public static function register_conversation_on_pageload() { // if we're not viewing a post, bail if (!is_single()) { return; } if (comments_open(get_the_ID()) && !SpotIM_Util::is_conversation_processed(get_the_ID())) { // by now this is a post that wasn't processed spotim_instance()->api->register_conversation(get_the_ID()); } }
public function setUp() { parent::setUp(); // add filter for the mock API class $this->spotim_instance = spotim_instance(); // create a post to do the work on $this->_post_id = $post_id = $this->factory->post->create(); // load JSON for main insertions $first_batch_data = $this->_read_json_file('sync-many-inserts.json'); // fire up the sync class $this->first_batch_sync = new SpotIM_Sync($post_id, $first_batch_data); $this->first_batch_result = $this->first_batch_sync->sync(); }
public function initiate_setup() { $current_user = wp_get_current_user(); // grab all the data needed to setup $request_data = array('request_token' => 'somerandomstring', 'blog_name' => get_bloginfo('name'), 'blog_url' => get_bloginfo('url'), 'blog_owner_name' => $current_user->display_name, 'blog_owner_id' => $current_user->ID, 'blog_owner_email' => get_bloginfo('admin_email')); $res = $this->request('spot', $request_data); $response = json_decode($res); // if spot_id/token exist in response, update option. if (is_array($response) && array_key_exists('spot_id', $response) && array_key_exists('spot_token', $response)) { // save the spot_id and spot_token $spotim_instance = spotim_instance(); update_option($spotim_instance::AUTH_OPTION, $response); } }
public function setUp() { parent::setUp(); // add filter for the mock API class $this->spotim_instance = spotim_instance(); }
public function test_get_instance() { $instance = spotim_instance(); $this->assertInstanceOf('WP_SpotIM', $instance); }
/** * Check that the API keys provided have the proper key-specific permissions to either read or write API resources * * @param WP_User $user * @throws Exception if the permission check fails */ public function check_api_key_permissions($user) { $key_permissions = 'read_write'; switch (spotim_instance()->spotim_api->server->method) { case 'HEAD': case 'GET': if ('read' !== $key_permissions && 'read_write' !== $key_permissions) { throw new Exception(__('The API key provided does not have read permissions', 'wp-spotim'), 401); } break; case 'POST': case 'PUT': case 'PATCH': case 'DELETE': if ('write' !== $key_permissions && 'read_write' !== $key_permissions) { throw new Exception(__('The API key provided does not have write permissions', 'wp-spotim'), 401); } break; } }
public function test_recieve_setup_spot_id_token() { // run initial plugin setup hook $this->assertTrue(spotim_instance()->api->initiate_setup()); }