| @@ -2,13 +2,24 @@ | ||
| 2 | 2 | /* |
| 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 | -Text Domain: contact-form-WPFormsDB | |
| 7 | -Domain Path: /languages/ | |
| 8 | -Version: 1.0.4 | |
| 6 | +Text Domain: database-for-wpforms | |
| 7 | +Version: 1.1.0 | |
| 8 | +License: GPL v2 or later | |
| 9 | +License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
| 9 | 10 | */ |
| 10 | 11 | |
| 12 | +if ( ! defined( 'ABSPATH' ) ) exit; | |
| 13 | + | |
| 14 | +function wpforms_db_plugin_load(){ | |
| 15 | + | |
| 16 | + load_plugin_textdomain( 'database-for-wpforms', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' ); | |
| 17 | +} | |
| 18 | + | |
| 19 | +add_action('plugins_loaded', 'wpforms_db_plugin_load'); | |
| 20 | + | |
| 21 | + | |
| 11 | 22 | add_action('init', 'wpforms_db_init'); |
| 12 | 23 | |
| 13 | 24 | function wpforms_db_init(){ |
| 14 | 25 | if( is_admin() ){ |
| @@ -18,12 +29,13 @@ | ||
| 18 | 29 | require_once 'inc/class-export-csv.php'; |
| 19 | 30 | |
| 20 | 31 | if( isset($_REQUEST['wpforms-csv']) && ( $_REQUEST['wpforms-csv'] == true ) && isset( $_REQUEST['nonce'] ) ) { |
| 21 | 32 | |
| 22 | - $nonce = filter_input( INPUT_GET, 'nonce', FILTER_SANITIZE_STRING ); | |
| 33 | + $nonce = sanitize_text_field( $_REQUEST['nonce'] ); | |
| 23 | 34 | |
| 24 | - if ( ! wp_verify_nonce( $nonce, 'dnonce' ) ) wp_die('Invalid nonce..!!'); | |
| 25 | - $csv = new WPForms_Export_CSV(); | |
| 35 | + if ( ! wp_verify_nonce( $nonce, 'dnonce' ) ) | |
| 36 | + wp_die( esc_html__( 'Invalid nonce..!!', 'database-for-wpforms' ) ); | |
| 37 | + $csv = new WPFormsDB_Export_CSV(); | |
| 26 | 38 | $csv->download_csv_file(); |
| 27 | 39 | } |
| 28 | 40 | new WPFormsDB_Wp_Main_Page; |
| 29 | 41 | } |
| @@ -51,9 +63,9 @@ | ||
| 51 | 63 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 52 | 64 | dbDelta( $sql ); |
| 53 | 65 | } |
| 54 | 66 | |
| 55 | - add_option( 'WPFormsDB_view_install_date', date('Y-m-d G:i:s'), '', 'yes'); | |
| 67 | + add_option( 'WPFormsDB_view_install_date', gmdate('Y-m-d G:i:s'), '', 'yes'); | |
| 56 | 68 | |
| 57 | 69 | } |
| 58 | 70 | |
| 59 | 71 | function WPFormsDB_on_activate( $network_wide ){ |
| @@ -59,9 +71,8 @@ | ||
| 59 | 71 | function WPFormsDB_on_activate( $network_wide ){ |
| 60 | 72 | |
| 61 | 73 | global $wpdb; |
| 62 | 74 | if ( is_multisite() && $network_wide ) { |
| 63 | - // Get all blogs in the network and activate plugin on each one | |
| 64 | 75 | $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
| 65 | 76 | foreach ( $blog_ids as $blog_id ) { |
| 66 | 77 | switch_to_blog( $blog_id ); |
| 67 | 78 | WPFormsDB_create_table(); |
| @@ -70,9 +81,8 @@ | ||
| 70 | 81 | } else { |
| 71 | 82 | WPFormsDB_create_table(); |
| 72 | 83 | } |
| 73 | 84 | |
| 74 | - // Add custom capability | |
| 75 | 85 | $role = get_role( 'administrator' ); |
| 76 | 86 | $role->add_cap( 'WPFormsDB_access' ); |
| 77 | 87 | } |
| 78 | 88 | |
| @@ -80,9 +90,8 @@ | ||
| 80 | 90 | |
| 81 | 91 | |
| 82 | 92 | function WPFormsDB_on_deactivate() { |
| 83 | 93 | |
| 84 | - // Remove custom capability from all roles | |
| 85 | 94 | global $wp_roles; |
| 86 | 95 | |
| 87 | 96 | foreach( array_keys( $wp_roles->roles ) as $role ) { |
| 88 | 97 | $wp_roles->remove_cap( $role, 'WPFormsDB_access' ); |
| @@ -119,9 +128,8 @@ | ||
| 119 | 128 | $form_data[ $d['name'] ] = $d['value']; |
| 120 | 129 | |
| 121 | 130 | } |
| 122 | 131 | |
| 123 | - /* WPFormsDB before save data. */ | |
| 124 | 132 | $form_data = apply_filters('WPFormsDB_before_save_data', $form_data); |
| 125 | 133 | |
| 126 | 134 | do_action( 'WPFormsDB_before_save_data', $form_data ); |
| 127 | 135 | |
| @@ -134,11 +142,10 @@ | ||
| 134 | 142 | 'form_value' => $form_value, |
| 135 | 143 | 'form_date' => $form_date |
| 136 | 144 | ) ); |
| 137 | 145 | |
| 138 | - /* WPFormsDB after save data */ | |
| 139 | 146 | $insert_id = $wpform->insert_id; |
| 140 | - do_action( 'WPFormsDB_after_save_data', $insert_id ); | |
| 147 | + do_action( 'WPFormsDB_after_save_data', $insert_id, $form_data ); | |
| 141 | 148 | } |
| 142 | 149 | |
| 143 | 150 | } |
| 144 | 151 | |
| @@ -164,24 +171,41 @@ | ||
| 164 | 171 | function wpformsdb_admin_notice() { |
| 165 | 172 | |
| 166 | 173 | $install_date = get_option( 'WPFormsDB_view_install_date', ''); |
| 167 | 174 | $install_date = date_create( $install_date ); |
| 168 | - $date_now = date_create( date('Y-m-d G:i:s') ); | |
| 175 | + $date_now = date_create( gmdate('Y-m-d G:i:s') ); | |
| 169 | 176 | $date_diff = date_diff( $install_date, $date_now ); |
| 170 | 177 | |
| 171 | - if ( $date_diff->format("%d") < 7 ) { | |
| 178 | + if ( $date_diff->days < 7 ) { | |
| 172 | 179 | |
| 173 | 180 | return false; |
| 174 | 181 | } |
| 175 | 182 | |
| 176 | - if ( ! get_option( 'wpformsdb_view_ignore_notice' ) ) { | |
| 183 | + if( empty($_GET['page']) ){ | |
| 184 | + return; | |
| 185 | + } | |
| 177 | 186 | |
| 178 | - echo '<div class="updated"><p>'; | |
| 187 | + if( isset($_GET['page']) && $_GET['page'] !== 'wp-forms-db-list.php' ){ | |
| 188 | + return; | |
| 189 | + } | |
| 179 | 190 | |
| 180 | - printf(__( '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>', 'wpformsdb' ), '?page=wp-forms-db-list.php&wpformsdb-ignore-notice=0', | |
| 181 | - 'https://wordpress.org/plugins/database-for-wpforms/'); | |
| 182 | - echo "</p></div>"; | |
| 191 | + if ( 'true' === get_option( 'wpformsdb_view_ignore_notice' ) ) { | |
| 192 | + return; | |
| 183 | 193 | } |
| 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 | + | |
| 184 | 208 | } |
| 185 | 209 | |
| 186 | 210 | function wpformsdb_view_ignore_notice() { |
| 187 | 211 | |