/** * Give the user options for how to handle their legacy Stream records * * @action admin_notices * @return void */ public static function show_migrate_notice() { if (!isset($_GET['migrate_action']) && WP_Stream::is_connected() && WP_Stream_Admin::is_stream_screen() && !empty(self::$record_count) && false === get_transient(self::MIGRATE_DELAY_TRANSIENT)) { return true; } return false; }
public static function in_admin_header() { ?> <div class="stream-example"> <div class="stream-example-modal"> <h1><i class="dashicons dashicons-chart-area"></i> <?php _e('Stream Reports', 'stream'); ?> </h1> <p><?php _e('Generate stunning visuals of logged-in user activity and share them with stakeholders or your clients.', 'stream'); ?> </p> <ul> <li><i class="dashicons dashicons-yes"></i> <?php _e('Fully-interactive charts', 'stream'); ?> </li> <li><i class="dashicons dashicons-yes"></i> <?php _e('Monitor team contributions', 'stream'); ?> </li> <li><i class="dashicons dashicons-yes"></i> <?php _e('Responsive for any screen size', 'stream'); ?> </li> </ul> <a href="<?php echo esc_url(WP_Stream_Admin::account_url(sprintf('upgrade?site_uuid=%s', WP_Stream::$api->site_uuid))); ?> " class="button button-primary button-large"><?php _e('Upgrade to Pro', 'stream'); ?> </a> </div> </div> <?php }
public static function register_list_table() { self::$list_table = new WP_Stream_List_Table(array('screen' => self::$screen_id['main'])); }
public static function register_list_table() { require_once WP_STREAM_INC_DIR . 'list-table.php'; self::$list_table = new WP_Stream_List_Table(array('screen' => self::$screen_id['main'])); }
public function get_filters() { $filters = array(); $date_interval = new WP_Stream_Date_Interval(); $filters['date'] = array('title' => __('dates', 'stream'), 'items' => $date_interval->intervals); $authors_records = WP_Stream_Admin::get_authors_record_meta($this->assemble_records('author')); $filters['author'] = array('title' => __('authors', 'stream'), 'items' => $authors_records, 'ajax' => count($authors_records) <= 0); $filters['context'] = array('title' => __('contexts', 'stream'), 'items' => $this->assemble_records('context')); $filters['action'] = array('title' => __('actions', 'stream'), 'items' => $this->assemble_records('action')); /** * Filter allows additional filters in the list table dropdowns * Note the format of the filters above, with they key and array * containing a title and array of items. * * @since 0.2.0 * * @return array */ return apply_filters('wp_stream_list_table_filters', $filters); }
/** * Helper function to query the marketplace API via wp_remote_request. * * @param string The url to access. * @param string The method of the request. * @param array The headers sent during the request. * @param bool Allow API calls to be cached. * @param int Set transient expiration in seconds. * * @return object The results of the wp_remote_request request. */ protected function remote_request($url = '', $args = array(), $allow_cache = true, $expiration = 300) { if (empty($url)) { return false; } $defaults = array('headers' => array(), 'method' => 'GET', 'body' => '', 'sslverify' => true); $this->count++; $args = wp_parse_args($args, $defaults); $args['headers']['Stream-Site-API-Key'] = $this->api_key; $args['headers']['Accept-Version'] = $this->api_version; $args['headers']['Content-Type'] = 'application/json'; if (WP_Stream::is_development_mode()) { $args['blocking'] = true; } add_filter('http_api_transports', array(__CLASS__, 'http_api_transport_priority'), 10, 3); $transient = 'wp_stream_' . md5($url); if ('GET' === $args['method'] && $allow_cache) { if (false === ($request = get_transient($transient))) { $request = wp_remote_request($url, $args); set_transient($transient, $request, $expiration); } } else { $request = wp_remote_request($url, $args); } remove_filter('http_api_transports', array(__CLASS__, 'http_api_transport_priority'), 10); // Return early if the request is non blocking if (isset($args['blocking']) && false === $args['blocking']) { return true; } if (!is_wp_error($request)) { $data = apply_filters('wp_stream_api_request_data', json_decode($request['body']), $url, $args); // Loose comparison needed if (200 == $request['response']['code'] || 201 == $request['response']['code']) { return $data; } else { // Disconnect if unauthorized or no longer exists, loose comparison needed if (403 == $request['response']['code'] || 410 == $request['response']['code']) { WP_Stream_Admin::remove_api_authentication(); } $this->errors['errors']['http_code'] = $request['response']['code']; } if (isset($data->error)) { $this->errors['errors']['api_error'] = $data->error; } } else { $this->errors['errors']['remote_request_error'] = $request->get_error_message(); WP_Stream::notice(sprintf('<strong>%s</strong> %s.', __('Stream API Error.', 'stream'), $this->errors['errors']['remote_request_error'])); } if (!empty($this->errors)) { delete_transient($transient); } return false; }
public static function in_admin_header() { global $typenow; if (WP_Stream_Notifications_Post_Type::POSTTYPE !== $typenow) { return; } ?> <div class="stream-example"> <div class="stream-example-modal"> <h1><i class="dashicons dashicons-admin-comments"></i> <?php _e('Stream Notifications', 'stream'); ?> </h1> <p><?php _e('Get notified instantly when important changes are made on your site.', 'stream'); ?> </p> <ul> <li><i class="dashicons dashicons-yes"></i> <?php _e('Create notification rules quickly and easily', 'stream'); ?> </li> <li><i class="dashicons dashicons-yes"></i> <?php _e('Smart and powerful trigger matching', 'stream'); ?> </li> <li><i class="dashicons dashicons-yes"></i> <?php _e('Fully customized e-mail and SMS alerts', 'stream'); ?> </li> <li><i class="dashicons dashicons-yes"></i> <?php _e('Push alerts to your smartphone or tablet', 'stream'); ?> </li> </ul> <a href="<?php echo esc_url(WP_Stream_Admin::account_url(sprintf('upgrade?site_uuid=%s', WP_Stream::$api->site_uuid))); ?> " class="button button-primary button-large"><?php _e('Upgrade to Pro', 'stream'); ?> </a> </div> </div> <?php }
/** * Helper function to query the marketplace API via wp_remote_request. * * @param string The url to access. * @param string The method of the request. * @param array The headers sent during the request. * @param bool Allow API calls to be cached. * @param int Set transient expiration in seconds. * * @return object The results of the wp_remote_request request. */ protected function remote_request($url = '', $args = array(), $allow_cache = true, $expiration = 300) { if (empty($url) || empty(get_option('api_key'))) { return false; } // error_log("url: ".json_encode($url)); $defaults = array('headers' => array(), 'method' => 'GET', 'body' => '', 'sslverify' => true); $args = wp_parse_args($args, $defaults); $args['headers']['Stream-Site-API-Key'] = get_option('api_key'); $args['headers']['Content-Type'] = 'application/json'; add_filter('http_api_transports', array(__CLASS__, 'http_api_transport_priority'), 10, 3); $transient = 'wp_stream_' . md5($url); // error_log("args:".json_encode($args)); // error_log("url:".$url); if ('GET' === $args['method'] && $allow_cache) { if (false === ($request = get_transient($transient))) { $request = wp_remote_request($url, $args); set_transient($transient, $request, $expiration); } } else { $request = wp_remote_request($url, $args); } remove_filter('http_api_transports', array(__CLASS__, 'http_api_transport_priority'), 10); // Return early if the request is non blocking if (isset($args['blocking']) && false === $args['blocking']) { return true; } if (!is_wp_error($request)) { /** * Filter the request data of the API response. * * Does not fire on non-blocking requests. * * @since 2.0.0 * * @param string $url * @param array $args * * @return array */ $data = apply_filters('wp_stream_api_request_data', json_decode($request['body']), $url, $args); // Loose comparison needed if (200 == $request['response']['code'] || 201 == $request['response']['code']) { return $data; } else { // Disconnect if unauthorized or no longer exists, loose comparison needed if (403 == $request['response']['code'] || 410 == $request['response']['code']) { WP_Stream_Admin::remove_api_authentication(); } $this->errors['errors']['http_code'] = $request['response']['code']; } if (isset($data->error)) { $this->errors['errors']['api_error'] = $data->error; } } else { $this->errors['errors']['remote_request_error'] = $request->get_error_message(); wp_stream_get_instance()->admin->notice(sprintf('<strong>%s</strong> %s.', __('Stream API Error.', 'stream'), $this->errors['errors']['remote_request_error'])); } if (!empty($this->errors)) { delete_transient($transient); } return false; }
static function update_activation_hook() { WP_Stream_Admin::register_update_hook(dirname(plugin_basename(__FILE__)), array(__CLASS__, 'install'), self::VERSION); }