Loops registered sidebars and creates metaboxes for them
@return  void
421980
public function addSidebarsMetaBoxes()
    {
        global $wp_registered_sidebars;

        $template = \Modularity\Helper\Post::getPostTemplate();
        $sidebars = null;

        $activeAreas = $this->getActiveAreas($template);


        // Add no active sidebars message if no active sidebars exists
        if (is_array($activeAreas) && count($activeAreas) === 0) {
            add_meta_box(
                'no-sidebars',
                __('No active sidebar areas', 'modularity'),
                function () {
                    echo '<p>' . __('There\'s no active sidebars. Please activate sidebar areas in the Modularity Options to add modules.', 'modularity') . '</p>';
                },
                $this->screenHook,
                'normal',
                'low',
                null
            );

            return;
        }

        if (is_array($activeAreas) && !empty($activeAreas)) {
            foreach ($activeAreas as $area) {
                if (isset($wp_registered_sidebars[$area])) {
                    $sidebars[$area] = $wp_registered_sidebars[$area];
                }
            }

            if (is_array($sidebars)) {
                foreach ($sidebars as $sidebar) {
                    $this->sidebarMetaBox($sidebar);
                }
            }
        }
    }
731009
public static function dynamic_sidebar( $sidebar_id ) {
		if ( ! static::_is_caching_sidebars() ) {
			dynamic_sidebar( $sidebar_id );
			return;
		}

		if ( ! static::_is_caching_sidebar( $sidebar_id ) ) {
			dynamic_sidebar( $sidebar_id );
			return;
		}

		if ( is_customize_preview() ) {
			dynamic_sidebar( $sidebar_id );
			return;
		}

		$transient_id = static::get_transient_id( $sidebar_id );
		$transient    = get_transient( $transient_id );

		if ( false === $transient ) {
			ob_start();
			dynamic_sidebar( $sidebar_id );
			$transient = ob_get_clean();
			set_transient( $transient_id, $transient, HOUR_IN_SECONDS );
		}

		// @codingStandardsIgnoreStart
		echo '<!-- Cached sidebar ' . $sidebar_id . ' -->' . $transient . '<!-- /Cached sidebar ' . $sidebar_id . ' -->';
		// @codingStandardsIgnoreEnd
	}
678977
public function dispatch()
    {
        $this->hook->action(
            'admin_print_footer_scripts',
            [$this, 'script']
        )->dispatch();

        echo $this->view->make('Assely::Metabox.metabox', [
            'slug' => $this->metabox->getModel()->getSlug(),
            'fingerprint' => $this->metabox->getModel()->getFingerprint(),
        ]);
    }
1300912
public function whereUsedMetaBox()
    {
        if (empty(self::$enabled)) {
            return;
        }

        global $post;
        $module = $this;

        if (is_null($post)) {
            return;
        }

        $usage = self::getModuleUsage($post->ID);

        add_meta_box('modularity-usage', 'Module usage', function () use ($module, $usage) {
            if (count($usage) == 0) {
                echo '<p>' . __('This modules is not used yet.', 'modularity')  . '</p>';
                return;
            }

            echo '<p>' . __('This module is used on the following places:', 'modularity') . '</p><p><ul class="modularity-usage-list">';

            foreach ($usage as $page) {
                echo '<li><a href="' . get_permalink($page->post_id) . '">' . $page->post_title . '</a></li>';
            }

            echo '</ul></p>';
        }, self::$enabled, 'side', 'default');
    }
49694
private function createPosts()
    {
        if($this->option('posts') || $this->option('posts_per_category') || $this->option('all')) {
            $this->comment('Creating dummy posts...');

            $output = (new \PostSeeder())
                ->setCommand($this)
                ->run(
                    $this->getDefaultOption('posts'),
                    $this->getDefaultOption('posts_per_category'),
                    $this->getDefaultOption('post_type'),
                    $this->getDefaultOption('media'),
                    $this->getDefaultOption('tags'),
                    $this->getDefaultOption('category'),
                    ($this->getDefaultOption('post_types') == 'all' ? true : false)
                );
            $this->info($output);
        }
        return $this;
    }
1115212
public function addSidebars($configs)
    {
        // Define defaults
        $default = [
            'name'          => Translate::t('configuration.sidebar.name'),
            'id'            => '',
            'description'   => '',
            'class'         => '',
            'before_widget' => '',
            'after_widget'  => '',
            'before_title'  => '',
            'after_title'   => '',
        ];

        // Check
        if (empty($configs)) {
            return;
        }

        // Iterate on configs
        foreach ($configs as $key => $props) {
            $props = !is_array($props) ? [$props] : $props;

            // Set id
            $props['id'] = isset($props['id']) && !empty($props['id']) ? $props['id'] : $key;

            // Set props
            $props = array_merge($default, $props);

            // Register sidebar
            register_sidebar($props);
        }
    }
517797
public function shortcodeMetabox()
    {
        if (empty(self::$enabled)) {
            return;
        }

        add_meta_box('modularity-shortcode', 'Modularity Shortcode', function () {
            global $post;
            echo '<p>';
            echo __('Copy and paste this shortcode to display the module inline.', 'modularity');
            echo '</p><p>';
            echo '<label><input type="checkbox" class="modularity-inline-template" checked> Use inline template</label>';
            echo '<textarea style="margin-top:10px; overflow: hidden;width: 100%;height:30px;background:#f9f9f9;border:1px solid #ddd;padding:5px;">[modularity id="' . $post->ID . '"]</textarea>';
            echo '</p>';

            echo "<script>
                jQuery(document).ready(function ($) {
                    $('.modularity-inline-template').prop('checked', true);

                    $('.modularity-inline-template').on('change', function () {
                        if ($(this).prop('checked') == false) {
                            $(this).parents('.inside').find('pre span').text(' inline=\"false\"');
                        } else {
                            $(this).parents('.inside').find('pre span').text('');
                        }
                    });
                });
            </script>";
        }, self::$enabled, 'side', 'default');
    }
1162200
public static function createLayouts()
    {
        $dbLayouts = self::lists('code', 'code');

        $definitions = MailManager::instance()->listRegisteredLayouts();
        foreach ($definitions as $code => $path) {
            if (array_key_exists($code, $dbLayouts)) {
                continue;
            }

            $layout = new static;
            $layout->code = $code;
            $layout->is_locked = true;
            $layout->fillFromView($path);
            $layout->save();
        }
    }
122899
public function init()
    {
        // Works only on backend site
        if (!OL_ZEUS_ISADMIN) {
            return;
        }

        // Check filepath
        if (empty($this->filepath)) {
            return;
        }

        // Get configurations
        $configs = include $this->filepath;

        // Check
        if (empty($configs)) {
            return;
        }

        // Iterate on configs
        foreach ($configs as $key => $props) {
            $props = !is_array($props) ? [$props] : $props;

            // Add admin theme
            $this->addAdminTheme($key, $props);
        }
    }
391181
public function setupAdminBar()
    {
        // Link to editor from page
        add_action('admin_bar_menu', function () {
            $options = get_option('modularity-options');

            if (is_admin() || !current_user_can('edit_posts')) {
                return;
            }

            global $wp_admin_bar;
            global $post;

            $editorLink = admin_url('options.php?page=modularity-editor&id=' . get_the_id());

            $archiveSlug = \Modularity\Helper\Wp::getArchiveSlug();
            if ($archiveSlug && $postId = \Modularity\Editor::pageForPostTypeTranscribe($archiveSlug)) {
                $editorLink = admin_url('options.php?page=modularity-editor&id=' . $postId);
            }

            if (isset($options['enabled-post-types']) && is_array($options['enabled-post-types']) && !in_array(get_post_type(), $options['enabled-post-types'])) {
                $editorLink = null;
            }

            $editorLink = apply_filters('Modularity/adminbar/editor_link', $editorLink, $post, $archiveSlug, $this->currentUrl());

            if (empty($editorLink)) {
                return;
            }

            $wp_admin_bar->add_node(array(
                'id' => 'modularity_editor',
                'title' => __('Edit', 'modularity') . ' ' . strtolower(__('Modules', 'modularity')),
                'href' => $editorLink,
                'meta' => array(
                    'class' => 'modularity-editor-icon'
                )
            ));
        }, 1050);
    }
28407
public function views()
    {
        $views = $this->get_views();
        $views = apply_filters('views_' . $this->screen->id, $views);

        if (empty($views)) {
            return;
        }

        echo "<ul class='subsubsub'>\n";

        foreach ( $views as $class => $view ) {
            $views[ $class ] = "\t<li class='$class'>$view";
        }

        echo implode( " |</li>\n", $views ) . "</li>\n";
        echo "</ul>";
    }
745507
public function sidebarActions()
    {
        if ($this->sidebarActions === null) {
            $this->setSidebarActions([]);
        }

        if ($this->parsedSidebarActions === false) {
            $this->parsedSidebarActions = true;
            $this->sidebarActions = $this->createSidebarActions($this->sidebarActions);
        }

        return $this->sidebarActions;
    }
66840
public function formProperties()
    {
        $sidebars = $this->sidebars;
        if (!is_array($sidebars)) {
            yield null;
        } else {
            foreach ($this->formProperties as $formProperty) {
                if ($formProperty->active() === false) {
                    continue;
                }

                $GLOBALS['widget_template'] = $formProperty->inputType();

                yield $formProperty->propertyIdent() => $formProperty;

                $GLOBALS['widget_template'] = '';
            }
        }
    }
1221935
public function setSidebar()
    {
        $this->sidebarItems = config('admin.sidebar');
        $responses = \Event::fire(new AfterSidebarSet($this->sidebarItems));
        if (is_array($responses)) {
            foreach ($responses as $response) {
                if (is_array($response)) {
                    $this->sidebarItems = array_merge($this->sidebarItems, $response);
                }
            }
        }
    }
929007
function (cb) {

            var opts = {
                meta: {}
            };
            opts = this.populateClasses(opts);
            opts = this.populateModules(opts);

            ['classes', 'modules'].forEach(function (id) {
                opts.meta[id].forEach(function (v, k) {
                    opts.meta[id][k] = v.name;
                    if (v.submodules) {
                        v.submodules.forEach(function (s) {
                            opts.meta[id].push(s.displayName);
                        });
                    }
                });
                opts.meta[id].sort();
            });

            var apijs = 'YUI.add("yuidoc-meta", function(Y) {\n' +
                '   Y.YUIDoc = { meta: ' + JSON.stringify(opts.meta, null, 4) + ' };\n' +
                '});';

            cb(apijs);
        }
1260541
protected function publishSidebarItems()
    {
        $this->publishes([
            $this->getSidebarFolder() => config_path($this->vendor.DS.'sidebar'.DS.$this->package)
        ], 'sidebar');
    }
959285
public function sidebars()
    {
        $sidebars = $this->app->make('sidebars.collection')->all();

        $headers = ['Slug', 'Title', 'Description', 'Has widgets'];

        $dataset = array_map(function ($sidebar) {
            return [
                $sidebar->getSlug(),
                $sidebar->getSingular(),
                $sidebar->getArgument('description'),
                $sidebar->hasWidgets() ? 'true' : 'false',
            ];
        }, $sidebars);

        $this->table($headers, $dataset);
    }