PluginProbe
Themify Builder / 7.6.2
Themify Builder v7.6.2
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / modules / module-gallery.php

module-gallery.php in Themify Builder 7.6.2, at modules/module-gallery.php

73 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined('ABSPATH') || exit;
4
5 /**
6 * Module Name: Gallery
7 * Description: Display WP Gallery Images
8 */
9 class TB_Gallery_Module extends Themify_Builder_Component_Module {
10
11 public static function init():void {
12 if(themify_is_ajax()){
13 add_action('wp_ajax_tb_gallery_lightbox_data', array(__CLASS__, 'gallery_lightbox_data'));
14 }
15 }
16
17 public static function get_module_name():string {
18 return __('Gallery', 'themify');
19 }
20
21 public static function get_js_css():array {
22 return array(
23 'css' => 1,
24 'js' => 1
25 );
26 }
27
28 public static function gallery_lightbox_data():void{
29 check_ajax_referer('tf_nonce', 'nonce');
30 if (!empty($_POST['bid']) && !empty($_POST['url']) && is_numeric($_POST['bid']) && Themify_Access_Role::check_access_frontend($_POST['bid'])) {
31 $post = get_post(themify_get_attachment_id_from_url(sanitize_url($_POST['url'])));
32 $res=array();
33 if(!empty($post)){
34 $res=array(
35 'title'=>$post->post_title,
36 'caption'=>$post->post_excerpt
37 );
38 }
39 wp_send_json_success($res);
40 }
41 wp_die();
42 }
43
44
45
46 /**
47 * Render plain content for static content.
48 *
49 * @param array $module
50 * @return string
51 */
52 public static function get_static_content(array $module):string {
53 $mod_settings= $module['mod_settings']+array(
54 'mod_title_gallery' => '',
55 'shortcode_gallery' => ''
56 );
57 $text = '' !== $mod_settings['mod_title_gallery'] ? sprintf('<h3>%s</h3>', $mod_settings['mod_title_gallery']) : '';
58 return $text.$mod_settings['shortcode_gallery'];
59 }
60
61 public static function get_styling_image_fields() : array {
62 return [
63 'background_image' => ''
64 ];
65 }
66
67 public static function get_translatable_text_fields( $module ) : array {
68 return [ 'mod_title_gallery' ];
69 }
70 }
71
72 TB_Gallery_Module::init();
73