| @@ -190,8 +190,15 @@ | ||
| 190 | 190 | 'wp_ajax_reset', |
| 191 | 191 | ) |
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | + /** | |
| 195 | + * Uninstall Streams and Deactivate plugin. | |
| 196 | + * | |
| 197 | + * @todo Confirm if variable assignment is necessary. | |
| 198 | + */ | |
| 199 | + $uninstall = $this->plugin->db->driver->purge_storage( $this->plugin ); | |
| 200 | + | |
| 194 | 201 | // Auto purge setup. |
| 195 | 202 | add_action( 'wp_loaded', array( $this, 'purge_schedule_setup' ) ); |
| 196 | 203 | add_action( |
| 197 | 204 | 'wp_stream_auto_purge', |
| @@ -464,8 +471,9 @@ | ||
| 464 | 471 | array( |
| 465 | 472 | 'i18n' => array( |
| 466 | 473 | 'confirm_purge' => esc_html__( 'Are you sure you want to delete all Stream activity records from the database? This cannot be undone.', 'stream' ), |
| 467 | 474 | 'confirm_defaults' => esc_html__( 'Are you sure you want to reset all site settings to default? This cannot be undone.', 'stream' ), |
| 475 | + 'confirm_uninstall' => esc_html__( 'Are you sure you want to uninstall and deactivate Stream? This will delete all Stream tables from the database and cannot be undone.', 'stream' ), | |
| 468 | 476 | ), |
| 469 | 477 | 'locale' => esc_js( $locale ), |
| 470 | 478 | 'gmt_offset' => get_option( 'gmt_offset' ), |
| 471 | 479 | ) |
| @@ -531,19 +539,14 @@ | ||
| 531 | 539 | * |
| 532 | 540 | * @return bool |
| 533 | 541 | */ |
| 534 | 542 | public function is_stream_screen() { |
| 535 | - if ( ! is_admin() ) { | |
| 536 | - return false; | |
| 537 | - } | |
| 538 | - | |
| 539 | - $page = wp_stream_filter_input( INPUT_GET, 'page' ); | |
| 540 | - if ( is_string( $page ) && false !== strpos( $page, $this->records_page_slug ) ) { | |
| 543 | + if ( is_admin() && false !== strpos( wp_stream_filter_input( INPUT_GET, 'page' ), $this->records_page_slug ) ) { | |
| 541 | 544 | return true; |
| 542 | 545 | } |
| 543 | 546 | |
| 544 | 547 | $screen = get_current_screen(); |
| 545 | - if ( Alerts::POST_TYPE === $screen->post_type ) { | |
| 548 | + if ( is_admin() && Alerts::POST_TYPE === $screen->post_type ) { | |
| 546 | 549 | return true; |
| 547 | 550 | } |
| 548 | 551 | |
| 549 | 552 | return false; |
| @@ -813,8 +816,20 @@ | ||
| 813 | 816 | } |
| 814 | 817 | |
| 815 | 818 | $links[] = sprintf( '<a href="%s">%s</a>', esc_url( $admin_page_url ), esc_html__( 'Settings', 'default' ) ); |
| 816 | 819 | |
| 820 | + if ( ! defined( 'DISALLOW_FILE_MODS' ) || false === DISALLOW_FILE_MODS ) { | |
| 821 | + $url = add_query_arg( | |
| 822 | + array( | |
| 823 | + 'action' => 'wp_stream_uninstall', | |
| 824 | + 'wp_stream_nonce' => wp_create_nonce( 'stream_nonce' ), | |
| 825 | + ), | |
| 826 | + admin_url( 'admin-ajax.php' ) | |
| 827 | + ); | |
| 828 | + | |
| 829 | + $links[] = sprintf( '<span id="wp_stream_uninstall" class="delete"><a href="%s">%s</a></span>', esc_url( $url ), esc_html__( 'Uninstall', 'stream' ) ); | |
| 830 | + } | |
| 831 | + | |
| 817 | 832 | return $links; |
| 818 | 833 | } |
| 819 | 834 | |
| 820 | 835 | /** |
| @@ -1070,8 +1085,12 @@ | ||
| 1070 | 1085 | * |
| 1071 | 1086 | * @return mixed |
| 1072 | 1087 | */ |
| 1073 | 1088 | public function get_user_meta( $user_id, $meta_key, $single = true ) { |
| 1089 | + if ( wp_stream_is_vip() && function_exists( 'get_user_attribute' ) ) { | |
| 1090 | + return get_user_attribute( $user_id, $meta_key ); | |
| 1091 | + } | |
| 1092 | + | |
| 1074 | 1093 | return get_user_meta( $user_id, $meta_key, $single ); |
| 1075 | 1094 | } |
| 1076 | 1095 | |
| 1077 | 1096 | /** |
| @@ -1084,8 +1103,12 @@ | ||
| 1084 | 1103 | * |
| 1085 | 1104 | * @return int|bool |
| 1086 | 1105 | */ |
| 1087 | 1106 | public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) { |
| 1107 | + if ( wp_stream_is_vip() && function_exists( 'update_user_attribute' ) ) { | |
| 1108 | + return update_user_attribute( $user_id, $meta_key, $meta_value ); | |
| 1109 | + } | |
| 1110 | + | |
| 1088 | 1111 | return update_user_meta( $user_id, $meta_key, $meta_value, $prev_value ); |
| 1089 | 1112 | } |
| 1090 | 1113 | |
| 1091 | 1114 | /** |
| @@ -1097,7 +1120,11 @@ | ||
| 1097 | 1120 | * |
| 1098 | 1121 | * @return bool |
| 1099 | 1122 | */ |
| 1100 | 1123 | public function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) { |
| 1124 | + if ( wp_stream_is_vip() && function_exists( 'delete_user_attribute' ) ) { | |
| 1125 | + return delete_user_attribute( $user_id, $meta_key, $meta_value ); | |
| 1126 | + } | |
| 1127 | + | |
| 1101 | 1128 | return delete_user_meta( $user_id, $meta_key, $meta_value ); |
| 1102 | 1129 | } |
| 1103 | 1130 | } |