コード例 #1
0
 /**
  * Adds a 'View Admin As: Reset view' link to the Meta sidebar widget if the admin bar is hidden
  *
  * @since   1.6
  * @access  public
  */
 public function action_wp_meta()
 {
     if (!is_admin_bar_showing() && $this->store->get_viewAs()) {
         $link = __('View Admin As', 'view-admin-as') . ': ' . __('Reset view', 'view-admin-as');
         $url = VAA_API::get_reset_link();
         echo '<li id="vaa_reset_view"><a href="' . esc_url($url) . '">' . esc_html($link) . '</a></li>';
     }
 }
コード例 #2
0
    /**
     * Add options to the access denied page when the user has selected a view and did something this view is not allowed
     *
     * @since   1.3
     * @since   1.5.1   Check for SSL
     * @since   1.6     More options and better description
     * @access  public
     *
     * @param   string  $function_name  function callback
     * @return  string  $function_name  function callback
     */
    public function die_handler($function_name)
    {
        if (false != $this->store->get_viewAs()) {
            $options = array();
            if (is_network_admin()) {
                $dashboard_url = network_admin_url();
                $options[] = array('text' => __('Go to network dashboard', 'view-admin-as'), 'url' => $dashboard_url);
            } else {
                $dashboard_url = admin_url();
                $options[] = array('text' => __('Go to dashboard', 'view-admin-as'), 'url' => $dashboard_url);
                $options[] = array('text' => __('Go to homepage', 'view-admin-as'), 'url' => get_bloginfo('url'));
            }
            // Reset url
            $options[] = array('text' => __('Reset the view', 'view-admin-as'), 'url' => VAA_API::get_reset_link());
            ?>
<div>
	<h3><?php 
            _e('View Admin As', 'view-admin-as');
            ?>
:</h3>
	<?php 
            _e('The view you have selected is not permitted to view this page, please choose one of the options below.', 'view-admin-as');
            ?>
	<ul>
		<?php 
            foreach ($options as $option) {
                ?>
		<li><a href="<?php 
                echo $option['url'];
                ?>
"><?php 
                echo $option['text'];
                ?>
</a></li>
		<?php 
            }
            ?>
	</ul>
</div>
<hr>
<?php 
        }
        return $function_name;
    }