forked from fourpointenergy/longpoint-minerals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
1116 lines (1035 loc) · 28.9 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
/**
* Main class for the WordPress Theme
*/
class Longpoint {
/**
* Name of the directory where the theme files resides
* @var string
* @since 1.0
*/
private $theme_name = "Longpoint";
private $scripts_version = '0.90';
function __construct() {
add_action('init', array($this, 'init_assets'));
add_action('init', array($this, 'init_custom_taxonomies'));
add_action('init', array($this, 'init_custom_post_types'));
add_action('init', array($this, 'init_custom_user_roles'));
add_action('admin_init', array($this, 'restrict_dashboard'));
add_action('login_form_middle', array($this, 'add_lost_password_link'));
add_action('wp_login_failed', array($this, 'front_end_login_fail'));
// add_action( 'gform_after_submission', array($this, 'set_gform_custom_fields'));
add_theme_support('post-thumbnails');
add_image_size('Page BG Photo',1200, 900, false);
add_image_size('Profile Photo',362, 240, false);
add_image_size('Card Photo',325, 168, false);
add_filter('mce_buttons_2', 'my_mce_buttons_2');
add_filter('excerpt_more', array($this, 'new_excerpt_more'));
add_filter( 'excerpt_length', array($this, 'custom_excerpt_length'), 999 );
// custom menu support
add_theme_support('nav-menus');
if (function_exists('register_nav_menus')) {
register_nav_menus(
array(
'main-menu' => 'Main Menu',
'upper-menu' => 'Upper Menu',
'footer-menu' => 'Footer Menu'
)
);
}
// Add an options page for global options using ACF
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
}
}
function is_logged_in_investor() {
$current_user = wp_get_current_user();
if(!$current_user) return false;
foreach($current_user->roles as $role) {
if(
$role === 'investor_1'
|| $role === 'investor_2'
|| $role === 'investor_3'
|| $role === 'investor_1_2'
|| $role === 'investor_1_3'
|| $role === 'investor_2_3'
|| $role === 'investor_1_2_3'
) {
return true;
}
}
return false;
}
function the_user_display_name() {
$current_user = wp_get_current_user();
if($current_user) {
echo $current_user->display_name;
}
}
function is_in_investor_roles($roles_to_check) {
$current_user = wp_get_current_user();
if(!$current_user) return false;
foreach($current_user->roles as $role) {
foreach($roles_to_check as $role_to_check) {
switch ($role_to_check) {
case "investor_1":
if (
$role === "investor_1"
|| $role === "investor_1_2"
|| $role === "investor_1_3"
|| $role === "investor_1_2_3"
) { return true; }
break;
case "investor_2":
if (
$role === "investor_2"
|| $role === "investor_1_2"
|| $role === "investor_2_3"
|| $role === "investor_1_2_3"
) { return true; }
break;
case "investor_3":
if (
$role === "investor_3"
|| $role === "investor_1_3"
|| $role === "investor_2_3"
|| $role === "investor_1_2_3"
) { return true; }
break;
}
}
}
return false;
}
function is_in_role($role_to_check) {
$current_user = wp_get_current_user();
if(!$current_user) return false;
foreach($current_user->roles as $role) {
if($role === $role_to_check) {
return true;
}
}
return false;
}
function restrict_dashboard() {
// die("restrict dashboard");
if ( ! defined( 'DOING_AJAX' ) && ! current_user_can( 'manage_options' ) ) {
wp_redirect( "/" ); //add this url here to where someone logged in on the front end
}
}
function add_lost_password_link() {
return '<p><a href="/wp-login.php?action=lostpassword">Forgot Password?</a></p>';
}
function front_end_login_fail( $username, $password_empty = 'false', $username_empty = 'false' ) {
$referrer = $_SERVER['HTTP_REFERER']; // where did the post submission come from?
$login_type = 'admin';
if(array_key_exists('login_type', $_REQUEST)) {
$login_type = $_REQUEST['login_type'];
}
// if there's a valid referrer, and it's not the default log-in screen
if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
$pos = strpos($referrer, '?login=failed');
if($pos === false) {
// add the failed
// wp_redirect( $referrer . '?login=failed&pwblank='.$password_empty.'&ublank='.$username_empty ); // let's append some information (login=failed) to the URL for the theme to use
wp_redirect( $referrer . '?login=failed&login_type='.$login_type); // let's append some information (login=failed) to the URL for the theme to use
}
else {
// already has the failed don't appened it again
// wp_redirect( $referrer . '&pwblank='.$password_empty.'&ublank='.$username_empty ); // already appeneded redirect back
wp_redirect( $referrer ); // already appeneded redirect back
}
exit;
}
}
//This forces the login fail function if the username or password is empty
function check_login_field_empty( $user, $username, $password ) {
if ( empty( $username ) || empty( $password ) ) {
$username_empty = empty( $username );
$password_empty = empty( $password );
do_action( 'wp_login_failed', $user, $password_empty, $username_empty );
}
return $user;
}
function images_path() {
echo get_bloginfo('template_url') . '/assets/images';
}
function register_nav_menus() {
// custom menu support
add_theme_support('menus');
if (function_exists('register_nav_menus')) {
register_nav_menus(
array(
'main-menu' => 'Main Menu',
)
);
}
}
/**
* Enqueues scripts and styles for this theme.
* This function will be run on initialization.
* @return void
* @since 1.0
*/
function init_assets() {
if (!is_admin() & !is_login_page()) {
// STYLES
wp_enqueue_style($this->theme_name . '-styles', get_bloginfo('stylesheet_directory') . '/assets/build/css/main.css', false, $this->scripts_version, 'all');
wp_enqueue_style('fonts', 'https://fonts.googleapis.com/css?family=Oswald:300,400|Source+Sans+Pro:400,700,900', false, '1.0', 'all');
// SCRIPTS
wp_deregister_script('jquery');
wp_register_script('jquery', "https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js", false, null, true);
/* wp_enqueue_script('fontawesome', "http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css", false); */
wp_enqueue_script('jquery');
wp_enqueue_script('libs', get_bloginfo('stylesheet_directory') . '/assets/javascripts/libs.js', array('jquery'), $this->scripts_version, true);
wp_enqueue_script($this->theme_name . '-site', get_bloginfo('stylesheet_directory') . '/assets/build/js/main.min.js', array('jquery', 'libs'), $this->scripts_version, true);
//wp_enqueue_script($this->theme_name . '-site', get_bloginfo('stylesheet_directory') . '/assets/javascripts/main.js', array('jquery', 'libs'), $this->scripts_version, true);
}
if(is_login_page()) {
wp_enqueue_style($this->theme_name . '-styles', get_bloginfo('stylesheet_directory') . '/assets/build/css/login.css', false, $this->scripts_version, 'all');
}
}
/**
* Initialize custom post types.
*/
function init_custom_post_types() {
// Team
$labels = array(
'name' => 'Profile',
'singular_name' => 'Profile',
'add_new' => 'Add New Profile',
'add_new_item' => 'Add Profile',
'edit_item' => 'Edit Profile',
'new_item' => 'New Profile',
'all_items' => 'All Profiles',
'view_item' => 'View Profiles',
'search_items' => 'Search Profiles',
'not_found' => 'No profiles found',
'not_found_in_trash' => 'No profiles found in Trash',
'menu_name' => 'Team'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'team'),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => 3,
'exclude_from_search' => true,
'supports' => array('title','editor','author')
);
register_post_type('team', $args);
//Longpoint Features
$labels = array(
'name' => 'Feature',
'singular_name' => 'Feature',
'add_new' => 'Add New Feature',
'add_new_item' => 'Add Feature',
'edit_item' => 'Edit Feature',
'new_item' => 'New Feature',
'all_items' => 'All Features',
'view_item' => 'View Feature',
'search_items' => 'Search Features',
'not_found' => 'No features found',
'not_found_in_trash' => 'No features found in Trash',
'menu_name' => 'Features'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'features'),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'exclude_from_search' => false,
'menu_position' => 3,
'taxonomies' => array( 'feature_category' ),
);
register_post_type('longpoint-feature', $args);
}
/**
* Initialize custom taxonomies.
*/
function init_custom_taxonomies() {
/** Feature Category **/
$labels = array(
'name' => __( 'Feature Category', 'feature_categories' ),
'singular_name' => __( 'Feature Category', 'feature_category' ),
'search_items' => __( 'Search Feature Categories' ),
'all_items' => __( 'All Feature Categories' ),
'edit_item' => __( 'Edit Feature Categories' ),
'update_item' => __( 'Update Feature Category' ),
'add_new_item' => __( 'Add New Feature Category' ),
'new_item_name' => __( 'New Feature Category' ),
'menu_name' => __( 'Feature Categories' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'feature-categories'),
);
register_taxonomy('feature_category', array('longpoint-feature'), $args);
}
/**
* Initialize custom roles
**/
function init_custom_user_roles() {
// remove_role( 'investor' );
remove_role( 'contributor' );
remove_role( 'author' );
remove_role( 'editor' );
remove_role( 'subscriber' );
$role_authorizations = array(
'administrator' => false,
'read' => true, // true allows this capability
'edit_posts' => false,
'delete_posts' => false, // Use false to explicitly deny
'delete_others_posts' => false,
'delete_others_pages' => false,
'edit_others_posts' => false,
'edit_others_pages' => false,
'manage_categories' => false,
'moderate_comments' => false,
'publish_posts' => true,
'publish_pages' => false,
'upload_files' => true,
'update_core' => false,
'update_plugins' => false,
'update_themes' => false,
'install_plugins' => false,
'install_themes' => false,
'delete_themes' => false,
'delete_plugins' => false,
'edit_plugins' => false,
'edit_themes' => false,
'edit_files' => false,
'edit_users' => false,
'create_users' => false,
'delete_users' => false,
'activate_plugins' => false,
'delete_pages' => false,
);
$result = add_role(
'investor_1_2_3',
__( 'Investor Level 1, 2 and 3' ),
$role_authorizations
);
$result = add_role(
'investor_2_3',
__( 'Investor Level 2 and 3' ),
$role_authorizations
);
$result = add_role(
'investor_1_3',
__( 'Investor Level 1 and 3' ),
$role_authorizations
);
$result = add_role(
'investor_1_2',
__( 'Investor Level 1 and 2' ),
$role_authorizations
);
$result = add_role(
'investor_3',
__( 'Investor Level 3' ),
$role_authorizations
);
$result = add_role(
'investor_2',
__( 'Investor Level 2' ),
$role_authorizations
);
$result = add_role(
'investor_1',
__( 'Investor Level 1' ),
$role_authorizations
);
}
/**
* Get attached image by post ID or image ID and echo an img tag with src, alt and class attributes.
* @param number $post_id Post ID of the post the featured image is attached to.
* @param number $img_ID Used when the image is not attached to a post, but the ID is known.
* @param array $classes An array of classes to add to the image tag.
* @param string $size Size of the image to grab. Defaults to 'full'.
*/
function echo_attached_image($post_id = null, $img_ID = null, $classes = null, $size = 'full') {
if ($img_ID === null) {
$img_ID = get_post_thumbnail_id($post_id);
}
$img_src = wp_get_attachment_image_src($img_ID, $size);
if ($img_src && $img_src != '') {
$img_alt = get_post_meta($img_ID, '_wp_attachment_image_alt', true);
$img_tag = '<img src="' . $img_src[0] . '" alt="' . $img_alt . '"';
if ($classes) {
$img_tag .= ' class="';
foreach ($classes as $class) {
$img_tag .= $class . ' ';
}
$img_tag .= '" ';
}
$img_tag .= '>';
echo $img_tag;
} else {
echo '';
}
}
function get_attached_image($post_id = null, $img_ID = null, $classes = null, $size = 'full') {
if ($img_ID === null) {
$img_ID = get_post_thumbnail_id($post_id);
}
$img_src = wp_get_attachment_image_src($img_ID, $size);
if ($img_src && $img_src != '') {
$img_alt = get_post_meta($img_ID, '_wp_attachment_image_alt', true);
$img_tag = '<img src="' . $img_src[0] . '" alt="' . $img_alt . '"';
if ($classes) {
$img_tag .= ' class="';
foreach ($classes as $class) {
$img_tag .= $class . ' ';
}
$img_tag .= '" ';
}
$img_tag .= '>';
return $img_tag;
} else {
return '';
}
}
function has_attached_image($post_id = null, $img_ID = null) {
if ($img_ID === null) {
$img_ID = get_post_thumbnail_id($post_id);
}
$returnval = false;
if($img_ID && $img_ID > 0) {
$returnval = true;
}
return $returnval;
}
function get_attached_image_url($post_id = null, $img_ID = null, $classes = null, $size = 'full') {
if ($img_ID === null) {
$img_ID = get_post_thumbnail_id($post_id);
}
$img_src = wp_get_attachment_image_src($img_ID, $size);
if ($img_src && $img_src != '') {
return $img_src[0];
} else {
return '';
}
}
function echo_attached_image_url($post_id = null, $img_ID = null, $classes = null, $size = 'full') {
if ($img_ID === null) {
$img_ID = get_post_thumbnail_id($post_id);
}
$img_src = wp_get_attachment_image_src($img_ID, $size);
if ($img_src && $img_src != '') {
echo $img_src[0];
}
}
function echo_links_from_title($str) {
$return_val = str_replace(" ", "-", strtolower($str));
$return_val = str_replace('’', '', $return_val);
echo ($return_val);
}
// Removes Trackbacks from the comment cout
function comment_count($count) {
if (!is_admin()) {
global $id;
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
// custom excerpt ellipses for 2.9+
function custom_excerpt_more($more) {
return 'READ MORE »';
}
// no more jumping for read more link
function no_more_jumping($post) {
return '<a href="' . get_permalink($post->ID) . '" class="read-more">' . ' Continue Reading »' . '</a>';
}
// category id in body and post class
function category_id_class($classes) {
global $post;
foreach ((get_the_category($post->ID)) as $category) {
$classes[] = 'cat-' . $category->cat_ID . '-id';
}
return $classes;
}
// adds a class to the post if there is a thumbnail
function has_thumb_class($classes) {
global $post;
if (has_post_thumbnail($post->ID)) {$classes[] = 'has_thumb';}
return $classes;
}
function security_measures() {
// removes detailed login error information for security
add_filter('login_errors', create_function('$a', "return null;"));
// removes the WordPress version from your header for security
add_filter('the_generator', create_function('$a', "return '';"));
}
function get_excerpt_by_id($post_id){
$the_post = get_post($post_id); //Gets post ID
$the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt
$excerpt_length = 55; //Sets excerpt length by word count
$the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); //Strips tags and images
if(strlen($the_excerpt) > $excerpt_length) {
$the_excerpt = trim(substr($the_excerpt,0,$excerpt_length)).'…';
}
$the_excerpt = '<p>' . $the_excerpt . '</p>';
return $the_excerpt;
}
/**
* Auto login after registration.
*/
function pi_gravity_registration_autologin( $user_id, $user_config, $entry, $password ) {
$user = get_userdata( $user_id );
$user_login = $user->user_login;
$user_password = $password;
wp_signon( array(
'user_login' => $user_login,
'user_password' => $user_password,
'remember' => false
) );
}
function new_excerpt_more($more) {
return '...';
}
function custom_excerpt_length( $length ) {
return 20;
}
}
$lp_theme = new Longpoint();
function register_editor_style() {
add_editor_style('editor-styles.css');
}
// Callback function to insert 'styleselect' into the $buttons array
function my_mce_buttons_2($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
function is_login_page() {
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
}
show_admin_bar(false);
// disable random password
add_filter( 'random_password', 'disable_random_password', 10, 2 );
function disable_random_password( $password ) {
$action = isset( $_GET['action'] ) ? $_GET['action'] : '';
if ( 'wp-login.php' === $GLOBALS['pagenow'] && ( 'rp' == $action || 'resetpass' == $action ) ) {
return '';
}
return $password;
}
/* Set a custom order for the longpoint features archive */
function wp_order_category( $query ) {
// exit out if it's the admin or it isn't the main query
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if( is_search() ) {
$query->set( 'numberposts', '100' );
$query->set( 'posts_per_page', '100' );
}
// order category archives by title in ascending order
if($query->query && array_key_exists('post_type',$query->query) && $query->query['post_type'] === 'longpoint-feature') {
$query->set( 'meta_key' , 'feature_date' );
$query->set( 'order' , 'desc' );
$query->set( 'orderby' , 'meta_value_num' );
if(get_query_var('filter')) {
$filter = get_query_var('filter');
$tax_query = array(
array(
'taxonomy' => 'feature_category',
'field' => 'slug',
'terms' => $filter
)
);
if($filter && $filter != '') {
// var_dump($tax_query);
// die($filter);
$query->set( 'tax_query' , $tax_query );
}
}
return;
}
}
add_action( 'pre_get_posts', 'wp_order_category', 1 );
function custom_query_vars_filter($vars) {
$vars[] = 'filter';
return $vars;
}
add_filter('query_vars', 'custom_query_vars_filter');
/* Customize Login Message */
function custom_login_message( $message ) {
if ( empty($message) ){
return "<p><strong>You need to be logged in to view this page. Please login to continue</strong></p>";
} else {
return $message;
}
}
add_filter( 'login_message', 'custom_login_message' );
/* Redirect all longpoint features to main features page */
add_action( 'template_redirect', 'redirect_post_type_features' );
function redirect_post_type_features(){
if ( ! is_singular( 'longpoint-feature' ) )
return;
wp_redirect( get_page_link( 7 ), 301 );
exit;
}
/* Redirect all longpoint team to about us page */
add_action( 'template_redirect', 'redirect_post_type_team' );
function redirect_post_type_team(){
if ( ! is_singular( 'team' ) )
return;
wp_redirect( get_page_link( 9 ), 301 );
exit;
}
// Return error if email is not set for password retrieval
add_action( 'lostpassword_post', 'email_only_lostpassword_post', 10, 1 );
function email_only_lostpassword_post( $errors ){
if( !is_email($_POST['user_login']) ){
$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid email address.'));
return $errors;
}
}
// Translate some login page text
add_filter( 'gettext', 'email_only_login_labels', 20, 3 );
function email_only_login_labels( $translated_text, $text, $domain ) {
if (in_array( $GLOBALS['pagenow'], array( 'wp-login.php' ) )) {
if ($translated_text === 'Username or Email Address') {
$translated_text = 'Email Address';
}
if ($translated_text === 'Please enter your username or email address. You will receive a link to create a new password via email.') {
$translated_text = 'Please enter your email address. You will receive a link to create a new password via email.';
}
}
return $translated_text;
}
/* ==================================================================
Filter Gravity Forms Submissions for spammy words
================================================================== */
/*
* Use an array to search a string
* Allows us to pass the stop words list and our post data
*/
function strpos_arr($haystack, $needle) {
if (!is_array($needle)) $needle = array($needle);
foreach($needle as $what) {
if ( ($pos = stripos($haystack, $what)) !== false ) {
return $pos;
}
}
return false;
}
/* -------------------------------------------------------------------------------------- */
add_action('gform_pre_submission', 'keywords_check');
// The form ID is currently set to ID 1 - shown in the above line gform_pre_submission_1.
// If you want to apply it to form ID 2 then change _1 it to _2
function keywords_check($form){
// function keywords_check($validation_result){
// $form = $validation_result["form"];
// -------> Enter all the keywords that you want to block. <------------ */
$stop_words = array(
'acrotomophilia',
'alabama hot pocket',
'alaskan pipeline',
'anal',
'anilingus',
'anus',
'apeshit',
'arsehole',
'ass',
'asshole',
'assmunch',
'auto erotic',
'autoerotic',
'babeland',
'baby batter',
'baby juice',
'ball gag',
'ball gravy',
'ball kicking',
'ball licking',
'ball sack',
'ball sucking',
'bangbros',
'bareback',
'barely legal',
'barenaked',
'bastard',
'bastardo',
'bastinado',
'bbw',
'bdsm',
'beaner',
'beaners',
'beaver cleaver',
'beaver lips',
'bestiality',
'big black',
'big breasts',
'big knockers',
'big tits',
'bimbos',
'birdlock',
'bitch',
'bitches',
'black cock',
'blonde action',
'blonde on blonde action',
'blowjob',
'blow job',
'blow your load',
'blue waffle',
'blumpkin',
'bollocks',
'bondage',
'boner',
'boob',
'boobs',
'booty call',
'brown showers',
'brunette action',
'bukkake',
'bulldyke',
'bullet vibe',
'bullshit',
'bung hole',
'bunghole',
'busty',
'butt',
'buttcheeks',
'butthole',
'camel toe',
'camgirl',
'camslut',
'camwhore',
'carpet muncher',
'carpetmuncher',
'chocolate rosebuds',
'circlejerk',
'cleveland steamer',
'clit',
'clitoris',
'clover clamps',
'clusterfuck',
'cock',
'cocks',
'coprolagnia',
'coprophilia',
'cornhole',
'coon',
'coons',
'creampie',
'cum',
'cumming',
'cunnilingus',
'cunt',
'darkie',
'date rape',
'daterape',
'debit',
'deep throat',
'deepthroat',
'dendrophilia',
'dick',
'dildo',
'dingleberry',
'dingleberries',
'dirty pillows',
'dirty sanchez',
'doggie style',
'doggiestyle',
'doggy style',
'doggystyle',
'dog style',
'dolcett',
'domination',
'dominatrix',
'dommes',
'donkey punch',
'double dong',
'double penetration',
'dp action',
'dry hump',
'dvda',
'eat my ass',
'ecchi',
'ejaculation',
'erotic',
'erotism',
'escort',
'eunuch',
'faggot',
'fecal',
'felch',
'fellatio',
'feltch',
'female squirting',
'femdom',
'figging',
'fingerbang',
'fingering',
'fisting',
'foot fetish',
'footjob',
'frotting',
'fuck',
'fuck buttons',
'fuckin',
'fucking',
'fucktards',
'fudge packer',
'fudgepacker',
'futanari',
'gang bang',
'gay sex',
'genitals',
'giant cock',
'girl on',
'girl on top',
'girls gone wild',
'goatcx',
'goatse',
'god damn',
'gokkun',
'golden shower',
'goodpoop',
'goo girl',
'goregasm',
'grope',
'group sex',
'g-spot',
'guro',
'hand job',
'handjob',
'hard core',
'hardcore',
'hentai',
'homoerotic',
'honkey',
'hooker',
'hot carl',
'hot chick',
'how to kill',
'how to murder',
'huge fat',
'humping',
'incest',
'intercourse',
'jack off',
'jail bait',
'jailbait',
'jelly donut',
'jerk off',
'jigaboo',
'jiggaboo',
'jiggerboo',
'jizz',
'juggs',
'kike',
'kinbaku',
'kinkster',
'kinky',
'knobbing',
'leather restraint',
'leather straight jacket',
'lemon party',
'lolita',
'lovemaking',
'make me come',
'male squirting',
'masturbate',
'menage a trois',
'milf',
'missionary position',
'motherfucker',
'mound of venus',
'mr hands',
'muff diver',
'muffdiving',
'nambla',
'nawashi',
'negro',
'neonazi',
'nigga',
'nigger',
'nig nog',
'nimphomania',
'nipple',
'nipples',
'nsfw images',
'nude',
'nudity',
'nympho',
'nymphomania',
'octopussy',
'omorashi',
'one cup two girls',
'one guy one jar',
'orgasm',
'orgy',
'paedophile',
'paki',
'panties',
'panty',
'pedobear',
'pedophile',
'pegging',
'penis',
'prescription',
'phone sex',
'piece of shit',
'pissing',
'piss pig',
'pisspig',
'playboy',
'pleasure chest',
'pole smoker',
'ponyplay',
'poof',
'poon',
'poontang',
'punany',
'poop chute',
'poopchute',
'porn',
'porno',
'pornography',
'prince albert piercing',
'pthc',
'pubes',
'pussy',
'queaf',
'queef',
'quim',
'raghead',
'raging boner',
'rape',
'raping',
'rapist',
'rectum',