PluginProbe
Optin Forms – Simple List Building Plugin for WordPress / 1.2.8
Optin Forms – Simple List Building Plugin for WordPress v1.2.8
trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.1 1.2.2 1.2.3 1.2.4 1.2.6 1.2.7 1.2.8 1.2.8.1 1.2.8.2 1.2.8.3 1.2.8.4 1.2.8.5 1.2.8.6 All 48 releases
optin-forms / optin-forms.php

optin-forms.php in Optin Forms – Simple List Building Plugin for WordPress 1.2.8, at optin-forms.php

403 lines 17.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Optin Forms
4 Plugin URI: http://fancythemes.com/plugins/optin-forms/
5 Description: Create beautiful optin forms with ease. Choose a form design, customize it, and add your form to your blog with a simple mouse-click.
6 Author: FancyThemes
7 Version: 1.2.8
8 Author URI: http://www.fancythemes.com
9 Text Domain: optin-forms
10 Domain Path: /languages/
11 License:
12 Copyright 2016 FancyThemes.com
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License, version 2, as
16 published by the Free Software Foundation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27
28 // Include our registration settings
29 include( plugin_dir_path( __FILE__ ) . 'includes/register-settings.php');
30 // Include our regular functions
31 include( plugin_dir_path( __FILE__ ) . 'includes/functions.php');
32 // Include our form functions
33 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-1.php');
34 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-2.php');
35 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-3.php');
36 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-4.php');
37 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-5.php');
38 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-6.php');
39 include( plugin_dir_path( __FILE__ ) . 'includes/functions-forms.php');
40
41 class Optin_Forms {
42
43 /**
44 * Constructor function
45 *
46 * @since 1.2.5
47 * @access public
48 */
49 public function __construct() {
50 add_action( 'plugins_loaded', array( $this, 'optinforms_init' ) );
51 add_action( 'admin_menu', array( $this, 'optinforms_menu' ) );
52 add_action( 'wp_enqueue_scripts', array( $this, 'optinforms_scripts' ) );
53 add_action( 'admin_enqueue_scripts', array( $this, 'optinforms_load_additional_scripts' ) );
54
55
56 }
57
58 /**
59 * Adds translation to plugin
60 */
61 public function optinforms_init() {
62 $plugin_dir = basename(dirname(__FILE__));
63 load_plugin_textdomain( 'optin-forms', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
64 }
65
66 /**
67 * Adds Optin Forms to WordPress dashboard menu
68 */
69 public function optinforms_menu() {
70 // Since 1.1.2 added a menu position decimal fix to prevent conflict with other themes using 31, such as Thesis Theme
71 // @http://gabrielharper.com/blog/2012/08/wordpress-admin-menu-positioning-conflicts/
72 $submenu = add_menu_page(__('Optin Forms','optin-forms'), __('Optin Forms','optin-forms'), 'manage_options', 'optinforms', array( $this, 'optinforms_main_page' ), plugin_dir_url( __FILE__ ) . '/images/icon.png', '30.1');
73
74 // We want our JS and CSS loaded on our admin pages only, so let's just load them for now
75 add_action( 'load-' . $submenu, array( $this, 'optinforms_load_admin_scripts' ) );
76 }
77
78 /**
79 * Enqueue our CSS and JS on Optin Forms admin pages only
80 */
81 public function optinforms_load_admin_scripts() {
82 add_action( 'admin_enqueue_scripts', array( $this, 'optinforms_admin_scripts' ) );
83 }
84
85 /**
86 * Adds CSS and JS to admin head, but just for our admin pages (see optinforms_load_admin_scripts above!)
87 */
88 public function optinforms_admin_scripts() {
89 wp_enqueue_style('optinforms-admin-stylesheet', plugins_url('/css/optinforms-admin.css', __FILE__ ), array('optinforms-googleFont'));
90 wp_enqueue_script('tabcontent', plugins_url('/js/tabcontent.js', __FILE__ ));
91 wp_enqueue_style('wp-color-picker');
92 wp_enqueue_script('optinforms-color', plugins_url('/js/optinforms-color.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
93 wp_enqueue_script('placeholder', plugins_url('/js/placeholder.js', __FILE__ ));
94 wp_enqueue_script('toggle', plugins_url('/js/custom.js', __FILE__ ));
95 wp_enqueue_script('jquery-ui-slider');
96 wp_register_style('optinforms-googleFont', '//fonts.googleapis.com/css?family=Share+Tech|Droid+Sans|Lobster|Fenix|Unkempt|Flavors|Viga|Damion|Oleo+Script|Racing+Sans+One|Nixie+One|Fredoka+One|Open+Sans|Overlock+SC|Bubbler+One|Contrail+One|Gochi+Hand|Roboto+Condensed|Russo+One|Cinzel+Decorative|News+Cycle|Marcellus+SC|Chewy|Quicksand|Sanchez|Signika+Negative|Gloria+Hallelujah|Grand+Hotel|Droid+Serif|Englebert|Oswald|Pacifico|Titan+One|Shadows+Into+Light|Dancing+Script|Luckiest+Guy|Parisienne|Coming+Soon|Baumans|Belgrano');
97
98 global $optinforms_forms;
99
100 // Have any custom form designs been registered?
101 if ( is_array( $optinforms_forms ) ) {
102
103 // Loops through registered form designs.
104 foreach ( $optinforms_forms as $class_name => $design ) {
105
106 // Does the form have an stylesheet URL specified?
107 if ( !empty( $design->optinform['stylesheet_url'] ) ) {
108 wp_enqueue_style( $class_name, $design->optinform['stylesheet_url'] );
109 }
110 }
111 }
112 }
113
114 /**
115 * Adds our CSS and JS to wp_head
116 */
117 public function optinforms_scripts() {
118 wp_enqueue_script('jquery');
119 wp_enqueue_style('optinforms-stylesheet', plugins_url('/css/optinforms.css', __FILE__ ), array('optinforms-googleFont'));
120 wp_enqueue_script('placeholder', plugins_url('/js/placeholder.js', __FILE__ ));
121 wp_register_style('optinforms-googleFont', optinforms_used_fonts());
122
123 global $optinforms_forms;
124
125 // Have any custom form designs been registered?
126 if ( is_array( $optinforms_forms ) ) {
127
128 // Loops through registered form designs.
129 foreach ( $optinforms_forms as $class_name => $design ) {
130
131 // Does the form have an stylesheet URL specified?
132 if ( !empty( $design->optinform['stylesheet_url'] ) ) {
133 wp_enqueue_style( $class_name, $design->optinform['stylesheet_url'] );
134 }
135 }
136 }
137 }
138
139 /**
140 * Add additional scripts to admin head on all admin pages (so supportbox slider will work on all pages!)
141 */
142 public function optinforms_load_additional_scripts(){
143 wp_enqueue_style('optinforms-admin-slider-stylesheet', plugins_url('/css/optinforms-admin-slider.css', __FILE__ ));
144 wp_enqueue_script('jquery-ui-slider');
145 }
146
147
148 /**
149 * Displays Optin Forms admin page.
150 */
151 public function optinforms_main_page() {
152 global $optinforms_forms;
153
154 { ?>
155 <div class="wrap">
156 <h2><?php echo __('Optin Forms', 'optin-forms'); ?></h2>
157 <div id="icon-optinforms" class="icon32">
158 </div><!--icon-32-->
159 <h3 class="title"><?php echo optinforms_menu_tabs(); ?></h3>
160 </div><!--wrap-->
161
162 <?php echo optinforms_configuration(); ?>
163
164 <?php if( isset($_GET['settings-updated']) ) { ?>
165 <div id="message" class="updated">
166 <p><strong><?php _e('Settings updated') ?></strong></p>
167 </div>
168 <?php } ?>
169
170 <div id="optinforms">
171 <form method="post" action="options.php" id="frm1">
172 <?php settings_fields( 'optinforms-settings-group' ); ?>
173
174 <div id="optinforms-email-solution-tab" class="tabcontent">
175 <div class="optinforms-container-left">
176 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-email-solution.php'); ?>
177 </div><!--optinforms-container-left-->
178 <div class="optinforms-container-right">
179 <?php include( plugin_dir_path( __FILE__ ) . 'includes/sidebar.php'); ?>
180 </div><!--optinforms-container-right-->
181 <div class="clear"></div>
182 </div><!--optinforms-email-solution-tab-->
183
184 <div id="optinforms-posts-tab" class="tabcontent">
185 <div class="optinforms-container-left">
186 <div class="optiongroup">
187 <p><?php echo __('Add a beautiful optin form to your posts, custom post types and pages. Include the form on your website with a simple mouse-click, or use the shortcode to add it to specific posts and pages.', 'optin-forms'); ?></p>
188 <div class="optionleft">
189 <label for="optinforms_form_design" class="nopointer"><?php echo __('Form design', 'optin-forms'); ?></label>
190 </div><!--optionleft-->
191 <div class="optionmiddle">
192 <select name="optinforms_form_design" id="optinforms_form_design">
193 <option value="optinforms_form_design_option1" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option1') { echo 'selected="selected"'; } ?>>01</option>
194 <option value="optinforms_form_design_option2" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option2') { echo 'selected="selected"'; } ?>>02</option>
195 <option value="optinforms_form_design_option3" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option3') { echo 'selected="selected"'; } ?>>03</option>
196 <option value="optinforms_form_design_option4" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option4') { echo 'selected="selected"'; } ?>>04</option>
197 <option value="optinforms_form_design_option5" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option5') { echo 'selected="selected"'; } ?>>05</option>
198 <option value="optinforms_form_design_option6" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option6') { echo 'selected="selected"'; } ?>>06</option>
199 <?php
200
201 // Have any custom form designs been registered?
202 if ( is_array( $optinforms_forms ) ) {
203
204 // Gets the saved form design ID.
205 $saved_design = get_option( 'optinforms_form_design' );
206
207 // Loops through registered form designs.
208 foreach ( $optinforms_forms as $class_name => $design ) {
209
210 // Does the form have an ID and a title?
211 if ( !empty( $design->optinform['id'] ) && !empty( $design->optinform['title'] ) ) {
212 echo '<option value="' . $design->optinform['id'] . '" ' . selected( $saved_design, $design->optinform['id'], false ) . '>' . $design->optinform['title'] . '</option>';
213
214 }
215 }
216 }
217 ?>
218 </select>
219 <script type="text/javascript">
220 // document.getElementById('optinforms_form_design').onchange = function() {
221 // var i = 1;
222 // var myDiv = document.getElementById("optinforms_form_design_option" + i);
223 // while(myDiv) {
224 // myDiv.style.display = 'none';
225 // myDiv = document.getElementById("optinforms_form_design_option" + ++i);
226 // }
227 // document.getElementById(this.value).style.display = 'block';
228 // };
229 </script>
230 </div><!--optionmiddle-->
231 <div class="optionlast">
232
233 </div><!--optionlast-->
234 <div class="clear"></div>
235
236 </div><!--optiongroup-->
237
238 <div id="optinforms-design-backend-wrap" class="optiongroup">
239 <div id="optinforms_form_design_option1" <?php if (get_option('optinforms_form_design')== '' || get_option('optinforms_form_design')== 'optinforms_form_design_option1') { echo 'style="display:block;"'; } ?>>
240
241 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-1.php'); ?>
242 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-1.php'); ?>
243
244 </div><!--optinforms_form_design_option1-->
245 <div id="optinforms_form_design_option2" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option2') { echo 'style="display:block;"'; } ?>>
246
247 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-2.php'); ?>
248 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-2.php'); ?>
249
250 </div><!--optinforms_form_design_option2-->
251 <div id="optinforms_form_design_option3" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option3') { echo 'style="display:block;"'; } ?>>
252
253 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-3.php'); ?>
254 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-3.php'); ?>
255
256 </div><!--optinforms_form_design_option3-->
257 <div id="optinforms_form_design_option4" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option4') { echo 'style="display:block;"'; } ?>>
258
259 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-4.php'); ?>
260 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-4.php'); ?>
261
262 </div><!--optinforms_form_design_option4-->
263 <div id="optinforms_form_design_option5" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option5') { echo 'style="display:block;"'; } ?>>
264
265 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-5.php'); ?>
266 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-5.php'); ?>
267
268 </div><!--optinforms_form_design_option5-->
269 <div id="optinforms_form_design_option6" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option6') { echo 'style="display:block;"'; } ?>>
270
271 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-6.php'); ?>
272 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-6.php'); ?>
273
274 </div><!--optinforms_form_design_option6-->
275 <?php
276
277 // Have any custom form designs been registered?
278 if ( is_array( $optinforms_forms ) ) {
279
280 // Loops through registered form designs.
281 foreach ( $optinforms_forms as $class_name => $design ) {
282
283 // Does the form have an ID and a title?
284 if ( !empty( $design->optinform['id'] ) && !empty( $design->optinform['title'] ) ) {
285 $display = $saved_design == $design->optinform['id'] ? 'style="display:block;"' : 'style="display:none;"';
286 echo '<div id="' . $design->optinform['id'] . '" ' . $display . '>';
287
288 // Displays the form preview if available.
289 if ( method_exists( $design, 'get_optin_form' ) ) {
290 echo $design->get_optin_form();
291 }
292
293 // Displays the form options if available.
294 if ( file_exists( $design->optinform['options_url'] ) ) {
295 include( $design->optinform['options_url'] );
296 }
297
298 echo '</div>';
299
300
301 }
302 }
303 }
304 ?>
305 </div><!--optiongroup-->
306
307 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-functionality.php'); ?>
308 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-placement.php'); ?>
309
310 </div><!--optinforms-container-left-->
311 <div class="optinforms-container-right">
312 <?php include( plugin_dir_path( __FILE__ ) . 'includes/sidebar.php'); ?>
313 </div><!--optinforms-container-right-->
314 <div class="clear"></div>
315 </div><!--optinforms-posts-tab-->
316
317 <script type="text/javascript">
318 var wpthumbs=new ddtabcontent("optinforms-menu-tabs") //enter ID of Tab Container
319 wpthumbs.setpersist(true) //toogle persistence of the tabs' state
320 wpthumbs.setselectedClassTarget("link") //"link" or "linkparent"
321 wpthumbs.init()
322 </script>
323
324 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
325 </form>
326
327 </div><!--optinforms-->
328
329 <?php }
330 }
331 }
332 $optin_forms = new Optin_Forms();
333
334
335 if ( !function_exists( 'register_optin_form') ) {
336 /**
337 * Registers optin forms
338 *
339 * Adds new forms to the $optinforms_forms array.
340 *
341 * @param $class_name string Name of the form class being registered.
342 */
343 function register_optin_form( $class_name ) {
344 global $optinforms_forms;
345
346 // Adds form to global forms array.
347 $optinforms_forms[$class_name] = new $class_name;
348 }
349 }
350
351
352 if ( !function_exists( 'optinforms_get_setting') ) {
353 /**
354 * Gets saved form setting
355 *
356 * Falls back on default form setting if there is no saved value.
357 *
358 * @param string $setting_id The ID of the setting to retrieve.
359 * @param string $design_class The class name of the design class that holds the default setting.
360 * @return string $setting The saved setting (or the default, if no setting is saved).
361 */
362 function optinforms_get_setting( $setting_id, $design_class = '' ) {
363
364 // Gets the saved setting from the database.
365 $setting = get_option( $setting_id );
366
367 // Is there no saved setting, and was a design class name provided?
368 if ( empty( $setting ) && !empty( $design_class ) ) {
369 $setting = optinforms_get_default_setting( $setting_id, $design_class );
370 }
371
372 return $setting;
373 }
374 }
375
376
377 if ( !function_exists( 'optinforms_get_default_setting') ) {
378 /**
379 * Gets default form setting
380 *
381 * @param string $setting_id The ID of the setting to retrieve.
382 * @param string $design_class The class name of the design class that holds the default setting.
383 * @return string $setting The saved setting (or the default, if no setting is saved).
384 */
385 function optinforms_get_default_setting( $setting_id, $design_class = '' ) {
386
387 global $optinforms_forms;
388 $setting = '';
389
390 // Is there a default setting stored in the design class?
391 if ( !empty( $optinforms_forms[$design_class]->defaults[$setting_id] ) ) {
392 $setting = $optinforms_forms[$design_class]->defaults[$setting_id];
393 }
394
395 return $setting;
396 }
397 }
398
399 // Allows for translation of plugin description
400 $plugin_header_translate = array(
401 __( 'Create beautiful optin forms with ease. Choose a form design, customize it, and add your form to your blog with a simple mouse-click.', 'optin-forms' ),
402 );
403