PluginProbe
Optin Forms – Simple List Building Plugin for WordPress / 1.3.5
Optin Forms – Simple List Building Plugin for WordPress v1.3.5
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.3.5, at optin-forms.php

443 lines 18.1 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.3.5
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 // Plugin Root File.
29 if ( ! defined( 'OPTIN_FORMS_PLUGIN_FILE' ) ) {
30 define( 'OPTIN_FORMS_PLUGIN_FILE', __FILE__ );
31 }
32
33 // Plugin Base Name.
34 if ( ! defined( 'OPTIN_FORMS_PLUGIN_BASE' ) ) {
35 define( 'OPTIN_FORMS_PLUGIN_BASE', plugin_basename( __FILE__ ) );
36 }
37
38 // Plugin Folder Path.
39 if ( ! defined( 'OPTIN_FORMS_PLUGIN_DIR' ) ) {
40 define( 'OPTIN_FORMS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
41 }
42
43 // Plugin Folder URL.
44 if ( ! defined( 'OPTIN_FORMS_PLUGIN_URL' ) ) {
45 define( 'OPTIN_FORMS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
46 }
47
48 // Include our registration settings
49 include( plugin_dir_path( __FILE__ ) . 'includes/register-settings.php');
50 // Include our regular functions
51 include( plugin_dir_path( __FILE__ ) . 'includes/functions.php');
52 // Include our form functions
53 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-1.php');
54 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-2.php');
55 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-3.php');
56 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-4.php');
57 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-5.php');
58 include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-6.php');
59 include( plugin_dir_path( __FILE__ ) . 'includes/functions-forms.php');
60
61 class Optin_Forms {
62
63 /**
64 * Constructor function
65 *
66 * @since 1.2.5
67 * @access public
68 */
69 public function __construct() {
70 add_action( 'plugins_loaded', array( $this, 'optinforms_init' ) );
71 add_action( 'admin_menu', array( $this, 'optinforms_menu' ) );
72 add_action( 'wp_enqueue_scripts', array( $this, 'optinforms_scripts' ) );
73 add_action( 'admin_enqueue_scripts', array( $this, 'optinforms_load_additional_scripts' ) );
74
75
76 }
77
78 /**
79 * Adds translation to plugin
80 */
81 public function optinforms_init() {
82 $plugin_dir = basename(dirname(__FILE__));
83 load_plugin_textdomain( 'optin-forms', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
84 }
85
86 /**
87 * Adds Optin Forms to WordPress dashboard menu
88 */
89 public function optinforms_menu() {
90 // Since 1.1.2 added a menu position decimal fix to prevent conflict with other themes using 31, such as Thesis Theme
91 // @http://gabrielharper.com/blog/2012/08/wordpress-admin-menu-positioning-conflicts/
92 $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');
93
94 // We want our JS and CSS loaded on our admin pages only, so let's just load them for now
95 add_action( 'load-' . $submenu, array( $this, 'optinforms_load_admin_scripts' ) );
96 }
97
98 /**
99 * Enqueue our CSS and JS on Optin Forms admin pages only
100 */
101 public function optinforms_load_admin_scripts() {
102 add_action( 'admin_enqueue_scripts', array( $this, 'optinforms_admin_scripts' ) );
103 }
104
105 /**
106 * Adds CSS and JS to admin head, but just for our admin pages (see optinforms_load_admin_scripts above!)
107 */
108 public function optinforms_admin_scripts() {
109 wp_enqueue_style('optinforms-admin-stylesheet', plugins_url('/css/optinforms-admin.css', __FILE__ ), array('optinforms-googleFont'));
110 wp_enqueue_style('wp-color-picker');
111 wp_enqueue_script('optinforms-color', plugins_url('/js/optinforms-color.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
112 wp_enqueue_script('placeholder', plugins_url('/js/placeholder.js', __FILE__ ));
113 wp_enqueue_script('toggle', plugins_url('/js/custom.js', __FILE__ ), array(), '1.3.5');
114 wp_enqueue_script('jquery-ui-slider');
115 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');
116
117 global $optinforms_forms;
118
119 // Have any custom form designs been registered?
120 if ( is_array( $optinforms_forms ) ) {
121
122 // Loops through registered form designs.
123 foreach ( $optinforms_forms as $class_name => $design ) {
124
125 // Does the form have an stylesheet URL specified?
126 if ( !empty( $design->optinform['stylesheet_url'] ) ) {
127 wp_enqueue_style( $class_name, $design->optinform['stylesheet_url'] );
128 }
129 }
130 }
131 }
132
133 /**
134 * Adds our CSS and JS to wp_head
135 */
136 public function optinforms_scripts() {
137 wp_enqueue_script('jquery');
138 wp_enqueue_style('optinforms-stylesheet', plugins_url('/css/optinforms.css', __FILE__ ), array(), '1.3.5' );
139 wp_enqueue_script('placeholder', plugins_url('/js/placeholder.js', __FILE__ ), array(), '1.3.5', true);
140 if ( optinforms_used_fonts() !== '//fonts.googleapis.com/css?family=' ) {
141 wp_enqueue_style('optinforms-googleFont', optinforms_used_fonts());
142 }
143
144 global $optinforms_forms;
145
146 // Have any custom form designs been registered?
147 if ( is_array( $optinforms_forms ) ) {
148
149 // Loops through registered form designs.
150 foreach ( $optinforms_forms as $class_name => $design ) {
151
152 // Does the form have an stylesheet URL specified?
153 if ( !empty( $design->optinform['stylesheet_url'] ) ) {
154 wp_enqueue_style( $class_name, $design->optinform['stylesheet_url'] );
155 }
156 }
157 }
158 }
159
160 /**
161 * Add additional scripts to admin head on all admin pages (so supportbox slider will work on all pages!)
162 */
163 public function optinforms_load_additional_scripts(){
164 wp_enqueue_style('optinforms-admin-slider-stylesheet', plugins_url('/css/optinforms-admin-slider.css', __FILE__ ));
165 wp_enqueue_script('jquery-ui-slider');
166 }
167
168
169 /**
170 * Displays Optin Forms admin page.
171 */
172 public function optinforms_main_page() {
173 global $optinforms_forms;
174
175 { ?>
176 <div class="wrap">
177 <h2><?php echo __('Optin Forms', 'optin-forms'); ?></h2>
178 <div id="icon-optinforms" class="icon32">
179 </div><!--icon-32-->
180 <h3 class="title"><?php echo optinforms_menu_tabs(); ?></h3>
181 </div><!--wrap-->
182
183 <?php echo optinforms_configuration(); ?>
184
185 <?php if( isset($_GET['settings-updated']) ) { ?>
186 <div id="message" class="updated">
187 <p><strong><?php _e('Settings updated') ?></strong></p>
188 </div>
189 <?php } ?>
190
191 <div id="optinforms">
192 <form method="post" action="options.php" id="frm1">
193 <?php settings_fields( 'optinforms-settings-group' ); ?>
194
195 <div id="optinforms-email-solution-tab" class="tabcontent">
196 <div class="optinforms-container-left">
197 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-email-solution.php'); ?>
198 </div><!--optinforms-container-left-->
199 <div class="optinforms-container-right">
200 <?php include( plugin_dir_path( __FILE__ ) . 'includes/sidebar.php'); ?>
201 </div><!--optinforms-container-right-->
202 <div class="clear"></div>
203 </div><!--optinforms-email-solution-tab-->
204
205 <div id="optinforms-posts-tab" class="tabcontent">
206 <div class="optinforms-container-left">
207 <div class="optiongroup">
208 <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>
209 <div class="optionleft">
210 <label for="optinforms_form_design" class="nopointer"><?php echo __('Form design', 'optin-forms'); ?></label>
211 </div><!--optionleft-->
212 <div class="optionmiddle">
213 <select name="optinforms_form_design" id="optinforms_form_design">
214 <option value="optinforms_form_design_option1" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option1') { echo 'selected="selected"'; } ?>>01</option>
215 <option value="optinforms_form_design_option2" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option2') { echo 'selected="selected"'; } ?>>02</option>
216 <option value="optinforms_form_design_option3" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option3') { echo 'selected="selected"'; } ?>>03</option>
217 <option value="optinforms_form_design_option4" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option4') { echo 'selected="selected"'; } ?>>04</option>
218 <option value="optinforms_form_design_option5" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option5') { echo 'selected="selected"'; } ?>>05</option>
219 <option value="optinforms_form_design_option6" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option6') { echo 'selected="selected"'; } ?>>06</option>
220 <?php
221
222 // Have any custom form designs been registered?
223 if ( is_array( $optinforms_forms ) ) {
224
225 // Gets the saved form design ID.
226 $saved_design = get_option( 'optinforms_form_design' );
227
228 // Loops through registered form designs.
229 foreach ( $optinforms_forms as $class_name => $design ) {
230
231 // Does the form have an ID and a title?
232 if ( !empty( $design->optinform['id'] ) && !empty( $design->optinform['title'] ) ) {
233 echo '<option value="' . $design->optinform['id'] . '" ' . selected( $saved_design, $design->optinform['id'], false ) . '>' . $design->optinform['title'] . '</option>';
234
235 }
236 }
237 }
238 ?>
239 </select>
240 <script type="text/javascript">
241 // document.getElementById('optinforms_form_design').onchange = function() {
242 // var i = 1;
243 // var myDiv = document.getElementById("optinforms_form_design_option" + i);
244 // while(myDiv) {
245 // myDiv.style.display = 'none';
246 // myDiv = document.getElementById("optinforms_form_design_option" + ++i);
247 // }
248 // document.getElementById(this.value).style.display = 'block';
249 // };
250 </script>
251 </div><!--optionmiddle-->
252 <div class="optionlast">
253
254 </div><!--optionlast-->
255 <div class="clear"></div>
256
257 </div><!--optiongroup-->
258
259 <div id="optinforms-design-backend-wrap" class="optiongroup">
260 <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;"'; } ?>>
261
262 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-1.php'); ?>
263 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-1.php'); ?>
264
265 </div><!--optinforms_form_design_option1-->
266 <div id="optinforms_form_design_option2" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option2') { echo 'style="display:block;"'; } ?>>
267
268 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-2.php'); ?>
269 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-2.php'); ?>
270
271 </div><!--optinforms_form_design_option2-->
272 <div id="optinforms_form_design_option3" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option3') { echo 'style="display:block;"'; } ?>>
273
274 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-3.php'); ?>
275 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-3.php'); ?>
276
277 </div><!--optinforms_form_design_option3-->
278 <div id="optinforms_form_design_option4" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option4') { echo 'style="display:block;"'; } ?>>
279
280 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-4.php'); ?>
281 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-4.php'); ?>
282
283 </div><!--optinforms_form_design_option4-->
284 <div id="optinforms_form_design_option5" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option5') { echo 'style="display:block;"'; } ?>>
285
286 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-5.php'); ?>
287 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-5.php'); ?>
288
289 </div><!--optinforms_form_design_option5-->
290 <div id="optinforms_form_design_option6" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option6') { echo 'style="display:block;"'; } ?>>
291
292 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-6.php'); ?>
293 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-6.php'); ?>
294
295 </div><!--optinforms_form_design_option6-->
296 <?php
297
298 // Have any custom form designs been registered?
299 if ( is_array( $optinforms_forms ) ) {
300
301 // Loops through registered form designs.
302 foreach ( $optinforms_forms as $class_name => $design ) {
303
304 // Does the form have an ID and a title?
305 if ( !empty( $design->optinform['id'] ) && !empty( $design->optinform['title'] ) ) {
306 $display = $saved_design == $design->optinform['id'] ? 'style="display:block;"' : 'style="display:none;"';
307 echo '<div id="' . $design->optinform['id'] . '" ' . $display . '>';
308
309 // Displays the form preview if available.
310 if ( method_exists( $design, 'get_optin_form' ) ) {
311 echo $design->get_optin_form();
312 }
313
314 // Displays the form options if available.
315 if ( file_exists( $design->optinform['options_url'] ) ) {
316 include( $design->optinform['options_url'] );
317 }
318
319 echo '</div>';
320
321
322 }
323 }
324 }
325 ?>
326 </div><!--optiongroup-->
327
328 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-functionality.php'); ?>
329 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-placement.php'); ?>
330
331 </div><!--optinforms-container-left-->
332 <div class="optinforms-container-right">
333 <?php include( plugin_dir_path( __FILE__ ) . 'includes/sidebar.php'); ?>
334 </div><!--optinforms-container-right-->
335 <div class="clear"></div>
336 </div><!--optinforms-posts-tab-->
337
338 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
339 </form>
340
341 </div><!--optinforms-->
342
343 <?php }
344 }
345 }
346 $optin_forms = new Optin_Forms();
347
348
349 if ( !function_exists( 'register_optin_form') ) {
350 /**
351 * Registers optin forms
352 *
353 * Adds new forms to the $optinforms_forms array.
354 *
355 * @param $class_name string Name of the form class being registered.
356 */
357 function register_optin_form( $class_name ) {
358 global $optinforms_forms;
359
360 // Adds form to global forms array.
361 $optinforms_forms[$class_name] = new $class_name;
362 }
363 }
364
365
366 if ( !function_exists( 'optinforms_get_setting') ) {
367 /**
368 * Gets saved form setting
369 *
370 * Falls back on default form setting if there is no saved value.
371 *
372 * @param string $setting_id The ID of the setting to retrieve.
373 * @param string $design_class The class name of the design class that holds the default setting.
374 * @return string $setting The saved setting (or the default, if no setting is saved).
375 */
376 function optinforms_get_setting( $setting_id, $design_class = '' ) {
377
378 // Gets the saved setting from the database.
379 $setting = get_option( $setting_id );
380
381 // Is there no saved setting, and was a design class name provided?
382 if ( empty( $setting ) && !empty( $design_class ) ) {
383 $setting = optinforms_get_default_setting( $setting_id, $design_class );
384 }
385
386 return $setting;
387 }
388 }
389
390
391 if ( !function_exists( 'optinforms_get_default_setting') ) {
392 /**
393 * Gets default form setting
394 *
395 * @param string $setting_id The ID of the setting to retrieve.
396 * @param string $design_class The class name of the design class that holds the default setting.
397 * @return string $setting The saved setting (or the default, if no setting is saved).
398 */
399 function optinforms_get_default_setting( $setting_id, $design_class = '' ) {
400
401 global $optinforms_forms;
402 $setting = '';
403
404 // Is there a default setting stored in the design class?
405 if ( !empty( $optinforms_forms[$design_class]->defaults[$setting_id] ) ) {
406 $setting = $optinforms_forms[$design_class]->defaults[$setting_id];
407 }
408
409 return $setting;
410 }
411 }
412
413 if ( ! function_exists( 'optinforms_translate_sc' ) ) {
414
415 /**
416 * Returns text based on language
417 *
418 * @return string $content The text in correct translation
419 */
420 function optinforms_translate_sc( $atts = false, $content = '') {
421
422 // no atts supplied, return empty
423 if ( ! $atts ) {
424 return '';
425 }
426
427 // if locale incorrect, return empty
428 if ( get_locale() != $atts['lang'] ) {
429 return '';
430 }
431
432 // return text
433 return $content;
434
435 }
436
437 } add_shortcode( 'optinforms_translate', 'optinforms_translate_sc' );
438
439 // Allows for translation of plugin description
440 $plugin_header_translate = array(
441 __( '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' ),
442 );
443