Create links from Admin Bar

@see \WP_Admin_Bar
776330
public function adminBar() {
		global $wp_admin_bar;

		if ( ! $wp_admin_bar instanceof \WP_Admin_Bar ) {
			return;
		}
		$nodes = $wp_admin_bar->get_nodes();
		if ( ! is_iterable( $nodes ) ) {
			return;
		}

		// First initialize the array of child/parent pairs:
		$relationships = [];
		foreach ( $nodes as $id => $node ) {
			$parent = ! empty( $node->parent ) ? $node->parent : 'root';
			// Child : Parent
			$relationships[ $id ] = $parent;
		}
		$relationships['root'] = null;

		$tree = $this->parseAdminBarTree( $relationships );

		ob_start();
		$this->printAdminBarTree( $tree[0]['children'], $nodes );
		$html = ob_get_clean();

		$this->adminBarForSiteMap = $html;
	}
1308839
function makeLinks (links, item) {
  var retLinks = {}

  _.each(links, function (value, name) {
    if (_.isFunction(value)) {
      retLinks[name] = value(item)
    } else {
      retLinks[name] = _(value).toString()
    }
  })

  return retLinks
}
1141431
public function createLinks($web) {
        $web = Path::ds($web, true);

        foreach ($this->getModules() as $key => $module) {
            $moduleWeb = $module->getPath() . 'web' . Path::SEPARATOR;

            if (!file_exists($moduleWeb)) {
                continue;
            }

            $targetLink = $web . $key . Path::SEPARATOR;

            // Create symlink if folder doesn't exist
            if (!file_exists($targetLink)) {
                symlink($moduleWeb, $targetLink);

            // Throw an error if file exists but is not a symlink
            } else if (is_file($targetLink) && !is_link($targetLink)) {
                throw new AssetSymlinkException(sprintf('Webroot folder %s must not exist so that static assets can be symlinked', $key));
            }
        }
    }
854061
public function admin_init(){
        if( !AjaxBase::is_ajax() && current_user_can('manage_options') ){
            if( !empty($this->classes) ){
                $rewrites = '';
                foreach( $this->classes as $class_name ){
                   $rewrites .= $this->get_prefix($class_name);
                }
                $rewrites = md5($rewrites);
                if( get_option('rewrite_rules') && $this->rewrite_md5 != $rewrites ){
                    flush_rewrite_rules();
                    $last_updated = current_time('timestamp');
                    update_option($this->option_name, $last_updated);
                    update_option($this->rewrite_md5_name, $rewrites);
                    $message = sprintf($this->__('Rewrite rules updated. Last modified date is %s'), date_i18n(get_option('date_format').' '.get_option('time_format'), $last_updated));
                    add_action('admin_notices', function() use ($message){
                        printf('<div class="updated"><p>%s</p></div>', $message);
                    });
                }
            }
        }
    }
1036741
public function createAdminMenu() {
        $connection = \Yii::$app->db;
        $query = new Query;
        if(!$this->singleMenu) {
            $menu_name = $this->friendly($this->getController());
            $menu = $query->from('AdminMenu')
                ->where('internal=:internal', [':internal'=>$this->menu])
                ->one();

            if(!$menu) {
                $query = new Query;
                // compose the query
                $last_main_menu = $query->from('AdminMenu')
                    ->where('AdminMenu_id IS NULL')
                    ->orderby('order DESC')          
                    ->one();

                $this->insert('AdminMenu', [
                    "name" => $this->menu,
                    "internal" => $this->menu,
                    "url" => '',
                    "ap" => 'read::'.$this->getController(),
                    "order" => $last_main_menu ? $last_main_menu['order'] + 1 : 1
                ]);
                $menu_id = $connection->getLastInsertID();
            } else {
                $menu_id = $menu['id'];
            }
        } else {
            $menu_id = NULL;
            $menu_name = $this->menu;
        }
        $query = new Query;

        $last_menu = $query->from('AdminMenu')
                ->from('AdminMenu')
                ->where('AdminMenu_id=:AdminMenu_id', [':AdminMenu_id'=>$menu_id])
                ->orderby('order DESC')
                ->one();

        $this->insert('AdminMenu', [
            "AdminMenu_id" => $menu_id,
            "name" => $menu_name,
            "internal" => $this->getController() . 'Controller',
            "url" => ($this->module ? '/' . $this->module : '' ) . '/'. strtolower(trim(preg_replace("([A-Z])", "-$0", $this->getController()), '-')).'/',
            "ap" => 'read::'.$this->getController(),
            "order" => $last_menu ? $last_menu['order'] + 1 : 1
        ]);
    }
1261471
def bind(cls, app, *paths, methods=None, name=None, view=None):
        """"""
        # Register self in admin
        if view is None:
            app.ps.admin.register(cls)
            if not paths:
                paths = ('%s/%s' % (app.ps.admin.cfg.prefix, name or cls.name),)
            cls.url = paths[0]
        return super(AdminHandler, cls).bind(app, *paths, methods=methods, name=name, view=view)
703056
protected function createDB()
    {
        $this->output->writeLn("Generating MySQL database based on the environment's configuration.");
        $command = sprintf("%s db create", $this->getWpCliPath());
        system($command);

        $this->nl();

        $title = 'StrataEnvironment';
        $adminUser = "admin";
        $adminPassword = "admin";
        $adminEmail = "admin@yourdomain.com";

        $this->output->writeLn("Installing using the following administrator information:");
        $this->output->writeLn("  Title:      $title");
        $this->output->writeLn("  User:       $adminUser");
        $this->output->writeLn("  Password:   $adminPassword");
        $this->output->writeLn("  Email:      $adminEmail");

        $command = sprintf("%s core install --url=%s --title=%s --admin_user=%s --admin_password=%s --admin_email=%s", $this->getWpCliPath(), WP_HOME, $title, $adminUser, $adminPassword, $adminEmail);
        system($command);
    }
186913
def create_links(self):
        
        for link in self.list_exes():
            print_pretty("<FG_BLUE>Creating link for {}...<END>".format(link))
            os.symlink(link, path.join(ENV_BIN, path.basename(link)))
650262
public function create_links()
    {
        // If our item count || per-page total is zero there is no need to continue.
        if ($this->total_rows == 0 || $this->per_page == 0) {
            return '';
        }

        // Calculate the total number of pages
        $num_pages = ceil($this->total_rows / $this->per_page);

        // Is there only one page? Hm... nothing more to do here then.
        if ($num_pages == 1) {
            return '';
        }

        // Set the base page index for starting page number
        if ($this->use_page_numbers) {
            $base_page = 1;
        } else {
            $base_page = 0;
        }

        // Determine the current page number.
        $CI =& get_instance();

        if ($CI->config->item('enable_query_strings') === true || $this->page_query_string === true) {
            if ($CI->input->get($this->query_string_segment) != $base_page) {
                $this->cur_page = $CI->input->get($this->query_string_segment);

                // Prep the current page - no funny business!
                $this->cur_page = (int) $this->cur_page;
            }
        } else {
            //  BEGIN CHANGES
            if (!$this->use_rsegment && $CI->uri->segment($this->uri_segment) != $base_page) {
                $this->cur_page = $CI->uri->segment($this->uri_segment);

                // Prep the current page - no funny business!
                $this->cur_page = (int) $this->cur_page;
            }

            if ($this->use_rsegment && $CI->uri->rsegment($this->uri_segment) != $base_page) {
                $this->cur_page = $CI->uri->rsegment($this->uri_segment);

                // Prep the current page - no funny business!
                $this->cur_page = (int) $this->cur_page;
            }
            //  END CHANGES
        }

        // Set current page to 1 if using page numbers instead of offset
        if ($this->use_page_numbers && $this->cur_page == 0) {
            $this->cur_page = $base_page;
        }

        $this->num_links = (int) $this->num_links;

        if ($this->num_links < 1) {
            throw new NailsException('Your number of links must be a positive number.', 1);
        }

        if (!is_numeric($this->cur_page)) {
            $this->cur_page = $base_page;
        }

        // Is the page number beyond the result range?
        // If so we show the last page
        if ($this->use_page_numbers) {
            if ($this->cur_page > $num_pages) {
                $this->cur_page = $num_pages;
            }
        } else {
            if ($this->cur_page > $this->total_rows) {
                $this->cur_page = ($num_pages - 1) * $this->per_page;
            }
        }

        $uri_page_number = $this->cur_page;

        if (!$this->use_page_numbers) {
            $this->cur_page = floor(($this->cur_page / $this->per_page) + 1);
        }

        // Calculate the start && end numbers. These determine
        // which number to start && end the digit links with
        $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
        $end   = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;

        // Is pagination being used over GET || POST?  If get, add a per_page query
        // string. If post, add a trailing slash to the base URL if needed
        if ($CI->config->item('enable_query_strings') === true || $this->page_query_string === true) {
            $this->base_url = rtrim($this->base_url) . '&amp;' . $this->query_string_segment . '=';
        } else {
            $this->base_url = rtrim($this->base_url, '/') . '/';
        }

        // && here we go...
        $output = '';

        // Render the "First" link
        if ($this->first_link !== false && $this->cur_page > ($this->num_links + 1)) {
            $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url;
            $output    .= $this->first_tag_open . '<a href="' . $first_url . '">' . $this->first_link . '</a>' . $this->first_tag_close;
        }

        // Render the "previous" link
        if ($this->prev_link !== false && $this->cur_page != 1) {
            if ($this->use_page_numbers) {
                $i = $uri_page_number - 1;
            } else {
                $i = $uri_page_number - $this->per_page;
            }

            if ($i == 0 && $this->first_url != '') {
                $output .= $this->prev_tag_open . '<a href="' . $this->first_url . '">' . $this->prev_link . '</a>' . $this->prev_tag_close;
            } else {
                $i      = ($i == 0) ? '' : $this->prefix . $i . $this->suffix;
                $output .= $this->prev_tag_open . '<a href="' . $this->base_url . $i . '">' . $this->prev_link . '</a>' . $this->prev_tag_close;
            }

        }

        // Render the pages
        if ($this->display_pages !== false) {
            // Write the digit links
            for ($loop = $start - 1; $loop <= $end; $loop++) {
                if ($this->use_page_numbers) {
                    $i = $loop;
                } else {
                    $i = ($loop * $this->per_page) - $this->per_page;
                }

                if ($i >= $base_page) {
                    if ($this->cur_page == $loop) {
                        $output .= $this->cur_tag_open . $loop . $this->cur_tag_close; // Current page
                    } else {
                        $n = ($i == $base_page) ? '' : $i;

                        if ($n == '' && $this->first_url != '') {
                            $output .= $this->num_tag_open . '<a href="' . $this->first_url . '">' . $loop . '</a>' . $this->num_tag_close;
                        } else {
                            $n = ($n == '') ? '' : $this->prefix . $n . $this->suffix;

                            $output .= $this->num_tag_open . '<a href="' . $this->base_url . $n . '">' . $loop . '</a>' . $this->num_tag_close;
                        }
                    }
                }
            }
        }

        // Render the "next" link
        if ($this->next_link !== false && $this->cur_page < $num_pages) {
            if ($this->use_page_numbers) {
                $i = $this->cur_page + 1;
            } else {
                $i = ($this->cur_page * $this->per_page);
            }

            $output .= $this->next_tag_open . '<a href="' . $this->base_url . $this->prefix . $i . $this->suffix . '">' . $this->next_link . '</a>' . $this->next_tag_close;
        }

        // Render the "Last" link
        if ($this->last_link !== false && ($this->cur_page + $this->num_links) < $num_pages) {
            if ($this->use_page_numbers) {
                $i = $num_pages;
            } else {
                $i = (($num_pages * $this->per_page) - $this->per_page);
            }
            $output .= $this->last_tag_open . '<a href="' . $this->base_url . $this->prefix . $i . $this->suffix . '">' . $this->last_link . '</a>' . $this->last_tag_close;
        }

        // Kill double slashes.  Note: Sometimes we can end up with a double slash
        // in the penultimate link so we'll kill all double slashes.
        $output = preg_replace("#([^:])//+#", "\\1/", $output);

        // Add the wrapper HTML if exists
        $output = $this->full_tag_open . $output . $this->full_tag_close;

        return $output;
    }
740205
public function createLink($label, $href = null, $position = self::NAVBAR_LEFT)
    {
        if ( ! is_object($label) && isset($href)) {
            $label = new Link($label, $href);
        }

        switch ($position) {
            default:
            case self::NAVBAR_LEFT:
                $node = $this->left->createList($label);
                break;

            case self::NAVBAR_RIGHT:
                $node = $this->right->createList($label);
                break;
        }

        return $node;
    }
1237745
public function createHooks()
	{
		global $context;

		// Get the hooks.
		$hooks = $this['config']->get('availableHooks');
		$overwriteHooks = $this['config']->get('overwriteHooks');

		// Don't execute on uninstall.
		if (!empty($context['uninstalling']) || $this['data']->get('sa') == 'uninstall2' || !$hooks)
			return;

		foreach ($hooks as $hook => $hook_name)
		{
			// The $hook_name value acts as an "enable" check, empty means you do not want to use this hook.
			if (empty($hook_name))
				continue;

			// Gotta replace our tokens.
			if ($overwriteHooks && !empty($overwriteHooks[$hook]))
				$overwriteHooks[$hook]['file'] = $this['tools']->parser($overwriteHooks[$hook]['file'], array(
					'$sourcedir' => $this->sourceDir,
					'$scripturl' => $this->scriptUrl,
					'$boarddir' => $this->boardDir,
					'$boardurl' => $this->boardUrl,
				));

			else
				$overwriteHooks[$hook] = [];

			// Set some default values.
			$defaultValues = array(
				'hookName' => $hook_name,
				'func' => $this->name .'::add'. ucfirst($hook),
				'permanent' => false,
				'file' => '$sourcedir/'. $this->name .'.php',
				'object' => true,
			);

			// You might or might not want to overwrite this...
			extract(array_merge($defaultValues, $overwriteHooks[$hook]));

			// You can also disable any hook used by this mod from the mod's admin settings if the mod has that feature.
			$hookAction = ($this->enable('disable_hook_'. $hook_name) ? 'remove' : 'add') .'_integration_function';

			$hookAction($hookName, $func, $permanent, $file, $object);
		}
	}
914060
public function setup_link() {
		$link = get_term_link( $this->term_object->term_id, $this->term_object->taxonomy );
		$this->set_link( $link );
	}
1273947
public function add_link_modal() {

		if ( ! class_exists( '_WP_Editors', false ) && file_exists( ABSPATH . WPINC . '/class-wp-editor.php' ) ) {
			require_once ABSPATH . WPINC . '/class-wp-editor.php';
		}

		if ( class_exists( '_WP_Editors' ) && method_exists( '_WP_Editors', 'wp_link_dialog' ) ) {
			_WP_Editors::wp_link_dialog();
		} else {
			echo '<div style="display:none;">';
			wp_editor( '', 'pods-link-editor-hidden' );
			echo '</div>';
		}

	}
1363168
protected function prepareLinks()
    {
        $links = [];
        if ($this->homeLink === null) {
            $links[] = $this->renderItem([
                'label' => Yii::t('yii', 'Home'),
                'url' => Yii::$app->homeUrl,
            ], $this->itemTemplate);
        } elseif ($this->homeLink !== false) {
            $links[] = $this->renderItem($this->homeLink, $this->itemTemplate);
        }

        foreach ($this->links as $link) {
            if (!is_array($link)) {
                $link = ['label' => $link];
            }
            $links[] = $this->renderItem($link, isset($link['url']) ? $this->itemTemplate : $this->activeItemTemplate);
        }

        return $links;
    }
135530
public function addToolbarCommands()
    {
        $entity = $this->getController()->getItem();

        if ($entity->authorize('vote')) {
            $this->addCommand('vote');
        }

        if ($entity->authorize('subscribe') || ($entity->isSubscribable() && $entity->subscribed(get_viewer()))) {
            $this->addCommand('subscribe');
        }

        if ($entity->authorize('edit')) {
            $this->addCommand('edit');
        }

        if ($entity->isOwnable() && $entity->owner->authorize('administration')) {
            $this->addAdministrationCommands();
        }

        if ($entity->authorize('delete')) {
            $this->addCommand('delete');
        }
    }
275937
def make_links(current_cn):
    '''
        
    '''
    if not os.path.isfile(CURRENT_CERTIFICATE_PATH):
        target = '{}/{}.crt'.format(CERTIFICATES_PATH, current_cn)
        print 'Create symlink {} -> {}'.format(CURRENT_CERTIFICATE_PATH,
                                               target)
        os.symlink(target, CURRENT_CERTIFICATE_PATH)

    if not os.path.isfile(CURRENT_PRIVATE_KEY_PATH):
        target = '{}/{}.key'.format(CERTIFICATES_PATH, current_cn)
        print 'Create symlink {} -> {}'.format(CURRENT_PRIVATE_KEY_PATH,
                                               target)
        os.symlink(target, CURRENT_PRIVATE_KEY_PATH)
133602
public function action_addAdminMenus()
    {
        // Default to the model's likely controller.
        $defaultController = Controller::generateClassName($this->model->getShortName());
        $parentSlug = 'edit.php?post_type=' . $this->model->getWordpressKey();

        foreach ($this->getConfiguration() as $func => $config) {
            $config += array(
                'title'         => ucfirst($func),
                'menu-title'    => ucfirst($func),
                'capability'    => "manage_options",
                'icon'          => null,
                'route'         => array($defaultController, $func),
                'position'      => null,
            );

            // This is to circumvent how Wordpress doesn't let you pass arguments to
            // callbacks so we can send the controller and function to the router.
            // We dont want people to have to specify that odd function name.
            // Allow them to send the controller string name and take care of the rest.
            if (is_string($config['route'])) {
                $route = Router::callback($config['route'], $func);
            } else {
                $route = Router::callback($config['route'][0], $config['route'][1]);
            }

            $uniquePage = $this->model->getWordpressKey() . "_" . $func;
            add_submenu_page($parentSlug, $config['title'], $config['menu-title'], $config['capability'], $uniquePage, $route, $config['icon'], $config['position']);
        }
    }