Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

At http://wordpress.stackexchange.com Mike Schinkel answered one of my questions with huge lines of code that almost look like a Wordpress plugin:

<?php 
/*
if (!class_exists('YourSite_StaticContent')) {
  class YourSite_StaticContent {
    static function on_load() {
      add_action('init',array(__CLASS__,'init'));
      add_filter('manage_static_content_posts_columns',
          array(__CLASS__,'manage_static_content_posts_columns'));
      add_filter('manage_posts_custom_column', 
          array(__CLASS__,'manage_posts_custom_column'));
    }
    function manage_static_content_posts_columns($columns){
      $new = array();
      foreach($columns as $key => $title) {
        if ($key=='author') // Put the Sections column before the Author column
          $new['sections'] = 'Sections';
        $new[$key] = $title;
      }
      return $new;
    }
    static function manage_posts_custom_column($column){
      global $post;
      switch ($column) {
        case "sections":
          echo get_the_term_list($post->ID, 'section', '', ', ','');
          break;
      }
    }
    static function init() {
      register_post_type('static_content',array(
        'labels' => array(
          'name' => __( 'Static Content' ),
          'singular_name' => __( 'Static Content' ),
          'add_new_item' => 'Add New Static Content',
          'edit_item' => 'Edit Static Content',
          'new_item' => 'New Static Content',
          'search_items' => 'Search Static Content',
          'not_found' => 'No Static Content found',
          'not_found_in_trash' => 'No Static Content found in trash',
        ),
        'public' => true,
        'hierarchical' => false,
        'taxonomies' => array( 'section'),
        'supports' => array('title','editor','excerpt'),
        'rewrite' => array('slug'=>'static_content','with_front'=>false),
      ));
      register_taxonomy('section','static_content',array(
        'hierarchical' => true,
        'labels' => array(
          'name' => __( 'Section' ),
          'singular_name' => __( 'Section' ),
          'add_new_item' => 'Add New Section',
          'edit_item' => 'Edit Section',
          'new_item' => 'New Section',
          'search_items' => 'Search Section',
          'not_found' => 'No Sections found',
          'not_found_in_trash' => 'No Sections found in trash',
          'all_items' => __( 'All Sections' ),
        ),
        'query_var' => true,
        'rewrite' => array( 'slug' => 'section' ),
        ));
      if (!get_option('yoursite-static-content-initialized')) {
        $terms = array(
          'Footer',
          'Header',
          'Front Page Intro',
          'Front Page Content',
          );
        foreach($terms as $term) {
          if (!get_term_by('name',$term,'section')) {
            wp_insert_term($term, 'section');
          }
        }
        update_option('yoursite-static-content-initialized',true);
      }
    }
  }
  YourSite_StaticContent::on_load();
}

If it were you, would you add something like this at the beginning of the code?:

/* Static Content (Thanks to http://mikeschinkel.com/) */

or mention their his name in the GPL licence file (Thanks to...)

or not mention it at all?

share|improve this question
up vote 9 down vote accepted

You are legally obligated to do so under the CC-BY-SA license, however, the Stack Exchange community prefers that instead of copy/pasting the code, you learn from it and write your own code. If you do so, usually a nice credit is appreciated.

Does the license matter? It's not just boring legalese. The CC licenses are very important for Stack Exchange participants—it's a guarantee that you'll get credit for your contributions, a give-and-take relationship. So do please credit according to the attribution requirements, not just because it's legally required, but because it's morally responsible.

share|improve this answer
    
It is hard to tell. For instance, at which extent I can determine if the person who answers the question is just referencing widely used lines of code or his own's? – user143756 Feb 8 '11 at 7:36
    
@user143756 Well, it would have to be ubiquitous to not require credit—think of it this way: if it's more than 10 characters, you should probably credit. – waiwai933 Feb 8 '11 at 7:38
    
@user143756, if in doubt, you could always include the link to the question in your comment. – Benjol Feb 8 '11 at 10:33
    
Thanks, I will give credit then. – user143756 Feb 8 '11 at 14:53

I would at least give them some credit even it is on a different page or on a page that the code is on.

share|improve this answer

If you weigh "how much did you benefit from their contribution" against "how much does it cost to give them credit", I think the answer will become obvious.

share|improve this answer

I usually add a link in the code so I can refer to it later myself, as well as complying with the license:

/* Some or all of the following code is from 
   http://wordpress.stackexchange.com/questions/7492/how-to-show-the-taxonomy-assigned-to-a-post-in-the-table-where-all-the-posts-are 
   -additional notes as needed-
*/

However you may want to consult with a lawyer on the impact of the license on your code and business model. The share-alike clause may require some or all of your code to be shared under a similar license once you add this code to it. This particular intersection is explored elsewhere:

I'm worried about Stack Overflow content licensing

Is Stack Overflow's use of Creative Commons Attribution-Share Alike (cc-wiki) viral?

share|improve this answer

Yes, and I think that next to giving this person credits, I would also notify him/her that you are using (extracts of) his/her code.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .