PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.5.1
WP Coder – Insert & Manage Code Snippets v3.5.1
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
wp-coder / classes / Dashboard / DashboardInitializer.php

DashboardInitializer.php in WP Coder – Insert & Manage Code Snippets 3.5.1, at classes/Dashboard/DashboardInitializer.php

119 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPCoder\Dashboard;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use WPCoder\WPCoder;
8
9 class DashboardInitializer {
10
11 public static function init(): void {
12 self::header();
13 echo '<div class="wrap wowp-wrap">';
14 // self::menu();
15 // self::include_pages();
16 echo '</div>';
17 }
18
19 public static function header(): void {
20 $logo_url = self::logo_url();
21 $add_url = add_query_arg( [
22 'page' => WPCoder::SLUG,
23 'tab' => 'settings',
24 'action' => 'new'
25 ], admin_url( 'admin.php' ) );
26 ?>
27
28 <div class="wowp-header-border"></div>
29 <div class="wowp-header">
30 <div class="wowp-logo">
31 <svg width="32px" height="32px" viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
32 <g id="WPCoder" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
33 <g id="code" transform="translate(26.000000, 56.000000)" fill-rule="nonzero">
34 <path d="M135.623849,107.492348 C132.313053,103.34684 127.489388,100.688372 122.21643,100.103113 C116.943473,99.5178542 111.654252,101.053868 107.514995,104.372476 L7.5090733,184.369213 C2.76301474,188.164426 0,193.911677 0,199.988576 C0,206.065476 2.76301474,211.812727 7.5090733,215.607939 L107.504995,295.604677 C111.643224,298.925874 116.933119,300.463522 122.20689,299.878173 C127.48066,299.292824 132.304624,296.632613 135.613849,292.484804 C142.506902,283.862628 141.110501,271.286066 132.493976,264.38595 L52.0172582,199.988576 L132.493976,135.611202 C141.110501,128.711086 142.506902,116.134524 135.613849,107.512348 L135.613849,107.482349 L135.623849,107.482349 L135.623849,107.492348 Z" id="Path" fill="#FF6B6B"></path>
35 <path d="M352.495005,104.372476 C343.863245,97.6171738 331.402277,99.0684778 324.554053,107.626703 C317.705829,116.184927 319.022334,128.660857 327.506024,135.601202 L407.982742,199.988576 L327.506024,264.365951 C319.022334,271.306297 317.705829,283.782226 324.554053,292.340451 C331.402277,300.898675 343.863245,302.349979 352.495005,295.594678 L452.490927,215.59794 C457.236985,211.802728 460,206.055476 460,199.978577 C460,193.901677 457.236985,188.154426 452.490927,184.359214 L352.495005,104.362476 L352.495005,104.382475 L352.495005,104.372476 Z" id="Path" fill="#007EA1"></path>
36 <path d="M285.347743,0.72670242 C274.707912,-2.20949175 263.697957,4.01547032 260.728747,14.6461348 L160.732825,374.631454 C157.911801,385.22514 164.145145,396.115314 174.708452,399.048043 C185.271759,401.980772 196.227146,395.862768 199.271253,385.331018 L299.267175,25.3456984 C302.221117,14.7036863 295.989426,3.68183039 285.347743,0.72670242 L285.347743,0.72670242 Z" id="Path" fill="#007EA1"></path>
37 </g>
38 </g>
39 </svg>
40 </div>
41 <h1><?php echo esc_html( WPCoder::info('name') ); ?> <sup
42 class="wowp-version"><?php echo esc_html( WPCoder::info('version') ); ?></sup></h1>
43
44 <?php do_action( WPCoder::PREFIX . '_admin_header_links' ); ?>
45 </div>
46
47
48 <?php
49 }
50
51 public static function logo_url(): string {
52 $logo_url = WPCoder::url() . 'assets/img/plugin-logo.png';
53 if ( filter_var( $logo_url, FILTER_VALIDATE_URL ) !== false ) {
54 return $logo_url;
55 }
56
57 return '';
58 }
59
60 public static function menu(): void {
61
62 $pages = DashboardHelper::get_files( 'pages' );
63 unset($pages["3"], $pages["4"]);
64
65 $current_page = self::get_current_page();
66
67 $action = ( isset( $_REQUEST["action"] ) ) ? sanitize_text_field( $_REQUEST["action"] ) : '';
68
69 echo '<h2 class="nav-tab-wrapper wowp-nav-tab-wrapper">';
70 foreach ( $pages as $key => $page ) {
71 $class = ( $page['file'] === $current_page ) ? ' nav-tab-active' : '';
72 $id = '';
73
74 if ( $action === 'update' && $page['file'] === 'settings' ) {
75 $id = ( isset( $_REQUEST["id"] ) ) ? absint( $_REQUEST["id"] ) : '';
76 $page['name'] = __( 'Update', 'wpcoder' ) . ' #' . $id;
77 } elseif ( $page['file'] === 'settings' && ( $action !== 'new' && $action !== 'duplicate' ) ) {
78 continue;
79 }
80
81 echo '<a class="nav-tab' . esc_attr( $class ) . '" href="' . esc_url( Link::menu( $page['file'], $action, $id ) ) . '">' . esc_html( $page['name'] ) . '</a>';
82 }
83 echo '</h2>';
84
85
86 }
87
88 public static function include_pages(): void {
89 $current_page = self::get_current_page();
90
91 $pages = DashboardHelper::get_files( 'pages' );
92 $default = DashboardHelper::first_file( 'pages' );
93
94 $current = DashboardHelper::search_value( $pages, $current_page ) ? $current_page : $default;
95
96 $file = DashboardHelper::get_file( $current, 'pages' );
97
98
99 if ( $file !== false ) {
100 $file = apply_filters( WPCoder::PREFIX . '_admin_filter_file', $file, $current );
101
102 $page_path = DashboardHelper::get_folder_path( 'pages' ) . '/' . $file;
103
104 if ( file_exists( $page_path ) ) {
105 require_once $page_path;
106 }
107 }
108
109 }
110
111
112 public static function get_current_page(): string {
113 $default = DashboardHelper::first_file( 'pages' );
114
115 return ( isset( $_REQUEST["tab"] ) ) ? sanitize_text_field( $_REQUEST["tab"] ) : $default;
116 }
117
118
119 }