| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/INFRABIKEDE/wp-content/plugins/eltd-core/shortcodes/image-gallery/ |
Upload File : |
<?php
if ( ! function_exists( 'eltd_core_add_image_gallery_shortcodes' ) ) {
function eltd_core_add_image_gallery_shortcodes( $shortcodes_class_name ) {
$shortcodes = array(
'ElatedCore\CPT\Shortcodes\ImageGallery\ImageGallery'
);
$shortcodes_class_name = array_merge( $shortcodes_class_name, $shortcodes );
return $shortcodes_class_name;
}
add_filter( 'eltd_core_filter_add_vc_shortcode', 'eltd_core_add_image_gallery_shortcodes' );
}
if ( ! function_exists( 'eltd_core_set_image_gallery_icon_class_name_for_vc_shortcodes' ) ) {
/**
* Function that set custom icon class name for image gallery shortcode to set our icon for Visual Composer shortcodes panel
*/
function eltd_core_set_image_gallery_icon_class_name_for_vc_shortcodes( $shortcodes_icon_class_array ) {
$shortcodes_icon_class_array[] = '.icon-wpb-image-gallery';
return $shortcodes_icon_class_array;
}
add_filter( 'eltd_core_filter_add_vc_shortcodes_custom_icon_class', 'eltd_core_set_image_gallery_icon_class_name_for_vc_shortcodes' );
}
if ( ! function_exists( 'eltd_core_add_image_gallery_attachment_custom_field' ) ) {
function eltd_core_add_image_gallery_attachment_custom_field( $form_fields, $post = null ) {
if ( wp_attachment_is_image( $post->ID ) ) {
$field_value = get_post_meta( $post->ID, 'image_gallery_masonry_image_size', true );
$form_fields['image_gallery_masonry_image_size'] = array(
'input' => 'html',
'label' => esc_html__( 'Image Size', 'eltd-core' ),
'helps' => esc_html__( 'Choose image size for Image Gallery shortcode item - Masonry layout', 'eltd-core' )
);
$form_fields['image_gallery_masonry_image_size']['html'] = "<select name='attachments[{$post->ID}][image_gallery_masonry_image_size]'>";
$form_fields['image_gallery_masonry_image_size']['html'] .= '<option ' . selected( $field_value, 'eltd-default-masonry-item', false ) . ' value="eltd-default-masonry-item">' . esc_html__( 'Default Size', 'eltd-core' ) . '</option>';
$form_fields['image_gallery_masonry_image_size']['html'] .= '<option ' . selected( $field_value, 'eltd-large-masonry-item', false ) . ' value="eltd-large-masonry-item">' . esc_html__( 'Large Size', 'eltd-core' ) . '</option>';
$form_fields['image_gallery_masonry_image_size']['html'] .= '</select>';
}
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'eltd_core_add_image_gallery_attachment_custom_field', 10, 2 );
}
if ( ! function_exists( 'eltd_core_save_image_gallery_attachment_fields' ) ) {
/**
* @param array $post
* @param array $attachment
*
* @return array
*/
function eltd_core_save_image_gallery_attachment_fields( $post, $attachment ) {
if ( isset( $attachment['image_gallery_masonry_image_size'] ) ) {
update_post_meta( $post['ID'], 'image_gallery_masonry_image_size', $attachment['image_gallery_masonry_image_size'] );
}
return $post;
}
add_filter( 'attachment_fields_to_save', 'eltd_core_save_image_gallery_attachment_fields', 10, 2 );
}