本文整理汇总了PHP中plugins::populate方法的典型用法代码示例。如果您正苦于以下问题:PHP plugins::populate方法的具体用法?PHP plugins::populate怎么用?PHP plugins::populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugins
的用法示例。
在下文中一共展示了plugins::populate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_plugins_table
/**
@brief Return the plugins table.
@since 2014-05-08 15:48:39
**/
public function get_plugins_table()
{
$form = $this->form2();
$r = '';
$table = $this->table();
$plugins = new plugins($this);
// Fill the plugins with all of the available classes
$action = new actions\get_plugin_classes();
// The prefix is the basename of the plugin pack class, with an underscore.
// Not \threewp_broadcast\premium_pack\ThreeWP_Broadcast_Premium_Pack but ThreeWP_Broadcast_Premium_Pack_
$action->__prefix = preg_replace('/.*\\\\/', '', get_called_class()) . '_';
$action->add(static::get_plugin_classes());
$action->execute();
$plugins->populate($action->classes);
// Plugins class for the coloring.
$table = $this->table()->css_class('plugin_pack plugins with_groups');
$row = $table->head()->row();
$table->bulk_actions()->form($form)->add($this->_('Activate plugin'), 'activate_plugin')->add($this->_('Deactivate plugin'), 'deactivate_plugin')->add($this->_('Uninstall plugin'), 'uninstall_plugin')->cb($row);
$row->th()->text(__('Plugin'));
$row->th()->text(__('Description'));
if ($form->is_posting()) {
if ($table->bulk_actions()->pressed()) {
$ids = $table->bulk_actions()->get_rows();
$action = $table->bulk_actions()->get_action();
$message = $this->_('No action selected.');
foreach ($plugins->from_ids($ids) as $plugin) {
$classname = $plugin->get_classname();
$this->plugins()->populate($classname);
$new_plugin = $this->plugins()->get($classname)->plugin();
switch ($action) {
case 'activate_plugin':
$new_plugin->activate_internal();
$message = $this->_('The selected plugin(s) have been activated.');
break;
case 'deactivate_plugin':
$new_plugin->deactivate_internal();
$this->plugins()->forget($classname);
$message = $this->_('The selected plugin(s) have been deactivated.');
break;
case 'uninstall_plugin':
$new_plugin->deactivate_internal();
$new_plugin->uninstall_internal();
$this->plugins()->forget($classname);
$message = $this->_('The selected plugin(s) have been uninstalled.');
break;
default:
$this->plugins()->forget($classname);
}
$this->plugins()->save();
}
$this->message($message);
}
}
$old_group = '';
foreach ($plugins->by_groups() as $group => $plugins) {
foreach ($plugins as $plugin) {
$group = $plugin->get_comment('plugin_group');
if ($old_group != $group) {
$old_group = $group;
// The group slug helps the javascript to group the rows together.
$group_slug = sanitize_title($group);
$row = $table->body()->row()->css_class('inactive group')->data('group', $group_slug);
$row->th()->css_class('plugin_group name')->colspan(3)->text($group);
}
$row = $table->body()->row()->css_class('plugin')->data('group', $group_slug);
$cb = $table->bulk_actions()->cb($row, $plugin->get_id());
$td = $row->td();
// Assemble a label.
$label = new \plainview\sdk_broadcast\html\div();
$label->tag = 'label';
$label->set_attribute('for', $cb->get_id());
$label->content = $plugin->get_name();
$td->text($label);
$td->css_class('plugin-title');
if ($this->plugins()->has($plugin->get_classname())) {
$row->css_class('active');
} else {
$row->css_class('inactive');
}
$text = $plugin->get_brief_description();
$row->td()->text($text);
}
}
$r .= $form->open_tag();
$r .= $table;
$r .= $form->close_tag();
return $r;
}