From 818da7ce69a524901137008bb97379835e62d408 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 1 Aug 2018 00:52:21 -0400 Subject: [PATCH 1/8] Remove the Largo Staff widget --- inc/widgets.php | 1 - inc/widgets/largo-staff.php | 123 ------------------------------------ 2 files changed, 124 deletions(-) delete mode 100644 inc/widgets/largo-staff.php diff --git a/inc/widgets.php b/inc/widgets.php index 7d7f4b7ef..e29ae28fa 100644 --- a/inc/widgets.php +++ b/inc/widgets.php @@ -35,7 +35,6 @@ function largo_widgets() { 'largo_author_widget' => '/inc/widgets/largo-author-bio.php', 'largo_tag_list_widget' => '/inc/widgets/largo-tag-list.php', 'largo_prev_next_post_links_widget' => '/inc/widgets/largo-prev-next-post-links.php', - 'largo_staff_widget' => '/inc/widgets/largo-staff.php' ); // If series are enabled diff --git a/inc/widgets/largo-staff.php b/inc/widgets/largo-staff.php deleted file mode 100644 index 715443bc1..000000000 --- a/inc/widgets/largo-staff.php +++ /dev/null @@ -1,123 +0,0 @@ - 'Display a list of staff members with photos and bios.' ) // Args - ); - } - - public function widget( $args, $instance ) { - $title = apply_filters('widget_title', $instance['title']); - - echo $args['before_widget']; - if (!empty($title)) - echo $args['before_title'] . $title . $args['after_title']; - - if (empty($instance['roles'])) { - $users = get_users(array( - 'blog_id' => get_current_blog_id(), - 'role' => 'author' - )); - } else { - $users = array(); - foreach ($instance['roles'] as $key => $val) { - if ($val == 'on') { - $result = get_users(array( - 'blog_id' => get_current_blog_id(), - 'role' => $key - )); - $users = array_merge($users, $result); - } - } - } - - $users = apply_filters('largo_staff_widget_users', $users); - - $markup = ''; - - echo $markup; - echo $args['after_widget']; - } - - public function form( $instance ) { - $roles = get_editable_roles(); - - if (isset($instance['title'])) - $title = $instance['title']; - else - $title = 'Staff Members'; - - if (empty($instance['roles'])) - $instance['roles']['author'] = 'on'; - - ?> -

- - -

- -

-
- $role) { ?> -
- -

- - $role) - $instance['roles'][$key] = (!empty($new_instance[$key]))? $new_instance[$key] : 'off'; - - return $instance; - } - - -} From 8f8e887332c207181789d6c9cdb615ef7aac3b96 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 1 Aug 2018 01:13:52 -0400 Subject: [PATCH 2/8] deprecate largo_render_staff_list_shortcode and with it the [roster] shortcode in Largo, but not the corresponding styles. --- inc/deprecated.php | 16 ++++++++++++++ inc/users.php | 45 ---------------------------------------- tests/inc/test-users.php | 4 ---- 3 files changed, 16 insertions(+), 49 deletions(-) diff --git a/inc/deprecated.php b/inc/deprecated.php index c4d47d3a8..9ead0fd3e 100644 --- a/inc/deprecated.php +++ b/inc/deprecated.php @@ -1,4 +1,7 @@ '; } -/** - * Shortcode version of `largo_render_user_list` - * - * @param $atts array The attributes of the shortcode. - * - * Example of possible attributes: - * - * [roster roles="author,contributor" include="292,12312" exclude="5002,2320" show_users_with_empty_desc="true"] - * - * @since 0.4 - */ -function largo_render_staff_list_shortcode($atts=array()) { - $options = array(); - - $show_users_with_empty_desc = false; - if (!empty($atts['show_users_with_empty_desc'])) { - $show_users_with_empty_desc = ($atts['show_users_with_empty_desc'] == 'false')? false : true; - unset($atts['show_users_with_empty_desc']); - } - - if (!empty($atts['roles'])) { - $roles = explode(',', $atts['roles']); - $options['roles'] = array_map(function($arg) { return trim($arg); }, $roles); - } - - if (!empty($atts['exclude'])) { - $exclude = explode(',', $atts['exclude']); - $options['exclude'] = array_map(function($arg) { return trim($arg); }, $exclude); - } - - if (!empty($atts['include'])) { - $exclude = explode(',', $atts['include']); - $options['include'] = array_map(function($arg) { return trim($arg); }, $exclude); - } - - $defaults = array( - 'roles' => array( - 'author' - ) - ); - $args = array_merge($defaults, $options); - largo_render_user_list(largo_get_user_list($args), $show_users_with_empty_desc); -} -add_shortcode('roster', 'largo_render_staff_list_shortcode'); - /** * Display extra profile fields related to staff member status * diff --git a/tests/inc/test-users.php b/tests/inc/test-users.php index 735fa00d8..9afb06192 100644 --- a/tests/inc/test-users.php +++ b/tests/inc/test-users.php @@ -169,10 +169,6 @@ function test_largo_render_user_list() { } - function test_largo_render_staff_list_shortcode() { - $this->markTestIncomplete('This test has not been implemented yet.'); - } - function test_more_profile_info() { $vars = $this->_more_profile_info_setup(); From e08f35bae5a873168f1d6079b9cdd251933298a0 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 1 Aug 2018 01:15:02 -0400 Subject: [PATCH 3/8] Remove the 'hide' user meta from the additional profile fields stored by Largo --- inc/users.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/inc/users.php b/inc/users.php index 57fc67fde..ea63f7f37 100644 --- a/inc/users.php +++ b/inc/users.php @@ -225,7 +225,6 @@ function largo_render_user_list($users, $show_users_with_empty_desc=false) { */ function more_profile_info($user) { $show_email = get_user_meta( $user->ID, "show_email", true ); - $hide = get_user_meta( $user->ID, "hide", true ); ?>

@@ -246,16 +245,6 @@ function more_profile_info($user) { - - - - - -
- checked /> -
-
'on', - 'hide' => 'off' )); - extract($values); - - update_user_meta($user_id, 'job_title', $job_title); - update_user_meta($user_id, 'show_email', $show_email); - update_user_meta($user_id, 'hide', $hide); + update_user_meta($user_id, 'job_title', $values['job_title']); + update_user_meta($user_id, 'show_email', $values['show_email']); } add_action('personal_options_update', 'save_more_profile_info'); add_action('edit_user_profile_update', 'save_more_profile_info'); From 54d2318aa40f59f60e5129b3fd31eaa3fc542983 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 1 Aug 2018 01:36:53 -0400 Subject: [PATCH 4/8] deprecate largo_render_user_list --- inc/deprecated.php | 21 +++++++++++++++++++-- inc/users.php | 25 ------------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/inc/deprecated.php b/inc/deprecated.php index 9ead0fd3e..83f1e7e4c 100644 --- a/inc/deprecated.php +++ b/inc/deprecated.php @@ -58,13 +58,30 @@ function largo_fb_user_is_followable( $username = '' ) { /** * Former shortcode version of `largo_render_user_list` * - * This function has been superceded by the correspondign shortcode in + * This function has been superceded by the corresponding shortcode in * https://github.com/INN/staff * * @param $atts array The attributes of the shortcode. * @since 0.4 * @link https://github.com/INN/staff + * @link https://github.com/INN/largo/issues/1505 */ function largo_render_staff_list_shortcode($atts=array()) { - error_log(var_export( 'This function is deprecated. Use INN\'s Staff plugin instead', true)); + error_log(var_export( 'function largo_render_staff_list_shortcode is deprecated. Use INN\'s Staff plugin instead', true)); +} + +/** + * Formerly, a list of user profiles based on the array of users passed + * + * This function has been superceded by the corresponding shortcode in + * https://github.com/INN/staff + * + * @param $users array The WP_User objects to use in rendering the list. + * @param $show_users_with_empty_desc bool Whether we should skip users that have no bio/description. + * @since 0.4 + * @link https://github.com/INN/staff + * @link https://github.com/INN/largo/issues/1505 + */ +function largo_render_user_list($users, $show_users_with_empty_desc=false) { + error_log(var_export( 'function largo_render_user_list is deprecated. Use INN\'s Staff plugin instead', true)); } diff --git a/inc/users.php b/inc/users.php index ea63f7f37..383689230 100644 --- a/inc/users.php +++ b/inc/users.php @@ -191,31 +191,6 @@ function largo_get_user_list($args=array()) { return $users; } -/** - * Render a list of user profiles based on the array of users passed - * - * @param $users array The WP_User objects to use in rendering the list. - * @param $show_users_with_empty_desc bool Whether we should skip users that have no bio/description. - * @since 0.4 - */ -function largo_render_user_list($users, $show_users_with_empty_desc=false) { - echo '
'; - foreach ($users as $user) { - $desc = trim($user->description); - if (empty($desc) && ($show_users_with_empty_desc == false)) - continue; - - $hide = get_user_meta($user->ID, 'hide', true); - if ($hide == 'on') - continue; - - $ctx = array('author_obj' => $user); - echo '
'; - largo_render_template('partials/author-bio', 'description', $ctx); - echo '
'; - } - echo '
'; -} /** * Display extra profile fields related to staff member status From ccfadd6f596c0a8bb312a314c0aec1bfffd2b2dd Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 11 Mar 2020 18:43:33 -0400 Subject: [PATCH 5/8] re-remove the largo staff list widget --- inc/widgets/largo-staff.php | 136 ------------------------------------ 1 file changed, 136 deletions(-) delete mode 100644 inc/widgets/largo-staff.php diff --git a/inc/widgets/largo-staff.php b/inc/widgets/largo-staff.php deleted file mode 100644 index a99dc3aa5..000000000 --- a/inc/widgets/largo-staff.php +++ /dev/null @@ -1,136 +0,0 @@ - 'Display a list of staff members with photos and bios.' ) // Args - ); - } - - public function widget( $args, $instance ) { - $title = apply_filters('widget_title', $instance['title']); - - echo $args['before_widget']; - if (!empty($title)) - echo $args['before_title'] . $title . $args['after_title']; - - if (empty($instance['roles'])) { - $users = get_users(array( - 'blog_id' => get_current_blog_id(), - 'role' => 'author' - )); - } else { - $users = array(); - foreach ($instance['roles'] as $key => $val) { - if ($val == 'on') { - $result = get_users(array( - 'blog_id' => get_current_blog_id(), - 'role' => $key - )); - $users = array_merge($users, $result); - } - } - } - - $users = apply_filters('largo_staff_widget_users', $users); - - $markup = '
    '; - foreach ($users as $user) { - $hide = get_user_meta($user->ID, 'hide', true); - if ($hide == 'on') - continue; - - $avatar_alt = esc_attr( $user->first_name . ' ' . $user->last_name ); - if ( $job_title = get_user_meta( $user->ID, 'job_title', true ) ) { - $avatar_alt .= ' (' . $job_title . ')'; - } - $avatar = get_avatar($user->ID, '65', null, esc_attr($avatar_alt)); - $author_url = get_author_posts_url($user->ID); - - $user_posts_link = ''; - if (count_user_posts($user->ID) > 0) - $user_posts_link = "{$user->first_name}'s posts"; - - $markup .= "
  • "; - $markup .= "
    "; - - if (count_user_posts($user->ID) > 0) - $markup .= ""; - - $markup .= " $avatar"; - $markup .= " {$user->display_name}"; - - if (count_user_posts($user->ID) > 0) - $markup .= ""; - - $markup .= "

    $job_title

    "; - $markup .= " $user_posts_link"; - $markup .= "

    "; - $markup .= "
  • "; - - } - $markup .= '
'; - - echo $markup; - echo $args['after_widget']; - } - - public function form( $instance ) { - $roles = get_editable_roles(); - - if (isset($instance['title'])) { - $title = $instance['title']; - } else { - $title = 'Staff Members'; - } - - if (empty($instance['roles'])) { - $instance['roles']['author'] = 'on'; - } - - ?> -

- - -

- -

-
- $role) { - if ( - isset( $instance['roles'] ) - && isset( $instance['roles'][$key] ) - ) { - $checked = checked( $instance['roles'][$key], 'on', false ); - } else { - $checked = ''; - } - ?> - -
- -

- - $role) - $instance['roles'][$key] = (!empty($new_instance[$key]))? $new_instance[$key] : 'off'; - - return $instance; - } - - -} From 3980532752aeb93f0e39fd1f68480d54179d49fe Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 11 Mar 2020 18:57:12 -0400 Subject: [PATCH 6/8] Update changelog with more deprecations for #1505 --- changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.md b/changelog.md index df8b8216d..5721fc5e9 100644 --- a/changelog.md +++ b/changelog.md @@ -17,6 +17,9 @@ Particular thanks go to outside contributor [@seanchayes](https://github.com/sea ### Potentially-breaking changes - Replace `#header-social` in CSS files with `.header-social` to mach updated markup. [Pull request #1826](https://github.com/INN/largo/pull/1826) for [issue #1781](https://github.com/INN/largo/issues/1781). +- Removes the Largo Staff Roster Widget. [Pull request #1763](https://github.com/INN/largo/pull/1763/) for [issue #1505](https://github.com/INN/largo/issues/1505). +- Removes the `[roster]` shortcode that can be used to output a list of staff. [Pull request #1763](https://github.com/INN/largo/pull/1763/) for [issue #1505](https://github.com/INN/largo/issues/1505). +- Deprecates the functions `largo_render_user_list` and `largo_render_staff_list_shortcode`. [Pull request #1763](https://github.com/INN/largo/pull/1763/) for [issue #1505](https://github.com/INN/largo/issues/1505). ## [Largo 0.6.4](https://github.com/INN/largo/compare/v0.6.3...v0.6.4) From 44d951d741a358c4adb28d8fdb8c50ad87ed6086 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 11 Mar 2020 18:57:37 -0400 Subject: [PATCH 7/8] Remove some tests for the now-deprecated staff roster --- tests/inc/test-users.php | 145 --------------------------------------- 1 file changed, 145 deletions(-) diff --git a/tests/inc/test-users.php b/tests/inc/test-users.php index 9afb06192..6c21a3a8c 100644 --- a/tests/inc/test-users.php +++ b/tests/inc/test-users.php @@ -27,148 +27,6 @@ function test_largo_edit_permission_check() { $this->markTestIncomplete('This test has not been implemented yet.'); } - function test_largo_get_user_list() { - /** - * With no arguments, `largo_get_user_list` should get a list of all authors for the current blog; - */ - $result = largo_get_user_list(); - $ids = array_map(function($user) { return $user->ID; }, $result); - - $this->assertEquals(count($ids), count($this->author_user_ids)); - - // Make sure all of the ids in the list returned by `largo_get_user_list` are the same as - // those in $this->author_user_ids - $not_present = array(); - foreach ($ids as $id) { - if (!in_array($id, $this->author_user_ids)) - $not_present[] = $id; - } - $this->assertEmpty($not_present); - - unset($result); - unset($ids); - - /** - * When we specify a role, we should get back only users with that role. - */ - $result = largo_get_user_list(array('roles' => array('contributor'))); - $ids = array_map(function($user) { return $user->ID; }, $result); - - $this->assertEquals(count($ids), count($this->contributor_user_ids)); - - // Make sure all of the ids in the list returned by `largo_get_user_list` are the same as - // those in $this->contribut_user_ids - $not_present = array(); - foreach ($ids as $id) { - if (!in_array($id, $this->contributor_user_ids)) - $not_present[] = $id; - } - $this->assertEmpty($not_present); - - unset($result); - unset($ids); - - /** - * When we specify multiple roles, we should get back a list of users with any of the roles specified. - */ - $result = largo_get_user_list(array('roles' => array('contributor', 'author'))); - $ids = array_map(function($user) { return $user->ID; }, $result); - - $this->assertEquals(count($ids), count($this->contributor_user_ids) + count($this->author_user_ids)); - - // Make sure all of the ids in the list returned by `largo_get_user_list` are the same as - // those in $this->contributor_user_ids and $this->author_user_ids - $not_present = array(); - foreach ($ids as $id) { - if (!in_array($id, $this->contributor_user_ids) && !in_array($id, $this->author_user_ids)) - $not_present[] = $id; - } - $this->assertEmpty($not_present); - - unset($result); - unset($ids); - } - - /** - * Test the function largo_render_user_list - * - * Be aware: This may fail if partials/author-bio-description.php changes. - */ - function test_largo_render_user_list() { - /* - * Test that a user without a description gets no output - */ - $user1 = $this->factory->user->create(); - $arg1[] = get_user_by('id', $user1); - - ob_start(); - largo_render_user_list($arg1); - $out1 = ob_get_clean(); - $this->assertEquals('
', $out1); - - /* - * Test that a user with a description gets output - */ - $user2 = $this->factory->user->create(); - update_user_meta($user2, 'description', 'foobar'); - $arg2[] = get_user_by('id', $user2); - - ob_start(); - largo_render_user_list($arg2); - $out2 = ob_get_clean(); - $this->assertRegExp('/author-box/', $out2); - $this->assertRegExp('/foobar/', $out2); - - /* - * Test that a user with an avatar has output including the avatar - */ - $user3 = $this->factory->user->create(); - $attachment = $this->factory->post->create(array('post_type' => 'attachment')); - update_user_meta($user3, 'description', 'foobar'); - update_user_meta($user3, 'largo_avatar', $attachment); - $arg3[] = get_user_by('id', $user3); - - ob_start(); - largo_render_user_list($arg3); - $out3 = ob_get_clean(); - $this->assertRegExp('/author-box/', $out3); - $this->assertRegExp('/foobar/', $out3); - $this->assertRegExp('/src/', $out3); - - /* - * Test it with all the users - */ - $arg4[] = get_user_by('id', $user1); - $arg4[] = get_user_by('id', $user2); - $arg4[] = get_user_by('id', $user3); - - ob_start(); - largo_render_user_list($arg4); - $out4 = ob_get_clean(); - - $this->assertEquals( 2, preg_match_all('/author-box/', $out4, $matches), "There were not 2 authors with descriptions rendered."); - $this->assertEquals( 1, preg_match_all('/src=/', $out4, $matches), "There was not 1 author with an avatar image rendered."); - - /* - * Test it with a user that is set to hide. - */ - $user4 = $this->factory->user->create(); - $att4 = $this->factory->post->create(array('post_type' => 'attachment')); - update_user_meta($user4, 'description', 'foobar'); - update_user_meta($user4, 'hide', 'on'); - update_user_meta($user4, 'largo_avatar', $att4); - $arg4[] = get_user_by('id', $user4); - - ob_start(); - largo_render_user_list($arg4); - $out5 = ob_get_clean(); - - // Using same numbers here because the hidden user should not change these numbers. - $this->assertEquals( 2, preg_match_all('/author-box/', $out5, $matches), "There were not 2 authors with descriptions rendered."); - $this->assertEquals( 1, preg_match_all('/src=/', $out5, $matches), "There was not 1 author with an avatar image rendered."); - - } - function test_more_profile_info() { $vars = $this->_more_profile_info_setup(); @@ -197,7 +55,6 @@ function test_save_more_profile_info() { save_more_profile_info($user_id); - $this->assertEquals($hide, get_user_meta($user_id, "hide", true)); $this->assertEquals($job_title, get_user_meta($user_id, "job_title", true)); } @@ -207,14 +64,12 @@ function _more_profile_info_setup() { $args = array( 'job_title' => 'Test Job Title', - 'hide' => 'on', 'show_email' => 'on' ); extract($args); $_POST = array_merge($_POST, array( - 'hide' => $hide, 'job_title' => $job_title, 'show_email' => $show_email )); From 16d6bf7b409f8ef14eccdf23af8bcd8a4a6b656f Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 11 Mar 2020 19:11:39 -0400 Subject: [PATCH 8/8] Update descriptions of deprecated functions to remove references to INN/staff --- inc/deprecated.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/inc/deprecated.php b/inc/deprecated.php index 83f1e7e4c..a29be771c 100644 --- a/inc/deprecated.php +++ b/inc/deprecated.php @@ -58,11 +58,9 @@ function largo_fb_user_is_followable( $username = '' ) { /** * Former shortcode version of `largo_render_user_list` * - * This function has been superceded by the corresponding shortcode in - * https://github.com/INN/staff - * * @param $atts array The attributes of the shortcode. * @since 0.4 + * @deprecated 0.7 * @link https://github.com/INN/staff * @link https://github.com/INN/largo/issues/1505 */ @@ -73,12 +71,10 @@ function largo_render_staff_list_shortcode($atts=array()) { /** * Formerly, a list of user profiles based on the array of users passed * - * This function has been superceded by the corresponding shortcode in - * https://github.com/INN/staff - * * @param $users array The WP_User objects to use in rendering the list. * @param $show_users_with_empty_desc bool Whether we should skip users that have no bio/description. * @since 0.4 + * @deprecated 0.7 * @link https://github.com/INN/staff * @link https://github.com/INN/largo/issues/1505 */