Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Customizations: Code Snippets

David Decker edited this page Sep 27, 2018 · 3 revisions

Remove styling:

Removes the styles from plugin cards (on hovering), and from the Plugin and Theme ZIP uploader areas.

/**
 * Remove styling options from library "DDWlib Plugin
 *   Installer Recommendations".
 */
add_filter( 'ddwlib_plir/filter/remove_installer_styles', '__return_true' );

Make strings translateable:

Via the filter the label strings are made translateable via your plugin. This means the library itself has no translations and that way is really "independent". Therefore the translations are only within your plugin, and with your plugin's textdomain. That way you can fullfill any requirements regarding textdomains and language packs for WordPress.org hosted plugins and still use the library.

/** Optionally add string translations for the library */
if ( ! function_exists( 'plir_custom_strings_plugin_installer' ) ) :

	add_filter( 'ddwlib_plir/filter/strings/plugin_installer', 'plir_custom_strings_plugin_installer' );
	/**
	 * Optionally, make strings translateable for included library "DDWlib Plugin
	 *   Installer Recommendations".
	 *   Strings:
	 *    - "Newest" --> tab in plugin installer toolbar
	 *    - "Version:" --> label in plugin installer plugin card
	 *
	 * @param  array $strings Holds all filterable strings of the library.
	 * @return array Array of tweaked translateable strings.
	 */
	function plir_custom_strings_plugin_installer( $strings ) {

		$strings[ 'newest' ] = _x(
			'Newest',
			'Plugin installer: Tab name in installer toolbar',
			'my-custom-textdomain'
		);

		$strings[ 'version' ] = _x(
			'Version:',
			'Plugin card: plugin version',
			'my-custom-textdomain'
		);

		return $strings;

	}  // end function

endif;  // function check

Clone this wiki locally