| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Optin Forms |
| 4 |
Plugin URI: http://www.codeleon.com/wordpress/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: Codeleon |
| 7 |
Version: 1.1 |
| 8 |
Author URI: http://www.codeleon.com |
| 9 |
License: Free |
| 10 |
Text Domain: optinforms |
| 11 |
Domain Path: /languages/ |
| 12 |
*/ |
| 13 |
|
| 14 |
// Add translation to plugin |
| 15 |
function optinforms_init() { |
| 16 |
$plugin_dir = basename(dirname(__FILE__)); |
| 17 |
load_plugin_textdomain( 'optinforms', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 18 |
} |
| 19 |
add_action('plugins_loaded', 'optinforms_init'); |
| 20 |
|
| 21 |
// Allow for translation of plugin description |
| 22 |
$plugin_header_translate = array( |
| 23 |
__('Create beautiful optin forms with ease. Choose a form design, customize it, and add your form to your blog with a simple mouse-click.', 'optinforms'), |
| 24 |
); |
| 25 |
|
| 26 |
// Add our menu to WordPress |
| 27 |
add_action( 'admin_menu', 'optinforms_menu' ); |
| 28 |
|
| 29 |
function optinforms_menu() |
| 30 |
{ |
| 31 |
$submenu = add_menu_page(__('Optin Forms','menu-test'), __('Optin Forms','menu-test'), 'manage_options', 'optinforms', 'optinforms_main_page', plugins_url('optin-forms/images/icon.png'), 31); |
| 32 |
|
| 33 |
// * We want our JS and CSS loaded on our admin pages only, so let's just load them for now |
| 34 |
add_action( 'load-' . $submenu, 'load_optinforms_admin_scripts' ); |
| 35 |
} |
| 36 |
|
| 37 |
// Enqueue our CSS and JS on WP Video Coach admin pages only |
| 38 |
function load_optinforms_admin_scripts() { |
| 39 |
add_action( 'admin_enqueue_scripts', 'optinforms_admin_scripts' ); |
| 40 |
} |
| 41 |
|
| 42 |
// Include our registration settings |
| 43 |
include( plugin_dir_path( __FILE__ ) . 'includes/register-settings.php'); |
| 44 |
// Include our regular functions |
| 45 |
include( plugin_dir_path( __FILE__ ) . 'includes/functions.php'); |
| 46 |
// Include our form functions |
| 47 |
include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-1.php'); |
| 48 |
include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-2.php'); |
| 49 |
include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-3.php'); |
| 50 |
include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-4.php'); |
| 51 |
include( plugin_dir_path( __FILE__ ) . 'includes/functions-form-5.php'); |
| 52 |
include( plugin_dir_path( __FILE__ ) . 'includes/functions-forms.php'); |
| 53 |
|
| 54 |
|
| 55 |
// Add our CSS and JS to admin head, but just for our pages (see load_optinforms_admin_scripts above!) |
| 56 |
function optinforms_admin_scripts() |
| 57 |
{ |
| 58 |
wp_enqueue_style('optinforms-admin-stylesheet', plugins_url('/css/optinforms-admin.css', __FILE__ ), array('googleFont')); |
| 59 |
wp_enqueue_script('tabcontent', plugins_url('/js/tabcontent.js', __FILE__ )); |
| 60 |
wp_enqueue_style('wp-color-picker'); |
| 61 |
wp_enqueue_script('optinforms-color', plugins_url('/js/optinforms-color.js', __FILE__ ), array( 'wp-color-picker' ), false, true ); |
| 62 |
wp_enqueue_script('placeholder', plugins_url('/js/placeholder.js', __FILE__ )); |
| 63 |
wp_enqueue_script('toggle', plugins_url('/js/custom.js', __FILE__ )); |
| 64 |
wp_register_style('googleFont', 'http://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'); |
| 65 |
} |
| 66 |
|
| 67 |
// Enqueue our form CSS on front end |
| 68 |
add_action( 'wp_enqueue_scripts', 'optinforms_scripts' ); |
| 69 |
|
| 70 |
|
| 71 |
// Add our CSS and JS to admin head, but just for our pages (see load_optinforms_admin_scripts above!) |
| 72 |
function optinforms_scripts() |
| 73 |
{ |
| 74 |
global $optinforms_form_design; |
| 75 |
wp_enqueue_style('optinforms-stylesheet', plugins_url('/css/optinforms.css', __FILE__ ), array('googleFont')); |
| 76 |
wp_enqueue_script('placeholder', plugins_url('/js/placeholder.js', __FILE__ )); |
| 77 |
wp_register_style('googleFont', optinforms_used_fonts()); |
| 78 |
} |
| 79 |
|
| 80 |
// Make sure user can manage options |
| 81 |
function optinforms_options() { |
| 82 |
if ( !current_user_can( 'manage_options' ) ) { |
| 83 |
wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); |
| 84 |
} |
| 85 |
?> |
| 86 |
|
| 87 |
<?php } |
| 88 |
function optinforms_main_page() { |
| 89 |
|
| 90 |
{ ?> |
| 91 |
<div class="wrap"> |
| 92 |
<div id="icon-optinforms" class="icon32"> |
| 93 |
</div><!--icon-32--> |
| 94 |
|
| 95 |
<h2 class="title"><?php echo optinforms_menu_tabs(); ?></h2> |
| 96 |
</div><!--wrap--> |
| 97 |
|
| 98 |
<?php echo optinforms_configuration(); ?> |
| 99 |
|
| 100 |
<?php if( isset($_GET['settings-updated']) ) { ?> |
| 101 |
<div id="message" class="updated"> |
| 102 |
<p><strong><?php _e('Settings updated') ?></strong> - <?php echo __('If you enjoy our plugin, why not tweet about it?', 'optinforms'); ?> <a href="https://twitter.com/intent/tweet?original_referer=http://www.codeleon.com/wordpress/plugins/optin-forms/&related=codeleoncom&text=Create%20Beautiful%20Optin%20Forms%20in%20WordPress%20with%20This%20FREE%20Plugin:&url=http://www.codeleon.com/wordpress/plugins/optin-forms" target="_blank"><?php echo __('Share on Twitter', 'optinforms'); ?></a></p> |
| 103 |
</div> |
| 104 |
<?php } ?> |
| 105 |
|
| 106 |
<div id="optinforms"> |
| 107 |
<form method="post" action="options.php" id="frm1"> |
| 108 |
<?php settings_fields( 'optinforms-settings-group' ); ?> |
| 109 |
|
| 110 |
<div id="optinforms-email-solution-tab" class="tabcontent"> |
| 111 |
<div class="optinforms-container-left"> |
| 112 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/options-email-solution.php'); ?> |
| 113 |
</div><!--optinforms-container-left--> |
| 114 |
<div class="optinforms-container-right"> |
| 115 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/sidebar.php'); ?> |
| 116 |
</div><!--optinforms-container-right--> |
| 117 |
<div class="clear"></div> |
| 118 |
</div><!--optinforms-email-solution-tab--> |
| 119 |
|
| 120 |
<div id="optinforms-posts-tab" class="tabcontent"> |
| 121 |
<div class="optinforms-container-left"> |
| 122 |
<div class="optiongroup"> |
| 123 |
<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.', 'optinforms'); ?></p> |
| 124 |
<div class="optionleft"> |
| 125 |
<label for="optinforms_form_design" class="nopointer"><?php echo __('Form design', 'optinforms'); ?></label> |
| 126 |
</div><!--optionleft--> |
| 127 |
<div class="optionmiddle"> |
| 128 |
<select name="optinforms_form_design" id="optinforms_form_design"> |
| 129 |
<option value="optinforms_form_design_option1" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option1') echo 'selected="selected"'; ?>>01</option> |
| 130 |
<option value="optinforms_form_design_option2" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option2') echo 'selected="selected"'; ?>>02</option> |
| 131 |
<option value="optinforms_form_design_option3" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option3') echo 'selected="selected"'; ?>>03</option> |
| 132 |
<option value="optinforms_form_design_option4" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option4') echo 'selected="selected"'; ?>>04</option> |
| 133 |
<option value="optinforms_form_design_option5" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option5') echo 'selected="selected"'; ?>>05</option> |
| 134 |
</select> |
| 135 |
<script type="text/javascript"> |
| 136 |
document.getElementById('optinforms_form_design').onchange = function() { |
| 137 |
var i = 1; |
| 138 |
var myDiv = document.getElementById("optinforms_form_design_option" + i); |
| 139 |
while(myDiv) { |
| 140 |
myDiv.style.display = 'none'; |
| 141 |
myDiv = document.getElementById("optinforms_form_design_option" + ++i); |
| 142 |
} |
| 143 |
document.getElementById(this.value).style.display = 'block'; |
| 144 |
}; |
| 145 |
</script> |
| 146 |
</div><!--optionmiddle--> |
| 147 |
<div class="optionlast"> |
| 148 |
|
| 149 |
</div><!--optionlast--> |
| 150 |
<div class="clear"></div> |
| 151 |
|
| 152 |
</div><!--optiongroup--> |
| 153 |
|
| 154 |
<div class="optiongroup"> |
| 155 |
<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;"'; ?>> |
| 156 |
|
| 157 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-1.php'); ?> |
| 158 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-1.php'); ?> |
| 159 |
|
| 160 |
</div><!--optinforms_form_design_option1--> |
| 161 |
<div id="optinforms_form_design_option2" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option2') echo 'style="display:block;"'; ?>> |
| 162 |
|
| 163 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-2.php'); ?> |
| 164 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-2.php'); ?> |
| 165 |
|
| 166 |
</div><!--optinforms_form_design_option2--> |
| 167 |
<div id="optinforms_form_design_option3" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option3') echo 'style="display:block;"'; ?>> |
| 168 |
|
| 169 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-3.php'); ?> |
| 170 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-3.php'); ?> |
| 171 |
|
| 172 |
</div><!--optinforms_form_design_option3--> |
| 173 |
<div id="optinforms_form_design_option4" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option4') echo 'style="display:block;"'; ?>> |
| 174 |
|
| 175 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-4.php'); ?> |
| 176 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-4.php'); ?> |
| 177 |
|
| 178 |
</div><!--optinforms_form_design_option4--> |
| 179 |
<div id="optinforms_form_design_option5" <?php if (get_option('optinforms_form_design')== 'optinforms_form_design_option5') echo 'style="display:block;"'; ?>> |
| 180 |
|
| 181 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/preview-form-5.php'); ?> |
| 182 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-5.php'); ?> |
| 183 |
|
| 184 |
</div><!--optinforms_form_design_option5--> |
| 185 |
</div><!--optiongroup--> |
| 186 |
|
| 187 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/options-form-placement.php'); ?> |
| 188 |
|
| 189 |
</div><!--optinforms-container-left--> |
| 190 |
<div class="optinforms-container-right"> |
| 191 |
<?php include( plugin_dir_path( __FILE__ ) . 'includes/sidebar.php'); ?> |
| 192 |
</div><!--optinforms-container-right--> |
| 193 |
<div class="clear"></div> |
| 194 |
</div><!--optinforms-posts-tab--> |
| 195 |
|
| 196 |
<script type="text/javascript"> |
| 197 |
var wpthumbs=new ddtabcontent("optinforms-menu-tabs") //enter ID of Tab Container |
| 198 |
wpthumbs.setpersist(true) //toogle persistence of the tabs' state |
| 199 |
wpthumbs.setselectedClassTarget("link") //"link" or "linkparent" |
| 200 |
wpthumbs.init() |
| 201 |
</script> |
| 202 |
|
| 203 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 204 |
</form> |
| 205 |
|
| 206 |
<div id="emailbox"> |
| 207 |
<form method="post" action="http://www.codeleon.com/send/form.php?form=5" id="frmSS5"> |
| 208 |
<h3><?php echo __('Sign up to receive news about the plugin and other WordPress news', 'optinforms'); ?></h3> |
| 209 |
<span><?php echo __('My email is', 'optinforms'); ?></span> |
| 210 |
<input type="text" name="email" value="<?php global $current_user; get_currentuserinfo(); echo $current_user->user_email; ?>" /> |
| 211 |
<span><?php echo __('and my name is', 'optinforms'); ?></span> |
| 212 |
<input type="text" name="CustomFields[1]" id="CustomFields_1_5" value="<?php global $current_user; get_currentuserinfo(); echo $current_user->display_name; ?>"> |
| 213 |
<input type="hidden" name="format" value="h" /> |
| 214 |
<input type="submit" class="emailbox-subscribe" value="<?php echo __('Subscribe', 'optinforms'); ?>" /> |
| 215 |
</form> |
| 216 |
</div><!--emailbox--> |
| 217 |
</div><!--optinforms--> |
| 218 |
|
| 219 |
<?php } |
| 220 |
|
| 221 |
|
| 222 |
} ?> |