PluginProbe
GetResponse Forms by Optin Cat / 1.8.0
GetResponse Forms by Optin Cat v1.8.0
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
getresponse / powerups / 2_custom_css / powerup.php

powerup.php in GetResponse Forms by Optin Cat 1.8.0, at powerups/2_custom_css/powerup.php

101 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /***** ADD OPTIONS *****/
4
5 function fca_eoi_add_powerup_2( $array ) {
6
7 $array[] = array( 'custom_css', 'Custom CSS', 'fca_eoi_checkbox_callback', 'fca_eoi_powerup_settings_section', __( 'Add custom CSS inside the form editor.' ,'easy-opt-ins') );
8 return $array;
9
10 }
11 add_filter( 'fca_eoi_setting_filter', 'fca_eoi_add_powerup_2' );
12
13 $options = get_option( 'fca_eoi_settings' );
14
15 if ( !empty ( $options['custom_css'] ) ) {
16 new EoiCustomCssBox();
17 }
18
19 class EoiCustomCssBox {
20
21 public function __construct() {
22 add_action( 'fca_eoi_powerups', array( $this, 'show_custom_css_field' ) );
23 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
24 add_action( 'admin_print_footer_scripts', array( $this, 'enqueue_admin_footer_js' ) );
25 add_filter( 'fca_eoi_alter_form', array( $this, 'append_css_to_form' ) , 10 , 2 );
26 }
27
28 public function init() {
29 }
30
31 public function append_css_to_form( $content , $fca_eoi_meta ) {
32
33 if( $css = K::get_var( 'custom_css', $fca_eoi_meta ) ) {
34 $content .= "<style>$css</style>";
35 }
36
37 return $content;
38 }
39
40 /*
41 * Add fieldset custom css box
42 */
43 public function show_custom_css_field( $fca_eoi_meta ) {
44 echo '<div class="eoi-custom-css-form" style="width:40.5em;">';
45 K::textarea( 'fca_eoi[custom_css]'
46 , array(
47 'class' => 'fca_eoi_custom_css_textbox',
48 'placeholder' => __( 'Enter your custom CSS here...' ),
49 )
50 , array(
51 'value' => K::get_var( 'custom_css', $fca_eoi_meta, '' ),
52 'format' => '<label> Custom CSS</label><br />:textarea',
53 )
54 );
55 echo '</div>';
56 }
57
58 public function enqueue_admin_scripts() {
59
60 $protocol = is_ssl() ? 'https' : 'http';
61 $screen = get_current_screen();
62
63 // Exit function if not in one of our plugin pages
64 if( 'easy-opt-ins' !== $screen->id ){
65 return;
66 }
67
68 // Enqueue CodeMirror JS and CSS
69 $codemirror_prefix = "$protocol://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/";
70 $codemirror_js = array(
71 'codemirror' => 'codemirror.min.js',
72 'codemirror-css' => 'mode/css/css.min.js',
73 'codemirror-placeholder' => 'addon/display/placeholder.min.js',
74 );
75 foreach ( $codemirror_js as $handle => $path) {
76 wp_enqueue_script( $handle, $codemirror_prefix . $path, array(), FCA_EOI_VER, true );
77 }
78 wp_enqueue_style('codemirror', $codemirror_prefix . 'codemirror.min.css', array(), FCA_EOI_VER );
79 }
80
81 public function enqueue_admin_footer_js() {
82 ?><script type="text/javascript">
83
84 jQuery( document ).ready( function( $ ) {
85
86 // Add CodeMirrors
87 $( '.fca_eoi_custom_css_textbox' ).each( function( i, el ) {
88 var editor = CodeMirror.fromTextArea( el, {
89 mode: "text/css",
90 matchBrackets: true,
91 lineNumbers: true,
92 lineWrapping: true,
93 foldGutter: true,
94 gutters: [ "CodeMirror-linenumbers", "CodeMirror-foldgutter" ]
95 } );
96 } );
97 } );
98 </script><?php
99 }
100 }
101