PluginProbe
Link Library / trunk
Link Library vtrunk
7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 6.0-Beta11 6.0-Beta12 6.0-Beta2 6.0-Beta3 6.0-Beta4 6.0-Beta5 6.0-Beta6 6.0-Beta7 6.0-Beta8 6.0-Beta9 6.6.8 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.1.9 7.2.0 All 135 releases
link-library / linkpopup.php

linkpopup.php in Link Library trunk, at linkpopup.php

306 lines 14.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function link_library_popup_content( $my_link_library_plugin ) {
4 if ( isset( $_GET['linkid'] ) && isset( $_GET['settings'] ) ) {
5 $link_id = intval( $_GET['linkid'] );
6 $settings_id = intval( $_GET['settings'] );
7 $settings_id = link_library_validate_settings_number( $settings_id );
8 } else {
9 wp_die();
10 }
11
12 $link_data = get_post( $link_id );
13
14 if ( !empty( $link_data ) && 'link_library_links' == $link_data->post_type && 'publish' == $link_data->post_status ) {
15 $options = get_option( 'LinkLibraryPP' . $settings_id );
16 $generaloptions = get_option( 'LinkLibraryGeneral' );
17 $generaloptions = wp_parse_args( $generaloptions, ll_reset_gen_settings( 'return' ) );
18
19 $link_categories = wp_get_post_terms( get_the_ID(), $generaloptions['cattaxonomy'] );
20
21 if ( !empty( $options['categorylist_cpt'] ) ) {
22 $link_categories_to_display_array = explode( ',', $options['categorylist_cpt'] );
23
24 $link_categories_id_array = [];
25 foreach ( $link_categories as $link_category ) {
26 $link_categories_id_array[] = $link_category->term_id;
27 }
28
29 if ( empty( array_intersect( $link_categories_id_array, $link_categories_to_display_array ) ) ) {
30 wp_die();
31 }
32 }
33
34 $link_url = get_post_meta( $link_id, 'link_url', true );
35 $link_second_url = get_post_meta( $link_id, 'link_second_url', true );
36 $link_description = get_post_meta( $link_id, 'link_description', true );
37 $link_no_follow = get_post_meta( $link_id, 'link_no_follow', true );
38 $link_target = get_post_meta( $link_id, 'link_target', true );
39 $link_image = get_post_meta( $link_id, 'link_image', true );
40 $link_featured = get_post_meta( $link_id, 'link_featured', true );
41 $link_textfield = get_post_meta( $link_id, 'link_textfield', true );
42 $link_telephone = get_post_meta( $link_id, 'link_telephone', true );
43 $link_email = get_post_meta( $link_id, 'link_email', true );
44 $link_visits = get_post_meta( $link_id, 'link_visits', true );
45 $link_submitter_name = get_post_meta( $link_id, 'link_submitter_name', true );
46 $link_rating = get_post_meta( $link_id, 'link_rating', true );
47 $link_rss = get_post_meta( $link_id, 'link_rss', true );
48
49 $the_link = '#';
50 if ( !empty( $link_url ) ) {
51 $the_link = esc_html( $link_url );
52 }
53
54 $the_second_link = '#';
55 if ( !empty( $link_second_url ) ) {
56 $the_second_link = esc_html( $link_second_url );
57 }
58
59 $cleanname = esc_html( $link_data->post_name, ENT_QUOTES );
60
61 $name = $cleanname;
62
63 $alt = ' alt="' . $cleanname . '"';
64
65 $title = esc_html( $link_description, ENT_QUOTES );
66
67 if ('' != $title)
68 $title = ' title="' . $title . '"';
69
70 $rel = '';
71 if ( ( $options['nofollow'] || $link_no_follow ) ) {
72 $rel = ' rel="nofollow"';
73 }
74
75 $target = $link_target;
76 if ( !empty( $target ) ) {
77 $target = ' target="' . $target . '"';
78 } else {
79 $target = $options['linktarget'];
80 if ( !empty( $target ) )
81 $target = ' target="' . $target . '"';
82 }
83
84 $popup_text = ( !empty( $options['link_popup_text'] ) ? stripslashes($options['link_popup_text']) : __( '%link_image%<br />Click through to visit %link_name%.', 'link-library') );
85
86 if ( ( strpos( $popup_text, '%link_image%' ) !== false ) && !empty( $link_image ) ) {
87 $imageoutput = '<a href="';
88
89 if ( 'primary' == $options['sourceimage'] || empty( $options['sourceimage'] ) ) {
90 $imageoutput .= $the_link;
91 } elseif ( 'secondary' == $options['sourceimage'] ) {
92 $imageoutput .= $the_second_link;
93 }
94
95 $imageoutput .= '" id="link-' . $link_data->ID . '" class="track_this_link ' . ( $link_featured ? 'featured' : '' ). '" ' . $rel . $title . $target. '>';
96
97 if ( $options['usethumbshotsforimages'] ) {
98 $protocol = is_ssl() ? 'https://' : 'http://';
99
100 if ( $generaloptions['thumbnailgenerator'] == 'robothumb' ) {
101 $imageoutput .= '<img src="' . $protocol . 'www.robothumb.com/src/?url=' . $the_link . '&size=' . $generaloptions['thumbnailsize'] . '"';
102 } elseif ( $generaloptions['thumbnailgenerator'] == 'thumbshots' ) {
103 if ( !empty( $generaloptions['thumbshotscid'] ) ) {
104 $imageoutput .= '<img src="' . $protocol . 'images.thumbshots.com/image.aspx?cid=' . rawurlencode( $generaloptions['thumbshotscid'] ) . '&v=1&w=120&url=' . $the_link . '"';
105 }
106 } elseif ( $generaloptions['thumbnailgenerator'] == 'pagepeeker' ) {
107 if ( empty( $pagepeekerid ) ) {
108 $imageoutput .= '<img src="' . $protocol . 'free.pagepeeker.com/v2/thumbs.php?size=' . $generaloptions['pagepeekersize'] . '&url=' . $the_link . '"';
109 } else {
110 $imageoutput .= '<img src="' . $protocol . 'api.pagepeeker.com/v2/thumbs.php?size=' . $generaloptions['pagepeekersize'] . '&url=' . $the_link . '"';
111 }
112 } elseif ( 'shrinktheweb' == $generaloptions['thumbnailgenerator'] ) {
113 if ( !empty( $shrinkthewebaccesskey ) ) {
114 $imageoutput .= '<img src="' . $protocol . 'images.shrinktheweb.com/xino.php?stwembed=1&stwaccesskeyid=' . rawurlencode( $generaloptions['shrinkthewebaccesskey'] ) . '&stwsize=' . $generaloptions['stwthumbnailsize'] . '&stwurl=' . $the_link . '"';
115 }
116 }
117 } elseif ( strpos( $link_image, 'http' ) !== false ) {
118 $imageoutput .= '<img src="' . $link_image . '"';
119 } else {
120 $imageoutput .= '<img src="' . get_option( 'siteurl' ) . $link_image . '"';
121 }
122
123 $imageoutput .= $alt . $title;
124
125 if ( !empty( $options['imageclass'] ) ) {
126 $imageoutput .= ' class="' . $options['imageclass'] . '" ';
127 }
128
129 $imageoutput .= "/>";
130
131 $imageoutput .= '</a>';
132
133 $popup_text = str_replace( '%link_image%', $imageoutput, $popup_text );
134 } elseif ( ( strpos( $popup_text, '%link_image%' ) !== false ) && empty( $link_image ) ) {
135 $popup_text = str_replace( '%link_image%', '', $popup_text );
136 }
137
138 if ( ( strpos( $popup_text, '%link_name%' ) !== false ) && !empty( $name ) ) {
139 if ( ( 'primary' == $options['sourcename'] && $the_link != '#' ) || ( 'secondary' == $options['sourcename'] && $the_second_link != '#' ) ) {
140 $nameoutput = '<a href="';
141
142 if ( isset( $options['sourcename'] ) && ( 'primary' == $options['sourcename'] || empty( $options['sourcename'] ) ) ) {
143 $nameoutput .= $the_link;
144 } elseif ( isset( $options['sourcename'] ) && 'secondary' == $options['sourcename'] ) {
145 $nameoutput .= $the_second_link;
146 }
147
148 $nameoutput .= '" id="link-' . $link_data->ID . '" class="' . ( ( isset( $enablelinkpopup ) && $enablelinkpopup ) ? 'thickbox' : 'track_this_link' ) . ( $link_featured ? ' featured' : '' ). '" ' . $rel . $title . $target. '>';
149 }
150
151 $nameoutput .= $name;
152
153 if ( ( 'primary' == $options['sourcename'] && $the_link != '#' ) || ( $options['sourcename'] == 'secondary' && $the_second_link != '#' ) ) {
154 $nameoutput .= '</a>';
155 }
156
157 $popup_text = str_replace( '%link_name%', $nameoutput, $popup_text );
158 } elseif ( ( strpos( $popup_text, '%link_name%' ) !== false ) && empty( $name ) ) {
159 $popup_text = str_replace( '%link_name%', '', $popup_text );
160 }
161
162 if ( ( strpos( $popup_text, '%link_url%' ) !== false ) && !empty( $link_url ) ) {
163 $popup_text = str_replace( '%link_url%', $link_url, $popup_text );
164 } elseif ( ( strpos( $popup_text, '%link_url%' ) !== false ) && empty( $link_url ) ) {
165 $popup_text = str_replace( '%link_url%', '', $popup_text );
166 }
167
168 $link_cat_names = '';
169 if ( $link_categories ) {
170 $countcats = 0;
171 foreach ( $link_categories as $link_category ) {
172 if ( $countcats >= 1 ) {
173 $link_cat_names .= ', ';
174 }
175 $link_cat_names .= $link_category->name;
176 $countcats++;
177 }
178 }
179
180 if ( ( strpos( $popup_text, '%link_cat_name%' ) !== false ) && !empty( $link_cat_names ) ) {
181 $popup_text = str_replace( '%link_cat_name%', $link_cat_names, $popup_text );
182 } elseif ( ( strpos( $popup_text, '%link_cat_name%' ) !== false ) && empty( $link_cat_names ) ) {
183 $popup_text = str_replace( '%link_cat_name%', '', $popup_text );
184 }
185
186 /* if ( ( strpos( $popup_text, '%link_cat_desc%' ) !== false ) && !empty( $link_description ) ) {
187 $cleandesc = str_replace('[', '<', $linkitem['description']);
188 $cleandesc = str_replace(']', '>', $cleandesc);
189
190 $popup_text = str_replace( '%link_cat_desc%', $cleandesc, $popup_text );
191 } elseif ( ( strpos( $popup_text, '%link_cat_desc%' ) !== false ) && empty( $linkitem['description'] ) ) {
192 $popup_text = str_replace( '%link_cat_desc%', '', $popup_text );
193 } */
194
195 if ( ( strpos ( $popup_text, '%link_desc%' ) !== false ) && !empty( $link_description ) ) {
196 $linkdesc = $link_description;
197 $linkdesc = str_replace('[', '<', $linkdesc);
198 $linkdesc = str_replace(']', '>', $linkdesc);
199
200 $popup_text = str_replace( '%link_desc%', $linkdesc, $popup_text );
201 } elseif ( ( strpos( $popup_text, '%link_desc%' ) !== false ) && empty( $link_description ) ) {
202 $popup_text = str_replace( '%link_desc%', '', $popup_text );
203 }
204
205 if ( ( strpos ( $popup_text, '%link_large_desc%' ) !== false ) && !empty( $link_textfield ) ) {
206 $linklargedesc = stripslashes( $link_textfield );
207 $linklargedesc = str_replace('[', '<', $linklargedesc);
208 $linklargedesc = str_replace(']', '>', $linklargedesc);
209
210 $popup_text = str_replace( '%link_large_desc%', $linklargedesc, $popup_text );
211 } elseif ( ( strpos( $popup_text, '%link_large_desc%' ) !== false ) && empty( $link_textfield ) ) {
212 $popup_text = str_replace( '%link_large_desc%', '', $popup_text );
213 }
214
215 if ( ( strpos ( $popup_text, '%link_telephone%' ) !== false ) && !empty( $link_telephone ) ) {
216 $linktelephone = stripslashes( $link_telephone );
217
218 $popup_text = str_replace( '%link_telephone%', $linktelephone, $popup_text );
219 } elseif ( ( strpos( $popup_text, '%link_telephone%' ) !== false ) && empty( $link_telephone ) ) {
220 $popup_text = str_replace( '%link_telephone%', '', $popup_text );
221 }
222
223 if ( ( strpos ( $popup_text, '%link_email%' ) !== false ) && !empty( $link_email ) ) {
224 $linkemail = stripslashes( $link_email );
225
226 $popup_text = str_replace( '%link_email%', $linkemail, $popup_text );
227 } elseif ( ( strpos( $popup_text, '%link_email%' ) !== false ) && empty( $link_email ) ) {
228 $popup_text = str_replace( '%link_email%', '', $popup_text );
229 }
230
231 if ( ( strpos ( $popup_text, '%link_email_link%' ) !== false ) && !empty( $linkitem['link_email'] ) ) {
232 $linkemail = stripslashes( $linkitem['link_email'] );
233 if ( strpos ( $linkemail, '@') !== false ) {
234 $linkemail = 'mailto:' . $linkemail;
235 }
236
237 $popup_text = str_replace( '%link_email_link%', $linkemail, $popup_text );
238 } elseif ( ( strpos( $popup_text, '%link_email_link%' ) !== false ) && empty( $linkitem['link_email'] ) ) {
239 $popup_text = str_replace( '%link_email_link%', '', $popup_text );
240 }
241
242 if ( ( strpos ( $popup_text, '%link_alt_web%' ) !== false ) && !empty( $link_second_url ) ) {
243 $linkalturl = stripslashes( esc_html( $link_second_url ) );
244
245 $popup_text = str_replace( '%link_alt_web%', $linkalturl, $popup_text );
246 } elseif ( ( strpos( $popup_text, '%link_alt_web%' ) !== false ) && empty( $link_second_url ) ) {
247 $popup_text = str_replace( '%link_alt_web%', '', $popup_text );
248 }
249
250 if ( ( strpos ( $popup_text, '%link_num_views%' ) !== false ) && !empty( $link_visits ) ) {
251 $linkvisits = stripslashes( $link_visits );
252
253 $popup_text = str_replace( '%link_num_views%', $linkvisits, $popup_text );
254 } elseif ( ( strpos( $popup_text, '%link_num_views%' ) !== false ) && empty( $link_visits ) ) {
255 $popup_text = str_replace( '%link_num_views%', '', $popup_text );
256 }
257
258 if ( ( strpos ( $popup_text, '%link_submitter_name%' ) !== false ) && !empty( $link_submitter_name ) ) {
259 $linksubmitter = stripslashes( $link_submitter_name );
260
261 $popup_text = str_replace( '%link_submitter_name%', $linksubmitter, $popup_text );
262 } elseif ( ( strpos( $popup_text, '%link_submitter_name%' ) !== false ) && empty( $link_submitter_name ) ) {
263 $popup_text = str_replace( '%link_submitter_name%', '', $popup_text );
264 }
265
266 if ( ( strpos ( $popup_text, '%link_rating%' ) !== false ) && !empty( $link_rating ) ) {
267 $linksubmitter = stripslashes( $link_rating );
268
269 $popup_text = str_replace( '%link_rating%', $linksubmitter, $popup_text );
270 } elseif ( ( strpos( $popup_text, '%link_rating%' ) !== false ) && empty( $link_rating ) ) {
271 $popup_text = str_replace( '%link_rating%', '', $popup_text );
272 }
273
274 if ( ( strpos ( $popup_text, '%link_rss%' ) !== false ) && !empty( $link_rss ) ) {
275 $linksubmitter = stripslashes( $link_rss );
276
277 $popup_text = str_replace( '%link_rss%', $linksubmitter, $popup_text );
278 } elseif ( ( strpos( $popup_text, '%link_rss%' ) !== false ) && empty( $link_rss ) ) {
279 $popup_text = str_replace( '%link_rss%', '', $popup_text );
280 }
281
282 $postshortcode_popup_text = apply_filters( 'the_content', $popup_text );
283 echo '<div class="linkpopup">' . esc_html( $postshortcode_popup_text ) . '</div>';
284
285 $xpath = $my_link_library_plugin->relativePath( dirname( __FILE__ ), ABSPATH );
286
287 $track_code = "<script type='text/javascript'>\n";
288 $track_code .= "jQuery(document).ready(function()\n";
289 $track_code .= "{\n";
290 $track_code .= "jQuery('a.track_this_link').click(function() {\n";
291 $track_code .= "linkid = this.id;\n";
292 $track_code .= "linkid = linkid.substring(5);";
293 $track_code .= "path = '" . $xpath . "';";
294 $track_code .= "jQuery.post('" . WP_PLUGIN_URL . "/link-library/tracker.php', {id:linkid, xpath:path});\n";
295 $track_code .= "return true;\n";
296 $track_code .= "});\n";
297 $track_code .= "});\n";
298 $track_code .= "</script>";
299
300 echo esc_html( $track_code );
301 }
302
303 exit;
304 }
305
306