Skip to content

Commit

Permalink
Merge pull request #141 from fumikito/enhancemnet/user-view
Browse files Browse the repository at this point in the history
Enhancemnet/user view
  • Loading branch information
fumikito authored Aug 29, 2024
2 parents 7f2082d + 40ada6f commit 36e582e
Show file tree
Hide file tree
Showing 14 changed files with 922 additions and 829 deletions.
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.git
.gitignore
.github
.wordpress-org
tests
bin
node_modules
Expand Down
Binary file added .wordpress-org/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ Sorry for that. Please refer to our support site [gianism.info](http://wordpress

Here is a list of change logs.

### 5.2.1

* Fix JS bug.
* Add SNS icon on user list screen in favor of users' connections.

### 5.2.0

* Fix XSS vulnerability.

### 5.1.0

* Supporting twitter API v2.
Expand Down
7 changes: 5 additions & 2 deletions app/Gianism/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Gianism\Controller\Profile;
use Gianism\Controller\ProfileChecker;
use Gianism\Controller\Rewrite;
use Gianism\Controller\UserList;
use Gianism\Helper\ServiceManager;
use Gianism\Pattern\AppBase;
use Gianism\Pattern\Singleton;
Expand Down Expand Up @@ -106,9 +107,10 @@ function () {

// Initialize Rewrite rules.
Rewrite::get_instance();

// Network controller.
Network::get_instance();
// User list
UserList::get_instance();

// If enabled, create interface and rewrite rules.
if ( $this->option->is_enabled() ) {
Expand All @@ -131,12 +133,13 @@ function () {
*
*/
public function register_assets() {
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
// LigatureSymbols
wp_register_style( 'ligature-symbols', $this->url . 'assets/css/lsf.css', [], '2.11' );
// Gianism style
wp_register_style( $this->name, $this->url . 'assets/css/gianism-style.css', [ 'ligature-symbols' ], $this->version );
// JS Cookie
wp_register_script( 'js-cookie', $this->url . 'assets/js/js.cookie.js', [], '2.1.3', true );
wp_register_script( 'js-cookie', $this->url . 'assets/js/js.cookie' . $min . '.js', [], '3.0.4', true );
// Gianism Notice
wp_register_script(
$this->name . '-notice-helper',
Expand Down
76 changes: 76 additions & 0 deletions app/Gianism/Controller/UserList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace Gianism\Controller;


use Gianism\Pattern\AbstractController;

/**
* Admin user list controller
*/
class UserList extends AbstractController {

/**
* {@inheritDoc}
*/
public function __construct( array $argument = [] ) {
parent::__construct( $argument );
add_filter( 'manage_users_columns', [ $this, 'add_columns' ] );
add_filter( 'manage_users_custom_column', [ $this, 'render_column' ], 10, 3 );
}


/**
* Add column for users list
*
* @param array{string,string} $columns Column name and label
* @return array
*/
public function add_columns( $columns ) {
$new_columns = [];
foreach ( $columns as $key => $label ) {
if ( 'posts' === $key ) {
$new_columns['gianism'] = __( 'SNS', 'wp-gianism' );
}
$new_columns[ $key ] = $label;
}
return $new_columns;
}

/**
* Render column of User list table..
*
* @param string $column Column name.
* @param int $user_id User ID.
*
* @return string
*/
public function render_column( $content, $column, $user_id ) {
switch ( $column ) {
case 'gianism':
$connected = [];
// Get user's connected SNS
foreach ( $this->service->service_list() as $service ) {
if ( ! $service['enabled'] ) {
continue 1;
}
$controller = $this->service->get( $service['name'] );
if ( $controller->is_connected( $user_id ) ) {
$connected[] = sprintf(
'<i class="lsf lsf-%s" title="%s"></i>',
esc_attr( $service['name'] ),
sprintf(
// translators: %s is service name
esc_attr__( 'Connected with %s', 'wp-gianism' ),
esc_attr( $controller->verbose_service_name )
)
);
$controller->disconnect_button( $user_id );
}
}
return empty( $connected ) ? '<span style="color:lightgray;">---</span>' : implode( ' ', $connected );
default:
return $content;
}
}
}
10 changes: 6 additions & 4 deletions app/Gianism/Helper/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Gianism\Pattern\AppBase;
use Gianism\Pattern\Singleton;
use Gianism\Service\AbstractService;

/**
* Class ServiceManager
Expand All @@ -16,7 +17,7 @@ class ServiceManager extends Singleton {
use ExtensionManager;

/**
* @var array
* @var array<string, class-string<AbstractService>>
*/
protected $service_classes = [];

Expand Down Expand Up @@ -110,7 +111,7 @@ public function all_services() {
/**
* Return registered services
*
* @return array
* @return array<array{name:string, label:string, enabled:bool, default:bool}>
*/
public function service_list() {
$services = [];
Expand All @@ -134,10 +135,11 @@ public function service_list() {
* @return null|\Gianism\Service\AbstractService
*/
public function get( $service ) {
if ( ! isset( $this->service_classes[ $service ] ) ) {
$service_classes = $this->service_classes;
if ( ! isset( $service_classes[ $service ] ) ) {
return null;
} else {
$class_name = $this->service_classes[ $service ];
$class_name = $service_classes[ $service ];
return $class_name::get_instance();
}
}
Expand Down
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ gulp.task('copylib', function () {
.pipe(gulp.dest('./assets/fonts/')),
// Copy JS Cookie
gulp.src([
'./node_modules/js-cookie/dist/js.cookie.min.js'
'./node_modules/js-cookie/dist/js.cookie.min.js',
'./node_modules/js-cookie/dist/js.cookie.js'
])
.pipe($.uglify())
.pipe(gulp.dest('./assets/js/'))
);
});
Expand Down
Binary file modified language/wp-gianism-ja.mo
Binary file not shown.
Loading

0 comments on commit 36e582e

Please sign in to comment.