public function __construct() { $module = wma_bb_get_custom_module_slug(__FILE__); parent::__construct(apply_filters('wmhook_wmamp_' . 'bb_module_construct_' . $module, wma_bb_shortcode_def($module, 'register'))); }
function wma_bb_custom_module_output($module, $settings = array()) { //Requirements check if (!is_object($module) || !isset($module->slug)) { return; } //Helper variables $shortcode_output = $replace_children = ''; /** * Removing 'wm_' (string length = 3) from the beginning * of the custom module file name slug. */ $module = substr($module->slug, 3); $output = array('parent' => (string) wma_bb_shortcode_def($module, 'output'), 'child' => (string) wma_bb_shortcode_def($module, 'output_children')); $params = array('parent' => (array) wma_bb_shortcode_def($module, 'params'), 'child' => (array) wma_bb_shortcode_def($module, 'params_children')); $children = isset($settings->children) ? array_filter($settings->children) : false; //Preparing output /** * Basic form output (parent) */ foreach ($params['parent'] as $param) { $replace = ''; $param = trim($param); if ($param) { if (isset($settings->{$param}) && !empty($settings->{$param})) { $value = $settings->{$param}; //Convert the array shortcode parameter to string if (is_array($value)) { $value = implode(',', $value); } $replace = 'content' === $param ? $value : ' ' . $param . '="' . $value . '"'; $replace = apply_filters('wmhook_shortcode_wma_bb_custom_module_output_parent_replace', $replace, $module, $param, $settings); } $output['parent'] = str_replace('{{' . $param . '}}', $replace, $output['parent']); } } // /foreach /** * Items form output (children) */ if (is_array($children) && !empty($children) && !empty($params['child'])) { foreach ($children as $child) { //Requirements check if (!is_object($child) || empty($child)) { continue; } $replace_child = $output['child']; foreach ($params['child'] as $param) { $replace = ''; $param = trim($param); if ($param) { if (isset($child->{$param}) && !empty($child->{$param})) { $value = $child->{$param}; //Convert the array shortcode parameter to string if (is_array($value)) { $value = implode(',', $value); } $replace = 'content' === $param ? $value : ' ' . $param . '="' . $value . '"'; $replace = apply_filters('wmhook_shortcode_wma_bb_custom_module_output_child_replace', $replace, $module, $param, $child, $settings); } $replace_child = str_replace('{{' . $param . '}}', $replace, $replace_child); } } // /foreach $replace_children .= $replace_child; } // /foreach } /** * Actual outputted shortcode */ $shortcode_output = str_replace(array('{{children}}', '{{items}}'), $replace_children, $output['parent']); $shortcode_output = apply_filters('wmhook_shortcode_wma_bb_custom_module_output', $shortcode_output, $module, $settings); //Output echo $shortcode_output; }