Issues (2756)

user/plugins/sample-plugin/plugin.php (16 issues)

1
<?php
2
/*
0 ignored issues
show
Empty line required before block comment
Loading history...
3
Plugin Name: Sample Plugin
0 ignored issues
show
First line of comment not aligned correctly; expected 4 spaces but found 0
Loading history...
4
Plugin URI: http://yourls.org/
0 ignored issues
show
Comment line indented incorrectly; expected at least 4 spaces but found 0
Loading history...
5
Description: Sample plugin to illustrate how actions and filters work. Read its source. Refer to the <a href="http://yourls.org/pluginapi">Plugin API documentation</a> for more details.
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 185 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
Comment line indented incorrectly; expected at least 4 spaces but found 0
Loading history...
6
Version: 0.1
0 ignored issues
show
Comment line indented incorrectly; expected at least 4 spaces but found 0
Loading history...
7
Author: Ozh
0 ignored issues
show
Comment line indented incorrectly; expected at least 4 spaces but found 0
Loading history...
8
Author URI: http://ozh.org/
0 ignored issues
show
Comment line indented incorrectly; expected at least 4 spaces but found 0
Loading history...
9
*/
10
11
// No direct call
12
if( !defined( 'YOURLS_ABSPATH' ) ) die();
13
14
/* Example of an action
0 ignored issues
show
Block comment text must start on a new line
Loading history...
15
 *
16
 * We're going to add an entry to the menu.
17
 *
18
 * The menu is drawn by function yourls_html_menu() in file includes/functions-html.php.
19
 * Right before the function outputs the closing </ul>, notice the following function call:
20
 * yourls_do_action( 'admin_menu' );
21
 * This function says: "hey, for your information, I've just done something called 'admin menu', thought I'd let you know..."
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
22
 *
23
 * We're going to hook into this action and add our menu entry
24
 */
25
 
26
yourls_add_action( 'admin_menu', 'ozh_sample_add_menu' );
27
/* This says: when YOURLS does action 'admin_menu', call function 'ozh_sample_add_menu'
0 ignored issues
show
Block comment text must start on a new line
Loading history...
28
 */
29
30
function ozh_sample_add_menu() {
31
	echo '<li><a href="http://ozh.org/">Ozh</a></li>';
32
}
33
/* And that's it. Activate the plugin and notice the new menu entry.
0 ignored issues
show
Block comment text must start on a new line
Loading history...
34
 */
35
36
 
37
38
/* Example of a filter
0 ignored issues
show
Block comment text must start on a new line
Loading history...
39
 *
40
 * We're going to modify the <title> of pages in the admin area
41
 *
42
 * The <title> tag is generated by function yourls_html_head() in includes/functions-html.php
43
 * Notice the following function call:
44
 * $title = yourls_apply_filter( 'html_title', 'YOURLS: Your Own URL Shortener' );
45
 * This function means: give $title the value "YOURLS: Your Own URL Shortener", unless a
46
 * filter modifies this value.
47
 *
48
 * We're going to hook into this filter and modify this value.
49
 */
50
 
51
yourls_add_filter( 'html_title', 'ozh_sample_change_title' );
52
/* This says: when filter 'html_title' is triggered, send its value to function 'ozh_sample_change_title'
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 105 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
Block comment text must start on a new line
Loading history...
53
 * and use what this function will return.
54
 */
55
 
56
function ozh_sample_change_title( $value ) {
57
	$value = $value . ' -- the sample plugin is activated';
58
	return $value; // a filter *always* has to return a value
59
}
60
/* And that's it. Activate the plugin and notice how the page title changes */
0 ignored issues
show
Single line block comment not allowed; use inline ("// text") comment instead
Loading history...
61
62