Choose the author for this blog
+ '',
+ 'orderby' => 'display_name',
+ 'order' => 'ASC',
+ 'multi' => true,
+ 'show' => 'display_name',
+ 'name' => 'user',
+ 'selected' => $current_user->ID,
+ 'id' => 'user',
+ 'class' => '',
+ 'blog_id' => $GLOBALS['blog_id'],
);
-
- wp_dropdown_users( $args ); ?>
';
-
- return $context . $result;
+function openattribute_button( $context ) {
+
+ $icon_url = WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . 'openatt.png';
+
+ $string = get_permalink();
+
+ $result = '
';
+
+ return $context . $result;
}
function openattribute_register() {
- update_option('openattribute_licenses', "http://creativecommons.org/licenses/by/3.0,Creative Commons Attribution CC BY 3.0\nhttp://creativecommons.org/licenses/by-nd/3.0,Creative Commons Attribution-NoDerivatives CC BY-ND 3.0\nhttp://creativecommons.org/licenses/by-nc-sa/3.0,Creative Commons Attribution-NonCommercial-ShareAlike CC BY-NC-SA 3.0 \nhttp://creativecommons.org/licenses/by-sa/3.0,Creative Commons Attribution-ShareAlike CC BY-SA 3.0\nhttp://creativecommons.org/licenses/by-nc/3.0,Creative Commons Attribution-NonCommercial CC BY-NC 3.0\nhttp://creativecommons.org/licenses/by-nc-nd/3.0,Creative Commons Attribution-NonCommercial-NoDerivatives CC BY-NC-ND 3.0\nhttps://creativecommons.org/publicdomain/zero/1.0/,Creative Commons Public Domain Dedication\nhttp://creativecommons.org/licenses/by/4.0,Creative Commons Attribution CC BY 4.0\nhttp://creativecommons.org/licenses/by-nd/4.0,Creative Commons Attribution-NoDerivatives CC BY-ND 4.0\nhttp://creativecommons.org/licenses/by-nc-sa/4.0,Creative Commons Attribution-NonCommercial-ShareAlike CC BY-NC-SA 4.0 \nhttp://creativecommons.org/licenses/by-sa/4.0,Creative Commons Attribution-ShareAlike CC BY-SA 4.0\nhttp://creativecommons.org/licenses/by-nc/4.0,Creative Commons Attribution-NonCommercial CC BY-NC 4.0\nhttp://creativecommons.org/licenses/by-nc-nd/4.0,Creative Commons Attribution-NonCommercial-NoDerivatives CC BY-NC-ND 4.0\n");
- add_option('openattribute_firstrun', 1);
- add_option('openattribute_rss', 1);
- add_option('openattribute_blogoverride', 1);
- add_option('openattribute_buttonset', 1);
- add_option('openattribute_linkset', 1);
- add_option('openattribute_widgetset', 1);
- add_option('openattribute_rdfa', 1);
- add_option('openattribute_disable', 1);
- add_option('openattribute_site_license', '');
- add_option('openattribute_site_author', '');
- add_option('openattribute_site_attribution_url', '');
- add_option('openattribute_append_content', '1');
- add_option('openattribute_append_footer', '1');
- add_option('openattribute_pre_license_html', '
');
- add_option('openattribute_authoroverride','');
- add_option('openattribute_index',0);
- add_option('openattribute_indexsingle',0);
- add_option('openattribute_postsonly',0);
- add_option('openattribute_postsonly',0);
-
+ update_option( 'openattribute_licenses', "http://creativecommons.org/licenses/by/3.0,Creative Commons Attribution CC BY 3.0\nhttp://creativecommons.org/licenses/by-nd/3.0,Creative Commons Attribution-NoDerivatives CC BY-ND 3.0\nhttp://creativecommons.org/licenses/by-nc-sa/3.0,Creative Commons Attribution-NonCommercial-ShareAlike CC BY-NC-SA 3.0 \nhttp://creativecommons.org/licenses/by-sa/3.0,Creative Commons Attribution-ShareAlike CC BY-SA 3.0\nhttp://creativecommons.org/licenses/by-nc/3.0,Creative Commons Attribution-NonCommercial CC BY-NC 3.0\nhttp://creativecommons.org/licenses/by-nc-nd/3.0,Creative Commons Attribution-NonCommercial-NoDerivatives CC BY-NC-ND 3.0\nhttps://creativecommons.org/publicdomain/zero/1.0/,Creative Commons Public Domain Dedication\nhttp://creativecommons.org/licenses/by/4.0,Creative Commons Attribution CC BY 4.0\nhttp://creativecommons.org/licenses/by-nd/4.0,Creative Commons Attribution-NoDerivatives CC BY-ND 4.0\nhttp://creativecommons.org/licenses/by-nc-sa/4.0,Creative Commons Attribution-NonCommercial-ShareAlike CC BY-NC-SA 4.0 \nhttp://creativecommons.org/licenses/by-sa/4.0,Creative Commons Attribution-ShareAlike CC BY-SA 4.0\nhttp://creativecommons.org/licenses/by-nc/4.0,Creative Commons Attribution-NonCommercial CC BY-NC 4.0\nhttp://creativecommons.org/licenses/by-nc-nd/4.0,Creative Commons Attribution-NonCommercial-NoDerivatives CC BY-NC-ND 4.0\n" );
+ add_option( 'openattribute_firstrun', 1 );
+ add_option( 'openattribute_rss', 1 );
+ add_option( 'openattribute_blogoverride', 1 );
+ add_option( 'openattribute_buttonset', 1 );
+ add_option( 'openattribute_linkset', 1 );
+ add_option( 'openattribute_widgetset', 1 );
+ add_option( 'openattribute_rdfa', 1 );
+ add_option( 'openattribute_disable', 1 );
+ add_option( 'openattribute_site_license', '' );
+ add_option( 'openattribute_site_author', '' );
+ add_option( 'openattribute_site_attribution_url', '' );
+ add_option( 'openattribute_append_content', '1' );
+ add_option( 'openattribute_append_footer', '1' );
+ add_option( 'openattribute_pre_license_html', '
' );
+ add_option( 'openattribute_authoroverride', '' );
+ add_option( 'openattribute_index', 0 );
+ add_option( 'openattribute_indexsingle', 0 );
+ add_option( 'openattribute_postsonly', 0 );
+ add_option( 'openattribute_postsonly', 0 );
+
}
function openattribute_options_page() {
- ?>
-
+ ?>
+
Open Attribute
-
OpenAttribute is a Wordpress plugin designed to allow users to add reuse licenses into their WordPress sites.
+
OpenAttribute is a WordPress plugin designed to allow users to add reuse licenses into their WordPress sites.
Built to allow users to be as flexible as possible with their licenses, OpenAttribute allows you to attribute your entire site or attribute each post / page individually if required.
On this control panel options for licensing are therefore divided between per page / post and per site options. You can also add any licenses you would like to be able to use
This control panel also has plugin settings to control features such as RSS and attribution buttons
-
-
- ";
-
+ } else {
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
+ return $post_id;
}
-
+ }
+
+ if ( isset( $_POST['disable_license'] ) && 'on' === $_POST['disable_license'] ) {
+ update_post_meta( $post_id, 'disable_license', 'on' );
+ } else {
+ update_post_meta( $post_id, 'disable_license', 'off' );
+ }
}
-function openattribute_add_disable_menu($output){
+function openattribute_disable_menu() {
+ $disable_license = null;
- if(get_option('openattribute_disable')==1){
-
- add_meta_box( 'openattribute_id', 'OpenAttribute',"openattribute_disable_menu","post","normal","high");
-
- }
-
- $meta = get_post_meta($_GET['post'], 'disable_license');
-
- if($meta[0]=="on"){
-
- add_meta_box( 'openattribute_id', 'OpenAttribute',"openattribute_disable_menu","post","normal","high");
-
- }
-
+ wp_nonce_field( plugin_basename( __FILE__ ), 'openattribute_noncename' );
+
+ if ( isset( $_GET['post'] ) ) {
+ $disable_license = get_post_meta( $_GET['post'], 'disable_license', true );
+ }
+
+ if ( 'on' === $disable_license ) {
+ $checked = 'checked';
+ } else {
+ $checked = '';
+ }
+
+ if ( ( 1 == get_option( 'openattribute_disable' ) ) || ( 'on' === $disable_license ) ) {
+ echo "To disable attribution for this post please tick this box
";
+ }
}
-function openattribute_add_license_content($output){
+function openattribute_add_disable_menu( $output ) {
+ $disable_license = null;
+
+ if ( get_option( 'openattribute_disable' ) == 1 ) {
+ add_meta_box( 'openattribute_id', 'OpenAttribute', 'openattribute_disable_menu', 'post', 'normal', 'high' );
+ }
+ if ( isset( $_GET['post'] ) ) {
+ $disable_license = get_post_meta( $_GET['post'], 'disable_license', true );
+ }
+
+ if ( 'on' === $disable_license ) {
+ add_meta_box( 'openattribute_id', 'OpenAttribute', 'openattribute_disable_menu', 'post', 'normal', 'high' );
+ }
+}
+
+function openattribute_add_license_content( $output ) {
global $wp_query, $post;
-
global $wp_query,$post;
-
- $indexposts = get_option('openattribute_index');
- $indexsingle = get_option('openattribute_indexsingle');
- $postsonly = get_option('openattribute_postsonly');
-
+
+ $indexposts = get_option( 'openattribute_index' );
+ $indexsingle = get_option( 'openattribute_indexsingle' );
+ $postsonly = get_option( 'openattribute_postsonly' );
+
+ $site_license_url = '';
+
$display_first = false;
-
- if(is_home()&&$indexposts){
-
- if(is_single()){
-
+
+ if ( is_home() && $indexposts ) {
+ if ( is_single() ) {
$display_first = true;
-
- }else if($indexsingle){
-
+ } elseif ( $indexsingle ) {
$display_first = true;
-
}
-
- }else if(is_page()&&$postsonly){
-
+ } elseif ( is_page() && $postsonly ) {
$display_first = true;
-
- }else if(is_single()){
-
+ } elseif ( is_single() ) {
$display_first = true;
-
}
-
- if($display_first){
-
- if(get_option('openattribute_append_content')==1){
-
- $disable = get_post_meta($wp_query->posts[0]->ID, 'disable_license');
-
- if($disable[0]=="off"||$disable[0]==""){
-
+
+ if ( $display_first ) {
+ if ( get_option( 'openattribute_append_content' ) == 1 ) {
+ $disable = get_post_meta( $wp_query->posts[0]->ID, 'disable_license' );
+
+ if ( $disable[0] == 'off' || $disable[0] == '' ) {
$display = true;
-
- if(get_option('openattribute_blogoverride')==1){
-
- $author = explode("oaauthor",$output);
- $title = explode("oatitle",$output);
- $oashorthand = explode("oalicense",$output);
-
- if(count($author)!=1){
-
+
+ if ( get_option( 'openattribute_blogoverride' ) == 1 ) {
+ $author = explode( 'oaauthor', $output );
+ $title = explode( 'oatitle', $output );
+ $oashorthand = explode( 'oalicense', $output );
+
+ if ( count( $author ) != 1 ) {
$display = false;
-
}
-
- if(count($title)!=1){
-
+
+ if ( count( $title ) != 1 ) {
$display = false;
-
}
-
- if(count($oashorthand)!=1){
-
+
+ if ( count( $oashorthand ) != 1 ) {
$display = false;
-
}
-
}
-
- if($display_first){
-
- $author = get_option('openattribute_site_author');
- $site_license = get_option('openattribute_site_license');
- $site_attribution_url = get_option('openattribute_site_attribution_url');
- $licenses = get_option('openattribute_licenses');
-
- if(get_option('openattribute_authoroverride')==1){
-
- $author = get_the_author_meta("display_name");
- $site_attribution_url = get_the_author_meta("user_url");
-
+
+ if ( $display_first ) {
+ $author = get_option( 'openattribute_site_author' );
+ $site_license = get_option( 'openattribute_site_license' );
+ $site_attribution_url = get_option( 'openattribute_site_attribution_url' );
+ $licenses = get_option( 'openattribute_licenses' );
+
+ if ( get_option( 'openattribute_authoroverride' ) == 1 ) {
+ $author = get_the_author_meta( 'display_name' );
+ $site_attribution_url = get_the_author_meta( 'user_url' );
}
-
- $data_licenses = explode("\n",$licenses);
-
- while($license = array_shift($data_licenses)){
-
- $pair = explode(",",$license);
-
- if(trim($pair[1])==trim($site_license)){
-
+
+ $data_licenses = explode( "\n", $licenses );
+
+ while ( $license = array_shift( $data_licenses ) ) {
+ $pair = explode( ',', $license );
+
+ if ( isset( $pair[1] ) && trim( $pair[1] ) == trim( $site_license ) ) {
$site_license_url = $pair[0];
-
}
-
}
-
- $license_data .= stripslashes(get_option('openattribute_pre_license_html'));
-
- if(get_option('openattribute_buttonset')==1){
-
- $license_data .= '
';
+ }
+
+ $license_data .= '
' . the_title( '', '', 0 ) . ' / ' . get_bloginfo( 'name' ) . ' ';
+ $license_data .= ' by
' . $author . ' ';
+ $license_data .= ' is licensed under a
' . $site_license . ' ';
+ $license_data .= get_option( 'openattribute_post_license_html' );
+
+ $output .= $license_data;
}
-
}
-
}
-
}
-
+
return $output;
}
-function openattribute_add_license_footer($content){
+function openattribute_add_license_footer( $content ) {
global $wp_query,$post;
-
- $indexposts = get_option('openattribute_index');
- $indexsingle = get_option('openattribute_indexsingle');
- $postsonly = get_option('openattribute_postsonly');
-
+
+ $indexposts = get_option( 'openattribute_index' );
+ $indexsingle = get_option( 'openattribute_indexsingle' );
+ $postsonly = get_option( 'openattribute_postsonly' );
+
$display_first = false;
-
- if(is_home()&&$indexposts){
-
- if(is_single()){
-
+
+ if ( is_home() && $indexposts ) {
+
+ if ( is_single() ) {
+
$display_first = true;
-
- }else if($indexsingle){
-
+
+ } elseif ( $indexsingle ) {
+
$display_first = true;
-
+
}
-
- }else if(is_page()&&$postsonly){
-
+ } elseif ( is_page() && $postsonly ) {
+
$display_first = true;
-
- }else if(is_single()){
-
+
+ } elseif ( is_single() ) {
+
$display_first = true;
-
+
}
-
- if($display_first){
-
- if(get_option('openattribute_append_footer')==1){
-
- $disable = get_post_meta($wp_query->posts[0]->ID, 'disable_license');
-
- if($disable[0]=="off"||$disable[0]==""){
-
+
+ if ( $display_first ) {
+
+ if ( get_option( 'openattribute_append_footer' ) == 1 ) {
+
+ $disable = get_post_meta( $wp_query->posts[0]->ID, 'disable_license' );
+
+ if ( $disable[0] == 'off' || $disable[0] == '' ) {
+
$display = true;
-
- if(get_option('openattribute_blogoverride')==1){
-
+
+ if ( get_option( 'openattribute_blogoverride' ) == 1 ) {
+
$content = $wp_query->posts[0]->post_content;
-
- $author = explode("oaauthor",$content);
- $title = explode("oatitle",$content);
- $oashorthand = explode("oashorthand",$content);
-
- if(count($author)!=1){
-
+
+ $author = explode( 'oaauthor', $content );
+ $title = explode( 'oatitle', $content );
+ $oashorthand = explode( 'oashorthand', $content );
+
+ if ( count( $author ) != 1 ) {
+
$display = false;
-
+
}
-
- if(count($title)!=1){
-
+
+ if ( count( $title ) != 1 ) {
+
$display = false;
-
+
}
-
- if(count($oashorthand)!=1){
-
+
+ if ( count( $oashorthand ) != 1 ) {
+
$display = false;
-
+
}
-
}
-
- if($display){
-
- get_option('openattribute_buttonset');
- $author = get_option('openattribute_site_author');
- $site_license = get_option('openattribute_site_license');
- $site_attribution_url = get_option('openattribute_site_attribution_url');
- $licenses = get_option('openattribute_licenses');
-
- if(get_option('openattribute_authoroverride')==1){
-
- $author = get_the_author_meta("display_name");
- $site_attribution_url = get_the_author_meta("user_url");
-
+
+ if ( $display ) {
+
+ get_option( 'openattribute_buttonset' );
+ $author = get_option( 'openattribute_site_author' );
+ $site_license = get_option( 'openattribute_site_license' );
+ $site_attribution_url = get_option( 'openattribute_site_attribution_url' );
+ $licenses = get_option( 'openattribute_licenses' );
+
+ if ( get_option( 'openattribute_authoroverride' ) == 1 ) {
+
+ $author = get_the_author_meta( 'display_name' );
+ $site_attribution_url = get_the_author_meta( 'user_url' );
+
}
-
- $data_licenses = explode("\n",$licenses);
-
- while($license = array_shift($data_licenses)){
-
- $pair = explode(",",$license);
-
- if(trim($pair[1])==trim($site_license)){
-
+
+ $data_licenses = explode( "\n", $licenses );
+
+ while ( $license = array_shift( $data_licenses ) ) {
+
+ $pair = explode( ',', $license );
+
+ if ( trim( $pair[1] ) == trim( $site_license ) ) {
+
$site_license_url = $pair[0];
-
+
}
-
}
-
- if($display_first){
-
- $license_data .= stripslashes(get_option('openattribute_pre_license_html'));
-
- if(get_option('openattribute_buttonset')==1){
-
- $license_data .= '
';
+
+ }
+
+ $license_data .= '
' . the_title( '', '', 0 ) . ' / ' . get_bloginfo( 'name' ) . ' ';
+ $license_data .= ' by
' . $author . ' ';
+ $license_data .= ' is licensed under a
' . $site_license . ' ';
+ $license_data .= get_option( 'openattribute_post_license_html' );
+
+ $output = $license_data;
+
+ echo $output;
+
+ }
}
-
}
-
}
-
}
}
-function openattribute_add_license_header(){
-
+function openattribute_add_license_header() {
global $post;
- $indexposts = get_option('openattribute_index');
- $indexsingle = get_option('openattribute_indexsingle');
- $postsonly = get_option('openattribute_postsonly');
-
+ $disable = null;
+
+ $indexposts = get_option( 'openattribute_index' );
+ $indexsingle = get_option( 'openattribute_indexsingle' );
+ $postsonly = get_option( 'openattribute_postsonly' );
+
$display_first = false;
-
- if(is_home()&&$indexposts){
-
- if(is_single()){
-
+
+ if ( is_home() && $indexposts ) {
+ if ( is_single() ) {
$display_first = true;
-
- }else if($indexsingle){
-
+ } elseif ( $indexsingle ) {
$display_first = true;
-
}
-
- }else if(is_page()&&$postsonly){
-
+ } elseif ( is_page() && $postsonly ) {
$display_first = true;
-
- }else if(is_single()){
-
+ } elseif ( is_single() ) {
$display_first = true;
-
}
-
- if($display_first){
-
- if((get_option('openattribute_append_footer')==1)||(get_option('openattribute_append_content')==1)||(get_option('openattribute_widgetset')==1)){
-
- if($disable[0]==""){
-
- $disable = get_post_meta($_GET['page_id'], 'disable_license');
-
+
+ if ( $display_first ) {
+ if ( ( get_option( 'openattribute_append_footer' ) == 1 ) || ( get_option( 'openattribute_append_content' ) == 1 ) || ( get_option( 'openattribute_widgetset' ) == 1 ) ) {
+ if ( isset( $_GET['page_id'] ) ) {
+ $disable = get_post_meta( $_GET['page_id'], 'disable_license' );
}
-
- if($disable[0]=="off"||$disable[0]==""){
-
+
+ if ( $disable[0] == 'off' || $disable[0] == '' ) {
$display = true;
-
- if($display){
-
- if((get_option('openattribute_buttonset')==1)||(get_option('openattribute_linkset')==1)||(get_option('openattribute_widgetset')==1)){
-
- $author = get_option('openattribute_site_author');
- $site_license = get_option('openattribute_site_license');
- $site_attribution_url = get_option('openattribute_site_attribution_url');
- $licenses = get_option('openattribute_licenses');
-
- $data_licenses = explode("\n",$licenses);
-
- while($license = array_shift($data_licenses)){
-
- $pair = explode(",",$license);
-
- if(trim($pair[1])==trim($site_license)){
-
+
+ if ( $display ) {
+ if ( ( get_option( 'openattribute_buttonset' ) == 1 ) || ( get_option( 'openattribute_linkset' ) == 1 ) || ( get_option( 'openattribute_widgetset' ) == 1 ) ) {
+ $author = get_option( 'openattribute_site_author' );
+ $site_license = get_option( 'openattribute_site_license' );
+ $site_attribution_url = get_option( 'openattribute_site_attribution_url' );
+ $licenses = get_option( 'openattribute_licenses' );
+
+ $data_licenses = explode( "\n", $licenses );
+
+ while ( $license = array_shift( $data_licenses ) ) {
+ $pair = explode( ',', $license );
+
+ if ( isset( $pair[1] ) && trim( $pair[1] ) == trim( $site_license ) ) {
$site_license_url = $pair[0];
-
}
-
}
-
- if($display_first){
-
+
+ if ( $display_first ) {
echo '';
-
- if(!isset($site_attribution_url)){
-
+ echo ' }';
+
+ if ( empty( $site_attribution_url ) ) {
$site_attribution_url = site_url();
-
}
-
- if(!isset($site_license_url)){
-
+
+ if ( empty( $site_license_url ) ) {
$site_license_url = $site_license;
-
}
-
- $license_data = '
';
-
- echo $license_data;
-
- }
-
- }
-
+
+ $license_data = '
';
+
+ echo $license_data;
+ }
+ }
}
-
}
-
}
-
}
-
}
-function openattribute_rdf_ns(){
+function openattribute_rdf_ns() {
- if(get_option('openattribute_site_license')!=""){
+ if ( get_option( 'openattribute_site_license' ) != '' ) {
echo 'xmlns:cc="http://creativecommons.org/ns#" ';
-
+
}
}
-function openattribute_rdf_head(){
-
- if(get_option('openattribute_site_license')!=""){
-
- echo '
';
-
- }
-}
-
-function openattribute_rss2_head(){
-
- if(get_option('openattribute_site_license')!=""){
-
- echo '
' . get_option('openattribute_site_license') . ' ';
- echo '
' . get_option('openattribute_site_license') . ' ';
-
- }
+function openattribute_rdf_head() {
+
+ if ( get_option( 'openattribute_site_license' ) != '' ) {
+
+ echo '
';
+
+ }
+}
+
+function openattribute_rss2_head() {
+
+ if ( get_option( 'openattribute_site_license' ) != '' ) {
+
+ echo '
' . get_option( 'openattribute_site_license' ) . ' ';
+ echo '
' . get_option( 'openattribute_site_license' ) . ' ';
+
+ }
}
function openattribute_atom_head() {
- if(get_option('openattribute_site_license')!=""){
-
- echo '
';
-
- }
+ if ( get_option( 'openattribute_site_license' ) != '' ) {
+
+ echo '
';
+
+ }
}
-function openattribute_augment_feed($content) {
-
- if(get_option('openattribute_site_license')!=""){
-
- if(get_option('openattribute_blogoverride')==0){
-
- echo '
' . get_option('openattribute_site_license') . ' ';
- echo '
' . get_option('openattribute_site_license') . ' ';
-
- }else{
+function openattribute_augment_feed( $content ) {
+
+ if ( get_option( 'openattribute_site_license' ) != '' ) {
+
+ if ( get_option( 'openattribute_blogoverride' ) == 0 ) {
+
+ echo '
' . get_option( 'openattribute_site_license' ) . ' ';
+ echo '
' . get_option( 'openattribute_site_license' ) . ' ';
+
+ } else {
- $display = true;
-
- $content = $wp_query->post->post_content;
-
- if(get_option('openattribute_blogoverride')==1){
-
- $author = explode("oaauthor",$content);
- $title = explode("oatitle",$content);
- $oashorthand = explode("oashorthand",$content);
-
- if(count($author)!=1){
-
- $display = false;
-
- }
-
- if(count($title)!=1){
-
- $display = false;
-
- }
-
- if(count($oashorthand)!=1){
-
- $display = false;
-
- }
-
- if($display){
-
- $data=explode("oalicenseurl=\"",$content);
-
- if(count($data)!=1){
-
- $license = explode("\"",$data[0]);
-
- echo '
' . $license[0] . ' ';
- echo '
' . $license[0] . ' ';
-
- }
-
- }
-
- }
-
- }
-
- }else{
-
- $content = $wp_query->post->post_content;
$display = true;
-
- $author = explode("oaauthor",$content);
- $title = explode("oatitle",$content);
- $oashorthand = explode("oashorthand",$content);
-
- if(count($author)!=1){
-
- $display = false;
-
- }
-
- if(count($title)!=1){
-
- $display = false;
-
- }
-
- if(count($oashorthand)!=1){
-
- $display = false;
-
- }
-
- if($display){
-
- $data=explode("oalicenseurl=\"",$content);
-
- if(count($data)!=1){
-
- $license = explode("\"",$data[0]);
-
- echo '
' . $license[0] . ' ';
- echo '
' . $license[0] . ' ';
-
+
+ $content = $wp_query->post->post_content;
+
+ if ( get_option( 'openattribute_blogoverride' ) == 1 ) {
+
+ $author = explode( 'oaauthor', $content );
+ $title = explode( 'oatitle', $content );
+ $oashorthand = explode( 'oashorthand', $content );
+
+ if ( count( $author ) != 1 ) {
+
+ $display = false;
+
+ }
+
+ if ( count( $title ) != 1 ) {
+
+ $display = false;
+
+ }
+
+ if ( count( $oashorthand ) != 1 ) {
+
+ $display = false;
+
+ }
+
+ if ( $display ) {
+
+ $data = explode( 'oalicenseurl="', $content );
+
+ if ( count( $data ) != 1 ) {
+
+ $license = explode( '"', $data[0] );
+
+ echo '
' . $license[0] . ' ';
+ echo '
' . $license[0] . ' ';
+
+ }
}
-
}
-
}
-
- }
-
- function openattribute_stylesheet(){
-
- echo '
';
-
- }
-
- function openattribute_widget(){
+ } else {
+
+ $content = $wp_query->post->post_content;
+ $display = true;
+
+ $author = explode( 'oaauthor', $content );
+ $title = explode( 'oatitle', $content );
+ $oashorthand = explode( 'oashorthand', $content );
+
+ if ( count( $author ) != 1 ) {
- register_widget('OpenAttributeWidget');
-
+ $display = false;
+
+ }
+
+ if ( count( $title ) != 1 ) {
+
+ $display = false;
+
+ }
+
+ if ( count( $oashorthand ) != 1 ) {
+
+ $display = false;
+
+ }
+
+ if ( $display ) {
+
+ $data = explode( 'oalicenseurl="', $content );
+
+ if ( count( $data ) != 1 ) {
+
+ $license = explode( '"', $data[0] );
+
+ echo '
' . $license[0] . ' ';
+ echo '
' . $license[0] . ' ';
+
+ }
+ }
}
+}
+
+function openattribute_stylesheet() {
+
+ echo '
';
+
+}
+
+function openattribute_widget() {
+ register_widget( 'Open_Attribute_Widget' );
+};
+
// Modifications to feeds
-;
-add_action('rss_head', 'openattribute_rss2_head');
-add_action('rss2_head', 'openattribute_rss2_head');
-add_action('atom_head', 'openattribute_atom_head');
-add_action('rss2_ns', 'openattribute_rdf_ns');
-add_action('rdf_ns', 'openattribute_rdf_ns');
-add_action('rdf_header', 'openattribute_rdf_head');
-add_action("atom_entry","openattribute_augment_feed");
-add_action("rdf_item","openattribute_augment_feed");
-add_action("rss2_item","openattribute_augment_feed");
-add_action("rss_item","openattribute_augment_feed");
+
+add_action( 'rss_head', 'openattribute_rss2_head' );
+add_action( 'rss2_head', 'openattribute_rss2_head' );
+add_action( 'atom_head', 'openattribute_atom_head' );
+add_action( 'rss2_ns', 'openattribute_rdf_ns' );
+add_action( 'rdf_ns', 'openattribute_rdf_ns' );
+add_action( 'rdf_header', 'openattribute_rdf_head' );
+add_action( 'atom_entry', 'openattribute_augment_feed' );
+add_action( 'rdf_item', 'openattribute_augment_feed' );
+add_action( 'rss2_item', 'openattribute_augment_feed' );
+add_action( 'rss_item', 'openattribute_augment_feed' );
// Admin options on wp-admin side of things
-add_action('admin_init', 'openattribute_register' );
-add_action('admin_menu', 'openattribute_menu_option');
-add_action('admin_head', 'openattribute_postform');
-add_action('admin_notices', 'openattribute_firstrun');
+add_action( 'admin_init', 'openattribute_register' );
+add_action( 'admin_menu', 'openattribute_menu_option' );
+add_action( 'admin_head', 'openattribute_postform' );
+add_action( 'admin_notices', 'openattribute_firstrun' );
// Code for the insert into blog function for non-site licenses.
-add_filter('media_buttons_context', 'openattribute_button');
-add_filter('media_upload_openattribute', 'add_openattribute_action');
+add_filter( 'media_buttons_context', 'openattribute_button' );
+add_filter( 'media_upload_openattribute', 'add_openattribute_action' );
// Code to handle blog specific licensing
-add_action("add_meta_boxes", "openattribute_add_disable_menu" );
-add_action('save_post', 'openattribute_save_post');
+add_action( 'add_meta_boxes', 'openattribute_add_disable_menu' );
+add_action( 'save_post', 'openattribute_save_post' );
// Code to display site licenses
-add_action("the_content", 'openattribute_add_license_content');
-add_action('get_footer', 'openattribute_add_license_footer');
+add_action( 'the_content', 'openattribute_add_license_content' );
+add_action( 'get_footer', 'openattribute_add_license_footer' );
//
// The footer attribution may appear neater if you use wp_footer over get_footer
@@ -1512,19 +1352,14 @@ function openattribute_widget(){
//add_action('wp_footer', 'openattribute_add_license_footer');
//
-add_action('loop_start', 'openattribute_add_license_header');
+add_action( 'loop_start', 'openattribute_add_license_header' );
// Load pop up for style sheet
-add_action('wp_head', 'openattribute_stylesheet');
+add_action( 'wp_head', 'openattribute_stylesheet' );
// Load the Widget code
-
-include "openattribute_widget.php";
+require 'class-open-attribute-widget.php';
// Widget register
-
-add_action('widgets_init', 'openattribute_widget');
-
-
-?>
+add_action( 'widgets_init', 'openattribute_widget' );
diff --git a/openattribute_widget.php b/openattribute_widget.php
deleted file mode 100644
index 50656c0..0000000
--- a/openattribute_widget.php
+++ /dev/null
@@ -1,138 +0,0 @@
- 'OpenAttribute Widget',
- 'description' => 'Display a a license for your blog post or entire site in a widget'
- );
-
- $this->WP_Widget('openattribute_widget', 'OpenAttribute Widget', $widgetSettings, '');
-
- }
-
- function widget($args, $instance){
-
- if(($instance['openattribute_link']) || $instance['openattribute_image']){
-
- global $wp_query;
-
- if(is_single()){
-
- if(get_option('openattribute_widgetset')==1){
-
- $disable = get_post_meta($wp_query->posts[0]->ID, 'disable_license');
-
- if($disable[0]=="off"||$disable[0]==""){
-
- $display = true;
-
- if(get_option('openattribute_blogoverride')==1){
-
- $content = $wp_query->posts[0]->post_content;
-
- $author = explode("oaauthor",$content);
- $title = explode("oatitle",$content);
- $oashorthand = explode("oashorthand",$content);
-
- if(count($author)!=1){
-
- $display = false;
-
- }
-
- if(count($title)!=1){
-
- $display = false;
-
- }
-
- if(count($oashorthand)!=1){
-
- $display = false;
-
- }
-
- }
-
- if($display){
-
- echo $args['before_widget'];
- echo $args['before_title'];
- echo "Attribute me";
- echo $args['after_title'];
-
- if($instance['openattribute_image']){
-
- echo "
";
-
- }
-
- if($instance['openattribute_link']){
-
- echo "
Attribute this resource ";
-
- }
-
- echo $args['after_widget'];
-
- }
- }
- }
-
- }
-
- }
-
- }
-
- public function update($new_instance, $old_instance) {
-
- print_r($new_instance);
-
- $instance = $old_instance;
-
- $instance['openattribute_link'] = strip_tags($new_instance['openattribute_link']);
-
- $instance['openattribute_image'] = strip_tags($new_instance['openattribute_image']);
-
- return $instance;
-
- }
-
- function form($instance) {
-
- ?>
Tick the respective box if you wish the following to appear in this widget:
-
";
-
- }else{
-
- echo " />";
-
- }
- ?>
-
"Attribute this resource"
-
";
-
- }else{
-
- echo " />";
-
- }
- ?>
-
OpenAttribute image
\ No newline at end of file
diff --git a/readme.txt b/readme.txt
index cbc6920..b5e6e87 100644
--- a/readme.txt
+++ b/readme.txt
@@ -2,10 +2,10 @@
Contributors: OpenAttribute, pgogy, barlas
Tags: attribution, licensing, creative commons, openattribute, mozilla, drumbeat, copyright, recognition, post, pages
Requires at least: 3.0.0
-Tested up to: 4.3
+Tested up to: 4.9.7
Stable tag: 1
-Allows a user to add licensing and attribution information into a blog post / WordPress powered site.
+Allows a user to add licensing and attribution information into a blog post / WordPress powered site.
== Description ==
@@ -19,12 +19,20 @@ This section describes how to install the plugin and get it working.
e.g.
-1. Upload the contents of the zip (including the folder - called 'openattribute-for-wordpress') to the `/wp-content/plugins/` directory
+1. Upload the contents of the zip (including the folder - called 'openattribute') to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Visit the settings page for the plugin - No other configuration is required.
== Changelog ==
+= 1.1.0 =
+Change WP_Widget to call __construct() instead of old PHP 4 constructors
+Implement multiple isset() checks to ensure we don't access unidentified indexes
+Add support to the widget for the WordPress customiser
+Update code format to match some WordPress core conventions
+Change openattribute_widget.php to class-openattribute-widget.php
+Change plugin folder name to be openattribute instead of openattribute-for-wordpress, matching the main plugin file as per WordPress recommended naming conventions
+
= 1 =
Fixed licence listing bug. Thanks to Phil Barker
@@ -72,4 +80,4 @@ We are a new plugin - so no questions so far. Perhaps try http://openattribute.c
== Upgrade Notice ==
-None exist so far
\ No newline at end of file
+None exist so far