enqueue_backend();
/** Remove unnecessary WordPress branding and messages. */
/** Remove all "third-party" notices from plugin settings page. */
add_action( 'in_admin_header', [ $this, 'remove_all_notices' ], 1000 );
/** Remove "Thank you for creating with WordPress" and WP version only from plugin settings page. */
add_action( 'admin_enqueue_scripts', [ $this, 'remove_wp_copyrights' ] );
}
/**
* Load JS and CSS for Backend Area.
*
* @since 1.0.0
* @access public
*
* @return void
**/
public function enqueue_backend() {
/** Add admin styles. */
add_action( 'admin_enqueue_scripts', [ $this, 'admin_styles' ] );
/** Add admin javascript. */
add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] );
}
/**
* Add CSS for admin area.
*
* @since 1.0.0
* @access public
*
* @return void
**/
public function admin_styles() {
$screen = get_current_screen();
if ( null === $screen ) { return; }
/** Add styles only on WP Plugins page. */
if ( 'plugins' !== $screen->base ) { return; }
wp_enqueue_style( 'pp-plugins', Plugin::get_url() . 'src/Core/Inc/assets/css/plugins' . Plugin::get_suffix() . '.css', [], Plugin::get_version() );
}
/**
* Add JS for admin area.
*
* @since 1.0.0
* @access public
*
* @return void
**/
public function admin_scripts() {
$screen = get_current_screen();
if ( null === $screen ) { return; }
/** Add scripts only on WP Plugins page. */
if ( 'plugins' !== $screen->base ) { return; }
wp_enqueue_script( 'pp-plugins', Plugin::get_url() . 'src/Core/Inc/assets/js/plugins' . Plugin::get_suffix() . '.js', ['jquery'], Plugin::get_version(), true );
}
/**
* Add "pixpal.net" links on plugin page.
*
* @param array $links Current links: Deactivate | Edit
*
* @return array
**@since 1.0.0
* @access public
*
*/
public function add_links( array $links ): array {
array_unshift( $links, '' . esc_html__( 'Settings', 'AdUnlocker' ) . '' );
$links[] = '' . esc_html__( 'Documentation', 'AdUnlocker' ) . '';
$links[] = '
' . esc_html__( 'Plugins', 'AdUnlocker' ) . '';
return $links;
}
/**
* Remove "Thank you for creating with WordPress" and WP version only from plugin settings page.
*
* @since 1.0.0
* @access public
*
* @return void
**/
public function remove_wp_copyrights() {
/** Remove "Thank you for creating with WordPress" and WP version from plugin settings page. */
$screen = get_current_screen();
if ( null === $screen ) { return; }
/** If not Plugin Settings Page. */
if ( ! in_array( $screen->base, Plugin::get_menu_bases(), true ) ) { return; }
/** Plugin Settings Page. */
add_filter( 'admin_footer_text', '__return_empty_string', 11 );
add_filter( 'update_footer', '__return_empty_string', 11 );
}
/**
* Remove all other notices.
*
* @since 1.0.0
* @access public
*
* @return void
**/
public function remove_all_notices() {
/** Work only on plugin settings page. */
$screen = get_current_screen();
if ( null === $screen ) { return; }
/** If not Plugin Settings Page. */
if ( ! in_array( $screen->base, Plugin::get_menu_bases(), true ) ) { return; }
/** Plugin Settings Page. */
remove_all_actions( 'admin_notices' );
remove_all_actions( 'all_admin_notices' );
}
/**
* Loads the plugin translated strings.
*
* @static
* @since 1.0.0
* @access public
*
* @return void
**/
public static function load_textdomain() {
load_plugin_textdomain( 'AdUnlocker', false, Plugin::get_path() . '/languages/' );
}
/**
* Main PluginHelper Instance.
* Insures that only one instance of PluginHelper exists in memory at any one time.
*
* @static
* @since 1.0.0
* @access public
*
* @return PluginHelper
**/
public static function get_instance(): PluginHelper {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
self::$instance = new self;
}
return self::$instance;
}
}