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

431 lines 18.0 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.3
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__ ), array(), '1.3.3');
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(), '1.3.3' );
120 wp_enqueue_script('placeholder', plugins_url('/js/placeholder.js', __FILE__ ), array(), '1.3.3', true);
121 if ( optinforms_used_fonts() !== '//fonts.googleapis.com/css?family=' ) {
122 wp_enqueue_style('optinforms-googleFont', optinforms_used_fonts());
123 }
124
125 global $optinforms_forms;
126
127 // Have any custom form designs been registered?
128 if ( is_array( $optinforms_forms ) ) {
129
130 // Loops through registered form designs.
131 foreach ( $optinforms_forms as $class_name => $design ) {
132
133 // Does the form have an stylesheet URL specified?
134 if ( !empty( $design->optinform['stylesheet_url'] ) ) {
135 wp_enqueue_style( $class_name, $design->optinform['stylesheet_url'] );
136 }
137 }
138 }
139 }
140
141 /**
142 * Add additional scripts to admin head on all admin pages (so supportbox slider will work on all pages!)
143 */
144 public function optinforms_load_additional_scripts(){
145 wp_enqueue_style('optinforms-admin-slider-stylesheet', plugins_url('/css/optinforms-admin-slider.css', __FILE__ ));
146 wp_enqueue_script('jquery-ui-slider');
147 }
148
149
150 /**
151 * Displays Optin Forms admin page.
152 */
153 public function optinforms_main_page() {
154 global $optinforms_forms;
155
156 { ?>
157 <div class="wrap">
158 <h2><?php echo __('Optin Forms', 'optin-forms'); ?></h2>
159 <div id="icon-optinforms" class="icon32">
160 </div><!--icon-32-->
161 <h3 class="title"><?php echo optinforms_menu_tabs(); ?></h3>
162 </div><!--wrap-->
163
164 <?php echo optinforms_configuration(); ?>
165
166 <?php if( isset($_GET['settings-updated']) ) { ?>
167 <div id="message" class="updated">
168 <p><strong><?php _e('Settings updated') ?></strong></p>
169 </div>
170 <?php } ?>
171
172 <div id="optinforms">
173 <form method="post" action="options.php" id="frm1">
174 <?php settings_fields( 'optinforms-settings-group' ); ?>
175
176 <div id="optinforms-email-solution-tab" class="tabcontent">
177 <div class="optinforms-container-left">
178 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-email-solution.php'); ?>
179 </div><!--optinforms-container-left-->
180 <div class="optinforms-container-right">
181 <?php include( plugin_dir_path( __FILE__ ) . 'includes/sidebar.php'); ?>
182 </div><!--optinforms-container-right-->
183 <div class="clear"></div>
184 </div><!--optinforms-email-solution-tab-->
185
186 <div id="optinforms-posts-tab" class="tabcontent">
187 <div class="optinforms-container-left">
188 <div class="optiongroup">
189 <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>
190 <div class="optionleft">
191 <label for="optinforms_form_design" class="nopointer"><?php echo __('Form design', 'optin-forms'); ?></label>
192 </div><!--optionleft-->
193 <div class="optionmiddle">
194 <select name="optinforms_form_design" id="optinforms_form_design">
195 <option value="optinforms_form_design_option1" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option1') { echo 'selected="selected"'; } ?>>01</option>
196 <option value="optinforms_form_design_option2" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option2') { echo 'selected="selected"'; } ?>>02</option>
197 <option value="optinforms_form_design_option3" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option3') { echo 'selected="selected"'; } ?>>03</option>
198 <option value="optinforms_form_design_option4" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option4') { echo 'selected="selected"'; } ?>>04</option>
199 <option value="optinforms_form_design_option5" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option5') { echo 'selected="selected"'; } ?>>05</option>
200 <option value="optinforms_form_design_option6" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option6') { echo 'selected="selected"'; } ?>>06</option>
201 <?php
202
203 // Have any custom form designs been registered?
204 if ( is_array( $optinforms_forms ) ) {
205
206 // Gets the saved form design ID.
207 $saved_design = get_option( 'optinforms_form_design' );
208
209 // Loops through registered form designs.
210 foreach ( $optinforms_forms as $class_name => $design ) {
211
212 // Does the form have an ID and a title?
213 if ( !empty( $design->optinform['id'] ) && !empty( $design->optinform['title'] ) ) {
214 echo '<option value="' . $design->optinform['id'] . '" ' . selected( $saved_design, $design->optinform['id'], false ) . '>' . $design->optinform['title'] . '</option>';
215
216 }
217 }
218 }
219 ?>
220 </select>
221 <script type="text/javascript">
222 // document.getElementById('optinforms_form_design').onchange = function() {
223 // var i = 1;
224 // var myDiv = document.getElementById("optinforms_form_design_option" + i);
225 // while(myDiv) {
226 // myDiv.style.display = 'none';
227 // myDiv = document.getElementById("optinforms_form_design_option" + ++i);
228 // }
229 // document.getElementById(this.value).style.display = 'block';
230 // };
231 </script>
232 </div><!--optionmiddle-->
233 <div class="optionlast">
234
235 </div><!--optionlast-->
236 <div class="clear"></div>
237
238 </div><!--optiongroup-->
239
240 <div id="optinforms-design-backend-wrap" class="optiongroup">
241 <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;"'; } ?>>
242
243 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-1.php'); ?>
244 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-1.php'); ?>
245
246 </div><!--optinforms_form_design_option1-->
247 <div id="optinforms_form_design_option2" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option2') { echo 'style="display:block;"'; } ?>>
248
249 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-2.php'); ?>
250 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-2.php'); ?>
251
252 </div><!--optinforms_form_design_option2-->
253 <div id="optinforms_form_design_option3" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option3') { echo 'style="display:block;"'; } ?>>
254
255 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-3.php'); ?>
256 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-3.php'); ?>
257
258 </div><!--optinforms_form_design_option3-->
259 <div id="optinforms_form_design_option4" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option4') { echo 'style="display:block;"'; } ?>>
260
261 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-4.php'); ?>
262 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-4.php'); ?>
263
264 </div><!--optinforms_form_design_option4-->
265 <div id="optinforms_form_design_option5" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option5') { echo 'style="display:block;"'; } ?>>
266
267 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-5.php'); ?>
268 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-5.php'); ?>
269
270 </div><!--optinforms_form_design_option5-->
271 <div id="optinforms_form_design_option6" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option6') { echo 'style="display:block;"'; } ?>>
272
273 <?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-6.php'); ?>
274 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-6.php'); ?>
275
276 </div><!--optinforms_form_design_option6-->
277 <?php
278
279 // Have any custom form designs been registered?
280 if ( is_array( $optinforms_forms ) ) {
281
282 // Loops through registered form designs.
283 foreach ( $optinforms_forms as $class_name => $design ) {
284
285 // Does the form have an ID and a title?
286 if ( !empty( $design->optinform['id'] ) && !empty( $design->optinform['title'] ) ) {
287 $display = $saved_design == $design->optinform['id'] ? 'style="display:block;"' : 'style="display:none;"';
288 echo '<div id="' . $design->optinform['id'] . '" ' . $display . '>';
289
290 // Displays the form preview if available.
291 if ( method_exists( $design, 'get_optin_form' ) ) {
292 echo $design->get_optin_form();
293 }
294
295 // Displays the form options if available.
296 if ( file_exists( $design->optinform['options_url'] ) ) {
297 include( $design->optinform['options_url'] );
298 }
299
300 echo '</div>';
301
302
303 }
304 }
305 }
306 ?>
307 </div><!--optiongroup-->
308
309 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-functionality.php'); ?>
310 <?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-placement.php'); ?>
311
312 </div><!--optinforms-container-left-->
313 <div class="optinforms-container-right">
314 <?php include( plugin_dir_path( __FILE__ ) . 'includes/sidebar.php'); ?>
315 </div><!--optinforms-container-right-->
316 <div class="clear"></div>
317 </div><!--optinforms-posts-tab-->
318
319 <script type="text/javascript">
320 var wpthumbs=new ddtabcontent("optinforms-menu-tabs") //enter ID of Tab Container
321 wpthumbs.setpersist(true) //toogle persistence of the tabs' state
322 wpthumbs.setselectedClassTarget("link") //"link" or "linkparent"
323 wpthumbs.init()
324 </script>
325
326 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
327 </form>
328
329 </div><!--optinforms-->
330
331 <?php }
332 }
333 }
334 $optin_forms = new Optin_Forms();
335
336
337 if ( !function_exists( 'register_optin_form') ) {
338 /**
339 * Registers optin forms
340 *
341 * Adds new forms to the $optinforms_forms array.
342 *
343 * @param $class_name string Name of the form class being registered.
344 */
345 function register_optin_form( $class_name ) {
346 global $optinforms_forms;
347
348 // Adds form to global forms array.
349 $optinforms_forms[$class_name] = new $class_name;
350 }
351 }
352
353
354 if ( !function_exists( 'optinforms_get_setting') ) {
355 /**
356 * Gets saved form setting
357 *
358 * Falls back on default form setting if there is no saved value.
359 *
360 * @param string $setting_id The ID of the setting to retrieve.
361 * @param string $design_class The class name of the design class that holds the default setting.
362 * @return string $setting The saved setting (or the default, if no setting is saved).
363 */
364 function optinforms_get_setting( $setting_id, $design_class = '' ) {
365
366 // Gets the saved setting from the database.
367 $setting = get_option( $setting_id );
368
369 // Is there no saved setting, and was a design class name provided?
370 if ( empty( $setting ) && !empty( $design_class ) ) {
371 $setting = optinforms_get_default_setting( $setting_id, $design_class );
372 }
373
374 return $setting;
375 }
376 }
377
378
379 if ( !function_exists( 'optinforms_get_default_setting') ) {
380 /**
381 * Gets default form setting
382 *
383 * @param string $setting_id The ID of the setting to retrieve.
384 * @param string $design_class The class name of the design class that holds the default setting.
385 * @return string $setting The saved setting (or the default, if no setting is saved).
386 */
387 function optinforms_get_default_setting( $setting_id, $design_class = '' ) {
388
389 global $optinforms_forms;
390 $setting = '';
391
392 // Is there a default setting stored in the design class?
393 if ( !empty( $optinforms_forms[$design_class]->defaults[$setting_id] ) ) {
394 $setting = $optinforms_forms[$design_class]->defaults[$setting_id];
395 }
396
397 return $setting;
398 }
399 }
400
401 if ( ! function_exists( 'optinforms_translate_sc' ) ) {
402
403 /**
404 * Returns text based on language
405 *
406 * @return string $content The text in correct translation
407 */
408 function optinforms_translate_sc( $atts = false, $content = '') {
409
410 // no atts supplied, return empty
411 if ( ! $atts ) {
412 return '';
413 }
414
415 // if locale incorrect, return empty
416 if ( get_locale() != $atts['lang'] ) {
417 return '';
418 }
419
420 // return text
421 return $content;
422
423 }
424
425 } add_shortcode( 'optinforms_translate', 'optinforms_translate_sc' );
426
427 // Allows for translation of plugin description
428 $plugin_header_translate = array(
429 __( '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' ),
430 );
431