PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 148
Lasso Lite – Affiliate Link Manager & Product Displays v148
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 148, at classes/class-shortcode.php

110 lines 2.5 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 const AAWP_SUPPORT_FIELDS_VALUE = array(
21 'title',
22 'image',
23 'thumb',
24 'button',
25 'price',
26 'list_price',
27 'amount_saved',
28 'percentage_saved',
29 'rating',
30 'star_rating',
31 'description',
32 'reviews',
33 'url',
34 'link',
35 'last_update',
36 );
37
38 /**
39 * Lasso Display Boxes
40 *
41 * @param array $attr Attributes of shortcode.
42 */
43 public function lasso_lite_core_shortcode( $attr ) {
44 $post_id = $attr['id'] ?? '';
45 $title = $attr['title'] ?? '';
46 $title_url = $attr['title_url'] ?? '';
47 $title_type = $attr['title_type'] ?? '';
48 $description = $attr['description'] ?? '';
49 $badge = $attr['badge'] ?? '';
50 $price = $attr['price'] ?? '';
51 $primary_url = $attr['primary_url'] ?? '';
52 $primary_text = $attr['primary_text'] ?? '';
53 $image_url = $attr['image_url'] ?? '';
54 $anchor_id = $attr['anchor_id'] ?? '';
55 $brag = $attr['brag'] ?? '';
56
57 if ( empty( $anchor_id ) ) {
58 $unique_id = $post_id;
59 $anchor_id = 'lasso-lite-anchor-id-' . $unique_id;
60 }
61
62 // ? Lasso Lite must be having "id" parameter
63 if ( ! $post_id ) {
64 return false;
65 }
66
67 $post = get_post( $post_id );
68 // ? Check existing post
69 if ( is_null( $post ) ) {
70 return false;
71 }
72
73 // ? Check case Lasso Lite deleted
74 if ( 'trash' === $post->post_status ) {
75 return false;
76 }
77
78 // ? Check post_type is Lasso Lite or not
79 if ( SIMPLE_URLS_SLUG !== $post->post_type ) {
80 if ( class_exists( 'Lasso_Shortcode' ) ) {
81 $shortcode_pro = new Lasso_Shortcode();
82 return $shortcode_pro->lasso_core_shortcode( $attr );
83 }
84 return false;
85 }
86
87 // ? Check post_type surl to execute shortcode correctly
88 if ( SIMPLE_URLS_SLUG === $post->post_type ) {
89 $pass_data = array(
90 'post' => $post,
91 'title' => $title,
92 'title_type' => $title_type,
93 'title_url' => $title_url,
94 'description' => $description,
95 'badge' => $badge,
96 'price' => $price,
97 'primary_url' => $primary_url,
98 'primary_text' => $primary_text,
99 'image_url' => $image_url,
100 'anchor_id' => $anchor_id,
101 'brag' => $brag,
102 );
103 // ? Default single-style display box
104 return Helper::include_with_variables( Helper::get_path_views_folder() . 'displays/single.php', $pass_data );
105 }
106
107 return false;
108 }
109 }
110