@@ -13,21 +13,46 @@ class Utils extends Plugin {
1313 * error, warning, success, info
1414 * @param bool $is_dismissible Specify whether or not the user may dismiss
1515 * the notice.
16- * @return null
16+ * @since 2.0.0
1717 */
18- public static function show_notice ($ msg , $ type = 'error ' , $ is_dismissible = false ) {
18+ public static function show_notice ( $ msg , $ type = 'error ' , $ is_dismissible = false ) {
1919
20+ $ msg = $ this ->translate ( $ msg );
2021 add_action ( 'admin_notices ' , function () use (&$ msg , &$ type , &$ is_dismissible ) {
2122
2223 $ class = 'notice notice- ' . $ type . ( $ is_dismissible ? ' is-dismissible ' : '' );
23- $ msg = __ ( $ msg , self ::$ settings ['data ' ]['TextDomain ' ] );
24-
2524 printf ( '<div class="%1$s"><p>%2$s</p></div> ' , $ class , $ msg );
2625
2726 });
2827
2928 }
3029
30+ /**
31+ * Combine function attributes with known attributes and fill in defaults when needed.
32+ *
33+ * @param array $pairs Entire list of supported attributes and their defaults.
34+ * @param array $atts User defined attributes in shortcode tag.
35+ * @return array Combined and filtered attribute list.
36+ * @link https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/shortcodes.php#L540 Original source
37+ * @since 0.2.0
38+ */
39+ public static function set_default_atts ( $ pairs , $ atts ) {
40+
41+ $ atts = (array )$ atts ;
42+ $ result = array ();
43+
44+ foreach ($ pairs as $ name => $ default ) {
45+ if ( array_key_exists ($ name , $ atts ) ) {
46+ $ result [$ name ] = $ atts [$ name ];
47+ } else {
48+ $ result [$ name ] = $ default ;
49+ }
50+ }
51+
52+ return $ result ;
53+
54+ }
55+
3156 /**
3257 * Merges two array, eliminating duplicates
3358 *
0 commit comments