| 1 |
<?php |
| 2 |
|
| 3 |
defined('ABSPATH') || exit; |
| 4 |
|
| 5 |
/** |
| 6 |
* Module Name: Testimonial Posts |
| 7 |
* Description: Display testimonial custom post type |
| 8 |
*/ |
| 9 |
class TB_Testimonial_Module extends Themify_Builder_Component_Module {//deprecated |
| 10 |
const SLUG='testimonial'; |
| 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_testimonial_posts')) { |
| 14 |
add_shortcode('themify_testimonial_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 __('Testimonial Posts', 'themify'); |
| 21 |
} |
| 22 |
|
| 23 |
public static function get_module_icon():string { |
| 24 |
return 'clipboard'; |
| 25 |
} |
| 26 |
|
| 27 |
public static function get_js_css():array { |
| 28 |
return array( |
| 29 |
'css' => 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 |
// Testimonial 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 |
// Testimonial Author Name |
| 52 |
array( |
| 53 |
'name' => '_testimonial_name', |
| 54 |
'title' => __('Testimonial Author Name', 'themify'), |
| 55 |
'description' => '', |
| 56 |
'type' => 'textbox', |
| 57 |
'meta' => array() |
| 58 |
), |
| 59 |
// Testimonial Author Link |
| 60 |
array( |
| 61 |
'name' => '_testimonial_link', |
| 62 |
'title' => __('Testimonial Author Link', 'themify'), |
| 63 |
'description' => '', |
| 64 |
'type' => 'textbox', |
| 65 |
'meta' => array() |
| 66 |
), |
| 67 |
// Testimonial Author Company |
| 68 |
array( |
| 69 |
'name' => '_testimonial_company', |
| 70 |
'title' => __('Testimonial Author Company', 'themify'), |
| 71 |
'description' => '', |
| 72 |
'type' => 'textbox', |
| 73 |
'meta' => array() |
| 74 |
), |
| 75 |
// Testimonial Author Position |
| 76 |
array( |
| 77 |
'name' => '_testimonial_position', |
| 78 |
'title' => __('Testimonial Author Position', 'themify'), |
| 79 |
'description' => '', |
| 80 |
'type' => 'textbox', |
| 81 |
'meta' => array() |
| 82 |
) |
| 83 |
); |
| 84 |
} |
| 85 |
|
| 86 |
public static function do_shortcode($atts) { |
| 87 |
|
| 88 |
$atts = shortcode_atts(array( |
| 89 |
'id' => '', |
| 90 |
'title' => 'no', // no |
| 91 |
'image' => 'yes', // no |
| 92 |
'image_w' => 80, |
| 93 |
'image_h' => 80, |
| 94 |
'display' => 'content', // excerpt, none |
| 95 |
'more_link' => false, // true goes to post type archive, and admits custom link |
| 96 |
'more_text' => __('More →', 'themify'), |
| 97 |
'limit' => 4, |
| 98 |
'category' => 0, // integer category ID |
| 99 |
'order' => 'DESC', // ASC |
| 100 |
'orderby' => 'date', // title, rand |
| 101 |
'style' => 'grid2', // grid3, grid4, list-post |
| 102 |
'show_author' => 'yes', // no |
| 103 |
'section_link' => false // true goes to post type archive, and admits custom link |
| 104 |
), $atts); |
| 105 |
|
| 106 |
$module = array( |
| 107 |
'module_ID' => self::SLUG.'-' . rand(0, 10000), |
| 108 |
'mod_name' => self::SLUG, |
| 109 |
'mod_settings' => array( |
| 110 |
'mod_title_testimonial' => '', |
| 111 |
'layout_testimonial' => $atts['style'], |
| 112 |
'category_testimonial' => $atts['category'], |
| 113 |
'post_per_page_testimonial' => $atts['limit'], |
| 114 |
'offset_testimonial' => '', |
| 115 |
'order_testimonial' => $atts['order'], |
| 116 |
'orderby_testimonial' => $atts['orderby'], |
| 117 |
'display_testimonial' => $atts['display'], |
| 118 |
'hide_feat_img_testimonial' => '', |
| 119 |
'image_size_testimonial' => '', |
| 120 |
'img_width_testimonial' => $atts['image_w'], |
| 121 |
'img_height_testimonial' => $atts['image_h'], |
| 122 |
'unlink_feat_img_testimonial' => 'no', |
| 123 |
'hide_post_title_testimonial' => $atts['title'] === 'yes' ? 'no' : 'yes', |
| 124 |
'unlink_post_title_testimonial' => 'no', |
| 125 |
'hide_post_date_testimonial' => 'no', |
| 126 |
'hide_post_meta_testimonial' => 'no', |
| 127 |
'hide_page_nav_testimonial' => 'yes', |
| 128 |
'animation_effect' => '', |
| 129 |
'css_testimonial' => '' |
| 130 |
) |
| 131 |
); |
| 132 |
|
| 133 |
return self::retrieve_template('template-blog.php', $module, THEMIFY_BUILDER_TEMPLATES_DIR, '', false); |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Render plain content for static content. |
| 138 |
* |
| 139 |
* @param array $module |
| 140 |
* @return string |
| 141 |
*/ |
| 142 |
public static function get_static_content(array $module):string { |
| 143 |
return ''; // no static content for dynamic content |
| 144 |
} |
| 145 |
|
| 146 |
public static function get_translatable_text_fields( $module ) : array { |
| 147 |
return [ 'mod_title_testimonial' ]; |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
/////////////////////////////////////// |
| 152 |
// Module Options |
| 153 |
/////////////////////////////////////// |
| 154 |
|
| 155 |
TB_Testimonial_Module::init(); //deprecated |
| 156 |
|