PluginProbe
GetResponse Forms by Optin Cat / 2.0.2
GetResponse Forms by Optin Cat v2.0.2
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 / includes / eoi-powerups.php

eoi-powerups.php in GetResponse Forms by Optin Cat 2.0.2, at includes/eoi-powerups.php

140 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 //
3 // Handle Powerups / Settings page
4 //
5
6 // Load all powerups
7 foreach ( glob( FCA_EOI_PLUGIN_DIR . 'powerups/*', GLOB_ONLYDIR ) as $powerup_path ) {
8 require_once "$powerup_path/powerup.php";
9 }
10
11 function fca_eoi_register_setting_page() {
12 add_submenu_page(
13 'edit.php?post_type=easy-opt-ins',
14 __('Settings', 'easy-opt-ins'),
15 __('Settings', 'easy-opt-ins'),
16 'manage_options',
17 'fca_eoi_settings_page',
18 'fca_eoi_settings_page'
19 );
20
21 }
22 add_action('admin_menu', 'fca_eoi_register_setting_page');
23
24 function fca_eoi_register_settings() {
25 global $dh_easy_opt_ins_plugin;
26 $fca_eoi_options = get_option( 'fca_eoi_settings' );
27 if( !$fca_eoi_options ) {
28 add_option( 'fca_eoi_settings' );
29 }
30
31 if ( $dh_easy_opt_ins_plugin->distro != 'free' ) {
32
33 add_settings_section( 'fca_eoi_license_settings_section', __('License', 'easy-opt-ins'), false, 'fca_eoi_settings_page' );
34
35 }
36
37 add_settings_section( 'fca_eoi_powerup_settings_section', __('Powerups', 'easy-opt-ins'), false, 'fca_eoi_settings_page' );
38
39 $option_fields = apply_filters( 'fca_eoi_setting_filter', array() );
40
41 foreach( $option_fields as $option ) {
42 $id = empty ( $option[0] ) ? '' : $option[0];
43 $friendly_text = empty ( $option[1] ) ? '' : $option[1];
44 $callback_function = empty ( $option[2] ) ? '' : $option[2];
45 $setting_heading = empty ( $option[3] ) ? '' : $option[3];
46
47
48 add_settings_field( "fca_eoi_settings[$id]", $friendly_text, $callback_function, 'fca_eoi_settings_page', $setting_heading, $option);
49 }
50
51 register_setting( 'fca_eoi_main_settings', 'fca_eoi_settings', 'fca_eoi_settings_sanitize_callback' );
52
53 }
54 add_action('admin_init', 'fca_eoi_register_settings');
55
56 function fca_eoi_settings_sanitize_callback( $data ) {
57
58 $status = get_option( 'fca_eoi_license_status' );
59 $settings = get_option( 'fca_eoi_settings' );
60
61 $deactivate = empty( $data['fca_eoi_license_deactivate'] ) ? false : true;
62 $data['license_key'] = empty( $data['license_key'] ) ? '' : trim( esc_textarea ( $data['license_key'] ) );
63 if ( $deactivate ) {
64 $key = !empty($settings['license_key']) ? $settings['license_key'] : $data['license_key'];
65 fca_eoi_deactivate_license( $key );
66 $data['license_key'] = '';
67 } else if ( $status != 'valid' && !empty( $data['license_key'] ) ) {
68 fca_eoi_activate_license( $data['license_key'] );
69 }
70 return $data;
71 }
72
73 function fca_eoi_checkbox_callback( $args ) {
74 $option_name = $args[0];
75
76 $options = get_option( 'fca_eoi_settings' );
77
78 $help_text = empty( $args[4] ) ? '' : $args[4];
79
80 /***** SET TO DEFAULT IF THIS OPTION HAS NEVER BEEN SET *****/
81
82 if ( !isset ( $options[ $option_name ] ) ) {
83 $options[ $option_name ] = 0;
84 }
85
86 $html = "<div class='onoffswitch'>";
87 $html .= "<input type='checkbox' class='onoffswitch-checkbox' id='fca_eoi_settings[$option_name]' style='display:none;' name='fca_eoi_settings[$option_name]' value='1' " . checked( 1, $options[ $option_name ], false ) . '/>';
88 $html .= "<label class='onoffswitch-label' for='fca_eoi_settings[$option_name]'><span class='onoffswitch-inner' data-content-on='".__('ON', 'easy-opt-ins')."' data-content-off='".__('OFF', 'easy-opt-ins')."'><span class='onoffswitch-switch'></span></span></label>";
89 $html .= "</div>";
90 $html .= "<p class='fca_eoi_help_text'>$help_text</p>";
91
92 echo $html;
93 }
94
95 function fca_eoi_text_box_callback( $args ) {
96
97 $option_name = $args[0];
98
99 $placeholder = empty( $args[1] ) ? '' : $args[1];
100
101 $help_text = empty( $args[2] ) ? '' : $args[2];
102
103 $options = get_option( 'fca_eoi_settings' );
104
105 /***** SET TO DEFAULT IF THIS OPTION HAS NEVER BEEN SET *****/
106
107 if ( !isset ( $options[ $option_name ] ) ) {
108 $value = $options[ $option_name ] = '';
109 }else {
110 $value = esc_textarea( $options[ $option_name ] );
111 }
112
113 $html = "<input type='text' class='fca_eoi_settings_text_input' id='fca_eoi_settings[$option_name]' name='fca_eoi_settings[$option_name]' value='$value' placeholder='$placeholder' />";
114
115 $html .= "<p class='fca_eoi_help_text'>$help_text</p>";
116
117 echo $html;
118 }
119
120 function fca_eoi_settings_page(){
121
122 wp_enqueue_style( 'fca_eoi_settings_page_css', FCA_EOI_PLUGIN_URL . '/assets/powerups/powerup-page.min.css', array(), FCA_EOI_VER );
123 wp_enqueue_script( 'fca_eoi_settings_page_js', FCA_EOI_PLUGIN_URL . '/assets/powerups/powerup-page.min.js', array(), FCA_EOI_VER, true );
124 do_action('fca_eoi_setting_page_enqueue');
125
126 ob_start(); ?>
127 <form method='post' action='options.php' id='fca_eoi_save_settings_form'>
128
129 <?php
130 settings_fields( 'fca_eoi_main_settings' );
131 do_settings_sections( 'fca_eoi_settings_page' );
132 ?>
133
134 <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e('Save', 'easy-opt-ins')?>" />
135
136 </form>
137 <?php
138 echo ob_get_clean();
139
140 }