PluginProbe
Related Posts By PickPlugins / trunk
Related Posts By PickPlugins vtrunk
trunk 1.0 1.1 1.2 2.0.0 2.0.1 2.0.10 2.0.11 2.0.14 2.0.16 2.0.17 2.0.18 2.0.19 2.0.2 2.0.20 2.0.21 2.0.22 2.0.23 2.0.24 2.0.25 2.0.26 2.0.27 2.0.28 2.0.29 2.0.30 All 60 releases
related-post / includes / shortcodes.php

shortcodes.php in Related Posts By PickPlugins trunk, at includes/shortcodes.php

65 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4
5
6 if (!defined('ABSPATH')) exit; // if direct access
7
8
9 add_shortcode('related_post', 'related_post_display');
10
11 function related_post_display($atts, $content = null)
12 {
13
14 $atts = shortcode_atts(
15 array(
16 'post_id' => "",
17 'post_ids' => "",
18 'headline' => "",
19 'view_type' => "",
20 ),
21 $atts
22 );
23
24 $related_post_settings = get_option('related_post_settings');
25
26 $post_id = isset($atts['post_id']) ? (int) $atts['post_id'] : get_the_ID();
27 $related_post_enable = get_post_meta($post_id, 'related_post_enable', true);
28
29 if ($related_post_enable == 'yes') return false;
30
31 $post_type = get_post_type($post_id);
32
33 $atts['settings'] = $related_post_settings;
34 $atts['post_type'] = $post_type;
35
36 $atts = apply_filters('related_post_atts', $atts);
37
38 $view_type = isset($atts['view_type']) ? esc_html($atts['view_type']) : 'grid';
39 $layout_type = !empty($view_type) ? $view_type : esc_html($related_post_settings['layout_type']);
40
41
42
43 require_once(related_post_plugin_dir . 'templates/related-post-hook.php');
44
45
46
47
48
49 ob_start();
50
51 ?>
52 <div class="related-post <?php echo esc_attr($layout_type); ?>">
53 <?php
54
55 do_action('related_post_main', $atts);
56
57 ?>
58 </div>
59 <?php
60
61
62
63 return ob_get_clean();
64 }
65