PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 4.3.2
Admin Columns v4.3.2
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Admin / Main / Help.php
codepress-admin-columns / classes / Admin / Main Last commit date
Addons.php 5 years ago Columns.php 5 years ago Help.php 5 years ago Settings.php 5 years ago
Help.php
160 lines
1 <?php
2
3 namespace AC\Admin\Main;
4
5 use AC;
6 use AC\Asset\Assets;
7 use AC\Asset\Enqueueables;
8 use AC\Asset\Location;
9 use AC\Asset\Style;
10 use AC\Deprecated\Hooks;
11 use AC\Renderable;
12 use AC\Type\Url;
13
14 class Help implements Enqueueables, Renderable {
15
16 const NAME = 'help';
17
18 /** @var Hooks */
19 private $hooks;
20
21 /**
22 * @var Location\Absolute
23 */
24 private $location;
25
26 public function __construct( Hooks $hooks, Location\Absolute $location ) {
27 $this->hooks = $hooks;
28 $this->location = $location;
29 }
30
31 public function get_assets() {
32 return new Assets( [
33 new Style( 'ac-admin-page-help-css', $this->location->with_suffix( 'assets/css/admin-page-help.css' ) ),
34 ] );
35 }
36
37 /**
38 * @return string
39 */
40 private function get_documention_link() {
41 return sprintf(
42 '<a href="%s" target="_blank">%s &raquo;</a>',
43 ( new Url\Documentation( Url\Documentation::ARTICLE_UPGRADE_V3_TO_V4 ) )->get_url(),
44 __( 'View documentation', 'codepress-admin-columns' )
45 );
46 }
47
48 /**
49 * @param array $callbacks
50 *
51 * @return false|string
52 */
53 private function get_callback_message( $callbacks ) {
54 if ( ! $callbacks ) {
55 return false;
56 }
57
58 return sprintf( _n( 'The callback used is %s.', 'The callbacks used are %s.', count( $callbacks ), 'codepress-admin-columns' ), '<code>' . implode( '</code>, <code>', $callbacks ) . '</code>' );
59 }
60
61 /**
62 * @return void
63 */
64 private function render_actions() {
65 $hooks = $this->hooks->get_deprecated_actions();
66
67 if ( ! $hooks ) {
68 return;
69 }
70
71 ?>
72 <h3><?php __( 'Deprecated Actions', 'codepress-admin-columns' ); ?></h3>
73 <?php
74
75 foreach ( $hooks as $hook ) {
76 $message = sprintf( __( 'The action %s used on this website is deprecated since %s.', 'codepress-admin-columns' ), '<code>' . $hook->get_name() . '</code>', '<strong>' . $hook->get_version() . '</strong>' );
77
78 $callbacks = $hook->get_callbacks();
79
80 if ( $callbacks ) {
81 $message .= ' ' . $this->get_callback_message( $callbacks );
82 }
83
84 $message .= ' ' . $this->get_documention_link();
85
86 $this->render_message( $message );
87 }
88 }
89
90 /**
91 * @return void
92 */
93 private function render_filters() {
94 $hooks = $this->hooks->get_deprecated_filters();
95
96 if ( ! $hooks ) {
97 return;
98 }
99
100 ?>
101 <h3><?php __( 'Deprecated Filters', 'codepress-admin-columns' ); ?></h3>
102 <?php
103
104 foreach ( $hooks as $hook ) {
105 $message = sprintf( __( 'The filter %s used on this website is deprecated since %s.', 'codepress-admin-columns' ), '<code>' . $hook->get_name() . '</code>', '<strong>' . $hook->get_version() . '</strong>' );
106
107 $callbacks = $hook->get_callbacks();
108
109 if ( $callbacks ) {
110 $message .= ' ' . $this->get_callback_message( $callbacks );
111 }
112
113 $message .= ' ' . $this->get_documention_link();
114
115 $this->render_message( $message );
116 }
117 }
118
119 private function render_message( $message ) {
120 ?>
121 <div class="ac-deprecated-message">
122 <p><?php echo $message; ?></p>
123 </div>
124 <?php
125 }
126
127 public function render() {
128 // Force cache refresh
129 $this->hooks->get_count( true );
130
131 ob_start();
132 ?>
133 <h2><?php _e( 'Help', 'codepress-admin-columns' ); ?></h2>
134 <p>
135 <?php _e( 'The Admin Columns plugin has undergone some major changes in version 4.', 'codepress-admin-columns' ); ?> <br/>
136
137 <?php
138 printf(
139 __( 'This site is using some actions or filters that have changed. Please read %s to resolve them.', 'codepress-admin-columns' ),
140 sprintf(
141 '<a href="%s" target="_blank">%s</a>', ( new Url\Documentation( Url\Documentation::ARTICLE_UPGRADE_V3_TO_V4 ) )->get_url(),
142 __( 'our documentation', 'codepress-admin-columns' )
143 )
144 );
145 ?>
146 </p>
147
148 <?php
149
150 if ( $this->hooks->get_count() > 0 ) {
151 $this->render_actions();
152 $this->render_filters();
153 } else {
154 printf( '<em>%s</em>', __( 'No deprecated hooks or filters found.', 'codepress-admin-columns' ) );
155 }
156
157 return ob_get_clean();
158 }
159
160 }