| 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' )){ |
| 12 |
remove_meta_box( 'fca_eoi_dashboard_widget', 'dashboard', 'normal' ); |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
add_action( 'wp_before_admin_bar_render', 'FCA_EOI_remove_admin_bar_link' ); |
| 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 |
$mode = $post_meta[ 'thankyou_page_mode' ]; |
| 55 |
|
| 56 |
if (empty ($mode)) { |
| 57 |
$mode = 'not set'; |
| 58 |
} |
| 59 |
|
| 60 |
return $mode; |
| 61 |
|
| 62 |
} |
| 63 |
|
| 64 |
function fca_eoi_migrate_css() { |
| 65 |
|
| 66 |
require_once FCA_EOI_PLUGIN_DIR . 'powerups/4_new_css/powerup.php'; |
| 67 |
|
| 68 |
//CHECK CURRENT SETTING |
| 69 |
$isActive = powerup_new_css_is_active(); |
| 70 |
|
| 71 |
if ( !$isActive ) { |
| 72 |
|
| 73 |
$new_css_obj = new EoiNewCssMigration(); |
| 74 |
$new_css_obj->migrate( 'old', 'new' ); |
| 75 |
|
| 76 |
powerup_new_css_set_active( TRUE ); |
| 77 |
} |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
function fca_eoi_compile_scss() { |
| 82 |
require_once FCA_EOI_PLUGIN_DIR . 'includes/eoi-layout.php'; |
| 83 |
$layouts_types = array( 'lightbox', 'postbox', 'widget'); |
| 84 |
$fca_eoi_global_scss_array = array(); |
| 85 |
foreach ( $layouts_types as $layout_type ) { |
| 86 |
|
| 87 |
foreach ( glob( FCA_EOI_PLUGIN_DIR . "layouts/$layout_type/*", GLOB_ONLYDIR ) as $layout_path ) { |
| 88 |
|
| 89 |
$layout_id = basename( $layout_path ); |
| 90 |
$layout_helper = new EasyOptInsLayout( $layout_id ); |
| 91 |
$scss = $layout_helper->new_scss_compiler(); |
| 92 |
$scss_path = $layout_helper->path_to_resource( 'layout', 'scss' ); |
| 93 |
|
| 94 |
if ( EasyOptInsLayout::uses_new_css() ) { |
| 95 |
$layout[ 'css' ] = file_exists( $scss_path ) |
| 96 |
? '#fca_eoi_preview_form_container {' . |
| 97 |
file_get_contents( $scss_path ) . |
| 98 |
'.fca_eoi_layout_popup_close {' . |
| 99 |
'display: none;' . |
| 100 |
'}' . |
| 101 |
'}' |
| 102 |
: '' |
| 103 |
; |
| 104 |
} else { |
| 105 |
$layout[ 'css' ] = file_exists( $scss_path ) |
| 106 |
? file_get_contents( $scss_path) |
| 107 |
: '' |
| 108 |
; |
| 109 |
} |
| 110 |
|
| 111 |
// Add $ltr SASS variable |
| 112 |
$layout[ 'css' ] = sprintf( '$ltr: %s;', is_rtl() ? 'false' : 'true' ) |
| 113 |
. $layout[ 'css' ] |
| 114 |
; |
| 115 |
|
| 116 |
$name = $layout[ 'css' ]; |
| 117 |
$layout[ 'css' ] = $scss->compile( $layout[ 'css' ] ); |
| 118 |
$fca_eoi_global_scss_array[$name] = $layout[ 'css' ]; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
$file = FCA_EOI_PLUGIN_DIR . "includes/cache"; |
| 123 |
$fileWrite = file_put_contents($file, serialize($fca_eoi_global_scss_array)); |
| 124 |
} |