| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
class FrmAppController { |
| 7 |
|
| 8 |
public static function menu() { |
| 9 |
FrmAppHelper::maybe_add_permissions(); |
| 10 |
if ( ! current_user_can( 'frm_view_forms' ) ) { |
| 11 |
return; |
| 12 |
} |
| 13 |
|
| 14 |
$menu_name = FrmAppHelper::get_menu_name(); |
| 15 |
add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() ); |
| 16 |
} |
| 17 |
|
| 18 |
private static function get_menu_position() { |
| 19 |
return apply_filters( 'frm_menu_position', '29.3' ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* @since 3.05 |
| 24 |
*/ |
| 25 |
private static function menu_icon() { |
| 26 |
$icon = FrmAppHelper::svg_logo( |
| 27 |
array( |
| 28 |
'fill' => '#a0a5aa', |
| 29 |
'orange' => '#a0a5aa', |
| 30 |
) |
| 31 |
); |
| 32 |
$icon = 'data:image/svg+xml;base64,' . base64_encode( $icon ); |
| 33 |
|
| 34 |
return apply_filters( 'frm_icon', $icon ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* @since 3.0 |
| 39 |
*/ |
| 40 |
public static function add_admin_class( $classes ) { |
| 41 |
if ( self::is_white_page() ) { |
| 42 |
$classes .= ' frm-white-body '; |
| 43 |
$classes .= self::get_os(); |
| 44 |
|
| 45 |
$page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ); |
| 46 |
if ( empty( $page ) || $page === 'formidable' ) { |
| 47 |
$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 48 |
if ( in_array( $action, array( 'settings', 'edit', 'list' ) ) ) { |
| 49 |
$page .= $action; |
| 50 |
} else { |
| 51 |
$page = $action; |
| 52 |
} |
| 53 |
} |
| 54 |
if ( ! empty( $page ) ) { |
| 55 |
$classes .= ' frm-admin-page-' . $page; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
if ( FrmAppHelper::is_full_screen() ) { |
| 60 |
$classes .= apply_filters( 'frm_admin_full_screen_class', ' frm-full-screen folded' ); |
| 61 |
} |
| 62 |
|
| 63 |
return $classes; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* @since 4.0 |
| 68 |
*/ |
| 69 |
private static function get_os() { |
| 70 |
$agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) ); |
| 71 |
$os = ''; |
| 72 |
if ( strpos( $agent, 'mac' ) !== false ) { |
| 73 |
$os = ' osx'; |
| 74 |
} elseif ( strpos( $agent, 'linux' ) !== false ) { |
| 75 |
$os = ' linux'; |
| 76 |
} elseif ( strpos( $agent, 'windows' ) !== false ) { |
| 77 |
$os = ' windows'; |
| 78 |
} |
| 79 |
return $os; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* @since 3.0 |
| 84 |
*/ |
| 85 |
private static function is_white_page() { |
| 86 |
$white_pages = array( |
| 87 |
'formidable', |
| 88 |
'formidable-entries', |
| 89 |
'formidable-views', |
| 90 |
'formidable-pro-upgrade', |
| 91 |
'formidable-addons', |
| 92 |
'formidable-import', |
| 93 |
'formidable-settings', |
| 94 |
'formidable-styles', |
| 95 |
'formidable-styles2', |
| 96 |
'formidable-inbox', |
| 97 |
); |
| 98 |
|
| 99 |
$get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 100 |
$is_white_page = in_array( $get_page, $white_pages ); |
| 101 |
|
| 102 |
if ( ! $is_white_page ) { |
| 103 |
$screen = get_current_screen(); |
| 104 |
$is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false ); |
| 105 |
} |
| 106 |
|
| 107 |
return $is_white_page; |
| 108 |
} |
| 109 |
|
| 110 |
public static function load_wp_admin_style() { |
| 111 |
FrmAppHelper::load_font_style(); |
| 112 |
} |
| 113 |
|
| 114 |
public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 115 |
$show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 116 |
if ( empty( $show_nav ) || ! $form ) { |
| 117 |
return; |
| 118 |
} |
| 119 |
|
| 120 |
FrmForm::maybe_get_form( $form ); |
| 121 |
if ( ! is_object( $form ) ) { |
| 122 |
return; |
| 123 |
} |
| 124 |
|
| 125 |
$id = $form->id; |
| 126 |
$current_page = self::get_current_page(); |
| 127 |
$nav_items = self::get_form_nav_items( $form ); |
| 128 |
|
| 129 |
include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
| 130 |
} |
| 131 |
|
| 132 |
private static function get_current_page() { |
| 133 |
$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 134 |
$post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); |
| 135 |
$current_page = isset( $_GET['page'] ) ? $page : $post_type; |
| 136 |
|
| 137 |
if ( FrmAppHelper::is_view_builder_page() ) { |
| 138 |
$current_page = 'frm_display'; |
| 139 |
} |
| 140 |
|
| 141 |
return $current_page; |
| 142 |
} |
| 143 |
|
| 144 |
private static function get_form_nav_items( $form ) { |
| 145 |
$id = $form->parent_form_id ? $form->parent_form_id : $form->id; |
| 146 |
|
| 147 |
$nav_items = array( |
| 148 |
array( |
| 149 |
'link' => FrmForm::get_edit_link( $id ), |
| 150 |
'label' => __( 'Build', 'formidable' ), |
| 151 |
'current' => array( 'edit', 'new', 'duplicate' ), |
| 152 |
'page' => 'formidable', |
| 153 |
'permission' => 'frm_edit_forms', |
| 154 |
), |
| 155 |
array( |
| 156 |
'link' => admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . absint( $id ) ), |
| 157 |
'label' => __( 'Settings', 'formidable' ), |
| 158 |
'current' => array( 'settings' ), |
| 159 |
'page' => 'formidable', |
| 160 |
'permission' => 'frm_edit_forms', |
| 161 |
), |
| 162 |
array( |
| 163 |
'link' => admin_url( 'admin.php?page=formidable-entries&frm-full=1&frm_action=list&form=' . absint( $id ) ), |
| 164 |
'label' => __( 'Entries', 'formidable' ), |
| 165 |
'current' => array(), |
| 166 |
'page' => 'formidable-entries', |
| 167 |
'permission' => 'frm_view_entries', |
| 168 |
), |
| 169 |
); |
| 170 |
|
| 171 |
// Let people know reports and views exist. |
| 172 |
if ( ! FrmAppHelper::pro_is_installed() ) { |
| 173 |
$nav_items[] = array( |
| 174 |
'link' => admin_url( 'admin.php?page=formidable-views&frm-full=1&form=' . absint( $id ) ), |
| 175 |
'label' => __( 'Views', 'formidable' ), |
| 176 |
'current' => array(), |
| 177 |
'page' => 'formidable-views', |
| 178 |
'permission' => 'frm_view_entries', |
| 179 |
'atts' => array( |
| 180 |
'class' => 'frm_noallow', |
| 181 |
), |
| 182 |
); |
| 183 |
$nav_items[] = array( |
| 184 |
'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&frm-full=1&form=' . absint( $id ) ), |
| 185 |
'label' => __( 'Reports', 'formidable' ), |
| 186 |
'current' => array( 'reports' ), |
| 187 |
'page' => 'formidable', |
| 188 |
'permission' => 'frm_view_entries', |
| 189 |
'atts' => array( |
| 190 |
'class' => 'frm_noallow', |
| 191 |
), |
| 192 |
); |
| 193 |
} |
| 194 |
|
| 195 |
$nav_args = array( |
| 196 |
'form_id' => $id, |
| 197 |
'form' => $form, |
| 198 |
); |
| 199 |
|
| 200 |
return apply_filters( 'frm_form_nav_list', $nav_items, $nav_args ); |
| 201 |
} |
| 202 |
|
| 203 |
// Adds a settings link to the plugins page |
| 204 |
public static function settings_link( $links ) { |
| 205 |
$settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; |
| 206 |
array_unshift( $links, $settings ); |
| 207 |
|
| 208 |
return $links; |
| 209 |
} |
| 210 |
|
| 211 |
public static function pro_get_started_headline() { |
| 212 |
self::review_request(); |
| 213 |
FrmAppHelper::min_pro_version_notice( '4.0' ); |
| 214 |
} |
| 215 |
|
| 216 |
/** |
| 217 |
* Add admin notices as needed for reviews |
| 218 |
* |
| 219 |
* @since 3.04.03 |
| 220 |
*/ |
| 221 |
private static function review_request() { |
| 222 |
$reviews = new FrmReviews(); |
| 223 |
$reviews->review_request(); |
| 224 |
} |
| 225 |
|
| 226 |
/** |
| 227 |
* Save the request to hide the review |
| 228 |
* |
| 229 |
* @since 3.04.03 |
| 230 |
*/ |
| 231 |
public static function dismiss_review() { |
| 232 |
FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 233 |
check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 234 |
|
| 235 |
$reviews = new FrmReviews(); |
| 236 |
$reviews->dismiss_review(); |
| 237 |
} |
| 238 |
|
| 239 |
/** |
| 240 |
* @since 3.04.02 |
| 241 |
*/ |
| 242 |
public static function include_upgrade_overlay() { |
| 243 |
wp_enqueue_script( 'jquery-ui-dialog' ); |
| 244 |
wp_enqueue_style( 'jquery-ui-dialog' ); |
| 245 |
|
| 246 |
add_action( 'admin_footer', 'FrmAppController::upgrade_overlay_html' ); |
| 247 |
} |
| 248 |
|
| 249 |
/** |
| 250 |
* @since 3.06.03 |
| 251 |
*/ |
| 252 |
public static function upgrade_overlay_html() { |
| 253 |
$is_pro = FrmAppHelper::pro_is_installed(); |
| 254 |
$upgrade_link = array( |
| 255 |
'medium' => 'builder', |
| 256 |
'content' => 'upgrade', |
| 257 |
); |
| 258 |
$default_link = FrmAppHelper::admin_upgrade_link( $upgrade_link ); |
| 259 |
|
| 260 |
include( FrmAppHelper::plugin_path() . '/classes/views/shared/upgrade_overlay.php' ); |
| 261 |
|
| 262 |
include( FrmAppHelper::plugin_path() . '/classes/views/shared/confirm-overlay.php' ); |
| 263 |
} |
| 264 |
|
| 265 |
public static function include_info_overlay() { |
| 266 |
wp_enqueue_script( 'jquery-ui-dialog' ); |
| 267 |
wp_enqueue_style( 'jquery-ui-dialog' ); |
| 268 |
|
| 269 |
add_action( 'admin_footer', 'FrmAppController::info_overlay_html' ); |
| 270 |
} |
| 271 |
|
| 272 |
public static function info_overlay_html() { |
| 273 |
include( FrmAppHelper::plugin_path() . '/classes/views/shared/info-overlay.php' ); |
| 274 |
} |
| 275 |
|
| 276 |
/** |
| 277 |
* @since 3.04.02 |
| 278 |
*/ |
| 279 |
public static function remove_upsells() { |
| 280 |
remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
| 281 |
remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' ); |
| 282 |
remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' ); |
| 283 |
remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' ); |
| 284 |
} |
| 285 |
|
| 286 |
/** |
| 287 |
* If there are CURL problems on this server, wp_remote_post won't work for installing |
| 288 |
* Use a javascript fallback instead. |
| 289 |
* |
| 290 |
* @since 2.0.3 |
| 291 |
*/ |
| 292 |
public static function install_js_fallback() { |
| 293 |
FrmAppHelper::load_admin_wide_js(); |
| 294 |
echo '<div id="hidden frm_install_message"></div><script type="text/javascript">jQuery(document).ready(function(){frm_install_now();});</script>'; |
| 295 |
} |
| 296 |
|
| 297 |
/** |
| 298 |
* Check if the database is outdated |
| 299 |
* |
| 300 |
* @since 2.0.1 |
| 301 |
* @return boolean |
| 302 |
*/ |
| 303 |
public static function needs_update() { |
| 304 |
$needs_upgrade = self::compare_for_update( |
| 305 |
array( |
| 306 |
'option' => 'frm_db_version', |
| 307 |
'new_db_version' => FrmAppHelper::$db_version, |
| 308 |
'new_plugin_version' => FrmAppHelper::plugin_version(), |
| 309 |
) |
| 310 |
); |
| 311 |
|
| 312 |
if ( ! $needs_upgrade ) { |
| 313 |
$needs_upgrade = apply_filters( 'frm_db_needs_upgrade', $needs_upgrade ); |
| 314 |
} |
| 315 |
|
| 316 |
return $needs_upgrade; |
| 317 |
} |
| 318 |
|
| 319 |
/** |
| 320 |
* Check both version number and DB number for changes |
| 321 |
* |
| 322 |
* @since 3.0.04 |
| 323 |
*/ |
| 324 |
public static function compare_for_update( $atts ) { |
| 325 |
$db_version = get_option( $atts['option'] ); |
| 326 |
|
| 327 |
if ( strpos( $db_version, '-' ) === false ) { |
| 328 |
$needs_upgrade = true; |
| 329 |
} else { |
| 330 |
$last_upgrade = explode( '-', $db_version ); |
| 331 |
$needs_db_upgrade = (int) $last_upgrade[1] < (int) $atts['new_db_version']; |
| 332 |
$new_version = version_compare( $last_upgrade[0], $atts['new_plugin_version'], '<' ); |
| 333 |
$needs_upgrade = $needs_db_upgrade || $new_version; |
| 334 |
} |
| 335 |
|
| 336 |
return $needs_upgrade; |
| 337 |
} |
| 338 |
|
| 339 |
/** |
| 340 |
* Check for database update and trigger js loading |
| 341 |
* |
| 342 |
* @since 2.0.1 |
| 343 |
*/ |
| 344 |
public static function admin_init() { |
| 345 |
new FrmPersonalData(); // register personal data hooks |
| 346 |
|
| 347 |
if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) { |
| 348 |
self::network_upgrade_site(); |
| 349 |
} |
| 350 |
|
| 351 |
if ( ! FrmAppHelper::doing_ajax() ) { |
| 352 |
// don't continue during ajax calls |
| 353 |
self::admin_js(); |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
public static function admin_js() { |
| 358 |
$version = FrmAppHelper::plugin_version(); |
| 359 |
FrmAppHelper::load_admin_wide_js(); |
| 360 |
|
| 361 |
$dependecies = array( |
| 362 |
'formidable_admin_global', |
| 363 |
'jquery', |
| 364 |
'jquery-ui-core', |
| 365 |
'jquery-ui-draggable', |
| 366 |
'jquery-ui-sortable', |
| 367 |
'bootstrap_tooltip', |
| 368 |
'bootstrap-multiselect', |
| 369 |
); |
| 370 |
|
| 371 |
if ( FrmAppHelper::is_admin_page( 'formidable-styles' ) || FrmAppHelper::is_admin_page( 'formidable-styles2' ) ) { |
| 372 |
$dependecies[] = 'wp-color-picker'; |
| 373 |
} |
| 374 |
|
| 375 |
wp_register_script( 'formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', $dependecies, $version, true ); |
| 376 |
wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 377 |
wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
| 378 |
wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version ); |
| 379 |
|
| 380 |
// load multselect js |
| 381 |
$depends_on = array( 'jquery', 'bootstrap_tooltip' ); |
| 382 |
wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', $depends_on, '0.9.8', true ); |
| 383 |
|
| 384 |
$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 385 |
$post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 386 |
|
| 387 |
global $pagenow; |
| 388 |
if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 389 |
|
| 390 |
wp_enqueue_script( 'admin-widgets' ); |
| 391 |
wp_enqueue_style( 'widgets' ); |
| 392 |
wp_enqueue_script( 'formidable_admin' ); |
| 393 |
FrmAppHelper::localize_script( 'admin' ); |
| 394 |
|
| 395 |
wp_enqueue_style( 'formidable-admin' ); |
| 396 |
if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) { |
| 397 |
wp_enqueue_style( 'formidable-grids' ); |
| 398 |
wp_enqueue_style( 'formidable-dropzone' ); |
| 399 |
} else { |
| 400 |
$settings = FrmAppHelper::get_settings(); |
| 401 |
if ( empty( $settings->old_css ) ) { |
| 402 |
wp_enqueue_style( 'formidable-grids' ); |
| 403 |
} |
| 404 |
} |
| 405 |
|
| 406 |
if ( 'formidable-entries' === $page ) { |
| 407 |
// Load front end js for entries. |
| 408 |
wp_enqueue_script( 'formidable' ); |
| 409 |
} |
| 410 |
|
| 411 |
do_action( 'frm_enqueue_builder_scripts' ); |
| 412 |
self::include_upgrade_overlay(); |
| 413 |
self::include_info_overlay(); |
| 414 |
} elseif ( FrmAppHelper::is_view_builder_page() ) { |
| 415 |
if ( isset( $_REQUEST['post_type'] ) ) { |
| 416 |
$post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) ); |
| 417 |
} elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 418 |
$post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) ); |
| 419 |
if ( ! $post ) { |
| 420 |
return; |
| 421 |
} |
| 422 |
$post_type = $post->post_type; |
| 423 |
} else { |
| 424 |
return; |
| 425 |
} |
| 426 |
|
| 427 |
if ( $post_type == 'frm_display' ) { |
| 428 |
wp_enqueue_style( 'formidable-grids' ); |
| 429 |
wp_enqueue_script( 'jquery-ui-draggable' ); |
| 430 |
wp_enqueue_script( 'formidable_admin' ); |
| 431 |
wp_enqueue_style( 'formidable-admin' ); |
| 432 |
FrmAppHelper::localize_script( 'admin' ); |
| 433 |
self::include_info_overlay(); |
| 434 |
} |
| 435 |
} |
| 436 |
} |
| 437 |
|
| 438 |
public static function load_lang() { |
| 439 |
load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
| 440 |
} |
| 441 |
|
| 442 |
/** |
| 443 |
* Check if the styles are updated when a form is loaded on the front-end |
| 444 |
* |
| 445 |
* @since 3.0.1 |
| 446 |
*/ |
| 447 |
public static function maybe_update_styles() { |
| 448 |
if ( self::needs_update() ) { |
| 449 |
self::network_upgrade_site(); |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
/** |
| 454 |
* @since 3.0 |
| 455 |
*/ |
| 456 |
public static function create_rest_routes() { |
| 457 |
$args = array( |
| 458 |
'methods' => 'GET', |
| 459 |
'callback' => 'FrmAppController::api_install', |
| 460 |
'permission_callback' => __CLASS__ . '::can_update_db', |
| 461 |
); |
| 462 |
|
| 463 |
register_rest_route( 'frm-admin/v1', '/install', $args ); |
| 464 |
} |
| 465 |
|
| 466 |
/** |
| 467 |
* Make sure the install is only being run when we tell it to. |
| 468 |
* We don't want to run manually by people calling the API. |
| 469 |
* |
| 470 |
* @since 4.06.02 |
| 471 |
*/ |
| 472 |
public static function can_update_db() { |
| 473 |
return get_transient( 'frm_updating_api' ); |
| 474 |
} |
| 475 |
|
| 476 |
/** |
| 477 |
* Run silent upgrade on each site in the network during a network upgrade. |
| 478 |
* Update database settings for all sites in a network during network upgrade process. |
| 479 |
* |
| 480 |
* @since 2.0.1 |
| 481 |
* |
| 482 |
* @param int $blog_id Blog ID. |
| 483 |
*/ |
| 484 |
public static function network_upgrade_site( $blog_id = 0 ) { |
| 485 |
// Flag to check if install is happening as intended. |
| 486 |
set_transient( 'frm_updating_api', true, MINUTE_IN_SECONDS ); |
| 487 |
$request = new WP_REST_Request( 'GET', '/frm-admin/v1/install' ); |
| 488 |
|
| 489 |
if ( $blog_id ) { |
| 490 |
switch_to_blog( $blog_id ); |
| 491 |
$response = rest_do_request( $request ); |
| 492 |
restore_current_blog(); |
| 493 |
} else { |
| 494 |
$response = rest_do_request( $request ); |
| 495 |
} |
| 496 |
|
| 497 |
if ( $response->is_error() ) { |
| 498 |
// if the remove post fails, use javascript instead |
| 499 |
add_action( 'admin_notices', 'FrmAppController::install_js_fallback' ); |
| 500 |
} |
| 501 |
} |
| 502 |
|
| 503 |
/** |
| 504 |
* @since 3.0 |
| 505 |
*/ |
| 506 |
public static function api_install() { |
| 507 |
delete_transient( 'frm_updating_api' ); |
| 508 |
if ( self::needs_update() ) { |
| 509 |
$running = get_option( 'frm_install_running' ); |
| 510 |
if ( false === $running || $running < strtotime( '-5 minutes' ) ) { |
| 511 |
update_option( 'frm_install_running', time(), 'no' ); |
| 512 |
self::install(); |
| 513 |
delete_option( 'frm_install_running' ); |
| 514 |
} |
| 515 |
} |
| 516 |
|
| 517 |
return true; |
| 518 |
} |
| 519 |
|
| 520 |
/** |
| 521 |
* Silent database upgrade (no redirect). |
| 522 |
* Called via ajax request during network upgrade process. |
| 523 |
* |
| 524 |
* @since 2.0.1 |
| 525 |
*/ |
| 526 |
public static function ajax_install() { |
| 527 |
self::api_install(); |
| 528 |
wp_die(); |
| 529 |
} |
| 530 |
|
| 531 |
public static function install() { |
| 532 |
$frmdb = new FrmMigrate(); |
| 533 |
$frmdb->upgrade(); |
| 534 |
} |
| 535 |
|
| 536 |
public static function uninstall() { |
| 537 |
FrmAppHelper::permission_check( 'administrator' ); |
| 538 |
check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 539 |
|
| 540 |
$frmdb = new FrmMigrate(); |
| 541 |
$frmdb->uninstall(); |
| 542 |
|
| 543 |
//disable the plugin and redirect after uninstall so the tables don't get added right back |
| 544 |
$plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' ); |
| 545 |
deactivate_plugins( $plugins, false, false ); |
| 546 |
echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 547 |
|
| 548 |
wp_die(); |
| 549 |
} |
| 550 |
|
| 551 |
public static function drop_tables( $tables ) { |
| 552 |
global $wpdb; |
| 553 |
$tables[] = $wpdb->prefix . 'frm_fields'; |
| 554 |
$tables[] = $wpdb->prefix . 'frm_forms'; |
| 555 |
$tables[] = $wpdb->prefix . 'frm_items'; |
| 556 |
$tables[] = $wpdb->prefix . 'frm_item_metas'; |
| 557 |
|
| 558 |
return $tables; |
| 559 |
} |
| 560 |
|
| 561 |
public static function deauthorize() { |
| 562 |
FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 563 |
check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 564 |
|
| 565 |
delete_option( 'frmpro-credentials' ); |
| 566 |
delete_option( 'frmpro-authorized' ); |
| 567 |
delete_site_option( 'frmpro-credentials' ); |
| 568 |
delete_site_option( 'frmpro-authorized' ); |
| 569 |
wp_die(); |
| 570 |
} |
| 571 |
|
| 572 |
public static function set_footer_text( $text ) { |
| 573 |
if ( FrmAppHelper::is_formidable_admin() ) { |
| 574 |
$text = ''; |
| 575 |
} |
| 576 |
|
| 577 |
return $text; |
| 578 |
} |
| 579 |
|
| 580 |
/** |
| 581 |
* @deprecated 1.07.05 |
| 582 |
* @codeCoverageIgnore |
| 583 |
*/ |
| 584 |
public static function get_form_shortcode( $atts ) { |
| 585 |
return FrmDeprecated::get_form_shortcode( $atts ); |
| 586 |
} |
| 587 |
|
| 588 |
/** |
| 589 |
* @deprecated 2.5.4 |
| 590 |
* @codeCoverageIgnore |
| 591 |
*/ |
| 592 |
public static function widget_text_filter( $content ) { |
| 593 |
return FrmDeprecated::widget_text_filter( $content ); |
| 594 |
} |
| 595 |
|
| 596 |
/** |
| 597 |
* Deprecated in favor of wpmu_upgrade_site |
| 598 |
* |
| 599 |
* @deprecated 2.3 |
| 600 |
* @codeCoverageIgnore |
| 601 |
*/ |
| 602 |
public static function front_head() { |
| 603 |
FrmDeprecated::front_head(); |
| 604 |
} |
| 605 |
|
| 606 |
/** |
| 607 |
* @deprecated 3.0.04 |
| 608 |
* @codeCoverageIgnore |
| 609 |
*/ |
| 610 |
public static function activation_install() { |
| 611 |
FrmDeprecated::activation_install(); |
| 612 |
} |
| 613 |
|
| 614 |
/** |
| 615 |
* @deprecated 3.0 |
| 616 |
* @codeCoverageIgnore |
| 617 |
*/ |
| 618 |
public static function page_route( $content ) { |
| 619 |
return FrmDeprecated::page_route( $content ); |
| 620 |
} |
| 621 |
} |
| 622 |
|