Пример #1
0
function update_notifier_bar_menu()
{
    if (function_exists('simplexml_load_string')) {
        // Stop if simplexml_load_string funtion isn't available
        global $wp_admin_bar, $wpdb;
        if (!is_super_admin() || !is_admin_bar_showing()) {
            // Don't display notification in admin bar if it's disabled or the current user isn't an administrator
            return;
        }
        $xml = get_latest_theme_version(NOTIFIER_CACHE_INTERVAL);
        // Get the latest remote XML file on our server
        // get version
        if (function_exists('wp_get_theme')) {
            $theme_data = wp_get_theme(get_template());
            $version = $theme_data->version;
        } else {
            $theme_data = get_theme_data(get_template_directory() . '/style.css');
            $version = $theme_data['Version'];
        }
        if (!is_object($xml)) {
            return;
        }
        if (version_compare($xml->latest, $version, '>')) {
            // Compare current theme version with the remote XML version
            $wp_admin_bar->add_menu(array('id' => 'update_notifier', 'title' => '<span>' . NOTIFIER_THEME_NAME . ' <span id="ab-updates">1 Update</span></span>', 'href' => get_admin_url() . 'index.php?page=theme-update-notifier'));
        }
    }
}
Пример #2
0
 /**
  * Setup BuddyBar navigation
  */
 function setup_nav()
 {
     // Define local variable
     $sub_nav = array();
     // Add the settings navigation item
     $main_nav = array('name' => __('Settings', 'buddypress'), 'slug' => $this->slug, 'position' => 100, 'show_for_displayed_user' => bp_core_can_edit_settings(), 'screen_function' => 'bp_settings_screen_general', 'default_subnav_slug' => 'general');
     // Determine user to use
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     $settings_link = trailingslashit($user_domain . $this->slug);
     // Add General Settings nav item
     $sub_nav[] = array('name' => __('General', 'buddypress'), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_settings_screen_general', 'position' => 10, 'user_has_access' => bp_core_can_edit_settings());
     // Add Notifications nav item
     $sub_nav[] = array('name' => __('Notifications', 'buddypress'), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_settings_screen_notification', 'position' => 20, 'user_has_access' => bp_core_can_edit_settings());
     // Add Spam Account nav item
     if (bp_current_user_can('bp_moderate')) {
         $sub_nav[] = array('name' => __('Capabilities', 'buddypress'), 'slug' => 'capabilities', 'parent_url' => $settings_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_settings_screen_capabilities', 'position' => 80, 'user_has_access' => !bp_is_my_profile());
     }
     // Add Delete Account nav item
     if (!bp_disable_account_deletion() || bp_current_user_can('delete_users')) {
         $sub_nav[] = array('name' => __('Delete Account', 'buddypress'), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $this->slug, 'screen_function' => 'bp_settings_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_my_profile() || !is_super_admin(bp_displayed_user_id()));
     }
     parent::setup_nav($main_nav, $sub_nav);
 }
Пример #3
0
 /**
  * Builds the composite and returns button markup.
  * @return string
  */
 public function build()
 {
     $environment = $this->builder->getEnvironment();
     $dispatcher = $environment->getDispatcher();
     $this->project = $dispatcher->apply('before_build', array($this->project));
     if ((!array_key_exists('action', $_GET) || $_GET['action'] !== 'getPreviewHtml') && $this->project->isShowOnPosts() && !$this->project->isShowAt('popup')) {
         $current = get_post();
         if ($current === null) {
             return '';
         }
         if (!$this->project->isShortCodeShow() && $current->post_type === 'post' && (!$this->project->isShowOnAllPosts() && !$this->project->isShowOnSpecificPost($current->ID)) && !$this->project->showOnSpecificPostType($current->post_type) && !$this->project->isShowOnAllPostTypes()) {
             return '';
         }
         if ($current->post_type === 'page' && (!$this->project->isShowOnAllPages() && !$this->project->isShowOnSpecificPost($current->ID)) && !$this->project->showOnSpecificPostType($current->post_type) && !$this->project->isShowOnAllPostTypes()) {
             return '';
         }
         if (!$this->project->isShowOnAllPosts() && !$this->project->isShowOnAllPages() && !in_array($current->post_type, array('post', 'page'), false) && !$this->project->showOnSpecificPostType($current->post_type) && !$this->project->isShowOnAllPostTypes()) {
             return '';
         }
     }
     if (!$this->project->isShortCodeShow() && !$this->project->isPopupShow() && $this->project->isShowOnHomepage() && !$this->builder->isHomepage()) {
         return '';
     }
     try {
         $composite = $this->builder->getComposite();
     } catch (Exception $e) {
         if (defined('WP_DEBUG') && WP_DEBUG && (function_exists('is_super_admin') && is_super_admin())) {
             return sprintf($this->environment->translate('Failed to build the project: %s.'), $e->getMessage());
         }
         return '';
     }
     $this->project = $dispatcher->apply('after_build', array($this->project));
     $dispatcher->dispatch('before_html_build');
     return $composite->build();
 }
function onepager_enqueue_scripts()
{
    if (!onepager()->content()->isOnepage()) {
        return;
    }
    $asset = onepager()->asset();
    // TX namespaced assets to avoid multiple assets loading from other ThemeXpert product
    $asset->style('bootstrap', asset('assets/css/bootstrap.css'));
    $asset->style('animatecss', asset('assets/css/animate.css'));
    $asset->style('fontawesome', asset('assets/css/font-awesome.css'));
    $asset->script('bootstrap', asset('assets/js/bootstrap.js'), ['jquery']);
    $asset->script('wow', asset('assets/js/wow.js'), array('jquery'));
    $asset->script('nicescroll', asset('assets/js/jquery.nicescroll.js'), array('jquery'));
    $asset->script('lithium', asset('assets/lithium.js'), array('jquery'));
    $asset->style('lithium', asset('assets/css/lithium.css'));
    if (onepager()->content()->isBuildMode()) {
        if (function_exists('wp_enqueue_media')) {
            wp_enqueue_media();
            js_wp_editor();
        }
        $asset->style('tx-colorpicker', asset("assets/css/bootstrap-colorpicker.css"));
        $asset->script('tx-bootstrap-select', asset('assets/js/bootstrap-select.js'), ['jquery']);
        $asset->script('tx-iconselector', asset('assets/js/icon-selector-bootstrap.js'), ['jquery']);
        $asset->script('tx-colorpicker', asset('assets/js/bootstrap-colorpicker.js'), ['jquery']);
        $asset->script('tx-bootstrap-switch', asset('assets/js/bootstrap-switch.js'), ['jquery']);
        $asset->script('tx-toastr', asset('assets/js/toastr.js'), ['jquery']);
        $asset->script('onepager', asset('assets/app.bundle.js'), ['jquery']);
        $asset->localizeScript('onepager', onepager_localize_script_data(onepager()->content()->getCurrentPageId()), 'onepager');
    }
    if (is_super_admin()) {
        $asset->style('lithium-ui', asset('assets/css/lithium-builder.css'));
    }
}
Пример #5
0
 /**
  * menus()
  *
  * Adds menus to admin area
  */
 function menus()
 {
     if (!is_super_admin()) {
         return;
     }
     add_options_page(__('Courseware Options', 'bpsp'), __('Courseware', 'bpsp'), 'manage_options', 'bp-courseware', array(__CLASS__, "screen"));
 }
Пример #6
0
 public static function can_user($capability)
 {
     if (!function_exists('members_check_for_cap')) {
         return current_user_can('manage_options') || is_super_admin();
     }
     return current_user_can($capability);
 }
Пример #7
0
 /**
  * Build The Layout
  */
 function __construct($args = array(), PL_Platform $platform)
 {
     $this->platform = $platform;
     $defaults = array('title' => '', 'callback' => false, 'page_slug' => '', 'config' => array(), 'render' => 'settings');
     $this->set = wp_parse_args($args, $defaults);
     /** Gets the control array */
     $this->config = isset($this->set['callback']) && $this->set['callback'] ? call_user_func($this->set['callback']) : $this->set['config'];
     $this->current_tab_slug = isset($_GET['sel_tab']) ? $_GET['sel_tab'] : 'default';
     $this->settings_tab_slug = isset($_GET['settings_tab']) ? $_GET['settings_tab'] : 'default';
     $tab_default = array('title' => '', 'groups' => false, 'mode' => 'banner');
     $current_tab_info = isset($this->config[$this->current_tab_slug]) ? $this->config[$this->current_tab_slug] : current($this->config);
     $this->current_tab_config = wp_parse_args($current_tab_info, $tab_default);
     $this->current_page = $this->platform->tab();
     // Draw the thing
     $this->build_header();
     // if not logged in and user is a super admin.. show banner to connect account
     if ('account' == $this->current_page && !$this->platform->oauth->is_connected() && is_super_admin()) {
         $this->platform_banner();
     } elseif (has_action('pl_ui_build_body')) {
         do_action('pl_ui_build_body', $this);
     } else {
         $this->build_body();
     }
     $this->build_footer();
 }
 /**
  * Display an admin notice, if the Features by WooThemes plugin is present and not activated, or not present.
  * @access  public
  * @since   1.2.1
  * @return  void
  */
 public function maybe_display_activation_notice()
 {
     if ($this->_is_features_plugin_activated()) {
         return;
     }
     if (!current_user_can('manage_options')) {
         return;
     }
     // Don't show the message if the user isn't an administrator.
     if (is_multisite() && !is_super_admin()) {
         return;
     }
     // Don't show the message if on a multisite and the user isn't a super user.
     if (true == get_option('icons_for_features_dismiss_activation_notice', false)) {
         return;
     }
     // Don't show the message if the user dismissed it.
     $slug = 'features-by-woothemes';
     $install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $slug), 'install-plugin_' . $slug);
     $activate_url = 'plugins.php?action=activate&plugin=' . urlencode('features-by-woothemes/woothemes-features.php') . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode(wp_create_nonce('activate-plugin_features-by-woothemes/woothemes-features.php'));
     if (true == $this->_is_features_plugin_installed()) {
         $text = '<a href="' . esc_url($activate_url) . '">' . __('Activate the Features by WooThemes plugin', 'icons-for-features') . '</a>';
     } else {
         $text = '<a href="' . esc_url($install_url) . '">' . __('Install the Features by WooThemes plugin', 'icons-for-features') . '</a>';
     }
     $text = sprintf(__('%sIcons for Features%s is almost ready. %s to get started.', 'icons-for-features'), '<strong>', '</strong>', $text);
     $dismiss_url = add_query_arg('action', 'icons-for-features-dismiss', add_query_arg('nonce', wp_create_nonce('icons-for-features-dismiss')));
     echo '<div class="updated fade"><p class="alignleft">' . $text . '</p><p class="alignright"><a href="' . esc_url($dismiss_url) . '">' . __('Dismiss', 'icons-for-features') . '</a></p><div class="clear"></div></div>' . "\n";
 }
Пример #9
0
	function catch_submit() {
		if ( isset( $_POST['add_ids'] ) ) {
			$redirect    = 'user-new.php';
			foreach( (array)$_POST['add_ids'] as $user_id ) {
				if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
					add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) );
					$users_added[] = (int)$user_id;
				} else {
					$user_details = get_userdata( $user_id );
					$newuser_key = substr( md5( $user_id ), 0, 5 );
					add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) );
					$message = __("Hi,\n\nYou have been invited to join '%s' at\n%s as a %s.\nPlease click the following link to confirm the invite:\n%s\n");
					wp_mail( $user_details->user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ),  sprintf($message, get_option('blogname'), site_url(), $_REQUEST[ 'role' ], site_url("/newbloguser/$newuser_key/")));
					$users_invited[] = (int)$user_id;
				}
			}

			if ( !empty( $users_added ) ) {
				$redirect = add_query_arg( 'users_added', implode( ',', $users_added ), $redirect );
			}

			if ( !empty( $users_invited ) ) {
				$redirect = add_query_arg( 'users_invited', implode( ',', $users_invited ), $redirect );
			}

			unset( $_POST );
			wp_redirect( $redirect );
		}
	}
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     /*
      * 
      * - Decomment following lines if the admin class should only be available for super admins
      */
     if (!is_super_admin()) {
         return;
     }
     /*
      * Call $plugin_slug from public plugin class.
      *
      *
      * - Rename "Custom_Post_Type_RSS_Feeds" to the name of your initial plugin class
      *
      */
     $plugin = Custom_Post_Type_RSS_Feeds::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     // Load admin style sheet and JavaScript.
     //add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
     //add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
     // Add an action link pointing to the options page.
     $plugin_basename = dirname(dirname(plugin_basename(__FILE__))) . '/' . $this->plugin_slug . '.php';
     add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
 }
Пример #11
0
function create_dwb_menu()
{
    if (is_super_admin()) {
        return;
    }
    global $wp_admin_bar;
    $current_user = wp_get_current_user();
    $userinfo = $wp_admin_bar->get_node('user-info');
    $userinfo->href = get_permalink(get_id_by_slug("members-dashboard"));
    $avatar = get_avatar($userinfo->ID, 64);
    $userinfo->title = $avatar . $current_user->last_name;
    $array = (array) $userinfo;
    $wp_admin_bar->add_menu($array);
    $logout = $wp_admin_bar->get_node('logout');
    $logout->href = wp_logout_url(get_permalink(get_id_by_slug("members-login")));
    $array = (array) $logout;
    $wp_admin_bar->add_menu($array);
    $sitename = $wp_admin_bar->get_node('site-name');
    $sitename->href = home_url();
    $array = (array) $sitename;
    $wp_admin_bar->add_menu($array);
    $my_account = $wp_admin_bar->get_node('my-account');
    $avatar = get_avatar($userinfo->ID, 28);
    $my_account->title = "Hello, {$current_user->last_name}" . $avatar;
    $array = (array) $my_account;
    $wp_admin_bar->add_menu($array);
    $wp_admin_bar->remove_node('edit-profile');
    $wp_admin_bar->remove_node('wp-logo');
    $wp_admin_bar->remove_node('dashboard');
}
Пример #12
0
 function prepare_items()
 {
     $orderby = 'domain';
     if (array_key_exists('orderby', $_REQUEST) && $_REQUEST['orderby'] != '') {
         $orderby = $_REQUEST['orderby'];
     }
     $order = 'asc';
     if (array_key_exists('order', $_REQUEST) && $_REQUEST['order'] != '') {
         $order = $_REQUEST['order'];
     }
     $domain = null;
     if (array_key_exists('s', $_REQUEST) && $_REQUEST['s'] != '') {
         $domain = "http://%" . $_REQUEST['s'] . "%";
     }
     $per_page = 25;
     $current_page = $this->get_pagenum();
     $offset = ($current_page - 1) * $per_page;
     $limit = $current_page * $per_page;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     if (is_super_admin()) {
         $data = Campaign::findAll($orderby, $order, $offset, $limit, $domain);
     } else {
         $user = wp_get_current_user();
         $data = Campaign::findAll($orderby, $order, $offset, $limit, $domain, $user->ID);
     }
     $total_items = $data->count;
     $this->items = $data->itens;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
     return $this->items;
 }
Пример #13
0
 /**
  * wcj_shortcode.
  */
 function wcj_shortcode($atts, $content, $shortcode)
 {
     // Init
     if (empty($atts)) {
         $atts = array();
     }
     $global_defaults = array('before' => '', 'after' => '', 'visibility' => '');
     $atts = array_merge($global_defaults, $atts);
     // Check if privileges are ok
     if ('admin' === $atts['visibility'] && !is_super_admin()) {
         return '';
     }
     // Add child class specific atts
     $atts = $this->add_extra_atts($atts);
     // Check for required atts
     if (false === ($atts = $this->init_atts($atts))) {
         return '';
     }
     // Run the shortcode function
     $shortcode_function = $shortcode;
     if ('' !== ($result = $this->{$shortcode_function}($atts, $content))) {
         return $atts['before'] . $result . $atts['after'];
     }
     return '';
 }
Пример #14
0
/**
 * Retrieve product data from Beans REST API.
 *
 * Data are cached in a 24 hours transients and will be returned if found to avoid long loading time.
 *
 * @ignore
 */
function beans_updater($value)
{
    // Stop here if the current user is not a super admin user.
    if (!is_super_admin()) {
        return;
    }
    $data = get_site_transient('beans_updater');
    $theme = wp_get_theme('tm-beans');
    if (!$theme->exists()) {
        return $value;
    }
    $current_version = $theme->get('Version');
    // Query Beans REST API if the transient is expired.
    if (empty($data)) {
        $response = wp_remote_get('http://www.getbeans.io/rest-api/', array('sslverify' => false));
        // Retrieve data from the body and decode json format.
        $data = json_decode(wp_remote_retrieve_body($response), true);
        // Stop here if the is an error.
        if (is_wp_error($response) || isset($data['error'])) {
            // Set temporary transient.
            set_site_transient('beans_updater', array('version' => $current_version), 30 * MINUTE_IN_SECONDS);
            return $value;
        }
        set_site_transient('beans_updater', $data, 24 * HOUR_IN_SECONDS);
    }
    // Return data if Beans is not up to date.
    if (version_compare($current_version, beans_get('version', $data), '<')) {
        $value->response[$data['path']] = array('slug' => $data['slug'], 'name' => $data['name'], 'url' => $data['changelog_url'], 'package' => $data['download_url'], 'new_version' => $data['version'], 'tested' => $data['tested'], 'requires' => $data['requires']);
        return $value;
    }
    return $value;
}
 function __construct($manager_obj)
 {
     if (!is_super_admin() && !current_user_can('restore_roles')) {
         wp_die(__('You do not have permission to restore roles.', 'capsman-enhanced'));
     }
     $this->cm = $manager_obj;
 }
Пример #16
0
 function post_review($args = '')
 {
     global $bp;
     $defaults = array('content' => false, 'rating' => false, 'user_id' => $bp->loggedin_user->id, 'group_id' => $bp->groups->current_group->id);
     $r = wp_parse_args($args, $defaults);
     extract($r, EXTR_SKIP);
     if (empty($content) || !strlen(trim($content)) || empty($user_id) || empty($group_id)) {
         return false;
     }
     // Be sure the user is a member of the group before posting.
     if (!is_super_admin() && !groups_is_user_member($user_id, $group_id)) {
         return false;
     }
     // Record this in activity streams
     $activity_action = sprintf(__('%s reviewed %s:', 'bpgr'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . '">' . esc_html($bp->groups->current_group->name) . '</a>');
     $rating_content = false;
     if (!empty($rating)) {
         $rating_content = '<span class="p-rating">' . bpgr_get_review_rating_html($rating) . '</span>';
     }
     $activity_content = $rating_content . $content;
     $activity_id = groups_record_activity(array('user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'type' => 'review', 'item_id' => $group_id));
     $this->add_rating(array('score' => $rating, 'activity_id' => $activity_id, 'group_id' => $group_id));
     groups_update_groupmeta($group_id, 'last_activity', gmdate("Y-m-d H:i:s"));
     do_action('bpgr_posted_review', $args, $activity_id);
     return $activity_id;
 }
Пример #17
0
function bgnp_add_admin_menu()
{
    // Hook for Super Admin permissions for Premium Google News Plugin dashboard
    if (is_multisite() && !is_super_admin()) {
        $bgnpSuperAdminsError = 'Only Super Admins can access my plugin';
        return $bgnpSuperAdminsError;
    } else {
        // Add main page
        $admin_page = add_menu_page(__('Google News Editors’ Picks RSS Feed Generator', 'google-news-editors-picks-feeds'), __('Google News'), 'manage_options', 'bgnp_dashboard', 'bgnp_general_settings_page', bgnp_URL . '/images/bgnp-rss-icon.png', '6');
        $submenu_pages = array(array('bgnp_dashboard', __('Tutorials'), __('Tutorials'), 'manage_options', 'bgnp_upgrade_settings', 'bgnp_upgrade_settings_page', array('load_page'), null), array('bgnp_dashboard', __('Editors’ Picks RSS Feeds'), __('Editors’ Picks'), 'manage_options', 'bgnp_feed_settings', 'bgnp_feed_settings_page', array('load_page'), null));
        // Loop through submenu pages and add them
        if (count($submenu_pages)) {
            foreach ($submenu_pages as $submenu_page) {
                $admin_page = add_submenu_page($submenu_page[0], $submenu_page[1], $submenu_page[2], $submenu_page[3], $submenu_page[4], $submenu_page[5]);
            }
        }
        // Add separate menu for dashboard
        global $submenu;
        if (isset($submenu['bgnp_dashboard'])) {
            $submenu['bgnp_dashboard'][0][0] = __('Dashboard', 'google-news-editors-picks-feeds');
        }
        // Load the CSS conditionally
        add_action('admin_print_styles-' . $submenu_pages, 'bgnp_admin_styles');
    }
}
Пример #18
0
function bpdd_admin_page()
{
    if (!is_super_admin()) {
        return;
    }
    add_management_page(__('BuddyPress Default Data', 'bpdd'), __('BP Default Data', 'bpdd'), 'manage_options', 'bpdd-setup', 'bpdd_admin_page_content');
}
Пример #19
0
/**
 * Checks status of current blog.
 *
 * Checks if the blog is deleted, inactive, archived, or spammed.
 *
 * Dies with a default message if the blog does not pass the check.
 *
 * To change the default message when a blog does not pass the check,
 * use the wp-content/blog-deleted.php, blog-inactive.php and
 * blog-suspended.php drop-ins.
 *
 * @return bool|string Returns true on success, or drop-in file to include.
 */
function ms_site_check()
{
    global $wpdb, $current_blog;
    // Allow short-circuiting
    $check = apply_filters('ms_site_check', null);
    if (null !== $check) {
        return true;
    }
    // Allow super admins to see blocked sites
    if (is_super_admin()) {
        return true;
    }
    if ('1' == $current_blog->deleted) {
        if (file_exists(WP_CONTENT_DIR . '/blog-deleted.php')) {
            return WP_CONTENT_DIR . '/blog-deleted.php';
        } else {
            wp_die(__('This user has elected to delete their account and the content is no longer available.'), '', array('response' => 410));
        }
    }
    if ('2' == $current_blog->deleted) {
        if (file_exists(WP_CONTENT_DIR . '/blog-inactive.php')) {
            return WP_CONTENT_DIR . '/blog-inactive.php';
        } else {
            wp_die(sprintf(__('This site has not been activated yet. If you are having problems activating your site, please contact <a href="mailto:%1$s">%1$s</a>.'), str_replace('@', ' AT ', get_site_option('admin_email', "support@{$current_site->domain}"))));
        }
    }
    if ($current_blog->archived == '1' || $current_blog->spam == '1') {
        if (file_exists(WP_CONTENT_DIR . '/blog-suspended.php')) {
            return WP_CONTENT_DIR . '/blog-suspended.php';
        } else {
            wp_die(__('This site has been archived or suspended.'), '', array('response' => 410));
        }
    }
    return true;
}
 /**
  * Can user do what he doo.
  * Any rule has three types of state: true,false, string.
  *
  * @param string $rule
  * @param bool|true $check_state
  *
  * @return $this
  */
 public function can($rule = '', $check_state = true)
 {
     if (null === $this->getRole()) {
         $this->setValidAccess(is_super_admin());
     } elseif ($this->getValidAccess()) {
         // YES it is hard coded :)
         if ('administrator' === $this->getRole()->name && 'settings' === $this->getPart() && ('vc-roles-tab' === $rule || 'vc-updater-tab' === $rule)) {
             $this->setValidAccess(true);
             return $this;
         }
         $rule = $this->updateMergedCaps($rule);
         if (true === $check_state) {
             $state = $this->getState();
             $return = false !== $state;
             if (null === $state) {
                 $return = true;
             } elseif (is_bool($state)) {
                 $return = $state;
             } elseif ('' !== $rule) {
                 $return = $this->getCapRule($rule);
             }
         } else {
             $return = $this->getCapRule($rule);
         }
         $return = apply_filters('vc_role_access_with_' . $this->getPart() . '_can', $return, $this->getRole(), $rule);
         $return = apply_filters('vc_role_access_with_' . $this->getPart() . '_can_' . $rule, $return, $this->getRole());
         $this->setValidAccess($return);
     }
     return $this;
 }
Пример #21
0
/**
 * Change redirect upon login to user's My Catalog page
 *
 * @param string $redirect_to
 * @param string $request_redirect_to
 * @param \WP_User $user
 *
 * @return string
 */
function login($redirect_to, $request_redirect_to, $user)
{
    if (false === is_a($user, 'WP_User')) {
        // Unknown user, bail with default
        return $redirect_to;
    }
    if (is_super_admin($user->ID)) {
        // This is an admin, don't mess
        return $redirect_to;
    }
    $blogs = get_blogs_of_user($user->ID);
    if (array_key_exists(get_current_blog_id(), $blogs)) {
        // Yes, user has access to this blog
        return $redirect_to;
    }
    if ($user->primary_blog) {
        // Force redirect the user to their blog or, if they have more than one, to their catalog, bypass wp_safe_redirect()
        if (count($blogs) > 1) {
            $redirect = get_blogaddress_by_id($user->primary_blog) . 'wp-admin/index.php?page=pb_catalog';
        } else {
            $redirect = get_blogaddress_by_id($user->primary_blog) . 'wp-admin/';
        }
        location($redirect);
    }
    // User has no primary_blog? Make them sign-up for one
    return network_site_url('/wp-signup.php');
}
 protected function _get_allow_caps()
 {
     if (empty($this->_allow_caps)) {
         $user = get_user_by('id', get_current_user_id());
         if (!$user) {
             wp_die('No allowed here.');
         }
         $user_cap = strtolower(key($user->caps));
         $allow_caps = array();
         foreach ($this->_caps as $key => $cap_allow) {
             if ($key === $user_cap) {
                 $allow_caps = array_merge($allow_caps, $cap_allow);
                 break;
             }
         }
         // TODO: Find better way to Multisite compatibility.
         if (is_super_admin() || current_user_can('view_all_aryo_activity_log')) {
             $allow_caps = $this->_caps['administrator'];
         }
         if (empty($allow_caps)) {
             wp_die('No allowed here.');
         }
         $this->_allow_caps = array_unique($allow_caps);
     }
     return $this->_allow_caps;
 }
Пример #23
0
/**
 * Catch a "Mark as Spammer/Not Spammer" click from the toolbar.
 *
 * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
 * this action will fire and mark or unmark the user and their blogs as spam.
 * Must be a site admin for this function to run.
 *
 * Note: no longer used in the current state. See the Settings component.
 *
 * @param int $user_id Optional. User ID to mark as spam. Defaults to displayed
 *        user.
 */
function bp_core_action_set_spammer_status($user_id = 0)
{
    // Only super admins can currently spam users (but they can't spam
    // themselves)
    if (!is_super_admin() || bp_is_my_profile()) {
        return;
    }
    // Use displayed user if it's not yourself
    if (empty($user_id)) {
        $user_id = bp_displayed_user_id();
    }
    if (bp_is_current_component('admin') && in_array(bp_current_action(), array('mark-spammer', 'unmark-spammer'))) {
        // Check the nonce
        check_admin_referer('mark-unmark-spammer');
        // To spam or not to spam
        $status = bp_is_current_action('mark-spammer') ? 'spam' : 'ham';
        // The heavy lifting
        bp_core_process_spammer_status($user_id, $status);
        // Add feedback message. @todo - Error reporting
        if ('spam' == $status) {
            bp_core_add_message(__('User marked as spammer. Spam users are visible only to site admins.', 'buddypress'));
        } else {
            bp_core_add_message(__('User removed as spammer.', 'buddypress'));
        }
        // Deprecated. Use bp_core_process_spammer_status.
        $is_spam = 'spam' == $status;
        do_action('bp_core_action_set_spammer_status', bp_displayed_user_id(), $is_spam);
        // Redirect back to where we came from
        bp_core_redirect(wp_get_referer());
    }
}
    function byt_admin_notices()
    {
        if (is_super_admin()) {
            $screen = get_current_screen();
            if ($screen->id != 'appearance_page_options-framework') {
                $byt_version_before_update = get_option('_byt_version_before_update', 0);
                global $byt_installed_version;
                ?>
			<div id="message" class="updated">
				<p><strong><?php 
                _e('Your Book Your Travel database needs an upgrade!', 'bookyourtravel');
                ?>
</strong></p>
				<p><?php 
                echo sprintf(__('Your current database version is <strong>%s</strong>, while the current theme version is <strong>%s</strong>.', 'bookyourtravel'), $byt_version_before_update, $byt_installed_version);
                ?>
</p>
				<p><?php 
                _e('Please click the button below to go to the upgrade screen.', 'bookyourtravel');
                ?>
</p>
				<p class="submit"><a href="<?php 
                echo esc_url(admin_url('themes.php?page=options-framework#options-group-14'));
                ?>
" class="button-primary"><?php 
                _e('Go To Upgrade Screen', 'woocommerce');
                ?>
</a></p>
			</div>
			<?php 
            }
        }
    }
Пример #25
0
function um_block_wpadmin_by_user_role()
{
    global $ultimatemember;
    if (is_admin() && !defined('DOING_AJAX') && um_user('ID') && !um_user('can_access_wpadmin') && !is_super_admin(um_user('ID'))) {
        um_redirect_home();
    }
}
Пример #26
0
function messages_action_view_message()
{
    global $thread_id, $bp;
    if (!bp_is_messages_component() || !bp_is_current_action('view')) {
        return false;
    }
    $thread_id = (int) bp_action_variable(0);
    if (!$thread_id || !messages_is_valid_thread($thread_id) || !messages_check_thread_access($thread_id) && !is_super_admin()) {
        bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug());
    }
    // Check if a new reply has been submitted
    if (isset($_POST['send'])) {
        // Check the nonce
        check_admin_referer('messages_send_message', 'send_message_nonce');
        // Send the reply
        if (messages_new_message(array('thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content']))) {
            bp_core_add_message(__('Your reply was sent successfully', 'buddypress'));
        } else {
            bp_core_add_message(__('There was a problem sending your reply, please try again', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/');
    }
    // Mark message read
    messages_mark_thread_read($thread_id);
    // Decrease the unread count in the nav before it's rendered
    $name = sprintf(__('Messages <span>%s</span>', 'buddypress'), bp_get_total_unread_messages_count());
    $bp->bp_nav[$bp->messages->slug]['name'] = $name;
    do_action('messages_action_view_message');
    bp_core_new_subnav_item(array('name' => sprintf(__('From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id)), 'slug' => 'view', 'parent_url' => trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug()), 'parent_slug' => bp_get_messages_slug(), 'screen_function' => true, 'position' => 40, 'user_has_access' => bp_is_my_profile(), 'link' => bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . (int) $thread_id));
    bp_core_load_template(apply_filters('messages_template_view_message', 'members/single/home'));
}
Пример #27
0
 /**
  * Set up navigation.
  *
  * @param array $main_nav Array of main nav items.
  * @param array $sub_nav  Array of sub nav items.
  */
 public function setup_nav($main_nav = array(), $sub_nav = array())
 {
     // Determine user to use
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     $access = bp_core_can_edit_settings();
     $slug = bp_get_settings_slug();
     $settings_link = trailingslashit($user_domain . $slug);
     // Add the settings navigation item
     $main_nav = array('name' => __('Settings', 'buddypress'), 'slug' => $slug, 'position' => 100, 'show_for_displayed_user' => $access, 'screen_function' => 'bp_settings_screen_general', 'default_subnav_slug' => 'general');
     // Add General Settings nav item
     $sub_nav[] = array('name' => __('General', 'buddypress'), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $slug, 'screen_function' => 'bp_settings_screen_general', 'position' => 10, 'user_has_access' => $access);
     // Add Email nav item. Formerly called 'Notifications', we
     // retain the old slug and function names for backward compat
     $sub_nav[] = array('name' => __('Email', 'buddypress'), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $slug, 'screen_function' => 'bp_settings_screen_notification', 'position' => 20, 'user_has_access' => $access);
     // Add Spam Account nav item
     if (bp_current_user_can('bp_moderate')) {
         $sub_nav[] = array('name' => __('Capabilities', 'buddypress'), 'slug' => 'capabilities', 'parent_url' => $settings_link, 'parent_slug' => $slug, 'screen_function' => 'bp_settings_screen_capabilities', 'position' => 80, 'user_has_access' => !bp_is_my_profile());
     }
     // Add Delete Account nav item
     if (!bp_disable_account_deletion() && bp_is_my_profile() || bp_current_user_can('delete_users')) {
         $sub_nav[] = array('name' => __('Delete Account', 'buddypress'), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $slug, 'screen_function' => 'bp_settings_screen_delete_account', 'position' => 90, 'user_has_access' => !is_super_admin(bp_displayed_user_id()));
     }
     parent::setup_nav($main_nav, $sub_nav);
 }
 /**
  * Show a form where users can enter their license key
  * Takes Multisites into account
  *
  * @param bool $embedded
  * @return null
  */
 public function show_license_form($embedded = true)
 {
     // For non-multisites, always show the license form
     if (!is_multisite()) {
         parent::show_license_form($embedded);
         return;
     }
     // Plugin is network activated
     if ($this->is_network_activated) {
         // We're on the network admin
         if (is_network_admin()) {
             parent::show_license_form($embedded);
         } else {
             // We're not in the network admin area, show a notice
             parent::show_license_form_heading();
             if (is_super_admin()) {
                 echo "<p>" . sprintf(__('%s is network activated, you can manage your license in the <a href="%s">network admin license page</a>.', $this->product->get_text_domain()), $this->product->get_item_name(), $this->product->get_license_page_url()) . "</p>";
             } else {
                 echo "<p>" . sprintf(__('%s is network activated, please contact your site administrator to manage the license.', $this->product->get_text_domain()), $this->product->get_item_name()) . "</p>";
             }
         }
     } else {
         if (false == is_network_admin()) {
             parent::show_license_form($embedded);
         }
     }
 }
Пример #29
0
function ubermenu_update_notifier_bar_menu()
{
    global $uberMenu;
    if (!$uberMenu->getSettings()->op('update-alerts')) {
        return;
    }
    if (!function_exists('simplexml_load_string')) {
        return;
    }
    global $wp_admin_bar, $wpdb;
    if (!is_super_admin() || !is_admin_bar_showing()) {
        return;
    }
    $xml = ubermenu_get_latest_plugin_version(UBERMENU_UPDATE_DELAY);
    //21600); // This tells the function to cache the remote call for 21600 seconds (6 hours)
    $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/ubermenu/ubermenu.php');
    // Get plugin data (current version is what we want)
    if (!$xml) {
        //we can't retrieve the XML file and parse it properly
        return;
    }
    if (version_compare($plugin_data['Version'], $xml->latest) == -1) {
        $wp_admin_bar->add_menu(array('id' => 'ubermenu_update_notifier', 'title' => '<span> ' . __('UberMenu', 'ubermenu') . ' <span id="ab-updates">' . __('New Updates', 'ubermenu') . '</span></span>', 'href' => get_admin_url() . 'themes.php?page=uber-menu&updates=1'));
    }
}
Пример #30
-1
function d4p_bbt_is_role($setting_name) {
    global $gdbbpress_tools;
    $allowed = false;

    if (current_user_can('d4p_bbpt_'.$setting_name)) {
        $allowed = true;
    } else if (is_super_admin()) {
        $allowed = $gdbbpress_tools->o[$setting_name.'_super_admin'] == 1;
    } else if (is_user_logged_in()) {
        $roles = $gdbbpress_tools->o[$setting_name.'_roles'];

        if (is_null($roles)) {
            $allowed = true;
        } else if (is_array($roles)) {
            global $current_user;

            if (is_array($current_user->roles)) {
                $matched = array_intersect($current_user->roles, $roles);
                $allowed = !empty($matched);
            }
        }
    }

    return $allowed;
}