Add gravity flow demo

This commit is contained in:
Almira Krdzic
2018-06-28 10:02:07 +02:00
parent 1b5076bf2f
commit 12a5066018
1106 changed files with 317603 additions and 4720 deletions

View File

@@ -0,0 +1,135 @@
<?php
/**
* Add caps actions.
*
* @since 1.7
* @version 1.7.4
*
* @var \VAA_View_Admin_As_Caps $this
* @var \WP_Admin_Bar $admin_bar The toolbar object.
* @var string $root The current root item.
* @var string $main_root The main VAA root item.
*/
if ( ! defined( 'VIEW_ADMIN_AS_DIR' ) ) {
die();
}
if ( isset( $admin_bar ) && $admin_bar instanceof WP_Admin_Bar && isset( $root ) ) {
if ( ! isset( $main_root ) ) {
$main_root = $root;
}
if ( ! isset( $parent ) ) {
$parent = $root;
}
// Text filter
$admin_bar->add_node(
array(
'id' => $root . '-filtercaps',
'parent' => $parent,
'title' => VAA_View_Admin_As_Form::do_input(
array(
'name' => $root . '-filtercaps',
'placeholder' => esc_attr__( 'Filter', VIEW_ADMIN_AS_DOMAIN ),
)
),
'href' => false,
'meta' => array(
'class' => 'ab-vaa-input ab-vaa-filter filter-caps vaa-column-one-half vaa-column-first',
),
)
);
// Select filter
$role_select_options = array(
array(
'value' => 'default',
'label' => __( 'Default', VIEW_ADMIN_AS_DOMAIN ),
),
);
// View filter
if ( $this->store->get_view() ) {
$data_caps = wp_json_encode( $this->store->get_selectedCaps() );
$role_select_options[] = array(
'compare' => 'vaa',
'label' => '= ' . __( 'Current view', VIEW_ADMIN_AS_DOMAIN ),
'attr' => array(
'data-caps' => $data_caps,
),
);
$role_select_options[] = array(
'compare' => 'reversed-vaa',
'label' => '≠ ' . __( 'Current view', VIEW_ADMIN_AS_DOMAIN ),
'attr' => array(
'data-caps' => $data_caps,
'data-reverse' => '1',
),
);
}
// Role filters
foreach ( $this->store->get_roles() as $role_key => $role ) {
$data_caps = wp_json_encode( $role->capabilities );
$role_select_options[] = array(
'compare' => esc_attr( $role_key ),
'label' => '= ' . $this->store->get_rolenames( $role_key ),
'attr' => array(
'data-caps' => $data_caps,
),
);
$role_select_options[] = array(
'compare' => 'reversed-' . esc_attr( $role_key ),
'label' => '≠ ' . $this->store->get_rolenames( $role_key ),
'attr' => array(
'data-caps' => $data_caps,
'data-reverse' => '1',
),
);
}
$admin_bar->add_node(
array(
'id' => $root . '-selectrolecaps',
'parent' => $parent,
'title' => VAA_View_Admin_As_Form::do_select(
array(
'name' => $root . '-selectrolecaps',
'values' => $role_select_options,
)
),
'href' => false,
'meta' => array(
'class' => 'ab-vaa-select select-role-caps vaa-column-one-half vaa-column-last',
'html' => '',
),
)
);
// Select/deselect
$admin_bar->add_node(
array(
'id' => $root . '-bulkselectcaps',
'parent' => $parent,
'title' => VAA_View_Admin_As_Form::do_button(
array(
'name' => 'select-all-caps',
'label' => __( 'Select', VIEW_ADMIN_AS_DOMAIN ),
'classes' => 'button-secondary',
)
) . ' ' . VAA_View_Admin_As_Form::do_button(
array(
'name' => 'deselect-all-caps',
'label' => __( 'Deselect', VIEW_ADMIN_AS_DOMAIN ),
'classes' => 'button-secondary',
)
),
'href' => false,
'meta' => array(
'class' => 'ab-vaa-input vaa-button-container vaa-clear-float',
),
)
);
} else {
_doing_it_wrong( __FILE__, esc_html__( 'No toolbar resources found.', VIEW_ADMIN_AS_DOMAIN ), '1.7' );
} // End if().

View File

@@ -0,0 +1,68 @@
<?php
/**
* Add caps items.
*
* @since 1.7
* @version 1.8
*
* @var \VAA_View_Admin_As_Caps $this
* @var \WP_Admin_Bar $admin_bar The toolbar object.
* @var string $root The current root item.
* @var string $main_root The main VAA root item.
*/
if ( ! defined( 'VIEW_ADMIN_AS_DIR' ) ) {
die();
}
if ( isset( $admin_bar ) && $admin_bar instanceof WP_Admin_Bar && isset( $root ) ) {
if ( ! isset( $main_root ) ) {
$main_root = $root;
}
if ( ! isset( $parent ) ) {
$parent = $root;
}
$caps_items = '';
foreach ( $this->store->get_caps() as $cap => $granted ) {
$class = 'vaa-cap-item';
$checked = (bool) $granted;
// check if we've selected a capability view and we've changed some capabilities.
$selected_caps = $this->store->get_view( $this->type );
if ( isset( $selected_caps[ $cap ] ) ) {
$checked = (bool) $selected_caps[ $cap ];
}
// Check for this capability in any view set.
if ( $this->vaa->view()->current_view_can( $cap ) ) {
$class .= ' current';
}
// The list of capabilities.
$caps_items .=
'<div class="ab-item ' . $class . '">'
. VAA_View_Admin_As_Form::do_checkbox(
array(
'name' => 'vaa_cap_' . esc_attr( $cap ),
'value' => $checked,
'compare' => true,
'checkbox_value' => esc_attr( $cap ),
'label' => $cap,
)
)
. '</div>';
}
$admin_bar->add_node(
array(
'id' => $root . '-select-options',
'parent' => $parent,
'title' => $caps_items,
'href' => false,
'meta' => array(
'class' => 'ab-vaa-multipleselect vaa-auto-max-height',
),
)
);
} else {
_doing_it_wrong( __FILE__, esc_html__( 'No toolbar resources found.', VIEW_ADMIN_AS_DOMAIN ), '1.7' );
} // End if().

View File

@@ -0,0 +1,61 @@
<?php
/**
* Add role items.
*
* @since 1.8
* @version 1.8
*
* @var \VAA_View_Admin_As_Languages $this
* @var \WP_Admin_Bar $admin_bar The toolbar object.
* @var string $root The current root item.
* @var string $main_root The main VAA root item.
*/
if ( ! defined( 'VIEW_ADMIN_AS_DIR' ) ) {
die();
}
if ( isset( $admin_bar ) && $admin_bar instanceof WP_Admin_Bar && isset( $root ) ) {
if ( ! isset( $main_root ) ) {
$main_root = $root;
}
$parent = $root . '-languages';
foreach ( $this->store->get_languages() as $locale => $language ) {
$href = VAA_API::get_vaa_action_link( array( $this->type => $locale ), $this->store->get_nonce( true ) );
$class = 'vaa-' . $this->type . '-item';
$title = $this->get_view_title( $locale );
$view_title = ( $locale !== $title ) ? '<code>' . $locale . '</code> | ' . $language : $locale;
$view_title = VAA_View_Admin_As_Form::do_view_title( $view_title, $this, $locale );
// Check if this role is the current view.
if ( VAA_API::is_current_view( $locale, $this->type ) ) {
$class .= ' current';
if ( 1 === count( $this->store->get_view() ) ) {
$href = false;
}
}
$admin_bar->add_node(
array(
'id' => $root . '-' . $this->type . '-' . $locale,
'parent' => $parent,
'title' => $view_title,
'href' => $href,
'meta' => array(
// Translators: %s stands for the translated role name.
'title' => sprintf( __( 'View as %s', VIEW_ADMIN_AS_DOMAIN ), $title ),
'class' => $class,
),
)
);
} // End foreach().
} else {
_doing_it_wrong( __FILE__, esc_html__( 'No toolbar resources found.', VIEW_ADMIN_AS_DOMAIN ), '1.7' );
} // End if().

View File

@@ -0,0 +1,86 @@
<?php
/**
* Add role items.
*
* @since 1.7
* @version 1.8
*
* @var \VAA_View_Admin_As_Roles $this
* @var \WP_Admin_Bar $admin_bar The toolbar object.
* @var string $root The current root item.
* @var string $main_root The main VAA root item.
*/
if ( ! defined( 'VIEW_ADMIN_AS_DIR' ) ) {
die();
}
if ( isset( $admin_bar ) && $admin_bar instanceof WP_Admin_Bar && isset( $root ) ) {
if ( ! isset( $main_root ) ) {
$main_root = $root;
}
if ( ! isset( $parent ) ) {
$parent = $root;
}
foreach ( $this->store->get_roles() as $role_key => $role ) {
$href = VAA_API::get_vaa_action_link( array( $this->type => $role_key ), $this->store->get_nonce( true ) );
$class = 'vaa-' . $this->type . '-item';
$title = $this->get_view_title( $role );
$view_title = VAA_View_Admin_As_Form::do_view_title( $title, $this, $role_key );
/**
* Check if the users need to be grouped under their roles.
* @var \VAA_View_Admin_As_Users $user_view_type
*/
$user_view_type = view_admin_as()->get_view_types( 'user' );
if ( $user_view_type instanceof VAA_View_Admin_As_Users && $user_view_type->group_user_roles() ) {
// Used to align items properly when some roles don't have users.
$class .= ' vaa-menupop';
// Check if the current view is a user with this role.
if ( $this->store->get_view( 'user' ) &&
in_array( $role_key, $this->store->get_selectedUser()->roles, true )
) {
$class .= ' current-parent';
}
// If there are users with this role, add a counter.
$user_count = 0;
foreach ( $this->store->get_users() as $user ) {
if ( in_array( $role_key, $user->roles, true ) ) {
$user_count ++;
}
}
if ( 0 < $user_count ) {
$view_title = $view_title . ' <span class="user-count ab-italic">(' . $user_count . ')</span>';
}
}
// Check if this role is the current view.
if ( VAA_API::is_current_view( $role_key, $this->type ) ) {
$class .= ' current';
if ( 1 === count( $this->store->get_view() ) ) {
$href = false;
}
}
$admin_bar->add_node(
array(
'id' => $root . '-' . $this->type . '-' . $role_key,
'parent' => $parent,
'title' => $view_title,
'href' => $href,
'meta' => array(
// Translators: %s stands for the translated role name.
'title' => sprintf( __( 'View as %s', VIEW_ADMIN_AS_DOMAIN ), $title ),
'class' => $class,
),
)
);
} // End foreach().
} else {
_doing_it_wrong( __FILE__, esc_html__( 'No toolbar resources found.', VIEW_ADMIN_AS_DOMAIN ), '1.7' );
} // End if().

View File

@@ -0,0 +1,250 @@
<?php
/**
* Add user setting items.
*
* @since 1.7.2
* @version 1.8
*
* @var \WP_Admin_Bar $admin_bar The toolbar object.
* @var string $root The current root item.
* @var string $main_root The main VAA root item.
*
* Settings order:
* - admin_menu_location
* - view_mode
* - disable_super_admin
* - hide_front
* - freeze_locale
*/
if ( ! defined( 'VIEW_ADMIN_AS_DIR' ) ) {
die();
}
if ( isset( $this ) &&
isset( $this->store ) &&
isset( $admin_bar ) && $admin_bar instanceof WP_Admin_Bar &&
isset( $root )
) {
/**
* admin_menu_location setting.
*
* @since 1.5
*/
$admin_bar->add_node(
array(
'id' => $root . '-admin-menu-location',
'parent' => $root,
'title' => VAA_View_Admin_As_Form::do_select(
array(
'name' => $root . '-admin-menu-location',
'value' => $this->store->get_userSettings( 'admin_menu_location' ),
'label' => __( 'Location', VIEW_ADMIN_AS_DOMAIN ) . ': &nbsp; ',
'description' => __( 'Change the location of this menu node', VIEW_ADMIN_AS_DOMAIN ),
'help' => true,
'values' => array(
array(
'compare' => 'top-secondary',
'label' => __( 'Default', VIEW_ADMIN_AS_DOMAIN ),
),
array(
'compare' => 'my-account',
'label' => __( 'My account', VIEW_ADMIN_AS_DOMAIN ),
),
),
'auto_js' => array(
'setting' => 'user_setting',
'key' => 'admin_menu_location',
'refresh' => true,
),
'auto_showhide' => true,
)
),
'href' => false,
'meta' => array(
'class' => 'auto-height',
),
)
);
/**
* view_mode setting.
*
* @since 1.5
*/
$admin_bar->add_node(
array(
'id' => $root . '-view-mode',
'parent' => $root,
'title' => VAA_View_Admin_As_Form::do_radio(
array(
'name' => $root . '-view-mode',
'value' => $this->store->get_userSettings( 'view_mode' ),
'values' => array(
array(
'compare' => 'browse',
'label' => __( 'Browse mode', VIEW_ADMIN_AS_DOMAIN ),
'description' => __( 'Store view and use WordPress with this view', VIEW_ADMIN_AS_DOMAIN ),
'help' => true,
),
array(
'compare' => 'single',
'label' => __( 'Single switch mode', VIEW_ADMIN_AS_DOMAIN ),
'description' => __( 'Choose view on every pageload. This setting doesn\'t store views', VIEW_ADMIN_AS_DOMAIN ),
'help' => true,
),
),
'auto_js' => array(
'setting' => 'user_setting',
'key' => 'view_mode',
'refresh' => false,
),
'auto_showhide' => true,
)
),
'href' => false,
'meta' => array(
'class' => 'auto-height',
),
)
);
/**
* Disable super admin checks while switched.
*
* @since 1.7.3
* @since 1.8 Don't use VAA_API since users that are super admins but don't have full access could
* still want to use this setting.
* Also check if the installation is a network.
*/
if ( is_multisite() && is_super_admin( view_admin_as()->store()->get_curUser()->ID ) ) {
$admin_bar->add_node(
array(
'id' => $root . '-disable-super-admin',
'parent' => $root,
'title' => VAA_View_Admin_As_Form::do_checkbox(
array(
'name' => $root . '-disable-super-admin',
'value' => $this->store->get_userSettings( 'disable_super_admin' ),
'compare' => true,
'label' => __( 'Disable super admin', VIEW_ADMIN_AS_DOMAIN ),
'description' => __( 'Disable super admin status while switched to another view', VIEW_ADMIN_AS_DOMAIN ),
'help' => true,
'auto_js' => array(
'setting' => 'user_setting',
'key' => 'disable_super_admin',
'refresh' => ( $this->store->get_view() ) ? true : false,
),
'auto_showhide' => true,
)
),
'href' => false,
'meta' => array(
'class' => 'auto-height',
),
)
);
}
/**
* hide_front setting.
*
* @since 1.6
*/
$admin_bar->add_node(
array(
'id' => $root . '-hide-front',
'parent' => $root,
'title' => VAA_View_Admin_As_Form::do_checkbox(
array(
'name' => $root . '-hide-front',
'value' => $this->store->get_userSettings( 'hide_front' ),
'compare' => true,
'label' => __( 'Hide on frontend', VIEW_ADMIN_AS_DOMAIN ),
'description' => __( 'Hide on frontend when no view is selected and the admin bar is not shown', VIEW_ADMIN_AS_DOMAIN ),
'help' => true,
'auto_js' => array(
'setting' => 'user_setting',
'key' => 'hide_front',
'refresh' => false,
),
'auto_showhide' => true,
)
),
'href' => false,
'meta' => array(
'class' => 'auto-height',
),
)
);
/**
* hide_customizer setting.
*
* @since 1.7.6
*/
$admin_bar->add_node(
array(
'id' => $root . '-hide-customizer',
'parent' => $root,
'title' => VAA_View_Admin_As_Form::do_checkbox(
array(
'name' => $root . '-hide-customizer',
'value' => $this->store->get_userSettings( 'hide_customizer' ),
'compare' => true,
'label' => __( 'Hide on customizer', VIEW_ADMIN_AS_DOMAIN ),
'description' => __( 'Hide on customizer when no view is selected', VIEW_ADMIN_AS_DOMAIN ),
'help' => true,
'auto_js' => array(
'setting' => 'user_setting',
'key' => 'hide_customizer',
'refresh' => VAA_API::is_customizer_admin(),
),
'auto_showhide' => true,
)
),
'href' => false,
'meta' => array(
'class' => 'auto-height',
),
)
);
/**
* freeze_locale setting.
* Force own locale on view, WP 4.7+ only.
*
* @see https://github.com/JoryHogeveen/view-admin-as/issues/21
* @since 1.6.1
*/
if ( VAA_API::validate_wp_version( '4.7' ) ) {
$admin_bar->add_node(
array(
'id' => $root . '-freeze-locale',
'parent' => $root,
'title' => VAA_View_Admin_As_Form::do_checkbox(
array(
'name' => $root . '-freeze-locale',
'value' => $this->store->get_userSettings( 'freeze_locale' ),
'compare' => true,
'label' => __( 'Freeze locale', VIEW_ADMIN_AS_DOMAIN ),
'description' => __( 'Force your own locale setting to the current view', VIEW_ADMIN_AS_DOMAIN ),
'help' => true,
'auto_js' => array(
'setting' => 'user_setting',
'key' => 'freeze_locale',
'refresh' => ( $this->store->get_view( 'user' ) ) ? true : false,
),
'auto_showhide' => true,
)
),
'href' => false,
'meta' => array(
'class' => 'auto-height',
),
)
);
}
} // End if().

View File

@@ -0,0 +1,54 @@
<?php
/**
* Add user actions.
*
* @since 1.8
* @version 1.8
*
* @var \VAA_View_Admin_As_Users $this
* @var \WP_Admin_Bar $admin_bar The toolbar object.
* @var string $root The current root item.
* @var string $main_root The main VAA root item.
*/
if ( ! defined( 'VIEW_ADMIN_AS_DIR' ) ) {
die();
}
if ( isset( $admin_bar ) && $admin_bar instanceof WP_Admin_Bar && isset( $root ) ) {
if ( ! isset( $main_root ) ) {
$main_root = $root;
}
if ( ! isset( $parent ) ) {
$parent = $root;
}
if ( ! isset( $title_submenu ) ) {
$title_submenu = false;
}
if ( $title_submenu || $this->ajax_search || $this->group_user_roles() ) {
$title = '';
if ( $this->group_user_roles() ) {
$title = VAA_View_Admin_As_Form::do_description( __( 'Users are grouped under their roles', VIEW_ADMIN_AS_DOMAIN ) );
}
$admin_bar->add_node( array(
'id' => $root . '-searchusers',
'parent' => $root,
'title' => $title . VAA_View_Admin_As_Form::do_input( array(
'name' => $root . '-searchusers',
'placeholder' => __( 'Search', VIEW_ADMIN_AS_DOMAIN ),
) ),
'href' => false,
'meta' => array(
'class' => 'ab-vaa-search search-users' . ( ( $this->ajax_search ) ? ' search-ajax' : '' ),
'html' => '<ul id="vaa-searchuser-results" class="ab-sub-secondary vaa-auto-max-height ab-submenu ab-vaa-results"></ul>',
),
) );
}
} else {
_doing_it_wrong( __FILE__, esc_html__( 'No toolbar resources found.', VIEW_ADMIN_AS_DOMAIN ), '1.7' );
} // End if().

View File

@@ -0,0 +1,106 @@
<?php
/**
* Add user items.
*
* @since 1.7
* @version 1.8
*
* @var \VAA_View_Admin_As_Users $this
* @var \WP_Admin_Bar $admin_bar The toolbar object.
* @var string $root The current root item.
* @var string $main_root The main VAA root item.
*/
if ( ! defined( 'VIEW_ADMIN_AS_DIR' ) ) {
die();
}
if ( isset( $admin_bar ) && $admin_bar instanceof WP_Admin_Bar && isset( $root ) ) {
if ( ! isset( $main_root ) ) {
$main_root = $root;
}
if ( ! isset( $parent ) ) {
$parent = $root;
}
if ( ! isset( $title_submenu ) ) {
$title_submenu = false;
}
foreach ( $this->store->get_users() as $user ) {
// Reset parent for each loop due to groupUserRoles.
$item_parent = $parent;
$href = VAA_API::get_vaa_action_link( array( $this->type => $user->ID ), $this->store->get_nonce( true ) );
$class = 'vaa-' . $this->type . '-item';
$title = $this->get_view_title( $user );
$view_title = VAA_View_Admin_As_Form::do_view_title( $title, $this, $user->ID );
/**
* Add the user roles to the user title?
* Only available if users are not grouped under their roles.
*
* @since 1.8
* @param bool $true True by default.
* @param \WP_User $user The user object.
* @return bool
*/
if ( ! $this->group_user_roles() && apply_filters( 'vaa_admin_bar_view_title_' . $this->type . '_show_roles', true, $user ) ) {
// Users displayed as normal.
$user_roles = array();
// Add the roles of this user in the name.
foreach ( $user->roles as $role ) {
$user_roles[] = $this->store->get_rolenames( $role );
}
$view_title = $view_title . ' &nbsp; <span class="user-role ab-italic">(' . implode( ', ', $user_roles ) . ')</span>';
}
// Check if this user is the current view.
if ( VAA_API::is_current_view( $user->ID, $this->type ) ) {
$class .= ' current';
if ( 1 === count( $this->store->get_view() ) ) {
$href = false;
}
}
$user_node = array(
'id' => $root . '-' . $this->type . '-' . $user->ID,
'parent' => $item_parent,
'title' => $view_title,
'href' => $href,
'meta' => array(
// Translators: %s stands for the user display name.
'title' => sprintf( __( 'View as %s', VIEW_ADMIN_AS_DOMAIN ), $title ),
'class' => $class,
),
);
if ( $this->group_user_roles() ) {
// Users grouped under roles.
foreach ( $user->roles as $role ) {
$user_role_node = $user_node;
$item_parent = $main_root . '-roles-role-' . $role;
$group = $item_parent . '-users';
if ( ! $admin_bar->get_node( $group ) ) {
$admin_bar->add_group( array(
'id' => $group,
'parent' => $item_parent,
'meta' => array(
'class' => 'vaa-auto-max-height',
),
) );
}
$user_role_node['id'] .= '-' . $role;
$user_role_node['parent'] = $group;
$admin_bar->add_node( $user_role_node );
}
} else {
$admin_bar->add_node( $user_node );
}
} // End foreach().
} else {
_doing_it_wrong( __FILE__, esc_html__( 'No toolbar resources found.', VIEW_ADMIN_AS_DOMAIN ), '1.7' );
} // End if().

View File

@@ -0,0 +1,2 @@
<?php
//Nothing to see here