PluginProbe
Bubble Menu – Floating Button Menu with Sticky Navigation / 2.2
Bubble Menu – Floating Button Menu with Sticky Navigation v2.2
trunk 1.3 2.0 2.2 2.2.1 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.1 4.1.1
bubble-menu / public / public.php

public.php in Bubble Menu – Floating Button Menu with Sticky Navigation 2.2, at public/public.php

82 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) exit;
2
3 add_action( 'wp_enqueue_scripts', 'wow_scripts_styles_bmp' );
4
5 function wow_scripts_styles_bmp() {
6 wp_enqueue_style( 'font-awesome', WOW_BMP_URL . 'asset/font-awesome/css/font-awesome.min.css', array(), '4.7.0' );
7 }
8
9
10 //* Include on page and posts
11 add_action( 'wp_footer', 'wow_display_bmp' );
12 function wow_display_bmp() {
13 global $wpdb;
14 $table = $wpdb->prefix . "wow_bmp";
15 $arrresult = $wpdb->get_results("select * from $table");
16 if (count($arrresult) > 0) {
17 foreach ($arrresult as $key => $val) {
18 $param = unserialize($val->param);
19 ob_start();
20 include( 'partials/public.php' );
21 $menu = ob_get_contents();
22 ob_end_clean();
23 echo $menu;
24 wp_enqueue_style( WOW_BMP_BASENAME.'-style', plugin_dir_url( __FILE__ ). 'css/style.css', null, WOW_BMP_VERSION);
25 }
26
27 }
28 }
29
30
31 add_filter( 'nav_menu_css_class', 'wow_nav_menu_css_class_bmp');
32 function wow_nav_menu_css_class_bmp( $classes ){
33 if( is_array( $classes ) ){
34 $tmp_classes = preg_grep( '/^(fa)(-\S+)?$/i', $classes );
35 if( !empty( $tmp_classes ) ){
36 $classes = array_values( array_diff( $classes, $tmp_classes ) );
37 }
38 }
39 return $classes;
40 }
41
42 add_filter( 'walker_nav_menu_start_el', 'wow_walker_nav_menu_start_el_bmp', 10, 4 );
43
44 function wow_walker_nav_menu_start_el_bmp( $item_output, $item, $depth, $args ){
45 if( is_array( $item->classes ) ){
46 $classes = preg_grep( '/^(fa)(-\S+)?$/i', $item->classes );
47 if( !empty( $classes ) ){
48 $item_output = wow_replace_item_bmp( $item_output, $classes );
49 }
50 }
51 return $item_output;
52 }
53
54 function wow_replace_item_bmp( $item_output, $classes ){
55
56
57 if( !in_array( 'fa', $classes ) ){
58 array_unshift( $classes, 'fa' );
59 }
60
61 $before = true;
62 if( in_array( 'fa-after', $classes ) ){
63 $classes = array_values( array_diff( $classes, array( 'fa-after' ) ) );
64 $before = false;
65 }
66
67 $icon = '<i class="' . implode( ' ', $classes ) . '"></i>';
68
69 preg_match( '/(<a.+>)(.+)(<\/a>)/i', $item_output, $matches );
70 if( 4 === count( $matches ) ){
71 $item_output = $matches[1];
72 if( $before ){
73 $item_output .= $icon . ' <span class="wow-bmp-text">' . $matches[2] . '</span>';
74 } else {
75 $item_output .= '<span class="wow-bmp-text">' . $matches[2] . '</span> ' . $icon;
76 }
77 $item_output .= $matches[3];
78 }
79 return $item_output;
80 }
81
82