Skip to content

Commit

Permalink
added support to edit gallery images in bulk
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-o committed Feb 26, 2024
1 parent 464d42e commit b44d3c0
Show file tree
Hide file tree
Showing 5 changed files with 732 additions and 250 deletions.
32 changes: 18 additions & 14 deletions classes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1651,19 +1651,21 @@ public function register_controls() {
'label' => esc_html__( 'Description', 'visual-portfolio' ),
),
'categories' => array(
'type' => 'select',
'label' => esc_html__( 'Categories', 'visual-portfolio' ),
'multiple' => true,
'creatable' => true,
'type' => 'select',
'label' => esc_html__( 'Categories', 'visual-portfolio' ),
'multiple' => true,
'creatable' => true,
'allow_bulk_edit' => true,
),
'format' => array(
'type' => 'select',
'label' => esc_html__( 'Format', 'visual-portfolio' ),
'default' => 'standard',
'options' => array(
'type' => 'select',
'label' => esc_html__( 'Format', 'visual-portfolio' ),
'default' => 'standard',
'options' => array(
'standard' => esc_html__( 'Standard', 'visual-portfolio' ),
'video' => esc_html__( 'Video', 'visual-portfolio' ),
),
'allow_bulk_edit' => true,
),
'video_url' => array(
'type' => 'text',
Expand All @@ -1684,14 +1686,16 @@ public function register_controls() {
'placeholder' => esc_html__( 'https://...', 'visual-portfolio' ),
),
'author' => array(
'type' => 'text',
'label' => esc_html__( 'Author Name', 'visual-portfolio' ),
'default' => '',
'type' => 'text',
'label' => esc_html__( 'Author Name', 'visual-portfolio' ),
'default' => '',
'allow_bulk_edit' => true,
),
'author_url' => array(
'type' => 'text',
'label' => esc_html__( 'Author URL', 'visual-portfolio' ),
'default' => '',
'type' => 'text',
'label' => esc_html__( 'Author URL', 'visual-portfolio' ),
'default' => '',
'allow_bulk_edit' => true,
),
'image_settings_pro_note' => array(
'type' => 'pro_note',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { addFilter } from '@wordpress/hooks';

import getAllCategories from '../utils/get-all-categories';

/**
* Add list of all categories to gallery images.
*/
Expand All @@ -8,20 +10,7 @@ addFilter(
'vpf/editor/controls-render-data/images-categories-suggestions',
(data) => {
if (data.name === 'images') {
const categories = [];

// find all used categories.
if (data.attributes.images && data.attributes.images.length) {
data.attributes.images.forEach((image) => {
if (image.categories && image.categories.length) {
image.categories.forEach((cat) => {
if (categories.indexOf(cat) === -1) {
categories.push(cat);
}
});
}
});
}
const categories = getAllCategories(data.attributes.images);

if (
categories.length &&
Expand Down
Loading

0 comments on commit b44d3c0

Please sign in to comment.