GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch master (6b3106)
by Marko
06:06 queued 03:45
created

Tabify_Edit_Screen_Settings_Page   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 50
c 5
b 0
f 0
dl 0
loc 107
rs 10
wmc 13

4 Methods

Rating   Name   Duplication   Size   Complexity  
A update_settings() 0 16 6
A admin_menu() 0 2 1
A edit_screen() 0 57 5
A __construct() 0 2 1
1
<?php
2
3
include 'settings-base.php';
4
include 'settings-posttype.php';
5
6
class Tabify_Edit_Screen_Settings_Page {
7
	private $tabs;
8
9
	/**
10
	 * Load helper methods
11
	 *
12
	 * @since 0.8.2
13
	 */
14
	public function __construct() {
15
		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
0 ignored issues
show
Bug introduced by
The function add_action was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
		/** @scrutinizer ignore-call */ 
16
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
Loading history...
16
	}
17
18
	/**
19
	 * Adds a option page to manage all the tabs
20
	 *
21
	 * @since 0.1.0
22
	 */
23
	public function admin_menu() {
24
		add_options_page( __( 'Tabify edit screen', 'tabify-edit-screen' ), __( 'Tabify edit screen', 'tabify-edit-screen' ), 'manage_options', 'tabify-edit-screen', array( $this, 'edit_screen' ) );
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
		add_options_page( /** @scrutinizer ignore-call */ __( 'Tabify edit screen', 'tabify-edit-screen' ), __( 'Tabify edit screen', 'tabify-edit-screen' ), 'manage_options', 'tabify-edit-screen', array( $this, 'edit_screen' ) );
Loading history...
Bug introduced by
The function add_options_page was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
		/** @scrutinizer ignore-call */ 
25
  add_options_page( __( 'Tabify edit screen', 'tabify-edit-screen' ), __( 'Tabify edit screen', 'tabify-edit-screen' ), 'manage_options', 'tabify-edit-screen', array( $this, 'edit_screen' ) );
Loading history...
25
	}
26
27
	/**
28
	 * Option page that handles the form request
29
	 *
30
	 * @since 0.1.0
31
	 */
32
	public function edit_screen() {
33
		if ( ! current_user_can( 'manage_options' ) ) {
0 ignored issues
show
Bug introduced by
The function current_user_can was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
		if ( ! /** @scrutinizer ignore-call */ current_user_can( 'manage_options' ) ) {
Loading history...
34
			wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
			wp_die( /** @scrutinizer ignore-call */ __( 'You do not have sufficient permissions to manage options for this site.' ) );
Loading history...
Bug introduced by
The function wp_die was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
			/** @scrutinizer ignore-call */ 
35
   wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
Loading history...
35
		}
36
37
		$suffix = SCRIPT_DEBUG ? '' : '.min';
0 ignored issues
show
Bug introduced by
The constant SCRIPT_DEBUG was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
38
39
		wp_register_script( 'tabify-edit-screen-admin', plugins_url( '/js/admin' . $suffix . '.js', dirname( __FILE__ ) ), array( 'jquery', 'wp-backbone', 'jquery-ui-sortable', 'jquery-touch-punch' ), '1.0' );
0 ignored issues
show
Bug introduced by
The function plugins_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
		wp_register_script( 'tabify-edit-screen-admin', /** @scrutinizer ignore-call */ plugins_url( '/js/admin' . $suffix . '.js', dirname( __FILE__ ) ), array( 'jquery', 'wp-backbone', 'jquery-ui-sortable', 'jquery-touch-punch' ), '1.0' );
Loading history...
Bug introduced by
The function wp_register_script was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
		/** @scrutinizer ignore-call */ 
40
  wp_register_script( 'tabify-edit-screen-admin', plugins_url( '/js/admin' . $suffix . '.js', dirname( __FILE__ ) ), array( 'jquery', 'wp-backbone', 'jquery-ui-sortable', 'jquery-touch-punch' ), '1.0' );
Loading history...
40
		wp_enqueue_script( 'tabify-edit-screen-admin' );
0 ignored issues
show
Bug introduced by
The function wp_enqueue_script was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
		/** @scrutinizer ignore-call */ 
41
  wp_enqueue_script( 'tabify-edit-screen-admin' );
Loading history...
41
42
		$data = array(
43
			'remove' => __( 'Remove', 'tabify-edit-screen' ),
44
			'cancel' => __( 'Cancel', 'tabify-edit-screen' ),
45
			'move_meta_boxes' => __( 'Move meta boxes to', 'tabify-edit-screen' )
46
		);
47
		wp_localize_script( 'tabify-edit-screen-admin', 'tabify_l10', $data );
0 ignored issues
show
Bug introduced by
The function wp_localize_script was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
		/** @scrutinizer ignore-call */ 
48
  wp_localize_script( 'tabify-edit-screen-admin', 'tabify_l10', $data );
Loading history...
48
		
49
		echo '<div class="wrap">';
50
		echo '<h1>' . esc_html( get_admin_page_title() ) . '</h1>';
0 ignored issues
show
Bug introduced by
The function get_admin_page_title was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
		echo '<h1>' . esc_html( /** @scrutinizer ignore-call */ get_admin_page_title() ) . '</h1>';
Loading history...
Bug introduced by
The function esc_html was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
		echo '<h1>' . /** @scrutinizer ignore-call */ esc_html( get_admin_page_title() ) . '</h1>';
Loading history...
51
52
		echo '<form id="tabify-form" method="post">';
53
		wp_nonce_field( plugin_basename( __FILE__ ), 'tabify_edit_screen_nonce' );
0 ignored issues
show
Bug introduced by
The function plugin_basename was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
		wp_nonce_field( /** @scrutinizer ignore-call */ plugin_basename( __FILE__ ), 'tabify_edit_screen_nonce' );
Loading history...
Bug introduced by
The function wp_nonce_field was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
		/** @scrutinizer ignore-call */ 
54
  wp_nonce_field( plugin_basename( __FILE__ ), 'tabify_edit_screen_nonce' );
Loading history...
54
55
		echo '<input type="hidden" id="tabify_edit_screen_nojs" name="tabify_edit_screen_nojs" value="1" />';
56
57
		$tabs = array(
58
			'posttypes' => array(
59
			'title'     => __('Post types', 'tabify-edit-screen' ),
60
			'class'     => 'Tabify_Edit_Screen_Settings_Posttypes'
61
			)
62
		);
63
		$tabs = apply_filters( 'tabify_settings_tabs', $tabs );
0 ignored issues
show
Bug introduced by
The function apply_filters was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
		$tabs = /** @scrutinizer ignore-call */ apply_filters( 'tabify_settings_tabs', $tabs );
Loading history...
64
65
		$this->tabs = new Tabify_Edit_Screen_Tabs( $tabs, 'horizontal', 'tab', false );
66
67
		if ( count( $tabs ) > 1 ) {
68
			echo $this->tabs->get_tabs_with_container();
69
		}
70
71
		if ( isset( $tabs[ $this->tabs->get_current_tab() ] ) ) {
72
			$class_name = $tabs[ $this->tabs->get_current_tab() ]['class'];
73
			$settings_screen = new $class_name();
74
75
			$this->update_settings();
76
77
			echo '<div id="tabify-settings">';
78
				echo '<div id="tabify-submenu">';
79
				echo $settings_screen->get_sections_menu();
80
				echo '</div>';
81
82
				echo '<div id="tabifyboxes">';
83
				echo $settings_screen->get_sections_box();
84
				echo '</div>';
85
			echo '</div>';
86
87
			echo '</form>';
88
			echo '</div>';
89
		}
90
	}
91
92
	/**
93
	 * Updates settings on POST
94
	 *
95
	 * @since 0.2.0
96
	 */
97
	private function update_settings() {
98
		if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST['tabify'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'tabify_edit_screen_nonce' ) ) {
0 ignored issues
show
Bug introduced by
The function plugin_basename was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

98
		if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST['tabify'] ) && check_admin_referer( /** @scrutinizer ignore-call */ plugin_basename( __FILE__ ), 'tabify_edit_screen_nonce' ) ) {
Loading history...
Bug introduced by
The function check_admin_referer was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

98
		if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST['tabify'] ) && /** @scrutinizer ignore-call */ check_admin_referer( plugin_basename( __FILE__ ), 'tabify_edit_screen_nonce' ) ) {
Loading history...
99
			$options = $_POST['tabify'];
100
101
			$options = apply_filters( 'tabify_settings_update', $options );
102
103
			if ( isset( $_POST['create_tab'], $_POST['subtab'] ) ) {
104
				if ( isset( $options['posttypes'][ $_POST['subtab'] ] ) ) {
105
					$options['posttypes'][ $_POST['subtab'] ]['tabs'][] = array(
106
						'title' => __( 'Choose title', 'tabify-edit-screen' ),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

106
						'title' => /** @scrutinizer ignore-call */ __( 'Choose title', 'tabify-edit-screen' ),
Loading history...
107
						'items' => array()
108
					);
109
				}
110
			}
111
112
			update_option( 'tabify-edit-screen', $options );
0 ignored issues
show
Bug introduced by
The function update_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

112
			/** @scrutinizer ignore-call */ 
113
   update_option( 'tabify-edit-screen', $options );
Loading history...
113
		}
114
	}
115
116
}
117