/**
  * Add custom columns (ID and Site Category) in Sites listing
  *
  */
 public function add_columns($column_name, $blog_id)
 {
     if ('mature' === $column_name) {
         if (apply_filters('msc_show_mature_column', B5F_Multisite_Categories::$show_mature_column)) {
             echo get_blog_status($blog_id, 'mature');
         }
     } elseif ('column-site-cat' === $column_name) {
         $cat_name = get_blog_option($blog_id, 'site_category');
         $uncategorized = '<span style="opacity:.5">Uncategorized</span>';
         echo empty($cat_name) ? $uncategorized : $cat_name;
     }
     return $column_name;
 }
 /**
  * Add new option when registering a site (back and front end)
  *
  * URI: http://stackoverflow.com/a/10372861/1287812
  */
 public function add_new_blog_field($blog_id, $user_id, $domain, $path, $site_id, $meta)
 {
     $new_field_value = '';
     # Site added in the back end
     if (!empty($_POST['blog']['input_site_cat'])) {
         switch_to_blog($blog_id);
         $cat_id = $_POST['blog']['input_site_cat'];
         # TODO: if Sign-up is to be enabled, change this to a method
         $val = B5F_Multisite_Categories::get_instance()->do_mature_to_name($cat_id);
         update_blog_option($blog_id, 'site_category', $val);
         update_blog_status($blog_id, 'mature', $cat_id);
         get_blog_status($blog_id, 'mature');
         restore_current_blog();
     } elseif (!empty($meta['input_site_cat'])) {
         $new_field_value = $meta['input_site_cat'];
         update_option('site_category', $new_field_value);
     }
 }
 function get_wpmu_posts($args = array())
 {
     global $wpdb;
     $blogArgs = array('network_id' => $wpdb->siteid, 'public' => is_user_logged_in() ? null : 1, 'archived' => null, 'mature' => null, 'spam' => null, 'deleted' => null, 'limit' => 999, 'offset' => 1);
     $blogs = get_sites($blogArgs);
     foreach ($blogs as $i => $blog) {
         $status = get_blog_status($blog->blog_id, 'public');
         if (!$status && (!is_user_logged_in() || !is_user_member_of_blog(get_current_user_id(), $blog->blog_id) && !is_super_admin())) {
             unset($blogs[$i]);
         }
     }
     $args = array_merge(array('posts_per_page' => 5, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'suppress_filters' => true, 'paged' => get_query_var('paged') ? get_query_var('paged') : 1), $args);
     extract($args);
     $args['posts_per_page'] = -1;
     $args['paged'] = 1;
     $orderbyVal = $orderby === 'meta_value' ? $meta_key : $orderby;
     $posts = array();
     $current_blog = get_current_blog_id();
     foreach ($blogs as $blog) {
         switch_to_blog($blog->blog_id);
         $blog_posts = get_posts($args);
         foreach ($blog_posts as $blog_post) {
             $blog_post->blog_id = $blog->blog_id;
             if ($orderby === 'date') {
                 $ordering = strtotime($blog_post->{$orderbyVal});
             } else {
                 $ordering = $blog_post->{$orderbyVal};
             }
             while (isset($posts[$ordering])) {
                 $ordering = $ordering + 1;
             }
             $posts[$ordering] = $blog_post;
         }
     }
     switch_to_blog($current_blog);
     krsort($posts);
     if ($posts_per_page == -1) {
         return array_slice($posts, 0, count($posts));
     } else {
         return array_slice($posts, ($paged - 1) * $posts_per_page, $posts_per_page);
     }
 }
Exemple #4
0
function sitewide_tags_post($post_id, $post)
{
    global $wpdb;
    if (!get_sitewide_tags_option('tags_blog_enabled')) {
        return;
    }
    // wp_insert_category()
    include_once ABSPATH . 'wp-admin/includes/admin.php';
    $tags_blog_id = get_sitewide_tags_option('tags_blog_id');
    if (!$tags_blog_id || $wpdb->blogid == $tags_blog_id) {
        return;
    }
    $allowed_post_types = apply_filters('sitewide_tags_allowed_post_types', array('post' => true));
    if (!$allowed_post_types[$post->post_type]) {
        return;
    }
    $post_blog_id = $wpdb->blogid;
    $blog_status = get_blog_status($post_blog_id, "public");
    if ($blog_status != 1 && ($blog_status != 0 || get_sitewide_tags_option('tags_blog_public') == 1 || get_sitewide_tags_option('tags_blog_pub_check') == 0)) {
        return;
    }
    $post->post_category = wp_get_post_categories($post_id);
    $cats = array();
    foreach ($post->post_category as $c) {
        $cat = get_category($c);
        $cats[] = array('name' => esc_html($cat->name), 'slug' => esc_html($cat->slug));
    }
    $post->tags_input = implode(', ', wp_get_post_tags($post_id, array('fields' => 'names')));
    $post->guid = $post_blog_id . '.' . $post_id;
    $global_meta = array();
    $global_meta['permalink'] = get_permalink($post_id);
    $global_meta['blogid'] = $org_blog_id = $wpdb->blogid;
    // org_blog_id
    $meta_keys = apply_filters('sitewide_tags_meta_keys', get_sitewide_tags_option('tags_blog_postmeta', array()));
    if (is_array($meta_keys) && !empty($meta_keys)) {
        foreach ($meta_keys as $key) {
            $global_meta[$key] = get_post_meta($post->ID, $key, true);
        }
    }
    unset($meta_keys);
    if (get_sitewide_tags_option('tags_blog_thumbs') && ($thumb_id = get_post_meta($post->ID, '_thumbnail_id', true))) {
        $thumb_size = apply_filters('sitewide_tags_thumb_size', 'thumbnail');
        $global_meta['thumbnail_html'] = wp_get_attachment_image($thumb_id, $thumb_size);
    }
    // custom taxonomies
    $taxonomies = apply_filters('sitewide_tags_custom_taxonomies', array());
    if (!empty($taxonomies) && $post->post_status == 'publish') {
        $registered_tax = array_diff(get_taxonomies(), array('post_tag', 'category', 'link_category', 'nav_menu'));
        $custom_tax = array_intersect($taxonomies, $registered_tax);
        $tax_input = array();
        foreach ($custom_tax as $tax) {
            $terms = wp_get_object_terms($post_id, $tax, array('fields' => 'names'));
            if (empty($terms)) {
                continue;
            }
            if (is_taxonomy_hierarchical($tax)) {
                $tax_input[$tax] = $terms;
            } else {
                $tax_input[$tax] = implode(',', $terms);
            }
        }
        if (!empty($tax_input)) {
            $post->tax_input = $tax_input;
        }
    }
    switch_to_blog($tags_blog_id);
    if (is_array($cats) && !empty($cats) && $post->post_status == 'publish') {
        foreach ($cats as $t => $d) {
            $term = get_term_by('slug', $d['slug'], 'category');
            if ($term && $term->parent == 0) {
                $category_id[] = $term->term_id;
                continue;
            }
            /* Here is where we insert the category if necessary */
            wp_insert_category(array('cat_name' => $d['name'], 'category_description' => $d['name'], 'category_nicename' => $d['slug'], 'category_parent' => ''));
            /* Now get the category ID to be used for the post */
            $category_id[] = $wpdb->get_var("SELECT term_id FROM " . $wpdb->get_blog_prefix($tags_blog_id) . "terms WHERE slug = '" . $d['slug'] . "'");
        }
    }
    $global_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE guid IN (%s,%s)", $post->guid, esc_url($post->guid)));
    if ($post->post_status != 'publish' && is_object($global_post)) {
        wp_delete_post($global_post->ID);
    } else {
        if ($global_post->ID != '') {
            $post->ID = $global_post->ID;
            // editing an old post
            foreach (array_keys($global_meta) as $key) {
                delete_post_meta($global_post->ID, $key);
            }
        } else {
            unset($post->ID);
            // new post
        }
    }
    if ($post->post_status == 'publish') {
        $post->ping_status = 'closed';
        $post->comment_status = 'closed';
        /* Use the category ID in the post */
        $post->post_category = $category_id;
        $p = wp_insert_post($post);
        foreach ($global_meta as $key => $value) {
            if ($value) {
                add_post_meta($p, $key, $value);
            }
        }
    }
    restore_current_blog();
}
    public function display_rows()
    {
        global $mode;
        $status_list = array('archived' => array('site-archived', __('Archived')), 'spam' => array('site-spammed', _x('Spam', 'site')), 'deleted' => array('site-deleted', __('Deleted')), 'mature' => array('site-mature', __('Mature')));
        if ('list' == $mode) {
            $date = 'Y/m/d';
        } else {
            $date = 'Y/m/d \\<\\b\\r \\/\\> g:i:s a';
        }
        $class = '';
        foreach ($this->items as $blog) {
            $class = 'alternate' == $class ? '' : 'alternate';
            reset($status_list);
            $blog_states = array();
            foreach ($status_list as $status => $col) {
                if (get_blog_status($blog['blog_id'], $status) == 1) {
                    $class = $col[0];
                    $blog_states[] = $col[1];
                }
            }
            $blog_state = '';
            if (!empty($blog_states)) {
                $state_count = count($blog_states);
                $i = 0;
                $blog_state .= ' - ';
                foreach ($blog_states as $state) {
                    ++$i;
                    $i == $state_count ? $sep = '' : ($sep = ', ');
                    $blog_state .= "<span class='post-state'>{$state}{$sep}</span>";
                }
            }
            echo "<tr class='{$class}'>";
            $blogname = is_subdomain_install() ? str_replace('.' . get_current_site()->domain, '', $blog['domain']) : $blog['path'];
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                switch ($column_name) {
                    case 'cb':
                        ?>
						<th scope="row" class="check-column">
							<?php 
                        if (!is_main_site($blog['blog_id'])) {
                            ?>
							<label class="screen-reader-text" for="blog_<?php 
                            echo $blog['blog_id'];
                            ?>
"><?php 
                            printf(__('Select %s'), $blogname);
                            ?>
</label>
							<input type="checkbox" id="blog_<?php 
                            echo $blog['blog_id'];
                            ?>
" name="allblogs[]" value="<?php 
                            echo esc_attr($blog['blog_id']);
                            ?>
" />
							<?php 
                        }
                        ?>
						</th>
					<?php 
                        break;
                    case 'id':
                        ?>
						<th scope="row">
							<?php 
                        echo $blog['blog_id'];
                        ?>
						</th>
					<?php 
                        break;
                    case 'blogname':
                        echo "<td class='column-{$column_name} {$column_name}'{$style}>";
                        ?>
							<a href="<?php 
                        echo esc_url(network_admin_url('site-info.php?id=' . $blog['blog_id']));
                        ?>
" class="edit"><?php 
                        echo $blogname . $blog_state;
                        ?>
</a>
							<?php 
                        if ('list' != $mode) {
                            switch_to_blog($blog['blog_id']);
                            echo '<p>' . sprintf(_x('%1$s &#8211; <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.'), get_option('blogname'), get_option('blogdescription ')) . '</p>';
                            restore_current_blog();
                        }
                        // Preordered.
                        $actions = array('edit' => '', 'backend' => '', 'activate' => '', 'deactivate' => '', 'archive' => '', 'unarchive' => '', 'spam' => '', 'unspam' => '', 'delete' => '', 'visit' => '');
                        $actions['edit'] = '<span class="edit"><a href="' . esc_url(network_admin_url('site-info.php?id=' . $blog['blog_id'])) . '">' . __('Edit') . '</a></span>';
                        $actions['backend'] = "<span class='backend'><a href='" . esc_url(get_admin_url($blog['blog_id'])) . "' class='edit'>" . __('Dashboard') . '</a></span>';
                        if (get_current_site()->blog_id != $blog['blog_id']) {
                            if (get_blog_status($blog['blog_id'], 'deleted') == '1') {
                                $actions['activate'] = '<span class="activate"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to activate the site %s'), $blogname))), 'confirm')) . '">' . __('Activate') . '</a></span>';
                            } else {
                                $actions['deactivate'] = '<span class="activate"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to deactivate the site %s'), $blogname))), 'confirm')) . '">' . __('Deactivate') . '</a></span>';
                            }
                            if (get_blog_status($blog['blog_id'], 'archived') == '1') {
                                $actions['unarchive'] = '<span class="archive"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to unarchive the site %s.'), $blogname))), 'confirm')) . '">' . __('Unarchive') . '</a></span>';
                            } else {
                                $actions['archive'] = '<span class="archive"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to archive the site %s.'), $blogname))), 'confirm')) . '">' . _x('Archive', 'verb; site') . '</a></span>';
                            }
                            if (get_blog_status($blog['blog_id'], 'spam') == '1') {
                                $actions['unspam'] = '<span class="spam"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to unspam the site %s.'), $blogname))), 'confirm')) . '">' . _x('Not Spam', 'site') . '</a></span>';
                            } else {
                                $actions['spam'] = '<span class="spam"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to mark the site %s as spam.'), $blogname))), 'confirm')) . '">' . _x('Spam', 'site') . '</a></span>';
                            }
                            if (current_user_can('delete_site', $blog['blog_id'])) {
                                $actions['delete'] = '<span class="delete"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to delete the site %s.'), $blogname))), 'confirm')) . '">' . __('Delete') . '</a></span>';
                            }
                        }
                        $actions['visit'] = "<span class='view'><a href='" . esc_url(get_home_url($blog['blog_id'], '/')) . "' rel='permalink'>" . __('Visit') . '</a></span>';
                        /**
                         * Filter the action links displayed for each site in the Sites list table.
                         *
                         * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
                         * default for each site. The site's status determines whether to show the
                         * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
                         * 'Not Spam' or 'Spam' link for each site.
                         *
                         * @since 3.1.0
                         *
                         * @param array  $actions  An array of action links to be displayed.
                         * @param int    $blog_id  The site ID.
                         * @param string $blogname Site path, formatted depending on whether it is a sub-domain
                         *                         or subdirectory multisite install.
                         */
                        $actions = apply_filters('manage_sites_action_links', array_filter($actions), $blog['blog_id'], $blogname);
                        echo $this->row_actions($actions);
                        ?>
						</td>
					<?php 
                        break;
                    case 'lastupdated':
                        echo "<td class='{$column_name} column-{$column_name}'{$style}>";
                        echo $blog['last_updated'] == '0000-00-00 00:00:00' ? __('Never') : mysql2date($date, $blog['last_updated']);
                        ?>
						</td>
					<?php 
                        break;
                    case 'registered':
                        echo "<td class='{$column_name} column-{$column_name}'{$style}>";
                        if ($blog['registered'] == '0000-00-00 00:00:00') {
                            echo '&#x2014;';
                        } else {
                            echo mysql2date($date, $blog['registered']);
                        }
                        ?>
						</td>
					<?php 
                        break;
                    case 'users':
                        echo "<td class='{$column_name} column-{$column_name}'{$style}>";
                        $blogusers = get_users(array('blog_id' => $blog['blog_id'], 'number' => 6));
                        if (is_array($blogusers)) {
                            $blogusers_warning = '';
                            if (count($blogusers) > 5) {
                                $blogusers = array_slice($blogusers, 0, 5);
                                $blogusers_warning = __('Only showing first 5 users.') . ' <a href="' . esc_url(network_admin_url('site-users.php?id=' . $blog['blog_id'])) . '">' . __('More') . '</a>';
                            }
                            foreach ($blogusers as $user_object) {
                                echo '<a href="' . esc_url(network_admin_url('user-edit.php?user_id=' . $user_object->ID)) . '">' . esc_html($user_object->user_login) . '</a> ';
                                if ('list' != $mode) {
                                    echo '( ' . $user_object->user_email . ' )';
                                }
                                echo '<br />';
                            }
                            if ($blogusers_warning != '') {
                                echo '<strong>' . $blogusers_warning . '</strong><br />';
                            }
                        }
                        ?>
						</td>
					<?php 
                        break;
                    case 'plugins':
                        ?>
					<?php 
                        if (has_filter('wpmublogsaction')) {
                            echo "<td class='{$column_name} column-{$column_name}'{$style}>";
                            /**
                             * Fires inside the auxiliary 'Actions' column of the Sites list table.
                             *
                             * By default this column is hidden unless something is hooked to the action.
                             *
                             * @since MU
                             *
                             * @param int $blog_id The site ID.
                             */
                            do_action('wpmublogsaction', $blog['blog_id']);
                            ?>
					</td>
					<?php 
                        }
                        break;
                    default:
                        echo "<td class='{$column_name} column-{$column_name}'{$style}>";
                        /**
                         * Fires for each registered custom column in the Sites list table.
                         *
                         * @since 3.1.0
                         *
                         * @param string $column_name The name of the column to display.
                         * @param int    $blog_id     The site ID.
                         */
                        do_action('manage_sites_custom_column', $column_name, $blog['blog_id']);
                        echo "</td>";
                        break;
                }
            }
            ?>
			</tr>
			<?php 
        }
    }
Exemple #6
0
</th>
                <th>&nbsp;</th>
            </tr>
        </tfoot>        
        <tbody>
        <?php 
    $status_list = array('archived' => array('site-archived', __('Archived')), 'spam' => array('site-spammed', _x('Spam', 'site')), 'deleted' => array('site-deleted', __('Deleted')), 'mature' => array('site-mature', __('Mature')));
    $class = '';
    foreach ($wp_list_table->items as $blog) {
        if (class_exists('WP_Site') && $blog instanceof WP_Site) {
            $blog = object_to_array($blog);
        }
        $class = 'alternate' == $class ? '' : 'alternate';
        $blog_states = array();
        foreach ($status_list as $status => $col) {
            if (1 === get_blog_status($blog['blog_id'], $status)) {
                $class = $col[0];
                $blog_states[] = $col[1];
            }
        }
        $blog_state = '';
        if (!empty($blog_states)) {
            $state_count = count($blog_states);
            $i = 0;
            $blog_state .= ' - ';
            foreach ($blog_states as $state) {
                ++$i;
                $i == $state_count ? $sep = '' : ($sep = ', ');
                $blog_state .= "<span class='post-state'>{$state}{$sep}</span>";
            }
        }
Exemple #7
0
                    ?>
								<td><?php 
                    echo mysql2date(__('Y-m-d \\<\\b\\r \\/\\> g:i:s a'), $user['user_registered']);
                    ?>
</td>
							<?php 
                    break;
                case 'blogs':
                    $blogs = get_blogs_of_user($user['ID'], true);
                    ?>
								<td>
									<?php 
                    if (is_array($blogs)) {
                        foreach ((array) $blogs as $key => $val) {
                            echo '<a href="wpmu-blogs.php?action=editblog&amp;id=' . $val->userblog_id . '">' . str_replace('.' . $current_site->domain, '', $val->domain . $val->path) . '</a> (<a ';
                            if (get_blog_status($val->userblog_id, 'spam') == 1) {
                                echo 'style="background-color: #f66" ';
                            }
                            echo 'target="_new" href="http://' . $val->domain . $val->path . '">' . __('View') . '</a>)<br />';
                        }
                    }
                    ?>
								</td>
							<?php 
                    break;
                default:
                    ?>
								<td><?php 
                    do_action('manage_users_custom_column', $column_name, $user['ID']);
                    ?>
</td>
Exemple #8
0
 private function update_site_status($ids, $pref, $value)
 {
     if ($pref == 'archived' && $value == 1) {
         $action = 'archived';
     } else {
         if ($pref == 'archived' && $value == 0) {
             $action = 'unarchived';
         } else {
             if ($pref == 'deleted' && $value == 1) {
                 $action = 'deactivated';
             } else {
                 if ($pref == 'deleted' && $value == 0) {
                     $action = 'activated';
                 } else {
                     if ($pref == 'spam' && $value == 1) {
                         $action = 'marked as spam';
                     } else {
                         if ($pref == 'spam' && $value == 0) {
                             $action = 'removed from spam';
                         }
                     }
                 }
             }
         }
     }
     foreach ($ids as $site_id) {
         $site = $this->fetcher->get_check($site_id);
         if (is_main_site($site->blog_id)) {
             WP_CLI::warning("You are not allowed to change the main site.");
             continue;
         }
         $old_value = get_blog_status($site->blog_id, $pref);
         if ($value == $old_value) {
             WP_CLI::warning("Site {$site->blog_id} already {$action}.");
             continue;
         }
         update_blog_status($site->blog_id, $pref, $value);
         WP_CLI::success("Site {$site->blog_id} {$action}.");
     }
 }
Exemple #9
0
                            // Preordered.
                            $actions = array('edit' => '', 'backend' => '', 'activate' => '', 'deactivate' => '', 'archive' => '', 'unarchive' => '', 'spam' => '', 'unspam' => '', 'delete' => '', 'visit' => '');
                            $actions['edit'] = '<span class="edit"><a href="' . esc_url(admin_url('ms-sites.php?action=editblog&amp;id=' . $blog['blog_id'])) . '">' . __('Edit') . '</a><span>';
                            $actions['backend'] = "<span class='backend'><a href='" . esc_url(get_admin_url($blog['blog_id'])) . "' class='edit'>" . __('Backend') . '</a></span>';
                            if ($current_site->blog_id != $blog['blog_id']) {
                                if (get_blog_status($blog['blog_id'], 'deleted') == '1') {
                                    $actions['activate'] = '<span class="activate"><a href="' . esc_url(admin_url('ms-edit.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to activate the site %s'), $blogname)))) . '">' . __('Activate') . '</a></span>';
                                } else {
                                    $actions['deactivate'] = '<span class="activate"><a href="' . esc_url(admin_url('ms-edit.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to deactivate the site %s'), $blogname)))) . '">' . __('Deactivate') . '</a></span>';
                                }
                                if (get_blog_status($blog['blog_id'], 'archived') == '1') {
                                    $actions['unarchive'] = '<span class="archive"><a href="' . esc_url(admin_url('ms-edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to unarchive the site %s.'), $blogname)))) . '">' . __('Unarchive') . '</a></span>';
                                } else {
                                    $actions['archive'] = '<span class="archive"><a href="' . esc_url(admin_url('ms-edit.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to archive the site %s.'), $blogname)))) . '">' . __('Archive') . '</a></span>';
                                }
                                if (get_blog_status($blog['blog_id'], 'spam') == '1') {
                                    $actions['unspam'] = '<span class="spam"><a href="' . esc_url(admin_url('ms-edit.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to unspam the site %s.'), $blogname)))) . '">' . __('Not Spam') . '</a></span>';
                                } else {
                                    $actions['spam'] = '<span class="spam"><a href="' . esc_url(admin_url('ms-edit.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to mark the site %s as spam.'), $blogname)))) . '">' . __('Spam') . '</a></span>';
                                }
                                $actions['delete'] = '<span class="delete"><a href="' . esc_url(admin_url('ms-edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to delete the site %s.'), $blogname)))) . '">' . __('Delete') . '</a></span>';
                            }
                            $actions['visit'] = "<span class='view'><a href='" . esc_url(get_home_url($blog['blog_id'])) . "' rel='permalink'>" . __('Visit') . '</a>';
                            $actions = array_filter($actions);
                            if (count($actions)) {
                                ?>
									<div class="row-actions">
										<?php 
                                echo implode(' | ', $actions);
                                ?>
									</div>
Exemple #10
0
<?php

echo get_blog_status(get_current_blog_id(), 'registered');
Exemple #11
0
function sitewide_tags_post($post_id, $post)
{
    global $wpdb;
    if (!get_sitewide_tags_option('tags_blog_enabled')) {
        return;
    }
    // wp_insert_category()
    include_once ABSPATH . 'wp-admin/includes/admin.php';
    $tags_blog_id = get_sitewide_tags_option('tags_blog_id');
    if (!$tags_blog_id || $wpdb->blogid == $tags_blog_id) {
        return;
    }
    $allowed_post_types = apply_filters('sitewide_tags_allowed_post_types', array('post' => true));
    if (!$allowed_post_types[$post->post_type]) {
        return;
    }
    $post_blog_id = $wpdb->blogid;
    $blog_status = get_blog_status($post_blog_id, "public");
    if ($blog_status != 1 && ($blog_status != 0 || get_sitewide_tags_option('tags_blog_public') == 1 || get_sitewide_tags_option('tags_blog_pub_check') == 0)) {
        return;
    }
    $post->post_category = wp_get_post_categories($post_id);
    foreach ($post->post_category as $c) {
        $cat = get_category($c);
        $cats[] = array('name' => wp_specialchars($cat->name), 'slug' => wp_specialchars($cat->slug));
    }
    $post->tags_input = implode(', ', wp_get_post_tags($post_id, array('fields' => 'names')));
    $post->guid = $post_blog_id . '.' . $post_id;
    $permalink = get_permalink($post_id);
    $org_blog_id = $wpdb->blogid;
    // org_blog_id
    $meta_keys = apply_filters('sitewide_tags_meta_keys', get_sitewide_tags_option('tags_blog_postmeta', array()));
    if (is_array($meta_keys) && count($meta_keys)) {
        foreach ($meta_keys as $key) {
            ${$key} = get_post_meta($post->ID, $key, true);
        }
    }
    switch_to_blog($tags_blog_id);
    if (is_array($cats) && !empty($cats)) {
        foreach ($cats as $t => $d) {
            /* Here is where we insert the category */
            wp_insert_category(array('cat_name' => $d['name'], 'category_description' => $d['name'], 'category_nicename' => $d['slug'], 'category_parent' => ''));
            /* Now get the category ID to be used for the post */
            $category_id[] = $wpdb->get_var("SELECT term_id FROM " . $wpdb->get_blog_prefix($tags_blog_id) . "terms WHERE slug = '" . $d['slug'] . "'");
        }
    }
    $global_post = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE guid = '{$post->guid}'");
    if ($post->post_status != 'publish' && is_object($global_post)) {
        wp_delete_post($global_post->ID);
    } else {
        if ($global_post->ID != '') {
            $post->ID = $global_post->ID;
            // editing an old post
            /* using this kind of update not simple add: fixing permalink-problems */
            delete_post_meta($global_post->ID, "permalink");
            if (is_array($meta_keys) && count($meta_keys)) {
                foreach ($meta_keys as $key) {
                    delete_post_meta($global_post->ID, $key);
                }
            }
        } else {
            unset($post->ID);
            // new post
        }
    }
    if ($post->post_status == 'publish') {
        $post->ping_status = 'closed';
        $post->comment_status = 'closed';
        /* Use the category ID in the post */
        $post->post_category = $category_id;
        $p = wp_insert_post($post);
        add_post_meta($p, "permalink", $permalink);
        add_post_meta($p, "blogid", $org_blog_id);
        // org_blog_id
        if (is_array($meta_keys) && count($meta_keys)) {
            foreach ($meta_keys as $key) {
                if (${$key}) {
                    add_post_meta($p, $key, ${$key});
                }
            }
        }
    }
    restore_current_blog();
}
    function display_rows()
    {
        global $current_site, $mode;
        $class = '';
        $super_admins = get_super_admins();
        foreach ($this->items as $user) {
            $class = 'alternate' == $class ? '' : 'alternate';
            $status_list = array('spam' => 'site-spammed', 'deleted' => 'site-deleted');
            foreach ($status_list as $status => $col) {
                if ($user[$status]) {
                    $class = $col;
                }
            }
            ?>
			<tr class="<?php 
            echo $class;
            ?>
">
			<?php 
            list($columns, $hidden) = $this->get_column_headers();
            foreach ($columns as $column_name => $column_display_name) {
                switch ($column_name) {
                    case 'cb':
                        ?>
						<th scope="row" class="check-column">
							<input type="checkbox" id="blog_<?php 
                        echo $user['ID'];
                        ?>
" name="allusers[]" value="<?php 
                        echo esc_attr($user['ID']);
                        ?>
" />
						</th>
					<?php 
                        break;
                    case 'id':
                        ?>
						<th valign="top" scope="row">
							<?php 
                        echo $user['ID'];
                        ?>
						</th>
					<?php 
                        break;
                    case 'login':
                        $avatar = get_avatar($user['user_email'], 32);
                        $edit_link = get_current_user_id() == $user['ID'] ? 'profile.php' : 'user-edit.php?user_id=' . $user['ID'];
                        ?>
						<td class="username column-username">
							<?php 
                        echo $avatar;
                        ?>
<strong><a href="<?php 
                        echo esc_url(admin_url($edit_link));
                        ?>
" class="edit"><?php 
                        echo stripslashes($user['user_login']);
                        ?>
</a><?php 
                        if (in_array($user['user_login'], $super_admins)) {
                            echo ' - ' . __('Super admin');
                        }
                        ?>
</strong>
							<br/>
							<div class="row-actions">
								<span class="edit"><a href="<?php 
                        echo esc_url(admin_url($edit_link));
                        ?>
"><?php 
                        _e('Edit');
                        ?>
</a></span>
								<?php 
                        if (!in_array($user['user_login'], $super_admins)) {
                            ?>
								| <span class="delete"><a href="<?php 
                            echo $delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), wp_nonce_url('edit.php', 'deleteuser') . '&amp;action=deleteuser&amp;id=' . $user['ID'])));
                            ?>
" class="delete"><?php 
                            _e('Delete');
                            ?>
</a></span>
								<?php 
                        }
                        ?>
							</div>
						</td>
					<?php 
                        break;
                    case 'name':
                        ?>
						<td class="name column-name"><?php 
                        echo $user['display_name'];
                        ?>
</td>
					<?php 
                        break;
                    case 'email':
                        ?>
						<td class="email column-email"><a href="mailto:<?php 
                        echo $user['user_email'];
                        ?>
"><?php 
                        echo $user['user_email'];
                        ?>
</a></td>
					<?php 
                        break;
                    case 'registered':
                        if ('list' == $mode) {
                            $date = 'Y/m/d';
                        } else {
                            $date = 'Y/m/d \\<\\b\\r \\/\\> g:i:s a';
                        }
                        ?>
						<td><?php 
                        echo mysql2date(__($date), $user['user_registered']);
                        ?>
</td>
					<?php 
                        break;
                    case 'blogs':
                        $blogs = get_blogs_of_user($user['ID'], true);
                        ?>
						<td>
							<?php 
                        if (is_array($blogs)) {
                            foreach ((array) $blogs as $key => $val) {
                                $path = $val->path == '/' ? '' : $val->path;
                                echo '<a href="' . esc_url(network_admin_url('sites.php?action=editblog&amp;id=' . $val->userblog_id)) . '">' . str_replace('.' . $current_site->domain, '', $val->domain . $path) . '</a>';
                                echo ' <small class="row-actions">';
                                // Edit
                                echo '<a href="' . esc_url(network_admin_url('sites.php?action=editblog&amp;id=' . $val->userblog_id)) . '">' . __('Edit') . '</a> | ';
                                // View
                                echo '<a ';
                                if (get_blog_status($val->userblog_id, 'spam') == 1) {
                                    echo 'style="background-color: #faa" ';
                                }
                                echo 'href="' . esc_url(get_home_url($val->userblog_id)) . '">' . __('View') . '</a>';
                                echo '</small><br />';
                            }
                        }
                        ?>
						</td>
					<?php 
                        break;
                    default:
                        ?>
						<td><?php 
                        do_action('manage_users_custom_column', $column_name, $user['ID']);
                        ?>
</td>
					<?php 
                        break;
                }
            }
            ?>
			</tr>
			<?php 
        }
    }
function pmpron_manage_sites_shortcode($atts, $content = null, $code = "")
{
    ob_start();
    global $current_user;
    //adding a site?
    if (!empty($_POST['addsite'])) {
        $sitename = $_REQUEST['sitename'];
        $sitetitle = $_REQUEST['sitetitle'];
        if (!empty($sitename) && !empty($sitetitle)) {
            if (pmpron_checkSiteName($sitename)) {
                $blog_id = pmpron_addSite($sitename, $sitetitle);
                if (is_wp_error($blog_id)) {
                    $pmpro_msg = "Error creating site.";
                    $pmpro_msgt = "pmpro_error";
                } else {
                    $pmpro_msg = "Your site has been created.";
                    $pmpro_msgt = "pmpro_success";
                }
            } else {
                //error set in checkSiteName
            }
        } else {
            $pmpro_msg = "Please enter a site name and title.";
            $pmpro_msgt = "pmpro_error";
        }
    } else {
        //default values for form
        $sitename = "";
        $sitetitle = "";
    }
    //show page
    $blog_ids = pmpron_getBlogsForUser($current_user->ID);
    ?>
		<p class="pmpro_message <?php 
    if (count($blog_ids) >= intval($current_user->pmpron_site_credits)) {
        ?>
pmpro_error<?php 
    }
    ?>
">
			<?php 
    if (count($blog_ids) >= intval($current_user->pmpron_site_credits)) {
        ?>
				You have used <?php 
        echo intval($current_user->pmpron_site_credits);
        ?>
 of <?php 
        echo intval($current_user->pmpron_site_credits);
        ?>
 site credits.
				<?php 
        if (count($blog_ids) > intval($current_user->pmpron_site_credits)) {
            ?>
					<?php 
            echo count($blog_ids) - intval($current_user->pmpron_site_credits);
            ?>
 of your sites have been deactivated.
				<?php 
        }
        ?>
 
			<?php 
    } else {
        ?>
				You have used <?php 
        echo count($blog_ids);
        ?>
 of <?php 
        echo intval($current_user->pmpron_site_credits);
        ?>
 site credits.
			<?php 
    }
    ?>
		</p>
		
		<?php 
    if ($current_user->pmpron_site_credits > count($blog_ids)) {
        ?>
		<form class="pmpro_form" action="" method="post">
			<table id="pmpro_add_site" class="pmpro_checkout" width="100%" cellpadding="0" cellspacing="0" border="0">
			<thead>
				<tr>
					<th>Add a Site</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>	
					<?php 
        if (!empty($pmpro_msg)) {
            ?>
						<p class="pmpro_message <?php 
            echo $pmpro_msgt;
            ?>
"><?php 
            echo $pmpro_msg;
            ?>
</p>
					<?php 
        }
        ?>
					<div>
						<label for="sitename"><?php 
        _e('Site Name');
        ?>
</label>
						<input id="sitename" name="sitename" type="text" class="input" size="30" value="<?php 
        echo esc_attr(stripslashes($sitename));
        ?>
" />				
						<?php 
        global $current_site;
        $site_domain = preg_replace('|^www\\.|', '', $current_site->domain);
        if (!is_subdomain_install()) {
            $site = $current_site->domain . $current_site->path . __('sitename');
        } else {
            $site = __('{site name}') . '.' . $site_domain . $current_site->path;
        }
        echo '<div class="leftmar"><strong>' . sprintf(__('Your address will be %s.'), $site) . '</strong><br />' . __('Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!') . '</div>';
        ?>
					</div>
					<div>
						<label for="sitetitle"><?php 
        _e('Site Title');
        ?>
</label>
						<input id="sitetitle" name="sitetitle" type="text" class="input" size="30" value="<?php 
        echo esc_attr(stripslashes($sitetitle));
        ?>
" />
					</div>
					<div class="leftmar">
						<input type="hidden" name="addsite" value="1" />
						<input type="submit" name="submit" value="Add Site" />
					</div>
					</td>
				</tr>
			</tbody>
		</table>
		</form>

		<?php 
    }
    ?>
		
		<?php 
    if (!empty($blog_ids)) {
        ?>
		<h3>Your Sites</h3>
		<table id="pmpro_add_site" class="pmpro_checkout" width="100%" cellpadding="0" cellspacing="0" border="0">
			<thead>
				<tr>
					<th><?php 
        _e('Name');
        ?>
</th>
					<th><?php 
        _e('Options');
        ?>
</th>
				</tr>
			</thead>
			<tbody>	
			<?php 
        foreach ($blog_ids as $blog_id) {
            ?>
				<tr<?php 
            if (get_blog_status($blog_id, "deleted")) {
                ?>
 class="pmpro_disabled"<?php 
            }
            ?>
>
					<td>
						<?php 
            if (get_blog_status($blog_id, "deleted")) {
                echo get_blog_option($blog_id, "blogname");
            } else {
                ?>
								<a href="<?php 
                echo get_site_url($blog_id);
                ?>
"><?php 
                echo get_blog_option($blog_id, "blogname");
                ?>
</a><br />
								<?php 
                echo get_site_url($blog_id);
                ?>
								<?php 
            }
            ?>
										
					</td>
					<td>					
						<?php 
            if (get_blog_status($blog_id, "deleted")) {
                ?>
								<?php 
                _e('(deactivated)');
                ?>
								<?php 
            } else {
                ?>
								<a href="<?php 
                echo get_site_url($blog_id);
                ?>
/wp-admin/"><?php 
                _e('Dashboard');
                ?>
</a>&nbsp;|&nbsp;<a href="<?php 
                echo get_site_url($blog_id, "/wp-admin/post-new.php");
                ?>
"><?php 
                _e('New Post');
                ?>
</a>&nbsp;|&nbsp;<a href="<?php 
                echo get_site_url($blog_id, "/wp-admin/edit-comments.php");
                ?>
"><?php 
                _e('Manage Comments');
                ?>
</a>&nbsp;|&nbsp;<a href="<?php 
                echo get_site_url($blog_id);
                ?>
"><?php 
                _e('Visit Site');
                ?>
</a>
								<?php 
            }
            ?>
					</td>
				</tr>
			<?php 
        }
        ?>
			</tbody>
		</table>
		<?php 
    }
    ?>
		<?php 
    $temp_content = ob_get_contents();
    ob_end_clean();
    return $temp_content;
}
Exemple #14
0
             <th>&nbsp;</th>
         </tr>
     </tfoot>        
     <tbody>
     <?php 
 $status_list = array('archived' => array('site-archived', __('Archived')), 'spam' => array('site-spammed', _x('Spam', 'site')), 'deleted' => array('site-deleted', __('Deleted')), 'mature' => array('site-mature', __('Mature')));
 $class = '';
 ?>
     <?php 
 foreach ($wp_list_table->items as $blog) {
     ?>
     <?php 
     $class = 'alternate' == $class ? '' : 'alternate';
     $blog_states = array();
     foreach ($status_list as $status => $col) {
         if (get_blog_status($blog['blog_id'], $status) == 1) {
             $class = $col[0];
             $blog_states[] = $col[1];
         }
     }
     $blog_state = '';
     if (!empty($blog_states)) {
         $state_count = count($blog_states);
         $i = 0;
         $blog_state .= ' - ';
         foreach ($blog_states as $state) {
             ++$i;
             $i == $state_count ? $sep = '' : ($sep = ', ');
             $blog_state .= "<span class='post-state'>{$state}{$sep}</span>";
         }
     }
Exemple #15
0
function xpress_primary_blog_link() {
	global $xoops_config;
	global $current_user;
	global $blog_id;
	$ret = array();

	if (xpress_is_multiblog() && is_user_logged_in()){
		$blog_list = get_blog_list();
		$root_path = get_blog_status(1,'path');
		$primary_blog_id = @$current_user->primary_blog;
		if(empty($primary_blog_id)) return $ret;
		$primary_path = get_blog_status($primary_blog_id,'path');
		$script = str_replace($root_path, "", $primary_path);
		if ($primary_blog_id !== $blog_id){
			$ret['url'] = get_blogaddress_by_id($primary_blog_id);
			$ret['menu_url'] = $script;
			$ret['title'] = __('Your Primary Blog','xpressme');
			$ret['link'] = '<a href="' . $ret['url'] . '">' . $ret['title'] . '</a>';
		}
	}
	return $ret;
}
Exemple #16
0
<?php

require_once './admin.php';
$title = __('Privacy Settings');
$parent_file = 'options-general.php';
include './admin-header.php';
if (trim(get_option('blog_public')) == '') {
    update_option('blog_public', get_blog_status($wpdb->blogid, 'public'));
}
?>

<div class="wrap">
<h2><?php 
_e('Privacy Settings');
?>
</h2>
<form method="post" action="options.php">
<?php 
wp_nonce_field('privacy-options');
?>
<input type='hidden' name='option_page' value='privacy' />
<table class="form-table">
<tr valign="top">
<th scope="row"><?php 
_e('Blog Visibility');
?>
 </th>
<td><fieldset><legend class="hidden"><?php 
_e('Blog Visibility');
?>
 </legend>
 /**
  * Filter Network Table Actions
  */
 function table_actions_Network_Admin_GForms_TMP($actions, $blog_id, $blogname)
 {
     $new_actions = array();
     $new_actions['backend'] = "<span class='backend'><a href='" . esc_url(get_admin_url($blog_id)) . "' class='edit'>" . __('Dashboard') . '</a></span>';
     if (get_blog_status($blog_id, 'public') == true && get_blog_status($blog_id, 'archived') == false && get_blog_status($blog_id, 'spam') == false && get_blog_status($blog_id, 'deleted') == false) {
         $new_actions['edit'] = '<span class="edit"><a href="' . esc_url(network_admin_url('admin.php?page=' . $this::slug . '&action=edit&id=' . $blog_id)) . '">' . __('Edit') . '</a></span>';
     }
     return $new_actions;
 }
									<br/>
									<?php 
                            $controlActions = array();
                            $controlActions[] = '<a href="wpmu-blogs.php?action=editblog&amp;id=' . $blog['blog_id'] . '" class="edit">' . __('Edit') . '</a>';
                            $controlActions[] = "<a href='http://{$blog['domain']}{$blog['path']}wp-admin/' class='edit'>" . __('Backend') . '</a>';
                            if (get_blog_status($blog['blog_id'], "deleted") == '1') {
                                $controlActions[] = '<a class="delete" href="wpmu-edit.php?action=confirm&amp;action2=activateblog&amp;ref=' . urlencode($_SERVER['REQUEST_URI']) . '&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__("You are about to activate the blog %s"), $blogname)) . '">' . __('Activate') . '</a>';
                            } else {
                                $controlActions[] = '<a class="delete" href="wpmu-edit.php?action=confirm&amp;action2=deactivateblog&amp;ref=' . urlencode($_SERVER['REQUEST_URI']) . '&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__("You are about to deactivate the blog %s"), $blogname)) . '">' . __('Deactivate') . '</a>';
                            }
                            if (get_blog_status($blog['blog_id'], "archived") == '1') {
                                $controlActions[] = '<a class="delete" href="wpmu-edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__("You are about to unarchive the blog %s"), $blogname)) . '">' . __('Unarchive') . '</a>';
                            } else {
                                $controlActions[] = '<a class="delete" href="wpmu-edit.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__("You are about to archive the blog %s"), $blogname)) . '">' . __('Archive') . '</a>';
                            }
                            if (get_blog_status($blog['blog_id'], "spam") == '1') {
                                $controlActions[] = '<a class="delete" href="wpmu-edit.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__("You are about to unspam the blog %s"), $blogname)) . '">' . __('Not Spam') . '</a>';
                            } else {
                                $controlActions[] = '<a class="delete" href="wpmu-edit.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__("You are about to mark the blog %s as spam"), $blogname)) . '">' . __("Spam") . '</a>';
                            }
                            $controlActions[] = '<a class="delete" href="wpmu-edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__("You are about to delete the blog %s"), $blogname)) . '">' . __("Delete") . '</a>';
                            $controlActions[] = "<a href='http://{$blog['domain']}{$blog['path']}' rel='permalink'>" . __('Visit') . '</a>';
                            ?>
									
									<?php 
                            if (count($controlActions)) {
                                ?>
									<div class="row-actions">
										<?php 
                                echo implode(' | ', $controlActions);
                                ?>
 function check_for_site_problems()
 {
     global $wpdb;
     if (!$this->options->get('tags_blog_enabled')) {
         return __('Multisite Aggregate not enabled.', 'wds-multisite-aggregate');
     }
     $tags_blog_id = $this->options->get('tags_blog_id');
     if (!$tags_blog_id || $tags_blog_id == $wpdb->blogid) {
         return __('No Multisite Aggregate blog ID, or current blog is Multisite Aggregate blog.', 'wds-multisite-aggregate');
     }
     $blogs_to_import = $this->get_blogs_to_import();
     if (!in_array((int) $wpdb->blogid, $blogs_to_import)) {
         return __('Blog ID is not saved to the "Blogs to Aggregate" setting.', 'wds-multisite-aggregate');
     }
     $blog_status = get_blog_status($wpdb->blogid, 'public');
     if (1 != $blog_status && (0 != $blog_status || 1 == $this->options->get('tags_blog_public') || 0 == $this->options->get('tags_blog_pub_check'))) {
         return __("This blog's status is not set to public", 'wds-multisite-aggregate');
     }
     return false;
 }
Exemple #20
0
&amp;id=<?php 
                                echo $blog['blog_id'];
                                ?>
&amp;msg=<?php 
                                echo urlencode(sprintf(__("You are about to deactivate the blog %s"), $blogname));
                                ?>
"><?php 
                                _e("Deactivate");
                                ?>
</a>
									</td>
								<?php 
                            }
                            break;
                        case 'control_archive':
                            if (get_blog_status($blog['blog_id'], "archived") == '1') {
                                ?>
									<td valign="top">
										<a class='delete' href="wpmu-edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=<?php 
                                echo $blog['blog_id'];
                                ?>
&amp;msg=<?php 
                                echo urlencode(sprintf(__("You are about to unarchive the blog %s"), $blogname));
                                ?>
"><?php 
                                _e("Unarchive");
                                ?>
</a>
									</td>
								<?php 
                            } else {
    function display_rows()
    {
        global $current_site, $mode;
        $alt = '';
        $super_admins = get_super_admins();
        foreach ($this->items as $user) {
            $alt = 'alternate' == $alt ? '' : 'alternate';
            $status_list = array('spam' => 'site-spammed', 'deleted' => 'site-deleted');
            foreach ($status_list as $status => $col) {
                if ($user->{$status}) {
                    $alt .= " {$col}";
                }
            }
            ?>
			<tr class="<?php 
            echo $alt;
            ?>
">
			<?php 
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='{$column_name} column-{$column_name}'";
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = "{$class}{$style}";
                switch ($column_name) {
                    case 'cb':
                        ?>
						<th scope="row" class="check-column">
							<input type="checkbox" id="blog_<?php 
                        echo $user->ID;
                        ?>
" name="allusers[]" value="<?php 
                        echo esc_attr($user->ID);
                        ?>
" />
						</th>
					<?php 
                        break;
                    case 'username':
                        $avatar = get_avatar($user->user_email, 32);
                        if (get_current_user_id() == $user->ID) {
                            $edit_link = esc_url(network_admin_url('profile.php'));
                        } else {
                            $edit_link = esc_url(network_admin_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), 'user-edit.php?user_id=' . $user->ID)));
                        }
                        echo "<td {$attributes}>";
                        ?>
							<?php 
                        echo $avatar;
                        ?>
<strong><a href="<?php 
                        echo $edit_link;
                        ?>
" class="edit"><?php 
                        echo stripslashes($user->user_login);
                        ?>
</a><?php 
                        if (in_array($user->user_login, $super_admins)) {
                            echo ' - ' . __('Super Admin');
                        }
                        ?>
</strong>
							<br/>
							<?php 
                        $actions = array();
                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
                        if (current_user_can('delete_user', $user->ID) && !in_array($user->user_login, $super_admins)) {
                            $actions['delete'] = '<a href="' . ($delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), wp_nonce_url('edit.php', 'deleteuser') . '&amp;action=deleteuser&amp;id=' . $user->ID))) . '" class="delete">' . __('Delete') . '</a>');
                        }
                        $actions = apply_filters('ms_user_row_actions', $actions, $user);
                        echo $this->row_actions($actions);
                        ?>
						</td>
					<?php 
                        break;
                    case 'name':
                        echo "<td {$attributes}>{$user->first_name} {$user->last_name}</td>";
                        break;
                    case 'email':
                        echo "<td {$attributes}><a href='mailto:{$user->user_email}'>{$user->user_email}</a></td>";
                        break;
                    case 'registered':
                        if ('list' == $mode) {
                            $date = 'Y/m/d';
                        } else {
                            $date = 'Y/m/d \\<\\b\\r \\/\\> g:i:s a';
                        }
                        echo "<td {$attributes}>" . mysql2date($date, $user->user_registered) . "</td>";
                        break;
                    case 'blogs':
                        $blogs = get_blogs_of_user($user->ID, true);
                        echo "<td {$attributes}>";
                        if (is_array($blogs)) {
                            foreach ((array) $blogs as $key => $val) {
                                if (!can_edit_network($val->site_id)) {
                                    continue;
                                }
                                $path = $val->path == '/' ? '' : $val->path;
                                echo '<span class="site-' . $val->site_id . '" >';
                                echo '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $val->userblog_id)) . '">' . str_replace('.' . $current_site->domain, '', $val->domain . $path) . '</a>';
                                echo ' <small class="row-actions">';
                                $actions = array();
                                $actions['edit'] = '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $val->userblog_id)) . '">' . __('Edit') . '</a>';
                                $class = '';
                                if (get_blog_status($val->userblog_id, 'spam') == 1) {
                                    $class .= 'site-spammed ';
                                }
                                if (get_blog_status($val->userblog_id, 'mature') == 1) {
                                    $class .= 'site-mature ';
                                }
                                if (get_blog_status($val->userblog_id, 'deleted') == 1) {
                                    $class .= 'site-deleted ';
                                }
                                if (get_blog_status($val->userblog_id, 'archived') == 1) {
                                    $class .= 'site-archived ';
                                }
                                $actions['view'] = '<a class="' . $class . '" href="' . esc_url(get_home_url($val->userblog_id)) . '">' . __('View') . '</a>';
                                $actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id);
                                $i = 0;
                                $action_count = count($actions);
                                foreach ($actions as $action => $link) {
                                    ++$i;
                                    $i == $action_count ? $sep = '' : ($sep = ' | ');
                                    echo "<span class='{$action}'>{$link}{$sep}</span>";
                                }
                                echo '</small></span><br/>';
                            }
                        }
                        ?>
						</td>
					<?php 
                        break;
                    default:
                        echo "<td {$attributes}>";
                        echo apply_filters('manage_users_custom_column', '', $column_name, $user->ID);
                        echo "</td>";
                        break;
                }
            }
            ?>
			</tr>
			<?php 
        }
    }
 function public_update($old_value, $value)
 {
     global $wpdb;
     $wpdb->update($wpdb->base_prefix . 'mp_products', array('blog_public' => get_blog_status($wpdb->blogid, 'public')), array('site_id' => $wpdb->siteid, 'blog_id' => $wpdb->blogid));
 }
    function display_rows()
    {
        global $current_site, $mode;
        $status_list = array('archived' => array('site-archived', __('Archived')), 'spam' => array('site-spammed', _x('Spam', 'site')), 'deleted' => array('site-deleted', __('Deleted')), 'mature' => array('site-mature', __('Mature')));
        $class = '';
        foreach ($this->items as $blog) {
            $class = 'alternate' == $class ? '' : 'alternate';
            reset($status_list);
            $blog_states = array();
            foreach ($status_list as $status => $col) {
                if (get_blog_status($blog['blog_id'], $status) == 1) {
                    $class = $col[0];
                    $blog_states[] = $col[1];
                }
            }
            $blog_state = '';
            if (!empty($blog_states)) {
                $state_count = count($blog_states);
                $i = 0;
                $blog_state .= ' - ';
                foreach ($blog_states as $state) {
                    ++$i;
                    $i == $state_count ? $sep = '' : ($sep = ', ');
                    $blog_state .= "<span class='post-state'>{$state}{$sep}</span>";
                }
            }
            echo "<tr class='{$class}'>";
            $blogname = is_subdomain_install() ? str_replace('.' . $current_site->domain, '', $blog['domain']) : $blog['path'];
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                switch ($column_name) {
                    case 'cb':
                        ?>
						<th scope="row" class="check-column">
							<input type="checkbox" id="blog_<?php 
                        echo $blog['blog_id'];
                        ?>
" name="allblogs[]" value="<?php 
                        echo esc_attr($blog['blog_id']);
                        ?>
" />
						</th>
					<?php 
                        break;
                    case 'id':
                        ?>
						<th valign="top" scope="row">
							<?php 
                        echo $blog['blog_id'];
                        ?>
						</th>
					<?php 
                        break;
                    case 'blogname':
                        echo "<td class='column-{$column_name} {$column_name}'{$style}>";
                        ?>
							<a href="<?php 
                        echo esc_url(network_admin_url('site-info.php?id=' . $blog['blog_id']));
                        ?>
" class="edit"><?php 
                        echo $blogname . $blog_state;
                        ?>
</a>
							<?php 
                        if ('list' != $mode) {
                            echo '<p>' . sprintf(_x('%1$s &#8211; <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.'), get_blog_option($blog['blog_id'], 'blogname'), get_blog_option($blog['blog_id'], 'blogdescription ')) . '</p>';
                        }
                        // Preordered.
                        $actions = array('edit' => '', 'backend' => '', 'activate' => '', 'deactivate' => '', 'archive' => '', 'unarchive' => '', 'spam' => '', 'unspam' => '', 'delete' => '', 'visit' => '');
                        $actions['edit'] = '<span class="edit"><a href="' . esc_url(network_admin_url('site-info.php?id=' . $blog['blog_id'])) . '">' . __('Edit') . '</a></span>';
                        $actions['backend'] = "<span class='backend'><a href='" . esc_url(get_admin_url($blog['blog_id'])) . "' class='edit'>" . __('Dashboard') . '</a></span>';
                        if ($current_site->blog_id != $blog['blog_id']) {
                            if (get_blog_status($blog['blog_id'], 'deleted') == '1') {
                                $actions['activate'] = '<span class="activate"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to activate the site %s'), $blogname))), 'confirm')) . '">' . __('Activate') . '</a></span>';
                            } else {
                                $actions['deactivate'] = '<span class="activate"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to deactivate the site %s'), $blogname))), 'confirm')) . '">' . __('Deactivate') . '</a></span>';
                            }
                            if (get_blog_status($blog['blog_id'], 'archived') == '1') {
                                $actions['unarchive'] = '<span class="archive"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to unarchive the site %s.'), $blogname))), 'confirm')) . '">' . __('Unarchive') . '</a></span>';
                            } else {
                                $actions['archive'] = '<span class="archive"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to archive the site %s.'), $blogname))), 'confirm')) . '">' . _x('Archive', 'verb; site') . '</a></span>';
                            }
                            if (get_blog_status($blog['blog_id'], 'spam') == '1') {
                                $actions['unspam'] = '<span class="spam"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to unspam the site %s.'), $blogname))), 'confirm')) . '">' . _x('Not Spam', 'site') . '</a></span>';
                            } else {
                                $actions['spam'] = '<span class="spam"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to mark the site %s as spam.'), $blogname))), 'confirm')) . '">' . _x('Spam', 'site') . '</a></span>';
                            }
                            if (current_user_can('delete_site', $blog['blog_id'])) {
                                $actions['delete'] = '<span class="delete"><a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode(sprintf(__('You are about to delete the site %s.'), $blogname))), 'confirm')) . '">' . __('Delete') . '</a></span>';
                            }
                        }
                        $actions['visit'] = "<span class='view'><a href='" . esc_url(get_home_url($blog['blog_id'])) . "' rel='permalink'>" . __('Visit') . '</a></span>';
                        $actions = apply_filters('manage_sites_action_links', array_filter($actions), $blog['blog_id'], $blogname);
                        echo $this->row_actions($actions);
                        ?>
						</td>
					<?php 
                        break;
                    case 'lastupdated':
                        echo "<td valign='top' class='{$column_name} column-{$column_name}'{$style}>";
                        if ('list' == $mode) {
                            $date = 'Y/m/d';
                        } else {
                            $date = 'Y/m/d \\<\\b\\r \\/\\> g:i:s a';
                        }
                        echo $blog['last_updated'] == '0000-00-00 00:00:00' ? __('Never') : mysql2date($date, $blog['last_updated']);
                        ?>
						</td>
					<?php 
                        break;
                    case 'registered':
                        echo "<td valign='top' class='{$column_name} column-{$column_name}'{$style}>";
                        if ($blog['registered'] == '0000-00-00 00:00:00') {
                            echo '&#x2014;';
                        } else {
                            echo mysql2date($date, $blog['registered']);
                        }
                        ?>
						</td>
					<?php 
                        break;
                    case 'users':
                        echo "<td valign='top' class='{$column_name} column-{$column_name}'{$style}>";
                        $blogusers = get_users(array('blog_id' => $blog['blog_id'], 'number' => 6));
                        if (is_array($blogusers)) {
                            $blogusers_warning = '';
                            if (count($blogusers) > 5) {
                                $blogusers = array_slice($blogusers, 0, 5);
                                $blogusers_warning = __('Only showing first 5 users.') . ' <a href="' . esc_url(network_admin_url('site-users.php?id=' . $blog['blog_id'])) . '">' . __('More') . '</a>';
                            }
                            foreach ($blogusers as $user_object) {
                                echo '<a href="' . esc_url(network_admin_url('user-edit.php?user_id=' . $user_object->ID)) . '">' . esc_html($user_object->user_login) . '</a> ';
                                if ('list' != $mode) {
                                    echo '( ' . $user_object->user_email . ' )';
                                }
                                echo '<br />';
                            }
                            if ($blogusers_warning != '') {
                                echo '<strong>' . $blogusers_warning . '</strong><br />';
                            }
                        }
                        ?>
						</td>
					<?php 
                        break;
                    case 'plugins':
                        ?>
					<?php 
                        if (has_filter('wpmublogsaction')) {
                            echo "<td valign='top' class='{$column_name} column-{$column_name}'{$style}>";
                            do_action('wpmublogsaction', $blog['blog_id']);
                            ?>
					</td>
					<?php 
                        }
                        break;
                    default:
                        echo "<td class='{$column_name} column-{$column_name}'{$style}>";
                        do_action('manage_sites_custom_column', $column_name, $blog['blog_id']);
                        echo "</td>";
                        break;
                }
            }
            ?>
			</tr>
			<?php 
        }
    }
 function check_privacy()
 {
     $settings_updated = isset($_GET['settings-updated']) ? $_GET['settings-updated'] : false;
     if ($settings_updated === true) {
         $blog_public = get_blog_status($this->db->blogid, 'public');
         if ($blog_public != '1') {
             $this->remove_from_index($this->db->blogid);
         }
     }
 }
    public function display_rows()
    {
        global $mode;
        $alt = '';
        $super_admins = get_super_admins();
        foreach ($this->items as $user) {
            $alt = 'alternate' == $alt ? '' : 'alternate';
            $status_list = array('spam' => 'site-spammed', 'deleted' => 'site-deleted');
            foreach ($status_list as $status => $col) {
                if ($user->{$status}) {
                    $alt .= " {$col}";
                }
            }
            ?>
			<tr class="<?php 
            echo $alt;
            ?>
">
			<?php 
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='{$column_name} column-{$column_name}'";
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = "{$class}{$style}";
                switch ($column_name) {
                    case 'cb':
                        ?>
						<th scope="row" class="check-column">
							<label class="screen-reader-text" for="blog_<?php 
                        echo $user->ID;
                        ?>
"><?php 
                        echo sprintf(__('Select %s'), $user->user_login);
                        ?>
</label>
							<input type="checkbox" id="blog_<?php 
                        echo $user->ID;
                        ?>
" name="allusers[]" value="<?php 
                        echo esc_attr($user->ID);
                        ?>
" />
						</th>
					<?php 
                        break;
                    case 'username':
                        $avatar = get_avatar($user->user_email, 32);
                        $edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user->ID)));
                        echo "<td {$attributes}>";
                        ?>
							<?php 
                        echo $avatar;
                        ?>
<strong><a href="<?php 
                        echo $edit_link;
                        ?>
" class="edit"><?php 
                        echo $user->user_login;
                        ?>
</a><?php 
                        if (in_array($user->user_login, $super_admins)) {
                            echo ' - ' . __('Super Admin');
                        }
                        ?>
</strong>
							<br/>
							<?php 
                        $actions = array();
                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
                        if (current_user_can('delete_user', $user->ID) && !in_array($user->user_login, $super_admins)) {
                            $actions['delete'] = '<a href="' . ($delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), wp_nonce_url('users.php', 'deleteuser') . '&amp;action=deleteuser&amp;id=' . $user->ID))) . '" class="delete">' . __('Delete') . '</a>');
                        }
                        /**
                         * Filter the action links displayed under each user
                         * in the Network Admin Users list table.
                         *
                         * @since 3.2.0
                         *
                         * @param array   $actions An array of action links to be displayed.
                         *                         Default 'Edit', 'Delete'.
                         * @param WP_User $user    WP_User object.
                         */
                        $actions = apply_filters('ms_user_row_actions', $actions, $user);
                        echo $this->row_actions($actions);
                        ?>
						</td>
					<?php 
                        break;
                    case 'name':
                        echo "<td {$attributes}>{$user->first_name} {$user->last_name}</td>";
                        break;
                    case 'email':
                        echo "<td {$attributes}><a href='" . esc_url("mailto:{$user->user_email}") . "'>{$user->user_email}</a></td>";
                        break;
                    case 'registered':
                        if ('list' == $mode) {
                            $date = 'Y/m/d';
                        } else {
                            $date = 'Y/m/d \\<\\b\\r \\/\\> g:i:s a';
                        }
                        echo "<td {$attributes}>" . mysql2date($date, $user->user_registered) . "</td>";
                        break;
                    case 'blogs':
                        $blogs = get_blogs_of_user($user->ID, true);
                        echo "<td {$attributes}>";
                        if (is_array($blogs)) {
                            foreach ((array) $blogs as $key => $val) {
                                if (!can_edit_network($val->site_id)) {
                                    continue;
                                }
                                $path = $val->path == '/' ? '' : $val->path;
                                echo '<span class="site-' . $val->site_id . '" >';
                                echo '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $val->userblog_id)) . '">' . str_replace('.' . get_current_site()->domain, '', $val->domain . $path) . '</a>';
                                echo ' <small class="row-actions">';
                                $actions = array();
                                $actions['edit'] = '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $val->userblog_id)) . '">' . __('Edit') . '</a>';
                                $class = '';
                                if (get_blog_status($val->userblog_id, 'spam') == 1) {
                                    $class .= 'site-spammed ';
                                }
                                if (get_blog_status($val->userblog_id, 'mature') == 1) {
                                    $class .= 'site-mature ';
                                }
                                if (get_blog_status($val->userblog_id, 'deleted') == 1) {
                                    $class .= 'site-deleted ';
                                }
                                if (get_blog_status($val->userblog_id, 'archived') == 1) {
                                    $class .= 'site-archived ';
                                }
                                $actions['view'] = '<a class="' . $class . '" href="' . esc_url(get_home_url($val->userblog_id)) . '">' . __('View') . '</a>';
                                /**
                                 * Filter the action links displayed next the sites a user belongs to
                                 * in the Network Admin Users list table.
                                 *
                                 * @since 3.1.0
                                 *
                                 * @param array $actions     An array of action links to be displayed.
                                 *                           Default 'Edit', 'View'.
                                 * @param int   $userblog_id The site ID.
                                 */
                                $actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id);
                                $i = 0;
                                $action_count = count($actions);
                                foreach ($actions as $action => $link) {
                                    ++$i;
                                    $i == $action_count ? $sep = '' : ($sep = ' | ');
                                    echo "<span class='{$action}'>{$link}{$sep}</span>";
                                }
                                echo '</small></span><br/>';
                            }
                        }
                        ?>
						</td>
					<?php 
                        break;
                    default:
                        echo "<td {$attributes}>";
                        /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
                        echo apply_filters('manage_users_custom_column', '', $column_name, $user->ID);
                        echo "</td>";
                        break;
                }
            }
            ?>
			</tr>
			<?php 
        }
    }
Exemple #26
0
 function is_blog_indexable($blog_id)
 {
     $this->switch_to_blog($blog_id);
     $indexing = get_option('postindexer_active', 'yes');
     if ($indexing == 'yes') {
         $blog_archived = get_blog_status($blog_id, 'archived');
         $blog_mature = get_blog_status($blog_id, 'mature');
         $blog_spam = get_blog_status($blog_id, 'spam');
         $blog_deleted = get_blog_status($blog_id, 'deleted');
         if ($blog_archived == '1') {
             $indexing = 'no';
         }
         if ($blog_mature == '1') {
             $indexing = 'no';
         }
         if ($blog_spam == '1') {
             $indexing = 'no';
         }
         if ($blog_deleted == '1') {
             $indexing = 'no';
         }
     }
     $this->restore_current_blog();
     $indexing = apply_filters('postindexer_is_blog_indexable', $indexing, $blog_id);
     if ($indexing == 'yes') {
         return true;
     } else {
         return false;
     }
 }
/**
 * Check if a particular blog is archived.
 *
 * @since MU
 *
 * @param int $id The blog id
 * @return string Whether the blog is archived or not
 */
function is_archived($id)
{
    return get_blog_status($id, 'archived');
}
 /**
  * Categories settings changed, updated sites
  * 
  * @param array $cats_arr
  */
 public function update_sites($cats_arr)
 {
     $this->options = $cats_arr;
     $blogs = self::get_blog_list();
     foreach ($blogs as $blog) {
         $id = $blog['blog_id'];
         $opt = get_blog_option($id, 'site_category');
         $mature = $this->do_name_to_mature($opt);
         if (!$mature) {
             update_blog_option($id, 'site_category', '');
         }
         update_blog_status(absint($id), 'mature', $mature);
         get_blog_status(absint($id), 'mature');
     }
 }