Whether licensed under the SE-standard CC-By, or as many of us state, licensed under GPL, attribution is required when distributing that code.
For both CC-By and GPL, that required attribution must be appropriate for the medium of the work, and must include the copyright and license declaration of the original work.
For PHP code, the attribution method generally accepted as appropriate is a comment in the file header phpDoc block or function phpDoc block.
In either case (though I'll use the function docBloc as an example), the minimum-acceptable amount of information is a declaration that the code is - or is derived from - another work, along with the copyright and license declaration from the original, and a link to the full-text license terms.
It is also generally appropriate, though not necessarily required, to include a link to the source.
For example:
/**
* Some function that does something
*
* This function is derived from code posted on the
* WordPress Development StackExchange site. The
* original code is copyright (c) 2014 Chip Bennett, and
* is distributed under the terms of the Creative Commons
* CC-By-SA 3.0, and under the terms of the GPL, version 2.0 or later.
*
* @link http://wordpress.stackexchange.com/a/654321
*
* @link http://creativecommons.org/licenses/by-sa/3.0/
* @link http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
function wpse123456_some_function_name() {
// function code here
}
One concern I have, though, is that, unless a user clicks through to my WPSE profile, that user will likely never know that I dual-license my WPSE code, to ensure that it is distributable under GPL as well as the SE-standard CC-By-SA.
It would be nice if we could formally declare all WPSE code as dual-licensed under the SE-standard CC-By-SA, and GPL.
Edit: CC-By Attribution Requirements
To be clear, the CC-By terms for attribution are quite specific:
If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and (iv) , consistent with Ssection 3(b), in the case of an
Adaptation, a credit identifying the use of the Work in the Adaptation
(e.g., "French translation of the Work by Original Author," or
"Screenplay based on original Work by Original Author"). The credit
required by this Section 4(c) may be implemented in any reasonable
manner; provided, however, that in the case of a Adaptation or
Collection, at a minimum such credit will appear, if a credit for all
contributing authors of the Adaptation or Collection appears, then as
part of these credits and in a manner at least as prominent as the
credits for the other contributing authors. For the avoidance of
doubt, You may only use the credit required by this Section for the
purpose of attribution in the manner set out above and, by exercising
Your rights under this License, You may not implicitly or explicitly
assert or imply any connection with, sponsorship or endorsement by the
Original Author, Licensor and/or Attribution Parties, as appropriate,
of You or Your use of the Work, without the separate, express prior
written permission of the Original Author, Licensor and/or Attribution
Parties.
Broken down:
(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing:
- the name of the Original Author
- the title of the Work if supplied
- the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work;
- consistent with Ssection 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation
The relevant clause is (3):
- the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work
The attribution-required URI must be specific to the copyright notice or licensing information for the work. Otherwise, any specified URL falls outside the scope of the attribution clause of the license.
@link
for that.