Passed
Push — develop ( e448bf...f6f336 )
by Paul
03:05
created

Archive::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 19
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace GeminiLabs\Pollux\PostType;
4
5
use GeminiLabs\Pollux\Application;
6
use GeminiLabs\Pollux\Facades\MetaArchive;
7
use GeminiLabs\Pollux\Helper;
8
use GeminiLabs\Pollux\Settings\Settings;
9
10
class Archive extends Settings
11
{
12
	/**
13
	 * @var string
14
	 */
15
	CONST ID = 'pollux_archives';
16
17
	/**
18
	 * {@inheritdoc}
19
	 */
20
	public function init()
21
	{
22
		// @todo: run GateKeeper to check dependencies and capability (make sure it it run on the correct hook!)
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
23
		// if( !is_plugin_active( 'meta-box/meta-box.php' ))return;
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
25
		$this->id = apply_filters( 'pollux/archives/option', static::ID );
26
27
		// $this->normalize( $this->app->config['archives'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
29
		add_action( 'admin_menu',                             [$this, 'addPage'] );
30
		add_action( 'pollux/archive/editor',                  [$this, 'renderEditor'] );
31
		// add_action( 'pollux/settings/init',                   [$this, 'addSubmitMetaBox'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
		// add_action( 'current_screen',                         [$this, 'register'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
		// add_action( 'admin_menu',                             [$this, 'registerSetting'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
		// add_action( 'pollux/settings/init',                   [$this, 'reset'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
35
		// add_action( "admin_footer-toplevel_page_{$this->id}", [$this, 'renderFooterScript'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
36
		// add_filter( 'pollux/settings/instruction',            [$this, 'filterInstruction'], 10, 3 );
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
		// add_filter( 'wp_redirect',                            [$this, 'filterRedirectOnSave'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
	}
39
40
	/**
41
	 * @return void
42
	 * @action admin_menu
43
	 */
44 View Code Duplication
	public function addPage()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
	{
46
		$this->hook = call_user_func_array( 'add_menu_page', apply_filters( 'pollux/archive/page', [
47
			__( 'Archive Page', 'pollux' ),
48
			__( 'Archive Page', 'pollux' ),
49
			'edit_theme_options',
50
			$this->id,
51
			[$this, 'renderPage'],
52
			'dashicons-screenoptions',
53
			1310
54
		]));
55
	}
56
57
	/**
58
	 * @return void
59
	 * @callback add_menu_page
60
	 */
61 View Code Duplication
	public function renderPage()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
	{
63
		$this->render( 'archive/index', [
64
			'columns' => get_current_screen()->get_columns(),
65
			'id' => $this->id,
66
			'title' => __( 'Archive Page', 'pollux' ),
67
		]);
68
	}
69
70
	/**
71
	 * @return void
72
	 * @callback pollux/archive/editor
73
	 */
74
	public function renderEditor()
75
	{
76
		wp_editor( '', 'content', [
77
			'_content_editor_dfw' => true,
78
			'drag_drop_upload' => true,
79
			'tabfocus_elements' => 'content-html, save-post',
80
			'editor_height' => 300,
81
			'tinymce' => [
82
				'resize' => false,
83
				'wp_autoresize_on' => true,
84
				'add_unload_trigger' => false,
85
			],
86
		]);
87
	}
88
}
89