/** * Get other templates (e.g. product attributes) passing attributes and including the file. * * @access public * * @param string $template_name * @param array $args (default: array()) * @param string $template_path (default: '') * @param string $default_path (default: '') * * @return void */ function rp4wp_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { // Manager Template $manager_template = new RP4WP_Manager_Template(); // Load the template output $manager_template->get_template($template_name, $args, $template_path, $default_path); }
/** * Load component template * * @param $component * @param $related_post * @param $excerpt_length * @param string $parent */ public function load_component_template($component, $related_post, $excerpt_length, $parent) { $manager_template = new RP4WP_Manager_Template(); echo '<div class="rp4wp_component rp4wp_component_' . $component->type . ' rp4wp_component_' . $component->id . '">'; $manager_template->get_template('components/' . $component->type . '.php', array('related_post' => $related_post, 'excerpt_length' => $excerpt_length, 'custom' => isset($component->custom) ? $component->custom : '', 'parent' => $parent)); echo '</div>'; }
<?php if ('' != $heading_text) { $heading = "<h3>" . $heading_text . "</h3>"; echo apply_filters('rp4wp_heading', $heading); } ?> <ul class="rp4wp-posts-list"> <?php global $post; $o_post = $post; $row_counter = 0; foreach ($related_posts as $post) { // Setup the postdata setup_postdata($post); // Load the content template $manager_template = new RP4WP_Manager_Template(); $manager_template->get_template('related-post-default.php', array('related_post' => $post, 'excerpt_length' => $excerpt_length, 'row_counter' => $row_counter, 'parent' => $o_post)); $row_counter++; } $post = $o_post; wp_reset_postdata(); ?> </ul> <?php if ('1' == RP4WP()->settings['misc']->get_option('show_love')) { // Base $base_url = "https://www.relatedpostsforwp.com"; $query_string = "?"; // Allow affiliates to add affiliate ID to Power By link $ref = apply_filters('rp4wp_poweredby_affiliate_id', ''); if ('' !== $ref) {
/** * Generate the related posts list * * @param int $post_id * @param string $template * @param int $limit * * @return string */ public function generate_related_posts_list($post_id, $template = 'related-posts-default.php', $limit = -1) { // the output $output = ''; // get the post type $post_type = get_post_type($post_id); // The settings object $pt_settings = RP4WP()->settings['general_' . $post_type]; // Post Link Manager $pl_manager = new RP4WP_Post_Link_Manager(); // Get the children $related_posts = $pl_manager->get_children($post_id, array('posts_per_page' => $limit)); // Count if (count($related_posts) > 0) { // Manager Template $manager_template = new RP4WP_Manager_Template(); // Load the template output ob_start(); $manager_template->get_template($template, array('related_posts' => $related_posts, 'heading_text' => $pt_settings->get_option('heading_text'), 'excerpt_length' => $pt_settings->get_option('excerpt_length'), 'post_type' => $post_type)); $output = trim(ob_get_clean()); } return $output; }