diff --git a/includes/class-creativecommons-image.php b/includes/class-creativecommons-image.php index ea65d6f..366dc3c 100644 --- a/includes/class-creativecommons-image.php +++ b/includes/class-creativecommons-image.php @@ -429,7 +429,7 @@ public function license_block( $att_id, $fallback_title = null ) { $meta = wp_get_attachment_metadata( $att_id, true ); $credit = get_post_meta( $att_id, 'attribution_name', true ); if ( ( ! $credit ) - && isset( $image_metadata['credit'] ) + && isset( $meta['credit'] ) ) { $credit = $meta['image_meta']['credit']; } diff --git a/includes/class-creativecommons.php b/includes/class-creativecommons.php index bfaca5b..1880511 100644 --- a/includes/class-creativecommons.php +++ b/includes/class-creativecommons.php @@ -8,7 +8,7 @@ class CreativeCommons { // Make sure the plugin header has the same version number. - const VERSION = '2019.12.2'; + const VERSION = '2020.1.1'; /** * Plugin URL. @@ -77,63 +77,9 @@ public function init() { add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_action( 'admin_init', array( $this, 'page_init' ) ); - /* - * Selecting a license for individual posts or pages is only - * possible if the settings of the site allow it - * by default it does allow it. - */ - if ( $this->allow_content_override_site_license() ) { - add_action( - 'post_submitbox_misc_actions', - array( &$this, 'post_page_license_settings_html' ) - ); - add_action( - 'page_submitbox_misc_actions', - array( &$this, 'post_page_license_settings_html' ) - ); - add_action( - 'save_post', - array( &$this, 'save_license' ) - ); - } - - /* - * Selecting a license as a user for all your content is only - * possible if the settings of the site allow it, - * by default it will allow it. - */ - if ( $this->allow_user_override_site_license() ) { - add_action( - 'personal_options', - array( &$this, 'user_license_settings_html' ) - ); - add_action( - 'personal_options_update', - array( &$this, 'save_license' ) - ); - } - // Adds CC License widget to display the license. add_action( 'widgets_init', array( &$this, 'license_as_widget' ) ); - /* - * if the plugin is installed in multisite environment allow to set - * the options for all sites as default from the network options - */ - if ( is_multisite() ) { - add_action( - 'wpmu_options', - array( &$this, 'network_license_settings_html' ), - 10, - 0 - ); - add_action( - 'update_wpmu_options', - array( &$this, 'save_license' ), - 10, - 0 - ); - } } @@ -194,15 +140,6 @@ public function page_init() { 'license-chooser', array( 'label_for' => 'license_current' ) ); - - add_settings_field( - 'license', - '', - array( &$this, 'setting_license_field' ), - 'cc-admin', - 'license-section' - ); - add_settings_field( 'additional_attribution_txt', __( @@ -238,30 +175,6 @@ public function page_init() { 'license-attribution-settings', array( 'label_for' => 'display_as' ) ); - - add_settings_field( - 'allow_user_override', - __( - 'Allow users to override site‑wide license', - 'CreativeCommons' - ), - array( &$this, 'setting_user_override_license_field' ), - 'cc-admin', - 'license-section', - array( 'label_for' => 'allow_user_override' ) - ); - - add_settings_field( - 'allow_content_override', - __( - 'Allow a different license per post/page', - 'CreativeCommons' - ), - array( &$this, 'setting_content_override_license_field' ), - 'cc-admin', - 'license-section', - array( 'label_for' => 'allow_content_override' ) - ); } @@ -409,15 +322,6 @@ public function settings_license_section() { ); } - - /** - * Funtion: setting_license_field - */ - public function setting_license_field() { - $this->select_license_html( $location = 'site', $echo = true ); - } - - /** * Displays a preview of current selected license. Used in 'license-chooser' settings section. */ @@ -473,41 +377,7 @@ public function display_license_as() { get_license( $location = 'site' ); - $checked = ( array_key_exists( 'user_override_license', $license ) ) - ? checked( $license['user_override_license'], 'true', false ) - : ''; - echo ""; - } - - - /** - * Function: setting_content_override_license_field - * only used once in site admin - * - * @return void - */ - public function setting_content_override_license_field() { - $license = $this->get_license( $location = 'site' ); - $checked = ( array_key_exists( 'content_override_license', $license ) ) - ? checked( - $license['content_override_license'], - 'true', - false - ) - : ''; - echo ""; - } - - + /** * Check if a site may override the network license. * @@ -537,51 +407,6 @@ public function allow_site_override_network_license() { } - /** - * Function: allow_user_override_site_license - * - * @return bool - */ - public function allow_user_override_site_license() { - if ( is_multisite() - && ! $this->allow_site_override_network_license() - ) { - return false; - } else { - $license = $this->get_license( $location = 'site' ); - if ( array_key_exists( 'user_override_license', $license ) - && 'true' == $license['user_override_license'] - ) { - return true; - } else { - return false; - } - } - } - - - /** - * Function: allow_content_override_site_license - * - * @return bool - */ - public function allow_content_override_site_license() { - if ( is_multisite() - && ! $this->allow_site_override_network_license() - ) { - return false; - } else { - $license = $this->get_license( $location = 'site' ); - if ( array_key_exists( 'content_override_license', $license ) - && 'true' == $license['content_override_license'] - ) { - return true; - } else { - return false; - } - } - } - /** * Set a default license. * @@ -682,33 +507,6 @@ public function get_license( $location = null ) { $this->_logger( 'get license: multisite' ); $license = $this->get_license( 'network' ); $this->_logger( 'got network license' ); - if ( $this->allow_site_override_network_license() ) { - $this->_logger( 'site may override network license' ); - $license = $this->get_license( 'site' ); - // keep track of site license cause we need to check it twice. - $site_license = $license; - $this->_logger( 'got site license' ); - if ( array_key_exists( - 'user_override_license', - $site_license - ) - && 'true' == $site_license['user_override_license'] - ) { - $this->_logger( 'user may override license' ); - $license = $this->get_license( 'profile' ); - $this->_logger( 'got user license' ); - } - if ( array_key_exists( - 'content_override_license', - $site_license - ) - && 'true' == $site_license['content_override_license'] - ) { - $this->_logger( 'content may override license' ); - $license = $this->get_license( 'post-page' ); - $this->_logger( 'got content license' ); - } - } } else { $license = $this->get_license( 'site' ); if ( array_key_exists( 'user_override_license', $license ) @@ -799,18 +597,7 @@ public function get_attribution_options( $location ) { break; default: - if ( $this->allow_user_override_site_license() ) { - $attribution_options = array( - 'display_name' => __( - 'The author display name', - 'CreativeCommons' - ), - 'other' => __( - 'Something completely differrent', - 'CreativeCommons' - ), - ); - } + break; } @@ -899,50 +686,6 @@ public function display_settings_warning( $echo = false ) { } } - - /** - * Renders the license settings WordPress Network Settings page - * - * Using the settings rendered by this function a superadmin may set a - * default license for the WordPress Network. This will be used for all - * sites. If the superadmin allows it, siteadmins may change their - * site's license and choose a different license than the default - * Network license. - * - * Called by wpmu_options action - **/ - public function network_license_settings_html() { - /* - * Get the previously selected license from the network options or - * the plugin's default license - * $license = get_site_option('license', $this->plugin_default_license()); - */ - $location = 'network'; - $license = $this->get_license( $location ); - - $html = ''; - $html .= '
| \n"; - $html .= "\t | "; - $html .= " | \n"; - $html .= "
|---|
'; - $html .= $this->select_license_html( $location, $echo = false ); - $html .= '
'; - - $html .= '' . __( 'Set attribution to', 'CreativeCommons' ) . ''; - - $html .= ''; - $html .= $this->select_attribute_to_html( $location, $echo = false ); - $html .= '
'; - $html .= '