Skip to content

Instantly share code, notes, and snippets.

@afragen
Last active June 27, 2020 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afragen/0fb7cfdd8a1132ae9f2dd4e4269e30b2 to your computer and use it in GitHub Desktop.
Save afragen/0fb7cfdd8a1132ae9f2dd4e4269e30b2 to your computer and use it in GitHub Desktop.
Switch the Plugin Dependency label of wp-dependency-installer
<?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();
@afragen
Copy link
Author

afragen commented Jun 27, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment