| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
/* ADD ANIMATION CSS TO FRONT-END AND ADMIN PAGES WHEN ENABLED */ |
| 5 |
add_action( 'fca_eoi_display_lightbox', 'fca_eoi_load_animation_script_popup' ); |
| 6 |
add_action( 'fca_eoi_render_animation_meta_box', 'fca_eoi_load_animation_script_popup' ); |
| 7 |
|
| 8 |
/* REMOVE LINKS FOR USERS WITH FEWER PERMISSIONS THAN EDITOR */ |
| 9 |
|
| 10 |
function FCA_EOI_remove_admin_bar_link() { |
| 11 |
if (!current_user_can( 'delete_others_pages' ) && function_exists( 'remove_meta_box' )){ |
| 12 |
remove_meta_box( 'fca_eoi_dashboard_widget', 'dashboard', 'normal' ); |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
add_action( 'wp_dashboard_setup', 'FCA_EOI_remove_admin_bar_link', 50 ); |
| 17 |
|
| 18 |
$fca_eoi_animation_enabled = false; //ONLY ENQUEUE WHEN ITS TURNED ON |
| 19 |
|
| 20 |
function fca_eoi_load_animation_script_popup() { |
| 21 |
global $fca_eoi_animation_enabled; |
| 22 |
if ( $fca_eoi_animation_enabled ) { |
| 23 |
wp_enqueue_style( 'fca_eoi_powerups_animate', FCA_EOI_PLUGIN_URL . '/assets/vendor/animate/animate.css' ); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
function fca_eoi_get_error_texts($id) { |
| 28 |
|
| 29 |
$post_meta = get_post_meta( $id , 'fca_eoi', true ); |
| 30 |
$errorTexts = array( |
| 31 |
'field_required' => $post_meta[ 'error_text_field_required' ], |
| 32 |
'invalid_email' => $post_meta[ 'error_text_invalid_email' ], |
| 33 |
); |
| 34 |
|
| 35 |
if (!empty($errorTexts['field_required']) AND !empty($errorTexts['invalid_email'])) { |
| 36 |
return array( |
| 37 |
'field_required' => $errorTexts['field_required'], |
| 38 |
'invalid_email' => $errorTexts['invalid_email'], |
| 39 |
); |
| 40 |
|
| 41 |
}else{ |
| 42 |
|
| 43 |
return array( |
| 44 |
'field_required' => 'Error: This field is required.', |
| 45 |
'invalid_email' => "Error: Please enter a valid email address. For example \"max@domain.com\"." |
| 46 |
); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
function fca_eoi_get_thanks_mode($id) { |
| 51 |
|
| 52 |
$post_meta = get_post_meta( $id , 'fca_eoi', true ); |
| 53 |
|
| 54 |
empty ( $post_meta[ 'thankyou_page_mode' ] ) ? $mode = 'not set' : $mode = $post_meta[ 'thankyou_page_mode' ]; |
| 55 |
|
| 56 |
return $mode; |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
//CHECK IF USER HAS AN ACTIVE CUSTOM FORM IN ONE OF THEIR OPT INS, OTHERWISE TURN OFF THIS FEATURE |
| 62 |
function fca_eoi_set_custom_form_depreciation() { |
| 63 |
|
| 64 |
$optins_using_customform = get_posts( array( |
| 65 |
'post_type' => 'easy-opt-ins', |
| 66 |
'posts_per_page' => -1, |
| 67 |
'post_status' => 'any', |
| 68 |
'meta_key' => 'fca_eoi_provider', |
| 69 |
'meta_value' => 'customform', |
| 70 |
|
| 71 |
)); |
| 72 |
|
| 73 |
$forms_in_trash = get_posts( array( |
| 74 |
'post_type' => 'easy-opt-ins', |
| 75 |
'posts_per_page' => -1, |
| 76 |
'post_status' => 'trash', |
| 77 |
'meta_key' => 'fca_eoi_provider', |
| 78 |
'meta_value' => 'customform', |
| 79 |
|
| 80 |
)); |
| 81 |
|
| 82 |
if ( count ( $optins_using_customform ) > 0 OR count ( $forms_in_trash ) > 0) { |
| 83 |
update_option ( 'fca_eoi_allow_customform', 'true' ); |
| 84 |
} else { |
| 85 |
update_option ( 'fca_eoi_allow_customform', 'false' ); |
| 86 |
} |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
function fca_eoi_migrate_css() { |
| 92 |
|
| 93 |
require_once FCA_EOI_PLUGIN_DIR . 'powerups/4_new_css/powerup.php'; |
| 94 |
|
| 95 |
//CHECK CURRENT SETTING |
| 96 |
$isActive = powerup_new_css_is_active(); |
| 97 |
|
| 98 |
if ( !$isActive ) { |
| 99 |
|
| 100 |
$new_css_obj = new EoiNewCssMigration(); |
| 101 |
$new_css_obj->migrate( 'old', 'new' ); |
| 102 |
|
| 103 |
powerup_new_css_set_active( TRUE ); |
| 104 |
} |
| 105 |
|
| 106 |
} |