plugin updates
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
// External Dependencies
|
||||
import React, {Component} from 'react';
|
||||
|
||||
// Internal Dependencies
|
||||
import './style.css';
|
||||
|
||||
class WpmfFileDesignDivi extends Component {
|
||||
|
||||
static slug = 'wpmf_file_design';
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
html: '',
|
||||
loading: true
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
if (typeof this.props.url !== "undefined") {
|
||||
this.loadHtml(this.props);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.url !== nextProps.url || this.props.align !== nextProps.align) {
|
||||
this.loadHtml(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
loadHtml(props) {
|
||||
if (!this.state.loading) {
|
||||
this.setState({
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
fetch(window.et_fb_options.ajaxurl + `?action=wpmf_divi_load_file_design_html&url=${props.url}&align=${props.align}&et_admin_load_nonce=${window.et_fb_options.et_admin_load_nonce}`)
|
||||
.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 (typeof this.props.url === "undefined") {
|
||||
return (
|
||||
<div className="wpmf-divi-container">
|
||||
<div id="divi-file-design-placeholder" className="divi-file-design-placeholder">
|
||||
<span className="wpmf-divi-message">
|
||||
{'WP Media Folder media download. Select a media and transform it into a download button'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-divi-container">
|
||||
<div className={'wpmf-loading-wrapper'}>
|
||||
<i className={'wpmf-loading'}>{loadingIcon}</i>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-file-design-wrap" dangerouslySetInnerHTML={{__html: this.state.html}}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default WpmfFileDesignDivi;
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfPdfEmbedDivi
|
||||
*/
|
||||
class WpmfFileDesignDivi extends ET_Builder_Module
|
||||
{
|
||||
|
||||
/**
|
||||
* Module slug
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $slug = 'wpmf_file_design';
|
||||
|
||||
/**
|
||||
* 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 Media Download', '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
|
||||
{
|
||||
return array(
|
||||
'url' => array(
|
||||
'type' => 'upload',
|
||||
'data_type' => '*',
|
||||
'option_category' => 'configuration',
|
||||
'upload_button_text' => esc_attr__('Upload a File', 'wpmf'),
|
||||
'choose_text' => esc_attr__('Choose a File', 'wpmf'),
|
||||
'update_text' => esc_attr__('Set As File', 'wpmf'),
|
||||
'hide_metadata' => true,
|
||||
'affects' => array(
|
||||
'alt',
|
||||
'title_text',
|
||||
),
|
||||
'description' => esc_html__('Upload your desired file, or type in the URL to the image you would like to display.', 'wpmf'),
|
||||
),
|
||||
'align' => array(
|
||||
'label' => esc_html__('File Alignment', 'wpmf'),
|
||||
'type' => 'text_align',
|
||||
'option_category' => 'layout',
|
||||
'options' => et_builder_get_text_orientation_options(array('justified')),
|
||||
'default_on_front' => 'left',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'alignment',
|
||||
'description' => esc_html__('Here you can choose the image alignment.', 'wpmf'),
|
||||
'options_icon' => 'module_align',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
if (empty($this->props['url'])) {
|
||||
$html = '<div class="wpmf-divi-container">
|
||||
<div id="divi-file-design-placeholder" class="divi-file-design-placeholder">
|
||||
<span class="wpmf-divi-message">
|
||||
' . esc_html__('Please select a PDF file to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
return $html;
|
||||
}
|
||||
return do_shortcode('[wpmffiledesign url="' . esc_attr($this->props['url']) . '" align="' . esc_attr($this->props['align']) . '"]');
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfFileDesignDivi;
|
||||
Reference in New Issue
Block a user