Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 65: Enable Stream on multisite / network installs #401

Merged
merged 141 commits into from
Apr 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
fda5332
Issue 65 Enable stream network
Jan 14, 2014
cefde8e
Network logging
Jan 14, 2014
46526d8
Network Admin List Table
Jan 14, 2014
e589ede
Network Admin Screen
Jan 14, 2014
9f65ca9
Add Stream Activity dashboard widget to network admin screen
Jan 14, 2014
cf6674c
Add initial context for blogs connector
Jan 15, 2014
8798f35
Blogs connector //comment out wp_get_sites to prevent fatal errors be…
Jan 15, 2014
343ad53
Move blogs.php to tmp directory during development
Jan 15, 2014
752fdb1
Log, query and display network wide options as blog_id 0
Jan 15, 2014
dc70230
added filter to blog_id used in log
Jan 15, 2014
d392373
Merge branch 'master' into issue-65
frankiejarrett Jan 19, 2014
babb077
Fix undefined function when multisite is not enabled
frankiejarrett Jan 19, 2014
ce2b64c
Just use null for site_id when not in multisite
frankiejarrett Jan 19, 2014
fe004b5
Remove ID col from network admin list table view
frankiejarrett Jan 20, 2014
dfc3437
Trivial code formatting
frankiejarrett Jan 20, 2014
b951ff9
Network Wide Stream
Feb 10, 2014
5431df1
Network Stream
Feb 10, 2014
febce32
Merge branch 'master' into issue-65
frankiejarrett Feb 11, 2014
b3b7919
Fixing phpcs syntax errors
frankiejarrett Feb 11, 2014
aa6cd33
Spacing fixes
frankiejarrett Feb 11, 2014
beb3489
Fixing phpcs syntax errors in list-table
frankiejarrett Feb 11, 2014
8e5bdd1
Fixing phpcs syntax errors in settings
frankiejarrett Feb 13, 2014
23fcafe
Don't use multisite-only functions when not in multisite
frankiejarrett Feb 13, 2014
bb5b391
Remove empty lines
frankiejarrett Feb 13, 2014
16e5821
Merge branch 'master' into issue-65
frankiejarrett Feb 18, 2014
11cf7b6
Display blogs titles in filter dropdown + fix warning
Mar 2, 2014
85992e1
[issue-65] Use more descriptive var name
Mar 2, 2014
221e7c5
[issue-65] Use `network` option value instead of `0`
Mar 2, 2014
d159b83
[issue-65] Filter `network` arg value to 0
Mar 2, 2014
67d6029
[issue-65] Add missing parentheses
Mar 2, 2014
ba206c5
[issue-65] Add msising parameter
Mar 2, 2014
4e05ea6
[issue] Translate Network Admin string
Mar 2, 2014
0e896c1
[issue-65] Log using blog's table prefix
Mar 2, 2014
47ce44f
Merge branch 'develop' into issue-65
frankiejarrett Mar 14, 2014
0c34ac8
Fixing sniffs in tmp Blogs connector
frankiejarrett Mar 14, 2014
a57ad69
Fixed some undefined notices.
lukecarbis Mar 31, 2014
d146920
Fixed the network admin settings.
lukecarbis Mar 31, 2014
d3844dc
Merge branch 'origin/develop' into issue-65
lukecarbis Mar 31, 2014
b760402
Fixed undefined notice $item->blog_id.
lukecarbis Mar 31, 2014
cec5ac0
Database updates. Fixes storing / retrieving steam entries for blogs.
lukecarbis Mar 31, 2014
94a22e3
Trimmed Whitespace
lukecarbis Mar 31, 2014
c66ce96
Remove the ability to change individual blog settings
lukecarbis Apr 2, 2014
e1b18dd
Separated Network and Site Settings
lukecarbis Apr 2, 2014
fc26be4
Fix blog_id column in Stream Activity, and rename to Site
lukecarbis Apr 2, 2014
1f7f39b
Various fixes
lukecarbis Apr 2, 2014
af81256
Options working with defaults, but implementation could do with some …
lukecarbis Apr 2, 2014
b4cf0c1
Add get_option_key to settings.
lukecarbis Apr 2, 2014
ee44bf3
Streamlined saving network and default settings.
lukecarbis Apr 2, 2014
d5c6e88
Remove get_network_sites() since it's not used
lukecarbis Apr 2, 2014
9d443b4
Fix reset database when network enabled
lukecarbis Apr 2, 2014
d2067b5
Fix tabs on default settings page
lukecarbis Apr 2, 2014
6790657
Fix for NULL default for blog_id column
lukecarbis Apr 2, 2014
8f493ad
Capability check if tables do not exist
lukecarbis Apr 2, 2014
abf00dd
Fix for unnecessary static db in last commit
lukecarbis Apr 2, 2014
6295045
Merge remote-tracking branch 'origin/master' into issue-65
lukecarbis Apr 3, 2014
486a6cd
Merge remote-tracking branch 'origin/master' into issue-65
lukecarbis Apr 3, 2014
59fe5c6
Fix Travis CI Errors
lukecarbis Apr 3, 2014
739f6b2
Fix fatal error on settings page.
lukecarbis Apr 3, 2014
4728dfd
Add Reset Site Settings option
lukecarbis Apr 3, 2014
8b5ea3d
Fix live update and columns
lukecarbis Apr 4, 2014
3f84124
Add Network Settings to settings connector.
lukecarbis Apr 4, 2014
2416dcc
Fix screen option column toggles
lukecarbis Apr 4, 2014
78432aa
Clean up admin, install and db-actions
lukecarbis Apr 7, 2014
0f63f20
Clean up admin, list-table
lukecarbis Apr 7, 2014
8de845f
Add blogs connector
lukecarbis Apr 8, 2014
0eed70c
Fix non-multisite error when using wp_get_sites()
lukecarbis Apr 8, 2014
dbd66b4
Upgrade routine for merging multisite tables
lukecarbis Apr 8, 2014
cb6f50d
Update routine version change
lukecarbis Apr 8, 2014
1fbb93d
Fix spacing errors
lukecarbis Apr 8, 2014
88b36b3
Merge branch 'develop' into issue-65
Apr 11, 2014
297f877
Should have been in merge
Apr 11, 2014
5a3e26f
Add blog count to records page title in network admin
frankiejarrett Apr 11, 2014
78fe00a
New settings layout in network admin.
Apr 11, 2014
5296812
Add 1 for network admin
frankiejarrett Apr 11, 2014
30f7600
Merge branch 'issue-65' of github.com:x-team/wp-stream into issue-65
frankiejarrett Apr 11, 2014
d089d8b
Revert "Add 1 for network admin"
frankiejarrett Apr 11, 2014
30682dd
Fix undefined key notice
frankiejarrett Apr 11, 2014
b9ab2fd
Don't show descriptions unless in the network admin
frankiejarrett Apr 11, 2014
2b31534
Code formatting
frankiejarrett Apr 11, 2014
ffd4529
Change the Private Feeds desc in the Network Admin
Apr 11, 2014
86b0e34
Remove tabs when only one exists
Apr 11, 2014
5dd02a9
Updating field description for network admin private feeds
frankiejarrett Apr 11, 2014
82ea869
Merge branch 'develop' into issue-65
frankiejarrett Apr 11, 2014
83e3c43
Changes to dashboard widget when viewed in Network Admin
frankiejarrett Apr 11, 2014
e734f03
Remove settings from New Site Settings screen
Apr 13, 2014
0e85746
Nicer way of editing the private feeds setting
Apr 15, 2014
e29e7d8
Adds feed support on multisite
Apr 15, 2014
8dc371a
Better name for "Network Admin in Feeds" setting
Apr 15, 2014
8a65b20
Patch vulnerability
Apr 15, 2014
2e8155a
Moving the furniture around
Apr 15, 2014
50366d0
Workaround for phpcs check
Apr 15, 2014
d695533
Merge branch 'develop' into issue-65
Apr 15, 2014
d15672f
Replace deprecated filter
Apr 15, 2014
f22b84d
Merge remote-tracking branch 'origin/issue-409' into issue-65
Apr 15, 2014
b2a30c3
Fix live updates for all blogs in network admin
Apr 15, 2014
6834837
Merge branch 'develop' into issue-65
Apr 15, 2014
f88816d
Fix ttl purge and enable for network
Apr 15, 2014
d04e706
Better uninstall for multisite
Apr 15, 2014
f679d08
Better uninstall
Apr 15, 2014
fbccdb5
Revert ttl fix (will open a separate issue)
Apr 15, 2014
3e9d64b
Fix network feed not showing after #410 merge
Apr 15, 2014
7cc0bd0
Fix database reset
Apr 16, 2014
c3756ea
Tidy up
Apr 16, 2014
7df5187
Rethinking settings for multisite
Apr 16, 2014
b2bbe2c
Network admin check for scheduled ttl purge
Apr 16, 2014
cfa01ba
Better quotes for query.
Apr 16, 2014
0677f53
Oops - used a deprecated function.
Apr 16, 2014
7e7b298
Remove exclude Network Admin Settings
Apr 16, 2014
64d9dc0
Version bump for testing
frankiejarrett Apr 17, 2014
c68699a
Cleaning up.
Apr 17, 2014
33c2433
Fixing sniff for misaligned equal sign
frankiejarrett Apr 17, 2014
06e451b
Merge branch 'develop' into issue-65
frankiejarrett Apr 17, 2014
fa4aa3e
Simplified the get_fields() function.
Apr 17, 2014
c103eee
Restore update routine.
Apr 17, 2014
91a43fc
Fix uninstall bug
Apr 17, 2014
c46114e
Fix primary blog records disappearing in update
Apr 17, 2014
84431b4
Move deactivate after is_plugin_active check.
Apr 17, 2014
fea9e2f
Fix network settings bug
Apr 17, 2014
fc4ab67
Fix bug preventing Stream access
Apr 17, 2014
95dd2a1
Check if exists before adding blog_id
Apr 17, 2014
fc36bf1
Don't show Stream if there's a DB update that needs a-doin'
Apr 17, 2014
4be02d2
Add Stream to the admin bar menu under My Sites > Network Admin
frankiejarrett Apr 17, 2014
3417e72
Merge branch 'issue-65' of github.com:x-team/wp-stream into issue-65
frankiejarrett Apr 17, 2014
c682f8e
Code formatting on array
frankiejarrett Apr 17, 2014
d02c954
Make some network functions static
Apr 17, 2014
9856364
Merge branch 'develop' into issue-65
Apr 17, 2014
34f2095
Fix for blog_id = '0' argument
Apr 18, 2014
bde79bb
Add is_plugin_active_for_network function check
Apr 18, 2014
1ce1466
Merge branch 'develop' into issue-65
Apr 18, 2014
4b63113
Code formatting
frankiejarrett Apr 18, 2014
68f0648
Ensure Network Admin can see DB update notices
frankiejarrett Apr 18, 2014
a3ebb08
Merge branch 'develop' into issue-65
frankiejarrett Apr 18, 2014
26e943f
Use default site_id of 1 if not on multisite
frankiejarrett Apr 18, 2014
408b0b9
Use get_site_option in feeds for MS compat
frankiejarrett Apr 18, 2014
381857a
Escape blog_charset output, provide text domain in translatable strings
frankiejarrett Apr 18, 2014
be7360b
Don't get option from network-wide
frankiejarrett Apr 18, 2014
4eb2fcd
Make author_role column value NULL by default when updating the DB
frankiejarrett Apr 18, 2014
2b5d20b
Fix last commit, edited wrong statement
frankiejarrett Apr 18, 2014
c07e3a9
Merge branch 'develop' into issue-65
Apr 22, 2014
b56b238
Merge branch 'develop' into issue-65
frankiejarrett Apr 22, 2014
2e5a56d
Set proper query default args for site_id
frankiejarrett Apr 22, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
309 changes: 309 additions & 0 deletions connectors/blogs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
<?php

class WP_Stream_Connector_Blogs extends WP_Stream_Connector {

/**
* Context name
* @var string
*/
public static $name = 'blogs';

/**
* Actions registered for this context
* @var array
*/
public static $actions = array(
'wpmu_new_blog',
'wpmu_activate_blog',
'wpmu_new_user',
'add_user_to_blog',
'remove_user_from_blog',
'make_spam_blog',
'make_ham_blog',
'mature_blog',
'unmature_blog',
'archive_blog',
'unarchive_blog',
'make_delete_blog',
'make_undelete_blog',
'update_blog_public',
);

/**
* Return translated context label
*
* @return string Translated context label
*/
public static function get_label() {
return __( 'Sites', 'stream' );
}

/**
* Return translated action labels
*
* @return array Action label translations
*/
public static function get_action_labels() {
return array(
'updated' => __( 'Updated', 'stream' ),
'created' => __( 'Created', 'stream' ),
'archive_blog' => __( 'Archived', 'stream' ),
'deleted' => __( 'Deleted', 'stream' ),
);
}

/**
* Return translated context labels
*
* @return array Context label translations
*/
public static function get_context_labels() {
$labels = array();
if ( is_multisite() ) {
$blogs = wp_get_sites();
foreach ( $blogs as $blog ) {
$blog_details = get_blog_details( $blog['blog_id'] );
$key = sanitize_key( $blog_details->blogname );
$labels[ $key ] = $blog_details->blogname;
}
}
return $labels;
}

/**
* Add action links to Stream drop row in admin list screen
*
* @filter wp_stream_action_links_{connector}
* @param array $links Previous links registered
* @param int $record Stream record
* @return array Action links
*/
public static function action_links( $links, $record ) {
$links [ __( 'Site Admin', 'stream' ) ] = get_admin_url( $record->object_id );
if ( $record->object_id ) {
$site_admin_link = get_admin_url( $record->object_id );

if ( $site_admin_link ) {
$links [ __( 'Site Admin', 'stream' ) ] = $site_admin_link;
}

$site_settings_link = add_query_arg(
array(
'id' => $record->object_id,
),
network_admin_url( 'site-info.php' )
);

if ( $site_settings_link ) {
$links [ __( 'Site Settings', 'stream' ) ] = $site_settings_link;
}
}
return $links;
}

/**
* @param $blog_id
* @action wpmu_new_blog
*/
public static function callback_wpmu_new_blog( $blog_id ) {
$blog = get_blog_details( $blog_id );
$context = sanitize_key( $blog->blogname );
self::log(
_x(
'A new site called "%1$s" has been created.',
'1. Site name',
'stream'
),
array(
'site_name' => $blog->blogname,
),
$blog_id,
array( $context => 'created' )
);
}

/**
* @param $blog_id
* @param $user_id
* @action wpmu_activate_blog
*/
public static function callback_wpmu_activate_blog( $blog_id, $user_id ) {
$blog = get_blog_details( $blog_id );
$context = sanitize_key( $blog->blogname );
self::log(
_x(
'A new site called "%1$s" has been registered.',
'1. Site name',
'stream'
),
array(
'site_name' => $blog->blogname,
),
$blog_id,
array( $context => 'created' ),
$user_id
);
}

/**
* @param $user_id
* @param $role
* @param $blog_id
* @action add_user_to_blog
*/
public static function callback_add_user_to_blog( $user_id, $role, $blog_id ) {
$blog = get_blog_details( $blog_id );
$user = get_user_by( 'id', $user_id );
$context = sanitize_key( $blog->blogname );

if ( ! is_a( $user, 'WP_User' ) ) {
return;
}

self::log(
_x(
'%1$s has been added to the site "%2$s" with %3$s capabilities.',
'1. User\'s name, 2. Site name, 3. Role',
'stream'
),
array(
'user_name' => $user->display_name,
'site_name' => $blog->blogname,
'role_name' => $role,
),
$blog_id,
array( $context => 'updated' )
);
}

/**
* @param $user_id
* @param $blog_id
* @action remove_user_from_blog
*/
public static function callback_remove_user_from_blog( $user_id, $blog_id ) {
$blog = get_blog_details( $blog_id );
$user = get_user_by( 'id', $user_id );
$context = sanitize_key( $blog->blogname );

if ( ! is_a( $user, 'WP_User' ) ) {
return;
}

self::log(
_x(
'%1$s has been removed from the site "%2$s".',
'1. User\'s name, 2. Site name',
'stream'
),
array(
'user_name' => $user->display_name,
'site_name' => $blog->blogname,
),
$blog_id,
array( $context => 'updated' )
);
}

/**
* @param $blog_id
* @action make_spam_blog
*/
public static function callback_make_spam_blog( $blog_id ) {
self::callback_update_blog_status( $blog_id, __( 'marked as spam', 'stream' ), 'updated' );
}

/**
* @param $blog_id
* @action make_spam_blog
*/
public static function callback_make_ham_blog( $blog_id ) {
self::callback_update_blog_status( $blog_id, __( 'marked as not spam', 'stream' ), 'updated' );
}

/**
* @param $blog_id
* @action mature_blog
*/
public static function callback_mature_blog( $blog_id ) {
self::callback_update_blog_status( $blog_id, __( 'marked as mature', 'stream' ), 'updated' );
}

/**
* @param $blog
* @action unmature_blog
*/
public static function callback_unmature_blog( $blog ) {
self::callback_update_blog_status( $blog_id, __( 'marked as not mature', 'stream' ), 'updated' );
}

/**
* @param $blog
* @action archive_blog
*/
public static function callback_archive_blog( $blog ) {
self::callback_update_blog_status( $blog_id, __( 'archived', 'stream' ), 'archive_blog' );
}

/**
* @param $blog_id
* @action unarchive_blog
*/
public static function callback_unarchive_blog( $blog_id ) {
self::callback_update_blog_status( $blog_id, __( 'restored from archive', 'stream' ), 'updated' );
}

/**
* @param $blog_id
* @action make_delete_blog
*/
public static function callback_make_delete_blog( $blog_id ) {
self::callback_update_blog_status( $blog_id, __( 'deleted', 'stream' ), 'deleted' );
}

/**
* @param $blog_id
* @action undelete_blog
*/
public static function callback_make_undelete_blog( $blog_id ) {
self::callback_update_blog_status( $blog_id, __( 'restored', 'stream' ), 'updated' );
}

/**
* @param $blog_id
* @param $value
* @action update_blog_public
*/
public static function callback_update_blog_public( $blog_id, $value ) {
if ( $value ) {
$status = __( 'marked as public', 'stream' );
} else {
$status = __( 'marked as private', 'stream' );
}
self::callback_update_blog_status( $blog_id, $status, 'updated' );
}

/**
* @param $blog_id
* @action update_blog_public
*/
public static function callback_update_blog_status( $blog_id, $status, $action ) {
$blog = get_blog_details( $blog_id );
$context = sanitize_key( $blog->blogname );
self::log(
_x(
'"%1$s" has been %2$s.',
'1. Site name, 2. Status',
'stream'
),
array(
'site_name' => $blog->blogname,
'status' => $status,
),
$blog_id,
array( $context => $action )
);

}

}
Loading