Download all files FTP
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
define( 'FL_MODULE_DA_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'FL_MODULE_DA_URL', plugins_url( '/', __FILE__ ) );
|
||||
|
||||
/* Define custom Beaver Builder modules */
|
||||
function da_load_module_examples() {
|
||||
if ( class_exists( 'FLBuilder' ) ) {
|
||||
require_once 'da/da.php';
|
||||
}
|
||||
}
|
||||
add_action( 'init', 'da_load_module_examples' );
|
||||
|
||||
/* Define a custom field for select DA images */
|
||||
function da_select_img( $name, $value, $field ) {
|
||||
$args = array(
|
||||
'post_type' => 'da_image',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => -1
|
||||
);
|
||||
$images = new WP_Query($args);
|
||||
|
||||
if ( $images->have_posts() ) {
|
||||
echo '<select name="' . $name . '">';
|
||||
echo '<option value="">Select an image</option>';
|
||||
while ( $images->have_posts() ) { $images->the_post();
|
||||
$selected = $value == get_the_id() ? 'selected ' : '';
|
||||
echo '<option ' . $selected . 'value="' . get_the_id() . '">' . get_the_title() . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
}
|
||||
add_action( 'fl_builder_control_select-img', 'da_select_img', 1, 3 );
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This is an example module with only the basic
|
||||
* setup necessary to get it working.
|
||||
*
|
||||
* @class DrawAttentionModule
|
||||
*/
|
||||
class DrawAttentionModule extends FLBuilderModule {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(
|
||||
'name' => __('Draw Attention', 'fl-builder'),
|
||||
'description' => __('Show a Draw Attention image', 'fl-builder'),
|
||||
'category' => __('Advanced Modules', 'fl-builder'),
|
||||
'dir' => FL_MODULE_DA_DIR . 'da/',
|
||||
'url' => FL_MODULE_DA_URL . 'da/',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the module and its form settings.
|
||||
*/
|
||||
FLBuilder::register_module('DrawAttentionModule', array(
|
||||
'general' => array( // Tab
|
||||
'title' => __('General', 'fl-builder'), // Tab title
|
||||
'sections' => array( // Tab Sections
|
||||
'general' => array( // Section
|
||||
'title' => __('Section Title', 'fl-builder'), // Section Title
|
||||
'fields' => array( // Section Fields
|
||||
'da_img' => array(
|
||||
'type' => 'select-img',
|
||||
'label' => __('Draw Attention Image', 'fl-builder'),
|
||||
'help' => 'Select a Draw Attention image to be displayed',
|
||||
'default' => '',
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="fl-draw-attention">
|
||||
<?php echo do_shortcode( '[drawattention ID=' . $settings->da_img . ']' ); ?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user