plugin updates

This commit is contained in:
Tony Volpe
2024-07-16 13:57:46 +00:00
parent 41f50eacc4
commit 8f93917880
1529 changed files with 259452 additions and 25451 deletions

View File

@@ -0,0 +1,473 @@
// External Dependencies
import React, {Component} from 'react';
import $ from 'jquery';
// Internal Dependencies
import './style.css';
class WpmfGalleryAddonDivi extends Component {
static slug = 'wpmf_gallery_addon_divi';
constructor(props) {
super(props);
this.state = {
html: '',
loading: true
};
this.wrap = React.createRef();
}
componentWillMount() {
if (this.props.items !== '') {
this.loadHtml(this.props);
}
}
componentWillReceiveProps(nextProps) {
if (this.props.gallery_id !== nextProps.gallery_id || this.props.columns !== nextProps.columns || this.props.theme !== nextProps.theme || this.props.layout !== nextProps.layout || this.props.row_height !== nextProps.row_height || this.props.aspect_ratio !== nextProps.aspect_ratio || this.props.size !== nextProps.size || this.props.orderby !== nextProps.orderby || this.props.order !== nextProps.order || this.props.border_radius !== nextProps.border_radius || this.props.gutterwidth !== nextProps.gutterwidth
|| this.props.border_width !== nextProps.border_width || this.props.border_color !== nextProps.border_color || this.props.border_style !== nextProps.border_style
|| this.props.enable_shadow !== nextProps.enable_shadow || this.props.shadow_color !== nextProps.shadow_color || this.props.shadow_horizontal !== nextProps.shadow_horizontal || this.props.shadow_vertical !== nextProps.shadow_vertical || this.props.shadow_blur !== nextProps.shadow_blur || this.props.shadow_spread !== nextProps.shadow_spread
|| this.props.gallery_image_tags !== nextProps.gallery_image_tags || this.props.gallery_navigation !== nextProps.gallery_navigation || this.props.sub_galleries_listing !== nextProps.sub_galleries_listing || this.props.number_lines !== nextProps.number_lines
|| this.props.disable_overlay !== nextProps.disable_overlay || this.props.hover_color !== nextProps.hover_color || this.props.hover_opacity !== nextProps.hover_opacity || this.props.hover_title_position !== nextProps.hover_title_position
|| this.props.hover_title_size !== nextProps.hover_title_size || this.props.hover_title_color !== nextProps.hover_title_color || this.props.hover_desc_position !== nextProps.hover_desc_position
|| this.props.hover_desc_size !== nextProps.hover_desc_size || this.props.hover_desc_color !== nextProps.hover_desc_color) {
this.loadHtml(nextProps);
}
}
componentDidMount() {
if (parseInt(this.props.gallery_id) !== 0) {
let t = this;
let a = setInterval(function () {
$(t.wrap.current).find('.loading_gallery').hide();
if (t.props.theme === 'masonry') {
if ($(t.wrap.current).find('.gallery-masonry').length) {
t.initMasonry();
clearInterval(a);
}
}
if (t.props.theme === 'custom_grid') {
if ($(t.wrap.current).find('.wpmf-custom-grid').length) {
t.initCustomGrid();
clearInterval(a);
}
}
if (t.props.theme === 'slider') {
if ($(t.wrap.current).find('.wpmfslick').length) {
t.initSlider();
clearInterval(a);
}
}
if (t.props.theme === 'flowslide') {
if ($(t.wrap.current).find('.wpmf-flipster').length) {
t.initFlowsSlide();
clearInterval(a);
}
}
}, 200);
}
}
componentDidUpdate(prevProps) {
// Deselect images when deselecting the block
if (parseInt(this.props.gallery_id) !== 0 && !(this.props.gallery_id === prevProps.gallery_id && this.props.columns === prevProps.columns && this.props.theme === prevProps.theme && this.props.layout === prevProps.layout && this.props.row_height === prevProps.row_height && this.props.aspect_ratio === prevProps.aspect_ratio && this.props.size === prevProps.size && this.props.orderby === prevProps.orderby && this.props.order === prevProps.order && this.props.border_radius === prevProps.border_radius && this.props.gutterwidth === prevProps.gutterwidth && this.props.border_width === prevProps.border_width && this.props.border_color === prevProps.border_color && this.props.border_style === prevProps.border_style && this.props.enable_shadow === prevProps.enable_shadow && this.props.shadow_color === prevProps.shadow_color && this.props.shadow_horizontal === prevProps.shadow_horizontal && this.props.shadow_vertical === prevProps.shadow_vertical && this.props.shadow_blur === prevProps.shadow_blur && this.props.shadow_spread === prevProps.shadow_spread && this.props.gallery_image_tags === prevProps.gallery_image_tags && this.props.disable_overlay === prevProps.disable_overlay && this.props.gallery_navigation === prevProps.gallery_navigation && this.props.sub_galleries_listing === prevProps.sub_galleries_listing && this.props.number_lines === prevProps.number_lines && this.props.hover_color === prevProps.hover_color && this.props.hover_opacity === prevProps.hover_opacity && this.props.hover_title_position === prevProps.hover_title_position && this.props.hover_title_size === prevProps.hover_title_size && this.props.hover_title_color === prevProps.hover_title_color && this.props.hover_desc_position === prevProps.hover_desc_position && this.props.hover_desc_size === prevProps.hover_desc_size && this.props.hover_desc_color === prevProps.hover_desc_color)) {
let t = this;
let a = setInterval(function () {
$(t.wrap.current).find('.loading_gallery').hide();
if (t.props.theme === 'masonry') {
if ($(t.wrap.current).find('.gallery-masonry').length) {
t.initMasonry();
clearInterval(a);
}
}
if (t.props.theme === 'custom_grid') {
if ($(t.wrap.current).find('.wpmf-custom-grid').length) {
t.initCustomGrid();
clearInterval(a);
}
}
if (t.props.theme === 'slider') {
if ($(t.wrap.current).find('.wpmfslick').length) {
t.initSlider();
clearInterval(a);
}
}
if (t.props.theme === 'flowslide') {
if ($(t.wrap.current).find('.wpmf-flipster').length) {
t.initFlowsSlide();
clearInterval(a);
}
}
}, 1000);
}
}
calculateGrid($container) {
let columns = parseInt($container.data('wpmfcolumns'));
let gutterWidth = $container.data('gutterWidth');
let containerWidth = $container.width();
if (isNaN(gutterWidth)) {
gutterWidth = 5;
} else if (gutterWidth > 500 || gutterWidth < 0) {
gutterWidth = 5;
}
if (parseInt(columns) < 2 || containerWidth <= 450) {
columns = 2;
}
gutterWidth = parseInt(gutterWidth);
let allGutters = gutterWidth * (columns - 1);
let contentWidth = containerWidth - allGutters;
let columnWidth = Math.floor(contentWidth / columns);
return {columnWidth: columnWidth, gutterWidth: gutterWidth, columns: columns};
};
initFlowsSlide() {
let $container = $(this.wrap.current).find('.wpmf-flipster');
let enableNavButtons = $container.data('button');
if (typeof enableNavButtons !== "undefined" && parseInt(enableNavButtons) === 1) {
$container.flipster({
style: 'coverflow',
buttons: 'custom',
spacing: 0,
loop: true,
autoplay: 5000,
buttonNext: '<i class="flipto-next material-icons"> keyboard_arrow_right </i>',
buttonPrev: '<i class="flipto-prev material-icons"> keyboard_arrow_left </i>',
onItemSwitch: function (currentItem, previousItem) {
$container.find('.flipster__container').height($(currentItem).height());
},
onItemStart: function (currentItem) {
$container.find('.flipster__container').height($(currentItem).height());
}
});
} else {
$container.flipster({
style: 'coverflow',
spacing: 0,
loop: true,
autoplay: 5000,
onItemSwitch: function (currentItem, previousItem) {
$container.find('.flipster__container').height($(currentItem).height());
},
onItemStart: function (currentItem) {
$container.find('.flipster__container').height($(currentItem).height());
}
});
}
}
initMasonry() {
let $container = $(this.wrap.current).find('.gallery-masonry');
let layout = $container.closest('.wpmf-gallerys-addon').data('layout');
let padding = $container.data('gutter-width');
if ($container.is(':hidden')) {
return;
}
if ($container.hasClass('masonry')) {
$container.masonry('destroy');
}
if ($container.hasClass('justified-gallery')) {
$container.justifiedGallery('destroy');
}
if (layout === 'horizontal') {
var row_height = $container.closest('.wpmf-gallerys-addon').data('row_height');
if (typeof row_height === "undefined" || row_height === '') {
row_height = 200;
}
$container.imagesLoaded(function () {
setTimeout(function () {
$container.justifiedGallery({
rowHeight: row_height,
margins: padding
});
},200);
});
return;
}
var t = this;
$container.imagesLoaded(function () {
var $postBox = $container.children('.wpmf-gallery-item');
var o = t.calculateGrid($container);
$postBox.css({'width': o.columnWidth + 'px', 'margin-bottom': o.gutterWidth + 'px'});
$container.masonry({
itemSelector: '.wpmf-gallery-item',
columnWidth: o.columnWidth,
gutter: o.gutterWidth,
isFitWidth: true,
transitionDuration: 0,
});
$container.css('visibility', 'visible');
});
}
initCustomGrid() {
let $container = $(this.wrap.current).find('.wpmf-custom-grid');
if ($container.is(':hidden')) {
return;
}
if ($container.hasClass('masonry')) {
$container.masonry('destroy');
}
if ($container.hasClass('justified-gallery')) {
$container.justifiedGallery('destroy');
}
if ($container.hasClass('wpmfInitPackery')) {
$container.isotope('destroy');
}
$container.imagesLoaded(function () {
var gutter = $container.data('gutter');
$container.closest('.wpmf_gallery_wrap').find('.loading_gallery').hide();
var wrap_width = $container.width();
var one_col_width = (wrap_width - gutter*12)/12;
$container.find('.grid-item').each(function() {
var dimensions = $(this).data('styles');
var w = (typeof dimensions.width !== "undefined") ? parseInt(dimensions.width) : 2;
var h = (typeof dimensions.height !== "undefined") ? parseInt(dimensions.height) : 2;
var g = (parseInt(w) - 1)*gutter;
var display_width = one_col_width;
var display_height = one_col_width;
if (w > 1) {
display_width = one_col_width*w + g;
}
if (w == h) {
display_height = display_width;
} else {
if (h > 1) {
display_height = (one_col_width*h) + (h - 1)*gutter;
}
}
$(this).width(display_width);
$(this).height(display_height);
});
$container.isotope({
itemSelector: '.grid-item',
layoutMode: 'packery',
resizable: true,
initLayout: true,
packery: {
gutter: gutter
}
});
$container.addClass('wpmfInitPackery');
});
}
/**
* run masonry layout
*/
initSlider() {
let $slider_container = $(this.wrap.current).find('.wpmfslick');
if ($slider_container.is(':hidden')) {
return;
}
let number_lines = parseInt($slider_container.data('number_lines'));
let columns = parseInt($slider_container.data('wpmfcolumns'));
let autoplay = $slider_container.data('auto_animation');
if ($slider_container.hasClass('slick-initialized')) {
$slider_container.slick('destroy');
}
$slider_container.imagesLoaded(function () {
var slick_args = {
infinite: true,
slidesToShow: parseInt(columns),
slidesToScroll: parseInt(columns),
pauseOnHover: true,
autoplay: (autoplay === 1),
adaptiveHeight: (parseInt(columns) === 1),
autoplaySpeed: 5000,
rows: number_lines,
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
};
$slider_container.slick(slick_args);
});
}
loadHtml(props) {
if (!this.state.loading) {
this.setState({
loading: true
});
}
let img_shadow = '';
if (props.enable_shadow === 'on') {
img_shadow = props.shadow_horizontal + ' ' + props.shadow_vertical + ' ' + props.shadow_blur + ' ' + props.shadow_spread + ' ' + props.shadow_color;
}
let gallery_id_string = props.gallery_id;
let gallery_id;
if (gallery_id_string.indexOf('-') != -1) {
let gallery_ids = gallery_id_string.split('-');
gallery_id = gallery_ids[1];
} else {
gallery_id = gallery_id_string;
}
let datas = {
gallery_id: gallery_id,
display: props.theme,
layout: props.layout,
row_height: props.row_height,
aspect_ratio: props.aspect_ratio,
columns: props.columns,
number_lines: props.number_lines,
size: props.size,
targetsize: props.targetsize,
link: props.action,
orderby: props.orderby,
order: props.order,
gutterwidth: props.gutterwidth,
border_width: props.border_width,
border_style: props.border_style,
border_color: props.border_color,
img_shadow: img_shadow,
border_radius: props.border_radius,
display_tree: props.gallery_navigation,
sub_galleries_listing: props.sub_galleries_listing,
display_tag: props.gallery_image_tags,
disable_overlay: props.disable_overlay,
hover_color: props.hover_color,
hover_opacity: props.hover_opacity,
hover_title_position: props.hover_title_position,
hover_title_size: props.hover_title_size,
hover_title_color: props.hover_title_color,
hover_desc_position: props.hover_desc_position,
hover_desc_size: props.hover_desc_size,
hover_desc_color: props.hover_desc_color
};
fetch(window.et_fb_options.ajaxurl + `?action=wpmf_divi_load_gallery_addon_html&et_admin_load_nonce=${window.et_fb_options.et_admin_load_nonce}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(datas)
})
.then(res => res.json())
.then(
(result) => {
this.setState({
html: result.html,
loading: false
});
},
// errors
(error) => {
this.setState({
html: '',
loading: true
});
}
);
}
render() {
const loadingIcon = (
<svg className={'wpfd-loading'} width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
<g transform="translate(25 50)">
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.590851 0.590851)">
<animateTransform attributeName="transform" type="scale" begin="-0.8666666666666667s" calcMode="spline"
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
repeatCount="indefinite"/>
</circle>
</g>
<g transform="translate(50 50)">
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.145187 0.145187)">
<animateTransform attributeName="transform" type="scale" begin="-0.43333333333333335s" calcMode="spline"
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
repeatCount="indefinite"/>
</circle>
</g>
<g transform="translate(75 50)">
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.0339143 0.0339143)">
<animateTransform attributeName="transform" type="scale" begin="0s" calcMode="spline"
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
repeatCount="indefinite"/>
</circle>
</g>
</svg>
);
if (parseInt(this.props.gallery_id) === 0) {
return (
<div className="wpmf-divi-container wpmf-gallery-divi-wrap" ref={this.wrap}>
<div id="divi-gallery-addon-placeholder" className="divi-gallery-addon-placeholder">
<span className="wpmf-divi-message">
{'Please select a gallery to activate the preview'}
</span>
</div>
</div>
);
}
if (this.state.loading) {
return (
<div className="wpmf-divi-container wpmf-gallery-divi-wrap" ref={this.wrap}>
<div className={'wpmf-loading-wrapper'}>
<i className={'wpmf-loading'}>{loadingIcon}</i>
</div>
</div>
);
}
if (!this.state.loading) {
return (
<div className="wpmf-gallery-divi-wrap" ref={this.wrap}
dangerouslySetInnerHTML={{__html: this.state.html}}/>
);
}
}
}
export default WpmfGalleryAddonDivi;

View File

@@ -0,0 +1,609 @@
<?php
/* Prohibit direct script loading */
defined('ABSPATH') || die('No direct script access allowed!');
/**
* Class WpmfGalleryDivi
*/
class WpmfGalleryAddonDivi extends ET_Builder_Module
{
/**
* Module slug
*
* @var string
*/
public $slug = 'wpmf_gallery_addon_divi';
/**
* Whether module support visual builder. e.g `on` or `off`.
*
* @var string
*/
public $vb_support = 'on';
/**
* Credits of all custom modules.
*
* @var array
*/
protected $module_credits = array(
'module_uri' => 'https://www.joomunited.com/',
'author' => 'Joomunited',
'author_uri' => 'https://www.joomunited.com/',
);
/**
* Init
*
* @return void
*/
public function init()
{
$this->name = esc_html__('WPMF Gallery Addon', 'wpmf');
}
/**
* Advanced Fields Config
*
* @return array
*/
public function get_advanced_fields_config() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
{
return array(
'button' => false,
'link_options' => false
);
}
/**
* Get the settings fields data for this element.
*
* @return array
*/
public function get_fields() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
{
$settings = get_option('wpmf_gallery_settings');
$galleries = get_categories(
array(
'hide_empty' => false,
'taxonomy' => WPMF_GALLERY_ADDON_TAXO,
'pll_get_terms_not_translated' => 1
)
);
if (count($galleries) < 100) {
$galleries = wpmfParentSort($galleries);
}
$galleries_list = array();
$galleries_list[0] = esc_html__('WP Media Folder Gallery', 'wpmf');
$i = 0;
foreach ($galleries as $gallery) {
$gallery_type = get_term_meta((int)$gallery->term_id, 'gallery_type', true);
if (!empty($gallery_type) && ($gallery_type === 'photographer' || $gallery_type === 'archive')) {
continue;
}
$depth = $gallery->depth + 1;
$galleries_list[$i . '-' . $gallery->term_id] = str_repeat('&nbsp;&nbsp;', $depth) . $gallery->name;
$i++;
}
foreach ($galleries as $gallery) {
$gallery_type = get_term_meta((int)$gallery->term_id, 'gallery_type', true);
if (!empty($gallery_type) && $gallery_type === 'archive') {
continue;
}
if (!empty($gallery_type) && $gallery_type === 'photographer') {
$root = get_term_by('slug', 'photographer-gallery', WPMF_GALLERY_ADDON_TAXO);
if ((int)$root->term_id === (int)$gallery->term_id) {
$galleries_list[$i . '-' . $gallery->term_id] = esc_html__('Photographer Gallery', 'wpmf');
} else {
$depth = $gallery->depth;
$galleries_list[$i . '-' . $gallery->term_id] = str_repeat('&nbsp;&nbsp;', $depth) . $gallery->name;
}
}
$i++;
}
return array(
'gallery_id' => array(
'label' => esc_html__('Choose a Gallery', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => $galleries_list,
'default' => 0,
'default_on_front' => 0
),
'theme' => array(
'label' => esc_html__('Theme', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'default' => esc_html__('Default', 'wpmf'),
'masonry' => esc_html__('Masonry', 'wpmf'),
'portfolio' => esc_html__('Portfolio', 'wpmf'),
'slider' => esc_html__('Slider', 'wpmf'),
'flowslide' => esc_html__('Flow slide', 'wpmf'),
'square_grid' => esc_html__('Square grid', 'wpmf'),
'material' => esc_html__('Material', 'wpmf'),
'custom_grid' => esc_html__('Custom grid', 'wpmf')
),
'default' => 'masonry',
'default_on_front' => 'masonry'
),
'layout' => array(
'label' => esc_html__('Layout', 'wpmf'),
'description' => esc_html__('Layout for masonry and square grid theme', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'vertical' => esc_html__('Vertical', 'wpmf'),
'horizontal' => esc_html__('Horizontal', 'wpmf'),
),
'default' => 'vertical',
'default_on_front' => 'vertical'
),
'row_height' => array(
'label' => esc_html__('Row height', 'wpmf'),
'description' => esc_html__('Layout for masonry and square grid theme', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => 200,
'default_on_front' => 200,
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 50,
'max' => 500,
'step' => 1
)
),
'aspect_ratio' => array(
'label' => esc_html__('Aspect ratio', 'wpmf'),
'description' => esc_html__('Aspect ratio for default, material, slider and square grid theme', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'default' => esc_html__('Default', 'wpmf'),
'1_1' => '1:1',
'3_2' => '3:2',
'2_3' => '2:3',
'4_3' => '4:3',
'3_4' => '3:4',
'16_9' => '16:9',
'9_16' => '9:16',
'21_9' => '21:9',
'9_21' => '9:21'
),
'default' => '1_1',
'default_on_front' => '1_1',
'show_if_not' => array(
'theme' => array(
'masonry',
'flowslide',
'custom_grid'
)
)
),
'gallery_navigation' => array(
'label' => esc_html__('Gallery Navigation', 'wpmf'),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__('On', 'wpmf'),
'off' => esc_html__('Off', 'wpmf'),
),
'default' => 'off',
'default_on_front' => 'off'
),
'sub_galleries_listing' => array(
'label' => esc_html__('Sub-galleries listing', 'wpmf'),
'description' => esc_html__('This gallery will only list its sub-galleries, using the galleries covers as image.', 'wpmf'),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__('On', 'wpmf'),
'off' => esc_html__('Off', 'wpmf'),
),
'default' => 'off',
'default_on_front' => 'off'
),
'gallery_image_tags' => array(
'label' => esc_html__('Display Images Tags', 'wpmf'),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__('On', 'wpmf'),
'off' => esc_html__('Off', 'wpmf'),
),
'default' => 'off',
'default_on_front' => 'off'
),
'columns' => array(
'label' => esc_html__('Columns', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => $settings['theme']['masonry_theme']['columns'],
'default_on_front' => $settings['theme']['masonry_theme']['columns'],
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 1,
'max' => 8,
'step' => 1
),
'show_if_not' => array(
'theme' => array(
'flowslide',
'custom_grid'
)
)
),
'number_lines' => array(
'label' => esc_html__('Slider number lines', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => 1,
'default_on_front' => 1,
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 1,
'max' => 3,
'step' => 1
)
),
'size' => array(
'label' => esc_html__('Image Size', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => apply_filters('image_size_names_choose', array(
'thumbnail' => __('Thumbnail', 'wpmf'),
'medium' => __('Medium', 'wpmf'),
'large' => __('Large', 'wpmf'),
'full' => __('Full Size', 'wpmf'),
)),
'default' => $settings['theme']['masonry_theme']['size'],
'default_on_front' => $settings['theme']['masonry_theme']['size']
),
'targetsize' => array(
'label' => esc_html__('Lightbox Size', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => apply_filters('image_size_names_choose', array(
'thumbnail' => __('Thumbnail', 'wpmf'),
'medium' => __('Medium', 'wpmf'),
'large' => __('Large', 'wpmf'),
'full' => __('Full Size', 'wpmf'),
)),
'default' => $settings['theme']['masonry_theme']['targetsize'],
'default_on_front' => $settings['theme']['masonry_theme']['targetsize']
),
'action' => array(
'label' => esc_html__('Action On Click', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'file' => esc_html__('Lightbox', 'wpmf'),
'post' => esc_html__('Attachment Page', 'wpmf'),
'none' => esc_html__('None', 'wpmf'),
),
'default' => $settings['theme']['masonry_theme']['link'],
'default_on_front' => $settings['theme']['masonry_theme']['link']
),
'orderby' => array(
'label' => esc_html__('Order by', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'post__in' => esc_html__('Custom', 'wpmf'),
'rand' => esc_html__('Random', 'wpmf'),
'title' => esc_html__('Title', 'wpmf'),
'date' => esc_html__('Date', 'wpmf')
),
'default' => $settings['theme']['masonry_theme']['orderby'],
'default_on_front' => $settings['theme']['masonry_theme']['orderby']
),
'order' => array(
'label' => esc_html__('Order', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'ASC' => esc_html__('Ascending', 'wpmf'),
'DESC' => esc_html__('Descending', 'wpmf')
),
'default' => $settings['theme']['masonry_theme']['order'],
'default_on_front' => $settings['theme']['masonry_theme']['order']
),
'gutterwidth' => array(
'label' => esc_html__('Gutter', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => 5,
'default_on_front' => 5,
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 0,
'max' => 100,
'step' => 5
)
),
'border_radius' => array(
'label' => esc_html__('Border Radius', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => 0,
'default_on_front' => 0,
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 0,
'max' => 20,
'step' => 1
)
),
'border_style' => array(
'label' => esc_html__('Border Type', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'solid' => esc_html__('Solid', 'wpmf'),
'double' => esc_html__('Double', 'wpmf'),
'dotted' => esc_html__('Dotted', 'wpmf'),
'dashed' => esc_html__('Dashed', 'wpmf'),
'groove' => esc_html__('Groove', 'wpmf')
),
'default' => 'solid',
'default_on_front' => 'solid'
),
'border_width' => array(
'label' => esc_html__('Border Width', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => 0,
'default_on_front' => 0,
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 0,
'max' => 30,
'step' => 1
)
),
'border_color' => array(
'label' => esc_html__('Border Color', 'wpmf'),
'type' => 'color-alpha',
'custom_color' => true,
'default' => '#cccccc',
'default_on_front' => '#cccccc'
),
'enable_shadow' => array(
'label' => esc_html__('Enable Shadow', 'wpmf'),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__('On', 'wpmf'),
'off' => esc_html__('Off', 'wpmf'),
),
'default' => 'off',
'default_on_front' => 'off'
),
'shadow_color' => array(
'label' => esc_html__('Shadow Color', 'wpmf'),
'type' => 'color-alpha',
'custom_color' => true,
'default' => '#cccccc',
'default_on_front' => '#cccccc'
),
'shadow_horizontal' => array(
'label' => esc_html__('Horizontal', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'validate_unit' => true,
'default' => '0px',
'default_unit' => 'px',
'default_on_front' => '0px',
'range_settings' => array(
'min' => '-50',
'max' => '50',
'step' => '1'
)
),
'shadow_vertical' => array(
'label' => esc_html__('Vertical', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'validate_unit' => true,
'default' => '0px',
'default_unit' => 'px',
'default_on_front' => '0px',
'range_settings' => array(
'min' => '-50',
'max' => '50',
'step' => '1'
)
),
'shadow_blur' => array(
'label' => esc_html__('Blur', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'validate_unit' => true,
'default' => '0px',
'default_unit' => 'px',
'default_on_front' => '0px',
'range_settings' => array(
'min' => '0',
'max' => '50',
'step' => '1'
)
),
'shadow_spread' => array(
'label' => esc_html__('Spread', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'validate_unit' => true,
'default' => '0px',
'default_unit' => 'px',
'default_on_front' => '0px',
'range_settings' => array(
'min' => '0',
'max' => '50',
'step' => '1'
)
),
'disable_overlay' => array(
'label' => esc_html__('Disable Overlay', 'wpmf'),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__('On', 'wpmf'),
'off' => esc_html__('Off', 'wpmf'),
),
'default' => 'off',
'default_on_front' => 'off'
),
'hover_color' => array(
'label' => esc_html__('Hover Color', 'wpmf'),
'type' => 'color-alpha',
'custom_color' => true,
'default' => '#000',
'default_on_front' => '#000'
),
'hover_opacity' => array(
'label' => esc_html__('Hover Opacity', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => 0.4,
'default_on_front' => 0.4,
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 0,
'max' => 1,
'step' => 0.1
)
),
'hover_title_position' => array(
'label' => esc_html__('Title Position', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'none' => esc_html__('None', 'wpmf'),
'top_left' => esc_html__('Top left', 'wpmf'),
'top_right' => esc_html__('Top right', 'wpmf'),
'top_center' => esc_html__('Top center', 'wpmf'),
'bottom_left' => esc_html__('Bottom left', 'wpmf'),
'bottom_right' => esc_html__('Bottom right', 'wpmf'),
'bottom_center' => esc_html__('Bottom center', 'wpmf'),
'center_center' => esc_html__('Center center', 'wpmf'),
),
'default' => 'center_center',
'default_on_front' => 'center_center'
),
'hover_title_size' => array(
'label' => esc_html__('Title Size', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => 16,
'default_on_front' => 16,
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 0,
'max' => 150,
'step' => 1
)
),
'hover_title_color' => array(
'label' => esc_html__('Title Color', 'wpmf'),
'type' => 'color-alpha',
'custom_color' => true,
'default' => '#fff',
'default_on_front' => '#fff'
),
'hover_desc_position' => array(
'label' => esc_html__('Description Position', 'wpmf'),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'none' => esc_html__('None', 'wpmf'),
'top_left' => esc_html__('Top left', 'wpmf'),
'top_right' => esc_html__('Top right', 'wpmf'),
'top_center' => esc_html__('Top center', 'wpmf'),
'bottom_left' => esc_html__('Bottom left', 'wpmf'),
'bottom_right' => esc_html__('Bottom right', 'wpmf'),
'bottom_center' => esc_html__('Bottom center', 'wpmf'),
'center_center' => esc_html__('Center center', 'wpmf'),
),
'default' => 'center_center',
'default_on_front' => 'center_center'
),
'hover_desc_size' => array(
'label' => esc_html__('Description Size', 'wpmf'),
'type' => 'range',
'option_category' => 'configuration',
'default' => 14,
'default_on_front' => 14,
'validate_unit' => false,
'unitless' => true,
'range_settings' => array(
'min' => 0,
'max' => 150,
'step' => 1
)
),
'hover_desc_color' => array(
'label' => esc_html__('Description Color', 'wpmf'),
'type' => 'color-alpha',
'custom_color' => true,
'default' => '#fff',
'default_on_front' => '#fff'
),
);
}
/**
* Render content
*
* @param array $attrs List of attributes.
* @param string $content Content being processed.
* @param string $render_slug Slug of module that is used for rendering output.
*
* @return string
*/
public function render($attrs, $content, $render_slug) // phpcs:ignore PEAR.Functions.ValidDefaultValue.NotAtEnd -- Method extends from ET_Builder_Module class
{
$gallery_navigation = (!empty($this->props['gallery_navigation']) && $this->props['gallery_navigation'] === 'on') ? 1 : 0;
$sub_galleries_listing = (!empty($this->props['sub_galleries_listing']) && $this->props['sub_galleries_listing'] === 'on') ? 1 : 0;
$gallery_image_tags = (!empty($this->props['gallery_image_tags']) && $this->props['gallery_image_tags'] === 'on') ? 1 : 0;
$disable_overlay = (!empty($this->props['disable_overlay']) && $this->props['disable_overlay'] === 'on') ? 1 : 0;
if (!empty($this->props['enable_shadow']) && $this->props['enable_shadow'] === 'on') {
$img_shadow = $this->props['shadow_horizontal'] . ' ' . $this->props['shadow_vertical'] . ' ' . $this->props['shadow_blur'] . ' ' . $this->props['shadow_spread'] . ' ' . $this->props['shadow_color'];
} else {
$img_shadow = '';
}
if (empty($this->props['gallery_id'])) {
$html = '<div class="wpmf-divi-container">
<div id="divi-gallery-addon-placeholder" class="divi-gallery-addon-placeholder">
<span class="wpmf-divi-message">
' . esc_html__('Please select a gallery to activate the preview', 'wpmf') . '
</span>
</div>
</div>';
return $html;
}
$gallery_id_string = $this->props['gallery_id'];
if (strpos($gallery_id_string, '-') !== false) {
$gallery_ids = explode('-', $gallery_id_string);
$gallery_id = $gallery_ids[1];
} else {
$gallery_id = $gallery_id_string;
}
return do_shortcode('[wpmfgallery gallery_id="'. (int)$gallery_id .'" display_tree="' . esc_attr($gallery_navigation) . '" sub_galleries_listing="' . esc_attr($sub_galleries_listing) . '" display_tag="' . esc_attr($gallery_image_tags) . '" disable_overlay="' . esc_attr($disable_overlay) . '" display="' . esc_attr($this->props['theme']) . '" layout="' . esc_attr($this->props['layout']) . '" row_height="' . esc_attr($this->props['row_height']) . '" aspect_ratio="' . esc_attr($this->props['aspect_ratio']) . '" columns="' . esc_attr($this->props['columns']) . '" size="' . esc_attr($this->props['size']) . '" targetsize="' . esc_attr($this->props['targetsize']) . '" link="' . esc_attr($this->props['action']) . '" wpmf_orderby="' . esc_attr($this->props['orderby']) . '" wpmf_order="' . esc_attr($this->props['order']) . '" gutterwidth="' . esc_attr($this->props['gutterwidth']) . '" border_width="' . esc_attr($this->props['border_width']) . '" border_style="' . esc_attr($this->props['border_style']) . '" border_color="' . esc_attr($this->props['border_color']) . '" img_shadow="' . esc_attr($img_shadow) . '" img_border_radius="' . esc_attr($this->props['border_radius']) . '" number_lines="' . esc_attr($this->props['number_lines']) . '" hover_color="'. $this->props['hover_color'] .'" hover_opacity="'. $this->props['hover_opacity'] .'" hover_title_position="'. $this->props['hover_title_position'] .'" hover_title_size="'. $this->props['hover_title_size'] .'" hover_title_color="'. $this->props['hover_title_color'] .'" hover_desc_position="'. $this->props['hover_desc_position'] .'" hover_desc_size="'. $this->props['hover_desc_size'] .'" hover_desc_color="'. $this->props['hover_desc_color'] .'"]');
}
}
new WpmfGalleryAddonDivi;