PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 110
Lasso Lite – Affiliate Link Manager & Product Displays v110
157 155 156 154 153 152 151 150 149 148 trunk 0.9.9 104 105 106 107 108 109 110 111 112 113 114 115 116 All 56 releases
simple-urls / classes / class-shortcode.php

class-shortcode.php in Lasso Lite – Affiliate Link Manager & Product Displays 110, at classes/class-shortcode.php

93 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Declare class Shortcode
4 *
5 * @package Page
6 */
7
8 namespace LassoLite\Classes;
9
10 use LassoLite\Classes\Helper;
11 use LassoLite\Classes\Setting;
12 use Lasso_Shortcode;
13
14 /**
15 * Shortcode
16 */
17 class Shortcode {
18
19 const LASSO_PRO_POST_TYPE = 'lasso-urls';
20
21 /**
22 * Lasso Display Boxes
23 *
24 * @param array $attr Attributes of shortcode.
25 */
26 public function lasso_lite_core_shortcode( $attr ) {
27 $post_id = $attr['id'] ?? '';
28 $title = $attr['title'] ?? '';
29 $title_url = $attr['title_url'] ?? '';
30 $title_type = $attr['title_type'] ?? '';
31 $description = $attr['description'] ?? '';
32 $badge = $attr['badge'] ?? '';
33 $price = $attr['price'] ?? '';
34 $primary_url = $attr['primary_url'] ?? '';
35 $primary_text = $attr['primary_text'] ?? '';
36 $image_url = $attr['image_url'] ?? '';
37 $anchor_id = $attr['anchor_id'] ?? '';
38 $brag = $attr['brag'] ?? '';
39
40 if ( empty( $anchor_id ) ) {
41 $unique_id = $post_id;
42 $anchor_id = 'lasso-lite-anchor-id-' . $unique_id;
43 }
44
45 // ? Lasso Lite must be having "id" parameter
46 if ( ! $post_id ) {
47 return false;
48 }
49
50 $post = get_post( $post_id );
51 // ? Check existing post
52 if ( is_null( $post ) ) {
53 return false;
54 }
55
56 // ? Check case Lasso Lite deleted
57 if ( 'trash' === $post->post_status ) {
58 return false;
59 }
60
61 // ? Check post_type is Lasso Lite or not
62 if ( SIMPLE_URLS_SLUG !== $post->post_type ) {
63 if ( class_exists( 'Lasso_Shortcode' ) ) {
64 $shortcode_pro = new Lasso_Shortcode();
65 return $shortcode_pro->lasso_core_shortcode( $attr );
66 }
67 return false;
68 }
69
70 // ? Check post_type surl to execute shortcode correctly
71 if ( SIMPLE_URLS_SLUG === $post->post_type ) {
72 $pass_data = array(
73 'post' => $post,
74 'title' => $title,
75 'title_type' => $title_type,
76 'title_url' => $title_url,
77 'description' => $description,
78 'badge' => $badge,
79 'price' => $price,
80 'primary_url' => $primary_url,
81 'primary_text' => $primary_text,
82 'image_url' => $image_url,
83 'anchor_id' => $anchor_id,
84 'brag' => $brag,
85 );
86 // ? Default single-style display box
87 return Helper::include_with_variables( Helper::get_path_views_folder() . 'displays/single.php', $pass_data );
88 }
89
90 return false;
91 }
92 }
93