PluginProbe
Social Media Auto Poster – Schedule & Publish to Buffer / 3.8.2
Social Media Auto Poster – Schedule & Publish to Buffer v3.8.2
6.2.4 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 All 125 releases
wp-to-buffer / vendor / includes / admin / screen.php

screen.php in Social Media Auto Poster – Schedule & Publish to Buffer 3.8.2, at vendor/includes/admin/screen.php

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