1 | <?php |
||
20 | abstract class AdminPageFramework_Link_Base extends AdminPageFramework_FrameworkUtility { |
||
21 | |||
22 | public $oProp; |
||
23 | |||
24 | public $oMsg; |
||
25 | |||
26 | /** |
||
27 | * Sets up hooks and properties. |
||
28 | */ |
||
29 | public function __construct( $oProp, $oMsg=null ) { |
||
30 | |||
31 | if ( ! $this->_isLoadable( $oProp ) ) { |
||
32 | return; |
||
33 | } |
||
34 | |||
35 | $this->oProp = $oProp; |
||
36 | $this->oMsg = $oMsg; |
||
37 | |||
38 | add_action( 'in_admin_footer', array( $this, '_replyToSetFooterInfo' ) ); |
||
39 | |||
40 | // Add an action link in the plugin listing page |
||
41 | if ( $this->_shouldSetPluginActionLinks() ) { |
||
42 | add_filter( |
||
43 | 'plugin_action_links_' . plugin_basename( $this->oProp->aScriptInfo[ 'sPath' ] ), |
||
44 | array( $this, '_replyToAddSettingsLinkInPluginListingPage' ), |
||
45 | 20 // set a lower priority so that the link will be embedded at the beginning ( the most left hand side ). |
||
46 | ); |
||
47 | } |
||
48 | |||
49 | } |
||
50 | /** |
||
51 | * Determines if construction the object should be performed or not. |
||
52 | * |
||
53 | * @since 3.5.5 |
||
54 | * @return boolean |
||
55 | */ |
||
56 | private function _isLoadable( $oProp ) { |
||
65 | |||
66 | /** |
||
67 | * Checks whether it is okay to set up action links in the plugin listing page (plugins.php). |
||
68 | * @since 3.7.15 |
||
69 | * @return boolean |
||
70 | */ |
||
71 | protected function _shouldSetPluginActionLinks() { |
||
84 | |||
85 | /** |
||
86 | * Sets up footer information. |
||
87 | * |
||
88 | * @since 3.5.5 |
||
89 | * @callback action in_admin_footer |
||
90 | */ |
||
91 | public function _replyToSetFooterInfo() { |
||
97 | |||
98 | /** |
||
99 | * Set the default footer text values. |
||
100 | * @internal |
||
101 | * @since 3.5.5 |
||
102 | * @return void |
||
103 | */ |
||
104 | protected function _setDefaultFooterText() { |
||
118 | /** |
||
119 | * Sets the default footer text on the left hand side. |
||
120 | * |
||
121 | * @since 2.1.1 |
||
122 | * @since 3.5.5 Changed the name from `_setFooterInfoLeft()` and dropped the second parameter. |
||
123 | * @return string |
||
124 | */ |
||
125 | private function _getFooterInfoLeft( $aScriptInfo ) { |
||
177 | /** |
||
178 | * Sets the default footer text on the right hand side. |
||
179 | * |
||
180 | * @since 2.1.1 |
||
181 | * @since 3.5.5 Changed the name from `_setFooterInfoRight()` and dropped the second parameter. |
||
182 | * @return string |
||
183 | */ |
||
184 | private function _getFooterInfoRight( $aScriptInfo ) { |
||
230 | |||
231 | /** |
||
232 | * Sets up hooks to insert admin footer text strings. |
||
233 | * @internal |
||
234 | * @since 3.5.5 |
||
235 | * @return void |
||
236 | */ |
||
237 | protected function _setFooterHooks() { |
||
243 | /** |
||
244 | * Inserts the left footer text. |
||
245 | * @since 2.0.0 |
||
246 | * @since 3.5.5 Moved from `AdminPageFramework_Link_post_type`. |
||
247 | * @remark The page link class will override this method. |
||
248 | * @callback filter admin_footer_text |
||
249 | * @internal |
||
250 | */ |
||
251 | public function _replyToAddInfoInFooterLeft( $sLinkHTML='' ) { |
||
264 | /** |
||
265 | * Inserts the right footer text. |
||
266 | * @since 2.0.0 |
||
267 | * @since 3.5.5 Moved from `AdminPageFramework_Link_post_type`. |
||
268 | * @remark The page link class will override this method. |
||
269 | * @callback filter admin_footer_text |
||
270 | * @internal |
||
271 | */ |
||
272 | public function _replyToAddInfoInFooterRight( $sLinkHTML='' ) { |
||
279 | |||
280 | } |
||
281 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: