• Resolved dangerouspiper

    (@dangerouspiper)


    On a multisite installation, is there a way to make settings page only available for network admin and disallow site admins to configure Embed Privacy?

    I’m trying to build a small plugin to do that… but I’m not sure how. Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Matthias Kittsteiner

    (@kittmedia)

    Hi there,

    currently, that is not supported out of the box. However, you should be able to achieve that with the available filters in WordPress. After the content in the menu has been added by Embed Privacy, you can filter the menu and remove the menu item if the user has is no super admin.

    Additionally, you can filter the capability of manage_options to something else and only give your super administrators this capability.

    Best regards,
    Matthias

    Thread Starter dangerouspiper

    (@dangerouspiper)

    Good Idea, I’ll try that. Thank you very much, and thank you for your plugin, is really nice.

    Thread Starter dangerouspiper

    (@dangerouspiper)

    Finally I wrote a small clumsy plugin that solves my problem, maybe it’s useful for somebody else. (I’m not a developer so use carefully).

    The options stored in site 1 (defined in variable $mainsite) overwrites all other sites options. I could add a network setting page to manage the options or simply set the main site, but for me is enough in that way. Thank you @kittmedia for your help!

    <?php

    /* <WP Plugin Data>
    * Plugin Name: Altuxa privacidá d'incrustaciones
    * Version: 1.0
    * Plugin URI:
    * License: GNU/GPL3
    * Description: Afita los axustes d'Embed Privacy a tolos sitios d'una rede
    * Author: Mikel González
    * Author URI: https://altuxa.net/
    * Requires Plugins: embed-privacy
    */

    defined( 'ABSPATH' ) || exit;

    //Removes embed-privacy settings page link and add a link to manage the embeds
    function altuxa_privacida_incrustaciones_removesettings() {
    remove_submenu_page( 'options-general.php', 'embed_privacy' );
    add_submenu_page( 'options-general.php', 'Remanar incrustaciones', 'Remanar incrustaciones', 'manage_options', 'edit.php?post_type=epi_embed' );
    }

    function altuxa_privacida_incrustaciones_run() {
    //check if embed-privacy and embed-privacy-network are active for network
    if ( (is_plugin_active_for_network( 'embed-privacy/embed-privacy.php' )) && (is_plugin_active_for_network( 'altuxa_privacida_incrustaciones.php' )) ) {
    //take the options of the main site to default the others

    //DEFINE MAIN SITE ID
    $mainsite = 1;
    //DEFINE MAIN SITE ID

    //get current site id
    $currentsite = get_current_blog_id();
    //If current site is not main site
    if($mainsite!=$currentsite) {
    //get settings of current site
    $currentsettings = array(
    'js_detection' => get_option('embed_privacy_javascript_detection'),
    'local_tweets' => get_option('embed_privacy_local_tweets'),
    'disable_link' => get_option('embed_privacy_disable_link'),
    'dw_thumbnails' => get_option('embed_privacy_download_thumbnails'),
    'preserve_data' => get_option('embed_privacy_preserve_data_on_uninstall')
    );
    //switch to main site
    switch_to_blog($mainsite);
    //get settings of main site
    $mainsettings = array(
    'js_detection' => get_option('embed_privacy_javascript_detection'),
    'local_tweets' => get_option('embed_privacy_local_tweets'),
    'disable_link' => get_option('embed_privacy_disable_link'),
    'dw_thumbnails' => get_option('embed_privacy_download_thumbnails'),
    'preserve_data' => get_option('embed_privacy_preserve_data_on_uninstall')
    );
    restore_current_blog();
    //if settings are not equals
    if ($currentsettings!=$mainsettings){
    if($currentsettings['js_detection']!=$mainsettings['js_detection']) {update_option('embed_privacy_javascript_detection', $mainsettings['js_detection']);}
    if($currentsettings['local_tweets']!=$mainsettings['local_tweets']) {update_option('embed_privacy_local_tweets', $mainsettings['local_tweets']);}
    if($currentsettings['disable_link']!=$mainsettings['disable_link']) {update_option('embed_privacy_disable_link', $mainsettings['disable_link']);}
    if($currentsettings['dw_thumbnails']!=$mainsettings['dw_thumbnails']) {update_option('embed_privacy_download_thumbnails', $mainsettings['dw_thumbnails']);}
    if($currentsettings['preserve_data']!=$mainsettings['preserve_data']) {update_option('embed_privacy_preserve_data_on_uninstall', $mainsettings['preserve_data']);}
    }
    }

    //if current user cannot manage network remove settings page
    if (!current_user_can('manage_network')){
    //removes link
    add_action('admin_menu', 'altuxa_privacida_incrustaciones_removesettings');
    //redirect
    global $pagenow;
    if ( ($pagenow=='options-general.php') && isset($_GET['page']) && ($_GET['page'] == 'embed_privacy') ){
    wp_redirect( 'edit.php?post_type=epi_embed' );
    exit();
    }
    }
    }
    }

    //run main function
    add_action('init','altuxa_privacida_incrustaciones_run');
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.