| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | Plugin Name:Database for WPforms |
| 4 | 4 | Description: Save and manage WPForms submissions. Never lose important data. Database add-on for WPForms. |
| 5 | 5 | Author: wpdebuglog |
| 6 | 6 | Text Domain: database-for-wpforms |
| 7 | -Version: 1.1.0 | |
| 7 | +Version: 1.0.7 | |
| 8 | 8 | License: GPL v2 or later |
| 9 | 9 | License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 10 | 10 | */ |
| 11 | 11 | |
| @@ -71,8 +71,9 @@ | ||
| 71 | 71 | function WPFormsDB_on_activate( $network_wide ){ |
| 72 | 72 | |
| 73 | 73 | global $wpdb; |
| 74 | 74 | if ( is_multisite() && $network_wide ) { |
| 75 | + // Get all blogs in the network and activate plugin on each one | |
| 75 | 76 | $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
| 76 | 77 | foreach ( $blog_ids as $blog_id ) { |
| 77 | 78 | switch_to_blog( $blog_id ); |
| 78 | 79 | WPFormsDB_create_table(); |
| @@ -81,8 +82,9 @@ | ||
| 81 | 82 | } else { |
| 82 | 83 | WPFormsDB_create_table(); |
| 83 | 84 | } |
| 84 | 85 | |
| 86 | + // Add custom capability | |
| 85 | 87 | $role = get_role( 'administrator' ); |
| 86 | 88 | $role->add_cap( 'WPFormsDB_access' ); |
| 87 | 89 | } |
| 88 | 90 | |
| @@ -90,8 +92,9 @@ | ||
| 90 | 92 | |
| 91 | 93 | |
| 92 | 94 | function WPFormsDB_on_deactivate() { |
| 93 | 95 | |
| 96 | + // Remove custom capability from all roles | |
| 94 | 97 | global $wp_roles; |
| 95 | 98 | |
| 96 | 99 | foreach( array_keys( $wp_roles->roles ) as $role ) { |
| 97 | 100 | $wp_roles->remove_cap( $role, 'WPFormsDB_access' ); |
| @@ -128,8 +131,9 @@ | ||
| 128 | 131 | $form_data[ $d['name'] ] = $d['value']; |
| 129 | 132 | |
| 130 | 133 | } |
| 131 | 134 | |
| 135 | + /* WPFormsDB before save data. */ | |
| 132 | 136 | $form_data = apply_filters('WPFormsDB_before_save_data', $form_data); |
| 133 | 137 | |
| 134 | 138 | do_action( 'WPFormsDB_before_save_data', $form_data ); |
| 135 | 139 | |
| @@ -142,10 +146,11 @@ | ||
| 142 | 146 | 'form_value' => $form_value, |
| 143 | 147 | 'form_date' => $form_date |
| 144 | 148 | ) ); |
| 145 | 149 | |
| 150 | + /* WPFormsDB after save data */ | |
| 146 | 151 | $insert_id = $wpform->insert_id; |
| 147 | - do_action( 'WPFormsDB_after_save_data', $insert_id, $form_data ); | |
| 152 | + do_action( 'WPFormsDB_after_save_data', $insert_id ); | |
| 148 | 153 | } |
| 149 | 154 | |
| 150 | 155 | } |
| 151 | 156 | |
| @@ -174,38 +179,26 @@ | ||
| 174 | 179 | $install_date = date_create( $install_date ); |
| 175 | 180 | $date_now = date_create( gmdate('Y-m-d G:i:s') ); |
| 176 | 181 | $date_diff = date_diff( $install_date, $date_now ); |
| 177 | 182 | |
| 178 | - if ( $date_diff->days < 7 ) { | |
| 183 | + if ( $date_diff->format("%d") < 7 ) { | |
| 179 | 184 | |
| 180 | 185 | return false; |
| 181 | 186 | } |
| 182 | 187 | |
| 183 | - if( empty($_GET['page']) ){ | |
| 184 | - return; | |
| 185 | - } | |
| 188 | + if ( ! get_option( 'wpformsdb_view_ignore_notice' ) ) { | |
| 186 | 189 | |
| 187 | - if( isset($_GET['page']) && $_GET['page'] !== 'wp-forms-db-list.php' ){ | |
| 188 | - return; | |
| 189 | - } | |
| 190 | + echo '<div class="updated"><p>'; | |
| 190 | 191 | |
| 191 | - if ( 'true' === get_option( 'wpformsdb_view_ignore_notice' ) ) { | |
| 192 | - return; | |
| 192 | + printf( | |
| 193 | + /* translators: 1: Settings URL, 2: Repository url */ | |
| 194 | + __( | |
| 195 | + 'Awesome, you\'ve been using <a href="admin.php?page=wp-forms-db-list.php">WPForms DB</a> for more than 1 week. May we ask you to give it a 5-star rating on WordPress? | <a href="%2$s" target="_blank">Ok, you deserved it</a> | <a href="%1$s">I already did</a> | <a href="%1$s">No, not good enough</a>', 'database-for-wpforms' ), | |
| 196 | + '?page=wp-forms-db-list.php&wpformsdb-ignore-notice=0', | |
| 197 | + 'https://wordpress.org/plugins/database-for-wpforms/' | |
| 198 | + ); | |
| 199 | + echo "</p></div>"; | |
| 193 | 200 | } |
| 194 | - | |
| 195 | - echo '<div class="updated"><p>'; | |
| 196 | - | |
| 197 | - printf( | |
| 198 | - /* translators: 1: Settings URL, 2: Repository url */ | |
| 199 | - __( | |
| 200 | - 'Awesome, you\'ve been using <a href="%s" target="_blank">WPForms DB</a> for more than 1 week. May we ask you to give it a 5-star rating on WordPress? | <a href="%s" target="_blank">Ok, you deserved it</a> | <a href="%s">I already did</a> | <a href="%s">No, not good enough</a>', 'database-for-wpforms' ), | |
| 201 | - 'https://wordpress.org/plugins/database-for-wpforms/', | |
| 202 | - 'https://wordpress.org/support/plugin/database-for-wpforms/reviews/', | |
| 203 | - '?page=wp-forms-db-list.php&wpformsdb-ignore-notice=0', | |
| 204 | - '?page=wp-forms-db-list.php&wpformsdb-ignore-notice=0', | |
| 205 | - ); | |
| 206 | - echo "</p></div>"; | |
| 207 | - | |
| 208 | 201 | } |
| 209 | 202 | |
| 210 | 203 | function wpformsdb_view_ignore_notice() { |
| 211 | 204 | |