__('Send Link', 'secure-downloads') // Title of TAB , 'hint' => __('Send Link', 'secure-downloads') // Hint , 'page_title' => __('Send Link', 'secure-downloads') // Title of Page , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link , 'position' => '' // 'left' || 'right' || '' , 'css_classes' => '' // CSS class(es) , 'icon' => '' // Icon - link to the real PNG img , 'font_icon' => 'glyphicon glyphicon-th' // CSS definition of forn Icon , 'default' => true // Is this tab activated by default or not: true || false. , 'disabled' => false // Is this tab disbaled: true || false. , 'hided' => true // Is this tab hided: true || false. , 'subtabs' => array() ); // $subtabs = array(); // $tabs[ 'items' ][ 'subtabs' ] = $subtabs; return $tabs; } public function content() { // Checking //////////////////////////////////////////////////////////// do_action( 'opsd_hook_settings_page_header', array( 'page' => $this->in_page() ) ); // Define Notices Section and show some static messages, if needed. // $this->settings_api(); // Init Settings API & Get Data from DB // Define all fields and get values from DB // Submit ///////////////////////////////////////////////////////////// $submit_form_name = 'opsd_send_links_form'; // Define form name $data_after_update = false; if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) { // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. } $nonce_gen_time = check_admin_referer( 'opsd_settings_page_' . $submit_form_name ); // Its stop show anything on submiting, if its not refear to the original page // Save Changes $data_after_update = $this->update(); $updated_data = '';//$data_after_update['original_validated_data']; } else { $updated_data = ''; } //$opsd_user_role_master = get_opsd_option( 'opsd_user_role_master' ); // O L D W A Y: Get Fields Data // JavaScript: Tooltips, Popover, Datepick (js & css) ////////////////// echo ''; opsd_js_for_items_page(); echo ''; ?>
define_products_from_csv( $products_csv ); /** Array ( [id] => 0 [order] => 0 [ip] => 0.0.0.0 [ipl] => 0 [expire] => +1440 seconds [title] => Personal [size] => 3.45 [path] => XXXXXXXXXX/wpbc/personal.zip ), ... */ $products = $products_obj->get_products(); //$secret_link = opsd_get_secret_link( $products[0] ); // Get Secret Link // Warning - NO Products if ( $products_obj->get_products_count() == 0 ) { $notice_id = 'opsd_warning_no_products'; if ( ! opsd_section_is_dismissed( $notice_id ) ) { ?>
' . __( 'Warning!', 'secure-downloads' ) . ' '; printf( __( 'No products defined at %s menu page.', 'secure-downloads' ) , '' . '' . 'Secure Downloads > ' . __( 'Files', 'secure-downloads' ) . '' . '' ); ?>
0 ) && ( strpos( $products_csv, $opsd_csv_separator ) === false ) ) { $notice_id = 'opsd_warning_wrong_csv_separator'; if ( ! opsd_section_is_dismissed( $notice_id ) ) { ?>
' . __( 'Warning!', 'secure-downloads' ) . ' '; printf( __( 'Probabaly you have defined incorrect CSV separator at %s menu page.', 'secure-downloads' ) , '' . '' . __( 'Settings', 'secure-downloads' ) . '' . '' ); ?>
__( 'Please Select', 'secure-downloads' ) ); $is_group_open = false; //FixIn: 1.1.5 $selected_product_id = ( ! empty( $_GET[ 'product_id' ] ) ) ? intval( $_GET[ 'product_id' ] ) : 0 ; $check_name = ''; if ( ! empty( $_GET[ 'product_name' ] ) ) { $check_name = esc_js( $_GET[ 'product_name' ] ); } foreach ( $products as $product_arr ) { //FixIn: 1.1.5 if ( ( ! empty( $check_name ) ) && ( $product_arr['title'] == $check_name ) ) { //FixIn: 1.1.3.2 $selected_product_id = $product_arr['id']; } if ( count($product_arr) == 2 ) { //Group if ( $is_group_open ) { $options[ intval( microtime( false ) ) + wp_rand(100) ] = array( 'optgroup' => true, 'title' =>'', 'close' => true ) ; //FixIn: 1.1.2.3 } $options[ intval( microtime( false ) ) + wp_rand(100) ] = array( 'optgroup' => true, 'title' => $product_arr['title'], 'close' => false ) ; //FixIn: 1.1.2.3 $is_group_open = true; } else { // Regular option $options[ $product_arr['id'] ] = $product_arr['title'] . ' ~ ' . $product_arr['version_num']; } } //Close group, if opened if ( $is_group_open ) { $options[ intval( microtime( false ) ) + wp_rand(100) ] = array( 'optgroup' => true, 'title' =>'', 'close' => true ) ; //FixIn: 1.1.2.3 } $fields = array( 'title' => '' , 'label' => '' , 'disabled' => false , 'disabled_options' => array() , 'class' => 'opsd_product_selection' , 'css' => '' , 'type' => 'select' , 'description' => '' , 'multiple' => ! true , 'attr' => array( 'size' => 1 ) , 'options' => $options , 'group' => 'general' , 'tr_class' => '' , 'only_field' => true , 'description_tag' => 'span' , 'value' => ( ( ! empty( $selected_product_id ) ) ? intval( $selected_product_id ) : 1 ) //FixIn: 1.1.4 //FixIn: 1.1.5 ); OPSD_Settings_API::field_select_row_static( 'opsd_product_selection', $fields ); } do_action( 'opsd_secure_links_send_section_footer' ); ?> settings_api()->show( 'help' ); ?>
[email]') ?>
__('Default Expiration', 'secure-downloads') , '+5 minutes' => '5 ' . __('minutes', 'secure-downloads') , '+15 minutes' => '15 ' . __('minutes', 'secure-downloads') , '+30 minutes' => '30 ' . __('minutes', 'secure-downloads') , '+45 minutes' => '45 ' . __('minutes', 'secure-downloads') , '+1 hour' => '1 ' . __('hour', 'secure-downloads') , '+6 hours' => '6 ' . __('hours', 'secure-downloads') , '+12 hours' => '12 ' . __('hours', 'secure-downloads') , '+24 hours' => '24 ' . __('hours', 'secure-downloads') , '+3 days' => '3 ' . __('days', 'secure-downloads') , '+5 days' => '5 ' . __('days', 'secure-downloads') , '+7 days' => '7 ' . __('days', 'secure-downloads') , '+30 days' => '30 ' . __('days', 'secure-downloads') , '+90 days' => '90 ' . __('days', 'secure-downloads') , '+365 days' => '1 ' . __('year', 'secure-downloads') , '0' => __('Never', 'secure-downloads') //FixIn: 1.2.2.2 ); // Expire $fields = array( 'title' => __('Link expire after', 'secure-downloads') , 'label' => '' , 'disabled' => false , 'disabled_options' => array() , 'class' => '' , 'css' => '' , 'type' => 'select' , 'description' => '' , 'multiple' => false , 'attr' => array() , 'options' => $options , 'group' => 'advanced' , 'tr_class' => '' , 'only_field' => false , 'description_tag' => 'span' , 'value' => get_opsd_option( 'opsd_defualt_expiration' ) //array( '+24 hours' ) ); OPSD_Settings_API::field_select_row_static( 'opsd_product_expire', $fields ); // IP lock $fields = array( 'title' => __( 'IP Lock', 'secure-downloads') , 'disabled' => false , 'class' => '' , 'css' => 'width:100%;' , 'placeholder' => '0.0.0.0' , 'description' => '' , 'attr' => array() , 'group' => 'advanced' , 'tr_class' => '' , 'only_field' => false , 'description_tag' => 'p' , 'validate_as' => array() , 'value' => get_opsd_option( 'opsd_defualt_iplock' ) ); OPSD_Settings_API::field_text_row_static( 'opsd_product_ip_lock', $fields ); ?>
'' , 'label' => __('Send copy to administrator', 'secure-downloads') , 'type' => 'checkbox' , 'value' => ( ( $mail_api->fields_values['copy_to_admin'] == 'On' ) ? 'On' : 'Off' ) , 'class' => '' , 'css' => '' , 'group' => 'advanced' , 'only_field' => true ); OPSD_Settings_API::field_checkbox_row_static( $field_name, $field ); ?>
js(); $this->css(); do_action( 'opsd_hook_settings_page_footer', 'send_links' ); } public function update() { $post_action_key = 'opsd_action'; if ( isset( $_POST[ $post_action_key ] ) && ( $_POST[ $post_action_key ] == 'go_send' ) ) { // Get Validated post $validated = array(); // Email $validated['opsd_email_to'] = OPSD_Settings_API::validate_email_post_static( 'opsd_email_to' ); // Is send copy to admin $validated['send_copy_to_admin'] = OPSD_Settings_API::validate_checkbox_post_static( 'send_copy_to_admin' ); // Products $validated['opsd_product_selection'] = OPSD_Settings_API::validate_select_post_static( 'opsd_product_selection' ); // Expire $validated['opsd_product_expire'] = OPSD_Settings_API::validate_select_post_static( 'opsd_product_expire' ); // IP lock $validated['opsd_product_ip_lock'] = OPSD_Settings_API::validate_text_post_static( 'opsd_product_ip_lock' ); // Check if we selected custom email template and need to send email even if the product was not selected $validated['continue_without_product'] = false; $validated = apply_filters( 'opsd_send_secure_links_validate_fields', $validated ); //Hook for validated fields. $response = opsd_send_secure_download_email_to_user( $validated ); //FixIn: 1.1.3.2 //debuge($response); $sent_summary_content = ''; switch ( $response[ 'status' ] ) { case 'error': if ( 'select_valid_product' == $response[ 'error_type' ] ) { opsd_show_fixed_message( __( 'Select valid product', 'secure-downloads' ), 3, 'updated error' ); // Show Message } break; case 'email_sent': // Get Summary about sending email and generating link ... $sent_summary_content = $this->get_sent_summary( $response['mail_api'], $response['product_replace'], $validated ); opsd_show_fixed_message ( __('Email sent to', 'secure-downloads') . ' ' . $validated['opsd_email_to'], 3 ); // Show Message break; case 'link_generated': // Get Summary about sending email and generating link ... $sent_summary_content = $this->get_sent_summary( $response['mail_api'], $response['product_replace'], $validated ); opsd_show_fixed_message ( __('Link generated', 'secure-downloads'), 3 ); // Show Message break; default: // Default } // Reload page after sending. Stop from sending once again, if refresh browser in mobile browser after some time ?> $validated, 'sent_summary_content' => $sent_summary_content ); // Exit, for do not parse } /* //$validated_fields = $this->settings_api()->validate_post(); // Get Validated Settings fields in $_POST request. //$validated_fields = apply_filters( 'opsd_settings_validate_fields_before_saving', $validated_fields ); //Hook for validated fields. // Skip saving specific option, for example in Demo mode. // unset($validated_fields['opsd_start_day_weeek']); //$this->settings_api()->save_to_db( $validated_fields ); // Save fields to DB //opsd_show_changes_saved_message(); //opsd_show_fixed_message ( __('Done', 'secure-downloads'), 0 ); // Show Message // O L D W A Y: Saving Fields Data // update_opsd_option( 'opsd_is_delete_if_deactive' // , OPSD_Settings_API::validate_checkbox_post('opsd_is_delete_if_deactive') ); // ( (isset( $_POST['opsd_is_delete_if_deactive'] ))?'On':'Off') ); */ return false; } public function get_sent_summary( $mail_api, $replace, $validated ) { if ( false === $mail_api ) { // Email disabled $mail_api = new OPSD_Emails_API_LinkUser( OPSD_EMAIL_LINK_USER_ID ); } // Parse for getting email content ///////////////////////////////// $mail_api->set_replace( $replace ); $content_email = $mail_api->get_content(); $subject_email = $mail_api->get_subject(); $mail_api->set_replace(); // Reset Email $pos = strpos($content_email, '', ++$pos ); $content_email = substr($content_email, ++$pos ); } //////////////////////////////////////////////////////////////////// ob_start(); opsd_open_meta_box_section( 'opsd_sent_summary', __('Summary', 'secure-downloads') ); //debuge($validated,$replace); ?> __( 'Link', 'secure-downloads') , 'disabled' => false , 'class' => '' , 'css' => 'width:100%;' , 'placeholder' => '' , 'description' => '' , 'attr' => array() , 'group' => 'advanced' , 'tr_class' => 'opsd_tr_more_margin' , 'only_field' => false , 'description_tag' => 'p' , 'validate_as' => array() , 'value' => ( isset( $replace[ 'product_link' ] ) ) ? $replace['product_link'] : '' ); OPSD_Settings_API::field_text_row_static( 'opsd_sent_summary_link', $fields ); // email $fields = array( 'title' => __( 'To', 'secure-downloads') , 'disabled' => false , 'class' => '' , 'css' => 'width:100%;' , 'placeholder' => '' , 'description' => '' , 'attr' => array() , 'group' => 'advanced' , 'tr_class' => '' , 'only_field' => false , 'description_tag' => 'p' , 'validate_as' => array() , 'value' => $validated['opsd_email_to'] ); OPSD_Settings_API::field_text_row_static( 'opsd_sent_summary_email', $fields ); // email $fields = array( 'title' => __( 'Subject', 'secure-downloads') , 'disabled' => false , 'class' => '' , 'css' => 'width:100%;' , 'placeholder' => '0.0.0.0' , 'description' => '' , 'attr' => array() , 'group' => 'advanced' , 'tr_class' => '' , 'only_field' => false , 'description_tag' => 'p' , 'validate_as' => array() , 'value' => $subject_email ); OPSD_Settings_API::field_text_row_static( 'opsd_sent_summary_subject', $fields ); $field = array( 'title' => '', 'disabled' => false, 'class' => '', 'css' => '', 'placeholder' => '', 'type' => 'text', 'description' => '', 'attr' => array(), 'rows' => 10, 'cols' => 20, 'teeny' => true, 'show_visual_tabs' => true, 'default_editor' => 'tinymce', // 'tinymce' | 'html' // 'html' is used for the "Text" editor tab. 'drag_drop_upload' => false, 'show_in_2_cols' => true, 'group' => 'general', 'tr_class' => '', 'only_field' => false, 'description_tag' => 'p' , 'value' => $content_email ); $email_content = OPSD_Settings_API::field_wp_textarea_row_static( 'show_email_content' , $field ); ?>
' . $validated['opsd_email_to'] . ' - '; //echo ( $validated['send_copy_to_admin'] == 'On' ) ? ' [' . __('copy to administrator' , 'secure-downloads') . ']' : ''; if ( ( isset( $replace[ 'product_summary' ] ) ) && ( isset( $replace[ 'product_expire_date' ] ) ) ) echo $replace['product_summary'] . ' ' . $replace['product_expire_date'] . ''; ?>