proActive = Utilities::isProActive(); $this->initHooks(); } /** * Initialize WordPress hooks */ private function initHooks() { add_action('add_meta_boxes', array($this, 'addAutoInsertMetaBoxes')); } /** * Add custom metaboxes for auto insert blocks */ public function addAutoInsertMetaBoxes() { if (!Utilities::settingIsEnabled('auto_insert_blocks')) { return; } add_meta_box( 'advgb_block_selection', __('Block Selection', 'advanced-gutenberg'), array($this, 'blockSelectionMetaBox'), 'advgb_insert_block', 'normal', 'high' ); add_meta_box( 'advgb_position_settings', __('Position Settings', 'advanced-gutenberg'), array($this, 'positionSettingsMetaBox'), 'advgb_insert_block', 'normal', 'high' ); add_meta_box( 'advgb_targeting_options', __('Targeting Options', 'advanced-gutenberg'), array($this, 'targetingOptionsMetaBox'), 'advgb_insert_block', 'normal', 'high' ); add_meta_box( 'advgb_rule_settings', __('Rule Settings', 'advanced-gutenberg'), array($this, 'ruleSettingsMetaBox'), 'advgb_insert_block', 'side', 'default' ); } /** * Block selection metabox */ public function blockSelectionMetaBox($post) { $block_id = get_post_meta($post->ID, '_advgb_block_id', true); $reusable_blocks = $this->getReusableBlocks(); ?>
ID, '_advgb_position', true); $position_value = get_post_meta($post->ID, '_advgb_position_value', true); $excluded_blocks = get_post_meta($post->ID, '_advgb_excluded_blocks', true); $blocks = get_post_meta($post->ID, '_advgb_blocks', true); if (empty($excluded_blocks)) { $excluded_blocks = []; } if (empty($position_value)) { $position_value = 1; } $position_options_grouped = [ __('General', 'advanced-gutenberg') => [ 'beginning' => __('Beginning of post', 'advanced-gutenberg'), 'end' => __('End of post', 'advanced-gutenberg'), ], __('Paragraph', 'advanced-gutenberg') => [ 'after_paragraph' => __('After Nth paragraph', 'advanced-gutenberg'), 'before_paragraph' => __('Before Nth paragraph', 'advanced-gutenberg'), ], __('Heading', 'advanced-gutenberg') => [ 'after_heading' => __('After Nth heading', 'advanced-gutenberg'), 'before_heading' => __('Before Nth heading', 'advanced-gutenberg'), ], __('Any Block', 'advanced-gutenberg') => [ 'after_block' => __('After Nth block', 'advanced-gutenberg'), 'before_block' => __('Before Nth block', 'advanced-gutenberg'), ], __('Specific Block', 'advanced-gutenberg') => [ 'after_specific_block' => __('After specific Nth block', 'advanced-gutenberg'), 'before_specific_block' => __('Before specific Nth block', 'advanced-gutenberg'), ], ]; $needs_position_value = ['after_heading', 'before_heading', 'after_paragraph', 'before_paragraph', 'after_block', 'before_block', 'after_specific_block', 'before_specific_block']; $needs_specific_block = ['after_specific_block', 'before_specific_block']; $needs_excluded_blocks = ['after_block', 'before_block']; $pro_class = ! $this->proActive ? 'advgb-blur' : ''; ?>
proActive) : ?>

proActive) : ?>
__('Paragraph', 'advanced-gutenberg'), 'core/heading' => __('Heading', 'advanced-gutenberg'), 'core/image' => __('Image', 'advanced-gutenberg'), 'core/list' => __('List', 'advanced-gutenberg'), 'core/quote' => __('Quote', 'advanced-gutenberg'), 'core/separator' => __('Separator', 'advanced-gutenberg'), 'core/spacer' => __('Spacer', 'advanced-gutenberg'), ); ?>
$block_label): ?>

$block_label) { if (empty($block_name) || empty($block_label)) { continue; } ?>
ID, '_advgb_post_types', true); $taxonomies = get_post_meta($post->ID, '_advgb_taxonomies', true); $authors = get_post_meta($post->ID, '_advgb_authors', true); $post_ids = get_post_meta($post->ID, '_advgb_post_ids', true); $exclude_post_ids = get_post_meta($post->ID, '_advgb_exclude_post_ids', true); $post_months = get_post_meta($post->ID, '_advgb_post_months', true); $post_years = get_post_meta($post->ID, '_advgb_post_years', true); if (empty($post_types)) { $post_types = ['post']; } if (empty($taxonomies)) { $taxonomies = []; } if (empty($post_ids)) { $post_ids = []; } if (empty($exclude_post_ids)) { $exclude_post_ids = []; } if (empty($authors)) { $authors = []; } if (empty($post_months)) { $post_months = []; } if (empty($post_years)) { $post_years = []; } $pro_class = ! $this->proActive ? 'advgb-blur' : ''; ?>
*
() true), 'objects'); foreach ($available_post_types as $post_type): if (in_array($post_type->name, ['attachment'])) { continue; } $additional_class = ! $this->proActive && $post_type->name !== 'post' ? $pro_class : ''; ?> proActive && $post_type->name !== 'post') : ?>

renderAllTaxonomies($post_types, $taxonomies, $available_post_types); ?>

proActive) : ?>

__('January', 'advanced-gutenberg'), 2 => __('February', 'advanced-gutenberg'), 3 => __('March', 'advanced-gutenberg'), 4 => __('April', 'advanced-gutenberg'), 5 => __('May', 'advanced-gutenberg'), 6 => __('June', 'advanced-gutenberg'), 7 => __('July', 'advanced-gutenberg'), 8 => __('August', 'advanced-gutenberg'), 9 => __('September', 'advanced-gutenberg'), 10 => __('October', 'advanced-gutenberg'), 11 => __('November', 'advanced-gutenberg'), 12 => __('December', 'advanced-gutenberg') ]; foreach ($months as $month_num => $month_name): ?>

proActive) : ?>

proActive) : ?>
ID, '_advgb_priority', true); if (empty($priority)) { $priority = 10; } ?>

'wp_block', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' )); $reusable_blocks = []; foreach ($blocks as $block) { $reusable_blocks[] = array( 'id' => $block->ID, 'title' => $block->post_title, 'content' => $block->post_content ); } return $reusable_blocks; } /** * Render all taxonomies with post type classes */ public function renderAllTaxonomies( $selected_post_types, $selected_taxonomies, $all_post_types ) { $pro_class = ! $this->proActive ? 'advgb-blur' : ''; $rendered_taxonomies = []; foreach ($all_post_types as $post_type) { $taxonomies = get_object_taxonomies($post_type->name, 'objects'); foreach ($taxonomies as $taxonomy) { if (in_array($taxonomy->name, ['post_format', 'pp_notify_user', 'pp_notify_role', 'pp_notify_email', 'pp_editorial_meta', 'pp_notify_user', 'pp_notify_role', 'pp_notify_email'])) { continue; } if (isset($rendered_taxonomies[$taxonomy->name])) { // Add post type class to existing taxonomy $rendered_taxonomies[$taxonomy->name]['post_types'][] = $post_type->name; continue; } $rendered_taxonomies[$taxonomy->name] = [ 'label' => $taxonomy->label, 'terms' => [], 'post_types' => [$post_type->name] ]; } } foreach ($rendered_taxonomies as $tax_name => $tax_data) { $post_type_classes = implode(' ', array_map(function ($pt) { return 'post-type-' . $pt; }, $tax_data['post_types'])); $is_visible = !empty($selected_post_types) ? array_intersect($tax_data['post_types'], $selected_post_types) : false; $display_style = $is_visible ? '' : 'display: none;'; $additional_class = ! $this->proActive && ! in_array($tax_name, ['category', 'post_tag']) ? $pro_class : ''; ?>

proActive && ! in_array($tax_name, ['category', 'post_tag'])) : ?>