diff --git a/.gitignore b/.gitignore index c24764d..5a6cb58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# Editor-specific # +################### +.vscode/ + # Compiled source # ################### *.com @@ -33,4 +37,4 @@ .Spotlight-V100 .Trashes ehthumbs.db -Thumbs.db \ No newline at end of file +Thumbs.db diff --git a/addons/bulkaction-mpd-addon.php b/addons/bulkaction-mpd-addon.php index 7ddf0f1..dbb7bf5 100644 --- a/addons/bulkaction-mpd-addon.php +++ b/addons/bulkaction-mpd-addon.php @@ -43,7 +43,7 @@ function mpd_bulk_admin_script() { if( is_multisite() ){ $defaultoptions = mdp_get_default_options(); - $sites = mpd_wp_get_sites(); + $allowed_sites = mpd_get_allowed_sites(); $options = get_option('mdp_settings'); $post_status = isset($_REQUEST["post_status"]) ? $_REQUEST["post_status"] : ''; @@ -57,16 +57,12 @@ function mpd_bulk_admin_script() { jQuery(document).ready(function() { - + blog_id); ?> - blog_id != get_current_blog_id() && current_user_can_for_blog($site->blog_id, mpd_get_required_cap())):?> - - jQuery('').val("dup-blog_id ?>").text('blogname; ?>').appendTo("select[name='action']"); - jQuery('').val("dup-blog_id ?>").text('blogname; ?>').appendTo("select[name='action2']"); - - + jQuery('').val("dup-blog_id ?>").text('blogname; ?>').appendTo("select[name='action']"); + jQuery('').val("dup-blog_id ?>").text('blogname; ?>').appendTo("select[name='action2']"); diff --git a/addons/restrictSites-mpd-addon.php b/addons/restrictSites-mpd-addon.php index 1e5cbd8..bc9022d 100644 --- a/addons/restrictSites-mpd-addon.php +++ b/addons/restrictSites-mpd-addon.php @@ -45,15 +45,15 @@ function restrict_option_setting_render(){ value="none"> - + value="some"> - + value="master"> - + @@ -64,6 +64,18 @@ function restrict_option_setting_render(){ blog_id, $restricted_ids); + }); +} +add_filter('mpd_allowed_sites', 'mpd_filter_restricted_sites'); + /** * @ignore */ diff --git a/inc/mpd-functions.php b/inc/mpd-functions.php index f01cce3..07d1347 100644 --- a/inc/mpd-functions.php +++ b/inc/mpd-functions.php @@ -848,6 +848,21 @@ function mpd_settings_field($tag, $settings_title, $callback_function_to_markup, } +function mpd_get_allowed_sites() { + + $sites = mpd_wp_get_sites(); + + $current_blog_id = get_current_blog_id(); + + $valid_sites = array_filter($sites, function($site) use ($current_blog_id) { + + return $site->blog_id != $current_blog_id + && current_user_can_for_blog($site->blog_id, mpd_get_required_cap()); + }); + + return apply_filters('mpd_allowed_sites', $valid_sites); +} + /** * This function allows for hooking into the sites returned in the WP core wp_get_sites() function. * diff --git a/inc/persist.php b/inc/persist.php index b6c1c4d..5e597bc 100644 --- a/inc/persist.php +++ b/inc/persist.php @@ -402,7 +402,7 @@ function persist_option_setting_render(){ */ function persist_functionality_setting_render(){ - $options = get_option( 'mdp_settings' ); ?> + $options = get_option( 'mdp_settings' ) || mdp_get_default_options(); ?> diff --git a/inc/postform_ui.php b/inc/postform_ui.php index 7aa15e8..2717801 100644 --- a/inc/postform_ui.php +++ b/inc/postform_ui.php @@ -155,7 +155,7 @@ function mpd_metabox_prefix(){ */ function mpd_do_metabox_site_list(){ - $sites = mpd_wp_get_sites(); + $allowed_sites = mpd_get_allowed_sites(); ?>