Last active
June 27, 2020 21:32
-
-
Save afragen/0fb7cfdd8a1132ae9f2dd4e4269e30b2 to your computer and use it in GitHub Desktop.
Switch the Plugin Dependency label of wp-dependency-installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Switch Plugin Dependency Label for WP Dependency Installer | |
* | |
* @package Switch_Plugin_Dependency_Label | |
* @author Andy Fragen | |
* @license MIT | |
* | |
* @wordpress-plugin | |
* Plugin Name: Switch Plugin Dependency Label | |
* Plugin URI: https://gist.github.com/afragen/0fb7cfdd8a1132ae9f2dd4e4269e30b2 | |
* Description: Switch location of WP Dependency Installer framework 'Plugin Dependency' label. | |
* Version 0.1 | |
* Author: Andy Fragen | |
* License: MIT | |
* Requires at least: 5.1 | |
* Requires PHP: 5.6 | |
* Gist Plugin URI: https://gist.github.com/afragen/0fb7cfdd8a1132ae9f2dd4e4269e30b2 | |
*/ | |
class Switch_Label { | |
protected $files = []; | |
public function __construct() { | |
add_filter( 'plugin_action_links', [ $this, 'plugin_row' ], 99, 2 ); | |
add_filter( 'plugin_row_meta', [ $this, 'row_meta' ], 99, 2 ); | |
} | |
public function plugin_row( $actions, $file ) { | |
add_filter( "plugin_action_links_$file", [ $this, 'action_links' ], 99, 2 ); | |
return $actions; | |
} | |
public function action_links( $actions, $file ) { | |
if ( array_key_exists( 'required-plugin', $actions ) ) { | |
unset( $actions['required-plugin'] ); | |
$this->files[] = $file; | |
} | |
return $actions; | |
} | |
public function row_meta( $links, $file ) { | |
if ( in_array( $file, $this->files, true ) ) { | |
array_unshift( $links, sprintf( esc_html__( '%1$sPlugin dependency%2$s' ), '<strong style=" font-weight: 700; padding: 2px 5px;">', '</strong>' ) ); | |
} | |
return $links; | |
} | |
} | |
new Switch_Label(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation instructions: https://gist.github.com/westonruter/6110fbc4bef0c4b8c021a112012f7e9c