Skip to content

Commit

Permalink
Force manual input for Schema.org Person when > 20 users (#2995)
Browse files Browse the repository at this point in the history
* Force manual input for Schema.org Person when > 20 users #2397

* Increase max user count to 50 #2397
  • Loading branch information
arnaudbroes committed Nov 3, 2019
1 parent 2e2b2eb commit a6f59f7
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions aioseop_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1127,23 +1127,35 @@ function __construct() {
),
);

$user_args = array(
'role__in' => array(
'administrator',
'editor',
'author',
),
'orderby' => 'nicename',
);
$users = get_users( $user_args );
global $pagenow;
if ( 'admin.php' === $pagenow ) {
// Person's Username setting.
$this->default_options['schema_person_user']['initial_options'] = array(
0 => __( '- Select -', 'all-in-one-seo-pack' ),
-1 => __( 'Manually Enter', 'all-in-one-seo-pack' ),
);

// Person's Username setting.
$this->default_options['schema_person_user']['initial_options'] = array(
0 => __( '- Select -', 'all-in-one-seo-pack' ),
-1 => __( 'Manually Enter', 'all-in-one-seo-pack' ),
);
foreach ( $users as $user ) {
$this->default_options['schema_person_user']['initial_options'][ $user->ID ] = $user->data->user_nicename . ' (' . $user->data->display_name . ')';
global $wpdb;
$user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" );
if ( 50 < $user_count ) {
$this->default_options['schema_person_user']['initial_options'] = array(
-1 => __( 'Manually Enter', 'all-in-one-seo-pack' ),
);
} else {
$user_args = array(
'role__in' => array(
'administrator',
'editor',
'author',
),
'orderby' => 'nicename',
);
$users = get_users( $user_args );

foreach ( $users as $user ) {
$this->default_options['schema_person_user']['initial_options'][ $user->ID ] = $user->data->user_nicename . ' (' . $user->data->display_name . ')';
}
}
}

if ( AIOSEOPPRO ) {
Expand Down

0 comments on commit a6f59f7

Please sign in to comment.