示例#1
0
$action = $wp_list_table->current_action();
$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$temp_args = array('enabled', 'disabled', 'error');
$_SERVER['REQUEST_URI'] = remove_query_arg($temp_args, $_SERVER['REQUEST_URI']);
$referer = remove_query_arg($temp_args, wp_get_referer());
if (!empty($_REQUEST['paged'])) {
    $referer = add_query_arg('paged', (int) $_REQUEST['paged'], $referer);
}
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
if (!$id) {
    wp_die(__('Invalid site ID.'));
}
$wp_list_table->prepare_items();
$details = get_blog_details($id);
if (!can_edit_network($details->site_id)) {
    wp_die(__('You do not have permission to access this page.'), 403);
}
$is_main_site = is_main_site($id);
if ($action) {
    switch_to_blog($id);
    $allowed_themes = get_option('allowedthemes');
    switch ($action) {
        case 'enable':
            check_admin_referer('enable-theme_' . $_GET['theme']);
            $theme = $_GET['theme'];
            $action = 'enabled';
            $n = 1;
            if (!$allowed_themes) {
                $allowed_themes = array($theme => true);
            } else {
    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 
        }
    }
 /**
  * Handles the blogs/sites column output.
  *
  * @since 4.3.0
  * @access public
  *
  * @param WP_User $user The current WP_User object.
  */
 public function column_blogs($user)
 {
     $blogs = get_blogs_of_user($user->ID, true);
     if (!is_array($blogs)) {
         return;
     }
     foreach ($blogs as $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 ($val->spam == 1) {
             $class .= 'site-spammed ';
         }
         if ($val->mature == 1) {
             $class .= 'site-mature ';
         }
         if ($val->deleted == 1) {
             $class .= 'site-deleted ';
         }
         if ($val->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;
             $sep = $i == $action_count ? '' : ' | ';
             echo "<span class='{$action}'>{$link}{$sep}</span>";
         }
         echo '</small></span><br/>';
     }
 }
    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 
        }
    }
    /**
     * Display Edit Site Section of Settings Page
     */
    function edit_site_Network_Admin_GForms_TMP()
    {
        $unauthorized = false;
        if (!is_multisite()) {
            $unauthorized = __('Multisite support is not enabled.');
        }
        if (!current_user_can('manage_sites')) {
            $unauthorized = __('You do not have sufficient permissions to edit this site.');
        }
        $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
        if (!$id) {
            $unauthorized = __('Invalid site ID.');
        }
        $details = get_blog_details($id);
        if (!can_edit_network($details->site_id)) {
            $unauthorized = __('You do not have permission to access this page.');
        }
        if ($unauthorized) {
            echo "<p>{$unauthorized}</p>\n";
            return;
        }
        $site_url_no_http = preg_replace('#^http(s)?://#', '', get_blogaddress_by_id($id));
        $title_site_url_linked = sprintf(__('API Enabled: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id($id), $site_url_no_http);
        $gforms_tmp_admin_client_id = \get_blog_option($id, 'gforms_tmp_admin_client_id', false);
        $gforms_tmp_admin_client_name = \get_blog_option($id, 'gforms_tmp_admin_client_name', false);
        $gforms_tmp_active = \get_blog_option($id, 'gforms_tmp_active', false);
        $gforms_tmp_last_update = \get_blog_option($id, 'gforms_tmp_last_update', false);
        $date = 'Y/m/d g:i:s a';
        $is_main_site = \is_main_site($id);
        if (isset($_GET['update'])) {
            $messages = array();
            if ('updated' == $_GET['update']) {
                $messages[1] = __('Site updated.');
            } else {
                $messages[0] = __('Site could not be updated.');
            }
        }
        if (!empty($messages)) {
            foreach ($messages as $status => $msg) {
                echo '<div id="message" class="' . ($status ? 'updated' : 'error') . '"><p>' . $msg . '</p></div>';
            }
        }
        ?>

<div class="wrap">

	<div id="icon-options-general" class="icon32">
		<br>
	</div>

	<h2 id="edit-site"><?php 
        echo $title_site_url_linked;
        ?>
</h2>

	<br />

	<form method="post"
		action="<?php 
        echo network_admin_url('admin.php?page=' . $this::slug . '&action=edit');
        ?>
">

                <?php 
        wp_nonce_field('gforms-tmp-edit-site');
        ?>

                <input type="hidden" name="id"
			value="<?php 
        echo esc_attr($id);
        ?>
" /> <input type="hidden"
			name="action" value="site_update_network_admin_gforms_tmp" />

		<table class="form-table">

			<tr class="form-field form-required">

				<th scope="row"><?php 
        _e('Domain');
        ?>
</th>

                        <?php 
        $protocol = is_ssl() ? 'https://' : 'http://';
        if ($is_main_site) {
            ?>

                            <td><code><?php 
            echo $protocol;
            echo esc_attr($details->domain);
            ?>
</code></td>

                        <?php 
        } else {
            ?>

                            <td><?php 
            echo $protocol;
            ?>
<input
					type="text" id="domain"
					value="<?php 
            echo esc_attr($details->domain);
            ?>
" size="33"
					readonly="readonly" /></td>

                        <?php 
        }
        ?>
                    </tr>

			<tr class="form-field">

				<th scope="row"><?php 
        _e('Ten Street Client Name');
        ?>
</th>

				<td><input type="text" name="gforms_tmp_admin_client_name"
					id="gforms_tmp_admin_client_name"
					value="<?php 
        echo $gforms_tmp_admin_client_name;
        ?>
" /></td>

			</tr>

			<tr class="form-field">

				<th scope="row"><?php 
        _e('Ten Street Client ID');
        ?>
</th>

				<td><input type="text" name="gforms_tmp_admin_client_id"
					id="gforms_tmp_admin_client_id"
					value="<?php 
        echo $gforms_tmp_admin_client_id;
        ?>
" size="4"
					style="width: 50px;" /></td>

			</tr>

                    <?php 
        $attributes = array();
        $attributes['archived'] = $details->archived;
        $attributes['spam'] = $details->spam;
        $attributes['deleted'] = $details->deleted;
        ?>

                    <tr>
				<th scope="row"><?php 
        _e('Enable API');
        ?>
</th>

				<td><label><input type="checkbox" name="gforms_tmp_active" value="1"
						<?php 
        checked((bool) $gforms_tmp_active, true);
        disabled(in_array(1, $attributes));
        ?>
 /> </label><br /></td>

			</tr>

			<tr class="form-field">

				<th scope="row"><?php 
        _e('Last Updated');
        ?>
</th>

				<td><label><?php 
        echo !$gforms_tmp_last_update ? __('Never') : mysql2date($date, date('Y-m-d h:i:s', $gforms_tmp_last_update));
        ?>
</label>

					<input name="gforms_tmp_last_update" type="hidden"
					id="gforms_tmp_last_update"
					value="<?php 
        echo $gforms_tmp_last_update;
        ?>
" /></td>

			</tr>

		</table>

                <?php 
        submit_button();
        ?>

            </form>

</div>

<?php 
    }
示例#6
0
/**
 * Output alias editing page
 */
function output_edit_page()
{
    $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    if (!$id) {
        wp_die(__('Invalid site ID.'));
    }
    $id = absint($id);
    $details = get_blog_details($id);
    if (!can_edit_network($details->site_id) || (int) $details->blog_id !== $id) {
        wp_die(__('You do not have permission to access this page.'));
    }
    // Are we editing?
    $mapping = null;
    $form_action = network_admin_url('admin.php?action=mercator-add');
    if (!empty($_REQUEST['mapping'])) {
        $mapping_id = absint($_REQUEST['mapping']);
        $mapping = Mapping::get($mapping_id);
        if (is_wp_error($mapping) || empty($mapping)) {
            wp_die(__('Invalid alias ID.', 'mercator'));
        }
        $form_action = network_admin_url('admin.php?action=mercator-edit');
    }
    // Handle form submission
    $messages = array();
    if (!empty($_POST['submit'])) {
        $messages = handle_edit_page_submit($id, $mapping);
    }
    output_page_header($id, $messages);
    if (empty($mapping) || !empty($_POST['_wpnonce'])) {
        $domain = empty($_POST['domain']) ? '' : wp_unslash($_POST['domain']);
        $active = !empty($_POST['active']);
    } else {
        $domain = $mapping->get_domain();
        $active = $mapping->is_active();
    }
    ?>
	<form method="post" action="<?php 
    echo esc_url($form_action);
    ?>
">
		<table class="form-table">
			<tr>
				<th scope="row">
					<label for="mercator-domain"><?php 
    echo esc_html_x('Domain Name', 'field name', 'mercator');
    ?>
</label>
				</th>
				<td>
					<input type="text" class="regular-text code"
						name="domain" id="mercator-domain"
						value="<?php 
    echo esc_attr($domain);
    ?>
" />
				</td>
			</tr>
			<tr>
				<th scope="row">
					<?php 
    echo esc_html_x('Active', 'field name', 'mercator');
    ?>
				</th>
				<td>
					<label>
						<input type="checkbox"
							name="active" <?php 
    checked($active);
    ?>
 />

						<?php 
    esc_html_e('Mark alias as active', 'mercator');
    ?>
					</label>
				</td>
			</tr>
		</table>

		<input type="hidden" name="id" value="<?php 
    echo esc_attr($id);
    ?>
" />
		<?php 
    if (empty($mapping)) {
        wp_nonce_field('mercator-add-' . $id);
        submit_button(__('Add Alias', 'mercator'));
    } else {
        echo '<input type="hidden" name="mapping" value="' . esc_attr($mapping->get_id()) . '" />';
        wp_nonce_field('mercator-edit-' . $mapping->get_id());
        submit_button(__('Save Alias', 'mercator'));
    }
    ?>
	</form>
<?php 
    output_page_footer();
}