From a4ef7e854c0a3c4a6c2d4242da03e44d0a38a6f9 Mon Sep 17 00:00:00 2001 From: sephster Date: Tue, 17 Jul 2018 11:11:15 +0100 Subject: [PATCH 01/28] Remove php4 constructor --- openattribute_widget.php | 115 +++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/openattribute_widget.php b/openattribute_widget.php index 50656c0..c434d45 100644 --- a/openattribute_widget.php +++ b/openattribute_widget.php @@ -2,137 +2,136 @@ class OpenAttributeWidget extends WP_Widget { - function OpenAttributeWidget() { - - $widgetSettings = array ( - 'classname' => 'OpenAttribute Widget', - 'description' => 'Display a a license for your blog post or entire site in a widget' - ); + public function __construct() { + + $widgetSettings = [ + 'classname' => '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); - + $oashorthand = explode("oashorthand",$content); + if(count($author)!=1){ - + $display = false; - + } - + if(count($title)!=1){ - + $display = false; - + } - + if(count($oashorthand)!=1){ - + $display = false; - + } - + } - - if($display){ + + 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 " />"; - + } ?>
"; - + }else{ - + echo " />"; - + } ?> \ No newline at end of file +?> From 2e59bb63964b4f2949e68225bb565d6ef8351ca2 Mon Sep 17 00:00:00 2001 From: sephster Date: Tue, 17 Jul 2018 16:03:50 +0100 Subject: [PATCH 02/28] Change to use yoda condition --- openattribute.php | 1217 +++++++++++++++++++------------------- openattribute_widget.php | 137 ----- 2 files changed, 606 insertions(+), 748 deletions(-) delete mode 100644 openattribute_widget.php diff --git a/openattribute.php b/openattribute.php index 1aee5b3..c381c22 100644 --- a/openattribute.php +++ b/openattribute.php @@ -13,207 +13,207 @@ function openattribute_firstrun(){ if(get_option('openattribute_firstrun')=='1'){ echo "
"; - + echo "

Information on OpenAttribute

"; - + echo "

Thanks for installing OpenAttribute. You can find out about how to use our wordpress plugin on our OpenAttribute site, where we also have browser plugins.

"; - + echo "

If you'd like to get started straight away - either go to OpenAttribute settings page or start a new blog post and look for the symbol below.

"; - + echo "

"; - + echo "

You can turn this screen off on the OpenAttribute settings page

"; - + echo "
"; - + update_option('openattribute_firstrun', 0); - + } } function add_openattribute_action() { - + ?> - + openattribute_iframe.css' type='text/css' media='all' /> -
+

Adding licensing to your blog post

-

Choose the author for this blog +

Choose the author for this blog '', 'orderby' => 'display_name', @@ -223,208 +223,208 @@ function insert_author(){ 'name' => 'user', 'selected' => $current_user->ID, 'id' => 'user', - 'class' => '', + 'class' => '', 'blog_id' => $GLOBALS['blog_id'] ); - + wp_dropdown_users( $args ); ?>

Next click to insert the author

Now choose a license + ?> +

'. __('Add license') .''; - + return $context . $result; } @@ -451,7 +451,7 @@ function openattribute_register() { add_option('openattribute_indexsingle',0); add_option('openattribute_postsonly',0); add_option('openattribute_postsonly',0); - + } function openattribute_options_page() { @@ -463,14 +463,14 @@ function openattribute_options_page() {

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

-

Attribution appearance settings

Here you can set settings for the plugin, these settings can be changed at anytime.

Choosing how the visitor sees the attribution
@@ -500,7 +500,7 @@ function openattribute_options_page() {

As a link such as the one above. -

+


/> If this box is ticked, an Open Attribute "Attribute Me" button will appear on all attributed resources (pages and posts)
@@ -556,60 +556,60 @@ function openattribute_options_page() {

Add Licenses

Please enter the licenses you wish to use below. The format for the license is "URL,text to display on screen". If you wish to use a custom license, perhaps create a page on your blog to hold your licensing info. By default you have been provided with some Creative Commons licenses.

- + + + ?>

Setup a site license

Choose a site license from this list - you can add new licenses in the box above

The current license is -

Choose an author name to display for this site
'', 'orderby' => 'display_name', @@ -618,23 +618,23 @@ function openattribute_options_page() { 'show' => 'display_name', 'name' => 'user', 'id' => 'user', - 'class' => '', + 'class' => '', 'blog_id' => $GLOBALS['blog_id'] ); - + wp_dropdown_users( $args ); - + ?>or enter a name

-

Do you wish to use a URL for this author (called an attribution url)" type="text" size="50" name="oa_url" />

/> If this box is ticked, the author of the page / post will be attributed.

@@ -643,184 +643,184 @@ function openattribute_options_page() {

- + "; - + } - + } function openattribute_add_disable_menu($output){ 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"); - + } - + } 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'); - + $display_first = false; - + if(is_home()&&$indexposts){ - + if(is_single()){ - + $display_first = true; - + }else if($indexsingle){ - + $display_first = true; - + } - + }else if(is_page()&&$postsonly){ - + $display_first = true; - + }else if(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]==""){ - + $display = true; - + if(get_option('openattribute_blogoverride')==1){ - + $author = explode("oaauthor",$output); $title = explode("oatitle",$output); - $oashorthand = explode("oalicense",$output); - + $oashorthand = explode("oalicense",$output); + if(count($author)!=1){ - + $display = false; - + } - + if(count($title)!=1){ - + $display = false; - + } - + if(count($oashorthand)!=1){ - + $display = false; - + } - + } - + if($display_first){ - - $author = get_option('openattribute_site_author'); + + $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)){ - + $site_license_url = $pair[0]; - + } - + } - + $license_data .= stripslashes(get_option('openattribute_pre_license_html')); - + if(get_option('openattribute_buttonset')==1){ - + $license_data .= '
'; - + if(get_option("openattribute_altlink")!=""){ $license_data .= ''; }else{ $license_data .= ''; } $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; } @@ -1035,136 +1035,136 @@ function openattribute_add_license_content($output){ 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'); - + $display_first = false; - + if(is_home()&&$indexposts){ - + if(is_single()){ - + $display_first = true; - + }else if($indexsingle){ - + $display_first = true; - + } - + }else if(is_page()&&$postsonly){ - + $display_first = true; - + }else if(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]==""){ - + $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); - + $oashorthand = explode("oashorthand",$content); + if(count($author)!=1){ - + $display = false; - + } - + if(count($title)!=1){ - + $display = false; - + } - + if(count($oashorthand)!=1){ - + $display = false; - + } - + } - + if($display){ - + get_option('openattribute_buttonset'); - $author = get_option('openattribute_site_author'); + $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)){ - + $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 .= '
'; - + if(get_option("openattribute_altlink")!=""){ $license_data .= ''; }else{ $license_data .= ''; } $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; - + } - + } - + } - + } - + } } @@ -1176,70 +1176,70 @@ function openattribute_add_license_header(){ $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()){ - + $display_first = true; - + }else if($indexsingle){ - + $display_first = true; - + } - + }else if(is_page()&&$postsonly){ - + $display_first = true; - + }else if(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($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'); + + $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)){ - + $site_license_url = $pair[0]; - + } - + } - + if($display_first){ - + echo ''; - + echo ' }'; + if(!isset($site_attribution_url)){ - + $site_attribution_url = site_url(); - + } - + if(!isset($site_license_url)){ - + $site_license_url = $site_license; - + } - + $license_data = ''; - + echo $license_data; - + } - + } - + } - + } - + } - + } } @@ -1302,7 +1302,7 @@ function openattribute_rdf_ns(){ if(get_option('openattribute_site_license')!=""){ echo 'xmlns:cc="http://creativecommons.org/ns#" '; - + } } @@ -1310,35 +1310,35 @@ function openattribute_rdf_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') . ''; - + } } @@ -1346,127 +1346,125 @@ function openattribute_rss2_head(){ function openattribute_atom_head() { 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{ $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); - + $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); - + $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 ' '; - + + echo ' '; + } - - function openattribute_widget(){ - register_widget('OpenAttributeWidget'); - + function openattribute_widget(){ + register_widget('Open_Attribute_Widget'); } // Modifications to feeds @@ -1520,11 +1518,8 @@ function openattribute_widget(){ // Load the Widget code -include "openattribute_widget.php"; +include 'class-open-attribute-widget.php'; // Widget register add_action('widgets_init', 'openattribute_widget'); - - -?> diff --git a/openattribute_widget.php b/openattribute_widget.php deleted file mode 100644 index c434d45..0000000 --- a/openattribute_widget.php +++ /dev/null @@ -1,137 +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 " />"; - - } - ?> -
- "; - - }else{ - - echo " />"; - - } - ?> - From 4ba2f2b0b6a8c109854d35ae18870bf7134add40 Mon Sep 17 00:00:00 2001 From: sephster Date: Tue, 17 Jul 2018 17:25:05 +0100 Subject: [PATCH 03/28] Fix coding standard issues --- class-open-attribute-widget.php | 116 ++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 class-open-attribute-widget.php diff --git a/class-open-attribute-widget.php b/class-open-attribute-widget.php new file mode 100644 index 0000000..31fc1d1 --- /dev/null +++ b/class-open-attribute-widget.php @@ -0,0 +1,116 @@ +WP_Widget( + 'openattribute_widget', + 'OpenAttribute Widget', + [ + 'classname' => 'OpenAttribute Widget', + 'description' => 'Display a a license for your blog post or entire site in a widget', + ], + '' + ); + } + + /** + * Echoes the widget content + * + * @return void + */ + public 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 ( 'off' === $disable[0] || '' === $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 esc_html( $args['before_widget'] ); + echo esc_html( $args['before_title'] ); + echo 'Attribute me'; + echo esc_html( $args['after_title'] ); + + if ( $instance['openattribute_image'] ) { + echo ''; + } + + if ( $instance['openattribute_link'] ) { + echo 'Attribute this resource'; + } + + echo esc_html( $args['after_widget'] ); + } + } + } + } + } + } + + /** + * Updates a particular instance of a widget + * + * @return array + */ + public function update( $new_instance, $old_instance ) { + $instance = $old_instance; + + $instance['openattribute_link'] = strip_tags( $new_instance['openattribute_link'] ); + $instance['openattribute_image'] = strip_tags( $new_instance['openattribute_image'] ); + + return $instance; + } + + /** + * Outputs the settings update form + * + * @return void + */ + public function form( $instance ) { + ?> +

Tick the respective box if you wish the following to appear in this widget:

+ '; + } else { + echo ' />'; + } + ?> +
+ '; + } else { + echo ' />'; + } + ?> + + Date: Tue, 17 Jul 2018 18:01:42 +0100 Subject: [PATCH 04/28] Removed excess blank lines --- openattribute.php | 1629 +++++++++++++++++---------------------------- 1 file changed, 610 insertions(+), 1019 deletions(-) diff --git a/openattribute.php b/openattribute.php index c381c22..0bbc5f8 100644 --- a/openattribute.php +++ b/openattribute.php @@ -2,56 +2,38 @@ /* Plugin Name: Open Attribute Plugin URI: http://openattribute.com -OpenAttribute allows you to add licensing information to your Wordpress site and individual blogs. It places information into posts and RSS feeds as well as other user friendly features. +OpenAttribute allows you to add licensing information to your WordPress site and individual blogs. It places information into posts and RSS feeds as well as other user friendly features. Version: 1 Author: OpenAttribute, pgogy Author URI: http://openattribute.com */ -function openattribute_firstrun(){ - - if(get_option('openattribute_firstrun')=='1'){ - +function openattribute_firstrun() { + if ( get_option( 'openattribute_firstrun' ) == '1' ) { echo "
"; - - echo "

Information on OpenAttribute

"; - - echo "

Thanks for installing OpenAttribute. You can find out about how to use our wordpress plugin on our OpenAttribute site, where we also have browser plugins.

"; - - echo "

If you'd like to get started straight away - either go to OpenAttribute settings page or start a new blog post and look for the symbol below.

"; - - echo "

"; - - echo "

You can turn this screen off on the OpenAttribute settings page

"; - - echo "
"; - - update_option('openattribute_firstrun', 0); - - } - + echo '

Information on OpenAttribute

'; + echo '

Thanks for installing OpenAttribute. You can find out about how to use our wordpress plugin on our OpenAttribute site, where we also have browser plugins.

'; + echo "

If you'd like to get started straight away - either go to OpenAttribute settings page or start a new blog post and look for the symbol below.

"; + echo '

'; + echo '

You can turn this screen off on the OpenAttribute settings page

'; + echo ''; + + update_option( 'openattribute_firstrun', 0 ); + } } function add_openattribute_action() { - ?> - openattribute_iframe.css' type='text/css' media='all' /> + function insert_author(){ + document.getElementById("author_oa").value = document.getElementById('user').options[document.getElementById('user').selectedIndex].text; + document.getElementById("url_oa").value = "/?author=" + document.getElementById('user').selectedIndex; + } + + openattribute_iframe.css' type='text/css' media='all' />
- -

Adding licensing to your blog post

-

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'] + +

Adding licensing to your blog post

+

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 ); ?>

Next click to insert the author

+ wp_dropdown_users( $args ); + ?> +

Next click to insert the author

Now choose a license

- @@ -417,829 +289,626 @@ function insert_author(){ '. __('Add license') .''; +function openattribute_button( $context ) { + $icon_url = WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . 'openatt.png'; + $string = get_permalink(); + $result = '' . __( 'Add license' ) . ''; - return $context . $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_post_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_post_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

-
-

Attribution appearance settings

-

Here you can set settings for the plugin, these settings can be changed at anytime.

-
Choosing how the visitor sees the attribution
-

- The attribution can appear in two ways (both can be used if you wish). -

-
- " /> -

- As this button. -

-
-
-

- - Attribute this resource - -

-

- As a link such as the one above. -

-
-
- /> If this box is ticked, an Open Attribute "Attribute Me" button will appear on all attributed resources (pages and posts)
- Replace the Open Attribute "Attribute Me" button with a different URL
- /> If this box is ticked, an Open Attribute "Attribute Me" link will appear on all attributed resources (pages and posts)
- /> Display attribution in the widget. In doing this the Widget can be made to appear anywhere your theme supports Widgets
-

-
-
Where will the link / button appear?
-

- Your license can either appear directly at the end of your post or page - or after comments. You can tick both boxes if you prefer. You can use this and insert attribution as text into a page or post's content.

- Using this option is like setting a site license, and so will appear on all content. -

- /> Display the attribution after the blog's content (before comments)
- /> Display the attribution after comments on the blog
- /> Display attribution on the index page
- /> Display attribution on the index page (if multiple posts appear)
- /> Display the attribution only on blog posts (not pages)
-
-

Please note the following

-

";?> -

If you insert using this button then the license is added as text to the post / page content itself, and will therefore be displayed where you put it in the page / post. The options above (after content / after comments) will not affect the location for this license.

-
-
-
HTML Options
-

- This section allows you (if you wish) to style how the attribution will appear. -

-

Before
-
-

After
-
-

-
-
Add licensing info to the RSS feeds
-

- Ticking this box will add attribution information to the RSS / RDFa / RSS2 feeds -

- /> If this box is ticked, the license information will be added to the RSS and Atom feeds
-
-
Administrative features
-

- You can allow an author to override a site license with a post / page specific license (inserted using the button shown above), or allow a user to opt out of licensing a specific post / page completely. -

- /> If this box is ticked, if you add a license into the page / post, then the site license will not be displayed
- /> If this box is ticked, a page / post author can opt out of having their work attributed
-
-
The first run page
-

- You can turn off the first run page here. -

- /> If this box is ticked, the "first run" guidance will be displayed
-
-

Add Licenses

-

Please enter the licenses you wish to use below. The format for the license is "URL,text to display on screen". If you wish to use a custom license, perhaps create a page on your blog to hold your licensing info. By default you have been provided with some Creative Commons licenses.

- -

Setup a site license

-

Choose a site license from this list - you can add new licenses in the box above

- + +

Attribution appearance settings

+

Here you can set settings for the plugin, these settings can be changed at anytime.

+
Choosing how the visitor sees the attribution
+

The attribution can appear in two ways (both can be used if you wish).

+
+ +

As this button.

+
+
+

Attribute this resource

+

As a link such as the one above.

+
+
+ /> If this box is ticked, an Open Attribute "Attribute Me" button will appear on all attributed resources (pages and posts)
+ Replace the Open Attribute "Attribute Me" button with a different URL
+ /> If this box is ticked, an Open Attribute "Attribute Me" link will appear on all attributed resources (pages and posts)
+ /> Display attribution in the widget. In doing this the Widget can be made to appear anywhere your theme supports Widgets
+

+
+
Where will the link / button appear?
+

+ Your license can either appear directly at the end of your post or page - or after comments. You can tick both boxes if you prefer. You can use this and insert attribution as text into a page or post's content.

+ Using this option is like setting a site license, and so will appear on all content. +

+ /> Display the attribution after the blog's content (before comments)
+ /> Display the attribution after comments on the blog
+ /> Display attribution on the index page
+ /> Display attribution on the index page (if multiple posts appear)
+ /> Display the attribution only on blog posts (not pages)
+
+

Please note the following

+

'; ?> +

If you insert using this button then the license is added as text to the post / page content itself, and will therefore be displayed where you put it in the page / post. The options above (after content / after comments) will not affect the location for this license.

+
+
+
HTML Options
+

+ This section allows you (if you wish) to style how the attribution will appear. +

+

Before
+
+

After
+
+

+
+
Add licensing info to the RSS feeds
+

+ Ticking this box will add attribution information to the RSS / RDFa / RSS2 feeds +

+ /> If this box is ticked, the license information will be added to the RSS and Atom feeds
+
+
Administrative features
+

+ You can allow an author to override a site license with a post / page specific license (inserted using the button shown above), or allow a user to opt out of licensing a specific post / page completely. +

+ /> If this box is ticked, if you add a license into the page / post, then the site license will not be displayed
+ /> If this box is ticked, a page / post author can opt out of having their work attributed
+
+
The first run page
+

+ You can turn off the first run page here. +

+ /> If this box is ticked, the "first run" guidance will be displayed
+
+

Add Licenses

+

Please enter the licenses you wish to use below. The format for the license is "URL,text to display on screen". If you wish to use a custom license, perhaps create a page on your blog to hold your licensing info. By default you have been provided with some Creative Commons licenses.

+ +

Setup a site license

+

Choose a site license from this list - you can add new licenses in the box above

+

The current license is -

The current license is - + -

Choose an author name to display for this site
Choose an author name to display for this site
+ '', - 'orderby' => 'display_name', - 'order' => 'ASC', - 'multi' => true, - 'show' => 'display_name', - 'name' => 'user', - 'id' => 'user', - 'class' => '', - 'blog_id' => $GLOBALS['blog_id'] - ); - - wp_dropdown_users( $args ); - - ?>or enter a name

-

Do you wish to use a URL for this author (called an attribution url) '', + 'orderby' => 'display_name', + 'order' => 'ASC', + 'multi' => true, + 'show' => 'display_name', + 'name' => 'user', + 'id' => 'user', + 'class' => '', + 'blog_id' => $GLOBALS['blog_id'], + ); + + wp_dropdown_users( $args ); + ?> + or enter a name

+

Do you wish to use a URL for this author (called an attribution url)

- /> If this box is ticked, the author of the page / post will be attributed.
-

- - -

+ $author_override = get_option( 'openattribute_authoroverride' ) == '1' ? 'checked' : ''; + ?> + " type="text" size="50" name="oa_url" />

+ /> If this box is ticked, the author of the page / post will be attributed.
+

+ + +

- - "; - + } else { + if ( ! current_user_can( 'edit_post', $post_id ) ) { + return $post_id; } + } + if ( $_POST['disable_license'] == 'on' ) { + update_post_meta( $post_id, 'disable_license', 'on' ); + } else { + update_post_meta( $post_id, 'disable_license', 'off' ); + } } -function openattribute_add_disable_menu($output){ - - if(get_option('openattribute_disable')==1){ - - add_meta_box( 'openattribute_id', 'OpenAttribute',"openattribute_disable_menu","post","normal","high"); +function openattribute_disable_menu() { + wp_nonce_field( plugin_basename( __FILE__ ), 'openattribute_noncename' ); - } + $meta = get_post_meta( $_GET['post'], 'disable_license' ); - $meta = get_post_meta($_GET['post'], 'disable_license'); + if ( $meta[0] == 'on' ) { + $checked = 'checked'; + } else { + $checked = ''; + } - if($meta[0]=="on"){ + if ( ( get_option( 'openattribute_disable' ) == 1 ) || ( $meta[0] == 'on' ) ) { + echo "To disable attribution for this post please tick this box "; + } +} - add_meta_box( 'openattribute_id', 'OpenAttribute',"openattribute_disable_menu","post","normal","high"); +function openattribute_add_disable_menu( $output ) { + 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' ); + } } -function openattribute_add_license_content($output){ - +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' ); $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); + $data_licenses = explode( "\n", $licenses ); - if(trim($pair[1])==trim($site_license)){ + while ( $license = array_shift( $data_licenses ) ) { + $pair = explode( ',', $license ); + if ( trim( $pair[1] ) == trim( $site_license ) ) { $site_license_url = $pair[0]; - } - } - $license_data .= stripslashes(get_option('openattribute_pre_license_html')); + $license_data .= stripslashes( get_option( 'openattribute_pre_license_html' ) ); - if(get_option('openattribute_buttonset')==1){ + if ( get_option( 'openattribute_buttonset' ) == 1 ) { + $license_data .= '
'; - $license_data .= '
'; - - if(get_option("openattribute_altlink")!=""){ - $license_data .= ''; - }else{ - $license_data .= ''; + if ( get_option( 'openattribute_altlink' ) != '' ) { + $license_data .= ''; + } else { + $license_data .= ''; } - $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'); + $license_data .= '
'; + } - $output .= $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){ + if ( $display ) { + get_option( 'openattribute_buttonset' ); - 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"); + $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); + $data_licenses = explode( "\n", $licenses ); - if(trim($pair[1])==trim($site_license)){ + 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){ + if ( $display_first ) { + $license_data .= stripslashes( get_option( 'openattribute_pre_license_html' ) ); - $license_data .= '
'; + if ( get_option( 'openattribute_buttonset' ) == 1 ) { + $license_data .= '
'; - if(get_option("openattribute_altlink")!=""){ - $license_data .= ''; - }else{ - $license_data .= ''; + if ( get_option( 'openattribute_altlink' ) != '' ) { + $license_data .= ''; + } else { + $license_data .= ''; } - $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'); + $license_data .= '
'; + } - $output .= $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' ); - echo $output; + $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'); + $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 ( $disable[0] == '' ) { + $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)){ + 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' ); - $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 ); - $data_licenses = explode("\n",$licenses); - - while($license = array_shift($data_licenses)){ - - $pair = explode(",",$license); - - if(trim($pair[1])==trim($site_license)){ + while ( $license = array_shift( $data_licenses ) ) { + $pair = explode( ',', $license ); + if ( 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 ( ! isset( $site_attribution_url ) ) { $site_attribution_url = site_url(); - } - if(!isset($site_license_url)){ - + if ( ! isset( $site_license_url ) ) { $site_license_url = $site_license; - } - $license_data = ''; + $license_data = ''; + echo $license_data; + } + } } - } - } - } - } -function openattribute_rdf_ns(){ - - if(get_option('openattribute_site_license')!=""){ - +function openattribute_rdf_ns() { + 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_rdf_head() { + if ( get_option( 'openattribute_site_license' ) != '' ) { + echo ''; + } } -function openattribute_rss2_head(){ - - if(get_option('openattribute_site_license')!=""){ +function openattribute_rss2_head() { + if ( get_option( 'openattribute_site_license' ) != '' ) { + echo '' . get_option('openattribute_site_license') . ''; - echo '' . 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{ - - $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; - - } +function openattribute_augment_feed( $content ) { + if ( get_option( 'openattribute_site_license' ) != '' ) { + if ( get_option( 'openattribute_blogoverride' ) == 0 ) { + echo '' . esc_html( get_option( 'openattribute_site_license' ) ) . ''; + echo '' . esc_html( get_option( 'openattribute_site_license' ) ) . ''; + } else { + $display = true; + $content = $wp_query->post->post_content; - if($display){ + if ( get_option( 'openattribute_blogoverride' ) == 1 ) { + $author = explode( 'oaauthor', $content ); + $title = explode( 'oatitle', $content ); + $oashorthand = explode( 'oashorthand', $content ); - $data=explode("oalicenseurl=\"",$content); + if ( count( $author ) != 1 ) { + $display = false; + } - if(count($data)!=1){ + if ( count( $title ) != 1 ) { + $display = false; + } - $license = explode("\"",$data[0]); + if ( count( $oashorthand ) != 1 ) { + $display = false; + } - echo '' . $license[0] . ''; - echo '' . $license[0] . ''; + if ( $display ) { + $data = explode( 'oalicenseurl="', $content ); - } + if ( count( $data ) != 1 ) { + $license = explode( '"', $data[0] ); + echo '' . esc_html( $license[0] ) . ''; + echo '' . esc_html( $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; - } + } + } else { + $content = $wp_query->post->post_content; + $display = true; - if($display){ + $author = explode( 'oaauthor', $content ); + $title = explode( 'oatitle', $content ); + $oashorthand = explode( 'oashorthand', $content ); - $data=explode("oalicenseurl=\"",$content); + if ( count( $author ) != 1 ) { + $display = false; + } - if(count($data)!=1){ + if ( count( $title ) != 1 ) { + $display = false; + } - $license = explode("\"",$data[0]); + if ( count( $oashorthand ) != 1 ) { + $display = false; + } - echo '' . $license[0] . ''; - echo '' . $license[0] . ''; + if ( $display ) { + $data = explode( 'oalicenseurl="', $content ); - } + if ( count( $data ) != 1 ) { + $license = explode( '"', $data[0] ); + echo '' . esc_html( $license[0] ) . ''; + echo '' . esc_html( $license[0] ) . ''; } - } - } +} - function openattribute_stylesheet(){ - - echo ' '; - - } +function openattribute_stylesheet() { + wp_enqueue_style( 'openattribute_popup', esc_url( WP_PLUGIN_URL . '/openattribute-for-wordpress/openattribute_popup.css' ), [], false, 'screen,projector' ); +} - function openattribute_widget(){ - register_widget('Open_Attribute_Widget'); - } +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 // // comment out the get footer line above and remove the commenting from the line below to do this // //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_enqueue_scripts', 'openattribute_stylesheet' ); // Load the Widget code - -include 'class-open-attribute-widget.php'; +require 'class-open-attribute-widget.php'; // Widget register - -add_action('widgets_init', 'openattribute_widget'); +add_action( 'widgets_init', 'openattribute_widget' ); From 65210bb2cdaf31457404cbfd29f14e7cad7f7a68 Mon Sep 17 00:00:00 2001 From: sephster Date: Wed, 18 Jul 2018 11:06:05 +0100 Subject: [PATCH 05/28] Code tidyup --- openattribute.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/openattribute.php b/openattribute.php index 0bbc5f8..2676444 100644 --- a/openattribute.php +++ b/openattribute.php @@ -852,7 +852,6 @@ function openattribute_add_license_footer( $content ) { $output .= $license_data; echo $output; - } } } @@ -884,11 +883,11 @@ function openattribute_add_license_header() { if ( $display_first ) { if ( ( get_option( 'openattribute_append_footer' ) == 1 ) || ( get_option( 'openattribute_append_content' ) == 1 ) || ( get_option( 'openattribute_widgetset' ) == 1 ) ) { - if ( $disable[0] == '' ) { + if ( '' == $disable[0] ) { $disable = get_post_meta( $_GET['page_id'], 'disable_license' ); } - if ( $disable[0] == 'off' || $disable[0] == '' ) { + if ( 'off' == $disable[0] || '' == $disable[0] ) { $display = true; if ( $display ) { @@ -900,6 +899,7 @@ function openattribute_add_license_header() { $data_licenses = explode( "\n", $licenses ); + // phpcs:disable while ( $license = array_shift( $data_licenses ) ) { $pair = explode( ',', $license ); @@ -907,6 +907,7 @@ function openattribute_add_license_header() { $site_license_url = $pair[0]; } } + // phpcs:enable if ( $display_first ) { echo ' - openattribute_iframe.css' type='text/css' media='all' /> -
- -

Adding licensing to your blog post

-

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'], + + string = data; + + string = string.split('>' + current_title + '').join(' xmlns:dc="http://purl.org/dc/terms/" property="dc:title">' + title + ''); + + string = string.split('xmlns:cc="http://creativecommons.org/ns#" href="' + current_attribution_url).join('xmlns:cc="http://creativecommons.org/ns#" href="' + attribution_url); + string = string.split(' oaauthor="' + current_author + '">' + current_author + '').join(' oaauthor="' + author + '">' + author + ''); + string = string.split('rel="license" href="' + current_oalicenseurl + '">').join('rel="license" href="' + license_url + '">'); + string = string.split(current_oashorthand + '').join(license_shorthand + ''); + + }else{ + + string = ' ' + title + '' + string += ' by ' + author + ''; + string += ' is licensed under a ' + license_shorthand + '.
'; + string += ' Based on a work at .'; + + } + + + + win.send_to_editor('' + string + ''); + + return true; + + } + + function insert_author(){ + + document.getElementById("author_oa").value = document.getElementById('user').options[document.getElementById('user').selectedIndex].text; + document.getElementById("url_oa").value = "/?author=" + document.getElementById('user').selectedIndex; + + } + + + openattribute_iframe.css' type='text/css' media='all' /> +

+ +

Adding licensing to your blog post

+

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 ); - ?> -

Next click to insert the author

+ + wp_dropdown_users( $args ); ?>

Next click to insert the author

Now choose a license + +

-

' . __( 'Add license' ) . ''; - - 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 = ''. __('Add license') .''; + + 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_post_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_post_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

-
- - -

Attribution appearance settings

-

Here you can set settings for the plugin, these settings can be changed at anytime.

-
Choosing how the visitor sees the attribution
-

The attribution can appear in two ways (both can be used if you wish).

-
- -

As this button.

-
-
-

Attribute this resource

-

As a link such as the one above.

-
-
- /> If this box is ticked, an Open Attribute "Attribute Me" button will appear on all attributed resources (pages and posts)
- Replace the Open Attribute "Attribute Me" button with a different URL
- /> If this box is ticked, an Open Attribute "Attribute Me" link will appear on all attributed resources (pages and posts)
- /> Display attribution in the widget. In doing this the Widget can be made to appear anywhere your theme supports Widgets
-

-
-
Where will the link / button appear?
-

- Your license can either appear directly at the end of your post or page - or after comments. You can tick both boxes if you prefer. You can use this and insert attribution as text into a page or post's content.

- Using this option is like setting a site license, and so will appear on all content. -

- /> Display the attribution after the blog's content (before comments)
- /> Display the attribution after comments on the blog
- /> Display attribution on the index page
- /> Display attribution on the index page (if multiple posts appear)
- /> Display the attribution only on blog posts (not pages)
-
-

Please note the following

-

'; ?> -

If you insert using this button then the license is added as text to the post / page content itself, and will therefore be displayed where you put it in the page / post. The options above (after content / after comments) will not affect the location for this license.

-
-
-
HTML Options
-

- This section allows you (if you wish) to style how the attribution will appear. -

-

Before
-
-

After
-
-

-
-
Add licensing info to the RSS feeds
-

- Ticking this box will add attribution information to the RSS / RDFa / RSS2 feeds -

- /> If this box is ticked, the license information will be added to the RSS and Atom feeds
-
-
Administrative features
-

- You can allow an author to override a site license with a post / page specific license (inserted using the button shown above), or allow a user to opt out of licensing a specific post / page completely. -

- /> If this box is ticked, if you add a license into the page / post, then the site license will not be displayed
- /> If this box is ticked, a page / post author can opt out of having their work attributed
-
-
The first run page
-

- You can turn off the first run page here. -

- /> If this box is ticked, the "first run" guidance will be displayed
-
-

Add Licenses

-

Please enter the licenses you wish to use below. The format for the license is "URL,text to display on screen". If you wish to use a custom license, perhaps create a page on your blog to hold your licensing info. By default you have been provided with some Creative Commons licenses.

- -

Setup a site license

-

Choose a site license from this list - you can add new licenses in the box above

+ +

Attribution appearance settings

+

Here you can set settings for the plugin, these settings can be changed at anytime.

+
Choosing how the visitor sees the attribution
+

+ The attribution can appear in two ways (both can be used if you wish). +

+
+ " /> +

+ As this button. +

+
+
+

+ + Attribute this resource + +

+

+ As a link such as the one above. +

+
+
+ /> If this box is ticked, an Open Attribute "Attribute Me" button will appear on all attributed resources (pages and posts)
+ Replace the Open Attribute "Attribute Me" button with a different URL
+ /> If this box is ticked, an Open Attribute "Attribute Me" link will appear on all attributed resources (pages and posts)
+ /> Display attribution in the widget. In doing this the Widget can be made to appear anywhere your theme supports Widgets
+

+
+
Where will the link / button appear?
+

+ Your license can either appear directly at the end of your post or page - or after comments. You can tick both boxes if you prefer. You can use this and insert attribution as text into a page or post's content.

+ Using this option is like setting a site license, and so will appear on all content. +

+ /> Display the attribution after the blog's content (before comments)
+ /> Display the attribution after comments on the blog
+ /> Display attribution on the index page
+ /> Display attribution on the index page (if multiple posts appear)
+ /> Display the attribution only on blog posts (not pages)
+
+

Please note the following

+

";?> +

If you insert using this button then the license is added as text to the post / page content itself, and will therefore be displayed where you put it in the page / post. The options above (after content / after comments) will not affect the location for this license.

+
+
+
HTML Options
+

+ This section allows you (if you wish) to style how the attribution will appear. +

+

Before
+
+

After
+
+

+
+
Add licensing info to the RSS feeds
+

+ Ticking this box will add attribution information to the RSS / RDFa / RSS2 feeds +

+ /> If this box is ticked, the license information will be added to the RSS and Atom feeds
+
+
Administrative features
+

+ You can allow an author to override a site license with a post / page specific license (inserted using the button shown above), or allow a user to opt out of licensing a specific post / page completely. +

+ /> If this box is ticked, if you add a license into the page / post, then the site license will not be displayed
+ /> If this box is ticked, a page / post author can opt out of having their work attributed
+
+
The first run page
+

+ You can turn off the first run page here. +

+ /> If this box is ticked, the "first run" guidance will be displayed
+
+

Add Licenses

+

Please enter the licenses you wish to use below. The format for the license is "URL,text to display on screen". If you wish to use a custom license, perhaps create a page on your blog to hold your licensing info. By default you have been provided with some Creative Commons licenses.

+ +

Setup a site license

+

Choose a site license from this list - you can add new licenses in the box above

The current license is - - "; + + } + ?> +

The current license is - -

Choose an author name to display for this site
- Choose an author name to display for this site
'', - 'orderby' => 'display_name', - 'order' => 'ASC', - 'multi' => true, - 'show' => 'display_name', - 'name' => 'user', - 'id' => 'user', - 'class' => '', - 'blog_id' => $GLOBALS['blog_id'], - ); - - wp_dropdown_users( $args ); - ?> - or enter a name

-

Do you wish to use a URL for this author (called an attribution url)

- /> If this box is ticked, the author of the page / post will be attributed.
-

- - -

+ 'show_option_all' => '', + 'orderby' => 'display_name', + 'order' => 'ASC', + 'multi' => true, + 'show' => 'display_name', + 'name' => 'user', + 'id' => 'user', + 'class' => '', + 'blog_id' => $GLOBALS['blog_id'] + ); + + wp_dropdown_users( $args ); + + ?>or enter a name

+

Do you wish to use a URL for this author (called an attribution url)" type="text" size="50" name="oa_url" />

+ /> If this box is ticked, the author of the page / post will be attributed.
+

+ + +

- "; + } - } - - if ( $_POST['disable_license'] == 'on' ) { - update_post_meta( $post_id, 'disable_license', 'on' ); - } else { - update_post_meta( $post_id, 'disable_license', 'off' ); - } + } -function openattribute_disable_menu() { - wp_nonce_field( plugin_basename( __FILE__ ), 'openattribute_noncename' ); +function openattribute_add_disable_menu($output){ - $meta = get_post_meta( $_GET['post'], 'disable_license' ); - - if ( $meta[0] == 'on' ) { - $checked = 'checked'; - } else { - $checked = ''; - } - - if ( ( get_option( 'openattribute_disable' ) == 1 ) || ( $meta[0] == 'on' ) ) { - echo "To disable attribution for this post please tick this box "; - } + 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"); + + } + } -function openattribute_add_disable_menu( $output ) { - 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' ); +function openattribute_add_license_content($output){ - if ( $meta[0] == 'on' ) { - 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'); + $display_first = false; - - if ( is_home() && $indexposts ) { - if ( is_single() ) { + + if(is_home()&&$indexposts){ + + if(is_single()){ + $display_first = true; - } elseif ( $indexsingle ) { + + }else if($indexsingle){ + $display_first = true; + } - } elseif ( is_page() && $postsonly ) { + + }else if(is_page()&&$postsonly){ + $display_first = true; - } elseif ( is_single() ) { + + }else if(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(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 .= '
'; - - if ( get_option( 'openattribute_altlink' ) != '' ) { - $license_data .= ''; - } else { - $license_data .= ''; + + $license_data .= stripslashes(get_option('openattribute_pre_license_html')); + + if(get_option('openattribute_buttonset')==1){ + + $license_data .= '
'; + + if(get_option("openattribute_altlink")!=""){ + $license_data .= ''; + }else{ + $license_data .= ''; } - - $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; + $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 ) { - global $wp_query,$post; +} - $indexposts = get_option( 'openattribute_index' ); - $indexsingle = get_option( 'openattribute_indexsingle' ); - $postsonly = get_option( 'openattribute_postsonly' ); +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'); + $display_first = false; - - if ( is_home() && $indexposts ) { - if ( is_single() ) { + + if(is_home()&&$indexposts){ + + if(is_single()){ + $display_first = true; - } elseif ( $indexsingle ) { + + }else if($indexsingle){ + $display_first = true; + } - } elseif ( is_page() && $postsonly ) { + + }else if(is_page()&&$postsonly){ + $display_first = true; - } elseif ( is_single() ) { + + }else if(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 .= '
'; - - if ( get_option( 'openattribute_altlink' ) != '' ) { - $license_data .= ''; - } else { - $license_data .= ''; + + if($display_first){ + + $license_data .= stripslashes(get_option('openattribute_pre_license_html')); + + if(get_option('openattribute_buttonset')==1){ + + $license_data .= '
'; + + if(get_option("openattribute_altlink")!=""){ + $license_data .= ''; + }else{ + $license_data .= ''; } - - $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; - } + $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() { - global $post; +function openattribute_add_license_header(){ - $indexposts = get_option( 'openattribute_index' ); - $indexsingle = get_option( 'openattribute_indexsingle' ); - $postsonly = get_option( 'openattribute_postsonly' ); + global $post; + $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; - } elseif ( $indexsingle ) { + + }else if($indexsingle){ + $display_first = true; + } - } elseif ( is_page() && $postsonly ) { + + }else if(is_page()&&$postsonly){ + $display_first = true; - } elseif ( is_single() ) { + + }else if(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($disable[0]==""){ + + $disable = get_post_meta($_GET['page_id'], 'disable_license'); + } - - if ( 'off' == $disable[0] || '' == $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 ); - - // phpcs:disable - 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(trim($pair[1])==trim($site_license)){ + $site_license_url = $pair[0]; + } + } - // phpcs:enable - - if ( $display_first ) { + + if($display_first){ + echo ''; - - if ( ! isset( $site_attribution_url ) ) { + echo ' }'; + + if(!isset($site_attribution_url)){ + $site_attribution_url = site_url(); + } - - if ( ! isset( $site_license_url ) ) { + + if(!isset($site_license_url)){ + $site_license_url = $site_license; + } - - $license_data = ''; - - echo esc_html( $license_data ); - } - } + + $license_data = ''; + + echo $license_data; + + } + + } + } + } + } + } -} -function openattribute_rdf_ns() { - 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_rdf_ns(){ -function openattribute_rss2_head() { - if ( get_option( 'openattribute_site_license' ) != '' ) { - echo '' . esc_html( get_option( 'openattribute_site_license' ) ) . ''; - echo '' . esc_html( get_option( 'openattribute_site_license' ) ) . ''; + echo 'xmlns:cc="http://creativecommons.org/ns#" '; + } -} -function openattribute_atom_head() { - 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 '' . esc_html( get_option( 'openattribute_site_license' ) ) . ''; - echo '' . esc_html( 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 ); +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') . ''; + + } - if ( count( $author ) != 1 ) { - $display = false; - } +} - if ( count( $title ) != 1 ) { - $display = false; - } +function openattribute_atom_head() { - if ( count( $oashorthand ) != 1 ) { - $display = false; - } + if(get_option('openattribute_site_license')!=""){ + + echo ''; + + } - if ( $display ) { - $data = explode( 'oalicenseurl="', $content ); +} - if ( count( $data ) != 1 ) { - $license = explode( '"', $data[0] ); +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{ - echo '' . esc_html( $license[0] ) . ''; - echo '' . esc_html( $license[0] ) . ''; + $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; + } - } - } 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 '' . esc_html( $license[0] ) . ''; - echo '' . esc_html( $license[0] ) . ''; + + 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() { - wp_enqueue_style( 'openattribute_popup', esc_url( WP_PLUGIN_URL . '/openattribute-for-wordpress/openattribute_popup.css' ), [], false, 'screen,projector' ); -} + + function openattribute_stylesheet(){ + + echo ' '; + + } + + function openattribute_widget(){ -function openattribute_widget() { - register_widget( 'Open_Attribute_Widget' ); -}; + register_widget('OpenAttributeWidget'); + + } // 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 // // comment out the get footer line above and remove the commenting from the line below to do this // //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_enqueue_scripts', 'openattribute_stylesheet' ); + +add_action('wp_head', 'openattribute_stylesheet'); // Load the Widget code -require 'class-open-attribute-widget.php'; + +include "openattribute_widget.php"; // Widget register -add_action( 'widgets_init', 'openattribute_widget' ); + +add_action('widgets_init', 'openattribute_widget'); + + +?> From b52d8e3114cc5d86da3d1a1866e5306279b765ab Mon Sep 17 00:00:00 2001 From: sephster Date: Wed, 18 Jul 2018 11:18:39 +0100 Subject: [PATCH 07/28] Change include file to match open-attribute-widget class --- openattribute.php | 1217 ++++++++++++++++++++++----------------------- 1 file changed, 606 insertions(+), 611 deletions(-) diff --git a/openattribute.php b/openattribute.php index 1aee5b3..0a6174e 100644 --- a/openattribute.php +++ b/openattribute.php @@ -13,207 +13,207 @@ function openattribute_firstrun(){ if(get_option('openattribute_firstrun')=='1'){ echo "
"; - + echo "

Information on OpenAttribute

"; - + echo "

Thanks for installing OpenAttribute. You can find out about how to use our wordpress plugin on our OpenAttribute site, where we also have browser plugins.

"; - + echo "

If you'd like to get started straight away - either go to OpenAttribute settings page or start a new blog post and look for the symbol below.

"; - + echo "

"; - + echo "

You can turn this screen off on the OpenAttribute settings page

"; - + echo "
"; - + update_option('openattribute_firstrun', 0); - + } } function add_openattribute_action() { - + ?> - + openattribute_iframe.css' type='text/css' media='all' /> -
+

Adding licensing to your blog post

-

Choose the author for this blog +

Choose the author for this blog '', 'orderby' => 'display_name', @@ -223,208 +223,208 @@ function insert_author(){ 'name' => 'user', 'selected' => $current_user->ID, 'id' => 'user', - 'class' => '', + 'class' => '', 'blog_id' => $GLOBALS['blog_id'] ); - + wp_dropdown_users( $args ); ?>

Next click to insert the author

Now choose a license + ?> +

'. __('Add license') .''; - + return $context . $result; } @@ -451,7 +451,7 @@ function openattribute_register() { add_option('openattribute_indexsingle',0); add_option('openattribute_postsonly',0); add_option('openattribute_postsonly',0); - + } function openattribute_options_page() { @@ -463,14 +463,14 @@ function openattribute_options_page() {

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

-

Attribution appearance settings

Here you can set settings for the plugin, these settings can be changed at anytime.

Choosing how the visitor sees the attribution
@@ -500,7 +500,7 @@ function openattribute_options_page() {

As a link such as the one above. -

+


/> If this box is ticked, an Open Attribute "Attribute Me" button will appear on all attributed resources (pages and posts)
@@ -556,60 +556,60 @@ function openattribute_options_page() {

Add Licenses

Please enter the licenses you wish to use below. The format for the license is "URL,text to display on screen". If you wish to use a custom license, perhaps create a page on your blog to hold your licensing info. By default you have been provided with some Creative Commons licenses.

- + + + ?>

Setup a site license

Choose a site license from this list - you can add new licenses in the box above

The current license is -

Choose an author name to display for this site
'', 'orderby' => 'display_name', @@ -618,23 +618,23 @@ function openattribute_options_page() { 'show' => 'display_name', 'name' => 'user', 'id' => 'user', - 'class' => '', + 'class' => '', 'blog_id' => $GLOBALS['blog_id'] ); - + wp_dropdown_users( $args ); - + ?>or enter a name

-

Do you wish to use a URL for this author (called an attribution url)" type="text" size="50" name="oa_url" />

/> If this box is ticked, the author of the page / post will be attributed.

@@ -643,184 +643,184 @@ function openattribute_options_page() {

- + "; - + } - + } function openattribute_add_disable_menu($output){ 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"); - + } - + } 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'); - + $display_first = false; - + if(is_home()&&$indexposts){ - + if(is_single()){ - + $display_first = true; - + }else if($indexsingle){ - + $display_first = true; - + } - + }else if(is_page()&&$postsonly){ - + $display_first = true; - + }else if(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]==""){ - + $display = true; - + if(get_option('openattribute_blogoverride')==1){ - + $author = explode("oaauthor",$output); $title = explode("oatitle",$output); - $oashorthand = explode("oalicense",$output); - + $oashorthand = explode("oalicense",$output); + if(count($author)!=1){ - + $display = false; - + } - + if(count($title)!=1){ - + $display = false; - + } - + if(count($oashorthand)!=1){ - + $display = false; - + } - + } - + if($display_first){ - - $author = get_option('openattribute_site_author'); + + $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)){ - + $site_license_url = $pair[0]; - + } - + } - + $license_data .= stripslashes(get_option('openattribute_pre_license_html')); - + if(get_option('openattribute_buttonset')==1){ - + $license_data .= '
'; - + if(get_option("openattribute_altlink")!=""){ $license_data .= ''; }else{ $license_data .= ''; } $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; } @@ -1035,136 +1035,136 @@ function openattribute_add_license_content($output){ 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'); - + $display_first = false; - + if(is_home()&&$indexposts){ - + if(is_single()){ - + $display_first = true; - + }else if($indexsingle){ - + $display_first = true; - + } - + }else if(is_page()&&$postsonly){ - + $display_first = true; - + }else if(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]==""){ - + $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); - + $oashorthand = explode("oashorthand",$content); + if(count($author)!=1){ - + $display = false; - + } - + if(count($title)!=1){ - + $display = false; - + } - + if(count($oashorthand)!=1){ - + $display = false; - + } - + } - + if($display){ - + get_option('openattribute_buttonset'); - $author = get_option('openattribute_site_author'); + $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)){ - + $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 .= '
'; - + if(get_option("openattribute_altlink")!=""){ $license_data .= ''; }else{ $license_data .= ''; } $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; - + } - + } - + } - + } - + } } @@ -1176,70 +1176,70 @@ function openattribute_add_license_header(){ $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()){ - + $display_first = true; - + }else if($indexsingle){ - + $display_first = true; - + } - + }else if(is_page()&&$postsonly){ - + $display_first = true; - + }else if(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($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'); + + $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)){ - + $site_license_url = $pair[0]; - + } - + } - + if($display_first){ - + echo ''; - + echo ' }'; + if(!isset($site_attribution_url)){ - + $site_attribution_url = site_url(); - + } - + if(!isset($site_license_url)){ - + $site_license_url = $site_license; - + } - + $license_data = ''; - + echo $license_data; - + } - + } - + } - + } - + } - + } } @@ -1302,7 +1302,7 @@ function openattribute_rdf_ns(){ if(get_option('openattribute_site_license')!=""){ echo 'xmlns:cc="http://creativecommons.org/ns#" '; - + } } @@ -1310,35 +1310,35 @@ function openattribute_rdf_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') . ''; - + } } @@ -1346,127 +1346,127 @@ function openattribute_rss2_head(){ function openattribute_atom_head() { 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{ $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); - + $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); - + $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 ' '; - + + echo ' '; + } - + function openattribute_widget(){ register_widget('OpenAttributeWidget'); - + } // Modifications to feeds @@ -1519,12 +1519,7 @@ function openattribute_widget(){ add_action('wp_head', 'openattribute_stylesheet'); // Load the Widget code - -include "openattribute_widget.php"; +include 'class-open-attribute-widget.php'; // Widget register - add_action('widgets_init', 'openattribute_widget'); - - -?> From 7c388603a24fbf42d056a8139de90d3b90bfbd72 Mon Sep 17 00:00:00 2001 From: sephster Date: Wed, 18 Jul 2018 11:20:51 +0100 Subject: [PATCH 08/28] Fix class name --- openattribute.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openattribute.php b/openattribute.php index 0a6174e..397f7e4 100644 --- a/openattribute.php +++ b/openattribute.php @@ -1464,9 +1464,7 @@ function openattribute_stylesheet(){ } function openattribute_widget(){ - - register_widget('OpenAttributeWidget'); - + register_widget('Open_Attribute_Widget'); } // Modifications to feeds From a3f5bd894517e8487c4a0916e2ff97c35384ec45 Mon Sep 17 00:00:00 2001 From: sephster Date: Wed, 18 Jul 2018 11:21:24 +0100 Subject: [PATCH 09/28] Apply coding standard fixes --- openattribute.php | 1247 ++++++++++++++++++++++----------------------- 1 file changed, 619 insertions(+), 628 deletions(-) diff --git a/openattribute.php b/openattribute.php index 397f7e4..15c8e23 100644 --- a/openattribute.php +++ b/openattribute.php @@ -2,33 +2,33 @@ /* Plugin Name: Open Attribute Plugin URI: http://openattribute.com -OpenAttribute allows you to add licensing information to your Wordpress site and individual blogs. It places information into posts and RSS feeds as well as other user friendly features. +OpenAttribute allows you to add licensing information to your WordPress site and individual blogs. It places information into posts and RSS feeds as well as other user friendly features. Version: 1 Author: OpenAttribute, pgogy Author URI: http://openattribute.com */ -function openattribute_firstrun(){ +function openattribute_firstrun() { - if(get_option('openattribute_firstrun')=='1'){ + if ( get_option( 'openattribute_firstrun' ) == '1' ) { echo "
"; - echo "

Information on OpenAttribute

"; + echo '

Information on OpenAttribute

'; - echo "

Thanks for installing OpenAttribute. You can find out about how to use our wordpress plugin on our OpenAttribute site, where we also have browser plugins.

"; + echo '

Thanks for installing OpenAttribute. You can find out about how to use our wordpress plugin on our OpenAttribute site, where we also have browser plugins.

'; - echo "

If you'd like to get started straight away - either go to OpenAttribute settings page or start a new blog post and look for the symbol below.

"; + echo "

If you'd like to get started straight away - either go to OpenAttribute settings page or start a new blog post and look for the symbol below.

"; - echo "

"; + echo '

'; - echo "

You can turn this screen off on the OpenAttribute settings page

"; + echo '

You can turn this screen off on the OpenAttribute settings page

'; - echo "
"; + echo '
'; - update_option('openattribute_firstrun', 0); + update_option( 'openattribute_firstrun', 0 ); - } + } } @@ -151,13 +151,13 @@ function insert() { license_url = document.getElementById('license_oa').options[document.getElementById('license_oa').selectedIndex].getAttribute("license_value"); license_shorthand = document.getElementById('license_oa').options[document.getElementById('license_oa').selectedIndex].text; - title = document.getElementById("title_oa").value; - attribution_url = document.getElementById("url_oa").value; - author = document.getElementById("author_oa").value; + title = document.getElementById("title_oa").value; + attribution_url = document.getElementById("url_oa").value; + author = document.getElementById("author_oa").value; - if((current_oashorthand!="")||(current_attribution_url!="")||(current_title!="")||(current_author!="")){ + if((current_oashorthand!="")||(current_attribution_url!="")||(current_title!="")||(current_author!="")){ - var data_drop = win.document.getElementById('content_ifr'); + var data_drop = win.document.getElementById('content_ifr'); if(data_drop==null){ @@ -169,65 +169,67 @@ function insert() { } - string = data; + string = data; - string = string.split('>' + current_title + '').join(' xmlns:dc="http://purl.org/dc/terms/" property="dc:title">' + title + ''); + string = string.split('>' + current_title + '').join(' xmlns:dc="http://purl.org/dc/terms/" property="dc:title">' + title + ''); - string = string.split('xmlns:cc="http://creativecommons.org/ns#" href="' + current_attribution_url).join('xmlns:cc="http://creativecommons.org/ns#" href="' + attribution_url); - string = string.split(' oaauthor="' + current_author + '">' + current_author + '').join(' oaauthor="' + author + '">' + author + ''); - string = string.split('rel="license" href="' + current_oalicenseurl + '">').join('rel="license" href="' + license_url + '">'); - string = string.split(current_oashorthand + '').join(license_shorthand + ''); + string = string.split('xmlns:cc="http://creativecommons.org/ns#" href="' + current_attribution_url).join('xmlns:cc="http://creativecommons.org/ns#" href="' + attribution_url); + string = string.split(' oaauthor="' + current_author + '">' + current_author + '').join(' oaauthor="' + author + '">' + author + ''); + string = string.split('rel="license" href="' + current_oalicenseurl + '">').join('rel="license" href="' + license_url + '">'); + string = string.split(current_oashorthand + '').join(license_shorthand + ''); - }else{ + }else{ - string = ' ' + title + '' - string += ' by ' + author + ''; - string += ' is licensed under a ' + license_shorthand + '.
'; - string += ' Based on a work at .'; + string = ' ' + title + '' + string += ' by ' + author + ''; + string += ' is licensed under a ' + license_shorthand + '.
'; + string += ' Based on a work at .'; - } + } - win.send_to_editor('' + string + ''); + win.send_to_editor('' + string + ''); - return true; + return true; - } + } - function insert_author(){ + function insert_author(){ - document.getElementById("author_oa").value = document.getElementById('user').options[document.getElementById('user').selectedIndex].text; - document.getElementById("url_oa").value = "/?author=" + document.getElementById('user').selectedIndex; + document.getElementById("author_oa").value = document.getElementById('user').options[document.getElementById('user').selectedIndex].text; + document.getElementById("url_oa").value = "/?author=" + document.getElementById('user').selectedIndex; - } + } - - openattribute_iframe.css' type='text/css' media='all' /> + + openattribute_iframe.css' type='text/css' media='all' />
-

Adding licensing to your blog post

-

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'] +

Adding licensing to your blog post

+

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 ); ?>

Next click to insert the author

+ wp_dropdown_users( $args ); + ?> +

Next click to insert the author

'; + echo ' }'; - if(!isset($site_attribution_url)){ + if ( ! isset( $site_attribution_url ) ) { $site_attribution_url = site_url(); } - if(!isset($site_license_url)){ + if ( ! isset( $site_license_url ) ) { $site_license_url = $site_license; } - $license_data = ''; + $license_data .= ' @ ' . $site_attribution_url; - echo $license_data; + } - } + $license_data .= ' is licensed under a ' . $site_license . '

Close

'; - } + 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#" '; @@ -1307,200 +1304,194 @@ function openattribute_rdf_ns(){ } -function openattribute_rdf_head(){ +function openattribute_rdf_head() { - if(get_option('openattribute_site_license')!=""){ + if ( get_option( 'openattribute_site_license' ) != '' ) { - echo ''; + echo ''; - } + } } -function openattribute_rss2_head(){ +function openattribute_rss2_head() { - if(get_option('openattribute_site_license')!=""){ + if ( get_option( 'openattribute_site_license' ) != '' ) { - echo '' . get_option('openattribute_site_license') . ''; - echo '' . 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')!=""){ + if ( get_option( 'openattribute_site_license' ) != '' ) { - echo ''; + echo ''; - } + } } -function openattribute_augment_feed($content) { +function openattribute_augment_feed( $content ) { - if(get_option('openattribute_site_license')!=""){ + if ( get_option( 'openattribute_site_license' ) != '' ) { - if(get_option('openattribute_blogoverride')==0){ + if ( get_option( 'openattribute_blogoverride' ) == 0 ) { - echo '' . get_option('openattribute_site_license') . ''; - echo '' . get_option('openattribute_site_license') . ''; + echo '' . get_option( 'openattribute_site_license' ) . ''; + echo '' . get_option( 'openattribute_site_license' ) . ''; - }else{ + } else { - $display = true; + $display = true; - $content = $wp_query->post->post_content; + $content = $wp_query->post->post_content; - if(get_option('openattribute_blogoverride')==1){ + if ( get_option( 'openattribute_blogoverride' ) == 1 ) { - $author = explode("oaauthor",$content); - $title = explode("oatitle",$content); - $oashorthand = explode("oashorthand",$content); + $author = explode( 'oaauthor', $content ); + $title = explode( 'oatitle', $content ); + $oashorthand = explode( 'oashorthand', $content ); - if(count($author)!=1){ + if ( count( $author ) != 1 ) { - $display = false; + $display = false; - } - - if(count($title)!=1){ + } - $display = false; + if ( count( $title ) != 1 ) { - } + $display = false; - if(count($oashorthand)!=1){ + } - $display = false; + if ( count( $oashorthand ) != 1 ) { - } + $display = false; - if($display){ + } - $data=explode("oalicenseurl=\"",$content); + if ( $display ) { - if(count($data)!=1){ + $data = explode( 'oalicenseurl="', $content ); - $license = explode("\"",$data[0]); + if ( count( $data ) != 1 ) { - echo '' . $license[0] . ''; - echo '' . $license[0] . ''; + $license = explode( '"', $data[0] ); - } + echo '' . $license[0] . ''; + echo '' . $license[0] . ''; } - } + } + } + } else { - } - - }else{ - - $content = $wp_query->post->post_content; - $display = true; - - $author = explode("oaauthor",$content); - $title = explode("oatitle",$content); - $oashorthand = explode("oashorthand",$content); + $content = $wp_query->post->post_content; + $display = true; - if(count($author)!=1){ + $author = explode( 'oaauthor', $content ); + $title = explode( 'oatitle', $content ); + $oashorthand = explode( 'oashorthand', $content ); - $display = false; + if ( count( $author ) != 1 ) { - } + $display = false; - if(count($title)!=1){ + } - $display = false; + if ( count( $title ) != 1 ) { - } + $display = false; - if(count($oashorthand)!=1){ + } - $display = false; + if ( count( $oashorthand ) != 1 ) { - } + $display = false; - if($display){ + } - $data=explode("oalicenseurl=\"",$content); + if ( $display ) { - if(count($data)!=1){ + $data = explode( 'oalicenseurl="', $content ); - $license = explode("\"",$data[0]); + if ( count( $data ) != 1 ) { - echo '' . $license[0] . ''; - echo '' . $license[0] . ''; + $license = explode( '"', $data[0] ); - } + echo '' . $license[0] . ''; + echo '' . $license[0] . ''; } - } - } - function openattribute_stylesheet(){ +} - echo ' '; +function openattribute_stylesheet() { - } + echo ' '; - function openattribute_widget(){ - register_widget('Open_Attribute_Widget'); - } +} + +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 @@ -1510,14 +1501,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 'class-open-attribute-widget.php'; +require 'class-open-attribute-widget.php'; // Widget register -add_action('widgets_init', 'openattribute_widget'); +add_action( 'widgets_init', 'openattribute_widget' ); From efe00962c5dc63eefd2b1fd8edd2983a4069b49a Mon Sep 17 00:00:00 2001 From: sephster Date: Wed, 18 Jul 2018 14:58:43 +0100 Subject: [PATCH 10/28] Fix calling of old constructor --- class-open-attribute-widget.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class-open-attribute-widget.php b/class-open-attribute-widget.php index 31fc1d1..d101117 100644 --- a/class-open-attribute-widget.php +++ b/class-open-attribute-widget.php @@ -3,7 +3,7 @@ class Open_Attribute_Widget extends WP_Widget { public function __construct() { - $this->WP_Widget( + parent::__construct( 'openattribute_widget', 'OpenAttribute Widget', [ From 846b69f1f068a70d8ec0eaab7e839902719af4bc Mon Sep 17 00:00:00 2001 From: sephster Date: Wed, 18 Jul 2018 17:42:12 +0100 Subject: [PATCH 11/28] Fix a bug where we were accessing an undefined index --- openattribute.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/openattribute.php b/openattribute.php index 15c8e23..cdaa02d 100644 --- a/openattribute.php +++ b/openattribute.php @@ -612,7 +612,7 @@ function openattribute_options_page() { } ?> -

The current license is - +

The current license is - Date: Wed, 18 Jul 2018 17:45:43 +0100 Subject: [PATCH 12/28] Fix access of undefined index bug --- openattribute.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/openattribute.php b/openattribute.php index cdaa02d..f4c1260 100644 --- a/openattribute.php +++ b/openattribute.php @@ -877,27 +877,19 @@ function openattribute_save_post( $post_id ) { } function openattribute_disable_menu() { + wp_nonce_field( plugin_basename( __FILE__ ), 'openattribute_noncename' ); - wp_nonce_field( plugin_basename( __FILE__ ), 'openattribute_noncename' ); - - $meta = get_post_meta( $_GET['post'], 'disable_license' ); - - if ( $meta[0] == 'on' ) { + $disable_license = get_post_meta( $_GET['post'], 'disable_license', true ); + if ( 'on' === $disable_license ) { $checked = 'checked'; - } else { - $checked = ''; - } - if ( ( get_option( 'openattribute_disable' ) == 1 ) || ( $meta[0] == 'on' ) ) { - + if ( ( 1 == get_option( 'openattribute_disable' ) ) || ( 'on' === $disable_license ) ) { echo "To disable attribution for this post please tick this box "; - } - } function openattribute_add_disable_menu( $output ) { @@ -905,7 +897,7 @@ function openattribute_add_disable_menu( $output ) { add_meta_box( 'openattribute_id', 'OpenAttribute', 'openattribute_disable_menu', 'post', 'normal', 'high' ); } - $disable_license = get_post_meta( $_GET['post'], 'disable_license', true ); + $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' ); From 0b562270abba181b9ab4ca37560b13c78d53cd9c Mon Sep 17 00:00:00 2001 From: sephster Date: Wed, 18 Jul 2018 17:52:14 +0100 Subject: [PATCH 13/28] Fix access to non-existent post value --- openattribute.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/openattribute.php b/openattribute.php index f4c1260..8465762 100644 --- a/openattribute.php +++ b/openattribute.php @@ -864,16 +864,11 @@ function openattribute_save_post( $post_id ) { } } - if ( $_POST['disable_license'] == 'on' ) { - + 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_disable_menu() { From 28fe3557d1e4aef1b22e7487d6ae446a4afe196d Mon Sep 17 00:00:00 2001 From: sephster Date: Wed, 18 Jul 2018 18:03:00 +0100 Subject: [PATCH 14/28] Change plugin directory to be openattribute --- openattribute.php | 10 +++++----- readme.txt | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openattribute.php b/openattribute.php index 8465762..4cc3a98 100644 --- a/openattribute.php +++ b/openattribute.php @@ -203,9 +203,9 @@ function insert_author(){ } - openattribute_iframe.css' type='text/css' media='all' /> + openattribute_iframe.css' type='text/css' media='all' />

- +

Adding licensing to your blog post

Choose the author for this blog '; } else { - $license_data .= ''; + $license_data .= ''; } $license_data .= '

'; @@ -1132,7 +1132,7 @@ function openattribute_add_license_footer( $content ) { if ( get_option( 'openattribute_altlink' ) != '' ) { $license_data .= ''; } else { - $license_data .= ''; + $license_data .= ''; } $license_data .= '
'; @@ -1431,7 +1431,7 @@ function openattribute_augment_feed( $content ) { function openattribute_stylesheet() { - echo ' '; + echo ' '; } diff --git a/readme.txt b/readme.txt index cbc6920..0f5d290 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Requires at least: 3.0.0 Tested up to: 4.3 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,7 +19,7 @@ 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. @@ -72,4 +72,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 From 6c522537f382575ae163c5f234ff9703ebc5c225 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 13:38:38 +0100 Subject: [PATCH 15/28] Fix issue with undefined variable being called --- openattribute.php | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/openattribute.php b/openattribute.php index 4cc3a98..771ab7f 100644 --- a/openattribute.php +++ b/openattribute.php @@ -1156,9 +1156,10 @@ function openattribute_add_license_footer( $content ) { } function openattribute_add_license_header() { - global $post; + $disable = null; + $indexposts = get_option( 'openattribute_index' ); $indexsingle = get_option( 'openattribute_indexsingle' ); $postsonly = get_option( 'openattribute_postsonly' ); @@ -1166,44 +1167,28 @@ function openattribute_add_license_header() { $display_first = false; if ( is_home() && $indexposts ) { - if ( is_single() ) { - $display_first = true; - } elseif ( $indexsingle ) { - $display_first = true; - } } elseif ( is_page() && $postsonly ) { - $display_first = true; - } 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] == '' ) { - + if ( isset( $_GET['page_id'] ) ) { $disable = get_post_meta( $_GET['page_id'], 'disable_license' ); - } 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' ); @@ -1212,18 +1197,14 @@ function openattribute_add_license_header() { $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 ) { - echo ''; if ( ! isset( $site_attribution_url ) ) { - $site_attribution_url = site_url(); - } if ( ! isset( $site_license_url ) ) { - $site_license_url = $site_license; - } $license_data = ''; echo $license_data; - } } } } } } - } function openattribute_rdf_ns() { From 1cc64c7cb401b183b5892effafeb80e2df5cac44 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 13:46:32 +0100 Subject: [PATCH 16/28] Initialise the site license URL --- openattribute.php | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/openattribute.php b/openattribute.php index 771ab7f..ea80f8d 100644 --- a/openattribute.php +++ b/openattribute.php @@ -900,104 +900,78 @@ function openattribute_add_disable_menu( $output ) { } 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' ); + $site_license_url = ''; + $display_first = false; if ( is_home() && $indexposts ) { - if ( is_single() ) { - $display_first = true; - } elseif ( $indexsingle ) { - $display_first = true; - } } elseif ( is_page() && $postsonly ) { - $display_first = true; - } 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] == '' ) { - $display = true; 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 ) { - $display = false; - } 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' ); - } $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]; - } } - $license_data .= stripslashes( get_option( 'openattribute_pre_license_html' ) ); + $license_data = stripslashes( get_option( 'openattribute_pre_license_html' ) ); if ( get_option( 'openattribute_buttonset' ) == 1 ) { - $license_data .= '
'; if ( get_option( 'openattribute_altlink' ) != '' ) { @@ -1005,8 +979,8 @@ function openattribute_add_license_content( $output ) { } else { $license_data .= ''; } - $license_data .= '
'; + $license_data .= '
'; } $license_data .= '' . the_title( '', '', 0 ) . ' / ' . get_bloginfo( 'name' ) . ''; @@ -1015,7 +989,6 @@ function openattribute_add_license_content( $output ) { $license_data .= get_option( 'openattribute_post_license_html' ); $output .= $license_data; - } } } From 33be017351cfe30dd4faa5de98666467b5969791 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 14:14:27 +0100 Subject: [PATCH 17/28] Fix checkbox for widget which return on, not true --- class-open-attribute-widget.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class-open-attribute-widget.php b/class-open-attribute-widget.php index d101117..7f555ab 100644 --- a/class-open-attribute-widget.php +++ b/class-open-attribute-widget.php @@ -95,7 +95,7 @@ public function form( $instance ) {

Tick the respective box if you wish the following to appear in this widget:

'; } else { echo ' />'; @@ -104,7 +104,7 @@ public function form( $instance ) {
'; } else { echo ' />'; From 072a993ab9decd0c319f135bdbc6394e0dfface9 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 14:34:57 +0100 Subject: [PATCH 18/28] Change incorrect constant to a string --- openattribute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openattribute.php b/openattribute.php index ea80f8d..fb0d778 100644 --- a/openattribute.php +++ b/openattribute.php @@ -466,7 +466,7 @@ function openattribute_options_page() {

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

-
+ Date: Thu, 19 Jul 2018 14:47:31 +0100 Subject: [PATCH 19/28] Fix accessing of undefined indexes --- openattribute.php | 85 +++++------------------------------------------ 1 file changed, 8 insertions(+), 77 deletions(-) diff --git a/openattribute.php b/openattribute.php index fb0d778..9ca11a2 100644 --- a/openattribute.php +++ b/openattribute.php @@ -466,7 +466,7 @@ function openattribute_options_page() {

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

- + Date: Thu, 19 Jul 2018 14:56:37 +0100 Subject: [PATCH 20/28] Fix access to undefined index --- openattribute.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openattribute.php b/openattribute.php index 9ca11a2..676bb30 100644 --- a/openattribute.php +++ b/openattribute.php @@ -895,7 +895,7 @@ function openattribute_add_license_content( $output ) { while ( $license = array_shift( $data_licenses ) ) { $pair = explode( ',', $license ); - if ( trim( $pair[1] ) == trim( $site_license ) ) { + if ( isset( $pair[1] ) && trim( $pair[1] ) == trim( $site_license ) ) { $site_license_url = $pair[0]; } } @@ -1103,7 +1103,7 @@ function openattribute_add_license_header() { while ( $license = array_shift( $data_licenses ) ) { $pair = explode( ',', $license ); - if ( trim( $pair[1] ) == trim( $site_license ) ) { + if ( isset( $pair[1] ) && trim( $pair[1] ) == trim( $site_license ) ) { $site_license_url = $pair[0]; } } From 0e712076cea731e0b3b9abea3497b147972ab3d6 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 15:12:39 +0100 Subject: [PATCH 21/28] Fix access to undefined post variables --- openattribute.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/openattribute.php b/openattribute.php index 676bb30..60fb262 100644 --- a/openattribute.php +++ b/openattribute.php @@ -777,7 +777,7 @@ function openattribute_menu_option() { function openattribute_save_post( $post_id ) { - if ( ! wp_verify_nonce( $_POST['openattribute_noncename'], plugin_basename( __FILE__ ) ) ) { + if ( isset( $_POST['openattribute_noncename'] ) && ! wp_verify_nonce( $_POST['openattribute_noncename'], plugin_basename( __FILE__ ) ) ) { return $post_id; } @@ -785,7 +785,7 @@ function openattribute_save_post( $post_id ) { return $post_id; } - if ( 'page' == $_POST['post_type'] ) { + if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return $post_id; } @@ -803,9 +803,13 @@ function openattribute_save_post( $post_id ) { } function openattribute_disable_menu() { + $disable_license = null; + wp_nonce_field( plugin_basename( __FILE__ ), 'openattribute_noncename' ); - $disable_license = get_post_meta( $_GET['post'], 'disable_license', true ); + if ( isset( $_GET['post'] ) ) { + $disable_license = get_post_meta( $_GET['post'], 'disable_license', true ); + } if ( 'on' === $disable_license ) { $checked = 'checked'; @@ -819,11 +823,15 @@ function openattribute_disable_menu() { } 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' ); } - $disable_license = get_post_meta( $_GET['post'], 'disable_license', true ); + 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' ); From a1dacbe6fc5b7c21ffe1f00ef61a5ccb486f63fb Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 15:44:11 +0100 Subject: [PATCH 22/28] Fixing blank spaces added to form fields --- openattribute.php | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/openattribute.php b/openattribute.php index 60fb262..fae0df7 100644 --- a/openattribute.php +++ b/openattribute.php @@ -565,24 +565,19 @@ function openattribute_options_page() { +

Setup a site license

Choose a site license from this list - you can add new licenses in the box above

-

Do you wish to use a URL for this author (called an attribution url)

+ or enter a name

+

Do you wish to use a URL for this author (called an attribution url)

/> If this box is ticked, the author of the page / post will be attributed.

@@ -1131,11 +1111,11 @@ function openattribute_add_license_header() { echo ' document.getElementById("openattribute_license_holder").style.display = "block";'; echo ' }'; - if ( ! isset( $site_attribution_url ) ) { + 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; } From 316452053630709e445b1aca5e1856ffabd9e253 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 16:06:36 +0100 Subject: [PATCH 23/28] Fix accessing undefined index --- openattribute.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openattribute.php b/openattribute.php index fae0df7..756c438 100644 --- a/openattribute.php +++ b/openattribute.php @@ -1015,7 +1015,7 @@ function openattribute_add_license_footer( $content ) { if ( $display_first ) { - $license_data .= stripslashes( get_option( 'openattribute_pre_license_html' ) ); + $license_data = stripslashes( get_option( 'openattribute_pre_license_html' ) ); if ( get_option( 'openattribute_buttonset' ) == 1 ) { @@ -1035,7 +1035,7 @@ function openattribute_add_license_footer( $content ) { $license_data .= ' is licensed under a ' . $site_license . ''; $license_data .= get_option( 'openattribute_post_license_html' ); - $output .= $license_data; + $output = $license_data; echo $output; From 4784f82ea9b5d4a44d22fe662dcadd2fc9807cb8 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 16:10:54 +0100 Subject: [PATCH 24/28] Fix incorrect escaping of html elements --- class-open-attribute-widget.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/class-open-attribute-widget.php b/class-open-attribute-widget.php index 7f555ab..0966533 100644 --- a/class-open-attribute-widget.php +++ b/class-open-attribute-widget.php @@ -50,10 +50,10 @@ public function widget( $args, $instance ) { } if ( $display ) { - echo esc_html( $args['before_widget'] ); - echo esc_html( $args['before_title'] ); + echo $args['before_widget']; + echo $args['before_title']; echo 'Attribute me'; - echo esc_html( $args['after_title'] ); + echo $args['after_title']; if ( $instance['openattribute_image'] ) { echo ''; @@ -63,7 +63,7 @@ public function widget( $args, $instance ) { echo 'Attribute this resource'; } - echo esc_html( $args['after_widget'] ); + echo $args['after_widget']; } } } From 2aae8929f3af96f63c91ccb912f026a6523ccbe1 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 16:23:58 +0100 Subject: [PATCH 25/28] Added support for the customizer --- class-open-attribute-widget.php | 1 + 1 file changed, 1 insertion(+) diff --git a/class-open-attribute-widget.php b/class-open-attribute-widget.php index 0966533..0604d98 100644 --- a/class-open-attribute-widget.php +++ b/class-open-attribute-widget.php @@ -9,6 +9,7 @@ public function __construct() { [ 'classname' => 'OpenAttribute Widget', 'description' => 'Display a a license for your blog post or entire site in a widget', + 'customize_selective_refresh' => true, ], '' ); From d763dd46c62a147f3eebf1c2069b4c03e1c31608 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 16:31:34 +0100 Subject: [PATCH 26/28] Update version number --- class-open-attribute-widget.php | 8 ++++---- openattribute.php | 31 ++++++++++++++++++------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/class-open-attribute-widget.php b/class-open-attribute-widget.php index 0604d98..465a223 100644 --- a/class-open-attribute-widget.php +++ b/class-open-attribute-widget.php @@ -3,13 +3,13 @@ class Open_Attribute_Widget extends WP_Widget { public function __construct() { - parent::__construct( + parent::__construct( 'openattribute_widget', 'OpenAttribute Widget', [ - 'classname' => 'OpenAttribute Widget', - 'description' => 'Display a a license for your blog post or entire site in a widget', - 'customize_selective_refresh' => true, + 'classname' => 'OpenAttribute Widget', + 'description' => 'Display a a license for your blog post or entire site in a widget', + 'customize_selective_refresh' => true, ], '' ); diff --git a/openattribute.php b/openattribute.php index 756c438..398c8dc 100644 --- a/openattribute.php +++ b/openattribute.php @@ -3,7 +3,7 @@ Plugin Name: Open Attribute Plugin URI: http://openattribute.com OpenAttribute allows you to add licensing information to your WordPress site and individual blogs. It places information into posts and RSS feeds as well as other user friendly features. -Version: 1 +Version: 1.0.1 Author: OpenAttribute, pgogy Author URI: http://openattribute.com */ @@ -565,7 +565,7 @@ function openattribute_options_page() { +

Setup a site license

Choose a site license from this list - you can add new licenses in the box above

-

Do you wish to use a URL for this author (called an attribution url)

+

Do you wish to use a URL for this author (called an attribution url)

/> If this box is ticked, the author of the page / post will be attributed.

@@ -783,13 +788,13 @@ function openattribute_save_post( $post_id ) { } function openattribute_disable_menu() { - $disable_license = null; + $disable_license = null; wp_nonce_field( plugin_basename( __FILE__ ), 'openattribute_noncename' ); - if ( isset( $_GET['post'] ) ) { - $disable_license = get_post_meta( $_GET['post'], 'disable_license', true ); - } + if ( isset( $_GET['post'] ) ) { + $disable_license = get_post_meta( $_GET['post'], 'disable_license', true ); + } if ( 'on' === $disable_license ) { $checked = 'checked'; @@ -803,15 +808,15 @@ function openattribute_disable_menu() { } function openattribute_add_disable_menu( $output ) { - $disable_license = null; + $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 ( 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' ); From 0155a1dcc4d80baa292bd2a71f2ec039b4c672b1 Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 16:36:01 +0100 Subject: [PATCH 27/28] Updates to the readme and version number --- openattribute.php | 2 +- readme.txt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openattribute.php b/openattribute.php index 398c8dc..77f6478 100644 --- a/openattribute.php +++ b/openattribute.php @@ -3,7 +3,7 @@ Plugin Name: Open Attribute Plugin URI: http://openattribute.com OpenAttribute allows you to add licensing information to your WordPress site and individual blogs. It places information into posts and RSS feeds as well as other user friendly features. -Version: 1.0.1 +Version: 1.1.0 Author: OpenAttribute, pgogy Author URI: http://openattribute.com */ diff --git a/readme.txt b/readme.txt index 0f5d290..9a96e56 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ 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. @@ -25,6 +25,11 @@ e.g. == 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 + = 1 = Fixed licence listing bug. Thanks to Phil Barker From 226aa0d6a6213a15f6296ba8fa5d4c3b015cdd4d Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 19 Jul 2018 16:44:41 +0100 Subject: [PATCH 28/28] Further updates to readme to clarify changes --- readme.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.txt b/readme.txt index 9a96e56..b5e6e87 100644 --- a/readme.txt +++ b/readme.txt @@ -29,6 +29,9 @@ e.g. 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