PluginProbe
Social Media Auto Poster – Schedule & Publish to Buffer / trunk
Social Media Auto Poster – Schedule & Publish to Buffer vtrunk
6.2.3 6.2.2 6.2.1 6.2.0 6.1.2 6.1.1 6.1.0 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 6.0.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 All 124 releases
wp-to-buffer / lib / social / includes / class-screen.php

class-screen.php in Social Media Auto Poster – Schedule & Publish to Buffer trunk, at lib/social/includes/class-screen.php

163 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Screen class
4 *
5 * @package WPZinc\Social
6 * @author WP Zinc
7 */
8
9 namespace WPZinc\Social;
10
11 /**
12 * Determines which Plugin Screen the User is on
13 *
14 * @package WPZinc\Social
15 * @author WP Zinc
16 * @version 3.9.6
17 */
18 class Screen {
19
20 /**
21 * Holds the base object.
22 *
23 * @since 3.9.6
24 *
25 * @var object
26 */
27 public $base;
28
29 /**
30 * Constructor
31 *
32 * @since 3.9.6
33 *
34 * @param object $base Base Plugin Class.
35 */
36 public function __construct( $base ) {
37
38 // Store base class.
39 $this->base = $base;
40
41 }
42
43 /**
44 * Returns an array comprising of the Plugin Top Level Screen and Section
45 *
46 * For example:
47 * [
48 * 'screen' => 'settings',
49 * 'section' => 'page',
50 * ]
51 *
52 * Returns false if we're not on a Plugin screen
53 *
54 * @since 3.9.6
55 *
56 * @return array Screen and Section (if false, we're not on this Plugin's screens)
57 */
58 public function get_current_screen() {
59
60 // Assume we're not on a plugin screen.
61 $result = array(
62 'screen' => false,
63 'section' => false,
64 );
65
66 // Early detection of settings page so that early hooks e.g. init can detect if we're on the settings screen.
67 $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
68 $tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
69 if ( $page === $this->base->plugin->name . '-settings' ) {
70 return array(
71 'screen' => 'settings',
72 'section' => ( $tab ? $tab : 'auth' ),
73 );
74 }
75
76 // Bail if we can't determine this.
77 if ( ! function_exists( 'get_current_screen' ) ) {
78 return $result;
79 }
80
81 // Get screen.
82 $screen = get_current_screen();
83
84 // Bail if screen is null.
85 if ( is_null( $screen ) ) {
86 return $result;
87 }
88
89 // Get screen ID without Plugin Display Name, which can be edited by whitelabelling.
90 $screen_id = str_replace(
91 array(
92 'toplevel_page_', // licensing = wp-to-xxx-pro.
93 sanitize_title( $this->base->plugin->displayName ) . '_page_',
94 ),
95 '',
96 $screen->base
97 );
98
99 switch ( $screen_id ) {
100
101 /**
102 * Post/Page/CPT WP_List_Table
103 */
104 case 'edit':
105 return array(
106 'screen' => 'post',
107 'section' => 'wp_list_table',
108 );
109
110 /**
111 * Post/Page/CPT Add/Edit
112 */
113 case 'post':
114 return array(
115 'screen' => 'post',
116 'section' => 'edit',
117 );
118
119 /**
120 * Settings
121 */
122 case $this->base->plugin->name . '-settings':
123 return array(
124 'screen' => 'settings',
125 'section' => filter_has_var( INPUT_GET, 'tab' ) ? filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : 'auth',
126 );
127
128 /**
129 * Bulk Publish
130 */
131 case $this->base->plugin->name . '-bulk-publish':
132 return array(
133 'screen' => 'bulk_publish',
134 'section' => 'bulk_publish',
135 );
136
137 /**
138 * Log
139 */
140 case $this->base->plugin->name . '-log':
141 return array(
142 'screen' => 'log',
143 'section' => 'log',
144 );
145
146 /**
147 * WordPress Screens
148 */
149 case 'customize':
150 return array(
151 'screen' => 'customize',
152 'section' => 'customize',
153 );
154
155 }
156
157 // If here, we couldn't determine the screen.
158 return $result;
159
160 }
161
162 }
163