/** * Callback function on WordPress' `template_include` filter hook. This function looks for a template within * the theme for handling the current page's output. If no template is found, it falls back to a default * `board.php` template within the plugin. * * @since 1.0.0 * @access public * @param string $template * @return string */ function mb_template_include($template) { /* If not viewing a message board page, bail. */ if (!mb_is_message_board()) { return $template; } /* Set up some default variables. */ $hierarchy = mb_get_template_hierarchy(); $theme_dir = mb_get_theme_template_folder(); $plugin_dir = mb_get_plugin_template_folder(); $_templates = array(); foreach ($hierarchy as $hier) { $_templates[] = "{$theme_dir}/{$hier}"; } /* Check to see if we can find one of our templates. */ $has_template = locate_template($_templates); /* Allow devs to overwrite template. */ $has_template = apply_filters('mb_template_include', $has_template, $theme_dir); /* If we have a template return it. */ if ($has_template) { return $has_template; } /* Load our fallback if nothing is found at this point. */ require_once "{$plugin_dir}/board.php"; return ''; }
/** * Filter on `breadcrumb_trail_object`. This filter returns a custom object if viewing a page from * the Message Board plugin. * * @since 1.0.0 * @access public * @param object|null $breadcrumb * @param array $args * @return object|null */ function mb_breadcrumb_trail_object($breadcrumb, $args) { return mb_is_message_board() ? new MB_Breadcrumb_Trail($args) : $breadcrumb; }
/** * Filters the edit user link for front-end editing. * * @since 1.0.0 * @access public * @param string $url * @param int $post_id */ function mb_get_edit_user_link_filter($url, $user_id) { if (is_admin() || !mb_is_message_board()) { return $url; } return add_query_arg(array('mb_action' => 'edit', 'user_id' => $user_id), mb_get_board_home_url()); }