updated plugin GP Premium version 2.0.3

This commit is contained in:
2021-07-25 23:25:02 +00:00
committed by Gitium
parent d7964b08bd
commit 3ef36355e9
154 changed files with 6153 additions and 9541 deletions

View File

@ -19,6 +19,7 @@ require $elements_dir . 'class-hooks.php';
require $elements_dir . 'class-hero.php';
require $elements_dir . 'class-layout.php';
require $elements_dir . 'class-block.php';
require $elements_dir . 'class-block-elements.php';
require $elements_dir . 'class-post-type.php';
add_action( 'wp', 'generate_premium_do_elements' );
@ -188,3 +189,84 @@ function generate_add_block_element_content_filters( $content ) {
return $content;
}
add_action( 'admin_bar_menu', 'generate_add_elements_admin_bar', 100 );
/**
* Add the Elementd admin bar item.
*
* @since 2.0.0
*/
function generate_add_elements_admin_bar() {
$current_user_can = 'manage_options';
if ( apply_filters( 'generate_elements_metabox_ajax_allow_editors', false ) ) {
$current_user_can = 'edit_posts';
}
if ( ! current_user_can( $current_user_can ) ) {
return;
}
global $wp_admin_bar;
global $generate_elements;
$title = __( 'Elements', 'gp-premium' );
$count = ! empty( $generate_elements ) ? count( $generate_elements ) : 0;
// Prevent "Entire Site" Elements from being counted on non-edit pages in the admin.
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
if ( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) {
$count = 0;
}
if ( 'edit' !== $screen->parent_base ) {
$count = 0;
}
}
if ( $count > 0 ) {
$title = sprintf(
/* translators: Active Element count. */
__( 'Elements (%s)', 'gp-premium' ),
$count
);
}
$wp_admin_bar->add_menu(
array(
'id' => 'gp_elements-menu',
'title' => $title,
'href' => esc_url( admin_url( 'edit.php?post_type=gp_elements' ) ),
)
);
if ( ! empty( $generate_elements ) ) {
// Prevent "Entire Site" Elements from being counted on non-edit pages in the admin.
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
if ( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) {
return;
}
if ( 'edit' !== $screen->parent_base ) {
return;
}
}
foreach ( (array) $generate_elements as $key => $data ) {
$label = GeneratePress_Elements_Helper::get_element_type_label( $data['type'] );
$wp_admin_bar->add_menu(
array(
'id' => 'element-' . absint( $data['id'] ),
'parent' => 'gp_elements-menu',
'title' => get_the_title( $data['id'] ) . ' (' . $label . ')',
'href' => get_edit_post_link( $data['id'] ),
)
);
}
}
}