The class CodeColorerLoader has 17 public methods. Consider refactoring CodeColorerLoader to keep number of public methods under 10. Open
class CodeColorerLoader
{
/**
* Enables the CodeColorer plugin with registering all required hooks.
*/
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Method enable
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function enable()
{
$path = dirname(__FILE__);
if (!file_exists("$path/codecolorer-core.php")) {
return false;
Avoid using static access to class 'CodeColorer' in method 'callBeforeProtectComment'. Open
$codecolorer = &CodeColorer::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CodeColorer' in method 'callBeforeHighlightCodeBlock'. Open
$codecolorer = &CodeColorer::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CodeColorer' in method 'callShowOptionsPage'. Open
$codecolorer = &CodeColorer::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CodeColorer' in method 'highlight'. Open
$codecolorer = &CodeColorer::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method addTinyMCEValidElements uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$init['extended_valid_elements'] = $ext;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'CodeColorerOptions' in method 'addTinyMCEValidElements'. Open
$knownOptions = CodeColorerOptions::parseOptions('');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CodeColorerLoader' in method 'codecolorer_highlight'. Open
return CodeColorerLoader::highlight($code);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CodeColorer' in method 'callShowGeshiWarning'. Open
$codecolorer = &CodeColorer::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CodeColorer' in method 'callAfterHighlightCodeBlock'. Open
$codecolorer = &CodeColorer::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CodeColorer' in method 'callAfterProtectComment'. Open
$codecolorer = &CodeColorer::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Call to undeclared function \add_filter()
Open
add_filter('the_excerpt', array('CodeColorerLoader', 'callAfterHighlightCodeBlock'), 1000);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('pre_comment_content', array('CodeColorerLoader', 'callBeforeProtectComment'), -1000);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('teeny_mce_before_init', array('CodeColorerLoader', 'addTinyMCEValidElements'));
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::addPluginOptionsPage()
Open
public static function addPluginOptionsPage()
- Exclude checks
Call to undeclared function \__()
(Did you mean _()) Open
$links[] = '<a href="https://kpumuk.info/projects/wordpress-plugins/codecolorer/#support">' . __('Support', 'codecolorer') . '</a>';
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::addTinyMCEValidElements()
Open
public static function addTinyMCEValidElements($init) {
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::callAfterHighlightCodeBlock()
Open
public static function callAfterHighlightCodeBlock($content)
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_css_class', '');
- Exclude checks
Call to undeclared function \add_action()
Open
add_action('admin_notices', array('CodeColorerLoader', 'callShowGeshiWarning'));
- Exclude checks
Call to undeclared function \add_action()
Open
add_action('wp_print_styles', array('CodeColorerLoader', 'loadStyles'));
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('sdm_downloads_description', array('CodeColorerLoader', 'callAfterHighlightCodeBlock'), 1000, 1);
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_css_style', '');
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::registerQuicktag()
Open
public static function registerQuicktag()
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_height', 300);
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_tab_size', 4);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('tablepress_cell_content', array('CodeColorerLoader', 'callBeforeHighlightCodeBlock'), -1000, 1);
- Exclude checks
Call to undeclared function \add_action()
Open
add_action('wp_print_scripts', array('CodeColorerLoader', 'registerQuicktag'));
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::loadStyles()
Open
public static function loadStyles()
- Exclude checks
Call to undeclared function \wp_register_style()
Open
wp_register_style('codecolorer', $cssUrl, array(), CODECOLORER_VERSION, 'screen');
- Exclude checks
Call to undeclared function \wp_enqueue_style()
Open
wp_enqueue_style('codecolorer');
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::callShowOptionsPage()
Open
public static function callShowOptionsPage()
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_width', 435);
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_line_numbers', false);
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_disable_keyword_linking', false);
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_inline_theme', '');
- Exclude checks
Call to undeclared function \add_action()
Open
add_action('admin_menu', array('CodeColorerLoader', 'addPluginOptionsPage'));
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_line_numbers', '');
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::callAfterProtectComment()
Open
public static function callAfterProtectComment($content)
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_language_notification', true);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('book_review', array('CodeColorerLoader', 'callBeforeHighlightCodeBlock'), -1000);
- Exclude checks
Call to undeclared function \load_plugin_textdomain()
Open
load_plugin_textdomain('codecolorer', false, "$pluginDir/languages");
- Exclude checks
Call to undeclared function \__()
(Did you mean _()) Open
$newLinks[] = '<a href="options-general.php?page=codecolorer.php">' . __('Settings', 'codecolorer') . '</a>';
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::addPluginLinks()
Open
public static function addPluginLinks($links, $file)
- Exclude checks
Call to undeclared function \wp_enqueue_script()
Open
wp_enqueue_script('codecolorer', $url, array('jquery'), CODECOLORER_VERSION, true);
- Exclude checks
Call to undeclared function \__()
(Did you mean _()) Open
'enterLanguage' => __('Enter Language')
- Exclude checks
Call to undeclared function \add_action()
Open
add_action('admin_print_styles', array('CodeColorerLoader', 'loadStyles'));
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_disable_keyword_linking', array('CodeColorerOptions', 'sanitizeBoolean'));
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_tab_size', 'intval');
- Exclude checks
Call to undeclared function \plugins_url()
Open
$cssUrl = plugins_url(basename(dirname(__FILE__)) . '/codecolorer.css');
- Exclude checks
Call to undeclared function \wp_script_is()
Open
if (!wp_script_is('quicktags')) {
- Exclude checks
Call to undeclared function \wp_strip_all_tags()
Open
$styles = trim(wp_strip_all_tags(get_option('codecolorer_css_style')));
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::addTinyMCEPlugin()
Open
public static function addTinyMCEPlugin($plugins)
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::callBeforeHighlightCodeBlock()
Open
public static function callBeforeHighlightCodeBlock($content)
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_rss_width', 435);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('the_content', array('CodeColorerLoader', 'callAfterHighlightCodeBlock'), 1000);
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_width', '');
- Exclude checks
Call to undeclared function \get_option()
Open
$styles = trim(wp_strip_all_tags(get_option('codecolorer_css_style')));
- Exclude checks
Call to undeclared function \__()
(Did you mean _()) Open
$links[] = '<a href="https://kpumuk.info/projects/wordpress-plugins/codecolorer/#faq">' . __('FAQ', 'codecolorer') . '</a>';
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_lines_to_scroll', 20);
- Exclude checks
Call to undeclared function \plugin_basename()
Open
add_action('plugin_action_links_' . plugin_basename(__FILE__), array('CodeColorerLoader', 'addPluginActions'));
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('the_excerpt', array('CodeColorerLoader', 'callBeforeHighlightCodeBlock'), -1000);
- Exclude checks
Call to undeclared function \add_options_page()
Open
add_options_page('CodeColorer', 'CodeColorer', 'manage_options', 'codecolorer.php', array('CodeColorerLoader', 'callShowOptionsPage'));
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::addPluginActions()
Open
public static function addPluginActions($links)
- Exclude checks
Call to undeclared function \wp_enqueue_script()
Open
wp_enqueue_script('jquery');
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::registerTinyMCEButton()
Open
public static function registerTinyMCEButton($buttons)
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::callShowGeshiWarning()
Open
public static function callShowGeshiWarning()
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_concurrent_notification', true);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('the_content', array('CodeColorerLoader', 'callBeforeHighlightCodeBlock'), -1000);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('pre_comment_content', array('CodeColorerLoader', 'callAfterProtectComment'), 1000);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('tablepress_cell_content', array('CodeColorerLoader', 'callAfterHighlightCodeBlock'), 1000, 1);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('sdm_downloads_description', array('CodeColorerLoader', 'callBeforeHighlightCodeBlock'), -1000, 1);
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_lines_to_scroll', 'intval');
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_inline_theme', '');
- Exclude checks
Call to undeclared function \plugins_url()
Open
$url = plugins_url(basename(dirname(__FILE__)) . '/js/quicktags.js');
- Exclude checks
Call to undeclared function \plugins_url()
Open
$url = plugins_url(basename(dirname(__FILE__)) . '/js/tinymce_plugin.js');
- Exclude checks
Possibly zero references to function \codecolorer_highlight()
Open
function codecolorer_highlight($code)
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('plugin_row_meta', array('CodeColorerLoader', 'addPluginLinks'), 10, 2);
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('book_review', array('CodeColorerLoader', 'callAfterHighlightCodeBlock'), 1000);
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_height', '');
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_rss_width', '');
- Exclude checks
Call to undeclared function \add_action()
Open
add_action('plugin_action_links_' . plugin_basename(__FILE__), array('CodeColorerLoader', 'addPluginActions'));
- Exclude checks
Call to undeclared function \add_action()
Open
add_action('admin_init', array('CodeColorerLoader', 'adminInit'));
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('tiny_mce_before_init', array('CodeColorerLoader', 'addTinyMCEValidElements'));
- Exclude checks
Call to undeclared function \is_admin()
Open
if (!is_admin()) {
- Exclude checks
Call to undeclared function \get_option()
Open
if (get_option('codecolorer_concurrent_notification')) {
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('comment_text', array('CodeColorerLoader', 'callBeforeHighlightCodeBlock'), -1000);
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_css_class', '');
- Exclude checks
Call to undeclared function \wp_localize_script()
Open
wp_localize_script(
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_theme', '');
- Exclude checks
Call to undeclared function \current_user_can()
Open
if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::callBeforeProtectComment()
Open
public static function callBeforeProtectComment($content)
- Exclude checks
Call to undeclared function \add_option()
Open
add_option('codecolorer_css_style', '');
- Exclude checks
Call to undeclared function \add_filter()
Open
add_filter('comment_text', array('CodeColorerLoader', 'callAfterHighlightCodeBlock'), 1000);
- Exclude checks
Possibly zero references to public method \CodeColorerLoader::adminInit()
Open
public static function adminInit()
- Exclude checks
Call to undeclared function \register_setting()
Open
register_setting('codecolorer', 'codecolorer_theme', '');
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class CodeColorerLoader
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 36 and the first side effect is on line 33. Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 305 characters Open
* Description: This plugin allows you to insert code snippets to your posts with nice syntax highlighting powered by <a href="http://qbnz.com/highlighter/">GeSHi</a> library. After enabling this plugin visit <a href="options-general.php?page=codecolorer.php">the options page</a> to configure code style.
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
register_setting('codecolorer', 'codecolorer_disable_keyword_linking', array('CodeColorerOptions', 'sanitizeBoolean'));
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
add_options_page('CodeColorer', 'CodeColorer', 'manage_options', 'codecolorer.php', array('CodeColorerLoader', 'callShowOptionsPage'));
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
$links[] = '<a href="https://kpumuk.info/projects/wordpress-plugins/codecolorer/#support">' . __('Support', 'codecolorer') . '</a>';
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
$links[] = '<a href="https://kpumuk.info/projects/wordpress-plugins/codecolorer/#faq">' . __('FAQ', 'codecolorer') . '</a>';
- Exclude checks
Opening brace should be on a new line Open
public static function addTinyMCEValidElements($init) {
- Exclude checks