-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
2544 lines (2308 loc) · 128 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// Report all PHP errors
/** Acoes iniciais ** */
//define('ALTERNATE_WP_CRON', true);
wp_register_script('jquery.min', get_template_directory_uri() . '/libraries/js/jquery.min.js', array('jquery'), '1.7');
wp_enqueue_script('jquery.min');
add_action('init', 'wpdbfix');
add_action('init', 'register_post_types');
add_action('init', 'register_taxonomies');
//load_theme_textdomain("tainacan", dirname(__FILE__) . "/languages");
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
include_once( dirname(__FILE__) . "/config/config.php" );
/**
* Criando tabela taxonomymeta
*
*/
function setup_taxonomymeta() {
global $wpdb;
$charset_collate = '';
if (!empty($wpdb->charset))
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if (!empty($wpdb->collate))
$charset_collate .= " COLLATE $wpdb->collate";
$tables_taxonomymeta = $wpdb->get_results("show tables like '{$wpdb->prefix}taxonomymeta'");
if (count($tables_taxonomymeta)) {
$wpdb->query("ALTER TABLE {$wpdb->prefix}taxonomymeta
CHANGE taxonomy_id term_id bigint(20);");
$wpdb->query("ALTER TABLE {$wpdb->prefix}taxonomymeta
RENAME TO {$wpdb->prefix}termmeta;");
}
$tables_termeta = $wpdb->get_results("show tables like '{$wpdb->prefix}termmeta'");
if (!count($tables_termeta))
$wpdb->query("CREATE TABLE {$wpdb->prefix}termmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment,
term_id bigint(20) unsigned NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
KEY term_id (term_id),
KEY meta_key (meta_key)
) $charset_collate;");
}
/*
* Quick touchup to wpdb
*/
/*
* Quick touchup to wpdb
*/
function wpdbfix() {
global $wpdb;
if (!isset($wpdb->termmeta)) {
$wpdb->termmeta = "{$wpdb->prefix}termmeta";
}
}
//
// Term Meta funtions para Wordpress inferiores ao 4.4
//
/**
* Update term meta field based on term ID.
*
* Use the $prev_value parameter to differentiate between meta fields with the
* same key and term ID.
*
* If the meta field for the term does not exist, it will be added.
*
* @param int $term_id Term ID.
* @param string $key Metadata key.
* @param mixed $value Metadata value.
* @param mixed $prev_value Optional. Previous value to check before removing.
* @return bool False on failure, true if success.
*/
if (!function_exists('update_term_meta')) {
function update_term_meta($term_id, $meta_key, $meta_value, $prev_value = '') {
return update_metadata('term', $term_id, $meta_key, $meta_value, $prev_value);
}
}
/**
* Add meta data field to a term.
*
* @param int $term_id Post ID.
* @param string $key Metadata name.
* @param mixed $value Metadata value.
* @param bool $unique Optional, default is false. Whether the same key should not be added.
* @return bool False for failure. True for success.
*/
if (!function_exists('add_term_meta')) {
function add_term_meta($term_id, $meta_key, $meta_value, $unique = false) {
return add_metadata('term', $term_id, $meta_key, $meta_value, $unique);
}
}
/**
* Remove metadata matching criteria from a term.
*
* You can match based on the key, or key and value. Removing based on key and
* value, will keep from removing duplicate metadata with the same key. It also
* allows removing all metadata matching key, if needed.
*
* @param int $term_id term ID
* @param string $meta_key Metadata name.
* @param mixed $meta_value Optional. Metadata value.
* @return bool False for failure. True for success.
*/
if (!function_exists('delete_term_meta')) {
function delete_term_meta($term_id, $meta_key, $meta_value = '') {
return delete_metadata('term', $term_id, $meta_key, $meta_value);
}
}
/**
* Retrieve term meta field for a term.
*
* @param int $term_id Term ID.
* @param string $key The meta key to retrieve.
* @param bool $single Whether to return a single value.
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single
* is true.
*/
if (!function_exists('get_term_meta')) {
function get_term_meta($term_id, $key, $single = false) {
return get_metadata('term', $term_id, $key, $single);
}
}
/* * **************** MENU FUNCTION PARA O WORDPRESS ADMIN *********************** */
/**
* Registra o menu do Tainacan no Wordpress
*
* @return void Apenas insere o menu do tainacan no wordpress
*/
function register_my_menu() {
register_nav_menu('header-menu', __('Header Menu', 'tainacan'));
}
add_action('init', 'register_my_menu');
/* * **************** END MENU FUNCTION PARA O WORDPRESS ADMIN *********************** */
$conditional_scripts = array(
'html5shiv' => '//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.js',
'html5shiv-printshiv' => '//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv-printshiv.js',
'respond' => '//cdn.jsdelivr.net/respond/1.4.2/respond.min.js'
);
foreach ($conditional_scripts as $handle => $src) {
wp_enqueue_script($handle, $src, array(), '', false);
}
add_filter('script_loader_tag', function( $tag, $handle ) use ( $conditional_scripts ) {
if (array_key_exists($handle, $conditional_scripts)) {
$tag = "<!--[if lt IE 9]>$tag<![endif]-->";
}
return $tag;
}, 10, 2);
/* * * CONSTANTE PATH DO WORDPRESS * */
if (!defined('WORDPRESS_PATH')) {
$iroot = getcwd();
$folder = explode("/", $iroot);
if (count($folder) == 1) {
define('WORDPRESS_PATH', $folder[0]);
} else {
define('WORDPRESS_PATH', $iroot);
}
}
/**
* Retorna uma string com o tipo text/html.
*
* @return void retorna o tipo text/html.
*/
function set_html_content_type() {
return 'text/html';
}
function modify_attachment_link($markup) {
return preg_replace('/^<a([^>]+)>(.*)$/', '<a\\1 target="_blank">\\2', $markup);
}
add_filter('wp_get_attachment_link', 'modify_attachment_link', 10, 6);
/**
* Altera o link para os feeds
* * */
add_action('template_redirect', 'socialdb_catch_uri', 99);
function socialdb_catch_uri() {
global $wp_query;
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (get_query_var('collection_name')) {
$_GET['collection_id'] = get_post_by_name(get_query_var('collection_name'))->ID;
$_GET['operation'] = 'feed';
$_GET['by_function'] = true;
$get_privacity = wp_get_object_terms($_GET['collection_id'], 'socialdb_collection_type');
if ($get_privacity) {
foreach ($get_privacity as $privacity) {
$privacity_name = $privacity->name;
}
}
if ($privacity_name == 'socialdb_collection_public') {
require_once 'controllers/rss/rss_controller.php';
exit();
} else {
wp_redirect(get_the_permalink($_GET['collection_id']));
}
} else if (get_query_var('oaipmh')) {
$_GET['by_function'] = true;
//$template = locate_template('single-socialdb-oai.php', true);
require_once 'controllers/export/oaipmh_controller.php';
exit();
} else if (strpos($actual_link, '.rdf') !== false) {
require_once 'controllers/export/rdf_controller.php';
exit();
}
}
add_filter('query_vars', 'my_queryvars');
function my_queryvars($qvars) {
$qvars[] = 'collection_name';
$qvars[] = 'oaipmh';
return $qvars;
}
function custom_rewrite_tag() {
add_rewrite_tag('%collection_name%', '([^&]+)');
add_rewrite_tag('%oaipmh%', '([^&]+)');
}
add_action('init', 'custom_rewrite_tag', 10, 0);
function custom_rewrite_basic() {
add_rewrite_rule('^feed_collection/([^/]*)', 'index.php?collection_name=$matches[1]', 'top');
add_rewrite_rule('^oai', 'index.php?oaipmh=true', 'top');
flush_rewrite_rules();
}
add_action('init', 'custom_rewrite_basic', 10, 0);
/**
* Mostra a barra de admin padrão do wordpress apenas para usuarios com permissao de administrador
* * */
if (!current_user_can('manage_options')) {
show_admin_bar(false);
}
/**
* Função responsavel pelas respostas dos comentários
* * */
function tainacan_comments($comment, $args, $depth) {
global $global_collection_id;
global $global_term_id;
$object = get_post(get_the_ID());
$is_from = get_comment_meta(get_comment_ID(), 'socialdb_is_comment_from', true);
// se nao pertencer a este termo item/propriedade/tag
if ($is_from != 'object' && $is_from != $global_term_id) {
return false;
}
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ('div' == $args['style']) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class(empty($args['has_children']) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<div class="col-md-12 comment-box-container">
<?php if ('div' != $args['style']) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="col-md-1 no-padding">
<?php if ($args['avatar_size'] != 0) echo get_avatar($comment, $args['avatar_size']); ?>
</div>
<div class="col-md-11">
<div class="row">
<div class="comment-author vcard" style="font-weight: bolder">
<?php printf(__('<span class="fn">%s</span>', 'tainacan'), get_comment_author_link()); ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.', 'tainacan'); ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata">
<a href="javascript:void(0)"> <?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()); ?> </a>
<?php edit_comment_link(__('(Painel Edit )', 'tainacan'), ' ', ''); ?>
</div>
</div>
<div class="row">
<div id="comment_text_<?php comment_ID(); ?>">
<?php comment_text(); ?>
</div>
<div style="display:none" id="comment_edit_field_<?php comment_ID(); ?>">
<form class="form-inline">
<div class="form-group">
<textarea id="edit_field_value_<?php comment_ID(); ?>" class="form-control" id="exampleInputEmail3">
</textarea>
</div>
<button type="button" onclick="cancelEditComment('<?php comment_ID(); ?>')" class="btn btn-default"><?php _e('Cancel', 'tainacan') ?></button>
<button type="button" onclick="submitEditComment('<?php comment_ID(); ?>')" class="btn btn-default"><?php _e('Save', 'tainacan') ?></button>
</form>
</div>
</div>
<div class="row reply" id="reply_<?php comment_ID(); ?>">
<div class="col-md-12 left">
<div class="col-md-1 no-padding">
<a href="#div-comment-<?php comment_ID(); ?>" onclick="showModalReply('<?php comment_ID(); ?>');"><b><?php _e("Reply", 'tainacan'); ?></b></a>
</div>
<?php if (!CollectionModel::is_moderator($global_collection_id, get_current_user_id()) && get_userdata(get_current_user_id())->display_name !== get_comment_author()): ?>
<?php if (verify_allowed_action($global_collection_id, 'socialdb_collection_permission_delete_comment')): ?>
<div class="col-md-1 no-padding">
<a href="#div-comment-<?php comment_ID(); ?>" onclick="showModalReportAbuseComment('<?php comment_ID(); ?>');"><span class="glyphicon glyphicon-bullhorn"></span> <?php _e("Report Abuse", 'tainacan'); ?></a>
</div>
<?php endif; ?>
<?php else: ?>
<div class="col-md-1 no-padding">
<a href="#div-comment-<?php comment_ID(); ?>" onclick="showEditComment('<?php comment_ID(); ?>');"><span class="glyphicon glyphicon-pencil"></span> <?php _e("Edit", 'tainacan'); ?></a>
</div>
<div class="col-md-1 no-padding">
<a href="#div-comment-<?php comment_ID(); ?>" onclick="showAlertDeleteComment('<?php comment_ID(); ?>', '<?php _e('Attention!') ?>', '<?php _e('Delete this comment?', 'tainacan') ?>', '<?php echo mktime(); ?>');"><span class="glyphicon glyphicon-remove"></span> <?php _e("Delete", 'tainacan'); ?></a>
</div>
<?php endif; ?>
<div class="col-md-2 no-padding">
<a href="#" id="resources_collection_button" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" style="display:inline-block;">
<div style="display: inline-block">
<div style="font-size:1em; cursor:pointer;" data-icon=""></div>
</div>
<span> <?php _e('Share', 'tainacan')?> </span>
</a>
<ul id="resources_collection_dropdown" class="dropdown-menu" role="menu">
<li>
<!-- ******************** FACEBOOK ******************** -->
<a target="_blank" href="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=<?php echo get_the_permalink($global_collection_id) . '?item=' . $object->post_name; ?>&p[images][0]=<?php echo wp_get_attachment_url(get_post_thumbnail_id($object->ID)); ?>&p[title]=<?php _e("Comment", 'tainacan'); ?> - <?php echo htmlentities($object->post_title); ?>&p[summary]=<?php comment_text(); ?>">
<img src="<?php echo get_template_directory_uri() ?>/libraries/images/icon_facebook.png" style="max-width: 32px;" />
</a>
</li>
<li>
<!-- ******************** GOOGLE PLUS ******************** -->
<a target="_blank" href="https://plus.google.com/share?url=<?php echo get_the_permalink($global_collection_id) . '?item=' . $object->post_name; ?>">
<img src="<?php echo get_template_directory_uri() ?>/libraries/images/icon_googleplus.png" style="max-width: 32px;" />
</a>
</li>
<li>
<!-- ******************** TWITTER ******************** -->
<a target="_blank" href="https://twitter.com/intent/tweet?url=<?php echo get_the_permalink($global_collection_id) . '?item=' . $object->post_name; ?>&text=<?php echo strip_tags(get_comment_text()); ?>&via=socialdb">
<img src="<?php echo get_template_directory_uri() ?>/libraries/images/icon_twitter.png" style="max-width: 32px;" />
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<?php if ('div' != $args['style']) : ?>
</div>
<?php endif; ?>
</div>
<?php
}
/**
* Logout Redirect
* Automatically redirect to current page after user logout WordPress.
*/
function get_current_logout($logout_url) {
if (!is_admin()) {
$logout_url = add_query_arg('redirect_to', urlencode(( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), $logout_url);
}
return $logout_url;
}
add_filter('logout_url', 'get_current_logout');
//add_filter('login_url', 'get_current_logout');
/* * ************************************************************************************* */
/**
* SocialDB Theme Option Page
*/
function socialdb_theme_menu() {
add_theme_page('SocialDB Option', 'SocialDB Option', 'manage_options', 'socialdb_theme_options.php', 'socialdb_theme_page');
}
add_action('admin_menu', 'socialdb_theme_menu');
/**
* Callback function to the add_theme_page
* Will display the theme options page
*/
function socialdb_theme_page() {
?>
<div class="section panel">
<h1>Custom SocialDB Options</h1>
<form method="post" enctype="multipart/form-data" action="options.php">
<?php
settings_fields('socialdb_theme_options');
do_settings_sections('socialdb_theme_options.php');
?>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes', 'tainacan') ?>" />
</p>
</form>
</div>
<?php
}
/**
* Register the settings to use on the theme options page
*/
add_action('admin_init', 'socialdb_register_settings');
/**
* Function to register the settings
*/
function socialdb_register_settings() {
// Register the settings with Validation callback
register_setting('socialdb_theme_options', 'socialdb_theme_options', 'socialdb_validate_settings');
// Add settings section
add_settings_section('socialdb_fb_section', 'Facebook API Login', 'socialdb_display_section', 'socialdb_theme_options.php');
// Create textbox field
$field_args_fb_id = array(
'type' => 'text',
'id' => 'socialdb_fb_api_id',
'name' => 'socialdb_fb_api_id',
'desc' => 'Facebook API ID',
'std' => '',
'label_for' => 'socialdb_fb_api_id',
'class' => 'css_class'
);
$field_args_fb_secret = array(
'type' => 'text',
'id' => 'socialdb_fb_api_secret',
'name' => 'socialdb_fb_api_secret',
'desc' => 'Facebook API Secret',
'std' => '',
'label_for' => 'socialdb_fb_api_secret',
'class' => 'css_class'
);
add_settings_field('socialdb_fb_api_id', 'API ID', 'socialdb_display_setting', 'socialdb_theme_options.php', 'socialdb_fb_section', $field_args_fb_id);
add_settings_field('socialdb_fb_api_secret', 'API Secret', 'socialdb_display_setting', 'socialdb_theme_options.php', 'socialdb_fb_section', $field_args_fb_secret);
// Add settings section
add_settings_section('socialdb_embed_ly_section', 'Embed Ly API', 'socialdb_display_section_embed', 'socialdb_theme_options.php');
// Create textbox field
$field_args_embed_id = array(
'type' => 'text',
'id' => 'socialdb_embed_api_id',
'name' => 'socialdb_embed_api_id',
'desc' => 'API ID',
'std' => '',
'label_for' => 'socialdb_embed_api_id',
'class' => 'css_class'
);
add_settings_field('socialdb_embed_api_id', 'Embed Ly API ID', 'socialdb_display_setting', 'socialdb_theme_options.php', 'socialdb_embed_ly_section', $field_args_embed_id);
}
/**
* Function to add extra text to display on each section
*/
function socialdb_display_section($section) {
_e('Session responsible for the use of facebook API to login.', 'tainacan');
}
/**
* Function to add extra text to display on each section
*/
function socialdb_display_section_embed($section) {
_e('Session responsible for the use of Embed Ly API. (http://embed.ly/)', 'tainacan');
}
/**
* Function to display the settings on the page
* This is setup to be expandable by using a switch on the type variable.
* In future you can add multiple types to be display from this function,
* Such as checkboxes, select boxes, file upload boxes etc.
*/
function socialdb_display_setting($args) {
extract($args);
$option_name = 'socialdb_theme_options';
$options = get_option($option_name);
switch ($type) {
case 'text':
$options[$id] = stripslashes($options[$id]);
$options[$id] = esc_attr($options[$id]);
echo "<input class='regular-text$class' type='text' id='$id' name='" . $option_name . "[$id]' value='$options[$id]' />";
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
break;
}
}
/**
* Callback function to the register_settings function will pass through an input variable
* You can then validate the values and the return variable will be the values stored in the database.
*/
function socialdb_validate_settings($input) {
foreach ($input as $k => $v) {
$newinput[$k] = trim($v);
// Check the input is a letter or a number
if (!preg_match('/^[A-Z0-9 _]*$/i', $v)) {
$newinput[$k] = '';
}
}
return $newinput;
}
//************************************************************************************************************/
//************************************************************************************************************/
/* function register_post_types() */
/* Recebe () */
/* Registra todos os post type utilizados pelo SocialDB */
/* Autor: Eduardo Humberto */
function register_post_types() {
/* Detalhes do post type collection */
$collection_args = array(
'public' => true,
'query_var' => 'collection',
'rewrite' => array(
'slug' => 'collection',
'with_front' => false),
'supports' => array(
'title',
'editor',
'author',
'excerpt',
'comments',
'custom-fields',
'thumbnail'),
'labels' => array(
'name' => __('Collections', 'tainacan'),
'menu_name' => __('SocialDB', 'tainacan'),
'all_items' => __('All Collections', 'tainacan'),
'singular_name' => __('Collection', 'tainacan'),
'add_new' => __('Add Collection', 'tainacan'),
'add_new_item' => __('Add Collection', 'tainacan'),
'edit_item' => __('Edit Collection', 'tainacan'),
'new_item' => __('New Collection', 'tainacan'),
'view_item' => __('View Collection', 'tainacan'),
'search_items' => __('Search Collection', 'tainacan'),
'not_found' => __('No Collection Found', 'tainacan'),
'not_found_in_trash' => __('No Collection Found in Trash', 'tainacan')),
//'menu_icon' => WP_IDEA_STREAM_PLUGIN_URL . '/images/is-logomenu.png',
'taxonomies' => array(
'socialdb_collection_type', 'socialdb_tag'),
);
/* register the collection post-type */
register_post_type('socialdb_collection', $collection_args);
/* Detalhes do post type collection */
$oai_args = array(
'public' => true,
'query_var' => 'oai',
'rewrite' => array(
'slug' => 'oai',
'with_front' => false)
//'menu_icon' => WP_IDEA_STREAM_PLUGIN_URL . '/images/is-logomenu.png',
);
/* register the collection post-type */
register_post_type('socialdb-oai', $oai_args);
/* Detalhes do post type object */
$object_args = array(
'public' => true,
'query_var' => 'object',
'rewrite' => array(
'slug' => 'object',
'with_front' => false),
'supports' => array(
'title',
'editor',
'author',
'excerpt',
'comments',
'custom-fields',
'thumbnail'),
'labels' => array(
'name' => __('Object', 'tainacan'),
'menu_name' => __('Object', 'tainacan'),
'all_items' => __('All Objects', 'tainacan'),
'singular_name' => __('Object', 'tainacan'),
'add_new' => __('Add Object', 'tainacan'),
'add_new_item' => __('Add Object', 'tainacan'),
'edit_item' => __('Edit Object', 'tainacan'),
'new_item' => __('New Object', 'tainacan'),
'view_item' => __('View Object', 'tainacan'),
'search_items' => __('Search Object', 'tainacan'),
'not_found' => __('No Object Found', 'tainacan'),
'not_found_in_trash' => __('No Object Found in Trash', 'tainacan')),
// 'menu_icon' => WP_IDEA_STREAM_PLUGIN_URL . '/images/is-logomenu.png',
'taxonomies' => array('socialdb_category'),
);
/* register the object post-type */
register_post_type('socialdb_object', $object_args);
flush_rewrite_rules();
register_post_type('socialdb_channel');
register_post_type('socialdb_vote');
register_post_type('socialdb_event');
register_post_type('socialdb_license');
}
/* function register_taxonomies() */
/* Recebe () */
/* Registra todos as txonomies utilizados pelo SocialDB */
/* Autor: Eduardo Humberto */
function register_taxonomies() {
$category_args = array(
'hierarchical' => true,
'query_var' => 'category',
'rewrite' => array(
'slug' => 'category',
'with_front' => false),
'labels' => array(
'name' => __('Category', 'tainacan'),
'singular_name' => __('Category', 'tainacan'),
'edit_item' => __('Edit Category', 'tainacan'),
'update_item' => __('Update Category', 'tainacan'),
'add_new_item' => __('Add New Category', 'tainacan'),
'new_item_name' => __('New Category Name', 'tainacan'),
'all_items' => __('All Categories', 'tainacan'),
'search_items' => __('Search Categories', 'tainacan'),
'parent_item' => __('Parent Category', 'tainacan'),
'parent_item_colon' => __('Parent Category:', 'tainacan')),
);
register_taxonomy('socialdb_category_type', array('socialdb_object'), $category_args);
register_taxonomy('socialdb_tag_type', array('socialdb_collection'));
register_taxonomy('socialdb_channel_type', array('socialdb_channel'));
register_taxonomy('socialdb_license_type', array('socialdb_license'));
register_taxonomy('socialdb_collection_type', array('socialdb_collection'));
register_taxonomy('socialdb_property_type', array('socialdb_vote'));
register_taxonomy('socialdb_event_type', array('socialdb_event'));
}
function create_oai_post() {
$post = array(
'post_title' => 'socialdb-oai',
'post_status' => 'publish',
'post_type' => 'socialdb-oai'
);
$object_id = wp_insert_post($post);
return $object_id;
}
function create_standart_licenses() {
$getLicenses = get_option('socialdb_standart_licenses');
if (!$getLicenses):
$licenses = [
'Creative Commons CC BY',
'Creative Commons CC BY-ND',
'Creative Commons CC BY-NC-SA',
'Creative Commons CC BY-SA',
'Creative Commons CC BY-NC',
'Creative Commons CC BY-NC-ND'
];
$arrId = array();
foreach ($licenses as $license) {
$post = array(
'post_title' => $license,
'post_status' => 'publish',
'post_type' => 'socialdb_license'
);
$object_id = wp_insert_post($post);
wp_set_object_terms($object_id, array((int) get_term_by('slug', 'socialdb_license_public', 'socialdb_license_type')->term_id), 'socialdb_license_type');
$arrId[] = $object_id;
}
update_option('socialdb_standart_licenses', $arrId);
endif;
//return $arrId;
}
function create_anonimous_user() {
$user = get_option('anonimous_user');
if (!$user) {
$user_id = wp_create_user('Anonimous', '12345678', '[email protected]');
if ($user_id) {
update_option('anonimous_user', $user_id);
}
}
}
/**
* function verify_allowed_action($collection_id)
* @param string $collection_id
* @return boolean With term_id created.
*
* Funcao generica que verifica se o usuario pode ao menos realizar a acao
* Autor: Eduardo Humberto
*/
function verify_allowed_action($collection_id, $name_permission, $object_id = 0) {
$user_id = get_current_user_id();
$permission = get_post_meta($collection_id, $name_permission, true);
$is_admin = verify_collection_moderators($collection_id, $user_id);
if (!$is_admin && $object_id != 0) {
$item = get_post($object_id);
$is_admin = ($item->post_author == $user_id) ? true : false;
}
if ($is_admin) {
return true;
} else {
if ($permission == 'unallowed') {
return false;
} else {
return true;
}
}
}
/**
* function create_register($name_register,$taxonomy)
* @param string $name_register
* @param string $taxonomy Metadata name.
* @return array With term_id created.
*
* Funcao generica para criar registros, Retorna o id do registro ou cria um novo, caso nao exista
* Autor: Eduardo Humberto
*/
function create_register($name_register, $taxonomy, $args = array()) {
if (isset($args['slug'])) {
$register_term = get_term_by('slug', $args['slug'], $taxonomy);
} else {
$register_term = get_term_by('name', $name_register, $taxonomy);
}
//inserting
if (!$register_term) {
$register_term = wp_insert_term($name_register, $taxonomy, $args);
} else {
$term_id = $register_term->term_id;
$register_term = array();
$register_term['term_id'] = $term_id;
}
return $register_term;
}
/**
* function create_metas($term_id,$meta_key,$meta_value,$previous_value)
* @param int $term_id
* @param string $meta_key Metadata name.
* @param string $meta_value Metadata value.
* @param string $previous_value Metadata name.
* @return array With term_id created.
*
* Funcao generica para criar ou atualizar os meta dados na tabela taxonomy meta
* Autor: Eduardo Humberto
*/
function create_metas($term_id, $meta_key, $meta_value, $previous_value) {
$register_term = get_term_meta($term_id, $meta_key); // pega os valores que estao neste meta key
if (!$register_term) {//se ele nao exisitr
$result = add_term_meta($term_id, $meta_key, $meta_value); // insere
} else {
if ($register_term[0] != '' && $meta_value == '') {// se o registro for vazio e se atualizacao tb for vazia
$result = update_term_meta($term_id, $meta_key, $register_term[0]);
} elseif (in_array($previous_value, $register_term)) {// se o valor anterior ja exisitir ele atualiza o valor anterior
$result = update_term_meta($term_id, $meta_key, $meta_value, $previous_value);
} else {// se nao apenas adiciona
$result = add_term_meta($term_id, $meta_key, $meta_value);
}
}
return $result;
}
/**
* function init_nav()
* Funcao para iniciar a navegação do JIT
* Autor: Eduardo Humberto
*/
function init_nav($data) {
switch ($data) {
case "regular":
wp_register_script('ExecuteDefault', get_template_directory_uri() . '/libraries/js/jit/executeDefault.js');
wp_enqueue_script('ExecuteDefault');
break;
case "hypertree":
wp_register_script('HypertreeJs', get_template_directory_uri() . '/libraries/js/jit/Hypertree.js');
wp_enqueue_script('HypertreeJs');
wp_register_style('HypertreeCss', get_template_directory_uri() . '/libraries/css/jit/Hypertree.css');
wp_enqueue_style('HypertreeCss');
wp_register_script('ExecuteHypertree', get_template_directory_uri() . '/libraries/js/jit/executeHypertree.js');
wp_enqueue_script('ExecuteHypertree');
break;
case "spacetree":
wp_register_script('SpacetreeJs', get_template_directory_uri() . '/libraries/js/jit/Spacetree.js');
wp_enqueue_script('SpacetreeJs');
wp_register_style('SpacetreeCss', get_template_directory_uri() . '/libraries/css/jit/Spacetree.css');
wp_enqueue_style('SpacetreeCss');
wp_register_script('ExecuteSpacetree', get_template_directory_uri() . '/libraries/js/jit/executeSpacetree.js');
wp_enqueue_script('ExecuteSpacetree');
break;
case "treemap":
wp_register_script('TreemapJs', get_template_directory_uri() . '/libraries/js/jit/Treemap.js');
wp_enqueue_script('TreemapJs');
wp_register_style('TreemapCss', get_template_directory_uri() . '/libraries/css/jit/Treemap.css');
wp_enqueue_style('TreemapCss');
wp_register_script('ExecuteTreemap', get_template_directory_uri() . '/libraries/js/jit/executeTreemap.js');
wp_enqueue_script('ExecuteTreemap');
break;
case "rgraph":
wp_register_script('RgraphJs', get_template_directory_uri() . '/libraries/js/jit/Rgraph.js');
wp_enqueue_script('RgraphJs');
wp_register_style('RgraphCss', get_template_directory_uri() . '/libraries/css/jit/Rgraph.css');
wp_enqueue_style('RgraphCss');
wp_register_script('ExecuteRgraph', get_template_directory_uri() . '/libraries/js/jit/executeRgraph.js');
wp_enqueue_script('ExecuteRgraph');
break;
default:
wp_register_script('ExecuteDefault', get_template_directory_uri() . '/libraries/js/jit/executeDefault.js');
wp_enqueue_script('ExecuteDefault');
break;
}
}
/**
* function create_register()
* Funcao para criar os registros da colecao
* Autor: Eduardo Humberto
*/
function create_collection_terms() {
$collection_root_term = create_register('socialdb_collection', 'socialdb_collection_type');
/* adiciona ou atualiza os metas */
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_post_type', 'socialdb_collection_post_type');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_facet_type', 'socialdb_collection_facet_type');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_facets', 'socialdb_collection_facets');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_object_type', 'socialdb_collection_object_type');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_moderators', 'socialdb_collection_moderators');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_group_admin', 'socialdb_collection_group_admin');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_channel', 'socialdb_collection_channel');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_license', 'socialdb_collection_license');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_default_ordering', 'socialdb_collection_default_ordering');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_columns', 'socialdb_collection_columns');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_board_background_color', 'socialdb_collection_board_background_color');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_board_border_color', 'socialdb_collection_board_border_color');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_board_link_color', 'socialdb_collection_board_link_color');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_board_skin_mode', 'socialdb_collection_board_skin_mode');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_board_font_color', 'socialdb_collection_board_font_color');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_hide_title', 'socialdb_collection_hide_title');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_hide_description', 'socialdb_collection_hide_description');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_hide_thumbnail', 'socialdb_collection_hide_thumbnail');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_hide_menu', 'socialdb_collection_hide_menu');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_hide_categories', 'socialdb_collection_hide_categories');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_hide_rankings', 'socialdb_collection_hide_rankings');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_size_thumbnail', 'socialdb_collection_size_thumbnail');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_hide_tags', 'socialdb_collection_hide_tags');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_ordenation_form', 'socialdb_collection_ordenation_form');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_address', 'socialdb_collection_address');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_mapping_exportation_active', 'socialdb_collection_mapping_exportation_active');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_allow_hierarchy', 'socialdb_collection_allow_hierarchy');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_download_control', 'socialdb_collection_download_control');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_parent', 'socialdb_collection_parent');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_license_pattern', 'socialdb_collection_license_pattern');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_license_enabled', 'socialdb_collection_license_enabled');
//Permissions
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_create_category', 'socialdb_collection_permission_create_category');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_edit_category', 'socialdb_collection_permission_edit_category');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_delete_category', 'socialdb_collection_permission_delete_category');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_add_classification', 'socialdb_collection_permission_add_classification');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_delete_classification', 'socialdb_collection_permission_delete_classification');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_create_object', 'socialdb_collection_permission_create_object');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_delete_object', 'socialdb_collection_permission_delete_object');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_create_property_data', 'socialdb_collection_permission_create_property_data');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_edit_property_data', 'socialdb_collection_permission_edit_property_data');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_delete_property_data', 'socialdb_collection_permission_delete_property_data');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_edit_property_data_value', 'socialdb_collection_permission_edit_property_data_value');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_create_property_object', 'socialdb_collection_permission_create_property_object');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_edit_property_object', 'socialdb_collection_permission_edit_property_object');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_delete_property_object', 'socialdb_collection_permission_delete_property_object');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_edit_property_object_value', 'socialdb_collection_permission_edit_property_object_value');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_create_property_term', 'socialdb_collection_permission_create_property_term');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_edit_property_term', 'socialdb_collection_permission_edit_property_term');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_delete_property_term', 'socialdb_collection_permission_delete_property_term');
//Permissions Comment
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_create_comment', 'socialdb_collection_permission_create_comment');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_edit_comment', 'socialdb_collection_permission_edit_comment');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_delete_comment', 'socialdb_collection_permission_delete_comment');
//Permissions Tags
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_create_tags', 'socialdb_collection_permission_create_tags');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_edit_tags', 'socialdb_collection_permission_edit_tags');
create_metas($collection_root_term['term_id'], 'socialdb_collection_metas', 'socialdb_collection_permission_delete_tags', 'socialdb_collection_permission_delete_tags');
//exit();
/* subfilhos */
$collection_public_term = create_register('socialdb_collection_public', 'socialdb_collection_type', array('parent' => $collection_root_term['term_id']));
$collection_private_term = create_register('socialdb_collection_private', 'socialdb_collection_type', array('parent' => $collection_root_term['term_id']));
}
/**
* function create_tag_terms()
* Funcao para criar os registros tag principal
* Autor: Eduardo Humberto
*/
function create_tag_terms() {
$tag_term = create_register('socialdb_tag', 'socialdb_tag_type');
}
/**
* function create_property_terms()
* Funcao para criar os registros dos canais
* Autor: Eduardo Humberto
*/
function create_property_terms() {
$property_root_term = create_register('socialdb_property', 'socialdb_property_type');
create_metas($property_root_term['term_id'], 'socialdb_property_metas', 'socialdb_property_required', 'socialdb_property_required');
create_metas($property_root_term['term_id'], 'socialdb_property_metas', 'socialdb_property_default_value', 'socialdb_property_default_value');
create_metas($property_root_term['term_id'], 'socialdb_property_metas', 'socialdb_property_help', 'socialdb_property_help');
create_metas($property_root_term['term_id'], 'socialdb_property_metas', 'socialdb_property_created_category', 'socialdb_property_created_category');
create_metas($property_root_term['term_id'], 'socialdb_property_metas', 'socialdb_property_collection_id', 'socialdb_property_collection_id');
create_metas($property_root_term['term_id'], 'socialdb_property_metas', 'socialdb_property_used_by_categories', 'socialdb_property_used_by_categories');
//action para adicao de metadados para a propriedade
do_action('add_new_metas_property', $property_root_term);
/* subfilhos */
$property_data_term = create_register('socialdb_property_data', 'socialdb_property_type', array('parent' => $property_root_term['term_id']));
create_metas($property_data_term['term_id'], 'socialdb_property_data_metas', 'socialdb_property_data_column_ordenation', 'socialdb_property_data_column_ordenation');
create_metas($property_data_term['term_id'], 'socialdb_property_data_metas', 'socialdb_property_data_widget', 'socialdb_property_data_widget');
create_metas($property_data_term['term_id'], 'socialdb_property_data_metas', 'socialdb_property_data_cardinality', 'socialdb_property_data_cardinality');
//action para adicao de metadados para a propriedade de dados
do_action('add_new_metas_property_data', $property_data_term);
/* Criando a propriedade recentes para ordenacao da colecao */
create_register(__('Recents', 'tainacan'), 'socialdb_property_type', array('parent' => $property_data_term['term_id'], 'slug' => 'socialdb_ordenation_recent'));
$property_object_term = create_register('socialdb_property_object', 'socialdb_property_type', array('parent' => $property_root_term['term_id']));
create_metas($property_object_term['term_id'], 'socialdb_property_object_metas', 'socialdb_property_object_category_id', 'socialdb_property_object_category_id');
create_metas($property_object_term['term_id'], 'socialdb_property_object_metas', 'socialdb_property_object_is_facet', 'socialdb_property_object_is_facet');
create_metas($property_object_term['term_id'], 'socialdb_property_object_metas', 'socialdb_property_object_is_reverse', 'socialdb_property_object_is_reverse');
create_metas($property_object_term['term_id'], 'socialdb_property_object_metas', 'socialdb_property_object_reverse', 'socialdb_property_object_reverse');
create_metas($property_object_term['term_id'], 'socialdb_property_object_metas', 'socialdb_property_object_cardinality', 'socialdb_property_object_cardinality');
//action para adicao de metadados para a propriedade de objeto
do_action('add_new_metas_property_object', $property_object_term);
$property_term_term = create_register('socialdb_property_term', 'socialdb_property_type', array('parent' => $property_root_term['term_id']));
create_metas($property_term_term['term_id'], 'socialdb_property_term_metas', 'socialdb_property_term_root', 'socialdb_property_term_root');
create_metas($property_term_term['term_id'], 'socialdb_property_term_metas', 'socialdb_property_term_widget', 'socialdb_property_term_widget');
create_metas($property_root_term['term_id'], 'socialdb_property_term_metas', 'socialdb_property_term_cardinality', 'socialdb_property_term_cardinality');
$property_ranking_term = create_register('socialdb_property_ranking', 'socialdb_property_type', array('parent' => $property_root_term['term_id']));
create_metas($property_ranking_term['term_id'], 'socialdb_property_ranking_metas', 'socialdb_property_ranking_vote', 'socialdb_property_ranking_vote');
/* sub-subfilhos */
$property_ranking_like_term = create_register('socialdb_property_ranking_like', 'socialdb_property_type', array('parent' => $property_ranking_term['term_id']));
$property_ranking_binary_term = create_register('socialdb_property_ranking_binary', 'socialdb_property_type', array('parent' => $property_ranking_term['term_id']));
$property_ranking_stars_term = create_register('socialdb_property_ranking_stars', 'socialdb_property_type', array('parent' => $property_ranking_term['term_id']));
}
/**