Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
Merge pull request #129 from creativecommons/fix-multisite-issue
Browse files Browse the repository at this point in the history
fix multisite issue retrieving license information
  • Loading branch information
hugosolar authored Sep 4, 2020
2 parents ae520c0 + 2fbee3e commit 411c068
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions includes/class-creativecommons.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ public function get_license( $location = null ) {
$this->_logger( 'called network' );
$license = ( $network_license = get_site_option( 'license' ) )
? $network_license : $this->plugin_default_license();

break;

case 'site':
Expand Down Expand Up @@ -525,22 +526,16 @@ public function get_license( $location = null ) {
// since this can cause way too many calls for the right license.
case 'frontend':
$this->_logger( 'get license for the frontend' );
if ( is_multisite() ) {
$this->_logger( 'get license: multisite' );
$license = $this->get_license( 'network' );
$this->_logger( 'got network license' );
} else {
$license = $this->get_license( 'site' );
if ( array_key_exists( 'user_override_license', $license )
&& 'true' == $license['user_override_license']
) {
$license = $this->get_license( 'profile' );
}
if ( array_key_exists( 'content_override_license', $license )
&& 'true' == $license['content_override_license']
) {
$license = $this->get_license( 'post-page' );
}
$license = $this->get_license( 'site' );
if ( array_key_exists( 'user_override_license', $license )
&& 'true' == $license['user_override_license']
) {
$license = $this->get_license( 'profile' );
}
if ( array_key_exists( 'content_override_license', $license )
&& 'true' == $license['content_override_license']
) {
$license = $this->get_license( 'post-page' );
}
break;
}
Expand Down Expand Up @@ -769,7 +764,6 @@ private function _verify_license_data( $from, $data = null ) {
) {
$data = sanitize_text_field( wp_unslash( $_POST['license'] ) );
}

// Saves the license attribution information. MAke sure to save the current version.
$license['version'] = self::VERSION;
$license['attribute_to'] = ( isset( $data['attribute_to'] ) ) ? esc_attr( $data['attribute_to'] ) : '';
Expand Down Expand Up @@ -1061,7 +1055,6 @@ public function print_license_html( $location = 'frontend', $echo = true ) {
* Add a filter to include the license with the excerpt & content
* filter allow an option to switch this off
*/

$license = $this->get_license( $location );
$html = '';
if ( is_array( $license ) && count( $license ) > 0 ) {
Expand Down

0 comments on commit 411c068

Please sign in to comment.