| 1 |
<?php |
| 2 |
/* |
| 3 |
* Get latest version |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! function_exists ( 'bws_include_init' ) ) { |
| 7 |
function bws_include_init( $base ) { |
| 8 |
global $bstwbsftwppdtplgns_options, $bstwbsftwppdtplgns_added_menu; |
| 9 |
if ( ! function_exists( 'get_plugin_data' ) ) |
| 10 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 11 |
|
| 12 |
$bws_menu_info = get_plugin_data( dirname( dirname( plugin_dir_path( __FILE__ ) ) ) . '/' . dirname( $base ) . '/bws_menu/bws_menu.php' ); |
| 13 |
$bws_menu_version = $bws_menu_info["Version"]; |
| 14 |
|
| 15 |
if ( ! isset( $bstwbsftwppdtplgns_options ) ) { |
| 16 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 17 |
if ( ! get_site_option( 'bstwbsftwppdtplgns_options' ) ) |
| 18 |
add_site_option( 'bstwbsftwppdtplgns_options', array() ); |
| 19 |
$bstwbsftwppdtplgns_options = get_site_option( 'bstwbsftwppdtplgns_options' ); |
| 20 |
} else { |
| 21 |
if ( ! get_option( 'bstwbsftwppdtplgns_options' ) ) |
| 22 |
add_option( 'bstwbsftwppdtplgns_options', array() ); |
| 23 |
$bstwbsftwppdtplgns_options = get_option( 'bstwbsftwppdtplgns_options' ); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
if ( isset( $bstwbsftwppdtplgns_options['bws_menu_version'] ) ) { |
| 28 |
$bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] = $bws_menu_version; |
| 29 |
unset( $bstwbsftwppdtplgns_options['bws_menu_version'] ); |
| 30 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) |
| 31 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
| 32 |
else |
| 33 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
| 34 |
require_once( dirname( __FILE__ ) . '/bws_menu.php' ); |
| 35 |
require_once( dirname( __FILE__ ) . '/bws_functions.php' ); |
| 36 |
} else if ( ! isset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] ) || $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] < $bws_menu_version ) { |
| 37 |
$bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] = $bws_menu_version; |
| 38 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) |
| 39 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
| 40 |
else |
| 41 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
| 42 |
require_once( dirname( __FILE__ ) . '/bws_menu.php' ); |
| 43 |
require_once( dirname( __FILE__ ) . '/bws_functions.php' ); |
| 44 |
} else if ( ! isset( $bstwbsftwppdtplgns_added_menu ) ) { |
| 45 |
$all_plugins = get_plugins(); |
| 46 |
foreach ( $bstwbsftwppdtplgns_options['bws_menu']['version'] as $key => $value ) { |
| 47 |
if ( array_key_exists( $key, $all_plugins ) ) { |
| 48 |
if ( $bws_menu_version < $value && is_plugin_active( $base ) ) { |
| 49 |
if ( ! isset( $plugin_with_newer_menu ) ) |
| 50 |
$plugin_with_newer_menu = $key; |
| 51 |
elseif ( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $plugin_with_newer_menu ] < $bstwbsftwppdtplgns_options['bws_menu']['version'][ $key ] ) |
| 52 |
$plugin_with_newer_menu = $key; |
| 53 |
} |
| 54 |
} else { |
| 55 |
unset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $key ] ); |
| 56 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) |
| 57 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
| 58 |
else |
| 59 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
| 60 |
} |
| 61 |
} |
| 62 |
if ( ! isset( $plugin_with_newer_menu ) ) |
| 63 |
$plugin_with_newer_menu = $base; |
| 64 |
$plugin_with_newer_menu = explode( '/', $plugin_with_newer_menu ); |
| 65 |
$wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? basename( WP_CONTENT_DIR ) : 'wp-content'; |
| 66 |
|
| 67 |
if ( file_exists( ABSPATH . $wp_content_dir . '/plugins/' . $plugin_with_newer_menu[0] . '/bws_menu/bws_menu.php' ) ) { |
| 68 |
require_once( ABSPATH . $wp_content_dir . '/plugins/' . $plugin_with_newer_menu[0] . '/bws_menu/bws_menu.php' ); |
| 69 |
} else { |
| 70 |
require_once( dirname( __FILE__ ) . '/bws_menu.php' ); |
| 71 |
} |
| 72 |
|
| 73 |
if ( file_exists( ABSPATH . $wp_content_dir . '/plugins/' . $plugin_with_newer_menu[0] . '/bws_menu/bws_functions.php' ) ) { |
| 74 |
require_once( ABSPATH . $wp_content_dir . '/plugins/' . $plugin_with_newer_menu[0] . '/bws_menu/bws_functions.php' ); |
| 75 |
} else { |
| 76 |
require_once( dirname( __FILE__ ) . '/bws_functions.php' ); |
| 77 |
} |
| 78 |
|
| 79 |
$bstwbsftwppdtplgns_added_menu = true; |
| 80 |
} |
| 81 |
} |
| 82 |
} |