PluginProbe
Image Source Control Lite – Show Image Credits and Captions / 1.10
Image Source Control Lite – Show Image Credits and Captions v1.10
3.12.0 3.11.0 trunk 1.1 1.1.1 1.1.2 1.1.2.1 1.1.3 1.10 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.2 1.2.0.1 1.2.0.2 1.2.0.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.4.1 1.3.5 All 110 releases
← All changes | isc.class.php +199 -1282 1.3.51.10 View file →
@@ -1,16 +1,8 @@
1 1 <?php
2 -//avoid direct calls to this file
3 -if (!function_exists('add_action')) {
4 - header('Status: 403 Forbidden');
5 - header('HTTP/1.1 403 Forbidden');
6 - exit();
7 -}
8 2
9 -if (!class_exists('ISC_CLASS')) {
3 +class ISC_Class {
10 4
11 - class ISC_CLASS
12 - {
13 5 /**
14 6 * define default meta fields
15 7 */
16 8 protected $_fields = array(
@@ -17,8 +9,12 @@
17 9 'image_source' => array(
18 10 'id' => 'isc_image_source',
19 11 'default' => '',
20 12 ),
13 + 'image_source_url' => array(
14 + 'id' => 'isc_image_source_url',
15 + 'default' => '',
16 + ),
21 17 'image_source_own' => array(
22 18 'id' => 'isc_image_source_own',
23 19 'default' => '',
24 20 ),
@@ -32,13 +28,8 @@
32 28 )
33 29 );
34 30
35 31 /**
36 - * Commonly used text elements
37 - */
38 - protected $_common_texts = array();
39 -
40 - /**
41 32 * allowed image file types/extensions
42 33 * @since 1.1
43 34 */
44 35 protected $_allowedExtensions = array(
@@ -69,8 +60,14 @@
69 60 'bottom-center',
70 61 'bottom-right'
71 62 );
72 63
64 + protected static $instance;
65 +
66 + public static function get_instance() {
67 + return self::$instance;
68 + }
69 +
73 70 /**
74 71 * Setup registers filterts and actions.
75 72 */
76 73 public function __construct()
@@ -76,420 +73,12 @@
76 73 public function __construct()
77 74 {
78 75 // load all plugin options
79 76 $this->_options = get_option('isc_options');
80 - $this->_common_texts['not_available'] = __('Not available', ISCTEXTDOMAIN);
81 -
82 - // insert all function for the frontend here
83 -
84 - add_shortcode('isc_list', array($this, 'list_post_attachments_with_sources_shortcode'));
85 - add_shortcode('isc_list_all', array($this, 'list_all_post_attachments_sources_shortcode'));
86 - add_action('wp_enqueue_scripts', array($this, 'front_scripts'));
87 - add_action('wp_head', array($this, 'front_head'));
88 - add_action('the_content', array($this, 'content_filter'));
89 -
90 - // insert all backend functions below this check
91 -
92 - if (is_admin()) {
93 - register_activation_hook(ISCPATH . '/isc.php', array($this, 'activation'));
94 -
95 - add_action('add_attachment', array($this, 'attachment_added'), 10, 2);
96 - add_filter('attachment_fields_to_edit', array($this, 'add_isc_fields'), 10, 2);
97 - add_filter('attachment_fields_to_save', array($this, 'isc_fields_save'), 10, 2);
98 -
99 - add_action('admin_notices', array($this, 'admin_notices'));
100 -
101 - add_action('admin_menu', array($this, 'create_menu'));
102 - add_action('admin_init', array($this, 'SAPI_init'));
103 -
104 - add_action('admin_enqueue_scripts', array($this, 'add_admin_scripts'));
105 - add_action( 'admin_print_scripts', array($this, 'admin_headjs') );
106 -
107 - // save image information in meta field when a post is saved
108 - add_action('save_post', array($this, 'save_image_information_on_post_save'));
109 - }
77 + self::$instance = $this;
110 78 }
111 79
112 80 /**
113 - * load an image source by url
114 - *
115 - * @updated 1.3.5
116 - * @param string $url url of the image
117 - * @return type
118 - */
119 - public function get_source_by_url($url)
120 - {
121 - $options = $this->get_isc_options();
122 - $id = $this->get_image_by_url($url);
123 - $metadata['source'] = get_post_meta($id, 'isc_image_source', true);
124 - $metadata['own'] = get_post_meta($id, 'isc_image_source_own', true);
125 - $metadata['licence'] = get_post_meta($id, 'isc_image_licence', true);
126 -
127 - $source = $this->_common_texts['not_available'];
128 -
129 - $att_post = get_post($id);
130 -
131 - if ('' != $metadata['own']) {
132 - if ($this->_options['use_authorname']) {
133 - if (!empty($att_post)) {
134 - $source = get_the_author_meta('display_name', $att_post->post_author);
135 - }
136 - } else {
137 - $source = $this->options['by_author_text'];
138 - }
139 - } else {
140 - if ('' != $metadata['source']) {
141 - $source = $metadata['source'];
142 - }
143 - }
144 - // add licence if enabled
145 - if($options['enable_licences'] && isset($metadata['licence']) && $metadata['licence']) {
146 - $licences = $this->licences_text_to_array($options['licences']);
147 - if(isset($licences[$metadata['licence']]['url'])) $licence_url = $licences[$metadata['licence']]['url'];
148 - if($licence_url) {
149 - $source = sprintf('%1$s | <a href="%3$s" target="_blank" rel="nofollow">%2$s</a>', $source, $metadata['licence'], $licence_url);
150 - } else {
151 - $source = sprintf('%1$s | %2$s', $source, $metadata['licence']);
152 - }
153 - }
154 -
155 - return $source;
156 - }
157 -
158 - public function content_filter($content)
159 - {
160 - $options = $this->get_isc_options();
161 - if ($options['source_on_image']) {
162 - $pattern = '#(\[caption.*align="(.+)"[^\]*]{0,}\])? *(<a [^>]+>)? *(<img .*class=".*(align\d{4,})?.*wp-image-(\d+)\D*".*src="(.+)".*/?>).*(?(3)(?:</a>)|.*).*(?(1)(?:\[/caption\])|.*)#isU';
163 - $count = preg_match_all($pattern, $content, $matches);
164 - if (false !== $count) {
165 - for ($i=0; $i < $count; $i++) {
166 - $id = $matches[6][$i];
167 - $src = $matches[7][$i];
168 - $source = '<p class="isc-source-text">' . $options['source_pretext'] . ' ' . $this->get_source_by_url($src) . '</p>';
169 - $old_content = $matches[0][$i];
170 - $new_content = str_replace('wp-image-' . $id, 'wp-image-' . $id . ' with-source', $old_content);
171 - $alignment = (!empty($matches[1][$i]))? $matches[2][$i] : $matches[5][$i];
172 -
173 - $content = str_replace($old_content, '<div id="isc_attachment_' . $id . '" class="isc-source ' . $alignment . '"> ' . $new_content . $source . '</div>', $content);
174 - }
175 - }
176 - }
177 - return $content;
178 - }
179 -
180 - public function attachment_added($att_id)
181 - {
182 - foreach ($this->_fields as $field) {
183 - update_post_meta($att_id, $field['id'], $field['default']);
184 - }
185 - }
186 -
187 - /**
188 - * Front-end scripts in <head /> section.
189 - */
190 - public function front_head()
191 - {
192 - $options = $this->get_isc_options();
193 - ?>
194 - <script type="text/javascript">
195 - /* <![CDATA[ */
196 - var isc_front_data =
197 - {
198 - caption_position : '<?php echo $options['caption_position']; ?>',
199 - }
200 - /* ]]> */
201 - </script>
202 - <?php
203 - }
204 -
205 - /**
206 - * Enqueue scripts for the front-end.
207 - */
208 - public function front_scripts() {
209 - wp_enqueue_script('isc_front_js', plugins_url('/js/front-js.js', __FILE__), array('jquery'), ISCVERSION);
210 - }
211 -
212 - /**
213 - * create the menu pages for isc
214 - */
215 - public function create_menu()
216 - {
217 - global $isc_missing;
218 - global $isc_setting;
219 -
220 - // These pages should be available only for editors and higher
221 - $isc_missing = add_submenu_page('upload.php', 'missing image sources by Image Source Control Plugin', __('Missing Sources', ISCTEXTDOMAIN), 'edit_others_posts', 'isc_missing_sources_page', array($this, 'render_missing_sources_page'));
222 - $isc_setting = add_options_page(__('Image control - ISC plugin', ISCTEXTDOMAIN), __('Image Control', ISCTEXTDOMAIN), 'edit_others_posts', 'isc_settings_page', array($this, 'render_isc_settings_page'));
223 - }
224 -
225 - /**
226 - * add scripts to admin pages
227 - * @since 1.0
228 - * @update 1.1.1
229 - */
230 - public function add_admin_scripts($hook)
231 - {
232 - global $isc_setting;
233 - if ('post.php' == $hook) {
234 - wp_enqueue_script('isc_postphp_script', plugins_url('/js/post.php.js', __FILE__), array('jquery'), ISCVERSION);
235 - }
236 - if ($hook == $isc_setting) {
237 - wp_enqueue_script('isc_script', plugins_url('/js/isc.js', __FILE__), false, ISCVERSION);
238 - wp_enqueue_style('isc_image_settings_css', plugins_url('/css/image-settings.css', __FILE__), false, ISCVERSION);
239 - }
240 - }
241 -
242 - /**
243 - * add custom field to attachment
244 - * @param arr $form_fields
245 - * @param object $post
246 - * @return arr
247 - * @since 1.0
248 - * @updated 1.1
249 - * @updated 1.3.5 added field for licence
250 - */
251 - public function add_isc_fields($form_fields, $post)
252 - {
253 - // add input field for source
254 - $form_fields['isc_image_source']['label'] = __('Image Source', ISCTEXTDOMAIN);
255 - $form_fields['isc_image_source']['value'] = get_post_meta($post->ID, 'isc_image_source', true);
256 - $form_fields['isc_image_source']['helps'] = __('Include the image source here.', ISCTEXTDOMAIN);
257 -
258 - // add checkbox to mark as your own image
259 - $form_fields['isc_image_source_own']['input'] = 'html';
260 - $form_fields['isc_image_source_own']['label'] = '';
261 - $form_fields['isc_image_source_own']['helps'] =
262 - __('Check this box if this is your own image and doesn\'t need a source.', ISCTEXTDOMAIN);
263 - $form_fields['isc_image_source_own']['html'] =
264 - "<input type='checkbox' value='1' name='attachments[{$post->ID}][isc_image_source_own]' id='attachments[{$post->ID}][isc_image_source_own]' "
265 - . checked(get_post_meta($post->ID, 'isc_image_source_own', true), 1, false )
266 - . " style=\"width:14px\"/> "
267 - . __('This is my image', ISCTEXTDOMAIN);
268 -
269 - // add input field for source
270 - $options = $this->get_isc_options();
271 - if($options['enable_licences'] && $licences = $this->licences_text_to_array($options['licences'])) {
272 - $form_fields['isc_image_licence']['input'] = 'html';
273 - $form_fields['isc_image_licence']['label'] = __('Image Licence', ISCTEXTDOMAIN);
274 - $form_fields['isc_image_licence']['helps'] = __('Choose the image licence.', ISCTEXTDOMAIN);
275 - $html = '<select name="attachments['.$post->ID.'][isc_image_licence]" id="attachments['.$post->ID.'][isc_image_licence]">';
276 - $html .= '<option value="">--</option>';
277 - foreach($licences as $_licence_name => $_licence_data) {
278 - $html .= '<option value="'.$_licence_name.'" '.selected(get_post_meta($post->ID, 'isc_image_licence', true), $_licence_name, false) .'>'.$_licence_name.'</option>';
279 - }
280 - $html .= '</select>';
281 - $form_fields['isc_image_licence']['html'] = $html;
282 - }
283 -
284 - return $form_fields;
285 - }
286 -
287 - /**
288 - * save image source to post_meta
289 - * @param object $post
290 - * @param $attachment
291 - * @return object $post
292 - */
293 - public function isc_fields_save($post, $attachment)
294 - {
295 - if (isset($attachment['isc_image_source'])) {
296 - update_post_meta($post['ID'], 'isc_image_source', $attachment['isc_image_source']);
297 - }
298 - update_post_meta($post['ID'], 'isc_image_source_own', $attachment['isc_image_source_own']);
299 - if (isset($attachment['isc_image_licence'])) {
300 - update_post_meta($post['ID'], 'isc_image_licence', $attachment['isc_image_licence']);
301 - }
302 - return $post;
303 - }
304 -
305 - /**
306 - * create image sources list for all images of this post
307 - * @since 1.0
308 - * @updated 1.1, 1.3.5
309 - * @param int $post_id id of the current post/page
310 - * @return echo output
311 - */
312 - public function list_post_attachments_with_sources($post_id = 0)
313 - {
314 - global $post;
315 -
316 - if (empty($post_id)) {
317 - if (!empty($post->ID)) {
318 - $post_id = $post->ID;
319 - } else {
320 - return;
321 - }
322 - }
323 -
324 - $attachments = get_post_meta($post_id, 'isc_post_images', true);
325 - // if attachments is an empty string, search for images in it
326 - if ($attachments == '') {
327 - $this->save_image_information_on_load();
328 - $this->update_image_posts_meta($post_id, $post->post_content);
329 -
330 - $attachments = get_post_meta($post_id, 'isc_post_images', true);
331 - }
332 -
333 - // get licence array
334 - $options = $this->get_isc_options();
335 - if(!$options['enable_licences']) {
336 - $licences = false;
337 - } else {
338 - $licences = $this->licences_text_to_array($options['licences']);
339 - if($licences == false) $licences = array();
340 - }
341 -
342 - $return = '';
343 - if (!empty($attachments)) {
344 - $atts = array();
345 - foreach ($attachments as $attachment_id => $attachment_array) {
346 - $atts[$attachment_id]['title'] = get_the_title($attachment_id);
347 - $own = get_post_meta($attachment_id, 'isc_image_source_own', true);
348 - $source = get_post_meta($attachment_id, 'isc_image_source', true);
349 -
350 - if ( $own == '' && $source == '' ) {
351 - // remove if no information set
352 - unset($atts[$attachment_id]);
353 - continue;
354 - } elseif ($own != '') {
355 - if ($this->_options['use_authorname']) {
356 - $authorname = '';
357 - $att_post = get_post($attachment_id);
358 - if (null !== $att_post) {
359 - $authorname = get_the_author_meta('display_name', $att_post->post_author);
360 - }
361 - $atts[$attachment_id ]['source'] = $authorname;
362 - } else {
363 - $atts[$attachment_id ]['source'] = $this->_options['by_author_text'];
364 - }
365 - } else {
366 - $atts[$attachment_id ]['source'] = $source;
367 - }
368 -
369 - // add licence information
370 - // TODO maybe don’t display an unused licence (e.g. removed from the licence textarea)
371 - if(is_array($licences)) {
372 - $_licence = get_post_meta($attachment_id, 'isc_image_licence', true);
373 - if(isset($licences[$_licence]['url'])) {
374 - $atts[$attachment_id]['licence_url'] = $licences[$_licence]['url'];
375 - }
376 - if($_licence) $atts[$attachment_id]['licence'] = $_licence;
377 - }
378 - }
379 -
380 - $return = $this->_renderAttachments($atts);
381 - }
382 -
383 - return $return;
384 - }
385 -
386 - /**
387 - * render attachment list
388 - *
389 - * @param array $attachments
390 - * @updated 1.3.5
391 - */
392 - protected function _renderAttachments($attachments)
393 - {
394 - // don't display anything, if no image sources displayed
395 - if ($attachments == array()) {
396 - return ;
397 - }
398 -
399 - $options = $this->get_isc_options();
400 - $show_text = __('Show the list', ISCTEXTDOMAIN);
401 - $hide_text = __('Hide the list', ISCTEXTDOMAIN);
402 -
403 - ob_start();
404 - $headline = $this->_options['image_list_headline'];
405 - $hide_style = ($options['hide_list'])? 'style="height: 0px; overflow: hidden;"': 'style="height: auto; overflow: hidden;"';
406 - $hide_class = ($options['hide_list'])? ' isc-list-up': ' isc-list-down';
407 - $hide_title = ($options['hide_list'])? $show_text : $hide_text;
408 - printf('<p class="isc_image_list_title" title="%2$s" style="cursor: pointer;">%1$s</p>', $headline, $hide_title); ?>
409 - <script type="text/javascript">
410 - /* <!--[CDATA[ */
411 - isc_jstext = {
412 - show_list: "<?php echo esc_attr($show_text); ?>",
413 - hide_list: "<?php echo esc_attr($hide_text); ?>"
414 - }
415 - /* ]]--> */
416 - </script>
417 - <ul class="isc_image_list <?php echo $hide_class; ?>"<?php echo $hide_style; ?>><?php
418 -
419 - foreach ($attachments as $atts_id => $atts_array) {
420 - if (empty($atts_array['source'])) {
421 - continue;
422 - }
423 - // TODO find a more flexible way to create the source information in less lines
424 - if($options['enable_licences'] && isset($atts_array['licence']))
425 - if($atts_array['licence_url']) {
426 - printf('<li>%1$s: %2$s | <a href="%4$s" target="_blank" rel="nofollow">%3$s</a></li>', $atts_array['title'], $atts_array['source'], $atts_array['licence'], $atts_array['licence_url']);
427 - } else {
428 - printf('<li>%1$s: %2$s | %3$s</li>', $atts_array['title'], $atts_array['source'], $atts_array['licence']);
429 - }
430 - else
431 - printf('<li>%1$s: %2$s</li>', $atts_array['title'], $atts_array['source']);
432 - }
433 - ?></ul><?php
434 - return ob_get_clean();
435 - }
436 -
437 - /**
438 - * shortcode function to list all image sources
439 - * @param arr $atts
440 - */
441 - public function list_post_attachments_with_sources_shortcode($atts = array())
442 - {
443 - global $post;
444 - extract(shortcode_atts(array('id' => 0), $atts));
445 -
446 - // if $id not set, use the current ID from the post
447 - if (empty($id)) {
448 - $id = $post->ID;
449 - }
450 -
451 - if (empty($id)) {
452 - return;
453 - }
454 - return $this->list_post_attachments_with_sources($id);
455 - }
456 -
457 - /**
458 - * get all attachments without sources
459 - * the downside of this function: is there is not even an empty metakey field, nothing is going to be retrieved
460 - * @todo fix this in WP 3.5 with compare => 'NOT EXISTS'
461 - */
462 - public function get_attachments_without_sources()
463 - {
464 - $args = array(
465 - 'post_type' => 'attachment',
466 - 'numberposts' => -1,
467 - 'post_status' => null,
468 - 'post_parent' => null,
469 - 'meta_query' => array(
470 - // image source is empty
471 - array(
472 - 'key' => 'isc_image_source',
473 - 'value' => '',
474 - 'compare' => '=',
475 - ),
476 - // and image source is not set
477 - array(
478 - 'key' => 'isc_image_source_own',
479 - 'value' => '1',
480 - 'compare' => '!=',
481 - ),
482 - )
483 - );
484 -
485 - $attachments = get_posts($args);
486 - if (!empty($attachments)) {
487 - return $attachments;
488 - }
489 - }
490 -
491 - /**
492 81 * add meta values to all attachments
493 82 * @todo probably need to fix this when more fields are added along the way
494 83 * @todo use compare => 'NOT EXISTS' when WP 3.5 is up to retrieve only values where it is not set
495 84 * @todo this currently updates all empty fields; empty in this context is empty string, 0, false or not existing; add check if meta field already existed before
@@ -504,17 +93,17 @@
504 93 'post_parent' => null,
505 94 );
506 95
507 96 $attachments = get_posts($args);
508 - if (empty($attachments)) {
97 + if ( empty($attachments) || !is_array($attachments) ) {
509 98 return;
510 99 }
511 100
512 101 $count = 0;
513 - foreach ($attachments as $_attachment) {
102 + foreach ( $attachments as $_attachment ) {
514 103 $set = false;
515 104 setup_postdata($_attachment);
516 - foreach ($this->_fields as $_field) {
105 + foreach ( $this->_fields as $_field ) {
517 106 $meta = get_post_meta($_attachment->ID, $_field['id'], true);
518 107 if (empty($meta)) {
519 108 update_post_meta($_attachment->ID, $_field['id'], $_field['default']);
520 109 $set = true;
@@ -526,86 +115,19 @@
526 115 }
527 116 }
528 117
529 118 /**
530 - * Display scripts in <head></head> section of admin page. Useful for creating js variables in the js global namespace.
531 - */
532 - public function admin_headjs()
533 - {
534 - global $pagenow;
535 - $options = $this->get_isc_options();
536 - if ('post.php' == $pagenow) {
537 - ?>
538 - <script type="text/javascript">
539 - /* <![CDATA[ */
540 - isc_data = {
541 - warning_nosource : <?php echo (($options['warning_nosource'])? 'true' : 'false'); ?>,
542 - block_form_message : '<?php _e('Please specify the image source', ISCTEXTDOMAIN); ?>'
543 - }
544 - /* ]]> */
545 - </script>
546 - <?php
547 - }
548 - }
549 -
550 - /**
551 - * this is an entry function to save image information to a post when it is saved
119 + * retrieve images added to a post or page and save all information as a post meta value for the post
552 120 * @since 1.1
553 - * @param type $post_id
554 - */
555 - public function save_image_information_on_post_save($post_id)
556 - {
557 - // return, if save_post is called more than one time
558 - if (did_action('save_post') !== 1) {
559 - return;
560 - }
561 -
562 - if (isset($_POST['post_type']) && 'attachment' == $_POST['post_type']) {
563 - return;
564 - }
565 -
566 - // check if this is a revision and if so, use parent post id
567 - if ($_id = wp_is_post_revision($post_id)) {
568 - $post_id = $_id;
569 - }
570 -
571 - $_content = '';
572 - if ( !empty( $_REQUEST['content']) ) $_content = stripslashes($_REQUEST['content']);
573 -
574 - // Needs to be called before the 'isc_post_images' field is updated.
575 - $this->update_image_posts_meta($post_id, $_content);
576 -
577 - $this->save_image_information($post_id, $_content);
578 - }
579 -
580 - /**
581 - * save image information for a post when it is viewed and the image source list is enabled
582 - * (this is in case the plugin is new and the current post wasn't saved before)
583 - *
584 - * @since 1.1
585 - */
586 - public function save_image_information_on_load()
587 - {
588 - global $post;
589 - if (empty($post->ID)) {
590 - return;
591 - }
592 -
593 - $post_id = $post->ID;
594 - $_content = $post->post_content;
595 -
596 - $this->save_image_information($post_id, $_content);
597 - }
598 -
599 - /**
600 - * retrieve images added to a post or page and save all information as a meta value
601 - * @since 1.1
602 121 * @updated 1.3.5 added isc_images_in_posts filter
603 122 * @todo check for more post types that maybe should not be parsed here
604 123 */
605 - public function save_image_information($post_id, $_content)
124 + public function save_image_information($post_id, $content = '' )
606 125 {
607 - $_image_urls = $this->_filter_src_attributes($_content);
126 + // creates an infinite loop if not secured, see ISC_Public::list_post_attachments_with_sources()
127 + $content = apply_filters( 'the_content', $content );
128 +
129 + /*$_image_urls = $this->_filter_src_attributes($_content);
608 130 $_imgs = array();
609 131
610 132 foreach ($_image_urls as $_image_url) {
611 133 // get ID of images by url
@@ -612,10 +134,12 @@
612 134 $img_id = $this->get_image_by_url($_image_url);
613 135 $_imgs[$img_id] = array(
614 136 'src' => $_image_url
615 137 );
616 - }
138 + }*/
617 139
140 + $_imgs = $this->_filter_image_ids($content);
141 +
618 142 // add thumbnail information
619 143 $thumb_id = get_post_thumbnail_id($post_id);
620 144
621 145 /**
@@ -631,9 +155,9 @@
631 155 // apply filter to image array, so other developers can add their own logic
632 156 $_imgs = apply_filters('isc_images_in_posts', $_imgs, $post_id);
633 157
634 158 if (empty($_imgs)) {
635 - $_imgs = false;
159 + $_imgs = array();
636 160 }
637 161 update_post_meta($post_id, 'isc_post_images', $_imgs);
638 162 }
639 163
@@ -640,8 +164,9 @@
640 164 /**
641 165 * filter image src attribute from text
642 166 * @since 1.1
643 167 * @updated 1.1.3
168 + * @deprecated since 1.9 use _filter_image_ids instead
644 169 * @return array with image src uri-s
645 170 */
646 171 public function _filter_src_attributes($content = '')
647 172 {
@@ -652,9 +177,11 @@
652 177 // parse HTML with DOM
653 178 $dom = new DOMDocument;
654 179
655 180 libxml_use_internal_errors(true);
656 - $content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8");
181 + if ( function_exists('mb_convert_encoding') ) {
182 + $content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8");
183 + }
657 184 $dom->loadHTML($content);
658 185
659 186 // Prevents from sending E_WARNINGs notice (Outputs are forbidden during activation)
660 187 libxml_clear_errors();
@@ -659,9 +186,13 @@
659 186 // Prevents from sending E_WARNINGs notice (Outputs are forbidden during activation)
660 187 libxml_clear_errors();
661 188
662 189 foreach ($dom->getElementsByTagName('img') as $node) {
663 - $srcs[] = $node->getAttribute('src');
190 + if ( isset( $node->attributes ) ) {
191 + if ( null !== $node->attributes->getNamedItem('src') ) {
192 + $srcs[] = $node->attributes->getNamedItem('src')->textContent;
193 + }
194 + }
664 195 }
665 196
666 197 return $srcs;
667 198 }
@@ -666,8 +197,55 @@
666 197 return $srcs;
667 198 }
668 199
669 200 /**
201 + * filter image ids from text
202 ++ * @return array with image ids => image src uri-s
203 ++ */
204 + public function _filter_image_ids($content = '') {
205 + $srcs = array();
206 + if (empty($content)){
207 + return $srcs;
208 + }
209 +
210 + // parse HTML with DOM
211 + $dom = new DOMDocument;
212 +
213 + libxml_use_internal_errors(true);
214 + if ( function_exists('mb_convert_encoding') ) {
215 + $content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8");
216 + }
217 + $dom->loadHTML($content);
218 +
219 + // Prevents from sending E_WARNINGs notice (Outputs are forbidden during activation)
220 + libxml_clear_errors();
221 +
222 + foreach ($dom->getElementsByTagName('img') as $node) {
223 + if ( isset( $node->attributes ) ) {
224 + $matched = false;
225 + if ( null !== $node->attributes->getNamedItem('class') ) {
226 + if (preg_match('#.*wp-image-(\d+?).*#U', $node->attributes->getNamedItem('class')->textContent, $matches)) {
227 + $srcs[intval($matches[1])] = $node->attributes->getNamedItem('src')->textContent;
228 + $matched = true;
229 + }
230 + }
231 + if (!$matched) {
232 + if ( null !== $node->attributes->getNamedItem('src') ) {
233 + $url = $node->attributes->getNamedItem('src')->textContent;
234 + // get ID of images by url
235 + $id = $this->get_image_by_url($url);
236 + if ($id) {
237 + $srcs[$id] = $url;
238 + }
239 + }
240 + }
241 + }
242 + }
243 +
244 + return $srcs;
245 + }
246 +
247 + /**
670 248 * get image by url accessing the database directly
671 249 * @since 1.1
672 250 * @updated 1.1.3
673 251 * @param string $url url of the image
@@ -674,18 +252,39 @@
674 252 * @return id of the image
675 253 */
676 254 public function get_image_by_url($url = '')
677 255 {
256 + global $wpdb;
257 +
678 258 if (empty($url)) {
679 259 return 0;
680 260 }
681 - $types = implode('|', $this->_allowedExtensions);
682 - // check for the format 'image-title-(e12452112-)300x200.jpg' and remove the image size and edit mark from it
683 - $newurl = preg_replace("/(-e\d+){0,1}-(\d+)x(\d+)\.({$types})$/i", '.${4}', $url);
684 - global $wpdb;
685 - $query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE guid = %s", $newurl);
261 + $types = implode( '|', $this->_allowedExtensions );
262 + /**
263 + * check for the format 'image-title-(e12452112-)300x200.jpg(?query…)' and removes
264 + * the image size
265 + * edit marks
266 + * additional query vars
267 + */
268 + $newurl = esc_url( preg_replace( "/(-e\d+){0,1}(-\d+x\d+){0,1}\.({$types})(.*)/i", '.${3}', $url ) );
269 +
270 + // remove protocoll (http or https)
271 + $url = str_ireplace( array( 'http:', 'https:' ) , '', $url );
272 + $newurl = str_ireplace( array( 'http:', 'https:' ) , '', $newurl );
273 +
274 + // not escaped, because escaping already happened above
275 + $raw_query = $wpdb->prepare(
276 + "SELECT ID FROM `$wpdb->posts` WHERE post_type='attachment' AND guid = %s OR guid = %s OR guid = %s OR guid = %s LIMIT 1",
277 + "http:$url",
278 + "https:$url",
279 + "http:$newurl",
280 + "https:$newurl"
281 + );
282 +
283 + $query = apply_filters( 'isc_get_image_by_url_query', $raw_query, $newurl );
686 284 $id = $wpdb->get_var($query);
687 - return $id;
285 +
286 + return intval( $id );
688 287 }
689 288
690 289 /**
691 290 * Update isc_image_posts meta field for all images found in a post with a given ID.
@@ -690,29 +289,62 @@
690 289 /**
691 290 * Update isc_image_posts meta field for all images found in a post with a given ID.
692 291 * @param $post_id ID of the target post
693 292 * @param $content content of the target post
694 - * @updated 1.3.5 added images_in_posts_simple filter
293 + * @updated 1.3.5 added images_in_posts_simple filter
695 294 */
696 295 public function update_image_posts_meta($post_id, $content)
697 296 {
698 - $image_urls = $this->_filter_src_attributes($content);
699 - $image_ids = array();
297 + $content = apply_filters( 'the_content', $content );
298 +
299 + $image_ids = $this->_filter_image_ids($content);
700 300 $added_images = array();
701 301 $removed_images = array();
702 302
703 303 // add thumbnail information
704 304 $thumb_id = get_post_thumbnail_id($post_id);
705 - if ( !empty( $thumb_id )) { $image_urls[] = wp_get_attachment_url($thumb_id); }
305 + if ( !empty( $thumb_id )) {
306 + $image_ids[$thumb_id] = wp_get_attachment_url($thumb_id);
307 + }
706 308
309 + // get urls from gallery images
310 + // this might not be needed, since the gallery shortcode might have run already, but just in case
311 + // only for php 5.3 and higher
312 + if ( -1 !== version_compare( phpversion(), '5.3' ) && preg_match_all('/\[gallery([^\]]+)\]/m', $content, $results, PREG_SET_ORDER)) {
313 + foreach ($results as $result) {
314 + if (! preg_match('/ids="([^"]+)"/m', $result[1], $ids)) {
315 + continue;
316 + }
317 + //$image_urls = array_merge($image_urls, array_map( 'map_walker', explode(',', $ids[1])));
318 + foreach (explode(',', $ids[1]) as $id) {
319 + $image_ids[intval($id)] = get_the_guid($id);
320 + }
321 + }
322 + }
323 +
707 324 // apply filter to image array, so other developers can add their own logic
708 - $image_urls = apply_filters('isc_images_in_posts_simple', $image_urls, $post_id);
325 + // $image_urls = apply_filters('isc_images_in_posts_simple', $image_urls, $post_id);
326 + $filtered_image_ids = apply_filters('isc_images_in_posts_simple', $image_ids, $post_id);
327 + //for backwards compatibilty: check if the array-keys are valid image ids
328 + if ($filtered_image_ids != $image_ids) {
329 + $image_ids = array();
330 + $valid_post_types = apply_filters('isc_valid_post_types', array('attachment'));
331 + if (in_array(get_post_type($post_id), $valid_post_types)) {
332 + if ($id = $this->get_image_by_url($url)) {
333 + $image_ids[$id] = $url;
334 + }
335 + } else {
336 + $image_ids[$post_id] = $url;
337 + }
338 + } else {
339 + $image_ids = $filtered_image_ids;
340 + }
709 341
710 342 $isc_post_images = get_post_meta($post_id, 'isc_post_images', true);
343 + // just needed in very rare cases, when updates comes from outside of isc and meta fields doesn’t exist yet
344 + if(empty($isc_post_images)) $isc_post_images = array();
711 345
712 - foreach ($image_urls as $url) {
713 - $id = intval($this->get_image_by_url($url));
714 - array_push($image_ids, $id);
346 + foreach ($image_ids as $id => $url) {
715 347 if (is_array($isc_post_images) && !array_key_exists($id, $isc_post_images)) {
716 348 array_push($added_images, $id);
717 349 }
718 350 }
@@ -717,9 +349,10 @@
717 349 }
718 350 }
719 351 if (is_array($isc_post_images)) {
720 352 foreach ($isc_post_images as $old_id => $value) {
721 - if (!in_array($old_id, $image_ids)) {
353 + // if (!in_array($old_id, $image_ids)) {
354 + if (!array_key_exists($old_id, $image_ids)) {
722 355 array_push($removed_images, $old_id);
723 356 } else {
724 357 if (!empty($old_id)) {
725 358 $meta = get_post_meta($old_id, 'isc_image_posts', true);
@@ -728,8 +361,9 @@
728 361 } else {
729 362 // In case the isc_image_posts is not up to date
730 363 if (is_array($meta) && !in_array($post_id, $meta)) {
731 364 array_push($meta, $post_id);
365 + $meta = array_unique( $meta );
732 366 update_post_meta($old_id, 'isc_image_posts', $meta);
733 367 }
734 368 }
735 369 }
@@ -742,8 +376,9 @@
742 376 if (!is_array($meta) || array() == $meta) {
743 377 update_post_meta($id, 'isc_image_posts', array($post_id));
744 378 } else {
745 379 array_push($meta, $post_id);
380 + $meta = array_unique( $meta );
746 381 update_post_meta($id, 'isc_image_posts', $meta);
747 382 }
748 383 }
749 384
@@ -752,8 +387,9 @@
752 387 if (is_array($image_meta)) {
753 388 $offset = array_search($post_id, $image_meta);
754 389 if (false !== $offset) {
755 390 array_splice($image_meta, $offset, 1);
391 + $image_meta = array_unique( $image_meta );
756 392 update_post_meta($id, 'isc_image_posts', $image_meta);
757 393 }
758 394 }
759 395 }
@@ -759,342 +395,48 @@
759 395 }
760 396 }
761 397
762 398 /**
763 - * create shortcode to list all image sources in the frontend
764 - * @param array $atts
765 - * @since 1.1.3
766 - */
767 - public function list_all_post_attachments_sources_shortcode($atts = array())
768 - {
769 - extract(shortcode_atts(array(
770 - 'per_page' => 99999,
771 - 'before_links' => '',
772 - 'after_links' => '',
773 - 'prev_text' => '&#171; Previous',
774 - 'next_text' => 'Next &#187;'
775 - ),
776 - $atts));
777 -
778 - if ('&#171; Previous' == $prev_text)
779 - $prev_text = __('&#171; Previous', ISCTEXTDOMAIN);
780 - if ('Next &#187;' == $next_text)
781 - $next_text = __('Next &#187;', ISCTEXTDOMAIN);
782 -
783 - // retrieve all attachments
784 - $args = array(
785 - 'post_type' => 'attachment',
786 - 'numberposts' => -1,
787 - 'post_status' => null,
788 - 'post_parent' => null,
789 - 'meta_query' => array(
790 - array(
791 - 'key' => 'isc_image_posts',
792 - 'value' => 'a:0:{}',
793 - 'compare' => '!='
794 - )
795 - )
796 - );
797 -
798 - $attachments = get_posts($args);
799 - if (empty($attachments)) {
800 - return;
801 - }
802 -
803 - $options = $this->get_isc_options();
804 -
805 - $connected_atts = array();
806 -
807 - foreach ($attachments as $_attachment) {
808 - $connected_atts[$_attachment->ID]['source'] = get_post_meta($_attachment->ID, 'isc_image_source', true);
809 - $connected_atts[$_attachment->ID]['own'] = get_post_meta($_attachment->ID, 'isc_image_source_own', true);
810 - $connected_atts[$_attachment->ID]['title'] = $_attachment->post_title;
811 - $connected_atts[$_attachment->ID]['author_name'] = '';
812 - if ('' != $connected_atts[$_attachment->ID]['own']) {
813 - $connected_atts[$_attachment->ID]['author_name'] = get_the_author_meta('display_name', $_attachment->post_author);
814 - }
815 -
816 - $metadata = get_post_meta($_attachment->ID, 'isc_image_posts', true);
817 - $usage_data = '';
818 -
819 - if (is_array($metadata) && array() != $metadata) {
820 - $usage_data .= "<ul style='margin: 0;'>";
821 - foreach($metadata as $data) {
822 - $usage_data .= sprintf(__('<li><a href="%1$s" title="View %2$s">%3$s</a></li>', ISCTEXTDOMAIN),
823 - esc_url(get_permalink($data)),
824 - esc_attr(get_the_title($data)),
825 - esc_html(get_the_title($data))
826 - );
827 - }
828 - $usage_data .= "</ul>";
829 - }
830 -
831 - $connected_atts[$_attachment->ID]['posts'] = $usage_data;
832 - }
833 -
834 - $total = count($connected_atts);
835 -
836 - if (0 == $total)
837 - return;
838 -
839 - $page = isset($_GET['isc-page']) ? intval($_GET['isc-page']) : 1;
840 - $down_limit = 1; // First page
841 -
842 - $up_limit = 1;
843 -
844 - if ($per_page < $total) {
845 - $rem = $total % $per_page; // The Remainder of $total/$per_page
846 - $up_limit = ($total - $rem) / $per_page;
847 - if (0 < $rem) {
848 - $up_limit++; //If rem is positive, add the last page that contains less than $per_page attachment;
849 - }
850 - }
851 -
852 - ob_start();
853 - if ( 2 > $up_limit ) {
854 - $this->display_all_attachment_list($connected_atts);
855 - } else {
856 - $starting_atts = $per_page * ($page - 1); // for page 2 and 3 $per_page start display on $connected_atts[3*(2-1) = 3]
857 - $paged_atts = array_slice($connected_atts, $starting_atts, $per_page, true);
858 - $this->display_all_attachment_list($paged_atts);
859 - $this->pagination_links($up_limit, $before_links, $after_links, $prev_text, $next_text);
860 - }
861 - if (isset($options['webgilde']) && true == $options['webgilde']) {
862 - ?>
863 - <p class="isc-backlink"><?php printf(__('Image list created by <a href="%s" title="Image Source Control">Image Source Control Plugin</a>', ISCTEXTDOMAIN), WEBGILDE); ?></p>
864 - <?php
865 - }
866 -
867 - $output = ob_get_clean();
868 - return $output;
869 - }
870 -
871 -
872 - /**
873 - * performs rendering of all attachments list
874 - * @since 1.1.3
399 + * Returns default options
875 400 */
876 - public function display_all_attachment_list($atts)
401 + public function default_options()
877 402 {
878 - if (!is_array($atts) || $atts == array())
879 - return;
880 - $options = $this->get_isc_options();
881 - ?>
882 - <table>
883 - <thead>
884 - <?php if ($options['thumbnail_in_list']) : ?>
885 - <th><?php _e('Thumbnail', ISCTEXTDOMAIN); ?></th>
886 - <?php endif; ?>
887 - <th><?php _e("Attachment's ID", ISCTEXTDOMAIN); ?></th>
888 - <th><?php _e('Title', ISCTEXTDOMAIN); ?></th>
889 - <th><?php _e('Attached to', ISCTEXTDOMAIN); ?></th>
890 - <th><?php _e('Source', ISCTEXTDOMAIN); ?></th>
891 - </thead>
892 - <tbody>
893 - <?php foreach ($atts as $id => $data) : ?>
894 - <?php
895 - $source = $this->_common_texts['not_available'];
896 - if ('' != $data['own']) {
897 - /** @todo ment for later: this text was used above already; find a place to but it so it is defined only once and used where needed */
898 - if ($this->_options['use_authorname']) {
899 - $source = $data['author_name'];
900 - } else {
901 - $source = $this->_options['by_author_text'];
902 - }
903 - } else {
904 - if (!empty($data['source']))
905 - $source = $data['source'];
906 - }
907 - ?>
908 - <tr>
909 - <?php
910 - $v_align = '';
911 - if ($options['thumbnail_in_list']) :
912 - $v_align = 'style="vertical-align: top;"';
913 - ?>
914 - <?php if ('custom' != $options['thumbnail_size']) : ?>
915 - <td><?php echo wp_get_attachment_image($id, $options['thumbnail_size']); ?></td>
916 - <?php else : ?>
917 - <td><?php echo wp_get_attachment_image($id, array($options['thumbnail_width'], $options['thumbnail_height'])); ?></td>
918 - <?php endif; ?>
919 - <?php endif; ?>
920 - <td <?php echo $v_align;?>><?php echo $id; ?></td>
921 - <td <?php echo $v_align;?>><?php echo $data['title']; ?></td>
922 - <td <?php echo $v_align;?>><?php echo $data['posts']; ?></td>
923 - <td <?php echo $v_align;?>><?php echo esc_html($source); ?></td>
924 - </tr>
925 - <?php endforeach; ?>
926 - </tbody>
927 - </table>
928 - <?php
929 - }
930 403
931 - /**
932 - * Render pagination links, use $before_links and after_links to wrap pagination links inside an additional block
933 - * @param int $max_page total page count
934 - * @param string $before_links optional html to display before pagination links
935 - * @param string $after_links optional html to display after pagination links
936 - * @param string $prev_text text for the previous page link
937 - * @param string $next_text text for the next page link
938 - * @since 1.1.3
939 - *
940 - */
941 - public function pagination_links($max_page, $before_links, $after_links, $prev_text, $next_text)
942 - {
943 - if ((!isset($max_page)) || (!isset($before_links)) || (!isset($after_links)) || (!isset($prev_text)) || (!isset($next_text)))
944 - return;
945 - if (!empty($before_links))
946 - echo $before_links;
947 - ?>
948 - <div class="isc-paginated-links">
949 - <?php
950 - $page = isset($_GET['isc-page']) ? intval($_GET['isc-page']) : 1;
951 - if ($max_page < $page) {
952 - $page = $max_page;
953 - }
954 - if ($page < 1) {
955 - $page = 1;
956 - }
957 - $min_page = 1;
958 - $backward_distance = $page - $min_page;
959 - $forward_distance = $max_page - $page;
404 + $licences = "All Rights Reserved
405 +Public Domain Mark 1.0|https://creativecommons.org/publicdomain/mark/1.0/
406 +CC0 1.0 Universal|https://creativecommons.org/publicdomain/zero/1.0/
407 +CC BY 4.0 International|https://creativecommons.org/licenses/by/4.0/
408 +CC BY-SA 4.0 International|https://creativecommons.org/licenses/by-sa/4.0/
409 +CC BY-ND 4.0 International|https://creativecommons.org/licenses/by-nd/4.0/
410 +CC BY-NC 4.0 International|https://creativecommons.org/licenses/by-nc/4.0/
411 +CC BY-NC-SA 4.0 International|https://creativecommons.org/licenses/by-nc-sa/4.0/
412 +CC BY-NC-ND 4.0 International|https://creativecommons.org/licenses/by-nc-nd/4.0/
413 +CC BY 3.0 Unported|https://creativecommons.org/licenses/by/3.0/
414 +CC BY-SA 3.0 Unported|https://creativecommons.org/licenses/by-sa/3.0/
415 +CC BY-ND 3.0 Unported|https://creativecommons.org/licenses/by-nd/3.0/
416 +CC BY-NC 3.0 Unported|https://creativecommons.org/licenses/by-nc/3.0/
417 +CC BY-NC-SA 3.0 Unported|https://creativecommons.org/licenses/by-nc-sa/3.0/
418 +CC BY-NC-ND 3.0 Unported|https://creativecommons.org/licenses/by-nc-nd/3.0/
419 +CC BY 2.5 Generic|https://creativecommons.org/licenses/by/2.5/
420 +CC BY-SA 2.5 Generic|https://creativecommons.org/licenses/by-sa/2.5/
421 +CC BY-ND 2.5 Generic|https://creativecommons.org/licenses/by-nd/2.5/
422 +CC BY-NC 2.5 Generic|https://creativecommons.org/licenses/by-nc/2.5/
423 +CC BY-NC-SA 2.5 Generic|https://creativecommons.org/licenses/by-nc-sa/2.5/
424 +CC BY-NC-ND 2.5 Generic|https://creativecommons.org/licenses/by-nc-nd/2.5/
425 +CC BY 2.0 Generic|https://creativecommons.org/licenses/by/2.0/
426 +CC BY-SA 2.0 Generic|https://creativecommons.org/licenses/by-sa/2.0/
427 +CC BY-ND 2.0 Generic|https://creativecommons.org/licenses/by-nd/2.0/
428 +CC BY-NC 2.0 Generic|https://creativecommons.org/licenses/by-nc/2.0/
429 +CC BY-NC-SA 2.0 Generic|https://creativecommons.org/licenses/by-nc-sa/2.0/
430 +CC BY-NC-ND 2.0 Generic|https://creativecommons.org/licenses/by-nc-nd/2.0/";
960 431
961 - $page_link = get_page_link();
962 -
963 - /**
964 - * Remove the query_string of the page_link (?page_id=xyz for the standard permalink structure),
965 - * which is already captured in $_SERVER['QUERY_STRING'].
966 - * @todo replace regex with other value (does WP store the url path without attributes somewhere?
967 - * >get_page_link() returns the permalink but for the default WP permalink structure, the permalink looks like "http://domain.tld/?p=52", while $_GET
968 - * still has a field named 'page_id' with the same value of 52.
969 - */
970 -
971 - $pos = strpos($page_link, '?');
972 - if (false !== $pos) {
973 - $page_link = substr($page_link, 0, $pos);
974 - }
975 -
976 - /**
977 - * Unset the actual "$_GET['isc-page']" variable (if is set). Pagination variable will be appended to the new query string with a different value for each
978 - * pagination link.
979 - */
980 -
981 - if (isset($_GET['isc-page'])) {
982 - unset($_GET['isc-page']);
983 - }
984 -
985 - $query_string = http_build_query($_GET);
986 -
987 - $isc_query_tag = '';
988 - if (empty($query_string)) {
989 - $isc_query_tag = '?isc-page=';
990 - } else {
991 - $query_string = '?' . $query_string;
992 - $isc_query_tag = '&isc-page=';
993 - }
994 -
995 - if ($min_page != $page) {
996 - ?>
997 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . ($page-1); ?>" class="prev page-numbers"><?php echo $prev_text; ?></a>
998 - <?php
999 - }
1000 -
1001 - if (5 < $max_page) {
1002 -
1003 - if (3 < $backward_distance) {
1004 - ?>
1005 - <a href="<?php echo $page_link . $query_string . $isc_query_tag; ?>1" class="page-numbers">1</a>
1006 - <span class="page-numbers dots">...</span>
1007 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . ($page-2);?>" class="page-numbers"><?php echo $page-2; ?></a>
1008 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . ($page-1);?>" class="page-numbers"><?php echo $page-1; ?></a>
1009 - <span class="page-numbers current"><?php echo $page; ?></span>
1010 - <?php
1011 - } else {
1012 - for ($i = 1; $i <= $page; $i++) {
1013 - if ($i == $page) {
1014 - ?>
1015 - <span class="page-numbers current"><?php echo $i; ?></span>
1016 - <?php
1017 - } else {
1018 - ?>
1019 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . $i;?>" class="page-numbers"><?php echo $i; ?></a>
1020 - <?php
1021 - }
1022 - }
1023 - }
1024 -
1025 - if (3 < $forward_distance) {
1026 - ?>
1027 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . ($page+1);?>" class="page-numbers"><?php echo $page+1; ?></a>
1028 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . ($page+2);?>" class="page-numbers"><?php echo $page+2; ?></a>
1029 - <span class="page-numbers dots">...</span>
1030 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . $max_page;?>" class="page-numbers"><?php echo $max_page; ?></a>
1031 - <?php
1032 - } else {
1033 - for ($i = $page+1; $i <= $max_page; $i++) {
1034 - ?>
1035 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . $i;?>" class="page-numbers"><?php echo $i; ?></a>
1036 - <?php
1037 - }
1038 - }
1039 - } else {
1040 - for ($i = 1; $i <= $max_page; $i++) {
1041 - if ($i == $page) {
1042 - ?>
1043 - <span class="page-numbers current"><?php echo $i; ?></span>
1044 - <?php
1045 - } else {
1046 - ?>
1047 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . $i;?>" class="page-numbers"><?php echo $i; ?></a>
1048 - <?php
1049 - }
1050 - }
1051 - }
1052 - if ($page != $max_page) {
1053 - ?>
1054 - <a href="<?php echo $page_link . $query_string . $isc_query_tag . ($page+1);?>" class="next page-numbers"><?php echo $next_text; ?></a>
1055 - <?php
1056 - }
1057 - ?>
1058 - </div>
1059 - <?php
1060 - echo $after_links;
1061 - }
1062 -
1063 - /**
1064 - * The activation function
1065 - */
1066 - public function activation()
1067 - {
1068 - if (!is_array(get_option('isc_options'))) {
1069 - update_option( 'isc_options', $this->default_options() );
1070 - }
1071 - $options = $this->get_isc_options();
1072 - if (!$options['installed']) {
1073 - /**
1074 - * Here, all jobs to perform during first activation, especially options and custom fields.
1075 - * Important: NO add_action('something', 'somefunction') here.
1076 - */
1077 -
1078 - // adds meta fields for attachments
1079 - $this->add_meta_values_to_attachments();
1080 -
1081 - // set all isc_image_posts meta fields.
1082 - $this->init_image_posts_metafield();
1083 -
1084 - $options['installed'] = true;
1085 - update_option('isc_options', $options);
1086 - }
1087 - }
1088 -
1089 - /**
1090 - * Returns default options
1091 - */
1092 - public function default_options()
1093 - {
1094 - $default['image_list_headline'] = __('image sources', ISCTEXTDOMAIN);
432 + $default['display_type'] = array('list');
433 + $default['list_on_archives'] = false;
434 + $default['list_on_excerpts'] = false;
435 + $default['image_list_headline'] = __('image sources', 'image-source-control-isc');
436 + $default['exclude_own_images'] = false;
1095 437 $default['use_authorname'] = true;
1096 - $default['by_author_text'] = __('Owned by the author', ISCTEXTDOMAIN);
438 + $default['by_author_text'] = __('Owned by the author', 'image-source-control-isc');
1097 439 $default['installed'] = false;
1098 440 $default['version'] = ISCVERSION;
1099 441 $default['webgilde'] = false;
1100 442 $default['thumbnail_in_list'] = false;
@@ -1104,333 +446,15 @@
1104 446 $default['warning_nosource'] = true;
1105 447 $default['warning_onesource_missing'] = true;
1106 448 $default['hide_list'] = false;
1107 449 $default['caption_position'] = 'top-left';
1108 - $default['source_on_image'] = false;
1109 - $default['source_pretext'] = __('Source:', ISCTEXTDOMAIN);
450 + $default['source_pretext'] = __('Source:', 'image-source-control-isc');
1110 451 $default['enable_licences'] = false;
1111 - $default['licences'] = __("CC BY 2.0|http://creativecommons.org/licenses/by/2.0/legalcode", ISCTEXTDOMAIN);
452 + $default['licences'] = apply_filters( 'isc-licences-list', $licences );
1112 453 return $default;
1113 454 }
1114 455
1115 456 /**
1116 - * Settings API initialization
1117 - *
1118 - * @update 1.3.5 added settings for sources
1119 - */
1120 - public function SAPI_init()
1121 - {
1122 - $this->upgrade_management();
1123 - register_setting('isc_options_group', 'isc_options', array($this, 'settings_validation'));
1124 - add_settings_section('isc_settings_section', '', '__return_false', 'isc_settings_page');
1125 -
1126 - // Starts Page/Post settings group
1127 - add_settings_field('image_list_headline', __('Image list headline', ISCTEXTDOMAIN), array($this, 'renderfield_list_headline'), 'isc_settings_page', 'isc_settings_section');
1128 - /**
1129 - * All new setting in Page/Post group Here!
1130 - */
1131 - add_settings_field('hide_list', __('Hide the image list', ISCTEXTDOMAIN), array($this, 'renderfield_hide_list'), 'isc_settings_page', 'isc_settings_section');
1132 - // Ends Page/Post settings group
1133 -
1134 - // Starts Full images list group
1135 - add_settings_field('use_thumbnail', __("Use thumbnails in images list", ISCTEXTDOMAIN), array($this, 'renderfield_use_thumbnail'), 'isc_settings_page', 'isc_settings_section');
1136 - /**
1137 - * All new setting in Full images list group Here!
1138 - */
1139 - add_settings_field('thumbnail_width', __("Thumbnails max-width", ISCTEXTDOMAIN), array($this, 'renderfield_thumbnail_width'), 'isc_settings_page', 'isc_settings_section');
1140 - add_settings_field('thumbnail_height', __("Thumbnails max-height", ISCTEXTDOMAIN), array($this, 'renderfield_thumbnail_height'), 'isc_settings_page', 'isc_settings_section');
1141 - // Ends Full images list group
1142 -
1143 - // Starts Licence settings group
1144 - add_settings_field('enable_licences', __("Enable licences", ISCTEXTDOMAIN), array($this, 'renderfield_enable_licences'), 'isc_settings_page', 'isc_settings_section');
1145 - add_settings_field('licences', __('List of licences', ISCTEXTDOMAIN), array($this, 'renderfield_licences'), 'isc_settings_page', 'isc_settings_section');
1146 -
1147 - // Starts Misc settings group
1148 - add_settings_field('use_authorname', __('Use authors names', ISCTEXTDOMAIN), array($this, 'renderfield_use_authorname'), 'isc_settings_page', 'isc_settings_section');
1149 - add_settings_field('by_author_text', __('Custom text for owned images', ISCTEXTDOMAIN), array($this, 'renderfield_byauthor_text'), 'isc_settings_page', 'isc_settings_section');
1150 - add_settings_field('webgilde_backlink', __("Link to webgilde's website", ISCTEXTDOMAIN), array($this, 'renderfield_webgile'), 'isc_settings_page', 'isc_settings_section');
1151 - /**
1152 - * All new setting in Misc settings group Here!
1153 - */
1154 - add_settings_field('source_caption', __("Source as caption on image", ISCTEXTDOMAIN), array($this, 'renderfield_source_caption'), 'isc_settings_page', 'isc_settings_section');
1155 - add_settings_field('caption_position', __("Caption position", ISCTEXTDOMAIN), array($this, 'renderfield_caption_pos'), 'isc_settings_page', 'isc_settings_section');
1156 - add_settings_field('warning_one_source', __("Warning when there is at least one missing source", ISCTEXTDOMAIN), array($this, 'renderfield_warning_onesource_misisng'), 'isc_settings_page', 'isc_settings_section');
1157 - add_settings_field('warning_nosource', __("Warnings when source not available", ISCTEXTDOMAIN), array($this, 'renderfield_warning_nosource'), 'isc_settings_page', 'isc_settings_section');
1158 - // Ends Misc settings group
1159 - }
1160 -
1161 - /**
1162 - * manage data structure upgrading of outdated versions
1163 - */
1164 - public function upgrade_management() {
1165 -
1166 - /*
1167 - * Since the activation hook is not executed on plugin upgrade, this function checks options in database
1168 - * during the admin_init hook to handle plugin's upgrade.
1169 - */
1170 -
1171 - $options = get_option('isc_options');
1172 -
1173 - if (!is_array($options)) {
1174 - // special case for version prior to 1.2 (which don't have options)
1175 - $options = $this->default_options();
1176 - $this->init_image_posts_metafield();
1177 - $options['installed'] = true;
1178 - update_option('isc_options', $options);
1179 - }
1180 -
1181 - if (ISCVERSION != $options['version']) {
1182 - $options = $options + $this->default_options();
1183 - $options['version'] = ISCVERSION;
1184 - update_option('isc_options', $options);
1185 - }
1186 - }
1187 -
1188 - /**
1189 - * Image_control's page callback
1190 - */
1191 - public function render_isc_settings_page()
1192 - {
1193 - ?>
1194 - <div id="icon-options-general" class="icon32"><br></div>
1195 - <h2><?php _e('Images control settings', ISCTEXTDOMAIN); ?></h2>
1196 - <div id="isc-admin-wrap">
1197 - <form id="image-control-form" method="post" action="options.php">
1198 - <div class="postbox isc-setting-group"><?php // Open the div for the first settings group ?>
1199 - <h3 class="setting-group-head"><?php _e('Post / Page images list', ISCTEXTDOMAIN); ?></h3>
1200 - <?php
1201 - settings_fields( 'isc_options_group' );
1202 - do_settings_sections( 'isc_settings_page' );
1203 - ?>
1204 - </div><?php //Close the last settings group div ?>
1205 - <p class="submit">
1206 - <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
1207 - </p>
1208 - </form>
1209 - </div><!-- #isc-admin-wrap -->
1210 - <?php
1211 - }
1212 -
1213 - /**
1214 - * Missing sources page callback
1215 - */
1216 - public function render_missing_sources_page()
1217 - {
1218 - require_once(ISCPATH . '/templates/missing_sources.php');
1219 - }
1220 -
1221 - /**
1222 - * *******************************
1223 - * WordPress Setting API Callbacks
1224 - * *******************************
1225 - */
1226 - public function renderfield_list_headline()
1227 - {
1228 - $options = $this->get_isc_options();
1229 - $description = __('The headline of the image list added via shortcode or function in your theme.', ISCTEXTDOMAIN);
1230 - ?>
1231 - <div id="image-list-headline-block">
1232 - <label for="list-head"><?php __('Image list headline', ISCTEXTDOMAIN); ?></label>
1233 - <input type="text" name="isc_options[image_list_headline_field]" id="list-head" value="<?php echo $options['image_list_headline'] ?>" class="regular-text" />
1234 - <p><em><?php echo $description; ?></em></p>
1235 - </div>
1236 - <?php
1237 - }
1238 -
1239 - public function renderfield_hide_list()
1240 - {
1241 - $options = $this->get_isc_options();
1242 - $description = __("Hide the list when the post is loaded. A simple click on the list headline will show the list content.", ISCTEXTDOMAIN);
1243 - ?>
1244 - <div id="hide-list-block">
1245 - <label for="hide-list"><?php _e('Hide the image list of a post', ISCTEXTDOMAIN) ?></label>
1246 - <input type="checkbox" name="isc_options[hide_list]" id="hide-list" <?php checked($options['hide_list']); ?> />
1247 - <p><em><?php echo $description; ?></em></p>
1248 - </div>
1249 - </td></tr></tbody></table>
1250 - </div><!-- .postbox -->
1251 - <div class="postbox isc-setting-group">
1252 - <h3 class="setting-group-head"><?php _e('Full images list', ISCTEXTDOMAIN) ?></h3>
1253 - <table class="form-table"><tbody>
1254 - <?php
1255 - }
1256 -
1257 - public function renderfield_use_authorname()
1258 - {
1259 - $options = $this->get_isc_options();
1260 - $description = __("Display the author's public name as source when the image is owned by the author (the uploader of the image, not necessarily the author of the post the image is displayed on). Uncheck to use a custom text instead.", ISCTEXTDOMAIN);
1261 -
1262 - ?>
1263 - <div id="use-authorname-block">
1264 - <label for="use_authorname"><?php _e('Use author name', ISCTEXTDOMAIN) ?></label>
1265 - <input type="checkbox" name="isc_options[use_authorname_ckbox]" id="use_authorname" <?php checked($options['use_authorname']); ?> />
1266 - <p><em><?php echo $description; ?></em></p>
1267 - </div>
1268 - <?php
1269 - }
1270 -
1271 - public function renderfield_byauthor_text()
1272 - {
1273 - $options = $this->get_isc_options();
1274 - $description = __("Enter the custom text to display if you do not want to use the author's public name.", ISCTEXTDOMAIN);
1275 - ?>
1276 - <div id="by-author-text">
1277 - <input type="text" id="byauthor" name="isc_options[by_author_text_field]" value="<?php echo $options['by_author_text']; ?>" <?php disabled($options['use_authorname']); ?> class="regular-text" />
1278 - <p><em><?php echo $description; ?></em></p>
1279 - </div>
1280 - <?php
1281 - }
1282 -
1283 - public function renderfield_enable_licences()
1284 - {
1285 - $options = $this->get_isc_options();
1286 - $description = __("Enable this to be able to add and display copyright/copyleft licences for your images and manage them in the field below.", ISCTEXTDOMAIN);
1287 -
1288 - ?>
1289 - <div id="enable-licences">
1290 - <input type="checkbox" name="isc_options[enable_licences]" id="enable_licences" <?php checked($options['enable_licences']); ?> />
1291 - <p><em><?php echo $description; ?></em></p>
1292 - </div>
1293 - <?php
1294 - }
1295 -
1296 - public function renderfield_licences()
1297 - {
1298 - $options = $this->get_isc_options();
1299 - $description = __('List of licences the author can choose for an image. Enter a licence per line and separate the name from the optional link with a pipe symbol (e.g. <em>CC BY 2.0|http://creativecommons.org/licenses/by/2.0/legalcode</em>).' ,ISCTEXTDOMAIN);
1300 - ?>
1301 - <div id="licences">
1302 - <textarea name="isc_options[licences]"><?php echo $options['licences'] ?></textarea>
1303 - <p><em><?php echo $description; ?></em></p>
1304 - </div>
1305 - </td></tr></tbody></table>
1306 - </div><!-- .postbox -->
1307 - <div class="postbox isc-setting-group">
1308 - <h3 class="setting-group-head"><?php _e('Miscellaneous settings', ISCTEXTDOMAIN); ?></h3>
1309 - <table class="form-table"><tbody><tr>
1310 - <?php
1311 - }
1312 -
1313 - public function renderfield_webgile()
1314 - {
1315 - $options = $this->get_isc_options();
1316 - $description = sprintf(__('Display a link to <a href="%s">Image Source Control plugin&#39;s website</a> below the list of all images in the blog?', ISCTEXTDOMAIN), WEBGILDE);
1317 - ?>
1318 - <div id="webgilde-block">
1319 - <input type="checkbox" id="webgilde-link" name="isc_options[webgilde_field]" <?php checked($options['webgilde']); ?> />
1320 - <p><em><?php echo $description; ?></em></p>
1321 - </div>
1322 - <?php
1323 - }
1324 -
1325 - public function renderfield_use_thumbnail()
1326 - {
1327 - $options = $this->get_isc_options();
1328 - $description = __('Display thumbnails on the list of all images in the blog.' ,ISCTEXTDOMAIN);
1329 - ?>
1330 - <div id="use-thumbnail-block">
1331 - <input type="checkbox" id="use-thumbnail" name="isc_options[use_thumbnail]" value="1" <?php checked($options['thumbnail_in_list']); ?> />
1332 - <select id="thumbnail-size-select" name="isc_options[size_select]" <?php disabled(!$options['thumbnail_in_list']) ?>>
1333 - <?php foreach ($this->_thumbnail_size as $size) : ?>
1334 - <option value="<?php echo $size; ?>" <?php selected($size, $options['thumbnail_size']);?>><?php echo $size; ?></option>
1335 - <?php endforeach; ?>
1336 - </select>
1337 - <p><em><?php echo $description; ?></em></p>
1338 - </div>
1339 - <?php
1340 - }
1341 -
1342 - public function renderfield_thumbnail_width()
1343 - {
1344 - $options = $this->get_isc_options();
1345 - $description = __('Custom value of the maximum allowed width for thumbnail.' ,ISCTEXTDOMAIN);
1346 - ?>
1347 - <div id="thumbnail-custom-width">
1348 - <input type="text" id="custom-width" name="isc_options[thumbnail_width]" class="small-text" value="<?php echo $options['thumbnail_width'] ?>" /> px
1349 - <p><em><?php echo $description; ?></em></p>
1350 - </div>
1351 - <?php
1352 - }
1353 -
1354 - public function renderfield_thumbnail_height()
1355 - {
1356 - $options = $this->get_isc_options();
1357 - $description = __('Custom value of the maximum allowed height for thumbnail.' ,ISCTEXTDOMAIN);
1358 - ?>
1359 - <div id="thumbnail-custom-height">
1360 - <input type="text" id="custom-height" name="isc_options[thumbnail_height]" class="small-text" value="<?php echo $options['thumbnail_height'] ?>"/> px
1361 - <p><em><?php echo $description; ?></em></p>
1362 - </div>
1363 - </td></tr></tbody></table>
1364 - </div><!-- .postbox -->
1365 - <div class="postbox isc-setting-group">
1366 - <h3 class="setting-group-head"><?php _e('Licences settings', ISCTEXTDOMAIN); ?></h3>
1367 - <table class="form-table"><tbody><tr>
1368 - <?php
1369 - }
1370 -
1371 - public function renderfield_warning_nosource()
1372 - {
1373 - $options = $this->get_isc_options();
1374 - $description = __('Warn and prevent data to be saved when an attachment is edited and the source has not been specified.' ,ISCTEXTDOMAIN);
1375 - ?>
1376 - <div id="no-source-block">
1377 - <input type="checkbox" id="no-source" name="isc_options[no_source]"value="1" <?php checked($options['warning_nosource']); ?>/>
1378 - <p><em><?php echo $description; ?></em></p>
1379 - </div>
1380 - <?php
1381 - }
1382 -
1383 - public function renderfield_warning_onesource_misisng()
1384 - {
1385 - $options = $this->get_isc_options();
1386 - $description = __('Display an admin notice in admin pages when one or more image sources are missing.' ,ISCTEXTDOMAIN);
1387 - ?>
1388 - <div id="one-source-block">
1389 - <input type="checkbox" id="one-source" name="isc_options[one_source]"value="1" <?php checked($options['warning_onesource_missing']); ?>/>
1390 - <p><em><?php echo $description; ?></em></p>
1391 - </div>
1392 - <?php
1393 - }
1394 -
1395 - public function renderfield_caption_pos()
1396 - {
1397 - $options = $this->get_isc_options();
1398 - $description = __('Position of captions into images' ,ISCTEXTDOMAIN);
1399 - ?>
1400 - <div id="caption-position-block">
1401 - <select id="caption-pos" name="isc_options[cap_pos]">
1402 - <?php foreach ($this->_caption_position as $pos) : ?>
1403 - <option value="<?php echo $pos; ?>" <?php selected($pos, $options['caption_position']); ?>><?php echo $pos; ?></option>
1404 - <?php endforeach; ?>
1405 - </select>
1406 - <p><em><?php echo $description; ?></em></p>
1407 - </div>
1408 - <?php
1409 - }
1410 -
1411 - public function renderfield_source_caption()
1412 - {
1413 - $options = $this->get_isc_options();
1414 - $description_checkbox = __('Tick to display source onto each image.' ,ISCTEXTDOMAIN);
1415 - $description_textfield = __('The text preceding the source on each image.' ,ISCTEXTDOMAIN);
1416 - ?>
1417 - <div id="caption-block">
1418 - <input type="checkbox" id="source-on-image" value="1" name="isc_options[source_on_image]" <?php checked($options['source_on_image']); ?> />
1419 - <p><em><?php echo $description_checkbox; ?></em></p>
1420 - <input type="text" id='source-pretext' name="isc_options[source_pretext]" value="<?php echo $options['source_pretext']; ?>" />
1421 - <p><em><?php echo $description_textfield; ?></em></p>
1422 - </div>
1423 - <?php
1424 - }
1425 -
1426 - /**
1427 - * ****************************
1428 - * End of Setting API Callbacks
1429 - * ****************************
1430 - */
1431 -
1432 - /**
1433 457 * Returns isc_options if it exists, returns the default options otherwise.
1434 458 */
1435 459 public function get_isc_options() {
1436 460 return get_option('isc_options', $this->default_options());
@@ -1436,82 +460,8 @@
1436 460 return get_option('isc_options', $this->default_options());
1437 461 }
1438 462
1439 463 /**
1440 - * Input validation function.
1441 - * @param array $input values from the admin panel
1442 - * @updated 1.3.5 added licences fields
1443 - */
1444 - public function settings_validation($input)
1445 - {
1446 - $output = $this->get_isc_options();
1447 - $output['image_list_headline'] = esc_html($input['image_list_headline_field']);
1448 - if (isset($input['use_authorname_ckbox'])) {
1449 - // Don't worry about the custom text if the author name is selected.
1450 - $output['use_authorname'] = true;
1451 - } else {
1452 - $output['use_authorname'] = false;
1453 - $output['by_author_text'] = esc_html($input['by_author_text_field']);
1454 - }
1455 - if (isset($input['webgilde_field'])) {
1456 - $output['webgilde'] = true;
1457 - } else {
1458 - $output['webgilde'] = false;
1459 - }
1460 - if (isset($input['enable_licences'])) {
1461 - $output['enable_licences'] = true;
1462 - } else {
1463 - $output['enable_licences'] = false;
1464 - }
1465 - if (isset($input['licences'])) {
1466 - $output['licences'] = esc_textarea($input['licences']);
1467 - } else {
1468 - $output['licences'] = false;
1469 - }
1470 - if (isset($input['use_thumbnail'])) {
1471 - $output['thumbnail_in_list'] = true;
1472 - if (in_array($input['size_select'], $this->_thumbnail_size)) {
1473 - $output['thumbnail_size'] = $input['size_select'];
1474 - }
1475 - if ('custom' == $input['size_select']) {
1476 - if (is_numeric($input['thumbnail_width'])) {
1477 - // Ensures that the value stored in database in a positive integer.
1478 - $output['thumbnail_width'] = absint(round($input['thumbnail_width']));
1479 - }
1480 - if (is_numeric($input['thumbnail_height'])) {
1481 - $output['thumbnail_height'] = absint(round($input['thumbnail_height']));
1482 - }
1483 - }
1484 - } else {
1485 - $output['thumbnail_in_list'] = false;
1486 - }
1487 - if (isset($input['no_source'])) {
1488 - $output['warning_nosource'] = true;
1489 - } else {
1490 - $output['warning_nosource'] = false;
1491 - }
1492 - if (isset($input['one_source'])) {
1493 - $output['warning_onesource_missing'] = true;
1494 - } else {
1495 - $output['warning_onesource_missing'] = false;
1496 - }
1497 - if (isset($input['hide_list'])){
1498 - $output['hide_list'] = true;
1499 - } else {
1500 - $output['hide_list'] = false;
1501 - }
1502 - if (in_array($input['cap_pos'], $this->_caption_position))
1503 - $output['caption_position'] = $input['cap_pos'];
1504 - if (isset($input['source_on_image'])) {
1505 - $output['source_on_image'] = true;
1506 - $output['source_pretext'] = $input['source_pretext'];
1507 - } else {
1508 - $output['source_on_image'] = false;
1509 - }
1510 - return $output;
1511 - }
1512 -
1513 - /**
1514 464 * Add isc_image_posts on all attachments. Launched during first installation.
1515 465 */
1516 466 public function init_image_posts_metafield()
1517 467 {
@@ -1523,14 +473,15 @@
1523 473 );
1524 474 $posts = get_posts($args);
1525 475 foreach ($posts as $post) {
1526 476 setup_postdata($post);
1527 - $image_urls = $this->_filter_src_attributes($post->post_content);
477 + /*$image_urls = $this->_filter_src_attributes($post->post_content);
1528 478 $image_ids = array();
1529 479 foreach ($image_urls as $url) {
1530 480 $image_id = intval($this->get_image_by_url($url));
1531 481 array_push($image_ids,$image_id);
1532 - }
482 + }*/
483 + $image_ids = $this->_filter_image_ids($post->post_content);
1533 484 foreach ($image_ids as $id) {
1534 485 $meta = get_post_meta($id, 'isc_image_posts', true);
1535 486 if (empty($meta)) {
1536 487 update_post_meta($id, 'isc_image_posts', array($post->ID));
@@ -1536,8 +487,9 @@
1536 487 update_post_meta($id, 'isc_image_posts', array($post->ID));
1537 488 } else {
1538 489 if (!in_array($post->ID, $meta)) {
1539 490 array_push($meta, $post->ID);
491 + $meta = array_unique( $meta );
1540 492 update_post_meta($id, 'isc_image_posts', $meta);
1541 493 }
1542 494 }
1543 495 }
@@ -1544,45 +496,12 @@
1544 496 }
1545 497 }
1546 498
1547 499 /**
1548 - * Search for missing sources
1549 - */
1550 - public function admin_notices()
1551 - {
1552 - $args = array(
1553 - 'post_type' => 'attachment',
1554 - 'numberposts' => -1,
1555 - 'post_status' => null,
1556 - 'post_parent' => null,
1557 - 'meta_query' => array(
1558 - array(
1559 - 'key' => 'isc_image_source',
1560 - 'value' => '',
1561 - 'compare' => '='
1562 - ),
1563 - array(
1564 - 'key' => 'isc_image_source_own',
1565 - 'value' => '',
1566 - 'compare' => ''
1567 - )
1568 - )
1569 - );
1570 - $attachments = get_posts($args);
1571 - $options = $this->get_isc_options();
1572 - if (!empty($attachments) && $options['warning_onesource_missing'] ) {
1573 - $missing_src = esc_url(admin_url('upload.php?page=isc_missing_sources_page'));
1574 - ?>
1575 - <div class="updated"><p><?php printf(__('One or more attachments still have no source. See the <a href="%s">missing sources</a> list', ISCTEXTDOMAIN), $missing_src);?></p></div>
1576 - <?php
1577 - }
1578 - }
1579 -
1580 - /**
1581 - * transform the licences from the options textfield into an array
500 + * transform the licenses from the options textfield into an array
1582 501 *
1583 - * @param string $licences text with licences
1584 - * @return array $new_licences array with licences and licence information
502 + * @param string $licences text with licenses
503 + * @return array $new_licences array with licenses and license information
1585 504 * @return false if no array created
1586 505 * @since 1.3.5
1587 506 */
1588 507 public function licences_text_to_array($licences = '')
@@ -1604,7 +523,5 @@
1604 523
1605 524 if($new_licences == array()) return false;
1606 525 else return $new_licences;
1607 526 }
1608 -
1609 - }// end of class
1610 -}
527 +}// end of class