Completed
Push — fix/static-html-fouc ( 51c774...93fc80 )
by
unknown
213:09 queued 203:02
created

Jetpack_Settings_Page::add_page_actions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
1
<?php
2
include_once( 'class.jetpack-admin-page.php' );
3
include_once( JETPACK__PLUGIN_DIR . 'class.jetpack-modules-list-table.php' );
4
5
// Builds the settings page and its menu
6
class Jetpack_Settings_Page extends Jetpack_Admin_Page {
7
8
	// Show the settings page only when Jetpack is connected or in dev mode
9
	protected $dont_show_if_not_active = true;
10
11
	function add_page_actions( $hook ) {} // There are no page specific actions to attach to the menu
12
13
	// Adds the Settings sub menu
14
	function get_page_hook() {
15
		return add_submenu_page( null, __( 'Jetpack Settings', 'jetpack' ), __( 'Settings', 'jetpack' ), 'jetpack_manage_modules', 'jetpack_modules', array( $this, 'render' ) );
16
	}
17
18
	// Renders the module list table where you can use bulk action or row
19
	// actions to activate/deactivate and configure modules
20
	function page_render() {
21
		$list_table = new Jetpack_Modules_List_Table;
22
		$static_html = file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static.html' );
23
		$noscript_notice = file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-noscript-notice.html' );
24
		$version_notice = file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-version-notice.html' );
25
		$ie_notice = file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-ie-notice.html' );
26
27
		$noscript_notice = str_replace(
28
			'#HEADER_TEXT#',
29
			esc_html( __( 'You have JavaScript disabled', 'jetpack' ) ),
30
			$noscript_notice
31
		);
32
		$noscript_notice = str_replace(
33
			'#TEXT#',
34
			esc_html( __( "Turn on JavaScript to unlock Jetpack's full potential!", 'jetpack' ) ),
35
			$noscript_notice
36
		);
37
38
		$version_notice = str_replace(
39
			'#HEADER_TEXT#',
40
			esc_html( __( 'You are using an outdated version of WordPress', 'jetpack' ) ),
41
			$version_notice
42
		);
43
		$version_notice = str_replace(
44
			'#TEXT#',
45
			esc_html( __( "Update WordPress to unlock Jetpack's full potential!", 'jetpack' ) ),
46
			$version_notice
47
		);
48
49
		$ie_notice = str_replace(
50
			'#HEADER_TEXT#',
51
			esc_html( __( 'You are using an unsupported browser version.', 'jetpack' ) ),
52
			$ie_notice
53
		);
54
		$ie_notice = str_replace(
55
			'#TEXT#',
56
			esc_html( __( "Update your browser to unlock Jetpack's full potential!", 'jetpack' ) ),
57
			$ie_notice
58
		);
59
60
		ob_start();
61
62
		$this->admin_page_top();
63
64
		if ( $this->is_wp_version_too_old() ) {
65
			echo $version_notice;
66
		}
67
		echo $noscript_notice;
68
		echo $ie_notice;
69
		?>
70
71
		<div class="page-content configure">
72
			<div class="frame top hide-if-no-js">
73
				<div class="wrap">
74
					<div class="manage-left">
75
						<table class="table table-bordered fixed-top">
76
							<thead>
77
								<tr>
78
									<th class="check-column"><input type="checkbox" class="checkall"></th>
79
									<th colspan="2">
80
										<?php $list_table->unprotected_display_tablenav( 'top' ); ?>
81
										<span class="filter-search">
82
											<button type="button" class="button">Filter</button>
83
										</span>
84
									</th>
85
								</tr>
86
							</thead>
87
						</table>
88
					</div>
89
				</div><!-- /.wrap -->
90
			</div><!-- /.frame -->
91
			<div class="frame bottom">
92
				<div class="wrap">
93
					<div class="manage-right" style="display: none;">
94
						<div class="bumper">
95
							<form class="navbar-form" role="search">
96
								<input type="hidden" name="page" value="jetpack_modules" />
97
								<?php $list_table->search_box( __( 'Search', 'jetpack' ), 'srch-term' ); ?>
98
								<p><?php esc_html_e( 'View:', 'jetpack' ); ?></p>
99
								<div class="button-group filter-active">
100
									<button type="button" class="button <?php if ( empty( $_GET['activated'] ) ) echo 'active'; ?>"><?php esc_html_e( 'All', 'jetpack' ); ?></button>
101
									<button type="button" class="button <?php if ( ! empty( $_GET['activated'] ) && 'true' == $_GET['activated'] ) echo 'active'; ?>" data-filter-by="activated" data-filter-value="true"><?php esc_html_e( 'Active', 'jetpack' ); ?></button>
102
									<button type="button" class="button <?php if ( ! empty( $_GET['activated'] ) && 'false' == $_GET['activated'] ) echo 'active'; ?>" data-filter-by="activated" data-filter-value="false"><?php esc_html_e( 'Inactive', 'jetpack' ); ?></button>
103
								</div>
104
								<p><?php esc_html_e( 'Sort by:', 'jetpack' ); ?></p>
105
								<div class="button-group sort">
106
									<button type="button" class="button <?php if ( empty( $_GET['sort_by'] ) ) echo 'active'; ?>" data-sort-by="name"><?php esc_html_e( 'Alphabetical', 'jetpack' ); ?></button>
107
									<button type="button" class="button <?php if ( ! empty( $_GET['sort_by'] ) && 'introduced' == $_GET['sort_by'] ) echo 'active'; ?>" data-sort-by="introduced" data-sort-order="reverse"><?php esc_html_e( 'Newest', 'jetpack' ); ?></button>
108
									<button type="button" class="button <?php if ( ! empty( $_GET['sort_by'] ) && 'sort' == $_GET['sort_by'] ) echo 'active'; ?>" data-sort-by="sort"><?php esc_html_e( 'Popular', 'jetpack' ); ?></button>
109
								</div>
110
								<p><?php esc_html_e( 'Show:', 'jetpack' ); ?></p>
111
								<?php $list_table->views(); ?>
112
							</form>
113
						</div>
114
					</div>
115
					<div class="manage-left" style="width: 100%;">
116
						<form class="jetpack-modules-list-table-form" onsubmit="return false;">
117
						<table class="<?php echo implode( ' ', $list_table->get_table_classes() ); ?>">
118
							<tbody id="the-list">
119
								<?php $list_table->display_rows_or_placeholder(); ?>
120
							</tbody>
121
						</table>
122
						</form>
123
					</div>
124
				</div><!-- /.wrap -->
125
			</div><!-- /.frame -->
126
		</div><!-- /.content -->
127
		<?php
128
129
		$this->admin_page_bottom();
130
131
		$page_content = ob_get_contents();
132
		ob_end_clean();
133
134
		echo str_replace(
135
			'<div class="jp-loading-placeholder"><span class="dashicons dashicons-wordpress-alt"></span></div>',
136
			$page_content,
137
			$static_html
138
		);
139
140
		JetpackTracking::record_user_event( 'page_view', array( 'path' => 'wpa_old_settings' ) );
141
	}
142
143
	/**
144
	 * Load styles for static page.
145
	 *
146
	 * @since 4.3
147
	 */
148
	function additional_styles() {
149
		$rtl = is_rtl() ? '.rtl' : '';
150
		wp_enqueue_style( 'dops-css', plugins_url( "_inc/build/static.dops-style$rtl.css", JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION );
151
		wp_enqueue_style( 'components-css', plugins_url( "_inc/build/style.min$rtl.css", JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION );
152
	}
153
154
	// Javascript logic specific to the list table
155
	function page_admin_scripts() {
156
		wp_enqueue_script( 'jetpack-admin-js', plugins_url( '_inc/jetpack-admin.js', JETPACK__PLUGIN_FILE ), array( 'jquery' ), JETPACK__VERSION );
157
	}
158
}
159