PluginProbe
Themify Builder / trunk
Themify Builder vtrunk
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-highlight.php

module-highlight.php in Themify Builder trunk, at modules/module-highlight.php

120 lines 4.3 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: Highlight
7 * Description: Display highlight custom post type
8 */
9 class TB_Highlight_Module extends Themify_Builder_Component_Module {//deprecated
10 const SLUG='highlight';
11 public static function init():void {
12 add_filter('themify_metabox/fields/themify-meta-boxes', array(__CLASS__, 'cpt_meta_boxes'), 100); // requires low priority so that it loads after theme's metaboxes
13 if (!shortcode_exists('themify_highlight_posts')) {
14 add_shortcode('themify_highlight_posts', array(__CLASS__, 'do_shortcode'));
15 }
16 }
17
18 public static function get_module_name():string {
19 add_filter( 'themify_builder_active_vars', [ __CLASS__, 'builder_active_enqueue' ] );
20 return __('Highlight', 'themify');
21 }
22
23 public static function get_module_icon():string {
24 return 'view-list-alt';
25 }
26
27 public static function get_js_css():array {
28 return array(
29 'css' => array('post' => 'post', self::SLUG => 1)
30 );
31 }
32
33 public static function get_json_file():array{
34 return ['f'=>THEMIFY_BUILDER_URI.'/json/'.self::SLUG.'.json','v'=>THEMIFY_VERSION];
35 }
36
37 public static function builder_active_enqueue(array $vars ):array {
38 $vars['addons'][THEMIFY_BUILDER_URI . '/js/editor/deprecated/'.self::SLUG.'.js']=THEMIFY_VERSION;
39 return $vars;
40 }
41
42 public static function get_metabox() {
43 // Highlight Meta Box Options
44 return array(
45 // Featured Image Size
46 Themify_Builder_Model::$featured_image_size,
47 // Image Width
48 Themify_Builder_Model::$image_width,
49 // Image Height
50 Themify_Builder_Model::$image_height,
51 // External Link
52 Themify_Builder_Model::$external_link,
53 // Lightbox Link
54 Themify_Builder_Model::$lightbox_link
55 );
56 }
57
58 public static function do_shortcode($atts) {
59 $atts = shortcode_atts(array(
60 'id' => '',
61 'title' => 'yes', // no
62 'image' => 'yes', // no
63 'image_w' => 68,
64 'image_h' => 68,
65 'display' => 'content', // excerpt, none
66 'more_link' => false, // true goes to post type archive, and admits custom link
67 'more_text' => __('More &rarr;', 'themify'),
68 'limit' => 6,
69 'category' => 0, // integer category ID
70 'order' => 'DESC', // ASC
71 'orderby' => 'date', // title, rand
72 'style' => 'grid3', // grid4, grid2, list-post
73 'section_link' => false // true goes to post type archive, and admits custom link
74 ), $atts);
75
76 $module = array(
77 'module_ID' => self::SLUG.'-' . rand(0, 10000),
78 'mod_name' => self::SLUG,
79 'mod_settings' => array(
80 'mod_title_highlight' => '',
81 'layout_highlight' => $atts['style'],
82 'category_highlight' => $atts['category'],
83 'post_per_page_highlight' => $atts['limit'],
84 'offset_highlight' => '',
85 'order_highlight' => $atts['order'],
86 'orderby_highlight' => $atts['orderby'],
87 'display_highlight' => $atts['display'],
88 'hide_feat_img_highlight' => $atts['image'] === 'yes' ? 'no' : 'yes',
89 'image_size_highlight' => '',
90 'img_width_highlight' => $atts['image_w'],
91 'img_height_highlight' => $atts['image_h'],
92 'hide_post_title_highlight' => $atts['title'] === 'yes' ? 'no' : 'yes',
93 'hide_post_date_highlight' => '',
94 'hide_post_meta_highlight' => '',
95 'hide_page_nav_highlight' => 'yes',
96 'animation_effect' => '',
97 'css_highlight' => ''
98 )
99 );
100
101 return self::retrieve_template('template-blog.php', $module, THEMIFY_BUILDER_TEMPLATES_DIR, '', false);
102 }
103
104
105
106 /**
107 * Render plain content for static content.
108 *
109 * @param array $module
110 * @return string
111 */
112 public static function get_static_content(array $module):string {
113 return ''; // no static content for dynamic content
114 }
115
116 public static function get_translatable_text_fields( $module ) : array {
117 return [ 'mod_title_highlight' ];
118 }
119 }
120 TB_Highlight_Module::init();