function bccl_license_text_hyperlink() { echo bccl_add_placeholders(bccl_get_license_text_hyperlink()); }
/** * This function should not be used in template tags. * * $work: The work that is licensed can be defined by the user. * $show_button: (default, yes, no) - no explanation (TODO possibly define icon URL) * $button: The user can se the desired button (hidden feature): "0", "1", "2" * */ function bccl_get_license_block( $work='', $css_class='', $show_button='default', $button='default' ) { global $post; $cc_block = "LICENSE BLOCK ERROR"; $cc_settings = get_option("cc_settings"); // If there is no global license, stop here // Since this may be called from the templates, we perform this check here once again. if ( empty($cc_settings['license_url']) ) { return ''; } // Set CSS class if (empty($css_class)) { $css_class = 'cc-block'; } // Get content specific license from the custom field $bccl_license = get_post_meta( $post->ID, '_bccl_license', true ); if ( empty( $bccl_license ) ) { // Set to default $bccl_license = 'default'; } // DEFAULT LICENSE // If no custom license has been set for this content if ( $bccl_license == 'default' ) { // License button inclusion $button_code = ''; if ($show_button == "default") { if ($cc_settings["cc_body_img"]) { $button_code = bccl_get_license_image_hyperlink($button) . "<br />"; } } elseif ($show_button == "yes") { $button_code = bccl_get_license_image_hyperlink($button) . "<br />"; } elseif ($show_button == "no") { $button_code = ""; } else { $button_code = "ERROR"; } // Work analysis if ( empty($work) ) { // Proceed only if the user has not defined the work. if ( $cc_settings["cc_extended"] == '1' ) { $creator = bccl_get_the_creator($cc_settings["cc_creator"]); $author_archive_url = get_author_posts_url( get_the_author_meta( 'ID' ) ); $work = "<em><a href=\"" . get_permalink() . "\">" . get_the_title() . "</a></em>"; $by = "<em><a href=\"" . $author_archive_url . "\">" . $creator . "</a></em>"; $work = sprintf("%s %s %s", $work, __("by", 'cc-configurator'), $by); } else { $work = __('This work', 'cc-configurator'); } } $work .= sprintf(", ".__('unless otherwise expressly stated', 'cc-configurator').", ".__('is licensed under a', 'cc-configurator')." %s.", bccl_get_license_text_hyperlink()); // Additional Permissions if ( ! empty( $cc_settings["cc_perm_url"] ) ) { $additional_perms = " ".__('Terms and conditions beyond the scope of this license may be available at', 'cc-configurator')." <a href=\"" . $cc_settings["cc_perm_url"] . "\">" . $_SERVER["HTTP_HOST"] . "</a>."; } else { $additional_perms = ""; } $license_text = $work . $additional_perms; // Derivatives // @see: http://wiki.creativecommons.org/Best_practices_for_attribution if ( ! empty($cc_settings['cc_derivative']) && "1" == $cc_settings['cc_derivative'] ) { $orig_title = (empty( $cc_settings['cc_derivative_orig_title'] )) ? '' : 'of <cite>' . $cc_settings['cc_derivative_orig_title'] . '</cite>'; // hyperlink if both aren't empty $orig_title = ( ! empty( $orig_title ) && ! empty( $cc_settings['cc_derivative_orig_src'] )) ? 'of <cite><a href="' . $cc_settings['cc_derivative_orig_src'] . '">' . $cc_settings['cc_derivative_orig_title'] . '</a></cite>' : $orig_title; $orig_author = (empty( $cc_settings['cc_derivative_orig_author'] )) ? '' : 'by ' . $cc_settings['cc_derivative_orig_author']; $orig_license = (empty( $cc_settings['cc_derivative_orig_lic'] )) ? '' : 'used under ' . $cc_settings['cc_derivative_orig_lic']; $derivative_text = sprintf( 'This is a derivative %s %s %s. ', $orig_title, $orig_author, $orig_license ); $license_text = $derivative_text . $license_text; } // $pre_text = 'Copyright © ' . get_the_date('Y') . ' - Some Rights Reserved' . '<br />'; $license_text = apply_filters( 'bccl_cc_license_text', $license_text ); $cc_block = sprintf( "<p class=\"%s\">%s%s</p>", $css_class, $button_code, $license_text ); } // CC0 elseif ( $bccl_license == 'cc0' ) { $license = bccl_get_license( 'cc0' ); // License button inclusion $button_code = ''; if ( $cc_settings["cc_body_img"] == '1' ) { if (is_ssl()) { $license['button_url'] = str_replace('http://', 'https://', $license['button_url']); } $button_code = sprintf( "<a rel=\"license\" href=\"%s\"><img alt=\"%s\" src=\"%s\" class=\"cc-button\" /></a><br />", $license['url'], 'CC0', $license['button_url'] ); } if ( $cc_settings["cc_extended"] == '1' ) { $creator = bccl_get_the_creator($cc_settings["cc_creator"]); $author_archive_url = get_author_posts_url( get_the_author_meta( 'ID' ) ); $creator_link = "<em><a href=\"" . $author_archive_url . "\">" . $creator . "</a></em>"; $work_link = "<em><a href=\"" . get_permalink() . "\">" . get_the_title() . "</a></em>"; $license_text = sprintf( $license['extended_text'], $creator_link, $work_link ); } else { $license_text = $license['text']; } $license_text = apply_filters( 'bccl_cc0_license_text', $license_text ); $cc_block = sprintf("<p class=\"%s\">%s%s</p>", $css_class, $button_code, $license_text); } // ARR elseif ( $bccl_license == 'arr' ) { $license = bccl_get_license( 'arr' ); $license_text = sprintf( $license['text'], get_the_date('Y') ); // Additional Permissions if ( ! empty( $cc_settings["cc_perm_url"] ) ) { $additional_perms = $license['additional_perms_text'] . " <a href=\"" . $cc_settings["cc_perm_url"] . "\">" . $cc_settings["cc_perm_url"] . "</a>."; } else { $additional_perms = ""; } $license_text = $license_text . $additional_perms; $license_text = apply_filters( 'bccl_arr_license_text', $license_text ); $cc_block = sprintf( "<p class=\"%s\">%s</p>", $css_class, $license_text ); } // NO LICENSE elseif ( $bccl_license == 'manual' ) { $cc_block = ''; } return $cc_block; }