| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Formidable |
| 4 |
*/ |
| 5 |
if(!defined('ABSPATH')) die('You are not allowed to call this page directly.'); |
| 6 |
|
| 7 |
if(class_exists('FrmAppController')) |
| 8 |
return; |
| 9 |
|
| 10 |
class FrmAppController{ |
| 11 |
public static function load_hooks(){ |
| 12 |
add_action('admin_menu', 'FrmAppController::menu', 1); |
| 13 |
add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
| 14 |
add_filter('plugin_action_links_formidable/formidable.php', 'FrmAppController::settings_link', 10, 2 ); |
| 15 |
add_filter('update_plugin_complete_actions', 'FrmAppController::update_action_links', 10, 2 ); |
| 16 |
add_action('admin_notices', 'FrmAppController::pro_get_started_headline'); |
| 17 |
add_filter('the_content', 'FrmAppController::page_route', 10); |
| 18 |
add_action('plugins_loaded', 'FrmAppController::load_lang'); |
| 19 |
add_action('init', 'FrmAppController::front_head'); |
| 20 |
add_action('wp_footer', 'FrmAppController::footer_js', 1, 0); |
| 21 |
add_action('admin_init', 'FrmAppController::admin_js', 11); |
| 22 |
register_activation_hook(FrmAppHelper::plugin_path().'/formidable.php', 'FrmAppController::install'); |
| 23 |
add_action('wp_ajax_frm_install', 'FrmAppController::install'); |
| 24 |
add_action('wp_ajax_frm_uninstall', 'FrmAppController::uninstall'); |
| 25 |
add_action('wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize'); |
| 26 |
|
| 27 |
// Used to process standalone requests |
| 28 |
add_action('init', 'FrmAppController::parse_standalone_request', 40); |
| 29 |
// Update the session data |
| 30 |
add_action('init', 'FrmAppController::referer_session', 1); |
| 31 |
} |
| 32 |
|
| 33 |
public static function menu(){ |
| 34 |
global $frm_vars, $frm_settings; |
| 35 |
|
| 36 |
if ( current_user_can('administrator') && !current_user_can('frm_view_forms') ) { |
| 37 |
global $current_user; |
| 38 |
$frm_roles = FrmAppHelper::frm_capabilities(); |
| 39 |
foreach($frm_roles as $frm_role => $frm_role_description) |
| 40 |
$current_user->add_cap( $frm_role ); |
| 41 |
unset($frm_roles); |
| 42 |
unset($frm_role); |
| 43 |
unset($frm_role_description); |
| 44 |
} |
| 45 |
|
| 46 |
$count = count(get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) )); |
| 47 |
$pos = ((int)$count > 0) ? '22.7' : '29.3'; |
| 48 |
$pos = apply_filters('frm_menu_position', $pos); |
| 49 |
|
| 50 |
if(current_user_can('frm_view_forms')){ |
| 51 |
add_menu_page('Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() .'/images/form_16.png', $pos); |
| 52 |
}else if(current_user_can('frm_view_entries') and $frm_vars['pro_is_installed']){ |
| 53 |
add_menu_page('Formidable', $frm_settings->menu, 'frm_view_entries', 'formidable', 'FrmProEntriesController::route', FrmAppHelper::plugin_url() .'/images/form_16.png', $pos); |
| 54 |
} |
| 55 |
|
| 56 |
add_filter('admin_body_class', 'FrmAppController::wp_admin_body_class'); |
| 57 |
} |
| 58 |
|
| 59 |
public static function load_wp_admin_style(){ |
| 60 |
wp_enqueue_style( 'frm_fonts', FrmAppHelper::plugin_url() .'/css/frm_fonts.css', array(), FrmAppHelper::plugin_version()); |
| 61 |
} |
| 62 |
|
| 63 |
public static function get_form_nav($id, $show_nav=false){ |
| 64 |
global $pagenow, $frm_vars; |
| 65 |
|
| 66 |
$show_nav = FrmAppHelper::get_param('show_nav', $show_nav); |
| 67 |
if(!$show_nav) |
| 68 |
return; |
| 69 |
|
| 70 |
$current_page = (isset($_GET['page'])) ? $_GET['page'] : (isset($_GET['post_type']) ? $_GET['post_type'] : 'None'); |
| 71 |
if($id and is_numeric($id)){ |
| 72 |
$frm_form = new FrmForm(); |
| 73 |
$form = $frm_form->getOne($id); |
| 74 |
unset($frm_form); |
| 75 |
}else{ |
| 76 |
$form = false; |
| 77 |
} |
| 78 |
|
| 79 |
include(FrmAppHelper::plugin_path() .'/classes/views/shared/form-nav.php'); |
| 80 |
} |
| 81 |
|
| 82 |
// Adds a settings link to the plugins page |
| 83 |
public static function settings_link($links, $file){ |
| 84 |
$settings = '<a href="'. admin_url('admin.php?page=formidable-settings') .'">' . __('Settings', 'formidable') . '</a>'; |
| 85 |
array_unshift($links, $settings); |
| 86 |
|
| 87 |
return $links; |
| 88 |
} |
| 89 |
|
| 90 |
public static function update_action_links( $actions, $plugin ) { |
| 91 |
|
| 92 |
if ( 'formidable/formidable.php' != $plugin ) |
| 93 |
return $actions; |
| 94 |
|
| 95 |
global $frm_vars; |
| 96 |
|
| 97 |
$db_version = get_option('frm_db_version'); |
| 98 |
$pro_db_version = $frm_vars['pro_is_installed'] ? get_option('frmpro_db_version') : false; |
| 99 |
|
| 100 |
if ( ( (int) $db_version < (int) FrmAppHelper::$db_version ) || |
| 101 |
( $frm_vars['pro_is_installed'] && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
| 102 |
|
| 103 |
return sprintf( '<a href="%s">%s</a>', add_query_arg(array('upgraded' => 'true'), menu_page_url( 'formidable', 0 )), __( 'Click here to complete the upgrade', 'formidable' ) ); |
| 104 |
|
| 105 |
} else { |
| 106 |
return $actions; |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
public static function pro_get_started_headline(){ |
| 111 |
if ( isset($_GET['page']) && 'formidable' == $_GET['page'] && isset( $_REQUEST['upgraded'] ) && 'true' == $_REQUEST['upgraded'] ) { |
| 112 |
self::install(); |
| 113 |
?> |
| 114 |
<div id="message" class="frm_message updated"><?php _e('Congratulations! Formidable is ready to roll.', 'formidable') ?></div> |
| 115 |
<?php |
| 116 |
return; |
| 117 |
} |
| 118 |
|
| 119 |
// Don't display this error as we're upgrading the thing... cmon |
| 120 |
if(isset($_GET['action']) and $_GET['action'] == 'upgrade-plugin') |
| 121 |
return; |
| 122 |
|
| 123 |
if ( is_multisite() && !current_user_can('administrator') ) { |
| 124 |
return; |
| 125 |
} |
| 126 |
|
| 127 |
if(!isset($_GET['activate'])){ |
| 128 |
global $frm_vars; |
| 129 |
$db_version = get_option('frm_db_version'); |
| 130 |
$pro_db_version = ($frm_vars['pro_is_installed']) ? get_option('frmpro_db_version') : false; |
| 131 |
if ( ( (int) $db_version < (int) FrmAppHelper::$db_version ) || |
| 132 |
( $frm_vars['pro_is_installed'] && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
| 133 |
?> |
| 134 |
<div class="error" id="frm_install_message" style="padding:7px;"><?php _e('Your update is not complete yet.<br/>Please deactivate and reactivate the plugin to complete the update or', 'formidable'); ?> <a id="frm_install_link" href="javascript:void(0)"><?php _e('Update Now', 'formidable') ?></a></div> |
| 135 |
<script type="text/javascript"> |
| 136 |
jQuery(document).ready(function($){ $('#frm_install_link').click(frm_install_now); }); |
| 137 |
function frm_install_now(){ |
| 138 |
jQuery('#frm_install_message').html('<div style="line-height:24px;"><?php _e("Please wait while your site updates.", "formidable") ?><div class="spinner frm_spinner" style="float:left;display:block;"></div></div>'); |
| 139 |
jQuery.ajax({ |
| 140 |
type:"POST",url:ajaxurl,data:"action=frm_install", |
| 141 |
success:function(msg){jQuery("#frm_install_message").fadeOut("slow");} |
| 142 |
}); |
| 143 |
} |
| 144 |
</script> |
| 145 |
<?php |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
if ( self::pro_is_authorized() && !self::pro_is_installed()) { |
| 150 |
// user is authorized, but running free version |
| 151 |
$inst_install_url = 'http://formidablepro.com/knowledgebase/manually-install-formidable-pro/'; |
| 152 |
?> |
| 153 |
<div class="error" style="padding:7px;"><?php echo apply_filters('frm_pro_update_msg', sprintf(__('This site has been previously authorized to run Formidable Pro.<br/>%1$sInstall the pro version%2$s or %3$sdeauthorize%4$s this site to continue running the free version and remove this message.', 'formidable'), '<a href="'. $inst_install_url .'" target="_blank">', '</a>', '<a href="javascript:void(0)" onclick="frm_deauthorize_now()" class="frm_deauthorize_link">', '</a>'), $inst_install_url); ?></div> |
| 154 |
<script type="text/javascript"> |
| 155 |
function frm_deauthorize_now(){ |
| 156 |
if(!confirm("<?php esc_attr_e('Are you sure you want to deauthorize Formidable Pro on this site?', 'formidable') ?>")) |
| 157 |
return false; |
| 158 |
jQuery('.frm_deauthorize_link').html('<span class="spinner" style="display:inline-block;margin-top:0;float:none;"></span>'); |
| 159 |
jQuery.ajax({type:'POST',url:ajaxurl,data:'action=frm_deauthorize&nonce='+wp_create_nonce('frm_ajax'), |
| 160 |
success:function(msg){jQuery('.error').fadeOut('slow');} |
| 161 |
}); |
| 162 |
return false; |
| 163 |
} |
| 164 |
</script> |
| 165 |
<?php |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
public static function admin_js(){ |
| 170 |
global $pagenow; |
| 171 |
|
| 172 |
if ( 'admin-ajax.php' == $pagenow && isset($_GET['action']) && $_GET['action'] != 'frm_import_choices' ) { |
| 173 |
return; |
| 174 |
} |
| 175 |
|
| 176 |
wp_enqueue_script('jquery'); |
| 177 |
wp_enqueue_script('jquery-ui-core'); |
| 178 |
wp_register_script('bootstrap_tooltip', FrmAppHelper::plugin_url() .'/js/bootstrap.min.js', array('jquery'), '3.0.3'); |
| 179 |
|
| 180 |
if ( isset($_GET) && ((isset($_GET['page']) && strpos($_GET['page'], 'formidable') === 0 ) || |
| 181 |
($pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'frm_display')) |
| 182 |
) { |
| 183 |
$version = FrmAppHelper::plugin_version(); |
| 184 |
add_filter('admin_body_class', 'FrmAppController::admin_body_class'); |
| 185 |
|
| 186 |
wp_enqueue_script('jquery-ui-sortable'); |
| 187 |
wp_enqueue_script('jquery-ui-draggable'); |
| 188 |
wp_enqueue_script('admin-widgets'); |
| 189 |
wp_enqueue_style('widgets'); |
| 190 |
wp_enqueue_script('formidable'); |
| 191 |
wp_enqueue_script('formidable_admin', FrmAppHelper::plugin_url() .'/js/formidable_admin.js', array('formidable', 'jquery', 'jquery-ui-draggable', 'bootstrap_tooltip'), $version, true); |
| 192 |
self::localize_script('admin'); |
| 193 |
|
| 194 |
wp_enqueue_style('formidable-admin', FrmAppHelper::plugin_url() .'/css/frm_admin.css', array(), $version); |
| 195 |
add_thickbox(); |
| 196 |
|
| 197 |
wp_register_script('formidable-editinplace', FrmAppHelper::plugin_url() .'/js/jquery/jquery.editinplace.packed.js', array('jquery'), '2.3.0'); |
| 198 |
wp_register_script('jquery-frm-themepicker', FrmAppHelper::plugin_url() .'/js/jquery/jquery-ui-themepicker.js', array('jquery'), $version); |
| 199 |
|
| 200 |
|
| 201 |
}else if($pagenow == 'post.php' or ($pagenow == 'post-new.php' and isset($_REQUEST['post_type']) and $_REQUEST['post_type'] == 'frm_display')){ |
| 202 |
if(isset($_REQUEST['post_type'])){ |
| 203 |
$post_type = $_REQUEST['post_type']; |
| 204 |
}else if(isset($_REQUEST['post']) and !empty($_REQUEST['post'])){ |
| 205 |
$post = get_post($_REQUEST['post']); |
| 206 |
if(!$post) |
| 207 |
return; |
| 208 |
$post_type = $post->post_type; |
| 209 |
}else{ |
| 210 |
return; |
| 211 |
} |
| 212 |
|
| 213 |
if($post_type == 'frm_display'){ |
| 214 |
$version = FrmAppHelper::plugin_version(); |
| 215 |
wp_enqueue_script('jquery-ui-draggable'); |
| 216 |
wp_enqueue_script('formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', array('formidable', 'jquery', 'jquery-ui-draggable', 'bootstrap_tooltip'), $version); |
| 217 |
wp_enqueue_style('formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css', array(), $version); |
| 218 |
self::localize_script('admin'); |
| 219 |
} |
| 220 |
} |
| 221 |
} |
| 222 |
|
| 223 |
public static function admin_body_class($classes){ |
| 224 |
global $wp_version; |
| 225 |
|
| 226 |
//we only need this class on Formidable pages |
| 227 |
if(version_compare( $wp_version, '3.4.9', '>')) |
| 228 |
$classes .= ' frm_35_trigger'; |
| 229 |
|
| 230 |
return $classes; |
| 231 |
} |
| 232 |
|
| 233 |
public static function wp_admin_body_class($classes){ |
| 234 |
global $wp_version; |
| 235 |
//we need this class everywhere in the admin for the menu |
| 236 |
if(version_compare( $wp_version, '3.7.2', '>')) |
| 237 |
$classes .= ' frm_38_trigger'; |
| 238 |
|
| 239 |
return $classes; |
| 240 |
} |
| 241 |
|
| 242 |
public static function load_lang(){ |
| 243 |
load_plugin_textdomain('formidable', false, 'formidable/languages/' ); |
| 244 |
} |
| 245 |
|
| 246 |
public static function front_head(){ |
| 247 |
global $frm_settings; |
| 248 |
|
| 249 |
if (is_multisite()){ |
| 250 |
global $frm_vars; |
| 251 |
$old_db_version = get_option('frm_db_version'); |
| 252 |
$pro_db_version = ($frm_vars['pro_is_installed']) ? get_option('frmpro_db_version') : false; |
| 253 |
if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
| 254 |
( $frm_vars['pro_is_installed'] && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
| 255 |
self::install($old_db_version); |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
$version = FrmAppHelper::plugin_version(); |
| 260 |
wp_register_script('formidable', FrmAppHelper::plugin_url() . '/js/formidable.min.js', array('jquery'), $version, true); |
| 261 |
wp_register_script('jquery-placeholder', FrmAppHelper::plugin_url() .'/js/jquery/jquery.placeholder.js', array('jquery'), '2.0.7', true); |
| 262 |
wp_register_script('recaptcha-ajax', 'http'. (is_ssl() ? 's' : '').'://www.google.com/recaptcha/api/js/recaptcha_ajax.js', '', true); |
| 263 |
|
| 264 |
if ( is_admin() && !defined('DOING_AJAX') ) { |
| 265 |
// don't load this in back-end |
| 266 |
return; |
| 267 |
} |
| 268 |
|
| 269 |
self::localize_script('front'); |
| 270 |
|
| 271 |
wp_enqueue_script('jquery'); |
| 272 |
|
| 273 |
$style = apply_filters('get_frm_stylesheet', array('frm-forms' => FrmAppHelper::plugin_url() .'/css/frm_display.css')); |
| 274 |
if($style){ |
| 275 |
foreach((array)$style as $k => $file){ |
| 276 |
wp_register_style($k, $file, array(), $version); |
| 277 |
if ( 'all' == $frm_settings->load_style ) { |
| 278 |
wp_enqueue_style($k); |
| 279 |
} |
| 280 |
unset($k, $file); |
| 281 |
} |
| 282 |
} |
| 283 |
unset($style); |
| 284 |
|
| 285 |
if ( $frm_settings->load_style == 'all' ) { |
| 286 |
global $frm_vars; |
| 287 |
$frm_vars['css_loaded'] = true; |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
public static function localize_script($location){ |
| 292 |
wp_localize_script('formidable', 'frm_js', array( |
| 293 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 294 |
'images_url' => FrmAppHelper::plugin_url() .'/images', |
| 295 |
'loading' => __('Loading…'), |
| 296 |
'remove' => __('Remove', 'formidable'), |
| 297 |
'offset' => apply_filters('frm_scroll_offset', 4), |
| 298 |
)); |
| 299 |
|
| 300 |
if($location == 'admin'){ |
| 301 |
global $frm_settings; |
| 302 |
wp_localize_script('formidable_admin', 'frm_admin_js', array( |
| 303 |
'confirm_uninstall' => __('Are you sure you want to do this? Clicking OK will delete all forms, form data, and all other Formidable data. There is no Undo.', 'formidable'), |
| 304 |
'get_page' => (isset($_GET) && isset($_GET['page'])) ? $_GET['page'] : '', |
| 305 |
'desc' => __('(Click here to add a description or instructions)', 'formidable'), |
| 306 |
'blank' => __('(Blank)', 'formidable'), |
| 307 |
'saving' => esc_attr(__('Saving', 'formidable')), |
| 308 |
'saved' => esc_attr(__('Saved', 'formidable')), |
| 309 |
'ok' => __('OK'), |
| 310 |
'cancel' => __('Cancel', 'formidable'), |
| 311 |
'clear_default' => __('Clear default value when typing', 'formidable'), |
| 312 |
'no_clear_default' => __('Do not clear default value when typing', 'formidable'), |
| 313 |
'valid_default' => __('Default value will pass form validation', 'formidable'), |
| 314 |
'no_valid_default' => __('Default value will NOT pass form validation', 'formidable'), |
| 315 |
'deauthorize' => __('Are you sure you want to deactivate Formidable Pro on this site?', 'formidable'), |
| 316 |
'confirm' => __('Are you sure?', 'formidable'), |
| 317 |
'default_unique' => $frm_settings->unique_msg, |
| 318 |
'import_complete' => __('Import Complete', 'formidable'), |
| 319 |
'updating' => __('Please wait while your site updates.', 'formidable'), |
| 320 |
'nonce' => wp_create_nonce('frm_ajax'), |
| 321 |
)); |
| 322 |
} |
| 323 |
} |
| 324 |
|
| 325 |
public static function footer_js($location='footer'){ |
| 326 |
global $frm_settings, $frm_vars; |
| 327 |
|
| 328 |
if($frm_vars['load_css'] and (!is_admin() or defined('DOING_AJAX')) and ($frm_settings->load_style != 'none')){ |
| 329 |
if(isset($frm_vars['css_loaded']) && $frm_vars['css_loaded']) |
| 330 |
$css = apply_filters('get_frm_stylesheet', array()); |
| 331 |
else |
| 332 |
$css = apply_filters('get_frm_stylesheet', array('frm-forms' => FrmAppHelper::plugin_url() .'/css/frm_display.css')); |
| 333 |
|
| 334 |
if(!empty($css)){ |
| 335 |
echo "\n".'<script type="text/javascript">'; |
| 336 |
foreach((array)$css as $css_key => $file){ |
| 337 |
echo 'jQuery("head").append(unescape("%3Clink rel=\'stylesheet\' id=\''. ($css_key + (isset($frm_vars['css_loaded']) ? $frm_vars['css_loaded'] : false)) .'-css\' href=\''. $file. '\' type=\'text/css\' media=\'all\' /%3E"));'; |
| 338 |
//wp_enqueue_style($css_key); |
| 339 |
unset($css_key); |
| 340 |
unset($file); |
| 341 |
} |
| 342 |
unset($css); |
| 343 |
|
| 344 |
echo '</script>'."\n"; |
| 345 |
} |
| 346 |
} |
| 347 |
|
| 348 |
if((!is_admin() or defined('DOING_AJAX')) and $location != 'header' and !empty($frm_vars['forms_loaded'])) //load formidable js |
| 349 |
FrmAppHelper::load_scripts(array('formidable')); |
| 350 |
} |
| 351 |
|
| 352 |
public static function install($old_db_version=false){ |
| 353 |
global $frmdb; |
| 354 |
$frmdb->upgrade($old_db_version); |
| 355 |
} |
| 356 |
|
| 357 |
public static function uninstall(){ |
| 358 |
check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 359 |
|
| 360 |
if ( current_user_can('administrator') ) { |
| 361 |
global $frmdb; |
| 362 |
$frmdb->uninstall(); |
| 363 |
echo true; |
| 364 |
} else { |
| 365 |
global $frm_settings; |
| 366 |
wp_die($frm_settings->admin_permission); |
| 367 |
} |
| 368 |
die(); |
| 369 |
} |
| 370 |
|
| 371 |
// Routes for wordpress pages -- we're just replacing content here folks. |
| 372 |
public static function page_route($content){ |
| 373 |
global $post, $frm_settings; |
| 374 |
|
| 375 |
if( $post && $post->ID == $frm_settings->preview_page_id && isset($_GET['form'])){ |
| 376 |
$content = FrmFormsController::page_preview(); |
| 377 |
} |
| 378 |
|
| 379 |
return $content; |
| 380 |
} |
| 381 |
|
| 382 |
public static function referer_session() { |
| 383 |
global $frm_settings; |
| 384 |
|
| 385 |
if ( !isset($frm_settings->track) || !$frm_settings->track || defined('WP_IMPORTING') ) { |
| 386 |
return; |
| 387 |
} |
| 388 |
|
| 389 |
// keep the page history below 100 |
| 390 |
$max = 100; |
| 391 |
|
| 392 |
if ( !isset($_SESSION) ) |
| 393 |
session_start(); |
| 394 |
|
| 395 |
if ( !isset($_SESSION['frm_http_pages']) or !is_array($_SESSION['frm_http_pages']) ) |
| 396 |
$_SESSION['frm_http_pages'] = array("http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']); |
| 397 |
|
| 398 |
if ( !isset($_SESSION['frm_http_referer']) or !is_array($_SESSION['frm_http_referer']) ) |
| 399 |
$_SESSION['frm_http_referer'] = array(); |
| 400 |
|
| 401 |
if (!isset($_SERVER['HTTP_REFERER']) or (isset($_SERVER['HTTP_REFERER']) and (strpos($_SERVER['HTTP_REFERER'], FrmAppHelper::site_url()) === false) and ! (in_array($_SERVER['HTTP_REFERER'], $_SESSION['frm_http_referer'])) )) { |
| 402 |
if (! isset($_SERVER['HTTP_REFERER'])){ |
| 403 |
$direct = __('Type-in or bookmark', 'formidable'); |
| 404 |
if(!in_array($direct, $_SESSION['frm_http_referer'])) |
| 405 |
$_SESSION['frm_http_referer'][] = $direct; |
| 406 |
}else{ |
| 407 |
$_SESSION['frm_http_referer'][] = $_SERVER['HTTP_REFERER']; |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
if ($_SESSION['frm_http_pages'] and !empty($_SESSION['frm_http_pages']) and (end($_SESSION['frm_http_pages']) != "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'])) |
| 412 |
$_SESSION['frm_http_pages'][] = "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']; |
| 413 |
|
| 414 |
//keep the page history below the max |
| 415 |
if(count($_SESSION['frm_http_pages']) > $max){ |
| 416 |
foreach($_SESSION['frm_http_pages'] as $pkey => $ppage){ |
| 417 |
if(count($_SESSION['frm_http_pages']) <= $max) |
| 418 |
break; |
| 419 |
|
| 420 |
unset($_SESSION['frm_http_pages'][$pkey]); |
| 421 |
} |
| 422 |
} |
| 423 |
} |
| 424 |
|
| 425 |
public static function parse_standalone_request(){ |
| 426 |
$plugin = FrmAppHelper::get_param('plugin'); |
| 427 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
| 428 |
$action = FrmAppHelper::get_param($action); |
| 429 |
$controller = FrmAppHelper::get_param('controller'); |
| 430 |
|
| 431 |
if( !empty($plugin) and $plugin == 'formidable' and !empty($controller) ){ |
| 432 |
_deprecated_function( __FUNCTION__, '1.07.02', 'wp_ajax_nopriv()' ); |
| 433 |
|
| 434 |
if($controller == 'forms') |
| 435 |
FrmFormsController::preview(FrmAppHelper::get_param('form')); |
| 436 |
else |
| 437 |
do_action('frm_standalone_route', $controller, $action); |
| 438 |
|
| 439 |
do_action('frm_ajax_'. $controller .'_'. $action); |
| 440 |
die(); |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
//formidable shortcode |
| 445 |
public static function get_form_shortcode($atts){ |
| 446 |
_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
| 447 |
return FrmFormsController::get_form_shortcode($atts); |
| 448 |
} |
| 449 |
|
| 450 |
public static function widget_text_filter_callback( $matches ) { |
| 451 |
return do_shortcode( $matches[0] ); |
| 452 |
} |
| 453 |
|
| 454 |
public static function update_message($features){ |
| 455 |
include(FrmAppHelper::plugin_path() .'/classes/views/shared/update_message.php'); |
| 456 |
} |
| 457 |
|
| 458 |
public static function get_postbox_class(){ |
| 459 |
if(version_compare( $GLOBALS['wp_version'], '3.3.2', '>')) |
| 460 |
return 'postbox-container'; |
| 461 |
else |
| 462 |
return 'inner-sidebar'; |
| 463 |
} |
| 464 |
|
| 465 |
public static function pro_is_installed(){ |
| 466 |
return file_exists(FrmAppHelper::plugin_path() . '/pro/formidable-pro.php'); |
| 467 |
} |
| 468 |
|
| 469 |
public static function pro_is_authorized(){ |
| 470 |
return get_site_option('frmpro-authorized'); |
| 471 |
} |
| 472 |
|
| 473 |
public static function deauthorize(){ |
| 474 |
check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 475 |
|
| 476 |
delete_option('frmpro-credentials'); |
| 477 |
delete_option('frmpro-authorized'); |
| 478 |
delete_site_option('frmpro-credentials'); |
| 479 |
delete_site_option('frmpro-authorized'); |
| 480 |
die(); |
| 481 |
} |
| 482 |
} |
| 483 |
|