PluginProbe
My WP Customize Admin/Frontend / 1.8
My WP Customize Admin/Frontend v1.8
1.27.4 1.27.3 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.10 1.10.1 1.10.2 1.11 1.12 1.12.1 1.12.2 1.13 1.13.1 1.13.2 1.14 1.15.0 1.16 1.17.0 All 76 releases
my-wp / controller / modules / mywp.controller.module.main.general.php

mywp.controller.module.main.general.php in My WP Customize Admin/Frontend 1.8, at controller/modules/mywp.controller.module.main.general.php

206 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 if( ! class_exists( 'MywpControllerAbstractModule' ) ) {
8 return false;
9 }
10
11 if ( ! class_exists( 'MywpControllerModuleMainGeneral' ) ) :
12
13 final class MywpControllerModuleMainGeneral extends MywpControllerAbstractModule {
14
15 static protected $id = 'main_general';
16
17 static protected $is_do_controller = true;
18
19 protected static function after_init() {
20
21 add_filter( 'mywp_controller_pre_get_model_' . self::$id , array( __CLASS__ , 'mywp_controller_pre_get_model' ) );
22
23 }
24
25 public static function mywp_controller_pre_get_model( $pre_model ) {
26
27 $pre_model = true;
28
29 return $pre_model;
30
31 }
32
33 public static function mywp_wp_loaded() {
34
35 if( ! is_admin() ) {
36
37 return false;
38
39 }
40
41 add_filter( 'plugin_row_meta' , array( __CLASS__ , 'plugin_row_meta' ) , 10 , 4 );
42
43 if( is_multisite() ) {
44
45 add_filter( 'network_admin_plugin_action_links_' . MYWP_PLUGIN_BASENAME , array( __CLASS__ , 'plugin_action_links' ) , 10 , 4 );
46
47 } else {
48
49 add_filter( 'plugin_action_links_' . MYWP_PLUGIN_BASENAME , array( __CLASS__ , 'plugin_action_links' ) , 10 , 4 );
50
51 }
52
53 add_action( 'admin_body_class' , array( __CLASS__ , 'admin_body_class' ) );
54
55 add_action( 'all_admin_notices' , array( __CLASS__ , 'all_admin_notices' ) );
56
57 }
58
59 private static function is_mywp_file( $plugin_file_name = false ) {
60
61 if( empty( $plugin_file_name ) ) {
62
63 return false;
64
65 }
66
67 $plugin_file_name = strip_tags( $plugin_file_name );
68
69 if ( strpos( MYWP_PLUGIN_BASENAME , $plugin_file_name ) === false ) {
70
71 return false;
72
73 }
74
75 return true;
76
77 }
78
79 public static function plugin_row_meta( $plugin_meta , $plugin_file , $plugin_data , $status ) {
80
81 if ( ! self::is_mywp_file( $plugin_file ) ) {
82
83 return $plugin_meta;
84
85 }
86
87 $plugin_info = MywpApi::plugin_info();
88
89 if( ! empty( $plugin_info['document_url'] ) ) {
90
91 $plugin_meta[] = sprintf( '<a href="%1$s" target="_blank">%2$s</a>' , esc_url( $plugin_info['document_url'] ) , __( 'Documents' , 'my-wp' ) );
92
93 }
94
95 if( ! empty( $plugin_info['forum_url'] ) ) {
96
97 $plugin_meta[] = sprintf( '<a href="%1$s" target="_blank">%2$s</a>' , esc_url( $plugin_info['forum_url'] ) , __( 'Support Forums' ) );
98
99 }
100
101 if( ! empty( $plugin_info['review_url'] ) ) {
102
103 $plugin_meta[] = sprintf( '<a href="%1$s" target="_blank">%2$s</a>' , esc_url( $plugin_info['review_url'] ) , __( 'Review' , 'my-wp' ) );
104
105 }
106
107 $plugin_meta = apply_filters( 'mywp_plugin_row_meta' , $plugin_meta , $plugin_file , $plugin_data , $status );
108
109 return $plugin_meta;
110
111 }
112
113 public static function plugin_action_links( $actions , $plugin_file , $plugin_data , $context ) {
114
115 if ( ! self::is_mywp_file( $plugin_file ) ) {
116
117 return $actions;
118
119 }
120
121 $plugin_info = MywpApi::plugin_info();
122
123 if( ! empty( $plugin_info['admin_url'] ) ) {
124
125 $action_link = array( 'setting' => sprintf( '<a href="%1$s">%2$s</a>' , esc_url( $plugin_info['admin_url'] ) , __( 'Settings' ) ) );
126
127 $actions = wp_parse_args( $actions , $action_link );
128
129 }
130
131 $actions = apply_filters( 'mywp_plugin_action_links' , $actions , $plugin_file , $plugin_data , $context );
132
133 return $actions;
134
135 }
136
137 public static function admin_body_class( $admin_body_class ) {
138
139 $admin_body_class .= ' mywp ';
140
141 if( MywpApi::is_manager() ) {
142
143 $admin_body_class .= ' mywp-manager ';
144
145 }
146
147 if( is_network_admin() ) {
148
149 $admin_body_class .= ' mywp-network-manager ';
150
151 }
152
153 return $admin_body_class;
154
155 }
156
157 public static function all_admin_notices() {
158
159 $mywp_notice = new MywpNotice();
160
161 $notices = $mywp_notice->get_notices();
162
163 if( empty( $notices ) ) {
164
165 return false;
166
167 }
168
169 if( ! empty( $notices['update'] ) ) {
170
171 echo '<div class="updated mywp-notice">';
172
173 foreach( $notices['update'] as $message ) {
174
175 printf( '<p class="update-notice">%s</p>' , $message );
176
177 }
178
179 echo '</div>';
180
181 }
182
183 if( ! empty( $notices['error'] ) ) {
184
185 echo '<div class="error mywp-notice">';
186
187 foreach( $notices['error'] as $code => $message ) {
188
189 printf( '<p class="error-notice error_%s">%s</p>' , $code , $message );
190
191 }
192
193 echo '</div>';
194
195 }
196
197 $mywp_notice->delete_notice();
198
199 }
200
201 }
202
203 MywpControllerModuleMainGeneral::init();
204
205 endif;
206