Skip to content

Commit

Permalink
Merge branch 'hotfix/0.17.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanDS committed Oct 30, 2019
2 parents fe673fa + d28b944 commit 4958372
Show file tree
Hide file tree
Showing 16 changed files with 496 additions and 550 deletions.
6 changes: 5 additions & 1 deletion ssl-alp/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: logbook, coauthor, revisions, references, latex, tex, mathematics, wiki
Requires at least: 5.1.0
Tested up to: 5.2.3
Requires PHP: 7.0.0
Stable tag: 0.17.1
Stable tag: 0.17.2
License: GNU General Public License v3 or later
License URI: LICENCE

Expand Down Expand Up @@ -79,6 +79,10 @@ on the ALP website.

== Changelog ==

= 0.17.2 =
- Fixed bug when rebuilding coauthors on sites with existing posts before ALP
was installed.

= 0.17.1 =
- Fixed bug with children block showing all post types and not just those
sharing the current post's post type.
Expand Down
4 changes: 2 additions & 2 deletions ssl-alp/alp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Academic Labbook
* Plugin URI: https://alp.attackllama.com/
* Description: Turn WordPress into a collaborative academic labbook.
* Version: 0.17.1
* Version: 0.17.2
* Author: Sean Leavey
* Author URI: https://attackllama.com/
* License: GPL3
Expand All @@ -21,7 +21,7 @@
* Current plugin version.
*/

define( 'SSL_ALP_VERSION', '0.17.1' );
define( 'SSL_ALP_VERSION', '0.17.2' );

/**
* Plugin name
Expand Down
75 changes: 0 additions & 75 deletions ssl-alp/blocks/tex/inline.js

This file was deleted.

Empty file removed ssl-alp/css/public.css
Empty file.
42 changes: 27 additions & 15 deletions ssl-alp/includes/class-ssl-alp-authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ class SSL_ALP_Authenticate extends SSL_ALP_Module {
*/
const APPLICATION_PASSWORD_LENGTH = 30;

/**
* Register styles.
*/
public function register_styles() {
if ( get_option( 'ssl_alp_require_login' ) ) {
wp_register_style(
'ssl-alp-login-hide-backlink-css',
esc_url( SSL_ALP_BASE_URL . 'css/login-hide-backlink.css' ),
array(),
$this->get_version()
);
}
}

/**
* Register settings.
*/
Expand Down Expand Up @@ -97,9 +111,6 @@ public function register_hooks() {
// Disable XML-RPC interface.
$loader->add_action( 'xmlrpc_enabled', $this, '__return_false' );

// Remove "Back to [Blog]" from login page if login is required.
$loader->add_action( 'login_enqueue_scripts', $this, 'remove_back_link' );

// Add admin applications page.
$loader->add_action( 'admin_menu', $this, 'add_applications_page' );

Expand All @@ -114,6 +125,19 @@ public function register_hooks() {
$loader->add_action( 'admin_notices', $this, 'print_admin_notices' );
}

/**
* Enqueue styles in the login header.
*/
public function enqueue_login_styles() {
if ( ! get_option( 'ssl_alp_require_login' ) ) {
return;
}

// Remove "Back to [Blog]" from login page if login is required.
// Use CSS to hide it as there is no hook for this link.
wp_enqueue_style( 'ssl-alp-login-hide-backlink-css' );
}

/**
* Prevent caching of unauthenticated status.
*
Expand Down Expand Up @@ -354,18 +378,6 @@ public function get_request_type() {
return 'front-end';
}

/**
* Remove "Back to [Blog]" link from login page if login is required.
*/
public function remove_back_link() {
if ( ! get_option( 'ssl_alp_require_login' ) ) {
return;
}

// Use CSS to hide it as there is no hook for this link.
wp_enqueue_style( 'ssl-alp-login-hide-backlink-css', SSL_ALP_BASE_URL . 'css/login-hide-backlink.css', array(), $this->get_version(), 'all' );
}

/**
* Generate a unique repeateable slug from the application data.
*
Expand Down
91 changes: 47 additions & 44 deletions ssl-alp/includes/class-ssl-alp-coauthors.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@ class SSL_ALP_Coauthors extends SSL_ALP_Module {
*/
protected $having_terms = '';

/**
* Register settings.
*/
public function register_settings() {
register_setting(
SSL_ALP_SITE_SETTINGS_PAGE,
'ssl_alp_allow_multiple_authors',
array(
'type' => 'boolean',
)
);
}

/**
* Register settings fields.
*/
public function register_settings_fields() {
/**
* Post multiple author settings field.
*/
add_settings_field(
'ssl_alp_author_settings',
__( 'Authors', 'ssl-alp' ),
array( $this, 'author_settings_callback' ),
SSL_ALP_SITE_SETTINGS_PAGE,
'ssl_alp_post_settings_section'
);
}

/**
* Register hooks.
*/
Expand Down Expand Up @@ -141,35 +170,6 @@ public function register_hooks() {
$loader->add_action( 'widgets_init', $this, 'register_users_widget' );
}

/**
* Register settings.
*/
public function register_settings() {
register_setting(
SSL_ALP_SITE_SETTINGS_PAGE,
'ssl_alp_allow_multiple_authors',
array(
'type' => 'boolean',
)
);
}

/**
* Register settings fields.
*/
public function register_settings_fields() {
/**
* Post multiple author settings field.
*/
add_settings_field(
'ssl_alp_author_settings',
__( 'Authors', 'ssl-alp' ),
array( $this, 'author_settings_callback' ),
SSL_ALP_SITE_SETTINGS_PAGE,
'ssl_alp_post_settings_section'
);
}

/**
* Author settings partial.
*/
Expand Down Expand Up @@ -457,22 +457,25 @@ public function rebuild_coauthors() {
foreach ( $users as $user ) {
// Add coauthor terms.
$this->add_coauthor_term( $user->ID );
}

// Get all of the user's posts.
$posts = get_posts(
array(
'post_author' => $user->ID,
'post_type' => $this->supported_post_types,
'post_status' => 'any',
'numberposts' => -1,
)
);
// Get all posts.
$posts = get_posts(
array(
'post_type' => $this->supported_post_types,
'post_status' => get_post_stati(),
'numberposts' => -1,
)
);

// Set coauthor terms on each of the user's posts.
foreach ( $posts as $post ) {
$coauthors = $this->get_coauthors( $post );
$this->set_coauthors( $post, $coauthors );
}
// Set coauthor terms on each of the posts. The get_coauthors() function will return at a
// minimum the existing post author if no additional coauthors are tagged against the post,
// which is the case for sites with existing posts and users before this plugin is enabled;
// therefore, this loop effectively populates the coauthor term taxonomy relationships to
// each post.
foreach ( $posts as $post ) {
$coauthors = $this->get_coauthors( $post );
$this->set_coauthors( $post, $coauthors );
}
}

Expand Down Expand Up @@ -1157,7 +1160,7 @@ public function get_coauthors( $post = null ) {
}

// Get the post's primary author.
$post_author = get_user_by( 'id', $post->post_author );
$post_author = get_user_by( 'ID', $post->post_author );

// Try to ensure at least the post's primary author is in the list of coauthors.
if ( ! empty( $post_author ) && ! in_array( $post_author, $coauthors, false ) ) { // Fuzzy comparison required.
Expand Down
Loading

0 comments on commit 4958372

Please sign in to comment.