| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Bubble Menu (free version) |
| 4 |
* Plugin URI: https://wordpress.org/plugins/bubble-menu |
| 5 |
* Description: Create flyouts bubble menu |
| 6 |
* Version: 1.3 |
| 7 |
* Author: Wow-Company |
| 8 |
* Author URI: https://wow-estore.com/author/admin/?author_downloads=true |
| 9 |
* License: GPL-2.0+ |
| 10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 11 |
*/ |
| 12 |
if ( ! defined( 'WPINC' ) ) {die;} |
| 13 |
// Declaration Wow-Company class |
| 14 |
if( !class_exists( 'Wow_Company' )) { |
| 15 |
require_once plugin_dir_path( __FILE__ ) . 'asset/class-wow-company.php'; |
| 16 |
} |
| 17 |
if( !class_exists( 'WOW_DATA' )) { |
| 18 |
require_once plugin_dir_path( __FILE__ ) . 'include/class/data.php'; |
| 19 |
} |
| 20 |
if( !class_exists( 'JavaScriptPacker' )) { |
| 21 |
require_once plugin_dir_path( __FILE__ ) . 'include/class/packer.php'; |
| 22 |
} |
| 23 |
// Declaration of the plugin class |
| 24 |
if( !class_exists( 'Bubble_Menu_Class' ) ) { |
| 25 |
class Bubble_Menu_Class |
| 26 |
{ |
| 27 |
const PREF = 'bmp'; |
| 28 |
function __construct() { |
| 29 |
$this->name = 'Bubble Menu'; |
| 30 |
$this->version = '1.3'; |
| 31 |
$this->pluginname = dirname(plugin_basename(__FILE__)); |
| 32 |
$this->plugindir = plugin_dir_path( __FILE__ ); |
| 33 |
$this->pluginurl = plugin_dir_url( __FILE__ ); |
| 34 |
// activate & diactivate |
| 35 |
register_activation_hook( __FILE__, array($this, 'plugin_activate' ) ); |
| 36 |
register_deactivation_hook( __FILE__, array($this, 'plugin_deactivate') ); |
| 37 |
// admin pages |
| 38 |
add_action( 'admin_menu', array($this, 'add_menu_page') ); |
| 39 |
add_action( 'wp_footer', array($this, 'display') ); |
| 40 |
// admin links |
| 41 |
add_filter( 'plugin_row_meta', array($this, 'row_meta'), 10, 4 ); |
| 42 |
add_filter( 'plugin_action_links', array($this, 'action_links'), 10, 2 ); |
| 43 |
add_filter( 'nav_menu_css_class', array($this,'wow_nav_menu_css_class_bmp') ); |
| 44 |
add_filter( 'walker_nav_menu_start_el', array($this,'wow_walker_nav_menu_start_el_bmp'), 10, 4 ); |
| 45 |
|
| 46 |
} |
| 47 |
// Activate & diactivate |
| 48 |
function plugin_activate() { |
| 49 |
require_once plugin_dir_path( __FILE__ ) . 'include/activator.php'; |
| 50 |
} |
| 51 |
function plugin_deactivate() { |
| 52 |
require_once plugin_dir_path( __FILE__ ) . 'include/deactivator.php'; |
| 53 |
} |
| 54 |
// AdminPanel |
| 55 |
function add_menu_page() { |
| 56 |
add_submenu_page('wow-company', $this->name, $this->name, 'manage_options', $this->pluginname, array( $this, 'plugin_admin' )); |
| 57 |
} |
| 58 |
function plugin_admin() { |
| 59 |
$name = $this->name; |
| 60 |
$pluginname = $this->pluginname; |
| 61 |
$version = $this->version; |
| 62 |
global $wow_company_plugin; |
| 63 |
$wow_company_plugin = true; |
| 64 |
include_once( 'admin/partials/main.php' ); |
| 65 |
self:: plugin_admin_style_script(); |
| 66 |
} |
| 67 |
function plugin_admin_style_script() { |
| 68 |
// plugin sctyle & script |
| 69 |
wp_enqueue_style( $this->pluginname.'-style', $this->pluginurl . 'admin/css/style.css',false, $this->version); |
| 70 |
wp_enqueue_script($this->pluginname.'-script', $this->pluginurl . 'admin/js/script.js', array('jquery'), $this->version); |
| 71 |
// icon style |
| 72 |
wp_enqueue_style( $this->pluginname.'-icon', $this->pluginurl . 'asset/font-awesome/css/font-awesome.min.css', array(), '4.7.0' ); |
| 73 |
// iconpicker |
| 74 |
wp_enqueue_script($this->pluginname.'-fonticonpicker', $this->pluginurl . 'admin/fonticonpicker/fonticonpicker.min.js', array('jquery')); |
| 75 |
wp_enqueue_style($this->pluginname.'-fonticonpicker', $this->pluginurl . 'admin/fonticonpicker/css/fonticonpicker.min.css'); |
| 76 |
wp_enqueue_style($this->pluginname.'-fonticonpicker-darkgrey', $this->pluginurl . 'admin/fonticonpicker/fonticonpicker.darkgrey.min.css'); |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
function display() { |
| 81 |
global $wpdb; |
| 82 |
$table = $wpdb->prefix . "wow_".self::PREF; |
| 83 |
$arrresult = $wpdb->get_results("SELECT * FROM " . $table . " order by id asc"); |
| 84 |
if (count($arrresult) > 0) { |
| 85 |
foreach ($arrresult as $key => $val) { |
| 86 |
$param = unserialize($val->param); |
| 87 |
ob_start(); |
| 88 |
include( 'public/partials/public.php' ); |
| 89 |
$menu = ob_get_contents(); |
| 90 |
ob_end_clean(); |
| 91 |
echo $menu; |
| 92 |
wp_enqueue_style( $this->pluginname.'-style', $this->pluginurl. 'public/css/style.css', null, $this->version); |
| 93 |
wp_enqueue_style( $this->pluginname.'-icon', $this->pluginurl . 'asset/font-awesome/css/font-awesome.min.css', array(), '4.7.0' ); |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
function wow_nav_menu_css_class_bmp( $classes ){ |
| 99 |
if( is_array( $classes ) ){ |
| 100 |
$tmp_classes = preg_grep( '/^(fa)(-\S+)?$/i', $classes ); |
| 101 |
if( !empty( $tmp_classes ) ){ |
| 102 |
$classes = array_values( array_diff( $classes, $tmp_classes ) ); |
| 103 |
} |
| 104 |
} |
| 105 |
return $classes; |
| 106 |
} |
| 107 |
|
| 108 |
function wow_walker_nav_menu_start_el_bmp( $item_output, $item, $depth, $args ){ |
| 109 |
if( is_array( $item->classes ) ){ |
| 110 |
$classes = preg_grep( '/^(fa)(-\S+)?$/i', $item->classes ); |
| 111 |
if( !empty( $classes ) ){ |
| 112 |
$item_output = self::wow_replace_item_bmp( $item_output, $classes ); |
| 113 |
} |
| 114 |
} |
| 115 |
return $item_output; |
| 116 |
} |
| 117 |
|
| 118 |
function wow_replace_item_bmp( $item_output, $classes ){ |
| 119 |
|
| 120 |
|
| 121 |
if( !in_array( 'fa', $classes ) ){ |
| 122 |
array_unshift( $classes, 'fa' ); |
| 123 |
} |
| 124 |
|
| 125 |
$before = true; |
| 126 |
if( in_array( 'fa-after', $classes ) ){ |
| 127 |
$classes = array_values( array_diff( $classes, array( 'fa-after' ) ) ); |
| 128 |
$before = false; |
| 129 |
} |
| 130 |
|
| 131 |
$icon = '<i class="' . implode( ' ', $classes ) . '"></i>'; |
| 132 |
|
| 133 |
preg_match( '/(<a.+>)(.+)(<\/a>)/i', $item_output, $matches ); |
| 134 |
if( 4 === count( $matches ) ){ |
| 135 |
$item_output = $matches[1]; |
| 136 |
if( $before ){ |
| 137 |
$item_output .= $icon . ' <span class="wow-bmp-text">' . $matches[2] . '</span>'; |
| 138 |
} else { |
| 139 |
$item_output .= '<span class="wow-bmp-text">' . $matches[2] . '</span> ' . $icon; |
| 140 |
} |
| 141 |
$item_output .= $matches[3]; |
| 142 |
} |
| 143 |
return $item_output; |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
// Admin links |
| 148 |
function row_meta( $meta, $plugin_file ){ |
| 149 |
if( false === strpos( $plugin_file, basename(__FILE__) ) ) |
| 150 |
return $meta; |
| 151 |
$meta[] = ' <a href="https://wow-estore.com/item/bubble-menu-pro/" target="_blank">Pro version</a>'; |
| 152 |
return $meta; |
| 153 |
} |
| 154 |
function action_links( $actions, $plugin_file ){ |
| 155 |
if( false === strpos( $plugin_file, basename(__FILE__) ) ) |
| 156 |
return $actions; |
| 157 |
$settings_link = '<a href="admin.php?page='. $this->pluginname .'">Settings</a>'; |
| 158 |
array_unshift( $actions, $settings_link ); |
| 159 |
return $actions; |
| 160 |
} |
| 161 |
} |
| 162 |
$plugin = new Bubble_Menu_Class(); |
| 163 |
} |