'opsd_version_num' , 'option-is_delete_if_deactive' => 'opsd_is_delete_if_deactive' , 'option-activation_process' => 'opsd_activation_process' , 'transient-opsd_activation_redirect' => '_opsd_activation_redirect' , 'message-delete_data' => '' . __('Warning!', 'secure-downloads') . ' ' . __('All plugin data will be deleted when the plugin is deactivated.', 'secure-downloads') . '
' . sprintf( __('If you want to save your plugin data, please uncheck the %s"Delete data"%s at the' , 'secure-downloads') , '', '') . ' ' . __('settings page', 'secure-downloads') . '.' . ' ' , 'link_settings' => ''.__("Settings", 'secure-downloads').'' , 'link_whats_new' => '' ); } /** Check if was updated from lower to high version */ public function is_update_from_lower_to_high_version() { $is_make_activation = false; // Check conditions for different version about Upgrade if ( ( class_exists( 'opsd_personal' ) ) && ( ! opsd_is_table_exists( 'itemtypes' ) ) ) $is_make_activation = true; return $is_make_activation; } } //////////////////////////////////////////////////////////////////////////////// // A c t i v a t e & D e a c t i v a t e //////////////////////////////////////////////////////////////////////////////// /** Activation */ function opsd_activate() { // Check for blank data install $opsd_secret_key = get_opsd_option( 'opsd_secret_key' ); if ( empty( $opsd_secret_key ) ) $is_first_time_install = true; else $is_first_time_install = false; make_opsd_action( 'opsd_before_activation' ); opsd_load_translation(); $version = get_opsd_version(); $is_demo = opsd_is_this_demo(); //////////////////////////////////////////////////////////////////////////// // Options //////////////////////////////////////////////////////////////////////////// $default_options_to_add = opsd_get_default_options(); foreach ( $default_options_to_add as $default_option_name => $default_option_value ) { add_opsd_option( $default_option_name, $default_option_value ); } // Check for blank data install if ( $is_first_time_install ) opsd_create_blank_files(); //////////////////////////////////////////////////////////////////////////// // DB Tables //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // Other versions Activation //////////////////////////////////////////////////////////////////////////// make_opsd_action( 'opsd_other_versions_activation' ); make_opsd_action( 'opsd_after_activation' ); } add_opsd_action( 'opsd_activation', 'opsd_activate' ); // Deactivate function opsd_deactivate() { //////////////////////////////////////////////////////////////////////////// // Options //////////////////////////////////////////////////////////////////////////// $default_options_to_add = opsd_get_default_options(); foreach ( $default_options_to_add as $default_option_name => $default_option_value) { delete_opsd_option( $default_option_name ); } //////////////////////////////////////////////////////////////////////////// // Widgets //////////////////////////////////////////////////////////////////////////// delete_opsd_option( 'opsd_activation_redirect_for_version' ); //////////////////////////////////////////////////////////////////////////// // DB Tables //////////////////////////////////////////////////////////////////////////// global $wpdb; // $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}opsd" ); // Delete all users item windows states if ( false === $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%opsd_%'" ) ){ // All users data debuge_error('Error during deleting user meta at DB',__FILE__,__LINE__); die(); } //////////////////////////////////////////////////////////////////////////// // Other versions Deactivation //////////////////////////////////////////////////////////////////////////// make_opsd_action('opsd_other_versions_deactivation'); } add_opsd_action( 'opsd_deactivation', 'opsd_deactivate' ); /** Default Options * * $option_name = ''; * $options_for_delete = opsd_get_default_options( $option_name, $is_get_multiuser_general_options ); */ function opsd_get_default_options( $option_name = '' ) { $is_demo = opsd_is_this_demo(); $default_options = array(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // General Settings //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $default_options[ 'opsd_download_url_path' ] = ''; $default_options[ 'opsd_protected_directory_name_level1' ] = 'opsd_' . wp_generate_password( 20, false, false ); $default_options[ 'opsd_secret_key' ] = wp_generate_password( 30, false, false ); $default_options[ 'opsd_defualt_expiration' ] = '+24 hours'; $default_options[ 'opsd_defualt_iplock' ] = ''; // URLs $default_options[ 'opsd_url_wrong_hash' ] = ''; $default_options[ 'opsd_url_download_expired' ] = ''; $default_options[ 'opsd_url_ip_not_valied' ] = ''; $default_options[ 'opsd_url_file_not_exist' ] = ''; $default_options[ 'opsd_url_error_opening_file' ] = ''; // Miscellaneous $default_options[ 'opsd_csv_separator' ] = ','; $default_options[ 'opsd_date_format' ] = get_option( 'date_format' ); $default_options[ 'opsd_time_format' ] = get_option( 'time_format' ); // Advanced $default_options[ 'opsd_is_not_load_bs_script_in_admin' ] = 'Off'; /** $default_options[ 'opsd_is_not_load_bs_script_in_client' ] = 'Off'; $default_options[ 'opsd_is_load_js_css_on_specific_pages' ] = 'Off'; $default_options[ 'opsd_pages_for_load_js_css' ] = ''; */ // User permissions $default_options[ 'opsd_user_role_master' ] = ( $is_demo ) ? 'subscriber' : 'editor'; $default_options[ 'opsd_user_role_addnew' ] = ( $is_demo ) ? 'subscriber' : 'editor'; $default_options[ 'opsd_user_role_settings' ] = ( $is_demo ) ? 'subscriber' : 'editor'; // Position $default_options[ 'opsd_menu_position' ] = ( $is_demo ) ? 'top' : 'top'; // Uninstall $default_options[ 'opsd_is_delete_if_deactive' ] = ($is_demo) ? 'On' : 'Off'; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Emails //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $user_info = array( 'name' => '' ); if ( is_user_logged_in() ) { $user_data = get_userdata( get_current_user_id() ); $user_info['name'] = ( $user_data ) ? $user_data->display_name : ''; } $email_settings = array(); $email_settings['enabled'] = 'On'; $email_settings['copy_to_admin'] = 'On'; $email_settings['from'] = get_option( 'admin_email' ); $email_settings['from_name'] = $user_info['name']; $email_settings['subject'] = sprintf( __( 'Delivery of %s', 'secure-downloads'), '[product_title] [product_version]' ); $email_settings['content'] = sprintf( __( 'Hello. %sThank you for requesting %s To download %s click the link below: %s Thank you, %s', 'secure-downloads' ) , '
' , '[product_title] [product_version]

' , '[product_description]' , '
---
[product_summary] - [product_expire_date]
---

' , '[siteurl]
[current_date] [current_time]' ); $email_settings['header_content'] = ''; $email_settings['footer_content'] = ''; $email_settings['template_file'] = 'plain'; $email_settings['base_color'] = '#557da1'; $email_settings['background_color'] = '#f5f5f5'; $email_settings['body_color'] = '#fdfdfd'; $email_settings['text_color'] = '#505050'; $email_settings['email_content_type'] = 'html'; $default_options[ 'opsd_email_link_user' ] = $email_settings; // Just modify some params in previos email $email_settings[ 'to' ] = $email_settings['from']; $email_settings[ 'to_name' ] = $email_settings['from_name']; $email_settings['subject'] = sprintf( __( 'Download notification of %s', 'secure-downloads'), '[product_title] [ [product_id] ]' ); $email_settings['content'] = sprintf( __( 'Hi. %s The %s have been downloaded. %s ===== User Info ===== %s To: %s IP: %s User agent: %s Request url: %s ====================== %s ===== Product Summary ===== %s Expire at %s ====================== %s', 'secure-downloads' ) , '

' , '[product_title] [product_version] [ID=[product_id]]' , '

' , '
' , '[link_sent_to]' . '
' , '[remote_ip]' . '
' , '[user_agent]' . '
' , '[request_url]' . '
' , '

' , '
[product_summary]
[product_description]
' , '[product_expire_date] '. '
' , '

[current_date] [current_time]' ); $default_options[ 'opsd_email_download_notification' ] = $email_settings; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // C S V P R O D U C T S - F I L E S //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $default_options[ 'opsd_products_csv' ] = ''; if ( ! empty( $option_name ) ) { if ( isset( $default_options[ $option_name ] ) ) return $default_options[ $option_name ]; // Return 1 option else return false; // Option does NOT exist } else { return $default_options; // Return ALL } }