get_uri() . 'quicklinks.js', array( 'jquery' ), self::$version, true ); wp_register_style( 'bsf-quick-links-css', $this->get_uri() . 'quicklink.css', array(), self::$version, 'screen' ); } /** * Get URI * * @return mixed URL. */ public function get_uri() { $path = wp_normalize_path( dirname( __FILE__ ) ); $theme_dir = wp_normalize_path( get_template_directory() ); if ( strpos( $path, $theme_dir ) !== false ) { return trailingslashit( get_template_directory_uri() . str_replace( $theme_dir, '', $path ) ); } return plugin_dir_url( __FILE__ ); } /** * Generate Quick Links Markup. * * @param array $data links array. */ public function generate_quick_links_markup( $data ) { wp_enqueue_script( 'bsf-quick-links' ); wp_enqueue_style( 'bsf-quick-links-css' ); ?> $item ) { $items_html .= sprintf( ' ', esc_url( $item['url'] ), esc_html( $item['label'] ), sanitize_html_class( $item['icon'] ), $item_key, ! empty( $item['bgcolor'] ) ? ' style="background-color: ' . esc_attr( $item['bgcolor'] ) . '"' : '' ); } return $items_html; } } /** * Kicking this off by calling 'get_instance()' method */ BSF_Quick_Links::get_instance(); } if ( ! function_exists( 'bsf_quick_links' ) ) { /** * Add BSF Quick Links. * * @param array $args links array. */ function bsf_quick_links( $args ) { BSF_Quick_Links::get_instance()->generate_quick_links_markup( $args ); } }