PluginProbe
My WP Customize Admin/Frontend / 1.3.2
My WP Customize Admin/Frontend v1.3.2
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.3.2, at controller/modules/mywp.controller.module.main.general.php

194 lines 3.9 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_model_' . self::$id , array( __CLASS__ , 'mywp_controller_model' ) );
22
23 }
24
25 public static function mywp_controller_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['forum_url'] ) ) {
90
91 $plugin_meta[] = sprintf( '<a href="%1$s" target="_blank">%2$s</a>' , esc_url( $plugin_info['forum_url'] ) , __( 'Support Forums' ) );
92
93 }
94
95 if( !empty( $plugin_info['review_url'] ) ) {
96
97 $plugin_meta[] = sprintf( '<a href="%1$s" target="_blank">%2$s</a>' , esc_url( $plugin_info['review_url'] ) , __( 'Review' , 'mywp' ) );
98
99 }
100
101 $plugin_meta = apply_filters( 'mywp_plugin_row_meta' , $plugin_meta , $plugin_file , $plugin_data , $status );
102
103 return $plugin_meta;
104
105 }
106
107 public static function plugin_action_links( $actions , $plugin_file , $plugin_data , $context ) {
108
109 if ( ! self::is_mywp_file( $plugin_file ) ) {
110
111 return $actions;
112
113 }
114
115 $plugin_info = MywpApi::plugin_info();
116
117 if( !empty( $plugin_info['admin_url'] ) ) {
118
119 $action_link = array( 'setting' => sprintf( '<a href="%1$s">%2$s</a>' , esc_url( $plugin_info['admin_url'] ) , __( 'Settings' ) ) );
120
121 $actions = wp_parse_args( $actions , $action_link );
122
123 }
124
125 $actions = apply_filters( 'mywp_plugin_action_links' , $actions , $plugin_file , $plugin_data , $context );
126
127 return $actions;
128
129 }
130
131 public static function admin_body_class( $admin_body_class ) {
132
133 $admin_body_class .= ' mywp ';
134
135 if( MywpApi::is_manager() ) {
136
137 $admin_body_class .= ' mywp-manager ';
138
139 }
140
141 return $admin_body_class;
142
143 }
144
145 public static function all_admin_notices() {
146
147 $mywp_notice = new MywpNotice();
148
149 $notices = $mywp_notice->get_notices();
150
151 if( empty( $notices ) ) {
152
153 return false;
154
155 }
156
157 if( !empty( $notices['update'] ) ) {
158
159 echo '<div class="updated mywp-notice">';
160
161 foreach( $notices['update'] as $message ) {
162
163 printf( '<p class="update-notice">%s</p>' , $message );
164
165 }
166
167 echo '</div>';
168
169 }
170
171 if( !empty( $notices['error'] ) ) {
172
173 echo '<div class="error mywp-notice">';
174
175 foreach( $notices['error'] as $code => $message ) {
176
177 printf( '<p class="error-notice error_%s">%s</p>' , $code , $message );
178
179 }
180
181 echo '</div>';
182
183 }
184
185 $mywp_notice->delete_notice();
186
187 }
188
189 }
190
191 MywpControllerModuleMainGeneral::init();
192
193 endif;
194