Skip to content

Commit

Permalink
Add a setting to enable attribution box.
Browse files Browse the repository at this point in the history
  • Loading branch information
rczajka committed Aug 21, 2020
1 parent a593cfd commit d6cd27d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 4 additions & 2 deletions includes/class-creativecommons-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,10 @@ public function init() {
* );
*/

add_filter( 'the_content', array( $this, 'add_attribution_boxes' ));
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_attribution_boxes' ));
if (get_option("enable_attribution_box")) {
add_filter( 'the_content', array( $this, 'add_attribution_boxes' ));
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_attribution_boxes' ));
}

add_shortcode(
'license',
Expand Down
25 changes: 24 additions & 1 deletion includes/class-creativecommons.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public function page_init() {
'license',
array( &$this, '_wrapper_settings_api_verify' )
);
register_setting(
'cc-admin',
'enable_attribution_box'
);
/**
* This section includes:
* License selector.
Expand Down Expand Up @@ -174,6 +178,18 @@ public function page_init() {
'license-attribution-settings',
array( 'label_for' => 'display_as' )
);

add_settings_field(
'enable_attribution_box',
__(
'Display attribution information for images',
'CreativeCommons'
),
array( &$this, 'enable_attribution_box' ),
'cc-admin',
'license-attribution-settings',
array( 'label_for' => 'enable_attribution_box' )
);
}


Expand Down Expand Up @@ -376,7 +392,14 @@ public function display_license_as() {

<?php
}


public function enable_attribution_box() {
$enabled = get_option("enable_attribution_box");
?>
<input name="enable_attribution_box" type="checkbox" value="true" <?php checked($enabled, 'true'); ?> />
<?php
}

/**
* Check if a site may override the network license.
*
Expand Down

0 comments on commit d6cd27d

Please sign in to comment.