$value ) { if ( is_numeric($key) ) { $output .= ' ' . esc_attr( $value ); } else { $output .= ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; } } $output .= '>'; return $output; } add_shortcode( 'add-to-calendar-button', 'atcb_shortcode_func' ); // define Gutenberg block function atcb_register_block() { global $pluginVersion; // register the block script wp_register_script( 'atcb-block', plugins_url('block.js', __FILE__), array('wp-blocks', 'wp-block-editor', 'wp-element'), $pluginVersion, true ); // register the actual block register_block_type( 'add-to-calendar/button', array('editor_script' => 'atcb-block') ); // add i18n load_plugin_textdomain( 'add-to-calendar-button', false, dirname(plugin_basename( __FILE__ )) . '/languages' ); $locale = get_Locale(); $language = explode( '_', $locale )[0]; wp_localize_script( 'atcb-block', 'atcbI18nObj', [ 'language' => $language, 'description' => __("Creates a button that adds an event to the user's calendar.", 'add-to-calendar-button'), 'default' => [ 'title' => __("My Event Title", 'add-to-calendar-button'), 'location' => __("World Wide Web", 'add-to-calendar-button'), ], 'keywords' => [ 'k1' => __("Calendar", 'add-to-calendar-button'), 'k2' => __("save", 'add-to-calendar-button'), 'k3' => __("Date", 'add-to-calendar-button'), 'k4' => __("Appointment", 'add-to-calendar-button') ], 'label' => __("Attributes", 'add-to-calendar-button'), 'help' => __("Click here for documentation", 'add-to-calendar-button'), 'note' => __("Mind that the interaction with the button is blocked in edit mode", 'add-to-calendar-button') ] ); } add_action( 'init', 'atcb_register_block' ); // set custom plugin links function pluginDetailsLinks($links, $file) { if ($file == basename(dirname(__FILE__)) . '/' . basename(__FILE__)) { $locale = get_Locale(); $language = explode( '_', $locale )[0]; $supportedLanguages = ['en', 'de']; if ($language == 'en' or !in_array($language, $supportedLanguages)) { $language = ''; } else { $language .= '/'; } $links[] = '' . __("Configuration Options", 'add-to-calendar-button') . ''; } return $links; } add_filter('plugin_row_meta', 'pluginDetailsLinks', 10, 2);