| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
die( '-1' ); |
| 5 |
} |
| 6 |
|
| 7 |
add_action( 'init', 'quadmenu_vc', 50 ); |
| 8 |
|
| 9 |
// TODO: check if this go to compatibility |
| 10 |
function quadmenu_vc() { |
| 11 |
|
| 12 |
if ( ! class_exists( '\\WPBakeryShortCode' ) ) { |
| 13 |
return; |
| 14 |
} |
| 15 |
|
| 16 |
class WPBakeryShortCode_quadmenu_vc extends \WPBakeryShortCode { |
| 17 |
|
| 18 |
protected function content( $atts, $content = null ) { |
| 19 |
|
| 20 |
if ( function_exists( 'quadmenu' ) ) { |
| 21 |
|
| 22 |
$theme = ''; |
| 23 |
|
| 24 |
extract( |
| 25 |
shortcode_atts( |
| 26 |
array( |
| 27 |
'menu' => '', |
| 28 |
'theme' => '', |
| 29 |
), |
| 30 |
$atts |
| 31 |
) |
| 32 |
); |
| 33 |
|
| 34 |
$args = array( |
| 35 |
'echo' => false, |
| 36 |
'menu' => $menu, |
| 37 |
'theme' => $theme, |
| 38 |
'layout' => 'inherit', |
| 39 |
); |
| 40 |
|
| 41 |
return quadmenu( $args ); |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
if ( ! function_exists( 'vc_map' ) ) { |
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
vc_map( |
| 51 |
array( |
| 52 |
'base' => 'quadmenu_vc', |
| 53 |
'name' => QUADMENU_PLUGIN_NAME, |
| 54 |
'icon' => '', |
| 55 |
'category' => esc_html__( 'Content', 'quadmenu' ), |
| 56 |
'description' => esc_html__( 'QuadMenu Shortcode', 'quadmenu' ), |
| 57 |
'params' => array( |
| 58 |
array( |
| 59 |
'type' => 'dropdown', |
| 60 |
'heading' => esc_html__( 'Menus', 'quadmenu' ), |
| 61 |
'param_name' => 'menu', |
| 62 |
'value' => quadmenu_vc_menus(), |
| 63 |
'description' => esc_html__( 'Choose a menu.', 'quadmenu' ), |
| 64 |
), |
| 65 |
array( |
| 66 |
'type' => 'dropdown', |
| 67 |
'heading' => esc_html__( 'Theme', 'quadmenu' ), |
| 68 |
'param_name' => 'theme', |
| 69 |
'value' => quadmenu_vc_themes(), |
| 70 |
'description' => esc_html__( 'Choose a theme location.', 'quadmenu' ), |
| 71 |
), |
| 72 |
), |
| 73 |
) |
| 74 |
); |
| 75 |
} |
| 76 |
|
| 77 |
function quadmenu_vc_themes( $themes = array() ) { |
| 78 |
|
| 79 |
global $quadmenu_themes; |
| 80 |
|
| 81 |
foreach ( $quadmenu_themes as $key => $theme ) { |
| 82 |
|
| 83 |
$themes[ $theme ] = $key; |
| 84 |
} |
| 85 |
|
| 86 |
return $themes; |
| 87 |
} |
| 88 |
|
| 89 |
function quadmenu_vc_menus( $menus_ids = array() ) { |
| 90 |
|
| 91 |
$menus = wp_get_nav_menus(); |
| 92 |
|
| 93 |
foreach ( $menus as $key => $menu ) { |
| 94 |
$menus_ids[ $menu->name ] = $menu->term_id; |
| 95 |
} |
| 96 |
|
| 97 |
return $menus_ids; |
| 98 |
} |
| 99 |
|