"; } /* REMOVE LINKS FOR USERS WITH FEWER PERMISSIONS THAN EDITOR */ function fca_eoi_remove_admin_bar_link() { if (!current_user_can( 'delete_others_pages' ) && function_exists( 'remove_meta_box' )){ remove_meta_box( 'fca_eoi_dashboard_widget', 'dashboard', 'normal' ); } } add_action( 'wp_dashboard_setup', 'fca_eoi_remove_admin_bar_link', 50 ); function fca_eoi_get_error_texts($post_meta) { $name_error = empty ( $post_meta[ 'error_text_field_required' ] ) ? "Please enter a valid email address. For example \"hi@fatcatapps.com\"." : $post_meta[ 'error_text_field_required' ]; $email_error = empty ( $post_meta[ 'error_text_invalid_email' ] ) ? 'Please fill out this field to continue.' : $post_meta[ 'error_text_invalid_email' ]; $errorTexts = array( 'field_required' => $name_error, 'invalid_email' => $email_error, ); return $errorTexts; } function fca_eoi_get_thanks_mode($post_meta) { $mode = empty ( $post_meta[ 'thankyou_page_mode' ] ) ? 'ajax' : $post_meta[ 'thankyou_page_mode' ]; return $mode; } //CHECK IF USER HAS AN ACTIVE CUSTOM FORM IN ONE OF THEIR OPT INS, OTHERWISE TURN OFF THIS FEATURE function fca_eoi_set_custom_form_depreciation() { $optins_using_customform = get_posts( array( 'post_type' => 'easy-opt-ins', 'posts_per_page' => -1, 'post_status' => 'any', 'meta_key' => 'fca_eoi_provider', 'meta_value' => 'customform', )); $forms_in_trash = get_posts( array( 'post_type' => 'easy-opt-ins', 'posts_per_page' => -1, 'post_status' => 'trash', 'meta_key' => 'fca_eoi_provider', 'meta_value' => 'customform', )); if ( count ( $optins_using_customform ) > 0 OR count ( $forms_in_trash ) > 0) { update_option ( 'fca_eoi_allow_customform', 'true' ); } else { update_option ( 'fca_eoi_allow_customform', 'false' ); } } function fca_eoi_get_html( $form_id, $fca_eoi_meta ) { $selected_layout = $fca_eoi_meta[ 'layout' ]; if( empty( $selected_layout ) OR empty ( $fca_eoi_meta ) ) { return 'Form data missing'; } $list_ids = array ( 'mailchimp_list_id', 'campaignmonitor_list_id', 'getresponse_list_id', 'aweber_list_id', 'drip_list_id' ); $list_id = 'Not Set'; forEach ($list_ids as $id ) { if ( !empty ($fca_eoi_meta[$id]) ) { $list_id = $fca_eoi_meta[$id]; break; } } $errorTexts = fca_eoi_get_error_texts($fca_eoi_meta); //determine if ajax or thank you page redirect $thanks_mode = fca_eoi_get_thanks_mode($fca_eoi_meta); if ( $thanks_mode === 'redirect' ) { $mode = empty ( $fca_eoi_meta[ 'redirect_page_mode' ] ) ? 'page' : $fca_eoi_meta[ 'redirect_page_mode' ]; $home_url = get_site_url(); if ( $mode === 'page' ) { $thanks_page = get_permalink( K::get_var( 'thank_you_page', $fca_eoi_meta, $home_url ) ); } else { $thanks_page = empty ( $fca_eoi_meta[ 'thank_you_url' ] ) ? $home_url : $fca_eoi_meta[ 'thank_you_url' ]; } } else { $thanks_page = htmlentities ( K::get_var( 'thankyou_ajax', $fca_eoi_meta, 'Thank you! Please check your inbox for your confirmation email.' ), ENT_QUOTES, "UTF-8"); } $sub_msg = htmlentities ( K::get_var( 'subscribing_message', $fca_eoi_meta, 'Subscribing...' ), ENT_QUOTES, "UTF-8"); $layout_helper = new EasyOptInsLayout( $selected_layout ); $php_path = $layout_helper->path_to_resource( 'layout', 'php' ); $html_path = $layout_helper->path_to_resource( 'layout', 'html' ); $html_wrap_path = $layout_helper->path_to_html_wrapper(); $scss_path = $layout_helper->path_to_resource( 'layout', 'scss' ); $form_wrapper = ''; $form_wrapper_end = ''; if ( $layout_helper->layout_type != 'lightbox' ) { $form_wrapper = '
'; $form_wrapper_end = '
'; } //SET UP TEMPLATE $layout_html = str_replace('{{{layout}}}',file_get_contents( $html_path ),file_get_contents( $html_wrap_path )); global $dh_easy_opt_ins_plugin; if ( $dh_easy_opt_ins_plugin->post_type_obj->settings[ 'distribution' ] === 'free' ) { $banding = K::get_var( 'show_fatcatapps_link', $fca_eoi_meta, false ); $banding = $banding ? "" : ''; } else { $banding = ''; } $form_head = $form_wrapper; $form_head .= "
"; $form_head .= "
', '{{{description_copy}}}', '{{{headline_copy}}}', '{{{name_field}}}', '{{{email_field}}}', '{{{submit_button}}}', '{{{privacy_copy}}}', '{{{fatcatapps_link}}}', '
', ), array( $form_head, '
{{{description_copy}}}
', '
{{{headline_copy}}}
', "", '', '
', '
{{{privacy_copy}}}
', $banding, '
' . $form_wrapper_end, ), $layout_html ); //ADD TEXTS $show_headline = K::get_var( 'show_headline_field', $fca_eoi_meta, 'on' ); $show_description = K::get_var( 'show_description_field', $fca_eoi_meta, 'on' ); $show_privacy = K::get_var( 'show_privacy_field', $fca_eoi_meta, 'on' ); $headline_copy = $show_headline == 'off' ? '' : $fca_eoi_meta[ 'headline_copy' ]; $description_copy = $show_description == 'off' ? '' : $fca_eoi_meta[ 'description_copy' ]; $name_placeholder = $fca_eoi_meta[ 'name_placeholder' ]; $email_placeholder = $fca_eoi_meta[ 'email_placeholder' ]; $button_copy = $fca_eoi_meta[ 'button_copy' ]; $privacy_copy = $show_privacy == 'off' ? '' : $fca_eoi_meta[ 'privacy_copy' ]; $output = str_replace( array( '{{{headline_copy}}}', '{{{description_copy}}}', '{{{name_placeholder}}}', '{{{email_placeholder}}}', '{{{button_copy}}}', '{{{privacy_copy}}}', ), array( $headline_copy, $description_copy, $name_placeholder, $email_placeholder, $button_copy, $privacy_copy, ), $layout_html ); $output = apply_filters( 'fca_eoi_alter_form', $output, $fca_eoi_meta ); return $output; } //ADD KEYUP ACTION TO TINY MCE VISUAL EDITOR function fca_eoi_tiny_mce_before_init( $initArray ) { global $post; if ( is_object ( $post ) && $post->post_type == 'easy-opt-ins' ) { $initArray['setup'] = << 'easy-opt-ins', 'post_status' => 'publish', 'posts_per_page'=> -1, ); $posts_array = get_posts( $args ); $settings = array ( 'form_background_color_selector' => 'background-color', 'form_border_color_selector' => 'border-color', 'headline_font_size_selector' => 'font-size', 'headline_font_color_selector' => 'color', 'headline_background_color_selector' => 'background-color', 'description_font_size_selector' => 'font-size', 'description_font_color_selector' => 'color', 'name_font_size_selector' => 'font-size', 'name_font_color_selector' => 'color', 'name_background_color_selector' => 'background-color', 'name_border_color_selector' => 'border-color', 'email_font_size_selector' => 'font-size', 'email_font_color_selector' => 'color', 'email_background_color_selector' => 'background-color', 'email_border_color_selector' => 'border-color', 'button_font_size_selector' => 'font-size', 'button_font_color_selector' => 'color', 'button_background_color_selector' => 'background-color', 'button_wrapper_background_color_selector' => 'background-color', 'privacy_font_size_selector' => 'font-size', 'privacy_font_color_selector' => 'color', 'branding_font_color_selector' => 'color', ); forEach ( $posts_array as $post ) { $form_id = $post->ID; $version = get_post_meta( $post->ID, 'fca_eoi_meta_format', true ); //ONLY CONVERT OLD VERSIONS if ( $version != '2.0' ) { $meta = get_post_meta( $post->ID, 'fca_eoi', true ); //FIX FOR EMPTY LAYOUT? SET THE DEFAULT $layout = empty ( $meta['layout'] ) ? 'postbox_1' : $meta['layout']; $new_meta['layout'] = $layout; $new_meta = $meta; unset ( $new_meta[$layout] ); $i = 0; forEach ( $meta[$layout] as $selector => $array ) { $type = ''; if ( $i == 0 ) { $type = 'form'; } else if ( strpos($selector, 'headline') !== false ) { $type = 'headline'; } else if ( strpos($selector, 'description') !== false ) { $type = 'description'; } else if ( strpos($selector, 'name') !== false ) { $type = 'name'; } else if ( strpos($selector, 'email') !== false ) { $type = 'email'; } else if ( strpos($selector, 'submit_button_wrapper input:hover') !== false ) { $type = 'hover'; } else if ( strpos($selector, 'submit_button_wrapper input') !== false && strpos($selector, 'hover') === false ) { $type = 'button'; } else if ( strpos($selector, 'privacy') !== false ) { $type = 'privacy'; } else if ( strpos($selector, 'fatcatapps') !== false ) { $type = 'branding'; } forEach ($array as $css_property => $value ) { if ( !empty ( $type ) ) { if ( $type == 'hover' ) { $new_meta['button_wrapper_background_color_selector'] = '.fca_eoi_layout_submit_button_wrapper'; $new_meta['button_wrapper_background_color'] = $value; } else { $new_key = $type . '_' . str_replace ('-', '_', $css_property) . '_selector'; if ( strpos( $new_key, 'color' ) !== false && strpos( $new_key, 'border' ) === false && strpos( $new_key, 'background' ) === false ) { $new_key = str_replace ('_color', '_font_color', $new_key); } $new_meta[trim($new_key)] = $selector; $new_value_key = $type . '_' . str_replace ('-', '_', $css_property); if ( strpos( $new_value_key, 'color' ) !== false && strpos( $new_value_key, 'border' ) === false && strpos( $new_value_key, 'background' ) === false ) { $new_value_key = str_replace ('_color', '_font_color', $new_value_key); } $new_meta[trim($new_value_key)] = $value; } } } $i++; } //SOME SPECIAL CASES if ( empty ( $new_meta['email_font_size'] ) ) { $new_meta['email_font_size_selector'] = 'div.fca_eoi_layout_email_field_wrapper'; $new_meta['email_font_size'] = '13px'; } if ( empty ( $new_meta['name_font_size'] ) ) { $new_meta['name_font_size_selector'] = 'div.fca_eoi_layout_name_field_wrapper'; $new_meta['name_font_size'] = '13px'; } //POSSIBLE FIX FOR PUBLICATION MODE if ( stripos ( $new_meta[ 'layout' ], 'lightbox') === FALSE && array_key_exists( 'publish_lightbox_mode', $new_meta )) { unset ( $new_meta['publish_lightbox_mode'] ); } //COMPILE CSS AND SAVE INTO 'HEAD' META // General CSS for all forms $css = "'; $html = fca_eoi_get_html ( $form_id, $new_meta ); $head = $head . $html; update_post_meta( $post->ID, 'fca_eoi', $new_meta ); update_post_meta( $post->ID, 'fca_eoi_meta_format', '2.0' ); update_post_meta( $post->ID, 'fca_eoi_head', $head ); } } } function fca_eoi_convert_option_save() { $old_options = get_option('paf'); $license = get_option('fca_eoi_license_key'); $new_options = array( 'license_key' => $license, ); $options = array ( 'eoi_powerup_custom_css' => 'custom_css', 'eoi_powerup_optin_bait' => 'optin_bait', 'eoi_powerup_animation' => 'animation', 'eoi_powerup_mp_groups' => 'mailchimp_groups', ); if ( !empty( $old_options ) ) { forEach ( $options as $key => $value ) { if ( !empty ( $old_options[$key] ) && $old_options[$key][0] == 'on' ) { $new_options[$value] = 1; } } update_option( 'fca_eoi_settings', $new_options ); delete_option ( 'paf' ); delete_option ( 'fca_eoi_license_key' ); } }