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

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